customize animation speed
This commit is contained in:
parent
0218ab3160
commit
8b4884616d
|
@ -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<String> versionList;
|
||||
private FCLSpinner<String> 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());
|
||||
|
|
|
@ -349,6 +349,50 @@
|
|||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"/>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:minHeight="48dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:auto_text_tint="true"
|
||||
android:layout_gravity="center"
|
||||
android:singleLine="true"
|
||||
android:text="@string/settings_launcher_animation_speed"/>
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLSeekBar
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:min="1"
|
||||
android:max="20"
|
||||
android:id="@+id/animation_speed"/>
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLTextView
|
||||
app:auto_text_tint="true"
|
||||
android:singleLine="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/animation_speed_text"/>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</com.tungsten.fcllibrary.component.view.FCLLinearLayout>
|
||||
|
||||
<com.tungsten.fcllibrary.component.view.FCLLinearLayout
|
||||
|
|
|
@ -1,45 +1,60 @@
|
|||
package com.tungsten.fcllibrary.anim;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
import com.tungsten.fcllibrary.component.theme.ThemeEngine;
|
||||
|
||||
public class DisplayAnimUtils {
|
||||
|
||||
public static void showViewFromLeft(View view, boolean animation) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
if (animation) {
|
||||
view.setAnimation(AnimationUtils.makeInAnimation(view.getContext(), true));
|
||||
Animation animation1 = AnimationUtils.makeInAnimation(view.getContext(), true);
|
||||
animation1.setDuration(ThemeEngine.getInstance().getTheme().getAnimationSpeed() * 100L);
|
||||
view.setAnimation(animation1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideViewToLeft(View view, boolean animation) {
|
||||
view.setVisibility(View.GONE);
|
||||
if (animation) {
|
||||
view.setAnimation(AnimationUtils.makeOutAnimation(view.getContext(), false));
|
||||
Animation animation1 = AnimationUtils.makeOutAnimation(view.getContext(), false);
|
||||
animation1.setDuration(ThemeEngine.getInstance().getTheme().getAnimationSpeed() * 100L);
|
||||
view.setAnimation(animation1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showViewFromRight(View view, boolean animation) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
if (animation) {
|
||||
view.setAnimation(AnimationUtils.makeInAnimation(view.getContext(), false));
|
||||
Animation animation1 = AnimationUtils.makeInAnimation(view.getContext(), false);
|
||||
animation1.setDuration(ThemeEngine.getInstance().getTheme().getAnimationSpeed() * 100L);
|
||||
view.setAnimation(animation1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideViewToRight(View view, boolean animation) {
|
||||
view.setVisibility(View.GONE);
|
||||
if (animation) {
|
||||
view.setAnimation(AnimationUtils.makeOutAnimation(view.getContext(), true));
|
||||
Animation animation1 = AnimationUtils.makeOutAnimation(view.getContext(), true);
|
||||
animation1.setDuration(ThemeEngine.getInstance().getTheme().getAnimationSpeed() * 100L);
|
||||
view.setAnimation(animation1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showViewWithAnim(View view, int animId) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
view.setAnimation(AnimationUtils.loadAnimation(view.getContext(), animId));
|
||||
Animation animation = AnimationUtils.loadAnimation(view.getContext(), animId);
|
||||
animation.setDuration(ThemeEngine.getInstance().getTheme().getAnimationSpeed() * 100L);
|
||||
view.setAnimation(animation);
|
||||
}
|
||||
|
||||
public static void hideViewWithAnim(View view, int animId) {
|
||||
view.setVisibility(View.GONE);
|
||||
view.setAnimation(AnimationUtils.loadAnimation(view.getContext(), animId));
|
||||
Animation animation = AnimationUtils.loadAnimation(view.getContext(), animId);
|
||||
animation.setDuration(ThemeEngine.getInstance().getTheme().getAnimationSpeed() * 100L);
|
||||
view.setAnimation(animation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
|
|||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
|
||||
import com.tungsten.fcllibrary.component.theme.ThemeEngine;
|
||||
import com.tungsten.fcllibrary.component.view.FCLDynamicIsland;
|
||||
|
||||
public class DynamicIslandAnim {
|
||||
|
@ -62,14 +63,17 @@ public class DynamicIslandAnim {
|
|||
if (hideAnimator != null && hideAnimator.isRunning()) {
|
||||
hideAnimator.cancel();
|
||||
}
|
||||
expandScaleAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", scale / 2f, 0.95f).setDuration(300);
|
||||
shrinkScaleAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", 0.95f, scale / 2f).setDuration(300);
|
||||
expandScaleAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 0.5f, 0.95f).setDuration(300);
|
||||
shrinkScaleAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 0.95f, 0.5f).setDuration(300);
|
||||
expandAdjustAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", 0.95f, 1f).setDuration(200);
|
||||
shrinkAdjustAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.95f).setDuration(200);
|
||||
expandAdjustAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 0.95f, 1f).setDuration(200);
|
||||
shrinkAdjustAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.95f).setDuration(200);
|
||||
int animationSpeed = ThemeEngine.getInstance().getTheme().getAnimationSpeed() * 100;
|
||||
int animationSpeedPri = (animationSpeed * 3) / 10;
|
||||
int animationSpeedSec = animationSpeed / 5;
|
||||
expandScaleAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", scale / 2f, 0.95f).setDuration(animationSpeedPri);
|
||||
shrinkScaleAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", 0.95f, scale / 2f).setDuration(animationSpeedPri);
|
||||
expandScaleAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 0.5f, 0.95f).setDuration(animationSpeedPri);
|
||||
shrinkScaleAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 0.95f, 0.5f).setDuration(animationSpeedPri);
|
||||
expandAdjustAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", 0.95f, 1f).setDuration(animationSpeedSec);
|
||||
shrinkAdjustAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.95f).setDuration(animationSpeedSec);
|
||||
expandAdjustAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 0.95f, 1f).setDuration(animationSpeedSec);
|
||||
shrinkAdjustAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.95f).setDuration(animationSpeedSec);
|
||||
hideAnimator = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f).setDuration(2000);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,11 @@ public class Theme {
|
|||
private final IntegerProperty dkColor = new SimpleIntegerProperty();
|
||||
private final IntegerProperty autoTint = new SimpleIntegerProperty();
|
||||
private final BooleanProperty fullscreen = new SimpleBooleanProperty();
|
||||
private final IntegerProperty animationSpeed = new SimpleIntegerProperty();
|
||||
private final ObjectProperty<BitmapDrawable> backgroundLt = new SimpleObjectProperty<>();
|
||||
private final ObjectProperty<BitmapDrawable> 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<BitmapDrawable> 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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue