Skip to content

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

launcher: optional cinematic top shelf (cinematic_home)

Manas Arora8cac61e41f26
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 e5e2d57bb..69879599f 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -426,6 +426,7 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (leanbackPackages.contains(e.pkg)) i.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
try {
ctx.startActivity(i);
+ LastOpened.record(ctx, e.pkg);
if (advancedEffects && ctx instanceof Activity) {
((Activity) ctx).overridePendingTransition(R.anim.app_open_enter, R.anim.app_open_exit);
}
@@ -525,6 +526,17 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
return position >= 0 && position < items.size() ? items.get(position).label : "";
}
+ String packageAt(int position) {
+ return position >= 0 && position < items.size() ? items.get(position).pkg : null;
+ }
+
+ /** The tile's artwork, its banner or else its icon, for the cinematic shelf's backdrop (HeroArt). */
+ Drawable artworkAt(int position) {
+ if (position < 0 || position >= items.size()) return null;
+ Entry e = items.get(position);
+ return e.banner != null ? e.banner : e.icon;
+ }
+
float focusScale() {
return !animations ? 1f : advancedEffects ? 1.12f : 1.10f;
}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index 96f18aae5..e63421a17 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -90,6 +90,8 @@ final class Config {
final boolean overlayApplied;
/** Festive skin from a theme (festival, festival_until, greeting, accent_color); {@link Festival#NONE} if none. */
final Festival festival;
+ /** Cinematic top shelf (config.xml, cinematic_home): the focused dock app's artwork behind a larger shelf. */
+ final boolean cinematicHome;
private Config(List<String> dockApps, boolean fillDock, List<String> hiddenApps, String liveTvPackage,
String liveTvAction, String sourcePanelService, String sourcePanelAction, String inputAction,
@@ -98,7 +100,7 @@ final class Config {
boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, int backgroundColor, int skyIntensity,
int[] settingsKeycodes, boolean settingsKeyPanel, boolean wallpaperEnabled, File wallpaper, List<File> wallpapers,
int wallpaperRotationMinutes, int wallpaperDim, boolean overlayApplied,
- Festival festival, int[] inputKeycodes, List<String> appKeys) {
+ Festival festival, int[] inputKeycodes, List<String> appKeys, boolean cinematicHome) {
this.inputKeycodes = inputKeycodes;
this.appKeys = Collections.unmodifiableList(appKeys);
this.dockApps = Collections.unmodifiableList(dockApps);
@@ -135,6 +137,7 @@ final class Config {
this.wallpaperDim = wallpaperDim;
this.overlayApplied = overlayApplied;
this.festival = festival;
+ this.cinematicHome = cinematicHome;
}
/** The folder the theme tools push into; null when external storage is unavailable. */
@@ -173,6 +176,7 @@ final class Config {
boolean settingsKeyPanel = res.getBoolean(R.bool.settings_key_panel);
int[] inputKeycodes = res.getIntArray(R.array.input_key_keycodes);
List<String> appKeys = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.app_keys)));
+ boolean cinematic = res.getBoolean(R.bool.cinematic_home);
boolean applied = false;
File dir = dir(ctx);
@@ -209,6 +213,7 @@ final class Config {
settingsKeyPanel = bool(json, "settings_key_panel", settingsKeyPanel);
inputKeycodes = intArray(json, "input_key_keycodes", inputKeycodes);
appKeys = stringList(json, "app_keys", appKeys);
+ cinematic = bool(json, "cinematic_home", cinematic);
}
// A theme push or reset invalidates choices made on the TV. On first use, remember the
// current theme without clearing choices from an older launcher version.
@@ -239,7 +244,7 @@ final class Config {
shamsi, greetingName, moduleCards, reducedMotion, dockTitle, dockRow, reorderButton, vpn, homeSettings, showStats, library, background,
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaperEnabled, wallpaper,
wallpapers, rotationMinutes, wallpaperDim, applied,
- festival, inputKeycodes, appKeys);
+ festival, inputKeycodes, appKeys, cinematic);
}
private static void syncThemeChoices(SharedPreferences choices, File dir, File config) {
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/DockDecoration.java b/launcher/app/src/main/java/com/gathin/tvhome/DockDecoration.java
index 429d310ac..2961c32c3 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/DockDecoration.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/DockDecoration.java
@@ -18,13 +18,14 @@ public class DockDecoration extends RecyclerView.ItemDecoration {
private final Paint edge = new Paint(Paint.ANTI_ALIAS_FLAG);
private final RectF rect = new RectF();
- DockDecoration(int dockSize, float density) {
+ /** @param translucent the cinematic shelf's band: the artwork and the glow show through it. */
+ DockDecoration(int dockSize, float density, boolean translucent) {
this.dockSize = dockSize;
this.density = density;
- band.setColor(0xFF141416);
+ band.setColor(translucent ? 0x8C121014 : 0xFF141416);
edge.setStyle(Paint.Style.STROKE);
edge.setStrokeWidth(density);
- edge.setColor(0x1FFFFFFF);
+ edge.setColor(translucent ? 0x26FFFFFF : 0x1FFFFFFF);
}
@Override
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HeroArt.java b/launcher/app/src/main/java/com/gathin/tvhome/HeroArt.java
new file mode 100644
index 000000000..c2071aa17
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/HeroArt.java
@@ -0,0 +1,87 @@
+package com.gathin.tvhome;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+
+/**
+ * The cinematic shelf's backdrop: an app's artwork reduced to 48×27 pixels, saturated and smoothed,
+ * then stretched over the screen by its ImageView. Bilinear filtering of an image that small is a
+ * blur that costs one tiny texture; a real blur would mean RenderScript or a shader pass per frame,
+ * which a 1 GB TV cannot spare.
+ */
+final class HeroArt {
+ static final int W = 48, H = 27;
+ private static final float SATURATION = 1.7f;
+
+ private HeroArt() {
+ }
+
+ /** The softened artwork, about 5 KB; null when there is nothing to draw. */
+ static Bitmap from(Drawable live) {
+ if (live == null) return null;
+ // Draw a private copy: changing the bounds of the drawable a tile shows would blank the tile.
+ Drawable d = live.getConstantState() != null ? live.getConstantState().newDrawable().mutate() : live;
+ Rect saved = new Rect(d.getBounds());
+ Bitmap big = Bitmap.createBitmap(W * 4, H * 4, Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(big);
+ c.drawColor(Color.BLACK);
+ d.setBounds(0, 0, big.getWidth(), big.getHeight());
+ d.draw(c);
+ d.setBounds(saved);
+ // Halve twice: each filtered halving averages 2×2 pixels, where one 4× step would skip most of them.
+ Bitmap half = Bitmap.createScaledBitmap(big, W * 2, H * 2, true);
+ big.recycle();
+ Bitmap small = Bitmap.createScaledBitmap(half, W, H, true);
+ half.recycle();
+
+ int[] px = new int[W * H];
+ small.getPixels(px, 0, W, 0, 0, W, H);
+ saturate(px);
+ // Three box passes approximate a gaussian, so the stretched image shows no seams between pixels.
+ for (int pass = 0; pass < 3; pass++) {
+ px = boxBlur(px, W, H, 2, true);
+ px = boxBlur(px, W, H, 2, false);
+ }
+ Bitmap out = small.isMutable() ? small : small.copy(Bitmap.Config.ARGB_8888, true);
+ if (out != small) small.recycle();
+ out.setPixels(px, 0, W, 0, 0, W, H);
+ return out;
+ }
+
+ private static void saturate(int[] px) {
+ for (int i = 0; i < px.length; i++) {
+ int p = px[i];
+ int r = Color.red(p), g = Color.green(p), b = Color.blue(p);
+ float lum = 0.2126f * r + 0.7152f * g + 0.0722f * b;
+ px[i] = Color.rgb(clamp(lum + (r - lum) * SATURATION), clamp(lum + (g - lum) * SATURATION),
+ clamp(lum + (b - lum) * SATURATION));
+ }
+ }
+
+ private static int clamp(float v) {
+ return v < 0 ? 0 : v > 255 ? 255 : Math.round(v);
+ }
+
+ /** One box blur pass along rows (horizontal) or columns, edges clamped. */
+ private static int[] boxBlur(int[] src, int w, int h, int radius, boolean horizontal) {
+ int[] dst = new int[src.length];
+ int lines = horizontal ? h : w, length = horizontal ? w : h, span = 2 * radius + 1;
+ for (int line = 0; line < lines; line++) {
+ for (int i = 0; i < length; i++) {
+ int r = 0, g = 0, b = 0;
+ for (int k = -radius; k <= radius; k++) {
+ int j = Math.max(0, Math.min(length - 1, i + k));
+ int p = horizontal ? src[line * w + j] : src[j * w + line];
+ r += Color.red(p);
+ g += Color.green(p);
+ b += Color.blue(p);
+ }
+ dst[horizontal ? line * w + i : i * w + line] = Color.rgb(r / span, g / span, b / span);
+ }
+ }
+ return dst;
+ }
+}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/LastOpened.java b/launcher/app/src/main/java/com/gathin/tvhome/LastOpened.java
new file mode 100644
index 000000000..cd932a53b
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LastOpened.java
@@ -0,0 +1,52 @@
+package com.gathin.tvhome;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.text.format.DateUtils;
+
+import java.util.Locale;
+
+/**
+ * When an app was last opened from Home, for the cinematic shelf's "Last opened" line: the launcher notes the
+ * time whenever it opens an app. No permission and nothing read from other apps, so an app started some other
+ * way (a remote's own Netflix button) shows the last time Home opened it.
+ */
+final class LastOpened {
+ private static final String PREFS = "last_opened";
+
+ private LastOpened() {
+ }
+
+ /** Notes that Home just opened this app. */
+ static void record(Context ctx, String pkg) {
+ prefs(ctx).edit().putLong(pkg, System.currentTimeMillis()).apply();
+ }
+
+ /** Milliseconds since the epoch, or 0 when Home never opened the app. */
+ static long get(Context ctx, String pkg) {
+ return pkg == null ? 0L : prefs(ctx).getLong(pkg, 0L);
+ }
+
+ /**
+ * "5 minutes ago" within the hour, then the day and the time: "today, 11:40 am", "yesterday, 9:40 pm",
+ * "3 days ago, 9:40 pm", "Oct 12, 9:40 pm". The parts are Android's own wording in the TV's language.
+ */
+ static String describe(Context ctx, long when) {
+ long now = System.currentTimeMillis();
+ // Under a minute Android says "0 minutes ago"; one minute reads better.
+ when = Math.min(when, now - DateUtils.MINUTE_IN_MILLIS);
+ if (now - when < DateUtils.HOUR_IN_MILLIS) {
+ return DateUtils.getRelativeTimeSpanString(when, now, DateUtils.MINUTE_IN_MILLIS).toString();
+ }
+ String day = DateUtils.getRelativeTimeSpanString(when, now, DateUtils.DAY_IN_MILLIS).toString();
+ // It follows "Last opened" mid-sentence: "yesterday", not "Yesterday". Month names keep their capital.
+ if (Locale.getDefault().getLanguage().equals("en") && (day.startsWith("Yesterday") || day.startsWith("Today"))) {
+ day = Character.toLowerCase(day.charAt(0)) + day.substring(1);
+ }
+ return day + ", " + DateUtils.formatDateTime(ctx, when, DateUtils.FORMAT_SHOW_TIME);
+ }
+
+ private static SharedPreferences prefs(Context ctx) {
+ return ctx.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
+ }
+}
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 28a35f331..fb15d15a2 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -14,6 +14,7 @@ import android.content.pm.ApplicationInfo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.RadialGradient;
import android.graphics.Rect;
@@ -21,6 +22,7 @@ import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
import android.media.tv.TvContract;
import android.media.tv.TvInputInfo;
import android.media.tv.TvInputManager;
@@ -43,6 +45,8 @@ import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
+import android.text.style.ForegroundColorSpan;
+import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
@@ -72,9 +76,11 @@ import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.Set;
/**
@@ -103,6 +109,20 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private GlassView glass;
private View ambient;
private TextView heroName;
+ /** The top shelf: heroName, plus the cinematic shelf's "Last opened" line and dock position dots. */
+ private View hero;
+ private TextView heroMeta;
+ private LinearLayout heroDots;
+ /** Cinematic top shelf (config.xml, cinematic_home): the focused dock app's artwork behind a larger shelf. */
+ private boolean cinematic;
+ private ImageView heroArt;
+ private static final float HERO_ART_ALPHA = 0.5f;
+ /** Softened artwork per app (HeroArt, about 5 KB each), made the first time its dock tile is focused. */
+ private final Map<String, Bitmap> heroArtCache = new HashMap<>();
+ /** The app whose artwork heroArt shows, so focusing it again only fades it back in. */
+ private String heroArtKey;
+ /** The focus glow's colour while the cinematic shelf tints it, 0 for plain white glass. */
+ private int glassAccent;
private int ambientColor = -1;
private ValueAnimator ambientAnimator;
private boolean heroShown;
@@ -275,8 +295,15 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
// a fade renders it into a full-screen offscreen buffer first.
ambient.forceHasOverlappingRendering(false);
heroName = findViewById(R.id.heroName);
- // dock_title false: the name above the dock never shows; the glow still follows the dock.
- if (!cfg.dockTitle) heroName.setVisibility(View.GONE);
+ hero = findViewById(R.id.hero);
+ heroMeta = findViewById(R.id.heroMeta);
+ heroDots = findViewById(R.id.heroDots);
+ heroArt = findViewById(R.id.heroArt);
+ cinematic = cfg.cinematicHome;
+ if (cinematic) setUpCinematicShelf();
+ // dock_title false: the name above the dock (and the cinematic lines under it) never shows; the glow
+ // still follows the dock.
+ if (!cfg.dockTitle) hero.setVisibility(View.GONE);
greeting = findViewById(R.id.greeting);
greetingColor = greeting.getCurrentTextColor();
btnWifi = findViewById(R.id.btnWifi);
@@ -351,7 +378,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
public void onChildViewDetachedFromWindow(@NonNull View v) {
}
});
- if (dockRow) grid.addItemDecoration(new DockDecoration(COLUMNS, density));
+ if (dockRow) grid.addItemDecoration(new DockDecoration(COLUMNS, density, cinematic));
if (animations) {
int enterAnim = reducedMotion ? R.anim.tile_enter_reduced : R.anim.tile_enter;
float enterDelay = reducedMotion ? 0f : 0.06f;
@@ -377,7 +404,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
int gridRows = itemH * rowsBelowDock;
// Keep the hero below the header when the library is enabled on a short screen,
// even when the theme requests an extra visible row below the dock.
- int shelfClearance = cfg.appLibrary ? heroName.getMeasuredHeight() + (int) (40 * density) : 0;
+ int shelfClearance = cfg.appLibrary ? hero.getMeasuredHeight() + (int) (40 * density) : 0;
int want = Math.max(shelfClearance, h - dockRow - gridRows - (int) (AppAdapter.BOTTOM_ROOM_DP * density));
// Where the rows cannot fit even at the smallest tile (3 rows with the title on), the title keeps its
// room above the dock and the last rows run off the bottom instead of the title drawing over the clock.
@@ -582,8 +609,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
glassShown = false;
glass.setAlpha(0f);
heroShown = false;
- heroName.setAlpha(0f);
+ hero.setAlpha(0f);
ambient.setAlpha(0f);
+ heroArt.animate().cancel();
+ heroArt.setAlpha(0f);
}
reloadTiles();
if (animate && animations && !reducedMotion) grid.scheduleLayoutAnimation();
@@ -615,6 +644,9 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
final String returnKey = lastFocusedKey;
final int returnSlot = lastFocused;
final List<Cards.Card> none = Collections.emptyList();
+ // An updated app may bring new artwork; the backdrop is cheap to make again.
+ heroArtCache.clear();
+ heroArtKey = null;
cards = moduleCards ? CardFeature.run(() -> Cards.discover(this, hiddenApps, Cards.load(Cards.storeFile(this))), none) : none;
adapter.reload(cards.isEmpty() ? none : CardFeature.run(() -> Cards.shown(cards), none));
lastFocusedKey = returnKey;
@@ -644,8 +676,9 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
endReorder(); // Home or another app while reordering keeps the order so far
wallpaperPlayer.stop();
stopAmbientAnimation();
- heroName.animate().cancel();
+ hero.animate().cancel();
ambient.animate().cancel();
+ heroArt.animate().cancel();
handler.removeCallbacks(minuteTick);
stopStats();
if (diya != null) diya.stop();
@@ -1011,6 +1044,12 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
}
glassTargetX = x;
glassTargetY = y;
+ // Cinematic shelf: the highlight glows in the dock app's colour, plain white in the grid.
+ int accent = cinematic && !festive && position < COLUMNS ? adapter.ambientColorAt(position) : 0;
+ if (cinematic && !festive && accent != glassAccent) {
+ glassAccent = accent;
+ glass.setAccent(accent);
+ }
if (!glassShown) {
springX.cancel();
springY.cancel();
@@ -1056,18 +1095,19 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private void showHero(int position, float dockTopInRoot) {
String label = adapter.labelAt(position);
int color = adapter.ambientColorAt(position);
- float y = dockTopInRoot - 14 * density - 26 * density - heroName.getHeight();
+ float y = dockTopInRoot - 14 * density - 26 * density - hero.getHeight();
boolean changed = !label.contentEquals(heroName.getText());
+ if (cinematic) showHeroArt(position);
if (!animations || reducedMotion) {
// Snap the shelf instead of sliding and fading it: each of those frames repaints the
// full-screen panel, and this switch exists for the GPUs that cannot afford it.
- heroName.animate().cancel();
+ hero.animate().cancel();
ambient.animate().cancel();
- heroName.setText(label);
- heroName.setY(y);
- heroName.setTranslationX(0f);
- heroName.setAlpha(1f);
+ fillHero(position, label);
+ hero.setY(y);
+ hero.setTranslationX(0f);
+ hero.setAlpha(1f);
setAmbient(color);
if (!animations) {
ambient.setAlpha(1f);
@@ -1082,22 +1122,22 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
if (!heroShown) {
stopAmbientAnimation();
- heroName.animate().cancel();
+ hero.animate().cancel();
ambient.animate().cancel();
- heroName.setText(label);
- heroName.setY(y);
- heroName.setTranslationX(0f);
- heroName.animate().alpha(1f).setDuration(260).start();
+ fillHero(position, label);
+ hero.setY(y);
+ hero.setTranslationX(0f);
+ hero.animate().alpha(1f).setDuration(260).start();
setAmbient(color);
ambient.animate().alpha(1f).setDuration(600).start();
heroShown = true;
} else if (changed) {
- if (advancedEffects) heroName.animate().cancel();
- heroName.animate().alpha(0f).translationX(-12 * density).setDuration(120).withEndAction(() -> {
- heroName.setText(label);
- heroName.setY(y);
- heroName.setTranslationX(12 * density);
- heroName.animate().alpha(1f).translationX(0f).setDuration(200).start();
+ if (advancedEffects) hero.animate().cancel();
+ hero.animate().alpha(0f).translationX(-12 * density).setDuration(120).withEndAction(() -> {
+ fillHero(position, label);
+ hero.setY(y);
+ hero.setTranslationX(12 * density);
+ hero.animate().alpha(1f).translationX(0f).setDuration(200).start();
}).start();
if (advancedEffects) {
transitionAmbient(color);
@@ -1108,7 +1148,130 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
}).start();
}
} else {
- heroName.setY(y);
+ hero.setY(y);
+ }
+ }
+
+ /** The shelf's text for this dock app: its name and, on the cinematic shelf, "Last opened" and the dots. */
+ private void fillHero(int position, String label) {
+ heroName.setText(label);
+ if (!cinematic) return;
+ updateHeroMeta(position);
+ updateHeroDots(position);
+ }
+
+ // ---- cinematic shelf -------------------------------------------------------------------------
+
+ /** The parts that never change: a larger name, the meta line and the dots, the artwork and the scrim. */
+ private void setUpCinematicShelf() {
+ heroName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 68f);
+ heroName.setLetterSpacing(-0.025f);
+ heroMeta.setVisibility(View.INVISIBLE); // keeps its height, so the name does not jump when it fills in
+ heroDots.setVisibility(View.VISIBLE);
+ heroArt.setVisibility(View.VISIBLE);
+ // One stretched bitmap: apply its alpha while drawing instead of through an offscreen buffer.
+ heroArt.forceHasOverlappingRendering(false);
+ View scrim = findViewById(R.id.heroScrim);
+ scrim.setBackground(scrimDrawable());
+ scrim.setVisibility(View.VISIBLE);
+ }
+
+ /**
+ * Darkens the side the shelf's text is on and the lower part of the screen, so the name, the dock and
+ * the grid stay readable over the artwork. One small bitmap stretched over the screen, like the glow.
+ */
+ private Drawable scrimDrawable() {
+ int w = 480, h = 270;
+ Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bmp);
+ boolean rtl = getResources().getBoolean(R.bool.rtl_menu_bar);
+ Paint paint = new Paint();
+ paint.setShader(new LinearGradient(rtl ? w : 0, 0, rtl ? 0 : w, 0,
+ new int[]{0xD1060406, 0x59060406, 0x00060406}, new float[]{0f, 0.42f, 0.7f}, Shader.TileMode.CLAMP));
+ canvas.drawRect(0, 0, w, h, paint);
+ paint.setShader(new LinearGradient(0, 0, 0, h,
+ new int[]{0x00060406, 0x00060406, 0xDB060406, 0xFF060406}, new float[]{0f, 0.28f, 0.58f, 0.76f},
+ Shader.TileMode.CLAMP));
+ canvas.drawRect(0, 0, w, h, paint);
+ BitmapDrawable scrim = new BitmapDrawable(getResources(), bmp);
+ scrim.setGravity(Gravity.FILL);
+ return scrim;
+ }
+
+ /** Swaps the backdrop to this app's artwork: fade out, swap, fade in, the way the shelf's name changes. */
+ private void showHeroArt(int position) {
+ String key = adapter.keyAt(position);
+ if (key == null) return;
+ heroArt.animate().cancel();
+ if (key.equals(heroArtKey)) {
+ fadeHeroArt(420);
+ return;
+ }
+ Bitmap art = heroArtCache.get(key);
+ if (art == null) {
+ art = HeroArt.from(adapter.artworkAt(position));
+ if (art != null) heroArtCache.put(key, art);
+ }
+ heroArtKey = key;
+ final Bitmap next = art;
+ if (!animations || reducedMotion || heroArt.getAlpha() == 0f) {
+ heroArt.setImageBitmap(next);
+ fadeHeroArt(600);
+ return;
+ }
+ heroArt.animate().alpha(0f).setDuration(140).withEndAction(() -> {
+ heroArt.setImageBitmap(next);
+ heroArt.animate().alpha(HERO_ART_ALPHA).setDuration(420).start();
+ }).start();
+ }
+
+ 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();
+ }
+
+ /** "Last opened yesterday, 9:40 PM", the time in white; nothing (but the same height) when it was never seen. */
+ private void updateHeroMeta(int position) {
+ long when = LastOpened.get(this, adapter.packageAt(position));
+ if (when <= 0) {
+ heroMeta.setVisibility(View.INVISIBLE);
+ return;
+ }
+ String rel = LastOpened.describe(this, when);
+ String text = getString(R.string.last_opened, rel);
+ SpannableString line = new SpannableString(text);
+ int at = text.indexOf(rel);
+ if (at >= 0) line.setSpan(new ForegroundColorSpan(0xFFFFFFFF), at, at + rel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ heroMeta.setText(line);
+ heroMeta.setVisibility(View.VISIBLE);
+ }
+
+ /** One dot per dock app, the focused one drawn long and white. Hebrew docks start on the right, so do the dots. */
+ private void updateHeroDots(int position) {
+ int count = Math.min(adapter.dockFilled(), COLUMNS);
+ heroDots.setVisibility(count > 1 ? View.VISIBLE : View.INVISIBLE);
+ if (heroDots.getChildCount() != count) {
+ heroDots.removeAllViews();
+ for (int i = 0; i < count; i++) {
+ View dot = new View(this);
+ GradientDrawable bg = new GradientDrawable();
+ bg.setCornerRadius(3 * density);
+ dot.setBackground(bg);
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int) (6 * density), (int) (6 * density));
+ if (i > 0) lp.leftMargin = (int) (6 * density);
+ heroDots.addView(dot, lp);
+ }
+ }
+ for (int i = 0; i < count; i++) {
+ View dot = heroDots.getChildAt(rtlAppGrid ? count - 1 - i : i);
+ boolean on = i == position;
+ ((GradientDrawable) dot.getBackground()).setColor(on ? 0xFFFFFFFF : 0x4DFFFFFF);
+ ViewGroup.LayoutParams lp = dot.getLayoutParams();
+ int w = (int) ((on ? 20 : 6) * density);
+ if (lp.width != w) {
+ lp.width = w;
+ dot.setLayoutParams(lp);
+ }
}
}
@@ -1129,11 +1292,22 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
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));
+ if (cinematic) {
+ // Higher and stronger, from the corner away from the shelf's text: the app's colour floods
+ // the top of the screen over its artwork, and the scrim keeps the text side dark.
+ boolean rtl = getResources().getBoolean(R.bool.rtl_menu_bar);
+ paint.setShader(new RadialGradient(
+ w * (rtl ? 0.20f : 0.80f), h * 0.06f, w * 0.78f,
+ new int[]{0xA6FFFFFF, 0x47FFFFFF, 0x00FFFFFF},
+ new float[]{0f, 0.5f, 1f},
+ Shader.TileMode.CLAMP));
+ } else {
+ 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);
@@ -1172,9 +1346,11 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private void showGlowOnly(int position) {
int color = adapter.ambientColorAt(position);
stopAmbientAnimation();
- heroName.animate().cancel();
+ hero.animate().cancel();
ambient.animate().cancel();
- heroName.setAlpha(0f);
+ hero.setAlpha(0f);
+ heroArt.animate().cancel();
+ heroArt.setAlpha(0f);
heroShown = false;
if (!animations || reducedMotion) {
setAmbient(color);
@@ -1195,15 +1371,18 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private void hideHero() {
if (!heroShown) return;
stopAmbientAnimation();
- heroName.animate().cancel();
+ hero.animate().cancel();
ambient.animate().cancel();
+ heroArt.animate().cancel();
heroShown = false;
if (animations) {
- heroName.animate().alpha(0f).setDuration(reducedMotion ? 100 : 160).start();
+ hero.animate().alpha(0f).setDuration(reducedMotion ? 100 : 160).start();
ambient.animate().alpha(0f).setDuration(reducedMotion ? 140 : 300).start();
+ heroArt.animate().alpha(0f).setDuration(reducedMotion ? 140 : 300).start();
} else {
- heroName.setAlpha(0f);
+ hero.setAlpha(0f);
ambient.setAlpha(0f);
+ heroArt.setAlpha(0f);
}
}
diff --git a/launcher/app/src/main/res/layout-iw/activity_main.xml b/launcher/app/src/main/res/layout-iw/activity_main.xml
index 97ed870f3..ee27f2f23 100644
--- a/launcher/app/src/main/res/layout-iw/activity_main.xml
+++ b/launcher/app/src/main/res/layout-iw/activity_main.xml
@@ -14,6 +14,17 @@
android:layout_height="match_parent"
android:importantForAccessibility="no" />
+ <!-- Cinematic top shelf (cinematic_home): the focused dock app's artwork, a few pixels across and
+ stretched over the screen, which softens it like a blur without the cost of one. Hidden otherwise. -->
+ <ImageView
+ android:id="@+id/heroArt"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitXY"
+ android:alpha="0"
+ android:visibility="gone"
+ android:importantForAccessibility="no" />
+
<!-- Ambient glow in the colour of the focused dock app. -->
<View
android:id="@+id/ambient"
@@ -21,21 +32,64 @@
android:layout_height="match_parent"
android:alpha="0" />
+
+ <!-- Cinematic top shelf: darkens the edge behind the shelf and the lower half, so the text and the
+ dock stay readable over the artwork. -->
+ <View
+ android:id="@+id/heroScrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"
+ android:importantForAccessibility="no" />
+
<!-- Top shelf: the focused dock app's name, positioned above the dock in code. -->
- <TextView
- android:id="@+id/heroName"
+ <LinearLayout
+ android:id="@+id/hero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="68dp"
android:layout_gravity="right"
android:gravity="right"
- android:alpha="0"
- android:textColor="#FFFFFFFF"
- android:textSize="48sp"
- android:fontFamily="@font/outfit_light"
- android:letterSpacing="-0.02"
- android:includeFontPadding="false"
- android:singleLine="true" />
+ android:orientation="vertical"
+ android:alpha="0">
+
+ <TextView
+ android:id="@+id/heroName"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:gravity="right"
+ android:textColor="#FFFFFFFF"
+ android:textSize="48sp"
+ android:fontFamily="@font/outfit_light"
+ android:letterSpacing="-0.02"
+ android:includeFontPadding="false"
+ android:singleLine="true" />
+
+ <!-- Cinematic shelf only: when the app was last opened, and the dock position dots. -->
+ <TextView
+ android:id="@+id/heroMeta"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:layout_marginEnd="4dp"
+ android:layout_marginTop="12dp"
+ android:singleLine="true"
+ android:textColor="#B3FFFFFF"
+ android:textSize="15sp"
+ android:fontFamily="@font/outfit_light"
+ android:visibility="gone" />
+
+ <LinearLayout
+ android:id="@+id/heroDots"
+ android:layout_width="wrap_content"
+ android:layout_height="6dp"
+ android:layout_gravity="right"
+ android:layout_marginEnd="4dp"
+ android:layout_marginTop="16dp"
+ android:orientation="horizontal"
+ android:visibility="gone" />
+ </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
diff --git a/launcher/app/src/main/res/layout/activity_main.xml b/launcher/app/src/main/res/layout/activity_main.xml
index 458c550dd..0a28d10c3 100644
--- a/launcher/app/src/main/res/layout/activity_main.xml
+++ b/launcher/app/src/main/res/layout/activity_main.xml
@@ -12,6 +12,17 @@
android:layout_height="match_parent"
android:importantForAccessibility="no" />
+ <!-- Cinematic top shelf (cinematic_home): the focused dock app's artwork, a few pixels across and
+ stretched over the screen, which softens it like a blur without the cost of one. Hidden otherwise. -->
+ <ImageView
+ android:id="@+id/heroArt"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitXY"
+ android:alpha="0"
+ android:visibility="gone"
+ android:importantForAccessibility="no" />
+
<!-- Ambient glow in the colour of the focused dock app. -->
<View
android:id="@+id/ambient"
@@ -19,19 +30,58 @@
android:layout_height="match_parent"
android:alpha="0" />
+
+ <!-- Cinematic top shelf: darkens the edge behind the shelf and the lower half, so the text and the
+ dock stay readable over the artwork. -->
+ <View
+ android:id="@+id/heroScrim"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"
+ android:importantForAccessibility="no" />
+
<!-- Top shelf: the focused dock app's name, positioned above the dock in code. -->
- <TextView
- android:id="@+id/heroName"
+ <LinearLayout
+ android:id="@+id/hero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="68dp"
- android:alpha="0"
- android:textColor="#FFFFFFFF"
- android:textSize="48sp"
- android:fontFamily="@font/outfit_light"
- android:letterSpacing="-0.02"
- android:includeFontPadding="false"
- android:singleLine="true" />
+ android:orientation="vertical"
+ android:alpha="0">
+
+ <TextView
+ android:id="@+id/heroName"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="#FFFFFFFF"
+ android:textSize="48sp"
+ android:fontFamily="@font/outfit_light"
+ android:letterSpacing="-0.02"
+ android:includeFontPadding="false"
+ android:singleLine="true" />
+
+ <!-- Cinematic shelf only: when the app was last opened, and the dock position dots. -->
+ <TextView
+ android:id="@+id/heroMeta"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="4dp"
+ android:layout_marginTop="12dp"
+ android:singleLine="true"
+ android:textColor="#B3FFFFFF"
+ android:textSize="15sp"
+ android:fontFamily="@font/outfit_light"
+ android:visibility="gone" />
+
+ <LinearLayout
+ android:id="@+id/heroDots"
+ android:layout_width="wrap_content"
+ android:layout_height="6dp"
+ android:layout_marginStart="4dp"
+ android:layout_marginTop="16dp"
+ android:orientation="horizontal"
+ android:visibility="gone" />
+ </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
diff --git a/launcher/app/src/main/res/values-iw/strings.xml b/launcher/app/src/main/res/values-iw/strings.xml
index 82e6ddd43..bc2206b8c 100644
--- a/launcher/app/src/main/res/values-iw/strings.xml
+++ b/launcher/app/src/main/res/values-iw/strings.xml
@@ -88,4 +88,5 @@
<item quantity="other">%1$d אפליקציות</item>
</plurals>
<string name="greeting_with_name">%1$s, %2$s</string>
+ <string name="last_opened">נפתח לאחרונה %1$s</string>
</resources>
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index d415e695b..9364ce6d8 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -137,4 +137,10 @@
sets its opacity. Around 60 reads clearly without hiding a wallpaper. Can also be set with
"sky_intensity": 60 in a theme's config.json. -->
<integer name="sky_intensity">0</integer>
+
+ <!-- Cinematic top shelf: the focused dock app's artwork, softened, fills the top of the screen in its
+ colour; the shelf gets a larger name, a "Last opened" line (from the apps Home opened) and dock position
+ dots, the focus glow takes the app's colour and the dock band turns translucent. false keeps the plain
+ shelf. Can also be set with "cinematic_home": true in a theme's config.json. -->
+ <bool name="cinematic_home">false</bool>
</resources>
diff --git a/launcher/app/src/main/res/values/strings.xml b/launcher/app/src/main/res/values/strings.xml
index 454dba403..d0fc7c068 100644
--- a/launcher/app/src/main/res/values/strings.xml
+++ b/launcher/app/src/main/res/values/strings.xml
@@ -90,4 +90,7 @@
</plurals>
<!-- The greeting, then greeting_name: "Good morning, Mr. Trịnh". -->
<string name="greeting_with_name">%1$s, %2$s</string>
+ <!-- Cinematic top shelf (cinematic_home): the line under the focused dock app's name; %1$s is when it was
+ last opened, e.g. "5 minutes ago" or "yesterday, 9:40 pm". -->
+ <string name="last_opened">Last opened %1$s</string>
</resources>
diff --git a/themes/README.md b/themes/README.md
index f81ca920c..58a54f516 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -60,6 +60,7 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `settings_key_panel` | bool | Those buttons open a small quick settings panel (TV settings, Display, Network, Apps, Launcher settings) instead of the TV's Settings |
| `input_key_keycodes` | list of keycodes | More remote buttons that open the input switcher, for `InputKeyService` (`KEYCODE_TV` and `KEYCODE_TV_INPUT` always do) |
| `app_keys` | list of strings | Remote buttons that open an app, as `"190:com.google.android.youtube.tv"` or `"KEYCODE_BUTTON_3:com.google.android.youtube.tv"`, for `InputKeyService` or `HomeKeyService` |
+| `cinematic_home` | bool | Cinematic top shelf: the focused dock app's artwork, softened, fills the top of the screen in its colour, with a larger name, "Last opened" (apps opened from Home), dock position dots, a focus glow in the app's colour and a translucent dock band; off by default |
## Wallpapers