Skip to content

Commit

Permalink
update android project settings and some code opt (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
penkzhou authored Feb 1, 2024
1 parent 2687e38 commit a5234e6
Show file tree
Hide file tree
Showing 16 changed files with 188 additions and 114 deletions.
209 changes: 137 additions & 72 deletions packages/example/pubspec.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/google_mlkit_barcode_scanning/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_barcode_scanning'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -40,5 +40,5 @@ android {
}

dependencies {
implementation 'com.google.mlkit:barcode-scanning:17.1.0'
implementation 'com.google.mlkit:barcode-scanning:17.2.0'
}
4 changes: 2 additions & 2 deletions packages/google_mlkit_commons/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_commons'
}

compileSdkVersion 29
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_digital_ink_recognition'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
4 changes: 2 additions & 2 deletions packages/google_mlkit_entity_extraction/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_entity_extraction'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
4 changes: 2 additions & 2 deletions packages/google_mlkit_face_detection/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_face_detection'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_face_mesh_detection'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
6 changes: 3 additions & 3 deletions packages/google_mlkit_image_labeling/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_image_labeling'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -41,6 +41,6 @@ android {

dependencies {
implementation 'com.google.mlkit:image-labeling:17.0.7'
implementation 'com.google.mlkit:image-labeling-custom:17.0.1'
implementation 'com.google.mlkit:image-labeling-custom:17.0.2'
implementation 'com.google.mlkit:linkfirebase:17.0.0'
}
4 changes: 2 additions & 2 deletions packages/google_mlkit_language_id/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_language_id'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
6 changes: 3 additions & 3 deletions packages/google_mlkit_object_detection/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_object_detection'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -41,6 +41,6 @@ android {

dependencies {
implementation 'com.google.mlkit:object-detection:17.0.0'
implementation 'com.google.mlkit:object-detection-custom:17.0.0'
implementation 'com.google.mlkit:object-detection-custom:17.0.1'
implementation 'com.google.mlkit:linkfirebase:17.0.0'
}
4 changes: 2 additions & 2 deletions packages/google_mlkit_pose_detection/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_pose_detection'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_selfie_segmentation'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
6 changes: 3 additions & 3 deletions packages/google_mlkit_smart_reply/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -26,8 +26,8 @@ android {
if (project.android.hasProperty("namespace")) {
namespace 'com.google_mlki_smart_reply'
}
compileSdkVersion 31

compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
4 changes: 2 additions & 2 deletions packages/google_mlkit_text_recognition/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_text_recognition'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
}

private com.google.mlkit.vision.text.TextRecognizer initialize(MethodCall call) {
int script = (int) call.argument("script");
Integer script = call.argument("script");
if (script == null) {
return null;
}
switch (script) {
case 0:
return TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS);
Expand All @@ -71,7 +74,10 @@ private com.google.mlkit.vision.text.TextRecognizer initialize(MethodCall call)
}

private void handleDetection(MethodCall call, final MethodChannel.Result result) {
Map<String, Object> imageData = (Map<String, Object>) call.argument("imageData");
Map<String, Object> imageData = call.argument("imageData");
if (imageData == null) {
return;
}
InputImage inputImage = InputImageConverter.getInputImageFromData(imageData, context, result);
if (inputImage == null) return;

Expand All @@ -81,7 +87,10 @@ private void handleDetection(MethodCall call, final MethodChannel.Result result)
textRecognizer = initialize(call);
instances.put(id, textRecognizer);
}

if (textRecognizer == null) {
result.error("TextRecognizerError", "TextRecognizer is not initialized", null);
return;
}
textRecognizer.process(inputImage)
.addOnSuccessListener(text -> {
Map<String, Object> textResult = new HashMap<>();
Expand All @@ -96,8 +105,8 @@ private void handleDetection(MethodCall call, final MethodChannel.Result result)
block.getText(),
block.getBoundingBox(),
block.getCornerPoints(),
block.getRecognizedLanguage(),
null,
block.getRecognizedLanguage(),
null,
null);

List<Map<String, Object>> textLines = new ArrayList<>();
Expand All @@ -108,8 +117,8 @@ private void handleDetection(MethodCall call, final MethodChannel.Result result)
line.getText(),
line.getBoundingBox(),
line.getCornerPoints(),
line.getRecognizedLanguage(),
line.getConfidence(),
line.getRecognizedLanguage(),
line.getConfidence(),
line.getAngle());

List<Map<String, Object>> elementsData = new ArrayList<>();
Expand Down Expand Up @@ -157,10 +166,10 @@ private void addData(Map<String, Object> addTo,
String text,
Rect rect,
Point[] cornerPoints,
String recognizedLanguage,
String recognizedLanguage,
Float confidence,
Float angle
) {
) {
List<String> recognizedLanguages = new ArrayList<>();
recognizedLanguages.add(recognizedLanguage);
List<Map<String, Integer>> points = new ArrayList<>();
Expand Down
6 changes: 3 additions & 3 deletions packages/google_mlkit_translation/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand All @@ -27,7 +27,7 @@ android {
namespace 'com.google_mlkit_translation'
}

compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -40,5 +40,5 @@ android {
}

dependencies {
implementation 'com.google.mlkit:translate:17.0.1'
implementation 'com.google.mlkit:translate:17.0.2'
}

0 comments on commit a5234e6

Please sign in to comment.