Skip to content

Commit d074d76

Browse files
authored
UPDATE flutter-hms-scan 2.1.0+300
1 parent 898cc53 commit d074d76

File tree

63 files changed

+616
-626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+616
-626
lines changed

Diff for: flutter-hms-scan/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.0.300
2+
* Nullsafety migration.
3+
* Scan Kit SDK is updated to the newest version.
4+
15
## 1.3.0.300
26
* Scan Kit SDK is updated to the newest version.
37
* [**Breaking Change**] HmsCustomizedView.startCustomizedView doesn't return ScanResponse anymore. All ScanResponse objects can be listenable from customizedCameraListener callback on CustomizedViewRequest.

Diff for: flutter-hms-scan/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ android {
4141
}
4242

4343
dependencies{
44-
implementation 'com.huawei.hms:scan:1.3.0.300'
44+
implementation 'com.huawei.hms:scan:2.1.0.300'
4545
implementation 'com.huawei.hms:hianalytics:5.1.0.301'
4646
implementation 'android.arch.lifecycle:common:1.1.1'
4747
implementation 'com.google.code.gson:gson:2.8.5'

Diff for: flutter-hms-scan/android/src/main/java/com/huawei/hms/flutter/scan/ScanPlugin.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class ScanPlugin implements FlutterPlugin, ActivityAware {
5454
private MethodChannel remoteViewChannel;
5555

5656
private void initChannels(final BinaryMessenger messenger) {
57-
//init channels
57+
// init channels
5858
permissionChannel = new MethodChannel(messenger, "permissionChannel");
5959
scanUtilsChannel = new MethodChannel(messenger, "scanUtilsChannel");
6060
multiProcessorChannel = new MethodChannel(messenger, "multiProcessorChannel");
@@ -103,7 +103,7 @@ private void removeHandlers() {
103103
}
104104

105105
private void removeChannels() {
106-
//remove channels
106+
// remove channels
107107
permissionChannel = null;
108108
scanUtilsChannel = null;
109109
multiProcessorChannel = null;

Diff for: flutter-hms-scan/android/src/main/java/com/huawei/hms/flutter/scan/customizedview/CustomizedViewActivity.java

+21-18
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ public class CustomizedViewActivity extends Activity {
6969
boolean continuouslyScan;
7070
Intent intent;
7171

72-
//Flash button image
72+
// Flash button image
7373
private int[] img = {R.drawable.flashlight_on, R.drawable.flashlight_off};
7474

75-
//Declare the key. It is used to obtain the value returned from Scan Kit.
75+
// Declare the key. It is used to obtain the value returned from Scan Kit.
7676
public static final int REQUEST_CODE_PHOTO = 0X1113;
7777

7878
@Override
7979
protected void onCreate(Bundle savedInstanceState) {
8080
super.onCreate(savedInstanceState);
81-
//HMS Logger
81+
// HMS Logger
8282
mHMSLogger = HMSLogger.getInstance(this.getApplicationContext());
8383
intent = getIntent();
84-
//Window options.
84+
// Window options.
8585
requestWindowFeature(Window.FEATURE_NO_TITLE);
8686
setContentView(R.layout.activity_defined);
8787

@@ -102,10 +102,10 @@ protected void onCreate(Bundle savedInstanceState) {
102102
ImageView scanFrame = findViewById(R.id.scan_area);
103103
flashButton = findViewById(R.id.flush_btn);
104104

105-
//1. Obtain the screen density to calculate the viewfinder's rectangle.
105+
// 1. Obtain the screen density to calculate the viewfinder's rectangle.
106106
DisplayMetrics dm = getResources().getDisplayMetrics();
107107
float density = dm.density;
108-
//2. Obtain the screen size.
108+
// 2. Obtain the screen size.
109109
mScreenWidth = dm.widthPixels;
110110
mScreenHeight = dm.heightPixels;
111111

@@ -115,8 +115,8 @@ protected void onCreate(Bundle savedInstanceState) {
115115
int scanFrameSizeHeight = (int) (SCAN_FRAME_SIZE_HEIGHT * density);
116116
int scanFrameSizeWidth = (int) (SCAN_FRAME_SIZE_WIDTH * density);
117117

118-
//3. Calculate the viewfinder's rectangle, which in the middle of the layout.
119-
//Set the scanning area. (Optional. Rect can be null. If no settings are specified, it will be located in the middle of the layout.)
118+
// 3. Calculate the viewfinder's rectangle, which in the middle of the layout.
119+
// Set the scanning area. (Optional. Rect can be null. If no settings are specified, it will be located in the middle of the layout.)
120120
Rect rect = new Rect();
121121
rect.left = mScreenWidth / 2 - scanFrameSizeWidth / 2;
122122
rect.right = mScreenWidth / 2 + scanFrameSizeWidth / 2;
@@ -126,10 +126,10 @@ protected void onCreate(Bundle savedInstanceState) {
126126
scanFrame.getLayoutParams().height = rect.height();
127127
scanFrame.getLayoutParams().width = rect.width();
128128

129-
//Continuously Scan option from Flutter.
129+
// Continuously Scan option from Flutter.
130130
continuouslyScan = intent.getExtras().getBoolean("continuouslyScan");
131131

132-
//Initialize the RemoteView instance, and set callback for the scanning result.
132+
// Initialize the RemoteView instance, and set callback for the scanning result.
133133
RemoteView.Builder builder = new RemoteView.Builder().setContext(this)
134134
.setBoundingBox(rect)
135135
.setContinuouslyScan(continuouslyScan)
@@ -141,7 +141,7 @@ protected void onCreate(Bundle savedInstanceState) {
141141
remoteView = builder.build();
142142
}
143143

144-
//Set Method Call Handler for pause and resume actions of remote view.
144+
// Set Method Call Handler for pause and resume actions of remote view.
145145
if (remoteViewChannel != null) {
146146
RemoteViewHandler remoteViewHandler = new RemoteViewHandler(remoteView, flashButton, mHMSLogger);
147147
remoteViewChannel.setMethodCallHandler(remoteViewHandler);
@@ -152,7 +152,7 @@ protected void onCreate(Bundle savedInstanceState) {
152152
remoteView.setOnResultCallback(new OnResultCallback() {
153153
@Override
154154
public void onResult(HmsScan[] result) {
155-
//Check the result.
155+
// Check the result.
156156
if (result == null || result.length == 0 || result[0] == null || TextUtils.isEmpty(result[0].getOriginalValue())) {
157157
return;
158158
}
@@ -193,7 +193,7 @@ public void onResult(HmsScan[] result) {
193193
// Set the back, photo scanning, and flashlight operations.
194194
setBackOperation();
195195

196-
//Flash button visibility
196+
// Flash button visibility
197197
flashButton.setVisibility(View.INVISIBLE);
198198

199199
// When the light is dim, this API is called back to display the flashlight switch.
@@ -213,20 +213,20 @@ public void onVisibleChanged(boolean visible) {
213213
mHMSLogger.sendSingleEvent("remoteView.setOnLightVisibleCallback");
214214
}
215215

216-
//Flash Button option from Flutter.
216+
// Flash Button option from Flutter.
217217
if (intent.getExtras().getBoolean("isFlashAvailable")) {
218218
flashButton.setVisibility(View.VISIBLE);
219219
setFlashOperation();
220220
}
221221

222-
//Gallery Button option from Flutter
222+
// Gallery Button option from Flutter
223223
if (intent.getExtras().getBoolean("gallery")) {
224224
galleryButton.setVisibility(View.VISIBLE);
225225
setPictureScanOperation();
226226
}
227227
}
228228

229-
//Gallery button
229+
// Gallery button
230230
private void setPictureScanOperation() {
231231
ImageView galleryButton = findViewById(R.id.img_btn);
232232
galleryButton.setOnClickListener(new View.OnClickListener() {
@@ -240,7 +240,7 @@ public void onClick(View v) {
240240
});
241241
}
242242

243-
//Normal flash button
243+
// Normal flash button
244244
private void setFlashOperation() {
245245
flashButton.setOnClickListener(new View.OnClickListener() {
246246
@Override
@@ -260,7 +260,7 @@ public void onClick(View v) {
260260
});
261261
}
262262

263-
//Back button
263+
// Back button
264264
private void setBackOperation() {
265265
ImageView backButton = findViewById(R.id.back_img);
266266
backButton.setOnClickListener(new View.OnClickListener() {
@@ -332,6 +332,9 @@ protected void onStop() {
332332

333333
/**
334334
* Handle the return results from the gallery.
335+
* @param requestCode requestCode
336+
* @param resultCode resultCode
337+
* @param data Intent
335338
*/
336339
@Override
337340
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

Diff for: flutter-hms-scan/android/src/main/java/com/huawei/hms/flutter/scan/customizedview/CustomizedViewMethodCallHandler.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
5656
}
5757

5858
private void customizedView(MethodCall call, MethodChannel.Result result) {
59-
//Arguments from call
59+
// Arguments from call
6060
int scanType = ValueGetter.getInt("scanType", call);
6161
List<Integer> additionalScanTypes = call.argument("additionalScanTypes");
6262
int[] scanTypesIntArray = null;
@@ -71,18 +71,18 @@ private void customizedView(MethodCall call, MethodChannel.Result result) {
7171
boolean continuouslyScan = ValueGetter.getBoolean("continuouslyScan", call);
7272
boolean enableReturnBitmap = ValueGetter.getBoolean("enableReturnBitmap", call);
7373

74-
//List<Integer> to int[]
74+
// List<Integer> to int[]
7575
if (additionalScanTypes != null) {
7676
scanTypesIntArray = ValueGetter.scanTypesListToArray(additionalScanTypes);
7777
}
7878

79-
//Intent
79+
// Intent
8080
Intent intent = new Intent(mActivity, CustomizedViewActivity.class);
8181

8282
intent.putExtra(Constants.CHANNEL_ID_KEY, customizedChannelId);
8383
intent.putExtra(Constants.CHANNEL_REMOTE_KEY, remoteChannelId);
8484

85-
//Intent extras
85+
// Intent extras
8686
intent.putExtra("scanType", scanType);
8787
if (additionalScanTypes != null) {
8888
intent.putExtra("additionalScanTypes", scanTypesIntArray);
@@ -96,7 +96,7 @@ private void customizedView(MethodCall call, MethodChannel.Result result) {
9696
intent.putExtra("continuouslyScan", continuouslyScan);
9797
intent.putExtra("enableReturnBitmap", enableReturnBitmap);
9898

99-
//Start intent for customized view
99+
// Start intent for customized view
100100
mActivity.startActivity(intent);
101101
result.success(true);
102102
}

Diff for: flutter-hms-scan/android/src/main/java/com/huawei/hms/flutter/scan/customizedview/RemoteViewHandler.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class RemoteViewHandler implements MethodChannel.MethodCallHandler {
4444
@Override
4545
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
4646
switch (call.method) {
47-
//remote view pause
47+
// remote view pause
4848
case "pause":
4949
mHMSLogger.startMethodExecutionTimer("remoteView.pauseContinuouslyScan");
5050
if (remoteView != null) {
@@ -56,7 +56,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
5656
Errors.remoteViewError.getErrorCode());
5757
}
5858
break;
59-
//remote view resume
59+
// remote view resume
6060
case "resume":
6161
mHMSLogger.startMethodExecutionTimer("remoteView.resumeContinuouslyScan");
6262
if (remoteView != null) {
@@ -68,7 +68,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
6868
Errors.remoteViewError.getErrorCode());
6969
}
7070
break;
71-
//Switch light
71+
// Switch light
7272
case "switchLight":
7373
mHMSLogger.startMethodExecutionTimer("remoteView.switchLight");
7474
if (remoteView != null) {
@@ -87,7 +87,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
8787
mHMSLogger.sendSingleEvent("remoteView.switchLight", Errors.remoteViewError.getErrorCode());
8888
}
8989
break;
90-
//get light status
90+
// get light status
9191
case "getLightStatus":
9292
mHMSLogger.startMethodExecutionTimer("remoteView.getLightStatus");
9393
if (remoteView != null) {

Diff for: flutter-hms-scan/android/src/main/java/com/huawei/hms/flutter/scan/logger/HMSLogger.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public final class HMSLogger {
4040

4141
private static final String PLATFORM = "Flutter";
4242

43-
private static final String VERSION = "1.3.0.300";
43+
private static final String VERSION = "1.3.1.300";
4444

4545
private static final String SERVICE = "Cross-Platform";
4646

Diff for: flutter-hms-scan/android/src/main/java/com/huawei/hms/flutter/scan/multiprocessor/MultiProcessorActivity.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ protected void onCreate(Bundle savedInstanceState) {
7979
super.onCreate(savedInstanceState);
8080
Window window = getWindow();
8181

82-
//HMS Logger
82+
// HMS Logger
8383
mHMSLogger = HMSLogger.getInstance(this.getApplicationContext());
8484

85-
//Window options
85+
// Window options
8686
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
8787
requestWindowFeature(Window.FEATURE_NO_TITLE);
8888
setContentView(R.layout.activity_multiprocessor);
8989

90-
//MultiProcessor mode
90+
// MultiProcessor mode
9191
mode = Objects.requireNonNull(getIntent().getExtras()).getInt("scanMode");
9292

9393
mMultiProcessorCamera = new MultiProcessorCamera();
@@ -110,7 +110,7 @@ protected void onCreate(Bundle savedInstanceState) {
110110
multiProcessorChannel = ScanPlugin.SCAN_CHANNELS.get(channelId);
111111
}
112112

113-
//Gallery option from Flutter.
113+
// Gallery option from Flutter.
114114
if (multiIntent.getExtras().getBoolean("gallery")) {
115115
galleryButton.setVisibility(View.VISIBLE);
116116
setPictureScanOperation();
@@ -124,7 +124,7 @@ protected void onCreate(Bundle savedInstanceState) {
124124

125125
}
126126

127-
//Adjust camera and surface.
127+
// Adjust camera and surface.
128128
private void adjustSurface(SurfaceView cameraPreview) {
129129
FrameLayout.LayoutParams paramSurface = (FrameLayout.LayoutParams) cameraPreview.getLayoutParams();
130130
if (getSystemService(Context.WINDOW_SERVICE) != null) {
@@ -157,7 +157,7 @@ private void adjustSurface(SurfaceView cameraPreview) {
157157
}
158158
}
159159

160-
//Back button
160+
// Back button
161161
private void setBackOperation() {
162162
ImageView backButton = findViewById(R.id.back_img);
163163
backButton.setOnClickListener(new View.OnClickListener() {
@@ -177,7 +177,7 @@ public void onBackPressed() {
177177
MultiProcessorActivity.this.finish();
178178
}
179179

180-
//Gallery button
180+
// Gallery button
181181
private void setPictureScanOperation() {
182182
galleryButton.setOnClickListener(new View.OnClickListener() {
183183
@Override
@@ -189,7 +189,7 @@ public void onClick(View v) {
189189
});
190190
}
191191

192-
//Camera Lifecycle
192+
// Camera Lifecycle
193193
@Override
194194
protected void onResume() {
195195
super.onResume();
@@ -218,13 +218,13 @@ protected void onDestroy() {
218218
super.onDestroy();
219219
}
220220

221-
//Camera start method.
221+
// Camera start method.
222222
private void initCamera() {
223223
try {
224224
mMultiProcessorCamera.open(surfaceHolder);
225225
if (handler == null) {
226226
Intent intent = getIntent();
227-
//Options from Flutter.
227+
// Options from Flutter.
228228
long[] colorList = Objects.requireNonNull(intent.getExtras()).getLongArray("colorList");
229229

230230
int textColor = intent.getExtras().getInt("textColor");
@@ -238,7 +238,7 @@ private void initCamera() {
238238
int minTextSize = intent.getExtras().getInt("minTextSize");
239239
int granularity = intent.getExtras().getInt("granularity");
240240

241-
//Handler for multi processor camera -- this is where camera continuously scan barcode.
241+
// Handler for multi processor camera -- this is where camera continuously scan barcode.
242242
if (mAnalyzer != null && multiProcessorChannel != null) {
243243
handler = new MultiProcessorHandler(MultiProcessorActivity.this, multiProcessorChannel,
244244
mMultiProcessorCamera, mode, colorList, textColor, textSize, strokeWidth, textBackgroundColor,
@@ -270,7 +270,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
270270
}
271271
}
272272

273-
//Multi Async mode for image based scanning mode.
273+
// Multi Async mode for image based scanning mode.
274274
private void decodeMultiAsync(Bitmap bitmap) {
275275
MLFrame image = MLFrame.fromBitmap(bitmap);
276276
if (analyzerIsAvailableWithLogger(this.getApplicationContext(), mAnalyzer, "MultiProcessorActivity")) {
@@ -301,7 +301,7 @@ public void onFailure(Exception e) {
301301
}
302302
}
303303

304-
//Multi Sync mode for image based scanning mode.
304+
// Multi Sync mode for image based scanning mode.
305305
private void decodeMultiSync(Bitmap bitmap) {
306306
MLFrame image = MLFrame.fromBitmap(bitmap);
307307
if (analyzerIsAvailableWithLogger(this.getApplicationContext(), mAnalyzer, "MultiProcessorActivity")) {

Diff for: flutter-hms-scan/android/src/main/java/com/huawei/hms/flutter/scan/multiprocessor/MultiProcessorCamera.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class MultiProcessorCamera {
3535

3636
/**
3737
* Open up the camera.
38+
* @param holder SurfaceHolder
39+
* @throws IOException
3840
*/
3941
synchronized void open(SurfaceHolder holder) throws IOException {
4042
camera = Camera.open();
@@ -73,7 +75,7 @@ synchronized void callbackFrame(Handler handler, double zoomValue) {
7375
frameCallback.setProperties(handler);
7476
double defaultZoom = 1.0;
7577
if (camera.getParameters().isZoomSupported() && zoomValue != defaultZoom) {
76-
//Auto zoom.
78+
// Auto zoom.
7779
parameters.setZoom(convertZoomInt(zoomValue));
7880
camera.setParameters(parameters);
7981
}

0 commit comments

Comments
 (0)