Browse Source

[feat]键盘插件,例子工程配置Application

hezihao 8 months ago
parent
commit
318ade1f28

+ 18 - 13
plugins/keyboard_android/example/android/app/src/main/AndroidManifest.xml

@@ -1,36 +1,41 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <manifest xmlns:android="http://schemas.android.com/apk/res/android">
+
     <application
     <application
-        android:label="keyboard_android_example"
-        android:name="${applicationName}"
-        android:icon="@mipmap/ic_launcher">
+        android:name=".AtmobApplication"
+        android:icon="@mipmap/ic_launcher"
+        android:label="keyboard_android_example">
+
         <activity
         <activity
             android:name=".MainActivity"
             android:name=".MainActivity"
+            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
             android:exported="true"
             android:exported="true"
+            android:hardwareAccelerated="true"
             android:launchMode="singleTop"
             android:launchMode="singleTop"
             android:taskAffinity=""
             android:taskAffinity=""
             android:theme="@style/LaunchTheme"
             android:theme="@style/LaunchTheme"
-            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
-            android:hardwareAccelerated="true"
             android:windowSoftInputMode="adjustResize">
             android:windowSoftInputMode="adjustResize">
+
             <!-- Specifies an Android theme to apply to this Activity as soon as
             <!-- Specifies an Android theme to apply to this Activity as soon as
                  the Android process has started. This theme is visible to the user
                  the Android process has started. This theme is visible to the user
                  while the Flutter UI initializes. After that, this theme continues
                  while the Flutter UI initializes. After that, this theme continues
                  to determine the Window background behind the Flutter UI. -->
                  to determine the Window background behind the Flutter UI. -->
             <meta-data
             <meta-data
-              android:name="io.flutter.embedding.android.NormalTheme"
-              android:resource="@style/NormalTheme"
-              />
+                android:name="io.flutter.embedding.android.NormalTheme"
+                android:resource="@style/NormalTheme" />
+
             <intent-filter>
             <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-                <category android:name="android.intent.category.LAUNCHER"/>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             </intent-filter>
         </activity>
         </activity>
+
         <!-- Don't delete the meta-data below.
         <!-- Don't delete the meta-data below.
              This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
              This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
         <meta-data
         <meta-data
             android:name="flutterEmbedding"
             android:name="flutterEmbedding"
             android:value="2" />
             android:value="2" />
     </application>
     </application>
+
     <!-- Required to query activities that can process text, see:
     <!-- Required to query activities that can process text, see:
          https://developer.android.com/training/package-visibility and
          https://developer.android.com/training/package-visibility and
          https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
          https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
@@ -38,8 +43,8 @@
          In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
          In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
     <queries>
     <queries>
         <intent>
         <intent>
-            <action android:name="android.intent.action.PROCESS_TEXT"/>
-            <data android:mimeType="text/plain"/>
+            <action android:name="android.intent.action.PROCESS_TEXT" />
+            <data android:mimeType="text/plain" />
         </intent>
         </intent>
     </queries>
     </queries>
-</manifest>
+</manifest>

+ 24 - 0
plugins/keyboard_android/example/android/app/src/main/kotlin/com/atmob/keyboard_android_example/AtmobApplication.kt

@@ -0,0 +1,24 @@
+package com.atmob.keyboard_android_example
+
+import android.app.Application
+import io.flutter.embedding.engine.FlutterEngine
+import io.flutter.embedding.engine.FlutterEngineCache
+import io.flutter.embedding.engine.dart.DartExecutor
+
+class AtmobApplication : Application() {
+    // 声明一个 FlutterEngine 实例
+    lateinit var flutterEngine: FlutterEngine
+
+    override fun onCreate() {
+        super.onCreate()
+
+        // 实例化 FlutterEngine,并确保应用退出时,FlutterEngine 能继续运行
+        flutterEngine = FlutterEngine(this).apply {
+            // 设置 Dart 入口点,确保 Dart 代码能够执行
+            dartExecutor.executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())
+        }
+
+        // 将 FlutterEngine 添加到 FlutterEngineCache,使用指定的 engine ID 进行管理
+        FlutterEngineCache.getInstance().put("my_engine_id", flutterEngine)
+    }
+}

+ 32 - 32
plugins/keyboard_android/example/pubspec.lock

@@ -6,7 +6,7 @@ packages:
     description:
     description:
       name: async
       name: async
       sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
       sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "2.12.0"
     version: "2.12.0"
   boolean_selector:
   boolean_selector:
@@ -14,7 +14,7 @@ packages:
     description:
     description:
       name: boolean_selector
       name: boolean_selector
       sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
       sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "2.1.2"
     version: "2.1.2"
   characters:
   characters:
@@ -22,7 +22,7 @@ packages:
     description:
     description:
       name: characters
       name: characters
       sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
       sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.4.0"
     version: "1.4.0"
   clock:
   clock:
@@ -30,7 +30,7 @@ packages:
     description:
     description:
       name: clock
       name: clock
       sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
       sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.1.2"
     version: "1.1.2"
   collection:
   collection:
@@ -38,7 +38,7 @@ packages:
     description:
     description:
       name: collection
       name: collection
       sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
       sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.19.1"
     version: "1.19.1"
   cupertino_icons:
   cupertino_icons:
@@ -46,7 +46,7 @@ packages:
     description:
     description:
       name: cupertino_icons
       name: cupertino_icons
       sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
       sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.0.8"
     version: "1.0.8"
   fake_async:
   fake_async:
@@ -54,7 +54,7 @@ packages:
     description:
     description:
       name: fake_async
       name: fake_async
       sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
       sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.3.2"
     version: "1.3.2"
   file:
   file:
@@ -62,7 +62,7 @@ packages:
     description:
     description:
       name: file
       name: file
       sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
       sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "7.0.1"
     version: "7.0.1"
   flutter:
   flutter:
@@ -80,7 +80,7 @@ packages:
     description:
     description:
       name: flutter_easyloading
       name: flutter_easyloading
       sha256: ba21a3c883544e582f9cc455a4a0907556714e1e9cf0eababfcb600da191d17c
       sha256: ba21a3c883544e582f9cc455a4a0907556714e1e9cf0eababfcb600da191d17c
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "3.0.5"
     version: "3.0.5"
   flutter_lints:
   flutter_lints:
@@ -88,7 +88,7 @@ packages:
     description:
     description:
       name: flutter_lints
       name: flutter_lints
       sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
       sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "5.0.0"
     version: "5.0.0"
   flutter_spinkit:
   flutter_spinkit:
@@ -96,7 +96,7 @@ packages:
     description:
     description:
       name: flutter_spinkit
       name: flutter_spinkit
       sha256: d2696eed13732831414595b98863260e33e8882fc069ee80ec35d4ac9ddb0472
       sha256: d2696eed13732831414595b98863260e33e8882fc069ee80ec35d4ac9ddb0472
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "5.2.1"
     version: "5.2.1"
   flutter_test:
   flutter_test:
@@ -126,7 +126,7 @@ packages:
     description:
     description:
       name: leak_tracker
       name: leak_tracker
       sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
       sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "10.0.8"
     version: "10.0.8"
   leak_tracker_flutter_testing:
   leak_tracker_flutter_testing:
@@ -134,7 +134,7 @@ packages:
     description:
     description:
       name: leak_tracker_flutter_testing
       name: leak_tracker_flutter_testing
       sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
       sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "3.0.9"
     version: "3.0.9"
   leak_tracker_testing:
   leak_tracker_testing:
@@ -142,7 +142,7 @@ packages:
     description:
     description:
       name: leak_tracker_testing
       name: leak_tracker_testing
       sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
       sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "3.0.1"
     version: "3.0.1"
   lints:
   lints:
@@ -150,7 +150,7 @@ packages:
     description:
     description:
       name: lints
       name: lints
       sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
       sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "5.1.1"
     version: "5.1.1"
   matcher:
   matcher:
@@ -158,7 +158,7 @@ packages:
     description:
     description:
       name: matcher
       name: matcher
       sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
       sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "0.12.17"
     version: "0.12.17"
   material_color_utilities:
   material_color_utilities:
@@ -166,7 +166,7 @@ packages:
     description:
     description:
       name: material_color_utilities
       name: material_color_utilities
       sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
       sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "0.11.1"
     version: "0.11.1"
   meta:
   meta:
@@ -174,7 +174,7 @@ packages:
     description:
     description:
       name: meta
       name: meta
       sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
       sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.16.0"
     version: "1.16.0"
   path:
   path:
@@ -182,7 +182,7 @@ packages:
     description:
     description:
       name: path
       name: path
       sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
       sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.9.1"
     version: "1.9.1"
   platform:
   platform:
@@ -190,7 +190,7 @@ packages:
     description:
     description:
       name: platform
       name: platform
       sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
       sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "3.1.6"
     version: "3.1.6"
   plugin_platform_interface:
   plugin_platform_interface:
@@ -198,7 +198,7 @@ packages:
     description:
     description:
       name: plugin_platform_interface
       name: plugin_platform_interface
       sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
       sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "2.1.8"
     version: "2.1.8"
   process:
   process:
@@ -206,7 +206,7 @@ packages:
     description:
     description:
       name: process
       name: process
       sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d"
       sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "5.0.3"
     version: "5.0.3"
   sky_engine:
   sky_engine:
@@ -219,7 +219,7 @@ packages:
     description:
     description:
       name: source_span
       name: source_span
       sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
       sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.10.1"
     version: "1.10.1"
   stack_trace:
   stack_trace:
@@ -227,7 +227,7 @@ packages:
     description:
     description:
       name: stack_trace
       name: stack_trace
       sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
       sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.12.1"
     version: "1.12.1"
   stream_channel:
   stream_channel:
@@ -235,7 +235,7 @@ packages:
     description:
     description:
       name: stream_channel
       name: stream_channel
       sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
       sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "2.1.4"
     version: "2.1.4"
   string_scanner:
   string_scanner:
@@ -243,7 +243,7 @@ packages:
     description:
     description:
       name: string_scanner
       name: string_scanner
       sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
       sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.4.1"
     version: "1.4.1"
   sync_http:
   sync_http:
@@ -251,7 +251,7 @@ packages:
     description:
     description:
       name: sync_http
       name: sync_http
       sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
       sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "0.3.1"
     version: "0.3.1"
   term_glyph:
   term_glyph:
@@ -259,7 +259,7 @@ packages:
     description:
     description:
       name: term_glyph
       name: term_glyph
       sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
       sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "1.2.2"
     version: "1.2.2"
   test_api:
   test_api:
@@ -267,7 +267,7 @@ packages:
     description:
     description:
       name: test_api
       name: test_api
       sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
       sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "0.7.4"
     version: "0.7.4"
   vector_math:
   vector_math:
@@ -275,7 +275,7 @@ packages:
     description:
     description:
       name: vector_math
       name: vector_math
       sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
       sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "2.1.4"
     version: "2.1.4"
   vm_service:
   vm_service:
@@ -283,7 +283,7 @@ packages:
     description:
     description:
       name: vm_service
       name: vm_service
       sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
       sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "14.3.1"
     version: "14.3.1"
   webdriver:
   webdriver:
@@ -291,7 +291,7 @@ packages:
     description:
     description:
       name: webdriver
       name: webdriver
       sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
       sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dev"
     source: hosted
     source: hosted
     version: "3.0.4"
     version: "3.0.4"
 sdks:
 sdks: