Cherish: Allow setting Lottie animation size [2/2]

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Advaith Bhat
2021-05-04 16:43:21 +00:00
committed by Hưng Phan
parent fb90dc38b9
commit 8921ede1d6
3 changed files with 41 additions and 0 deletions

View File

@@ -1409,4 +1409,7 @@
<string name="clock_lottie_animation_blue_circle_2">Blue Circle v2</string> <string name="clock_lottie_animation_blue_circle_2">Blue Circle v2</string>
<string name="clock_lottie_animation_rainbow_circle">Rainbow Circle</string> <string name="clock_lottie_animation_rainbow_circle">Rainbow Circle</string>
<string name="clock_lottie_animation_fire_circle">Fire Circle</string> <string name="clock_lottie_animation_fire_circle">Fire Circle</string>
<!-- Clock lottie animation size -->
<string name="clock_lottie_animation_size_title">Animation size</string>
</resources> </resources>

View File

@@ -86,6 +86,14 @@
android:summary="%s" android:summary="%s"
android:defaultValue="0" /> android:defaultValue="0" />
<com.cherish.settings.preferences.CustomSeekBarPreference
android:key="lockscreen_clock_animation_size"
android:title="@string/clock_lottie_animation_size_title"
android:max="500"
settings:min="300"
settings:units="dp"
android:defaultValue="300" />
<com.cherish.settings.preferences.SecureSettingListPreference <com.cherish.settings.preferences.SecureSettingListPreference
android:key="lockscreen_clock_selection" android:key="lockscreen_clock_selection"
android:title="@string/lockscreen_clock_title" android:title="@string/lockscreen_clock_title"

View File

@@ -24,6 +24,9 @@ import android.content.Context;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.app.WallpaperManager; import android.app.WallpaperManager;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources; import android.content.res.Resources;
import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager;
import android.net.Uri; import android.net.Uri;
@@ -66,6 +69,7 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
private static final String FOD_ICON_PICKER_CATEGORY = "fod_icon_picker"; private static final String FOD_ICON_PICKER_CATEGORY = "fod_icon_picker";
private static final String PREF_LS_CLOCK_SELECTION = "lockscreen_clock_selection"; private static final String PREF_LS_CLOCK_SELECTION = "lockscreen_clock_selection";
private static final String PREF_LS_CLOCK_ANIM_SELECTION = "lockscreen_clock_animation_selection"; private static final String PREF_LS_CLOCK_ANIM_SELECTION = "lockscreen_clock_animation_selection";
private static final String LOTTIE_ANIMATION_SIZE = "lockscreen_clock_animation_size";
private ContentResolver mResolver; private ContentResolver mResolver;
private Preference FODSettings; private Preference FODSettings;
@@ -82,6 +86,7 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
private PreferenceCategory mFODIconPickerCategory; private PreferenceCategory mFODIconPickerCategory;
private SecureSettingListPreference mLockClockSelection; private SecureSettingListPreference mLockClockSelection;
private SystemSettingListPreference mLockClockAnimSelection; private SystemSettingListPreference mLockClockAnimSelection;
private CustomSeekBarPreference mLottieAnimationSize;
private Preference mAODPref; private Preference mAODPref;
@Override @Override
@@ -93,6 +98,22 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
PreferenceScreen prefScreen = getPreferenceScreen(); PreferenceScreen prefScreen = getPreferenceScreen();
Resources resources = getResources(); Resources resources = getResources();
Resources res = null;
Context ctx = getContext();
float density = Resources.getSystem().getDisplayMetrics().density;
try {
res = ctx.getPackageManager().getResourcesForApplication("com.android.systemui");
} catch (NameNotFoundException e) {
e.printStackTrace();
}
mLottieAnimationSize = (CustomSeekBarPreference) findPreference(LOTTIE_ANIMATION_SIZE);
int lottieSize = Settings.System.getIntForUser(ctx.getContentResolver(),
Settings.System.LOCKSCREEN_CLOCK_ANIMATION_SIZE, res.getIdentifier("com.android.systemui:dimen/lottie_animation_width_height", null, null), UserHandle.USER_CURRENT);
mLottieAnimationSize.setValue(lottieSize);
mLottieAnimationSize.setOnPreferenceChangeListener(this);
mLockClockAnimSelection = (SystemSettingListPreference) findPreference(PREF_LS_CLOCK_ANIM_SELECTION); mLockClockAnimSelection = (SystemSettingListPreference) findPreference(PREF_LS_CLOCK_ANIM_SELECTION);
mLockClockSelection = (SecureSettingListPreference) findPreference(PREF_LS_CLOCK_SELECTION); mLockClockSelection = (SecureSettingListPreference) findPreference(PREF_LS_CLOCK_SELECTION);
@@ -101,8 +122,10 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
mLockClockSelection.setOnPreferenceChangeListener(this); mLockClockSelection.setOnPreferenceChangeListener(this);
if (val > 3 && val < 8) { if (val > 3 && val < 8) {
mLockClockAnimSelection.setEnabled(true); mLockClockAnimSelection.setEnabled(true);
mLottieAnimationSize.setEnabled(true);
} else { } else {
mLockClockAnimSelection.setEnabled(false); mLockClockAnimSelection.setEnabled(false);
mLottieAnimationSize.setEnabled(false);
} }
mFODIconPickerCategory = findPreference(FOD_ICON_PICKER_CATEGORY); mFODIconPickerCategory = findPreference(FOD_ICON_PICKER_CATEGORY);
@@ -192,6 +215,11 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
int top = (Integer) newValue; int top = (Integer) newValue;
Settings.System.putInt(getContentResolver(), Settings.System.putInt(getContentResolver(),
Settings.System.LOCKDATE_FONT_SIZE, top*1); Settings.System.LOCKDATE_FONT_SIZE, top*1);
return true;
} else if (preference == mLottieAnimationSize) {
int value = (Integer) newValue;
Settings.System.putIntForUser(getContext().getContentResolver(),
Settings.System.LOCKSCREEN_CLOCK_ANIMATION_SIZE, value, UserHandle.USER_CURRENT);
return true; return true;
} else if (preference == mLockClockSelection) { } else if (preference == mLockClockSelection) {
int val = Integer.parseInt((String) newValue); int val = Integer.parseInt((String) newValue);
@@ -199,8 +227,10 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
Settings.Secure.LOCKSCREEN_CLOCK_SELECTION, val); Settings.Secure.LOCKSCREEN_CLOCK_SELECTION, val);
if (val > 3 && val < 8) { if (val > 3 && val < 8) {
mLockClockAnimSelection.setEnabled(true); mLockClockAnimSelection.setEnabled(true);
mLottieAnimationSize.setEnabled(true);
} else { } else {
mLockClockAnimSelection.setEnabled(false); mLockClockAnimSelection.setEnabled(false);
mLottieAnimationSize.setEnabled(false);
} }
return true; return true;
} }