Skip to content

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

launcher: uniform icon tiles, off unless a theme asks

VincentYe123cd8aa4995b52
diff --git a/docs/switches.md b/docs/switches.md
index 17f253536..0d48f476b 100644
--- a/docs/switches.md
+++ b/docs/switches.md
@@ -29,3 +29,4 @@ the rules. Keys from before this rule are on its wanted list; a screenshot for o
| `settings_key_panel` | <img src="quick-settings-panel.jpg" width="320" alt="settings_key_panel on a TV"> |
| `home_idle_clock_minutes` | <img src="clock-screensaver.png" width="320" alt="home_idle_clock_minutes on a TV"> |
| `gamepad_passthrough` | <img src="switches/gamepad_passthrough.jpg" width="320" alt="gamepad_passthrough on a TV"> |
+| `uniform_tiles` | <img src="switches/uniform_tiles.jpg" width="320" alt="uniform_tiles on a TV"> |
diff --git a/docs/switches/uniform_tiles.jpg b/docs/switches/uniform_tiles.jpg
new file mode 100644
index 000000000..81d6caa6e
Binary files /dev/null and b/docs/switches/uniform_tiles.jpg differ
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 ea0030630..9f21eaf3d 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -15,6 +15,7 @@ import android.graphics.Outline;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.provider.Settings;
import android.util.DisplayMetrics;
@@ -25,6 +26,7 @@ import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.OvershootInterpolator;
+import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -74,6 +76,8 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final String name;
/** Ambient glow colour; 0 until sampled from the banner, or the card's accent from the start. */
int ambient;
+ /** uniform_tiles card fill, top and bottom colour; null until sampled from the icon. */
+ int[] backdrop;
Entry(String label, ComponentName component, Drawable banner, Drawable icon) {
this(APP, label, component, banner, icon, null, 0);
@@ -208,6 +212,8 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final boolean tileMenu;
/** Tile names and bundled banners that replace the app's own (config.xml, app_labels and app_banners). */
private final Map<String, String> appLabels, appBanners;
+ /** Every app tile is its icon on a card tinted from that icon, never its banner (config.xml, uniform_tiles). */
+ private final boolean uniformTiles;
private final List<Entry> items = new ArrayList<>();
AppAdapter(Context ctx, TileListener listener, int dockSize, Config cfg) {
@@ -233,6 +239,7 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
this.tileMenu = cfg.tileMenu;
this.appLabels = cfg.appLabels;
this.appBanners = cfg.appBanners;
+ this.uniformTiles = cfg.uniformTiles;
// Tiles keep their identity across reload(), so a focused tile stays on its app instead of
// its view being rebound to whatever app now sits in that slot.
setHasStableIds(true);
@@ -281,8 +288,12 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
String label = card != null ? card.label : Cards.cleanLabel(
appLabels.containsKey(pkg) ? appLabels.get(pkg) : String.valueOf(ri.loadLabel(pm)), pkg);
if (!seen.add(pkg + '\n' + label)) continue;
- Drawable banner = bundledBanner(appBanners.get(pkg));
- if (banner == null) banner = loadBanner(pm, ri);
+ Drawable banner = null;
+ // uniform_tiles draws the icon, so an app's banner is never loaded. A module card keeps its banner.
+ if (!(uniformTiles && card == null)) {
+ banner = bundledBanner(appBanners.get(pkg));
+ if (banner == null) banner = loadBanner(pm, ri);
+ }
// The icon is only drawn (and sampled for the glow) when there is no banner, so a tile with a
// banner skips loading and decoding it.
Drawable icon = banner == null ? ri.loadIcon(pm) : null;
@@ -402,6 +413,14 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
v.setPadding(v.getPaddingLeft(), pad, v.getPaddingRight(), pad);
}
name.setLayoutParams(nameLp);
+ if (uniformTiles) {
+ // tvOS-style tile: a large centred mark, no caption inside the card.
+ View icon = v.findViewById(R.id.icon);
+ FrameLayout.LayoutParams iconLp = (FrameLayout.LayoutParams) icon.getLayoutParams();
+ iconLp.width = iconLp.height = Math.round(h * ICON_SHARE);
+ iconLp.bottomMargin = 0;
+ icon.setLayoutParams(iconLp);
+ }
return new Holder(v, listener, animations, advancedEffects, reducedMotion, restNameAlpha, focusOvershoot);
}
@@ -437,6 +456,10 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
// A fully opaque banner covers the whole card (centerCrop), so the card's own fill under it is drawn for
// nothing on every frame; keep it under banners with transparent parts and under icon tiles.
h.card.setBackground(e.banner != null && e.banner.getOpacity() == PixelFormat.OPAQUE ? null : h.cardBackground);
+ if (uniformTiles && e.banner == null) {
+ if (e.backdrop == null) e.backdrop = backdrop(e.icon, ambientColorAt(position));
+ h.card.setBackground(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, e.backdrop));
+ }
if (e.banner != null) {
h.banner.setImageDrawable(e.banner);
h.banner.setVisibility(View.VISIBLE);
@@ -448,7 +471,7 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
h.icon.setImageDrawable(e.icon);
h.icon.setVisibility(View.VISIBLE);
h.label.setText(e.label);
- h.label.setVisibility(View.VISIBLE);
+ h.label.setVisibility(uniformTiles ? View.GONE : View.VISIBLE);
}
h.card.setOnClickListener(v -> launch(e));
h.card.setOnLongClickListener(v -> {
@@ -619,10 +642,156 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
int ambientColorAt(int position) {
if (position < 0 || position >= items.size()) return 0xFF444444;
Entry e = items.get(position);
- if (e.ambient == 0) e.ambient = vividColor(e.banner != null ? e.banner : e.icon);
+ if (e.ambient == 0) {
+ e.ambient = uniformTiles && e.banner == null ? dominantColor(e.icon) : vividColor(e.banner != null ? e.banner : e.icon);
+ }
return e.ambient;
}
+ /** Share of the tile height the icon takes in uniform_tiles mode (onCreateViewHolder). */
+ private static final float ICON_SHARE = 0.62f;
+
+ /**
+ * The colour covering most of an icon, for a card that should read as that app: a small saturated badge
+ * (a red "new" corner on a blue icon) must not win, as it can with {@link #vividColor}. Grey if none.
+ */
+ private static int dominantColor(Drawable live) {
+ if (live == null) return 0xFF6E6E73;
+ Drawable d = live.getConstantState() != null ? live.getConstantState().newDrawable().mutate() : live;
+ Rect saved = new Rect(d.getBounds());
+ int n = 24;
+ Bitmap bmp = Bitmap.createBitmap(n, n, Bitmap.Config.ARGB_8888);
+ d.setBounds(0, 0, n, n);
+ d.draw(new Canvas(bmp));
+ d.setBounds(saved);
+ float[] weight = new float[12];
+ float[][] sum = new float[12][3];
+ float[] hsv = new float[3];
+ for (int y = 0; y < n; y++) {
+ for (int x = 0; x < n; x++) {
+ int p = bmp.getPixel(x, y);
+ if (Color.alpha(p) < 128) continue;
+ Color.colorToHSV(p, hsv);
+ if (hsv[1] < 0.3f || hsv[2] < 0.25f) continue; // white, grey and black carry no hue
+ int bin = (int) (hsv[0] / 30f) % 12;
+ float w = hsv[1] * hsv[2];
+ weight[bin] += w;
+ sum[bin][0] += Color.red(p) * w;
+ sum[bin][1] += Color.green(p) * w;
+ sum[bin][2] += Color.blue(p) * w;
+ }
+ }
+ bmp.recycle();
+ int best = 0;
+ for (int i = 1; i < 12; i++) if (weight[i] > weight[best]) best = i;
+ if (weight[best] < n * n * 0.03f) return 0xFF6E6E73; // a monochrome icon, like a grey gear
+ float w = weight[best];
+ return Color.rgb((int) (sum[best][0] / w), (int) (sum[best][1] / w), (int) (sum[best][2] / w));
+ }
+
+ /**
+ * The uniform tile's fill. Where the icon sits on a flat colour of its own (a white or coloured rounded
+ * square), the card takes that colour, so the mark reads as filling the tile as on tvOS. Otherwise a
+ * gradient of the icon's main colour, deepened so the mark stands out. The card clips the corners.
+ */
+ private static int[] backdrop(Drawable live, int fallback) {
+ int[] plate = iconPlate(live);
+ if (plate != null) return plate;
+ float[] hsv = new float[3];
+ Color.colorToHSV(fallback, hsv);
+ // Yellow darkened turns olive: lean it to amber instead.
+ if (hsv[0] > 42f && hsv[0] < 70f && hsv[1] > 0.3f) hsv[0] = 36f;
+ hsv[2] = Math.min(hsv[2], 0.62f);
+ int top = Color.HSVToColor(hsv);
+ hsv[2] *= 0.6f;
+ return new int[]{top, Color.HSVToColor(hsv)};
+ }
+
+ /**
+ * The plate an icon's artwork sits on (a flat or vertically graded rounded square), carried out to the
+ * card's top and bottom edges so the mark reads as filling the tile; null when the icon has no
+ * opaque plate (a bare mark on transparency).
+ */
+ private static int[] iconPlate(Drawable live) {
+ if (live == null) return null;
+ Drawable d = live.getConstantState() != null ? live.getConstantState().newDrawable().mutate() : live;
+ Rect saved = new Rect(d.getBounds());
+ int n = 48;
+ Bitmap bmp = Bitmap.createBitmap(n, n, Bitmap.Config.ARGB_8888);
+ d.setBounds(0, 0, n, n);
+ d.draw(new Canvas(bmp));
+ d.setBounds(saved);
+ // Just inside a rounded square's corners; one side may go a step further in, past a corner badge.
+ // An icon padded on both sides is a small plate in the middle, which no fill would meet.
+ int a = plateColor(bmp, 7, n), b = plateColor(bmp, n - 8, n);
+ int topRow = 7, bottomRow = n - 8;
+ if (a == 0 && b != 0) a = plateColor(bmp, topRow = 10, n);
+ else if (b == 0 && a != 0) b = plateColor(bmp, bottomRow = n - 11, n);
+ bmp.recycle();
+ if (a == 0 || b == 0) return null;
+ // The sampled rows sit at these heights of the tile; extend the line through them to its edges. A row
+ // taken further in sits on artwork-side plate, so its slope is less certain: cap how far it reaches.
+ float margin = (1f - ICON_SHARE) / 2f;
+ float yA = margin + ICON_SHARE * topRow / n, yB = margin + ICON_SHARE * bottomRow / n;
+ float t0 = -yA / (yB - yA), t1 = (1f - yA) / (yB - yA);
+ if (topRow != 7 || bottomRow != n - 8) {
+ t0 = Math.max(-0.35f, t0);
+ t1 = Math.min(1.35f, t1);
+ }
+ return new int[]{mix(a, b, t0), mix(a, b, t1)};
+ }
+
+ /** {@link #plateColor(int[])} of row y, between the same insets as the row's distance from the edge. */
+ private static int plateColor(Bitmap bmp, int y, int n) {
+ int inset = Math.min(y, n - 1 - y);
+ int[] row = new int[n - 2 * inset];
+ bmp.getPixels(row, 0, row.length, inset, y, row.length, 1);
+ return plateColor(row);
+ }
+
+ /** The colour most of a row shares, ignoring artwork that crosses it; 0 if the row is not mostly plate. */
+ private static int plateColor(int[] row) {
+ int[] r = new int[row.length], g = new int[row.length], b = new int[row.length];
+ int opaque = 0;
+ for (int p : row) {
+ if (Color.alpha(p) < 240) continue;
+ r[opaque] = Color.red(p);
+ g[opaque] = Color.green(p);
+ b[opaque] = Color.blue(p);
+ opaque++;
+ }
+ if (opaque < row.length * 0.9f) return 0;
+ int mr = median(r, opaque), mg = median(g, opaque), mb = median(b, opaque);
+ long sr = 0, sg = 0, sb = 0;
+ int close = 0;
+ for (int i = 0; i < opaque; i++) {
+ if (Math.abs(r[i] - mr) + Math.abs(g[i] - mg) + Math.abs(b[i] - mb) >= 48) continue;
+ sr += r[i];
+ sg += g[i];
+ sb += b[i];
+ close++;
+ }
+ if (close < row.length * 0.7f) return 0;
+ return Color.rgb((int) (sr / close), (int) (sg / close), (int) (sb / close));
+ }
+
+ private static int median(int[] values, int count) {
+ int[] sorted = Arrays.copyOf(values, count);
+ Arrays.sort(sorted);
+ return sorted[count / 2];
+ }
+
+ /** a + (b - a) * t per channel, clamped; t outside 0..1 extrapolates. */
+ private static int mix(int a, int b, float t) {
+ return Color.rgb(clamp(Color.red(a) + (Color.red(b) - Color.red(a)) * t),
+ clamp(Color.green(a) + (Color.green(b) - Color.green(a)) * t),
+ clamp(Color.blue(a) + (Color.blue(b) - Color.blue(a)) * t));
+ }
+
+ private static int clamp(float v) {
+ return Math.max(0, Math.min(255, Math.round(v)));
+ }
+
private static int vividColor(Drawable live) {
if (live == null) return 0xFF444444;
// Draw a private copy: changing the bounds of the drawable an ImageView shows would blank the tile.
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 6252d6d4b..6caa8d743 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -128,6 +128,8 @@ final class Config {
final boolean appLibrary;
/** OK directly toggles Home membership in the library (app_library_selection). */
final boolean appLibrarySelection;
+ /** Icon on a card tinted from that icon, instead of the app's banner (config.xml uniform_tiles). */
+ final boolean uniformTiles;
/** Background colour behind everything, #RRGGBB; black unless a theme says otherwise. */
final int backgroundColor;
/** Time-of-day backdrop, 0 to 100 (config.xml, sky_intensity); 0 keeps the plain background. */
@@ -213,7 +215,8 @@ final class Config {
String sourcePanelExtra, boolean coocaaSources, String inputAction,
String inputUriScheme, int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,
boolean shamsiDate, String greetingName, boolean moduleCards, boolean reducedMotion, boolean bootToLiveTv, boolean dockTitle, boolean dockRow, boolean topMenu, boolean launcherSettingsButton, boolean reorderButton, boolean showNetworkPill, boolean showInputsPill, boolean iconOnlyButtons, boolean iconOnlyInputs, boolean libraryButton, int wifiLabelWidth, boolean alwaysShowNames, boolean wallpaperTrueColor, boolean focusOvershoot, String vpnApp,
- boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, boolean appLibrarySelection, int backgroundColor, int skyIntensity,
+ boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, boolean appLibrarySelection,
+ boolean uniformTiles, int backgroundColor, int skyIntensity,
int[] settingsKeycodes, boolean settingsKeyPanel, boolean restoreKeyServices, boolean wallpaperEnabled, File wallpaper, List<File> wallpapers,
int wallpaperRotationMinutes, int wallpaperDim, int dockOpacity, String wallpaperOrder, boolean overlayApplied,
Festival festival, int[] inputKeycodes, List<String> appKeys, String stockHomeRedirect,
@@ -271,6 +274,7 @@ final class Config {
this.showStats = showStats;
this.appLibrary = appLibrary;
this.appLibrarySelection = appLibrarySelection;
+ this.uniformTiles = uniformTiles;
this.backgroundColor = backgroundColor;
this.skyIntensity = skyIntensity;
this.settingsKeycodes = settingsKeycodes;
@@ -362,6 +366,7 @@ final class Config {
boolean showStats = res.getBoolean(R.bool.show_stats);
boolean library = res.getBoolean(R.bool.app_library);
boolean librarySelection = res.getBoolean(R.bool.app_library_selection);
+ boolean uniformTiles = res.getBoolean(R.bool.uniform_tiles);
int background = 0xFF000000;
int skyIntensity = res.getInteger(R.integer.sky_intensity);
int[] settingsKeycodes = res.getIntArray(R.array.settings_key_keycodes);
@@ -441,6 +446,7 @@ final class Config {
showStats = bool(json, "show_stats", showStats);
library = bool(json, "app_library", library);
librarySelection = bool(json, "app_library_selection", librarySelection);
+ uniformTiles = bool(json, "uniform_tiles", uniformTiles);
background = color(json, "background_color", background);
skyIntensity = integer(json, "sky_intensity", skyIntensity, 0, 100);
settingsKeycodes = intArray(json, "settings_key_keycodes", settingsKeycodes);
@@ -516,7 +522,7 @@ final class Config {
packageMap(appBanners), panelService,
panelAction, panelExtra, coocaaSources, inputAction, inputUriScheme,
Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,
- shamsi, greetingName, moduleCards, reducedMotion, bootToLiveTv, dockTitle, dockRow, topMenu, launcherSettingsButton, reorderButton, showNetworkPill, showInputsPill, iconOnlyButtons, iconOnlyInputs, libraryButton, wifiLabelWidth, alwaysShowNames, wallpaperTrueColor, focusOvershoot, vpn, homeSettings, showStats, library, librarySelection, background,
+ shamsi, greetingName, moduleCards, reducedMotion, bootToLiveTv, dockTitle, dockRow, topMenu, launcherSettingsButton, reorderButton, showNetworkPill, showInputsPill, iconOnlyButtons, iconOnlyInputs, libraryButton, wifiLabelWidth, alwaysShowNames, wallpaperTrueColor, focusOvershoot, vpn, homeSettings, showStats, library, librarySelection, uniformTiles, background,
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, restoreKeyServices, wallpaperEnabled, wallpaper,
wallpapers, rotationMinutes, wallpaperDim, dockOpacity, wallpaperOrder, applied,
festival, inputKeycodes, appKeys, stockHomeRedirect, json == null ? Collections.emptyList() : raceCalendar(json), cinematic, ambientGlow, appGlow, fadeRows,
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index f600b7d60..1427d5799 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -278,6 +278,9 @@
<!-- Installed launchable apps, including ordinary Android apps. Also settable in config.json. -->
<bool name="app_library">false</bool>
+ <!-- Every app tile is its icon on a card tinted from that icon, name only under the focused tile,
+ instead of each app's own banner. Off by default; a theme can set "uniform_tiles": true. -->
+ <bool name="uniform_tiles">false</bool>
<!-- Optional direct Home picker in the app library: OK toggles the checkmark, checked apps first.
Off by default; a theme can set "app_library_selection": true (also needs app_library). -->
<bool name="app_library_selection">false</bool>
diff --git a/themes/README.md b/themes/README.md
index fd66ad533..a12455cda 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -67,6 +67,7 @@ A new key needs one there in the same pull request.
| `always_show_names` | bool | Names under every tile, dimmed until focused, the dock included (its band grows to hold them); `false` by default shows only the focused tile's name |
| `wallpaper_true_color` | bool | Decode wallpapers in 32-bit colour (8 MB at 1080p) instead of RGB_565 (4 MB), which bands dark gradients such as a night sky; for TVs with 2 GB or more (`false` by default) |
| `app_library` | bool | An App library pill after the last Home row: every installed app, add one to Home or take it off (`false` by default). The choices stay on the TV when a theme is pushed or reset; see [docs/app-library.md](../docs/app-library.md) |
+| `uniform_tiles` | bool | Each app tile is its icon on a card tinted from that icon, with the name only under the focused tile, instead of the app's own banner (`false` by default) |
| `app_library_selection` | bool | OK toggles Home checkmarks in the library; checked apps first, both groups alphabetized. Hiding keeps focus on the adjacent next app (previous at the end). Requires `app_library`; `false` preserves the standard open/long-press behavior |
| `library_apps` | list of package names | Packages pre-seeded into the App library's "added" set at startup (config.xml `library_apps`, or a theme's `config.json`). They show on Home as if the owner had added them in the App library UI, and stay removable there (a removed one stays hidden); empty (off) by default |
| `shamsi_date` | bool | Show the Solar Hijri date above the Gregorian one |