diff --git a/app/src/main/java/eu/ottop/yamlauncher/Animations.kt b/app/src/main/java/eu/ottop/yamlauncher/Animations.kt index 431d981..e080531 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/Animations.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/Animations.kt @@ -15,12 +15,12 @@ class Animations (context: Context) { private val sharedPreferenceManager = SharedPreferenceManager(context) - fun fadeViewIn(view: View, duration: Long = 100) { - view.fadeIn(duration) + fun fadeViewIn(view: View) { + view.fadeIn() } - fun fadeViewOut(view: View, duration: Long = 100) { - view.fadeOut(duration) + fun fadeViewOut(view: View) { + view.fadeOut() } fun showHome(homeView: View, appView: View) { appView.slideOutToBottom() @@ -32,7 +32,7 @@ class Animations (context: Context) { homeView.fadeOut() } - fun backgroundIn(activity: Activity, duration: Long = 100) { + fun backgroundIn(activity: Activity) { val originalColor = sharedPreferenceManager.getBgColor() val newColor: Int = if (originalColor == Color.parseColor("#00000000")) { @@ -48,12 +48,13 @@ class Animations (context: Context) { backgroundColorAnimator.addUpdateListener { animator -> colorDrawable.color = animator.animatedValue as Int } + val duration = sharedPreferenceManager.getAnimationSpeed() backgroundColorAnimator.duration = duration backgroundColorAnimator.start() } - fun backgroundOut(activity: Activity, duration: Long = 100) { + fun backgroundOut(activity: Activity) { val newColor = sharedPreferenceManager.getBgColor() val originalColor: Int = if (newColor == Color.parseColor("#00000000")) { @@ -69,32 +70,37 @@ class Animations (context: Context) { backgroundColorAnimator.addUpdateListener { animator -> colorDrawable.color = animator.animatedValue as Int } + val duration = sharedPreferenceManager.getAnimationSpeed() backgroundColorAnimator.duration = duration backgroundColorAnimator.start() } - private fun View.slideInFromBottom(duration: Long = 100) { + private fun View.slideInFromBottom() { if (visibility != View.VISIBLE) { translationY = height.toFloat()/5 scaleY = 1.2f alpha = 0f visibility = View.VISIBLE + val duration = sharedPreferenceManager.getAnimationSpeed() + animate() - .translationY(0f) - .scaleY(1f) - .alpha(1f) - .setDuration(duration) - .setListener(null) + .translationY(0f) + .scaleY(1f) + .alpha(1f) + .setDuration(duration) + .setListener(null) } } - private fun View.slideOutToBottom(duration: Long = 50) { + private fun View.slideOutToBottom() { if (visibility == View.VISIBLE) { + val duration = sharedPreferenceManager.getAnimationSpeed() + animate() .translationY(height.toFloat() / 5) .scaleY(1.2f) .alpha(0f) - .setDuration(duration) + .setDuration(duration/2) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { visibility = View.INVISIBLE @@ -103,29 +109,36 @@ class Animations (context: Context) { } } - private fun View.fadeIn(duration: Long = 100) { + private fun View.fadeIn() { if (visibility != View.VISIBLE) { alpha = 0f translationY = -height.toFloat()/100 visibility = View.VISIBLE + val duration = sharedPreferenceManager.getAnimationSpeed() + animate() .alpha(1f) .translationY(0f) .setDuration(duration) .setListener(null) + } } - private fun View.fadeOut(duration: Long = 50) { + private fun View.fadeOut() { if (visibility == View.VISIBLE) { + val duration = sharedPreferenceManager.getAnimationSpeed() + animate() .alpha(0f) .translationY(-height.toFloat()/100) - .setDuration(duration) + .setDuration(duration/2) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { visibility = View.GONE } - })} + }) + + } } } \ No newline at end of file diff --git a/app/src/main/java/eu/ottop/yamlauncher/AppActionMenu.kt b/app/src/main/java/eu/ottop/yamlauncher/AppActionMenu.kt index bc83454..8c5a8a2 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/AppActionMenu.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/AppActionMenu.kt @@ -48,7 +48,7 @@ class AppActionMenu { ) } - animations.fadeViewOut(actionMenu, 100) + animations.fadeViewOut(actionMenu) textView.visibility = View.VISIBLE } @@ -58,7 +58,7 @@ class AppActionMenu { intent.putExtra(Intent.EXTRA_USER, userHandle) activity.startActivity(intent) - animations.fadeViewOut(actionMenu, 100) + animations.fadeViewOut(actionMenu) textView.visibility = View.VISIBLE } @@ -66,7 +66,7 @@ class AppActionMenu { actionMenu.findViewById(R.id.rename).setOnClickListener { textView.visibility = View.INVISIBLE animations.fadeViewIn(editLayout) - animations.fadeViewOut(actionMenu, 100) + animations.fadeViewOut(actionMenu) val editText = editLayout.findViewById(R.id.appNameEdit) val resetButton = editLayout.findViewById(R.id.reset) @@ -86,7 +86,7 @@ class AppActionMenu { if (bottom - top > oldBottom - oldTop) { editLayout.clearFocus() - animations.fadeViewOut(editLayout, 100) + animations.fadeViewOut(editLayout) textView.visibility = View.VISIBLE searchView.visibility = View.VISIBLE } @@ -138,7 +138,7 @@ class AppActionMenu { } actionMenu.findViewById(R.id.close).setOnClickListener { - animations.fadeViewOut(actionMenu, 100) + animations.fadeViewOut(actionMenu) textView.visibility = View.VISIBLE } } diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index c6a2edb..b6d51f7 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -370,6 +370,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh closeKeyboard() animations.showHome(binding.homeView, binding.appView) animations.backgroundOut(this@MainActivity) + val animSpeed = sharedPreferenceManager.getAnimationSpeed() val handler = Handler(Looper.getMainLooper()) handler.postDelayed({ try { @@ -378,7 +379,8 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh catch (_: UninitializedPropertyAccessException) { } - }, 100) + }, animSpeed) + handler.postDelayed({ lifecycleScope.launch { refreshAppMenu() @@ -391,7 +393,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh catch (_: UninitializedPropertyAccessException) { } - }}, 150) + }}, animSpeed + 50) } diff --git a/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt b/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt index a227bce..a7dc30a 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/SharedPreferenceManager.kt @@ -161,4 +161,12 @@ class SharedPreferenceManager (context: Context) { fun isBatteryEnabled(): Boolean { return preferences.getBoolean("battery_enabled", false) } + + fun getAnimationSpeed(): Long { + val animSpeed = preferences.getString("animationSpeed", "200")?.toLong() + if (animSpeed != null) { + return animSpeed + } + return 200 + } } \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 9f1423d..dbf8646 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,17 +1,6 @@ - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - + Transparent Black @@ -36,6 +25,35 @@ #FF0C0C0C + + 0.25x + 0.5x + 1x + 2x + 4x + + + + 800 + 400 + 200 + 100 + 50 + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + Left Center @@ -60,6 +78,7 @@ large + °C °F diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c82d7c5..47961f7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,12 +5,14 @@ App + Select an app Unhide an app Find your city Search… + Reset Info Uninstall @@ -18,6 +20,7 @@ Hide Close + App Icon By Otto Petäjä Source Code @@ -28,19 +31,17 @@ Liberapay Weather data by Open-Meteo.com\n(CC BY 4.0) + Otto Petäjä]]> - Codeberg]]> GitHub]]> - Liberapay
(recurring)]]>
Stripe
(one-time)]]>
- Open-Meteo.com
(CC BY 4.0)]]>
+ + Open-Meteo.com (CC BY 4.0)]]> %1$s%2$s The permission is required for double tap to work for locking the screen.\n\nIt is only needed if you want to use the double tap to lock screen feature in YAM Launcher. - -
\ No newline at end of file diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index fc8ddff..a224b06 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -30,6 +30,15 @@ android:defaultValue="false" android:title="Show Status Bar" app:key="barVisibility" /> +