creativecreatorormaybenot
Committed by GitHub

0.1.4+1 (#24)

@@ -57,7 +57,7 @@ jobs: @@ -57,7 +57,7 @@ jobs:
57 - 'stable' 57 - 'stable'
58 - 'beta' 58 - 'beta'
59 - 'dev' 59 - 'dev'
60 - fail-fast: true 60 + fail-fast: false
61 61
62 steps: 62 steps:
63 - name: Start iOS simulator 63 - name: Start iOS simulator
@@ -87,12 +87,12 @@ jobs: @@ -87,12 +87,12 @@ jobs:
87 - name: Run unit tests 87 - name: Run unit tests
88 run: flutter test 88 run: flutter test
89 - name: Run integration tests on iOS 89 - name: Run integration tests on iOS
90 - if: contains(matrix.device, 'iPhone') 90 + if: contains(matrix.device, 'iPhone') && false # Need to run locally for now.
91 run: | 91 run: |
92 cd example 92 cd example
93 flutter drive --target=test_driver/app.dart 93 flutter drive --target=test_driver/app.dart
94 - name: Run integration tests on Android 94 - name: Run integration tests on Android
95 - if: contains(matrix.device, 'Android') && false # Run these locally for now. 95 + if: contains(matrix.device, 'Android')
96 uses: reactivecircus/android-emulator-runner@v2.5.0 96 uses: reactivecircus/android-emulator-runner@v2.5.0
97 with: 97 with:
98 api-level: 29 98 api-level: 29
@@ -29,7 +29,7 @@ jobs: @@ -29,7 +29,7 @@ jobs:
29 - name: Run unit tests 29 - name: Run unit tests
30 run: flutter test 30 run: flutter test
31 - name: Run integration tests on Android 31 - name: Run integration tests on Android
32 - if: false # Run these locally for now. 32 + if: false # Need to run locally for now.
33 uses: reactivecircus/android-emulator-runner@v2.5.0 33 uses: reactivecircus/android-emulator-runner@v2.5.0
34 with: 34 with:
35 api-level: 29 35 api-level: 29
  1 +## 0.1.4+1
  2 +
  3 +* Finished migration to new Flutter plugin embedding.
  4 +* Fixed missing activity on Android for apps using the old plugin embedding.
  5 +* Lowered Flutter SDK version constraint to `1.12.0`.
  6 +
1 ## 0.1.4 7 ## 0.1.4
2 8
3 * Added assertion for `on` in `Wakelock.toggle` to be non-null and `@required` annotation. 9 * Added assertion for `on` in `Wakelock.toggle` to be non-null and `@required` annotation.
@@ -16,9 +16,11 @@ public class WakelockPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { @@ -16,9 +16,11 @@ public class WakelockPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
16 override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 16 override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
17 channel = MethodChannel(flutterPluginBinding.binaryMessenger, "wakelock") 17 channel = MethodChannel(flutterPluginBinding.binaryMessenger, "wakelock")
18 channel.setMethodCallHandler(this) 18 channel.setMethodCallHandler(this)
19 - setup() 19 + wakelock = Wakelock()
20 } 20 }
21 21
  22 + private var registrar: Registrar? = null
  23 +
22 // This static function is optional and equivalent to onAttachedToEngine. It supports the old 24 // This static function is optional and equivalent to onAttachedToEngine. It supports the old
23 // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting 25 // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting
24 // plugin registration via this function while apps migrate to use the new Android APIs 26 // plugin registration via this function while apps migrate to use the new Android APIs
@@ -33,34 +35,34 @@ public class WakelockPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { @@ -33,34 +35,34 @@ public class WakelockPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
33 fun registerWith(registrar: Registrar) { 35 fun registerWith(registrar: Registrar) {
34 val channel = MethodChannel(registrar.messenger(), "wakelock") 36 val channel = MethodChannel(registrar.messenger(), "wakelock")
35 val plugin = WakelockPlugin() 37 val plugin = WakelockPlugin()
  38 + plugin.registrar = registrar
  39 + plugin.wakelock = Wakelock()
36 channel.setMethodCallHandler(plugin) 40 channel.setMethodCallHandler(plugin)
37 - plugin.setup()  
38 } 41 }
39 } 42 }
40 43
41 private var wakelock: Wakelock? = null 44 private var wakelock: Wakelock? = null
42 45
43 - private fun setup() {  
44 - wakelock = Wakelock()  
45 - }  
46 -  
47 override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 46 override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
  47 + if (registrar != null) wakelock!!.activity = registrar!!.activity()
48 when (call.method) { 48 when (call.method) {
49 "toggle" -> { 49 "toggle" -> {
50 - wakelock?.toggle(call.argument<Boolean>("enable")!!, result) 50 + wakelock!!.toggle(call.argument<Boolean>("enable")!!, result)
51 } 51 }
52 "isEnabled" -> { 52 "isEnabled" -> {
53 - wakelock?.isEnabled(result) 53 + wakelock!!.isEnabled(result)
54 } 54 }
55 else -> { 55 else -> {
56 result.notImplemented() 56 result.notImplemented()
57 } 57 }
58 } 58 }
  59 + if (registrar != null) wakelock!!.activity = null
59 } 60 }
60 61
61 override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 62 override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
62 channel.setMethodCallHandler(null) 63 channel.setMethodCallHandler(null)
63 wakelock = null 64 wakelock = null
  65 + registrar = null
64 } 66 }
65 67
66 override fun onAttachedToActivity(binding: ActivityPluginBinding) { 68 override fun onAttachedToActivity(binding: ActivityPluginBinding) {
1 name: wakelock 1 name: wakelock
2 description: This plugin allows you to keep Android and iOS devices awake, i.e. prevent the screen from sleeping by toggling the wakelock of the device on or off. 2 description: This plugin allows you to keep Android and iOS devices awake, i.e. prevent the screen from sleeping by toggling the wakelock of the device on or off.
3 -version: 0.1.4 3 +version: 0.1.4+1
4 homepage: https://github.com/creativecreatorormaybenot/wakelock 4 homepage: https://github.com/creativecreatorormaybenot/wakelock
5 5
6 environment: 6 environment:
7 sdk: ">=2.7.0 <3.0.0" 7 sdk: ">=2.7.0 <3.0.0"
8 - flutter: ">=1.12.13+hotfix.8 <2.0.0" 8 + flutter: ">=1.12.0 <2.0.0"
9 9
10 dependencies: 10 dependencies:
11 flutter: 11 flutter: