| @@ -1,24 +1,41 @@ | |||||
| package net.touchcapture.qr.flutterqr | package net.touchcapture.qr.flutterqr | ||||
| import androidx.annotation.NonNull | |||||
| import io.flutter.embedding.engine.plugins.FlutterPlugin | |||||
| import io.flutter.plugin.common.MethodCall | import io.flutter.plugin.common.MethodCall | ||||
| import io.flutter.plugin.common.MethodChannel.MethodCallHandler | import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||||
| import io.flutter.plugin.common.MethodChannel.Result | import io.flutter.plugin.common.MethodChannel.Result | ||||
| import io.flutter.plugin.common.PluginRegistry.Registrar | import io.flutter.plugin.common.PluginRegistry.Registrar | ||||
| class FlutterQrPlugin : MethodCallHandler { | |||||
| class FlutterQrPlugin : FlutterPlugin, MethodCallHandler { | |||||
| /** Plugin registration embedding v1 */ | |||||
| companion object { | companion object { | ||||
| @JvmStatic | @JvmStatic | ||||
| fun registerWith(registrar: Registrar) { | fun registerWith(registrar: Registrar) { | ||||
| registrar | |||||
| .platformViewRegistry() | |||||
| .registerViewFactory( | |||||
| "net.touchcapture.qr.flutterqr/qrview", QRViewFactory(registrar)) | |||||
| FlutterQrPlugin().onAttachedToEngine(registrar) | |||||
| } | } | ||||
| } | } | ||||
| /** Plugin registration embedding v2 */ | |||||
| override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | |||||
| onAttachedToEngine(flutterPluginBinding) | |||||
| } | |||||
| override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | |||||
| } | |||||
| private fun onAttachedToEngine(registrar: Registrar) { | |||||
| registrar | |||||
| .platformViewRegistry() | |||||
| .registerViewFactory( | |||||
| "net.touchcapture.qr.flutterqr/qrview", QRViewFactory(registrar)) | |||||
| } | |||||
| override fun onMethodCall(call: MethodCall, result: Result) { | override fun onMethodCall(call: MethodCall, result: Result) { | ||||
| when { | |||||
| call.method == "getPlatformVersion" -> result.success("Android ${android.os.Build.VERSION.RELEASE}") | |||||
| when (call.method) { | |||||
| "getPlatformVersion" -> result.success("Android ${android.os.Build.VERSION.RELEASE}") | |||||
| else -> result.notImplemented() | else -> result.notImplemented() | ||||
| } | } | ||||
| } | } | ||||
| @@ -13,7 +13,6 @@ | |||||
| additional functionality it is fine to subclass or reimplement | additional functionality it is fine to subclass or reimplement | ||||
| FlutterApplication and put your custom class here. --> | FlutterApplication and put your custom class here. --> | ||||
| <application | <application | ||||
| android:name="io.flutter.app.FlutterApplication" | |||||
| android:label="flutter_qr_example" | android:label="flutter_qr_example" | ||||
| android:icon="@mipmap/ic_launcher"> | android:icon="@mipmap/ic_launcher"> | ||||
| <activity | <activity | ||||
| @@ -23,13 +22,19 @@ | |||||
| android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" | android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" | ||||
| android:hardwareAccelerated="true" | android:hardwareAccelerated="true" | ||||
| android:windowSoftInputMode="adjustResize"> | android:windowSoftInputMode="adjustResize"> | ||||
| <!-- This keeps the window background of the activity showing | |||||
| until Flutter renders its first frame. It can be removed if | |||||
| there is no splash screen (such as the default splash screen | |||||
| defined in @style/LaunchTheme). --> | |||||
| <!-- Specify that the launch screen should continue being displayed --> | |||||
| <!-- until Flutter renders its first frame. --> | |||||
| <meta-data | <meta-data | ||||
| android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" | |||||
| android:value="true" /> | |||||
| android:name="io.flutter.embedding.android.SplashScreenDrawable" | |||||
| android:resource="@drawable/launch_background" /> | |||||
| <!-- Theme to apply as soon as Flutter begins rendering frames --> | |||||
| <meta-data | |||||
| android:name="io.flutter.embedding.android.NormalTheme" | |||||
| android:resource="@style/NormalTheme" | |||||
| /> | |||||
| <meta-data | |||||
| android:name="flutterEmbedding" | |||||
| android:value="2" /> | |||||
| <intent-filter> | <intent-filter> | ||||
| <action android:name="android.intent.action.MAIN"/> | <action android:name="android.intent.action.MAIN"/> | ||||
| <category android:name="android.intent.category.LAUNCHER"/> | <category android:name="android.intent.category.LAUNCHER"/> | ||||
| @@ -1,13 +1,6 @@ | |||||
| package net.touchcapture.qr.flutterqrexample | package net.touchcapture.qr.flutterqrexample | ||||
| import android.os.Bundle | |||||
| import io.flutter.app.FlutterActivity | |||||
| import io.flutter.plugins.GeneratedPluginRegistrant | |||||
| import io.flutter.embedding.android.FlutterActivity | |||||
| class MainActivity: FlutterActivity() { | class MainActivity: FlutterActivity() { | ||||
| override fun onCreate(savedInstanceState: Bundle?) { | |||||
| super.onCreate(savedInstanceState) | |||||
| GeneratedPluginRegistrant.registerWith(this) | |||||
| } | |||||
| } | } | ||||
| @@ -5,4 +5,8 @@ | |||||
| Flutter draws its first frame --> | Flutter draws its first frame --> | ||||
| <item name="android:windowBackground">@drawable/launch_background</item> | <item name="android:windowBackground">@drawable/launch_background</item> | ||||
| </style> | </style> | ||||
| <style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar"> | |||||
| <item name="android:windowBackground">@drawable/launch_background</item> | |||||
| </style> | |||||
| </resources> | </resources> | ||||