mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Pebble: use dynamic appkeys for TrekVolle handler
This commit is contained in:
parent
8027b8ac96
commit
746eeda777
@ -21,7 +21,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
class AppMessageHandler {
|
||||
final PebbleProtocol mPebbleProtocol;
|
||||
final UUID mUUID;
|
||||
protected Map<String, Integer> messageKeys;
|
||||
Map<String, Integer> messageKeys;
|
||||
|
||||
AppMessageHandler(UUID uuid, PebbleProtocol pebbleProtocol) {
|
||||
mUUID = uuid;
|
||||
@ -55,7 +55,7 @@ class AppMessageHandler {
|
||||
return mPebbleProtocol.getDevice();
|
||||
}
|
||||
|
||||
protected JSONObject getAppKeys() throws IOException, JSONException {
|
||||
JSONObject getAppKeys() throws IOException, JSONException {
|
||||
File destDir = new File(FileUtils.getExternalFilesDir() + "/pbw-cache");
|
||||
File configurationFile = new File(destDir, mUUID.toString() + ".json");
|
||||
if (configurationFile.exists()) {
|
||||
|
@ -1,25 +1,65 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble;
|
||||
|
||||
import android.util.Pair;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
class AppMessageHandlerTrekVolle extends AppMessageHandler {
|
||||
private static final int MESSAGE_KEY_WEATHER_TEMPERATURE = 10000;
|
||||
private static final int MESSAGE_KEY_WEATHER_CONDITIONS = 10001;
|
||||
private static final int MESSAGE_KEY_WEATHER_ICON = 10002;
|
||||
private static final int MESSAGE_KEY_WEATHER_TEMPERATURE_MIN = 10024;
|
||||
private static final int MESSAGE_KEY_WEATHER_TEMPERATURE_MAX = 10025;
|
||||
private static final int MESSAGE_KEY_WEATHER_LOCATION = 10030;
|
||||
private Integer MESSAGE_KEY_WEATHER_TEMPERATURE;
|
||||
private Integer MESSAGE_KEY_WEATHER_CONDITIONS;
|
||||
private Integer MESSAGE_KEY_WEATHER_ICON;
|
||||
private Integer MESSAGE_KEY_WEATHER_TEMPERATURE_MIN;
|
||||
private Integer MESSAGE_KEY_WEATHER_TEMPERATURE_MAX;
|
||||
private Integer MESSAGE_KEY_WEATHER_LOCATION;
|
||||
|
||||
AppMessageHandlerTrekVolle(UUID uuid, PebbleProtocol pebbleProtocol) {
|
||||
super(uuid, pebbleProtocol);
|
||||
|
||||
messageKeys = new HashMap<>();
|
||||
try {
|
||||
JSONObject appKeys = getAppKeys();
|
||||
Iterator<String> appKeysIterator = appKeys.keys();
|
||||
while (appKeysIterator.hasNext()) {
|
||||
String current = appKeysIterator.next();
|
||||
int appKey = appKeys.getInt(current);
|
||||
switch (current) {
|
||||
case "WEATHER_TEMPERATURE":
|
||||
MESSAGE_KEY_WEATHER_TEMPERATURE = appKey;
|
||||
break;
|
||||
case "WEATHER_CONDITIONS":
|
||||
MESSAGE_KEY_WEATHER_CONDITIONS = appKey;
|
||||
break;
|
||||
case "WEATHER_ICON":
|
||||
MESSAGE_KEY_WEATHER_ICON = appKey;
|
||||
break;
|
||||
case "WEATHER_TEMPERATURE_MIN":
|
||||
MESSAGE_KEY_WEATHER_TEMPERATURE_MIN = appKey;
|
||||
break;
|
||||
case "WEATHER_TEMPERATURE_MAX":
|
||||
MESSAGE_KEY_WEATHER_TEMPERATURE_MAX = appKey;
|
||||
break;
|
||||
case "WEATHER_LOCATION":
|
||||
MESSAGE_KEY_WEATHER_LOCATION = appKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException | JSONException e) {
|
||||
GB.toast("There was an error accessing the watchface configuration.", Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private int getIconForConditionCode(int conditionCode, boolean isNight) {
|
||||
|
Loading…
Reference in New Issue
Block a user