Skip to content

Commit

Permalink
Release 53.3.0 (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitlokhandeanyline authored Aug 14, 2024
1 parent 7f4ecb5 commit 0fab5b7
Show file tree
Hide file tree
Showing 20 changed files with 297 additions and 231 deletions.
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 = "53.0.0"
anyline_sdk_version = "53.3.0"
kotlin_version = "1.8.0"
}
repositories {
Expand Down
10 changes: 6 additions & 4 deletions android/src/main/java/io/anyline/flutter/AnylinePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
}
} else if (call.method.equals(Constants.METHOD_START_ANYLINE)) {
this.configJson = call.argument(Constants.EXTRA_CONFIG_JSON);
scanAnyline4();
String initializationParametersString = call.argument(Constants.EXTRA_INITIALIZATION_PARAMETERS);
scanAnyline4(initializationParametersString);
} else if (call.method.equals(Constants.METHOD_EXPORT_CACHED_EVENTS)) {
exportCachedEvents();
} else {
Expand All @@ -115,20 +116,21 @@ private void initSdk(String sdkLicenseKey,
AnylineSdk.init(sdkLicenseKey, activity, sdkAssetsFolder, cacheConfig, wrapperConfig);
}

private void scanAnyline4() {
private void scanAnyline4(String initializationParametersString) {
try {
configObject = new JSONObject(this.configJson);
scan();
scan(initializationParametersString);
} catch (JSONException e) {
e.printStackTrace();
returnError(Constants.EXCEPTION_CONFIG, e.getLocalizedMessage());
}
}

private void scan() {
private void scan(String initializationParameters) {
Intent intent = new Intent(activity, ScanActivity.class);
intent.putExtra(Constants.EXTRA_VIEW_CONFIGS_PATH, viewConfigsPath);
intent.putExtra(Constants.EXTRA_CONFIG_JSON, configObject.toString());
intent.putExtra(Constants.EXTRA_INITIALIZATION_PARAMETERS, initializationParameters);
ResultReporter.setListener(this);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Expand Down
1 change: 1 addition & 0 deletions android/src/main/java/io/anyline/flutter/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Constants {

public static final String EXTRA_CONFIG_JSON = "EXTRA_CONFIG_JSON";
public static final String EXTRA_LICENSE_KEY = "EXTRA_LICENSE_KEY";
public static final String EXTRA_INITIALIZATION_PARAMETERS = "EXTRA_INITIALIZATION_PARAMETERS";
public static final String EXTRA_ENABLE_OFFLINE_CACHE = "EXTRA_ENABLE_OFFLINE_CACHE";
public static final String EXTRA_PLUGIN_VERSION = "EXTRA_PLUGIN_VERSION";
public static final String EXTRA_CUSTOM_MODELS_PATH = "EXTRA_CUSTOM_MODELS_PATH";
Expand Down
152 changes: 82 additions & 70 deletions android/src/main/java/io/anyline/flutter/ScanActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.anyline.flutter;

import static io.anyline2.sdk.extension.ScanViewInitializationParametersExtensionKt.getScanViewInitializationParametersFromJsonObject;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
Expand Down Expand Up @@ -28,7 +30,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.anyline.plugin.config.BarcodeFormat;
import io.anyline.plugin.config.ScanViewInitializationParameters;
import io.anyline.plugin.result.Barcode;
import io.anyline.plugin.result.BarcodeResult;
import io.anyline2.Event;
Expand All @@ -48,6 +52,7 @@ public class ScanActivity extends Activity implements CameraOpenListener,

protected String viewConfigsPath = "";
protected String configString;
protected String initializationParametersString;

private ScanView anylineScanView;
private RadioGroup radioGroup = null;
Expand All @@ -69,6 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {

viewConfigsPath = getIntent().getStringExtra(Constants.EXTRA_VIEW_CONFIGS_PATH);
configString = getIntent().getStringExtra(Constants.EXTRA_CONFIG_JSON);
initializationParametersString = getIntent().getStringExtra(Constants.EXTRA_INITIALIZATION_PARAMETERS);

setContentView(R.layout.activity_scan_scanview);

Expand All @@ -80,12 +86,7 @@ protected void onCreate(Bundle savedInstanceState) {
defaultOrientationApplied = savedInstanceState.getBoolean(KEY_DEFAULT_ORIENTATION_APPLIED);
}

try {
initScanView();
} catch (Exception ex) {
ex.printStackTrace();
}

initScanView();
setDebugListener();
}

Expand Down Expand Up @@ -204,7 +205,7 @@ public void eventReceived(Pair<AnylineYuvImage, BarcodeResult> anylineYuvImageBa
if (nativeBarcodeMap == null) {
nativeBarcodeMap = new HashMap<>();
}
for (Barcode barcode: anylineYuvImageBarcodeResultPair.second.getBarcodes()) {
for (Barcode barcode : anylineYuvImageBarcodeResultPair.second.getBarcodes()) {
nativeBarcodeMap.put(barcode.getValue(), barcode);
}
}
Expand All @@ -227,89 +228,100 @@ private void setScanConfig(String viewConfigAssetFileName) {
}

private void setScanConfig(JSONObject scanConfigJson, String viewConfigAssetFileName) {
configJson = scanConfigJson;
optionsJson = configJson.optJSONObject("options");

anylineScanView.getCameraView().removeNativeBarcodeReceivedEventListener(this);
nativeBarcodeMap = null;

anylineScanView.init(scanConfigJson);
try {
configJson = scanConfigJson;
optionsJson = configJson.optJSONObject("options");

ViewPluginBase viewPluginBase = anylineScanView.getScanViewPlugin();
if (viewPluginBase != null) {
anylineScanView.getCameraView().removeNativeBarcodeReceivedEventListener(this);
nativeBarcodeMap = null;

ScanViewPlugin scanViewPlugin = viewPluginBase.getFirstActiveScanViewPlugin();
if (initializationParametersString != null) {
ScanViewInitializationParameters scanViewInitializationParameters = getScanViewInitializationParametersFromJsonObject(this, new JSONObject(initializationParametersString));
anylineScanView.init(scanConfigJson, scanViewInitializationParameters);
} else {
anylineScanView.init(scanConfigJson);
}

viewPluginBase.resultReceived = scanResult -> {
setResult(scanViewPlugin, AnylinePluginHelper.jsonHelper(scanResult, nativeBarcodeMap).toString());
};

viewPluginBase.resultsReceived = scanResults -> {
JSONObject jsonResult = new JSONObject();
for (ScanResult scanResult: scanResults) {
try {
jsonResult.put(scanResult.getPluginId(), AnylinePluginHelper.jsonHelper(scanResult, nativeBarcodeMap));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
setResult(scanViewPlugin, jsonResult.toString());
};
ViewPluginBase viewPluginBase = anylineScanView.getScanViewPlugin();
if (viewPluginBase != null) {

anylineScanView.onCutoutChanged = pairs -> {
if (anylineUIConfig != null && anylineUIConfig.hasSegmentConfig) {
if (!pairs.isEmpty()) {
Rect rect = pairs.get(0).second;
ScanViewPlugin scanViewPlugin = viewPluginBase.getFirstActiveScanViewPlugin();

CoordinatorLayout.LayoutParams segmentLayoutParams =
new CoordinatorLayout.LayoutParams(rect.width(), anylineScanView.getHeight() - rect.bottom);
segmentLayoutParams.setMargins(rect.left, rect.bottom, rect.right, anylineScanView.getBottom());
radioGroup.setLayoutParams(segmentLayoutParams);
viewPluginBase.resultReceived = scanResult -> {
setResult(scanViewPlugin, AnylinePluginHelper.jsonHelper(scanResult, nativeBarcodeMap).toString());
};

radioGroup.setVisibility(View.VISIBLE);
viewPluginBase.resultsReceived = scanResults -> {
JSONObject jsonResult = new JSONObject();
for (ScanResult scanResult : scanResults) {
try {
jsonResult.put(scanResult.getPluginId(), AnylinePluginHelper.jsonHelper(scanResult, nativeBarcodeMap));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
else {
radioGroup.setVisibility(View.GONE);
setResult(scanViewPlugin, jsonResult.toString());
};

anylineScanView.onCutoutChanged = pairs -> {
if (anylineUIConfig != null && anylineUIConfig.hasSegmentConfig) {
if (!pairs.isEmpty()) {
Rect rect = pairs.get(0).second;

CoordinatorLayout.LayoutParams segmentLayoutParams =
new CoordinatorLayout.LayoutParams(rect.width(), anylineScanView.getHeight() - rect.bottom);
segmentLayoutParams.setMargins(rect.left, rect.bottom, rect.right, anylineScanView.getBottom());
radioGroup.setLayoutParams(segmentLayoutParams);

radioGroup.setVisibility(View.VISIBLE);
} else {
radioGroup.setVisibility(View.GONE);
}
}
}
};

if (optionsJson != null) {
if (optionsJson.has("nativeBarcodeScanningFormats")) {
List<BarcodeFormat> barcodeFormatsList = new ArrayList<>();
JSONArray barcodeFormatsJsonArray = optionsJson.optJSONArray("nativeBarcodeScanningFormats");
for (int i = 0; i < barcodeFormatsJsonArray.length(); i++) {
try {
barcodeFormatsList.add(BarcodeFormat.valueOf(barcodeFormatsJsonArray.getString(i)));
} catch (Exception e) {

};

if (optionsJson != null) {
if (optionsJson.has("nativeBarcodeScanningFormats")) {
List<BarcodeFormat> barcodeFormatsList = new ArrayList<>();
JSONArray barcodeFormatsJsonArray = optionsJson.optJSONArray("nativeBarcodeScanningFormats");
for (int i = 0; i < barcodeFormatsJsonArray.length(); i++) {
try {
barcodeFormatsList.add(BarcodeFormat.valueOf(barcodeFormatsJsonArray.getString(i)));
} catch (Exception e) {

}
}
anylineScanView.getCameraView().addNativeBarcodeReceivedEventListener(this, barcodeFormatsList);
}
anylineScanView.getCameraView().addNativeBarcodeReceivedEventListener(this, barcodeFormatsList);
}
}
}

layoutChangeOrientation.setVisibility(View.GONE);
if (optionsJson != null) {
if (shouldShowRotateButton(optionsJson)) {
try {
RotateButtonConfig rotateButtonConfig = new RotateButtonConfig(optionsJson.getJSONObject("rotateButton"));
configRotateButtonInView(rotateButtonConfig);
} catch (JSONException e) {
layoutChangeOrientation.setVisibility(View.GONE);
if (optionsJson != null) {
if (shouldShowRotateButton(optionsJson)) {
try {
RotateButtonConfig rotateButtonConfig = new RotateButtonConfig(optionsJson.getJSONObject("rotateButton"));
configRotateButtonInView(rotateButtonConfig);
} catch (JSONException e) {

}
}
}

setDefaultOrientation();
setDefaultOrientation();

if (optionsJson.has("segmentConfig")) {
// create the radio button for the UI
addSegmentRadioButtonUI(optionsJson, viewConfigAssetFileName);
}
else {
radioGroup.setVisibility(View.GONE);
if (optionsJson.has("segmentConfig")) {
// create the radio button for the UI
addSegmentRadioButtonUI(optionsJson, viewConfigAssetFileName);
} else {
radioGroup.setVisibility(View.GONE);
}
}
} catch (Exception e) {
finishWithError(
getString(getResources().getIdentifier("error_invalid_initialization_parameters", "string", getPackageName()))
+ "\n" + e.getLocalizedMessage());
}
}

Expand Down
1 change: 1 addition & 0 deletions android/src/main/res/values/anyline_sdk_plugin_strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="error_unkown_scan_mode">Unkown scan mode: </string>
<string name="error_invalid_json_data">Config json is invalid.</string>
<string name="error_invalid_initialization_parameters">Initialization parameters is invalid.</string>
<string name="error_invalid_segment_config">Semgent config not valid. Must have equal amount of titles and modes.</string>
<string name="error_accessing_camera">Error while accessing camera.</string>
<string name="error_licence_invalid">Error: Anyline license invalid.</string>
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Anyline (53.0.0)
- Anyline (53.3.0)
- anyline_plugin (53.0.0):
- Anyline (~> 53)
- Flutter
Expand Down Expand Up @@ -37,7 +37,7 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"

SPEC CHECKSUMS:
Anyline: 24167878dda34930abdf3f0d8665cbcc4204b3cb
Anyline: d076ffac04ccf43a281ac6a6dd5230630c7e260c
anyline_plugin: 1f62863478c6660d2f40144e31e1b74b215ac721
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 53.0.0;
MARKETING_VERSION = 53.3.0;
PRODUCT_BUNDLE_IDENTIFIER = io.anyline.flutter.examples;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -545,7 +545,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 53.0.0;
MARKETING_VERSION = 53.3.0;
PRODUCT_BUNDLE_IDENTIFIER = io.anyline.flutter.examples;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -578,7 +578,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 53.0.0;
MARKETING_VERSION = 53.3.0;
PRODUCT_BUNDLE_IDENTIFIER = io.anyline.flutter.examples;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
1 change: 1 addition & 0 deletions example/lib/anyline_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class AnylineService {
List<Result> getResultList();

String? getSdkVersion();

String? getPluginVersion();
}

Expand Down
Loading

0 comments on commit 0fab5b7

Please sign in to comment.