Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

# 55.8.1
# 55.9.0




Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version '1.0'

buildscript {
ext {
anyline_sdk_version = '55.8.1'
anyline_sdk_version = '55.9.0'
kotlin_version = "1.8.0"
}
repositories {
Expand Down
29 changes: 29 additions & 0 deletions android/src/main/java/io/anyline/flutter/AnylinePlugin.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package io.anyline.flutter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.List;

import io.anyline.flutter.nativeview.NativeFragmentContainerFactory;
import io.anyline.flutter.nativeview.NativeViewRegistry;
import io.anyline.plugin.config.UIFeedbackElementConfig;
import io.anyline.plugin.result.ExportedScanResult;
import io.anyline.wrapper.config.WrapperSessionExportCachedEventsResponse;
Expand Down Expand Up @@ -73,6 +77,8 @@ public class AnylinePlugin implements
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
onAttachedToEngine(flutterPluginBinding.getApplicationContext(), flutterPluginBinding.getBinaryMessenger());
flutterPluginBinding.getPlatformViewRegistry().registerViewFactory(
Constants.ANYLINE_NATIVE_VIEW_FACTORY_ID, new NativeFragmentContainerFactory());
}

private void onAttachedToEngine(Context applicationContext, BinaryMessenger messenger) {
Expand Down Expand Up @@ -103,13 +109,18 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
call.argument(Constants.EXTRA_LICENSE_KEY),
customModelsPath,
Boolean.TRUE.equals(call.argument(Constants.EXTRA_ENABLE_OFFLINE_CACHE)));
} else if (call.method.equals(Constants.METHOD_SET_DEFAULT_SCAN_START_PLATFORM_OPTIONS)) {
setDefaultScanStartPlatformOptions(call.argument(Constants.EXTRA_DEFAULT_SCAN_START_PLATFORM_OPTIONS), result);
} else if (call.method.equals(Constants.METHOD_START_ANYLINE)) {
startScanMethodResult = result;
routeScanMode(
call.argument(Constants.EXTRA_CONFIG_JSON),
call.argument(Constants.EXTRA_INITIALIZATION_PARAMETERS),
viewConfigsPath,
call.argument(Constants.EXTRA_SCAN_CALLBACK_CONFIG));
} else if (call.method.equals(Constants.METHOD_REPLACE_ANYLINE)) {
requestScanSwitchWithScanViewConfigContentString(
call.argument(Constants.EXTRA_CONFIG_JSON));
} else if (call.method.equals(Constants.METHOD_STOP_ANYLINE)) {
tryStopScan(call.argument(Constants.EXTRA_STOP_CONFIG));
} else if (call.method.equals(Constants.METHOD_EXPORT_CACHED_EVENTS)) {
Expand All @@ -135,6 +146,11 @@ private void setupWrapperSession(final String pluginVersion) {
return this.context;
}

@Override
public @Nullable ViewGroup getContainerView() {
return (ViewGroup) NativeViewRegistry.getLastOrNull();
}

private void initSdk(String sdkLicenseKey,
String sdkAssetsFolder,
boolean enableOfflineCache) {
Expand Down Expand Up @@ -163,6 +179,15 @@ public void onSdkInitializationResponse(@NotNull WrapperSessionSdkInitialization
}
}

private void setDefaultScanStartPlatformOptions(final String scanStartPlatformOptionsString, @NonNull Result resultListener) {
try {
WrapperSessionProvider.setDefaultScanStartPlatformOptions(scanStartPlatformOptionsString);
returnSuccess(resultListener, "");
} catch (Exception e) {
returnDefaultError(resultListener, e.getMessage());
}
}

private void routeScanMode(
String scanViewConfigContent,
String scanViewInitializationParametersString,
Expand Down Expand Up @@ -192,6 +217,10 @@ private void routeScanMode(
ResultReporter.setListener(this);
}

private void requestScanSwitchWithScanViewConfigContentString(String scanViewConfigContent) {
WrapperSessionProvider.requestScanSwitchWithScanViewConfigContentString(scanViewConfigContent);
}

@Override
public void onScanResults(@NotNull WrapperSessionScanResultsResponse scanResultsResponse) {
WrapperSessionScanResultConfig scanResultConfig = scanResultsResponse.getScanResultConfig();
Expand Down
5 changes: 5 additions & 0 deletions android/src/main/java/io/anyline/flutter/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ public class Constants {
public static final String METHOD_SET_CUSTOM_MODELS_PATH = "METHOD_SET_CUSTOM_MODELS_PATH";
public static final String METHOD_SET_VIEW_CONFIGS_PATH = "METHOD_SET_VIEW_CONFIGS_PATH";
public static final String METHOD_SET_LICENSE_KEY = "METHOD_SET_LICENSE_KEY";
public static final String METHOD_SET_DEFAULT_SCAN_START_PLATFORM_OPTIONS = "METHOD_SET_DEFAULT_SCAN_START_PLATFORM_OPTIONS";
public static final String METHOD_START_ANYLINE = "METHOD_START_ANYLINE";
public static final String METHOD_REPLACE_ANYLINE = "METHOD_REPLACE_ANYLINE";
public static final String METHOD_STOP_ANYLINE = "METHOD_STOP_ANYLINE";
public static final String METHOD_EXPORT_CACHED_EVENTS = "METHOD_EXPORT_CACHED_EVENTS";
public static final String METHOD_REPORT_UCR = "METHOD_REPORT_UCR";
Expand All @@ -19,6 +21,7 @@ public class Constants {
public static final String EXTRA_PLUGIN_VERSION = "EXTRA_PLUGIN_VERSION";
public static final String EXTRA_CUSTOM_MODELS_PATH = "EXTRA_CUSTOM_MODELS_PATH";
public static final String EXTRA_VIEW_CONFIGS_PATH = "EXTRA_VIEW_CONFIGS_PATH";
public static final String EXTRA_DEFAULT_SCAN_START_PLATFORM_OPTIONS = "EXTRA_DEFAULT_SCAN_START_PLATFORM_OPTIONS";
public static final String EXTRA_SCAN_CALLBACK_CONFIG = "EXTRA_SCAN_CALLBACK_CONFIG";
public static final String EXTRA_STOP_CONFIG = "EXTRA_STOP_CONFIG";
public static final String EXTRA_REPORT_UCR_BLOBKEY = "EXTRA_REPORT_UCR_BLOBKEY";
Expand All @@ -32,4 +35,6 @@ public class Constants {
public static final int RESULT_CANCELLED = 0;
public static final int RESULT_OK = 1;
public static final int RESULT_ERROR = 2;

public static final String ANYLINE_NATIVE_VIEW_FACTORY_ID = "AnylineNativeView";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

package io.anyline.flutter.nativeview;

import android.content.Context;

import androidx.annotation.NonNull;

import io.flutter.plugin.platform.PlatformView;
import io.flutter.plugin.platform.PlatformViewFactory;
import io.flutter.plugin.common.StandardMessageCodec;
import java.util.Map;

public class NativeFragmentContainerFactory extends PlatformViewFactory {
public NativeFragmentContainerFactory() {
super(StandardMessageCodec.INSTANCE);
}

@NonNull
@Override
public PlatformView create(Context context, int viewId, Object args) {
return new NativeFragmentContainerView(context, viewId, (Map<String, Object>) args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

package io.anyline.flutter.nativeview;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.PixelFormat;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import io.flutter.plugin.platform.PlatformView;
import java.util.Map;

public class NativeFragmentContainerView implements PlatformView {
private final FrameLayout container;
private final String containerId;

NativeFragmentContainerView(Context context, int id, Map<String, Object> args) {
container = new FrameLayout(context);
container.setLayoutParams(
new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_APPLICATION,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
PixelFormat.TRANSLUCENT
));

container.isHardwareAccelerated();

container.setId(View.generateViewId());

containerId = String.valueOf(container.getId());

NativeViewRegistry.register(containerId, container);
}

@Override
public View getView() {
return container;
}

@Override
public void dispose() {
NativeViewRegistry.remove(containerId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

package io.anyline.flutter.nativeview;

import android.view.View;

import java.util.HashMap;
import java.util.Map;

public class NativeViewRegistry {
private static final Map<String, View> registry = new HashMap<>();

private NativeViewRegistry () {
//empty constructor
}

public static void register(String id, View view) {
registry.put(id, view);
}

public static View get(String id) {
return registry.get(id);
}

public static View getLastOrNull() {
if (registry.isEmpty()) {
return null;
} else {
return (View) registry.values().toArray()[registry.size() - 1];
}
}

public static void remove(String id) {
registry.remove(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.anyline.flutter.examples;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.android.FlutterFragmentActivity;

public class MainActivity extends FlutterActivity {
public class MainActivity extends FlutterFragmentActivity {
}
74 changes: 74 additions & 0 deletions example/config/NativeViewBarcodeConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"options": {

},
"flashConfig": {
"mode": "manual_off",
"alignment": "top_left"
},
"viewPluginConfig": {
"pluginConfig": {
"id": "barcode_all",
"barcodeConfig": {
"fastProcessMode": true,
"parseAAMVA": false,
"barcodeFormats": [
"ALL"
]
},
"consecutiveEqualResultFilter": -1,
"cancelOnResult": false,
"startScanDelay": 1000
},
"cutoutConfig": {
"animation": "none",
"maxWidthPercent": "70%",
"maxHeightPercent": "70%",
"alignment": "center",
"ratioFromSize": {
"width": 3,
"height": 2
},
"offset": {
"x": 0,
"y": 0
},
"cropOffset": {
"x": 0,
"y": 0
},
"cropPadding": {
"x": 0,
"y": 0
},
"cornerRadius": 4,
"strokeColor": "0099ff",
"strokeWidth": 2,
"outerColor": "000000",
"feedbackStrokeColor": "0099FF",
"outerAlpha": 0.3
},
"scanFeedbackConfig": {
"style": "rect",
"strokeWidth": 0,
"strokeColor": "0099FF",
"fillColor": "330099FF",
"beepOnResult": false,
"vibrateOnResult": false,
"blinkAnimationOnResult": false
},
"uiFeedbackConfig": {
"presets": [
{
"presetName": "simple_instruction_label",
"presetAttributes": [
{
"attributeName": "instruction_text",
"attributeValue": "Scanning different barcodes."
}
]
}
]
}
}
}
Loading