diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-06-19 01:26:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-06-19 01:26:58 +0000 |
commit | 86816fc4c96704b9d7d8d6f4de2f2caabf79a893 (patch) | |
tree | 7f28ead9211640cbd64d4277cb1c4a305bd9467a | |
parent | 9ad06b48045cc1110ec04eabdbf4f9380ef25781 (diff) | |
parent | 8bf5250cbd41d61d1b8315f95e467f948cc2b5a6 (diff) | |
download | ThemePicker-86816fc4c96704b9d7d8d6f4de2f2caabf79a893.tar.gz |
Merge "Add timestamp when applying a clock face" into ub-launcher3-qt-r1-dev
-rw-r--r-- | src/com/android/customization/model/clock/ClockManager.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/android/customization/model/clock/ClockManager.java b/src/com/android/customization/model/clock/ClockManager.java index 3744317e..180d3a0c 100644 --- a/src/com/android/customization/model/clock/ClockManager.java +++ b/src/com/android/customization/model/clock/ClockManager.java @@ -20,6 +20,9 @@ import android.provider.Settings.Secure; import com.android.customization.module.ThemesUserEventLogger; +import org.json.JSONException; +import org.json.JSONObject; + /** * {@link CustomizationManager} for clock faces that implements apply by writing to secure settings. */ @@ -27,6 +30,8 @@ public class ClockManager extends BaseClockManager { // TODO: use constant from Settings.Secure static final String CLOCK_FACE_SETTING = "lock_screen_custom_clock_face"; + private static final String CLOCK_FIELD = "clock"; + private static final String TIMESTAMP_FIELD = "_applied_timestamp"; private final ContentResolver mContentResolver; private final ThemesUserEventLogger mEventLogger; @@ -39,7 +44,15 @@ public class ClockManager extends BaseClockManager { @Override protected void handleApply(Clockface option, Callback callback) { - boolean stored = Secure.putString(mContentResolver, CLOCK_FACE_SETTING, option.getId()); + boolean stored; + try { + final JSONObject json = new JSONObject(); + json.put(CLOCK_FIELD, option.getId()); + json.put(TIMESTAMP_FIELD, System.currentTimeMillis()); + stored = Secure.putString(mContentResolver, CLOCK_FACE_SETTING, json.toString()); + } catch (JSONException ex) { + stored = false; + } if (stored) { mEventLogger.logClockApplied(option); callback.onSuccess(); @@ -50,6 +63,12 @@ public class ClockManager extends BaseClockManager { @Override protected String lookUpCurrentClock() { - return Secure.getString(mContentResolver, CLOCK_FACE_SETTING); + final String value = Secure.getString(mContentResolver, CLOCK_FACE_SETTING); + try { + final JSONObject json = new JSONObject(value); + return json.getString(CLOCK_FIELD); + } catch (JSONException ex) { + return value; + } } } |