Pebble: Pass booleans from Javascript Appmessage as such and convert to int16 later when sending to pebble

https://developer.pebble.com/guides/communication/using-pebblekit-js/#type-conversion
master
Andreas Shimokawa 2017-07-28 23:54:29 +02:00
parent 8353026c08
commit c2af2dd15c
2 changed files with 2 additions and 3 deletions

View File

@ -221,9 +221,6 @@ public class ExternalPebbleJSActivity extends GBActivity {
if (passKey) {
Object obj = in.get(inKey);
if (obj instanceof Boolean) {
obj = ((Boolean) obj) ? "true" : "false";
}
out.put(outKey, obj);
} else {
GB.toast("Discarded key " + inKey + ", not found in the local configuration and is not an integer key.", Toast.LENGTH_SHORT, GB.WARN);

View File

@ -87,6 +87,8 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
byteArray[i] = ((Integer) jsonArray.get(i)).byteValue();
}
object = byteArray;
} else if (object instanceof Boolean) {
object = (short) (((Boolean) object) ? 1 : 0);
}
pairs.add(new Pair<>(Integer.parseInt(keyStr), object));
}