Skip to content

Commit d313918

Browse files
authored
Merge pull request #2 from Foundation-Devices/port_changes_from_qr_plus
Port changes from qr plus
2 parents 1bf7ecb + 4363377 commit d313918

8 files changed

Lines changed: 83 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1+
## 2.0.14
2+
3+
- Updated android compile and target SDK to 36
4+
- Updated android targets to java 17
5+
- Fixed android build for example app
6+
7+
## 2.0.13
8+
9+
Fix:
10+
11+
- Correctly parse all iOS versions to reliably apply the UI Hanging fix from version 2.0.12
12+
113
## 2.0.12
2-
- For iOS 18 or newer, call `pauseCamera` on dispose instead of `stopCamera`
14+
15+
- For iOS 18 or newer, call `pauseCamera` on dispose instead of `stopCamera` to avoid UI hang
16+
17+
**L.e. The iOS version detection was not correctly parsed, causing this fix to not apply for hotfix iOS versions (such as 26.0.1)**
318

419
## 2.0.11
520

621
FIX for iOS 26:
22+
723
- For iOS 26 or newer, call `pauseCamera` on dispose instead of `stopCamera`
824

925
Note: Calling stopCamera on dispose was causing UI to hang for 1-3 seconds
1026

1127
## 2.0.10+1
1228

13-
- Increased android compile SDK to 35 and removed android test deps
29+
- Increased android compile SDK to 35 and removed android test deps
1430

1531
## 2.0.10
1632

android/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@ apply plugin: 'com.android.library'
2525
apply plugin: 'kotlin-android'
2626

2727
android {
28-
compileSdk 34
28+
compileSdk 36
2929

3030
sourceSets {
3131
main.java.srcDirs += 'src/main/kotlin'
3232
}
3333
defaultConfig {
3434
// minSdkVersion is determined by Native View.
3535
minSdkVersion 20
36-
targetSdkVersion 34
36+
targetSdkVersion 36
3737
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3838
multiDexEnabled true
3939
}
4040

4141
kotlinOptions {
42-
jvmTarget = '11'
42+
jvmTarget = '17'
4343
}
4444

4545
compileOptions {
4646
// Flag to enable support for the new language APIs
4747
// // // coreLibraryDesugaringEnabled true
48-
// Sets Java compatibility to Java 11
49-
sourceCompatibility JavaVersion.VERSION_11
50-
targetCompatibility JavaVersion.VERSION_11
48+
// Sets Java compatibility to Java 17
49+
sourceCompatibility JavaVersion.VERSION_17
50+
targetCompatibility JavaVersion.VERSION_17
5151
}
5252
if (project.android.hasProperty('namespace')) {
5353
namespace 'net.touchcapture.qr.flutterqrplus'

example/android/app/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -21,12 +27,8 @@ if (flutterVersionName == null) {
2127
flutterVersionName = '1.0'
2228
}
2329

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
2830
android {
29-
compileSdk 35
31+
compileSdk 36
3032

3133
sourceSets {
3234
main.java.srcDirs += 'src/main/kotlin'
@@ -35,7 +37,7 @@ android {
3537
defaultConfig {
3638
applicationId "net.touchcapture.qr.flutterqrexample"
3739
minSdkVersion flutter.minSdkVersion
38-
targetSdkVersion 35
40+
targetSdkVersion 36
3941
versionCode flutterVersionCode.toInteger()
4042
versionName flutterVersionName
4143
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.9.0'
2+
ext.kotlin_version = '2.2.20'
33
repositories {
44
google()
55
mavenCentral()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Aug 08 21:31:11 CEST 2023
1+
#Thu Sep 18 11:28:23 EEST 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

example/android/settings.gradle

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
22+
// https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
23+
// AGP (gradle plugin)
24+
id "com.android.application" version '8.13.0' apply false
25+
26+
// Kotlin Version
27+
// https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android
28+
id "org.jetbrains.kotlin.android" version "2.2.20" apply false
29+
30+
31+
}
32+
33+
include ":app"

lib/src/qr_code_scanner.dart

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import 'platform/platform_info_stub.dart'
2626
typedef QRViewCreatedCallback = void Function(QRViewController);
2727
typedef PermissionSetCallback = void Function(QRViewController, bool);
2828

29+
const _defaultIOSMajorVersionOnUnknown = 18;
30+
2931
/// The [QRView] is the view where the camera
3032
/// and the barcode scanner gets displayed.
3133
class QRView extends StatefulWidget {
@@ -308,17 +310,24 @@ class QRViewController {
308310
try {
309311
final osVersionSplit = osVersion.split(' ');
310312

311-
final iOSVersion =
312-
osVersionSplit.length > 1 ? osVersionSplit[1] : 'Unknown';
313-
final iOSVersionDouble = double.tryParse(iOSVersion) ?? 0;
313+
// iOS version is sth like 26.0 or 26.0.1, etc.
314+
// We cannot assume it would parse as a double, so we need to handle that.
315+
final iOSVersion = osVersionSplit.length > 1
316+
? osVersionSplit[1]
317+
: "$_defaultIOSMajorVersionOnUnknown.0";
318+
319+
final iOSMajorVersion = int.tryParse(
320+
iOSVersion.split('.').firstOrNull ??
321+
'$_defaultIOSMajorVersionOnUnknown') ??
322+
_defaultIOSMajorVersionOnUnknown;
323+
final isAtLeastIOS18 = iOSMajorVersion >= 18;
314324

315-
// print('iOSVersionDouble $iOSVersionDouble');
316-
if (iOSVersionDouble < 18.0) {
317-
// Don't call stopCamera on iOS 18 or higher
325+
if (isAtLeastIOS18) {
326+
// Don't call stopCamera on iOS 18+
318327
// -- it causes UI to hang for a few seconds, especially on iOS 26+
319-
await _channel.invokeMethod('stopCamera');
320-
} else {
321328
await _channel.invokeMethod('pauseCamera');
329+
} else {
330+
await _channel.invokeMethod('stopCamera');
322331
}
323332
} on PlatformException catch (e) {
324333
throw CameraException(e.code, e.message);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: qr_code_scanner_plus
22
description: QR code scanner that can be embedded inside flutter. It uses zxing in Android and MTBBarcode scanner in iOS.
3-
version: 2.0.12
3+
version: 2.0.14
44
homepage: https://vespr.xyz
55
repository: https://github.com/vespr-wallet/qr_code_scanner_plus
66

0 commit comments

Comments
 (0)