mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Fossil Q: Migrate existing button preferences automatically
This commit is contained in:
committed by
Arjan Schrijver
parent
aa37f7bdce
commit
66f2c26c53
+20
-1
@@ -360,6 +360,25 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
String middleButtonFunction = getDeviceSpecificPreferences().getString("middle_button_function", "");
|
||||
String bottomButtonFunction = getDeviceSpecificPreferences().getString("bottom_button_function", "");
|
||||
JSONArray buttonConfigJson = new JSONArray();
|
||||
if (upperButtonFunction.isEmpty() && middleButtonFunction.isEmpty() && bottomButtonFunction.isEmpty()) {
|
||||
// Migrate old type button settings
|
||||
String buttonConfig = getDeviceSpecificPreferences().getString("buttons", null);
|
||||
if (buttonConfig != null) {
|
||||
JSONArray parsedConfig = new JSONArray(buttonConfig);
|
||||
if (parsedConfig.length() >= 3) {
|
||||
LOG.info("Found unmigrated button preferences, migrating now.");
|
||||
upperButtonFunction = parsedConfig.getString(0);
|
||||
middleButtonFunction = parsedConfig.getString(1);
|
||||
bottomButtonFunction = parsedConfig.getString(2);
|
||||
getDeviceSpecificPreferences()
|
||||
.edit()
|
||||
.putString("top_button_function", upperButtonFunction)
|
||||
.putString("middle_button_function", middleButtonFunction)
|
||||
.putString("bottom_button_function", bottomButtonFunction)
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
buttonConfigJson.put(upperButtonFunction);
|
||||
buttonConfigJson.put(middleButtonFunction);
|
||||
buttonConfigJson.put(bottomButtonFunction);
|
||||
@@ -386,7 +405,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
};
|
||||
queueWrite(fileUploadRequest);
|
||||
} catch (JSONException e) {
|
||||
LOG.error("error", e);
|
||||
LOG.error("JSON error", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user