Skip to content
Open
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
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -400,6 +401,8 @@ private Size getAppropriateSize(Size[] sizes) {
}

private Size[] sortSizesAscending(Size[] sizes) {
// Java code not supported on older versions of Android
/*
Comparator<Size> compareWidth = new Comparator<Size>() {
public int compare(Size a, Size b) {
return Integer.compare(a.getWidth(), b.getWidth());
Expand All @@ -412,6 +415,27 @@ public int compare(Size a, Size b) {
};

Arrays.sort(sizes, compareWidth.thenComparing(compareHeight));
*/
Comparator<Size> areaComparator = new Comparator<Size>() {

public int compare(Size size, Size size2) {
if (size.equals(size2)) {
return 0;
}

long width = size.getWidth();
long width2 = size2.getWidth();
long area = width * size.getHeight();
long area2 = width2 * size2.getHeight();

if (area == area2) {
return (width > width2) ? 1 : -1;
}

return (area > area2) ? 1 : -1;
}
};
Collections.sort(Arrays.asList(sizes), areaComparator);
return sizes;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.github.rmtmckenzie.qrmobilevision;

import android.util.Log;

import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import java.util.List;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
Expand All @@ -13,7 +10,9 @@
import com.google.mlkit.vision.barcode.common.Barcode;
import com.google.mlkit.vision.common.InputImage;

import java.util.List;
import android.util.Log;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;

/**
* Allows QrCamera classes to send frames to a Detector
Expand Down Expand Up @@ -74,7 +73,8 @@ private void processFrame(Frame frame) {
.addOnSuccessListener(this)
.addOnFailureListener(this);
}
frame.close();
// commented out as it was causing an issue with "IllegalStateException: Image is already closed" error
//frame.close();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:label="qr_mobile_vision_example"
android:allowBackup="false">
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:name="${applicationName}"
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
native_device_orientation: ^1.0.0
native_device_orientation: ^1.1.4
device_info_plus: '>=3.0.0 <5.0.0'

false_secrets:
Expand Down