diff --git a/FCL/src/main/java/com/tungsten/fcl/ui/setting/LauncherSettingPage.java b/FCL/src/main/java/com/tungsten/fcl/ui/setting/LauncherSettingPage.java index 52d3f22b..73c2cdb6 100644 --- a/FCL/src/main/java/com/tungsten/fcl/ui/setting/LauncherSettingPage.java +++ b/FCL/src/main/java/com/tungsten/fcl/ui/setting/LauncherSettingPage.java @@ -34,6 +34,7 @@ import com.tungsten.fcllibrary.browser.options.LibMode; import com.tungsten.fcllibrary.browser.options.SelectionMode; import com.tungsten.fcllibrary.component.dialog.FCLAlertDialog; import com.tungsten.fcllibrary.component.dialog.FCLColorPickerDialog; +import com.tungsten.fcllibrary.component.theme.Theme; import com.tungsten.fcllibrary.component.theme.ThemeEngine; import com.tungsten.fcllibrary.component.ui.FCLCommonPage; import com.tungsten.fcllibrary.component.view.FCLButton; @@ -69,6 +70,8 @@ public class LauncherSettingPage extends FCLCommonPage implements View.OnClickLi private FCLButton resetLtBackground; private FCLButton resetDkBackground; private FCLSwitch ignoreNotch; + private FCLSeekBar animationSpeed; + private FCLTextView animationSpeedText; private FCLCheckBox autoSource; private FCLSpinner versionList; private FCLSpinner downloadType; @@ -94,6 +97,8 @@ public class LauncherSettingPage extends FCLCommonPage implements View.OnClickLi resetLtBackground = findViewById(R.id.reset_background_lt); resetDkBackground = findViewById(R.id.reset_background_dk); ignoreNotch = findViewById(R.id.ignore_notch); + animationSpeed = findViewById(R.id.animation_speed); + animationSpeedText = findViewById(R.id.animation_speed_text); autoSource = findViewById(R.id.check_auto_source); versionList = findViewById(R.id.source_auto); downloadType = findViewById(R.id.source); @@ -124,6 +129,12 @@ public class LauncherSettingPage extends FCLCommonPage implements View.OnClickLi ignoreNotch.setChecked(ThemeEngine.getInstance().getTheme().isFullscreen()); ignoreNotch.setOnCheckedChangeListener(this); + animationSpeed.setProgress(ThemeEngine.getInstance().getTheme().getAnimationSpeed()); + animationSpeed.addProgressListener(); + animationSpeed.progressProperty().bindBidirectional(ThemeEngine.getInstance().getTheme().animationSpeedProperty()); + animationSpeedText.stringProperty().bind(Bindings.createStringBinding(() -> animationSpeed.getProgress() * 100 + " MS", animationSpeed.progressProperty())); + ThemeEngine.getInstance().getTheme().animationSpeedProperty().addListener(observable -> Theme.saveTheme(getContext(), ThemeEngine.getInstance().getTheme())); + autoSource.setChecked(config().autoChooseDownloadTypeProperty().get()); autoSource.addCheckedChangeListener(); autoSource.checkProperty().bindBidirectional(config().autoChooseDownloadTypeProperty()); diff --git a/FCL/src/main/res/layout/page_launcher_setting.xml b/FCL/src/main/res/layout/page_launcher_setting.xml index 49f1677a..7fa84c3f 100644 --- a/FCL/src/main/res/layout/page_launcher_setting.xml +++ b/FCL/src/main/res/layout/page_launcher_setting.xml @@ -349,6 +349,50 @@ + + + + + + + + + + + + backgroundLt = new SimpleObjectProperty<>(); private final ObjectProperty backgroundDk = new SimpleObjectProperty<>(); - public Theme(int color, boolean fullscreen, BitmapDrawable backgroundLt, BitmapDrawable backgroundDk) { + public Theme(int color, boolean fullscreen, int animationSpeed, BitmapDrawable backgroundLt, BitmapDrawable backgroundDk) { float[] ltHsv = new float[3]; Color.colorToHSV(color, ltHsv); ltHsv[1] -= (1 - ltHsv[1]) * 0.3f; @@ -46,6 +47,7 @@ public class Theme { this.ltColor.set(Color.HSVToColor(ltHsv)); this.dkColor.set(Color.HSVToColor(dkHsv)); this.fullscreen.set(fullscreen); + this.animationSpeed.set(animationSpeed); this.autoTint.set(ColorUtils.calculateLuminance(color) >= 0.5 ? Color.parseColor("#FF000000") : Color.parseColor("#FFFFFFFF")); this.backgroundLt.set(backgroundLt); this.backgroundDk.set(backgroundDk); @@ -75,6 +77,10 @@ public class Theme { return fullscreen.get(); } + public int getAnimationSpeed() { + return animationSpeed.get(); + } + public BitmapDrawable getBackgroundLt() { return backgroundLt.get(); } @@ -103,6 +109,10 @@ public class Theme { return fullscreen; } + public IntegerProperty animationSpeedProperty() { + return animationSpeed; + } + public ObjectProperty ltBackgroundProperty() { return backgroundLt; } @@ -135,6 +145,10 @@ public class Theme { this.fullscreen.set(fullscreen); } + public void setAnimationSpeed(int animationSpeed) { + this.animationSpeed.set(animationSpeed); + } + public void setBackgroundLt(BitmapDrawable backgroundLt) { this.backgroundLt.set(backgroundLt); } @@ -148,11 +162,12 @@ public class Theme { sharedPreferences = context.getSharedPreferences("theme", MODE_PRIVATE); int color = sharedPreferences.getInt("theme_color", Color.parseColor("#7797CF")); boolean fullscreen = sharedPreferences.getBoolean("fullscreen", false); + int animationSpeed = sharedPreferences.getInt("animation_speed", 8); Bitmap lt = !new File(context.getFilesDir().getAbsolutePath() + "/background/lt.png").exists() ? ConvertUtils.getBitmapFromRes(context, R.drawable.background_light) : BitmapFactory.decodeFile(context.getFilesDir().getAbsolutePath() + "/background/lt.png"); BitmapDrawable backgroundLt = new BitmapDrawable(lt); Bitmap dk = !new File(context.getFilesDir().getAbsolutePath() + "/background/dk.png").exists() ? ConvertUtils.getBitmapFromRes(context, R.drawable.background_dark) : BitmapFactory.decodeFile(context.getFilesDir().getAbsolutePath() + "/background/dk.png"); BitmapDrawable backgroundDk = new BitmapDrawable(dk); - return new Theme(color, fullscreen, backgroundLt, backgroundDk); + return new Theme(color, fullscreen, animationSpeed, backgroundLt, backgroundDk); } public static void saveTheme(Context context, Theme theme) { @@ -162,6 +177,7 @@ public class Theme { editor = sharedPreferences.edit(); editor.putInt("theme_color", theme.getColor()); editor.putBoolean("fullscreen", theme.isFullscreen()); + editor.putInt("animation_speed", theme.getAnimationSpeed()); editor.apply(); } }