diff --git a/wakelock/CHANGELOG.md b/wakelock/CHANGELOG.md index 135437a5..8668a61e 100644 --- a/wakelock/CHANGELOG.md +++ b/wakelock/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.1 + +* Rewrite messages to stay as Java code and use `1.8` JVM target in order to allow interop with + Kotlin. This **fixes** Android build errors. + ## 0.2.0+2 * Bumped pigeon to `0.1.14`. diff --git a/wakelock/android/build.gradle b/wakelock/android/build.gradle index ab16a3d8..cf29b2ee 100644 --- a/wakelock/android/build.gradle +++ b/wakelock/android/build.gradle @@ -36,6 +36,13 @@ android { lintOptions { disable 'InvalidPackage' } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } } dependencies { diff --git a/wakelock/android/src/main/java/creativemaybeno/wakelock/Messages.java b/wakelock/android/src/main/java/creativemaybeno/wakelock/Messages.java new file mode 100644 index 00000000..8a006016 --- /dev/null +++ b/wakelock/android/src/main/java/creativemaybeno/wakelock/Messages.java @@ -0,0 +1,110 @@ +// Autogenerated from Pigeon (v0.1.14), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package creativemaybeno.wakelock; + +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; +import java.util.HashMap; + +/** Generated class from Pigeon. */ +@SuppressWarnings("unused") +public class Messages { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class ToggleMessage { + private Boolean enable; + public Boolean getEnable() { return enable; } + public void setEnable(Boolean setterArg) { this.enable = setterArg; } + + HashMap toMap() { + HashMap toMapResult = new HashMap<>(); + toMapResult.put("enable", enable); + return toMapResult; + } + static ToggleMessage fromMap(HashMap map) { + ToggleMessage fromMapResult = new ToggleMessage(); + Object enable = map.get("enable"); + fromMapResult.enable = (Boolean)enable; + return fromMapResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class IsEnabledMessage { + private Boolean enabled; + public Boolean getEnabled() { return enabled; } + public void setEnabled(Boolean setterArg) { this.enabled = setterArg; } + + HashMap toMap() { + HashMap toMapResult = new HashMap<>(); + toMapResult.put("enabled", enabled); + return toMapResult; + } + static IsEnabledMessage fromMap(HashMap map) { + IsEnabledMessage fromMapResult = new IsEnabledMessage(); + Object enabled = map.get("enabled"); + fromMapResult.enabled = (Boolean)enabled; + return fromMapResult; + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter.*/ + public interface WakelockApi { + void toggle(ToggleMessage arg); + IsEnabledMessage isEnabled(); + + /** Sets up an instance of `WakelockApi` to handle messages through the `binaryMessenger` */ + static void setup(BinaryMessenger binaryMessenger, WakelockApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.WakelockApi.toggle", new StandardMessageCodec()); + if (api != null) { + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + @SuppressWarnings("ConstantConditions") + ToggleMessage input = ToggleMessage.fromMap((HashMap)message); + api.toggle(input); + wrapped.put("result", null); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.WakelockApi.isEnabled", new StandardMessageCodec()); + if (api != null) { + channel.setMessageHandler((message, reply) -> { + HashMap wrapped = new HashMap<>(); + try { + IsEnabledMessage output = api.isEnabled(); + wrapped.put("result", output.toMap()); + } + catch (Exception exception) { + wrapped.put("error", wrapError(exception)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + private static HashMap wrapError(Exception exception) { + HashMap errorMap = new HashMap<>(); + errorMap.put("message", exception.toString()); + errorMap.put("code", exception.getClass().getSimpleName()); + errorMap.put("details", null); + return errorMap; + } +} diff --git a/wakelock/android/src/main/kotlin/creativemaybeno/wakelock/Messages.kt b/wakelock/android/src/main/kotlin/creativemaybeno/wakelock/Messages.kt deleted file mode 100644 index 048f7538..00000000 --- a/wakelock/android/src/main/kotlin/creativemaybeno/wakelock/Messages.kt +++ /dev/null @@ -1,121 +0,0 @@ -// Autogenerated from Pigeon (v0.1.14), do not edit directly. -// See also: https://pub.dev/packages/pigeon -package creativemaybeno.wakelock - -import io.flutter.plugin.common.BasicMessageChannel -import io.flutter.plugin.common.BinaryMessenger -import io.flutter.plugin.common.StandardMessageCodec -import java.util.ArrayList -import java.util.HashMap - -/** Generated class from Pigeon. */ -object Messages { - private fun wrapError(exception: Exception): HashMap { - val errorMap: HashMap = HashMap() - errorMap.put("message", exception.toString()) - errorMap.put("code", exception.getClass().getSimpleName()) - errorMap.put("details", null) - return errorMap - } - - /** Generated class from Pigeon that represents data sent in messages. */ - class ToggleMessage { - private var enable: Boolean? = null - fun getEnable(): Boolean? { - return enable - } - - fun setEnable(setterArg: Boolean?) { - enable = setterArg - } - - fun toMap(): HashMap { - val toMapResult: HashMap = HashMap() - toMapResult.put("enable", enable) - return toMapResult - } - - companion object { - fun fromMap(map: HashMap): ToggleMessage { - val fromMapResult = ToggleMessage() - val enable: Object = map.get("enable") - fromMapResult.enable = enable - return fromMapResult - } - } - } - - /** Generated class from Pigeon that represents data sent in messages. */ - class IsEnabledMessage { - private var enabled: Boolean? = null - fun getEnabled(): Boolean? { - return enabled - } - - fun setEnabled(setterArg: Boolean?) { - enabled = setterArg - } - - fun toMap(): HashMap { - val toMapResult: HashMap = HashMap() - toMapResult.put("enabled", enabled) - return toMapResult - } - - companion object { - fun fromMap(map: HashMap): IsEnabledMessage { - val fromMapResult = IsEnabledMessage() - val enabled: Object = map.get("enabled") - fromMapResult.enabled = enabled - return fromMapResult - } - } - } - - /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ - interface WakelockApi { - fun toggle(arg: ToggleMessage?) - val isEnabled: IsEnabledMessage - - companion object { - /** Sets up an instance of `WakelockApi` to handle messages through the `binaryMessenger` */ - fun setup(binaryMessenger: BinaryMessenger?, api: WakelockApi?) { - run { - val channel: BasicMessageChannel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.WakelockApi.toggle", StandardMessageCodec()) - if (api != null) { - channel.setMessageHandler { message, reply -> - val wrapped: HashMap = HashMap() - try { - @SuppressWarnings("ConstantConditions") val input = ToggleMessage.fromMap(message as HashMap) - api.toggle(input) - wrapped.put("result", null) - } catch (exception: Exception) { - wrapped.put("error", wrapError(exception)) - } - reply.reply(wrapped) - } - } else { - channel.setMessageHandler(null) - } - } - run { - val channel: BasicMessageChannel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.WakelockApi.isEnabled", StandardMessageCodec()) - if (api != null) { - channel.setMessageHandler { message, reply -> - val wrapped: HashMap = HashMap() - try { - val output = api.isEnabled - wrapped.put("result", output.toMap()) - } catch (exception: Exception) { - wrapped.put("error", wrapError(exception)) - } - reply.reply(wrapped) - } - } else { - channel.setMessageHandler(null) - } - } - } - } - } -} diff --git a/wakelock/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt b/wakelock/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt index 4430084e..3baf8ba2 100644 --- a/wakelock/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt +++ b/wakelock/android/src/main/kotlin/creativemaybeno/wakelock/WakelockPlugin.kt @@ -42,8 +42,7 @@ class WakelockPlugin : FlutterPlugin, WakelockApi, ActivityAware { wakelock!!.toggle(arg!!) } - override val isEnabled: IsEnabledMessage - get() { - return wakelock!!.isEnabled() - } + override fun isEnabled(): IsEnabledMessage { + return wakelock!!.isEnabled() + } } diff --git a/wakelock/pubspec.yaml b/wakelock/pubspec.yaml index 924938a6..c9516202 100644 --- a/wakelock/pubspec.yaml +++ b/wakelock/pubspec.yaml @@ -2,7 +2,7 @@ name: wakelock description: >-2 Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web. -version: 0.2.0+2 +version: 0.2.1 homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock environment: