Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Closes #52 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
creativecreatorormaybenot authored Oct 25, 2020
1 parent e8dd53c commit afd369e
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 126 deletions.
5 changes: 5 additions & 0 deletions wakelock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
7 changes: 7 additions & 0 deletions wakelock/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ android {
lintOptions {
disable 'InvalidPackage'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
Expand Down
110 changes: 110 additions & 0 deletions wakelock/android/src/main/java/creativemaybeno/wakelock/Messages.java
Original file line number Diff line number Diff line change
@@ -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<String, Object> 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<String, Object> 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<Object> channel =
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.WakelockApi.toggle", new StandardMessageCodec());
if (api != null) {
channel.setMessageHandler((message, reply) -> {
HashMap<String, 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<Object> channel =
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.WakelockApi.isEnabled", new StandardMessageCodec());
if (api != null) {
channel.setMessageHandler((message, reply) -> {
HashMap<String, 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<String, Object> errorMap = new HashMap<>();
errorMap.put("message", exception.toString());
errorMap.put("code", exception.getClass().getSimpleName());
errorMap.put("details", null);
return errorMap;
}
}
121 changes: 0 additions & 121 deletions wakelock/android/src/main/kotlin/creativemaybeno/wakelock/Messages.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
2 changes: 1 addition & 1 deletion wakelock/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit afd369e

Please sign in to comment.