Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

launcher: reduced_motion settles in 5 frames, nothing over 90 ms

sim8f5d4bf07316
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
index d55717cba..cc380acaf 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -469,7 +469,7 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
try {
ctx.startActivity(i);
if (cinematic) LastOpened.record(ctx, e.pkg);
- if (advancedEffects && ctx instanceof Activity) {
+ if (advancedEffects && !reducedMotion && ctx instanceof Activity) {
((Activity) ctx).overridePendingTransition(R.anim.app_open_enter, R.anim.app_open_exit);
}
} catch (Exception ex) {
@@ -703,13 +703,15 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
name.setAlpha(focused ? 1f : restNameAlpha);
name.setTranslationY(0f);
} else if (reducedMotion) {
+ // A short zoom with no hardware layer: building a layer for so short an animation costs more
+ // frames than it saves. The name just appears instead of fading.
view.animate().scaleX(s).scaleY(s)
.translationY(focused && advancedEffects ? -4f * density : 0f)
.translationZ(focused && advancedEffects ? 8f * density : 0f)
- .setDuration(focused ? 120 : 80)
+ .setDuration(focused ? Motion.REDUCED_MS : 60)
.setInterpolator(new DecelerateInterpolator())
- .withLayer().start();
- name.animate().alpha(focused ? 1f : restNameAlpha).setDuration(100).start();
+ .start();
+ name.setAlpha(focused ? 1f : restNameAlpha);
// Same place as the full motion's slide ends: the layout's -6dp is only its starting point, and
// left there the name overlaps the zoomed tile.
// Only on focus: snapping it back to -6dp while it fades out would jump it up over the tile.
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java b/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java
index 29c5d5bf2..e7d92edc8 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java
@@ -145,7 +145,7 @@ final class AppLibraryDialog {
activity.getWindowManager().updateViewLayout(container, params);
}
panel.setAlpha(0f);
- panel.animate().alpha(1f).setDuration(180).start();
+ panel.animate().alpha(1f).setDuration(reducedMotion ? Motion.REDUCED_MS : 180).start();
}
/** Called by the activity's existing package receiver; an uninstall cannot leave a stale action. */
@@ -267,8 +267,8 @@ final class AppLibraryDialog {
@Override public float getValue(View view) { return view.getTranslationX() + scrollOffset; }
@Override public void setValue(View view, float value) { view.setTranslationX(value - scrollOffset); }
});
- spring.setSpring(new SpringForce().setStiffness(reducedMotion ? 1400f : 260f)
- .setDampingRatio(reducedMotion ? 0.95f : 0.58f));
+ if (reducedMotion) Motion.reduce(spring);
+ else spring.setSpring(new SpringForce().setStiffness(260f).setDampingRatio(0.58f));
list.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override public void onScrolled(@NonNull RecyclerView rv, int dx, int dy) {
scrollOffset += dx;
@@ -399,7 +399,7 @@ final class AppLibraryDialog {
menuPanel.setScaleY(0.92f);
menuPanel.setTranslationY(-dp(8));
menu.showAtLocation(activity.getWindow().getDecorView(), Gravity.TOP | Gravity.START, x, y);
- menuPanel.animate().alpha(1f).scaleY(1f).translationY(0f).setDuration(220)
+ menuPanel.animate().alpha(1f).scaleY(1f).translationY(0f).setDuration(reducedMotion ? Motion.REDUCED_MS : 220)
.setInterpolator(new android.view.animation.DecelerateInterpolator(1.6f)).start();
rows.getChildAt(0).requestFocus();
}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index e89977e15..909e7b027 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -432,11 +432,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
}
});
if (dockRow) grid.addItemDecoration(new DockDecoration(COLUMNS, density, cinematic, cfg.alwaysShowNames));
- if (animations) {
- int enterAnim = reducedMotion ? R.anim.tile_enter_reduced : R.anim.tile_enter;
- float enterDelay = reducedMotion ? 0f : 0.06f;
+ // Reduced motion: the tiles are simply there, with no entrance (reloadApps skips it there too).
+ if (animations && !reducedMotion) {
grid.setLayoutAnimation(new LayoutAnimationController(
- AnimationUtils.loadAnimation(this, enterAnim), enterDelay));
+ AnimationUtils.loadAnimation(this, R.anim.tile_enter), 0.06f));
}
adapter = new AppAdapter(this, this, COLUMNS, cfg);
dockApps = cfg.dockApps;
@@ -498,10 +497,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
});
for (SpringAnimation s : new SpringAnimation[]{springX, springY}) {
if (reducedMotion) {
- // Stiff and almost critically damped: settles in a few frames instead of oscillating,
- // and stops once the highlight is within 1.5 px of its tile.
- s.setSpring(new SpringForce().setStiffness(1400f).setDampingRatio(0.95f));
- s.setMinimumVisibleChange(1.5f);
+ Motion.reduce(s);
} else {
s.setSpring(new SpringForce().setStiffness(advancedEffects ? 320f : 260f)
.setDampingRatio(advancedEffects ? 0.76f : 0.58f));
@@ -565,7 +561,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
for (View button : new View[]{btnInputs, btnWifi, btnReorder, btnLibraryTop, btnSettings}) {
button.setOnFocusChangeListener((view, focused) -> view.animate()
.scaleX(focused ? 1.04f : 1f).scaleY(focused ? 1.04f : 1f)
- .setDuration(160).start());
+ .setDuration(reducedMotion ? Motion.REDUCED_MS : 160).start());
}
}
if (festive) applyFestiveSkin((TextView) btnInputs, (TextView) btnSettings);
@@ -1212,7 +1208,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
springY.cancel();
glass.setTranslationX(x);
glass.setTranslationY(y);
- if (animations) glass.animate().alpha(1f).setDuration(reducedMotion ? 100 : 180).start();
+ if (animations && !reducedMotion) glass.animate().alpha(1f).setDuration(180).start();
else glass.setAlpha(1f);
glassShown = true;
} else if (!animations) {
@@ -1283,12 +1279,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
hero.setAlpha(1f);
if (ambientGlow) {
setAmbient(color);
- if (!animations) {
- ambient.setAlpha(1f);
- } else if (!heroShown) {
- ambient.setAlpha(0f);
- ambient.animate().alpha(1f).setDuration(160).start();
- }
+ ambient.setAlpha(1f);
}
heroShown = true;
return;
@@ -1403,7 +1394,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private void fadeHeroArt(int ms) {
if (!animations) heroArt.setAlpha(HERO_ART_ALPHA);
- else heroArt.animate().alpha(HERO_ART_ALPHA).setDuration(reducedMotion ? Math.min(ms, 160) : ms).start();
+ else heroArt.animate().alpha(HERO_ART_ALPHA).setDuration(reducedMotion ? Math.min(ms, Motion.REDUCED_MS) : ms).start();
}
/** "Last opened yesterday, 9:40 PM", the time in white; nothing (but the same height) when it was never seen. */
@@ -1552,10 +1543,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
ambient.animate().cancel();
heroArt.animate().cancel();
heroShown = false;
- if (animations) {
- hero.animate().alpha(0f).setDuration(reducedMotion ? 100 : 160).start();
- if (ambientGlow) ambient.animate().alpha(0f).setDuration(reducedMotion ? 140 : 300).start();
- heroArt.animate().alpha(0f).setDuration(reducedMotion ? 140 : 300).start();
+ if (animations && !reducedMotion) {
+ hero.animate().alpha(0f).setDuration(160).start();
+ if (ambientGlow) ambient.animate().alpha(0f).setDuration(300).start();
+ heroArt.animate().alpha(0f).setDuration(300).start();
} else {
hero.setAlpha(0f);
ambient.setAlpha(0f);
@@ -1567,7 +1558,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
if (!glassShown) return;
glassShown = false;
glass.animate().cancel();
- if (animations) glass.animate().alpha(0f).setDuration(160).start();
+ if (animations && !reducedMotion) glass.animate().alpha(0f).setDuration(160).start();
else glass.setAlpha(0f);
}
@@ -2419,7 +2410,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
panel.setScaleY(0.92f);
panel.setTranslationY(-8 * density);
popup.showAsDropDown(anchor, 0, (int) (10 * density), gravity);
- panel.animate().alpha(1f).scaleY(1f).translationY(0f).setDuration(220)
+ panel.animate().alpha(1f).scaleY(1f).translationY(0f).setDuration(reducedMotion ? Motion.REDUCED_MS : 220)
.setInterpolator(new android.view.animation.DecelerateInterpolator(1.6f)).start();
}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Motion.java b/launcher/app/src/main/java/com/gathin/tvhome/Motion.java
new file mode 100644
index 000000000..89867980d
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Motion.java
@@ -0,0 +1,23 @@
+package com.gathin.tvhome;
+
+import androidx.dynamicanimation.animation.SpringAnimation;
+import androidx.dynamicanimation.animation.SpringForce;
+
+/** Reduced motion (config.xml reduced_motion): the one spring and the one time limit every animation uses then. */
+final class Motion {
+
+ /** The longest any reduced-motion animation runs, in milliseconds. */
+ static final int REDUCED_MS = 90;
+ /** Critically damped (no bounce) and stiff enough that any move, even across the screen, settles in 5 frames. */
+ static final float REDUCED_STIFFNESS = 15000f;
+ /** The spring stops once it is within this many pixels of its target. */
+ static final float REDUCED_MIN_CHANGE = 2f;
+
+ private Motion() {
+ }
+
+ static void reduce(SpringAnimation spring) {
+ spring.setSpring(new SpringForce().setStiffness(REDUCED_STIFFNESS).setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY));
+ spring.setMinimumVisibleChange(REDUCED_MIN_CHANGE);
+ }
+}
diff --git a/launcher/app/src/main/res/anim/tile_enter_reduced.xml b/launcher/app/src/main/res/anim/tile_enter_reduced.xml
deleted file mode 100644
index 6f8289645..000000000
--- a/launcher/app/src/main/res/anim/tile_enter_reduced.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:interpolator/decelerate_cubic"
- android:duration="160">
- <alpha android:fromAlpha="0.0" android:toAlpha="1.0" />
- <translate android:fromYDelta="6%" android:toYDelta="0%" />
- <scale
- android:fromXScale="0.98" android:toXScale="1.0"
- android:fromYScale="0.98" android:toYScale="1.0"
- android:pivotX="50%" android:pivotY="50%" />
-</set>
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 4ca1b963c..b78f61698 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -161,8 +161,9 @@
<bool name="module_cards">true</bool>
<!-- Reduced motion: for TVs whose GPU cannot keep up (MediaTek MT5895 on Android 10 is the known case).
- true keeps the GPU drawing path but calms the movement: a stiff highlight spring with no bounce,
- tiles that zoom without overshoot, shorter fades and no tile entrance when Home comes back. Set it
+ true keeps the GPU drawing path but calms the movement and draws far fewer frames: the highlight
+ slides with no bounce and settles within 5 frames, every animation lasts 90 ms or less, names, top
+ shelf, glow and highlight appear instead of fading, and there is no tile entrance. Set it
here or with "reduced_motion": true in a theme's config.json; false keeps the normal motion. -->
<bool name="reduced_motion">false</bool>
diff --git a/launcher/app/src/test/java/androidx/dynamicanimation/animation/SpringFrames.java b/launcher/app/src/test/java/androidx/dynamicanimation/animation/SpringFrames.java
new file mode 100644
index 000000000..29b5461cf
--- /dev/null
+++ b/launcher/app/src/test/java/androidx/dynamicanimation/animation/SpringFrames.java
@@ -0,0 +1,25 @@
+package androidx.dynamicanimation.animation;
+
+/**
+ * Test helper in the library's own package, for the package-private stepping SpringAnimation does on each frame:
+ * counts the frames a spring needs to come to rest after a move, with the threshold SpringAnimation derives from
+ * setMinimumVisibleChange.
+ */
+public final class SpringFrames {
+
+ private SpringFrames() {
+ }
+
+ public static int toSettle(float stiffness, float dampingRatio, float minimumVisibleChange, float distancePx) {
+ SpringForce spring = new SpringForce(0f).setStiffness(stiffness).setDampingRatio(dampingRatio);
+ spring.setValueThreshold(minimumVisibleChange * 0.75f); // DynamicAnimation.THRESHOLD_MULTIPLIER
+ double value = -distancePx, velocity = 0;
+ for (int frame = 1; frame <= 120; frame++) {
+ DynamicAnimation.MassState s = spring.updateValues(value, velocity, frame % 3 == 0 ? 16 : 17); // 60 Hz
+ value = s.mValue;
+ velocity = s.mVelocity;
+ if (spring.isAtEquilibrium((float) value, (float) velocity)) return frame;
+ }
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/MotionTest.java b/launcher/app/src/test/java/com/gathin/tvhome/MotionTest.java
new file mode 100644
index 000000000..780498a4c
--- /dev/null
+++ b/launcher/app/src/test/java/com/gathin/tvhome/MotionTest.java
@@ -0,0 +1,26 @@
+package com.gathin.tvhome;
+
+import androidx.dynamicanimation.animation.SpringForce;
+import androidx.dynamicanimation.animation.SpringFrames;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/** Reduced motion's spring: no bounce, and settled within 5 frames at 60 Hz for any move on a 1080p screen. */
+public class MotionTest {
+
+ @Test
+ public void reducedSpringSettlesWithinFiveFrames() {
+ for (float px : new float[]{50, 150, 300, 600, 1000, 1920}) {
+ int frames = SpringFrames.toSettle(Motion.REDUCED_STIFFNESS, SpringForce.DAMPING_RATIO_NO_BOUNCY,
+ Motion.REDUCED_MIN_CHANGE, px);
+ assertTrue(px + " px took " + frames + " frames", frames <= 5);
+ }
+ }
+
+ @Test
+ public void reducedAnimationsLastAtMost100ms() {
+ assertTrue(Motion.REDUCED_MS <= 100);
+ }
+}
diff --git a/themes/README.md b/themes/README.md
index e9ae32cfe..2bd43a0c9 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -51,7 +51,7 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `shamsi_date` | bool | Show the Solar Hijri date above the Gregorian one |
| `greeting_name` | string | A name after the greeting, e.g. `"Mr. Trịnh"` for GOOD MORNING, MR. TRỊNH; empty for the greeting alone |
| `module_cards` | bool | Look for module cards and ask about them (`true`); `false` turns the feature off |
-| `reduced_motion` | bool | Calmer motion for weak GPUs: stiff highlight spring, no tile overshoot, short fades, no entrance replay |
+| `reduced_motion` | bool | Calmer motion for weak GPUs: highlight settles in 5 frames, animations 90 ms or less, no fades, no tile entrance |
| `vpn_app` | string | App the network pill opens when a VPN is configured; also shows a red "VPN off" badge while no VPN is up |
| `animations` | bool | Basic focus, glass, title and tile entrance motion; true by default |
| `advanced_effects` | bool | Optional lifted tile, icon zoom, smooth ambient colour and app opening effects; false by default |
@@ -115,9 +115,10 @@ default, press Follow theme, or push a theme again.
## Reduced motion
-`"reduced_motion": true` keeps the look but calms the movement: the highlight spring is stiff instead
-of bouncing, tiles zoom without overshoot, fades are shorter, and Home does not replay the tile
-entrance when you come back to it. Use it on TVs whose GPU cannot keep up; a MediaTek MT5895 on
+`"reduced_motion": true` keeps the look but calms the movement and draws far fewer frames: the
+highlight slides without bouncing and settles within 5 frames, every animation (tile zoom, dropdowns,
+the app library) lasts 90 ms or less, names, the top shelf, the glow and the highlight appear instead of
+fading, and there is no tile entrance. Use it on TVs whose GPU cannot keep up; a MediaTek MT5895 on
Android 10 is the known case. The default, `false`, keeps the normal motion.
```json