From 33a3145ffc9492135b9d0d3f17643965213e509d Mon Sep 17 00:00:00 2001 From: Leon Date: Sun, 31 Mar 2019 01:03:35 +0800 Subject: [PATCH 1/4] support android x --- android/gradle.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f6..08f2b5f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +android.enableJetifier=true +android.useAndroidX=true From 66e811b04e208b2bdad457635912bbb47d82d803 Mon Sep 17 00:00:00 2001 From: Leon Date: Sun, 31 Mar 2019 01:21:57 +0800 Subject: [PATCH 2/4] fix black screen after change screen orientation but need to fix preview stretching after change screen orientation --- .../main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt index 10d1838..ebaf833 100644 --- a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt +++ b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt @@ -43,8 +43,6 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, } ) - init() - activity.application.registerActivityLifecycleCallbacks( object : Application.ActivityLifecycleCallbacks{ override fun onActivityPaused(p0: Activity?) { @@ -84,7 +82,10 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, } override fun getView(): View { - return barcodeView + barcodeView.pause() + return barcodeView.apply { + init() + } } override fun dispose() { From e74400d3a84572968bc5a32a99fa9755f4b68e86 Mon Sep 17 00:00:00 2001 From: Leon Date: Sun, 31 Mar 2019 20:02:14 +0800 Subject: [PATCH 3/4] fix #7 bug after unlock screen --- .../net/touchcapture/qr/flutterqr/QRView.kt | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt index ebaf833..1dce749 100644 --- a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt +++ b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt @@ -42,34 +42,6 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, override fun possibleResultPoints(resultPoints: List) {} } ) - - activity.application.registerActivityLifecycleCallbacks( - object : Application.ActivityLifecycleCallbacks{ - override fun onActivityPaused(p0: Activity?) { - barcodeView.pause() - } - - override fun onActivityResumed(p0: Activity?) { - init() - } - - override fun onActivityStarted(p0: Activity?) { - } - - override fun onActivityDestroyed(p0: Activity?) { - } - - override fun onActivitySaveInstanceState(p0: Activity?, p1: Bundle?) { - } - - override fun onActivityStopped(p0: Activity?) { - } - - override fun onActivityCreated(p0: Activity?, p1: Bundle?) { - barcodeView.decoderFactory = DefaultDecoderFactory() - } - - }) } From d18e2dffae00bd278bdefe41a3acdb0da64c65a8 Mon Sep 17 00:00:00 2001 From: Leon Date: Tue, 2 Apr 2019 11:18:26 +0800 Subject: [PATCH 4/4] fix black screen when manual focus --- .../kotlin/net/touchcapture/qr/flutterqr/QRView.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt index 1dce749..72fa5c6 100644 --- a/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt +++ b/android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt @@ -42,6 +42,15 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, override fun possibleResultPoints(resultPoints: List) {} } ) + barcodeView.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener { + override fun onViewDetachedFromWindow(p0: View?) { + barcodeView.pause() + } + + override fun onViewAttachedToWindow(p0: View?) { + barcodeView.resume() + } + }) } @@ -54,7 +63,6 @@ class QRView(context: Context, private val registrar: PluginRegistry.Registrar, } override fun getView(): View { - barcodeView.pause() return barcodeView.apply { init() }