Skip to content

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

launcher: rows_below_dock fits the screen height; dock_title option

Samuel Hinton4f20a336a0b6
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 1c351396f..5b0eb318f 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -106,10 +106,38 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
/** Height of one grid item: the tile, the name label under it and the item's own padding. */
static int itemHeightPx(int tileHeightPx, float density) {
- return tileHeightPx + Math.round(45 * density);
+ return tileHeightPx + Math.round(ITEM_EXTRA_DP * density);
+ }
+
+ /** item_app.xml: 8dp padding above and below, a 7dp gap and the 22dp name label under the tile. */
+ static final float ITEM_EXTRA_DP = 45;
+ /** DockDecoration's offsets above and below the dock row. */
+ static final float DOCK_EXTRA_DP = 6 + 12;
+ /** Room kept under the last row rows_below_dock asks for (MainActivity places the dock with the same). */
+ static final float BOTTOM_ROOM_DP = 30;
+ /** Room kept above the dock for the dock title (48sp hero name plus its 40dp gap) when dock_title is on. */
+ static final float TITLE_ROOM_DP = 104;
+
+ /**
+ * Tile width that fits the columns across and, with rows_below_dock > 0, the dock (with its title above it,
+ * if shown) plus that many rows down the grid's height; the smaller wins. With rows_below_dock = 0, or before
+ * the grid has a height, only the width counts, as before. Without this, 2 or 3 rows below the dock did not
+ * fit: the dock was pushed to the top and its title drew over the clock.
+ */
+ static int tileWidthPx(int innerWidthPx, int gridHeightPx, int columns, int rowsBelowDock, boolean dockTitle,
+ float density) {
+ int w = tileWidthPx(innerWidthPx, columns, density);
+ if (gridHeightPx <= 0 || rowsBelowDock <= 0) return w;
+ float reserved = (DOCK_EXTRA_DP + BOTTOM_ROOM_DP + (dockTitle ? TITLE_ROOM_DP : 0)) * density;
+ float perItem = (gridHeightPx - reserved) / (rowsBelowDock + 1);
+ float tileH = perItem - ITEM_EXTRA_DP * density;
+ int byHeight = Math.round(tileH * DESIGN_W_DP / DESIGN_H_DP);
+ return Math.max(Math.round(80 * density), Math.min(w, byHeight));
}
private final Context ctx;
+ private final int rowsBelowDock;
+ private final boolean dockTitle;
private final TileListener listener;
private final int dockSize;
/** Dock order (config.xml dock_apps, or a theme's config.json). */
@@ -138,6 +166,8 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
this.advancedEffects = cfg.animations && cfg.advancedEffects;
this.showHomeSettings = cfg.showHomeSettingsShortcut;
this.reducedMotion = cfg.reducedMotion;
+ this.rowsBelowDock = cfg.rowsBelowDock;
+ this.dockTitle = cfg.dockTitle;
// 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);
@@ -224,7 +254,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
float density = parent.getResources().getDisplayMetrics().density;
int width = parent.getWidth() > 0 ? parent.getWidth() : parent.getMeasuredWidth();
int inner = width - parent.getPaddingLeft() - parent.getPaddingRight();
- int w = tileWidthPx(inner, dockSize, density), h = tileHeightPx(w);
+ int w = tileWidthPx(inner, parent.getHeight(), dockSize, rowsBelowDock, dockTitle, density), h = tileHeightPx(w);
View card = v.findViewById(R.id.card);
ViewGroup.LayoutParams cardLp = card.getLayoutParams();
cardLp.width = w;
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 96e48018d..7670a61c2 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -52,6 +52,8 @@ final class Config {
final boolean moduleCards;
/** Calmer motion for weak GPUs (config.xml, reduced_motion): stiff spring, short fades, no replay. */
final boolean reducedMotion;
+ /** The focused dock app's name in large type above the dock (config.xml, dock_title). */
+ final boolean dockTitle;
final String vpnApp;
final boolean showHomeSettingsShortcut;
/** Background colour behind everything, #RRGGBB; black unless a theme says otherwise. */
@@ -72,7 +74,7 @@ final class Config {
private Config(List<String> dockApps, boolean fillDock, List<String> hiddenApps, String liveTvPackage,
String liveTvAction, String sourcePanelService, String sourcePanelAction, String inputAction,
int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,
- boolean shamsiDate, boolean moduleCards, boolean reducedMotion, String vpnApp,
+ boolean shamsiDate, boolean moduleCards, boolean reducedMotion, boolean dockTitle, String vpnApp,
boolean showHomeSettingsShortcut, int backgroundColor, int skyIntensity,
int[] settingsKeycodes, boolean settingsKeyPanel, File wallpaper, boolean overlayApplied,
Festival festival) {
@@ -91,6 +93,7 @@ final class Config {
this.shamsiDate = shamsiDate;
this.moduleCards = moduleCards;
this.reducedMotion = reducedMotion;
+ this.dockTitle = dockTitle;
this.vpnApp = vpnApp;
this.showHomeSettingsShortcut = showHomeSettingsShortcut;
this.backgroundColor = backgroundColor;
@@ -124,6 +127,7 @@ final class Config {
boolean shamsi = res.getBoolean(R.bool.shamsi_date);
boolean moduleCards = res.getBoolean(R.bool.module_cards);
boolean reducedMotion = res.getBoolean(R.bool.reduced_motion);
+ boolean dockTitle = res.getBoolean(R.bool.dock_title);
String vpn = res.getString(R.string.vpn_app).trim();
boolean homeSettings = res.getBoolean(R.bool.show_home_settings_shortcut);
int background = 0xFF000000;
@@ -152,6 +156,7 @@ final class Config {
shamsi = bool(json, "shamsi_date", shamsi);
moduleCards = bool(json, "module_cards", moduleCards);
reducedMotion = bool(json, "reduced_motion", reducedMotion);
+ dockTitle = bool(json, "dock_title", dockTitle);
vpn = string(json, "vpn_app", vpn);
homeSettings = bool(json, "show_home_settings_shortcut", homeSettings);
background = color(json, "background_color", background);
@@ -177,7 +182,7 @@ final class Config {
return new Config(dock, fillDock, hidden, liveTv, liveTvAction, panelService, panelAction, inputAction,
Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,
- shamsi, moduleCards, reducedMotion, vpn, homeSettings, background,
+ shamsi, moduleCards, reducedMotion, dockTitle, vpn, homeSettings, background,
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaper, applied,
festival);
}
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 d7c86c17d..24daf7280 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -236,6 +236,8 @@ 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);
greeting = findViewById(R.id.greeting);
greetingColor = greeting.getCurrentTextColor();
btnWifi = findViewById(R.id.btnWifi);
@@ -304,12 +306,16 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
int rowsBelowDock = cfg.rowsBelowDock;
grid.addOnLayoutChangeListener((v, l, t, r, b, ol, ot, or, ob) -> {
int h = b - t;
- // Item height follows the tile size, which follows the column count (AppAdapter.tileWidthPx).
+ // Item height follows the tile size, which follows the columns and the rows that must fit (AppAdapter.tileWidthPx).
int inner = (r - l) - grid.getPaddingLeft() - grid.getPaddingRight();
- int itemH = AppAdapter.itemHeightPx(AppAdapter.tileHeightPx(AppAdapter.tileWidthPx(inner, COLUMNS, density)), density);
- int dockRow = itemH + (int) ((6 + 12) * density); // item height plus DockDecoration offsets
+ int tileW = AppAdapter.tileWidthPx(inner, h, COLUMNS, rowsBelowDock, cfg.dockTitle, density);
+ int itemH = AppAdapter.itemHeightPx(AppAdapter.tileHeightPx(tileW), density);
+ int dockRow = itemH + (int) (AppAdapter.DOCK_EXTRA_DP * density); // item height plus DockDecoration offsets
int gridRows = itemH * rowsBelowDock;
- int want = Math.max(0, h - dockRow - gridRows - (int) (30 * density));
+ int want = Math.max(0, 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.
+ if (cfg.dockTitle && rowsBelowDock > 0) want = Math.max(want, (int) (AppAdapter.TITLE_ROOM_DP * density));
if (grid.getPaddingTop() != want) {
grid.setPadding(grid.getPaddingLeft(), want, grid.getPaddingRight(), grid.getPaddingBottom());
}
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 959b86d0f..7bc6d1ba3 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -68,9 +68,14 @@
VPN you use. Empty: the pill opens Wi-Fi settings. The green VPN badge shows for any VPN either way;
with an app set here, a red "VPN off" badge also shows while no VPN is up. -->
<string name="vpn_app" translatable="false"></string>
- <!-- Grid rows left visible under the dock on the home screen. 0 = dock sits at the very bottom. -->
+ <!-- Grid rows left visible under the dock on the home screen. 0 = dock sits at the very bottom. Tiles shrink if
+ the dock, its title and this many rows would not otherwise fit the screen height. -->
<integer name="rows_below_dock">0</integer>
+ <!-- The focused dock app's name in large type above the dock. false keeps only the glow, which leaves room
+ for bigger tiles when rows_below_dock is 2 or 3. -->
+ <bool name="dock_title">true</bool>
+
<!-- Tiles per row in the grid; the dock always has this many slots. Tiles are 180dp wide at 4 columns and
shrink to fit from 5 up (about 144dp at 5, 117dp at 6 on a 1080p TV). -->
<integer name="columns">4</integer>
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/TileFitTest.java b/launcher/app/src/test/java/com/gathin/tvhome/TileFitTest.java
new file mode 100644
index 000000000..8187db0b9
--- /dev/null
+++ b/launcher/app/src/test/java/com/gathin/tvhome/TileFitTest.java
@@ -0,0 +1,50 @@
+package com.gathin.tvhome;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/** AppAdapter.tileWidthPx with rows_below_dock: the dock, its title and the rows must fit the grid's height. */
+public class TileFitTest {
+
+ private static final float D = 2f; // 1080p TV: 2 px per dp
+ private static final int INNER = 1696; // grid width minus padding at 1920 px
+ private static final int GRID_H = 846; // grid height under the top bar
+
+ private static int height(int tileW, int rows, boolean title) {
+ int itemH = AppAdapter.itemHeightPx(AppAdapter.tileHeightPx(tileW), D);
+ return itemH * (rows + 1) + Math.round((AppAdapter.DOCK_EXTRA_DP + AppAdapter.BOTTOM_ROOM_DP
+ + (title ? AppAdapter.TITLE_ROOM_DP : 0)) * D);
+ }
+
+ @Test
+ public void noRowsBelowDockKeepsTheWidthOnlySize() {
+ int widthOnly = AppAdapter.tileWidthPx(INNER, 4, D);
+ assertEquals(widthOnly, AppAdapter.tileWidthPx(INNER, GRID_H, 4, 0, true, D));
+ assertEquals(widthOnly, AppAdapter.tileWidthPx(INNER, 0, 4, 3, true, D)); // not laid out yet
+ }
+
+ @Test
+ public void dockTitleAndRowsFitTheHeight() {
+ for (int rows = 1; rows <= 3; rows++) {
+ for (boolean title : new boolean[]{true, false}) {
+ if (rows == 3 && title) continue; // below the 80dp minimum, see the next test
+ int w = AppAdapter.tileWidthPx(INNER, GRID_H, 4, rows, title, D);
+ assertTrue("rows " + rows + " title " + title, height(w, rows, title) <= GRID_H + 2);
+ }
+ }
+ }
+
+ @Test
+ public void threeRowsWithTheTitleStopAtTheMinimumTile() {
+ // Tiles would have to be about 23dp tall; they stop at the 80dp-wide minimum instead (dock_title false fits).
+ assertEquals(Math.round(80 * D), AppAdapter.tileWidthPx(INNER, GRID_H, 4, 3, true, D));
+ }
+
+ @Test
+ public void droppingTheTitleGivesBiggerTiles() {
+ assertTrue(AppAdapter.tileWidthPx(INNER, GRID_H, 4, 3, false, D)
+ > AppAdapter.tileWidthPx(INNER, GRID_H, 4, 3, true, D));
+ }
+}
diff --git a/themes/README.md b/themes/README.md
index 1ea46d3c8..92519ee86 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -33,7 +33,8 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `source_panel_service`, `source_panel_action` | string | The TV's own source panel, for sets with no TvInputManager |
| `input_action` | string | Action sent with an HDMI/AV row's channel URI when nothing handles the standard `VIEW` (XGIMI: `com.xgimi.action.hdmiPlayer`) |
| `columns` | 1 to 8 | Tiles per row; tiles shrink to fit from 5 up |
-| `rows_below_dock` | 0 to 3 | Grid rows left visible under the dock |
+| `rows_below_dock` | 0 to 3 | Grid rows left visible under the dock; tiles shrink if the dock, its title and that many rows would not fit the screen height |
+| `dock_title` | bool | The focused dock app's name in large type above the dock (`true`); `false` keeps only the glow |
| `shamsi_date` | bool | Show the Solar Hijri date above the Gregorian one |
| `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 |