Skip to content

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

Merge PR #225: Launcher: build each font weight once, tint the glow instead of repainting it

Gathin23da8490566db6
diff --cc launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index 133bcf129,44b04b2d5..5f3cb6c5a
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@@ -647,58 -608,32 +651,62 @@@ public class MainActivity extends Activ
private void setAmbient(int color) {
if (color == ambientColor && ambient.getBackground() != null) return;
ambientColor = color;
- int c = color & 0x00FFFFFF;
- int w = 480;
- int h = 270;
- Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bmp);
- Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
- paint.setShader(new RadialGradient(
- w * 0.32f, h * 0.42f, w * 0.62f,
- new int[]{0x5C000000 | c, 0x26000000 | c, 0x00000000 | c},
- new float[]{0f, 0.45f, 1f},
- Shader.TileMode.CLAMP));
- canvas.drawRect(0, 0, w, h, paint);
- BitmapDrawable drawable = new BitmapDrawable(getResources(), bmp);
- drawable.setGravity(Gravity.FILL);
- ambient.setBackground(drawable);
+ BitmapDrawable glow = (BitmapDrawable) ambient.getBackground();
+ if (glow == null) {
+ int w = 480;
+ int h = 270;
+ Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bmp);
+ Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ paint.setShader(new RadialGradient(
+ w * 0.32f, h * 0.42f, w * 0.62f,
+ new int[]{0x5CFFFFFF, 0x26FFFFFF, 0x00FFFFFF},
+ new float[]{0f, 0.45f, 1f},
+ Shader.TileMode.CLAMP));
+ canvas.drawRect(0, 0, w, h, paint);
+ glow = new BitmapDrawable(getResources(), bmp);
+ glow.setGravity(Gravity.FILL);
+ ambient.setBackground(glow);
+ }
+ // The default tint mode, SRC_IN, keeps the mask's alpha and takes the colour from the tint.
+ glow.setTint(0xFF000000 | color);
}
+ private void transitionAmbient(int color) {
+ // A rapid focus change continues from the colour actually displayed on screen.
+ stopAmbientAnimation();
+ ambient.animate().cancel();
+ if (color == ambientColor) {
+ ambient.animate().alpha(1f).setDuration(180).start();
+ return;
+ }
+ ambient.animate().alpha(1f).setDuration(180).start();
+ ambientAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), ambientColor, color);
+ ambientAnimator.setDuration(360);
+ ambientAnimator.addUpdateListener(animation -> setAmbient((int) animation.getAnimatedValue()));
+ ambientAnimator.start();
+ }
+
+ private void stopAmbientAnimation() {
+ if (ambientAnimator != null) {
+ ambientAnimator.cancel();
+ ambientAnimator = null;
+ }
+ }
+
private void hideHero() {
if (!heroShown) return;
+ stopAmbientAnimation();
+ heroName.animate().cancel();
+ ambient.animate().cancel();
heroShown = false;
- heroName.animate().alpha(0f).setDuration(reducedMotion ? 100 : 160).start();
- ambient.animate().alpha(0f).setDuration(reducedMotion ? 140 : 300).start();
+ if (animations) {
+ heroName.animate().alpha(0f).setDuration(reducedMotion ? 100 : 160).start();
+ ambient.animate().alpha(0f).setDuration(reducedMotion ? 140 : 300).start();
+ } else {
+ heroName.setAlpha(0f);
+ ambient.setAlpha(0f);
+ }
}
private void hideGlass() {