From 22d0d198d9b2fd9f5f22d9ee0feaae0f817591b8 Mon Sep 17 00:00:00 2001 From: Brandon Cheng Date: Mon, 19 Aug 2024 11:20:20 -0700 Subject: [PATCH 1/3] Revert onCreate changes and bump version to 4.0.1 Revert ReaderSdk.initialize changes in TatsuUkraine:flutter-3. This change causes the application to crash whenever the app is background and the app has been initialized before. Bump version --- .../flutter/SquareReaderSdkFlutterPlugin.java | 11 ++++++++--- .../flutter/squareup/sdk/reader/MainActivity.kt | 6 ++++-- .../squareup/sdk/reader/MainApplication.kt | 15 +++++++++++++-- pubspec.yaml | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/squareup/sdk/reader/flutter/SquareReaderSdkFlutterPlugin.java b/android/src/main/java/com/squareup/sdk/reader/flutter/SquareReaderSdkFlutterPlugin.java index c57d878..9418006 100644 --- a/android/src/main/java/com/squareup/sdk/reader/flutter/SquareReaderSdkFlutterPlugin.java +++ b/android/src/main/java/com/squareup/sdk/reader/flutter/SquareReaderSdkFlutterPlugin.java @@ -157,7 +157,12 @@ private void initializeReaderSdk() { return; } - ReaderSdk.initialize(currentActivity.getApplication()); - sdkInitialized = true; + try { + ReaderSdk.initialize(currentActivity.getApplication()); + sdkInitialized = true; + } catch (IllegalStateException e) { + // allow double-initialization; devs _should_ init in Application.onCreate, + // but to be non-breaking we try here also in case they didn't. + } } -} +} \ No newline at end of file diff --git a/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.kt b/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.kt index d20f9ef..105a6b3 100644 --- a/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.kt +++ b/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.kt @@ -15,8 +15,10 @@ limitations under the License. */ package com.example.flutter.squareup.sdk.reader; -import io.flutter.embedding.android.FlutterActivity +import androidx.annotation.NonNull; -class MainActivity: FlutterActivity() { +import io.flutter.embedding.android.FlutterActivity; + +public class MainActivity extends FlutterActivity { } diff --git a/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.kt b/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.kt index bddc3fe..1eb228c 100644 --- a/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.kt +++ b/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.kt @@ -15,7 +15,18 @@ limitations under the License. */ package com.example.flutter.squareup.sdk.reader; -import io.flutter.app.FlutterApplication +import com.squareup.sdk.reader.ReaderSdk; +import io.flutter.app.FlutterApplication; -class MainApplication: FlutterApplication() { +import io.flutter.view.FlutterMain; + + +public class MainApplication extends FlutterApplication { + + @Override + public void onCreate() { + super.onCreate(); + ReaderSdk.initialize(this); + FlutterMain.startInitialization(this); + } } diff --git a/pubspec.yaml b/pubspec.yaml index f1b4b4a..2b7c158 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: square_reader_sdk description: An open source Flutter plugin for calling Square’s native Reader SDK implementations to take in-person payments on iOS and Android. -version: 4.0.0 +version: 4.0.1 homepage: https://github.com/square/reader-sdk-flutter-plugin environment: From f161196f9cf24ab12160d02e9ef53c31abf66aa4 Mon Sep 17 00:00:00 2001 From: Artem Chubaryan Date: Mon, 26 Aug 2024 14:58:56 -0500 Subject: [PATCH 2/3] Changed files back into `.java` --- .../squareup/sdk/reader/{MainActivity.kt => MainActivity.java} | 0 .../sdk/reader/{MainApplication.kt => MainApplication.java} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/{MainActivity.kt => MainActivity.java} (100%) rename example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/{MainApplication.kt => MainApplication.java} (100%) diff --git a/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.kt b/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.java similarity index 100% rename from example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.kt rename to example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainActivity.java diff --git a/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.kt b/example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.java similarity index 100% rename from example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.kt rename to example/android/app/src/main/java/com/example/flutter/squareup/sdk/reader/MainApplication.java From 1def276ba663c4999d2d4b53b65668b1980d31e6 Mon Sep 17 00:00:00 2001 From: Artem Chubaryan Date: Thu, 29 Aug 2024 10:40:03 -0500 Subject: [PATCH 3/3] Merge pull request #118 * Updated changelog for 4.0.1 --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 057a753..0b90d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ ## Changelog -### v5.0.0 Aug 22st, 2023 +### v4.0.1 Aug 29st, 2024 * Upgrade to Reader SDK 1.7.5 on Android. -* Support CompileSDK and targetSDK 33 on Android +* Support CompileSDK and targetSDK 34 on Android +* Fixed the [issue](https://github.com/square/reader-sdk-flutter-plugin/pull/116) with resuming the app after process is killed on Android. ### v4.0.0 Sep 1st, 2022