Cherish: Bring Back LsClock settings
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -394,4 +394,22 @@
|
|||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Lockscreen Clock -->
|
||||||
|
<string-array name="lock_screen_custom_clock_face_entries" translatable="false">
|
||||||
|
<item>@string/lock_screen_custom_clock_face_default</item>
|
||||||
|
<item>@string/lock_screen_custom_clock_face_sfunny</item>
|
||||||
|
<item>@string/lock_screen_custom_clock_face_oos</item>
|
||||||
|
<item>@string/lock_screen_custom_clock_face_clockertino</item>
|
||||||
|
<item>@string/lock_screen_custom_clock_face_spark</item>
|
||||||
|
<item>@string/lock_screen_custom_clock_face_spark_circle</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="lock_screen_custom_clock_face_values" translatable="false">
|
||||||
|
<item>com.android.keyguard.clock.DefaultClockController</item>
|
||||||
|
<item>com.android.keyguard.clock.SfunnyClockController</item>
|
||||||
|
<item>com.android.keyguard.clock.OOSClockController</item>
|
||||||
|
<item>com.android.keyguard.clock.ClockertinoClockController</item>
|
||||||
|
<item>com.android.keyguard.clock.SparkClockController</item>
|
||||||
|
<item>com.android.keyguard.clock.SparkCircleClockController</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -604,4 +604,14 @@
|
|||||||
<string name="disable_usercard_title">Settings UserCard</string>
|
<string name="disable_usercard_title">Settings UserCard</string>
|
||||||
<string name="disable_usercard_summary">Toggle in order not to show the usercard on main settings page</string>
|
<string name="disable_usercard_summary">Toggle in order not to show the usercard on main settings page</string>
|
||||||
|
|
||||||
|
<!-- Lockscreen Clocks -->
|
||||||
|
<string name="lock_screen_custom_clock_face_category">Lockscreen Clock</string>
|
||||||
|
<string name="lock_screen_custom_clock_face_title">Lockscreen clock style</string>
|
||||||
|
<string name="lock_screen_custom_clock_face_default">Default</string>
|
||||||
|
<string name="lock_screen_custom_clock_face_sfunny">Sfuny</string>
|
||||||
|
<string name="lock_screen_custom_clock_face_oos">OOS</string>
|
||||||
|
<string name="lock_screen_custom_clock_face_clockertino">Clockertino</string>
|
||||||
|
<string name="lock_screen_custom_clock_face_spark">Spark</string>
|
||||||
|
<string name="lock_screen_custom_clock_face_spark_circle">Spark Circle</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -57,6 +57,18 @@
|
|||||||
android:title="@string/lockscreen_charging_info_title"
|
android:title="@string/lockscreen_charging_info_title"
|
||||||
android:summary="@string/lockscreen_charging_info_summary"
|
android:summary="@string/lockscreen_charging_info_summary"
|
||||||
android:defaultValue="true" />
|
android:defaultValue="true" />
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/lock_screen_custom_clock_face_category">
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="lock_screen_custom_clock_face"
|
||||||
|
android:summary="%s"
|
||||||
|
android:title="@string/lock_screen_custom_clock_face_title"
|
||||||
|
android:entries="@array/lock_screen_custom_clock_face_entries"
|
||||||
|
android:entryValues="@array/lock_screen_custom_clock_face_values" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="lockscreen_media_art_options"
|
android:key="lockscreen_media_art_options"
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
|
|||||||
Preference.OnPreferenceChangeListener {
|
Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
private static final String AOD_SCHEDULE_KEY = "always_on_display_schedule";
|
private static final String AOD_SCHEDULE_KEY = "always_on_display_schedule";
|
||||||
|
private static final String CUSTOM_CLOCK_FACE = Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE;
|
||||||
|
private static final String DEFAULT_CLOCK = "com.android.keyguard.clock.DefaultClockController";
|
||||||
|
|
||||||
static final int MODE_DISABLED = 0;
|
static final int MODE_DISABLED = 0;
|
||||||
static final int MODE_NIGHT = 1;
|
static final int MODE_NIGHT = 1;
|
||||||
@@ -66,6 +68,9 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
|
|||||||
static final int MODE_MIXED_SUNSET = 3;
|
static final int MODE_MIXED_SUNSET = 3;
|
||||||
static final int MODE_MIXED_SUNRISE = 4;
|
static final int MODE_MIXED_SUNRISE = 4;
|
||||||
|
|
||||||
|
private ListPreference mLockClockStyles;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
Preference mAODPref;
|
Preference mAODPref;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,6 +94,12 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
mAODPref = findPreference(AOD_SCHEDULE_KEY);
|
mAODPref = findPreference(AOD_SCHEDULE_KEY);
|
||||||
updateAlwaysOnSummary();
|
updateAlwaysOnSummary();
|
||||||
|
|
||||||
|
mLockClockStyles = (ListPreference) findPreference(CUSTOM_CLOCK_FACE);
|
||||||
|
String mLockClockStylesValue = getLockScreenCustomClockFace();
|
||||||
|
mLockClockStyles.setValue(mLockClockStylesValue);
|
||||||
|
mLockClockStyles.setSummary(mLockClockStyles.getEntry());
|
||||||
|
mLockClockStyles.setOnPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -123,8 +134,39 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
|
if (preference == mLockClockStyles) {
|
||||||
|
setLockScreenCustomClockFace((String) newValue);
|
||||||
|
int index = mLockClockStyles.findIndexOfValue((String) newValue);
|
||||||
|
mLockClockStyles.setSummary(mLockClockStyles.getEntries()[index]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getLockScreenCustomClockFace() {
|
||||||
|
mContext = getActivity();
|
||||||
|
String value = Settings.Secure.getStringForUser(mContext.getContentResolver(),
|
||||||
|
CUSTOM_CLOCK_FACE, USER_CURRENT);
|
||||||
|
|
||||||
|
if (value == null || value.isEmpty()) value = DEFAULT_CLOCK;
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject json = new JSONObject(value);
|
||||||
|
return json.getString("clock");
|
||||||
|
} catch (JSONException ex) {
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLockScreenCustomClockFace(String value) {
|
||||||
|
try {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("clock", value);
|
||||||
|
Settings.Secure.putStringForUser(mContext.getContentResolver(), CUSTOM_CLOCK_FACE,
|
||||||
|
json.toString(), USER_CURRENT);
|
||||||
|
} catch (JSONException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
|
|||||||
Reference in New Issue
Block a user