Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
Launcher: tiles shrink to fit when columns is above 4
Gathin23d7a2efcd84bf
diff --git a/README.md b/README.mdindex 44a986e29..a98be36fb 100644--- a/README.md+++ b/README.md@@ -182,8 +182,8 @@ AndroidX RecyclerView and nothing heavier. It is built for sets with 1 GB of RAMvideo, no network, no background services.**Configure** it in [`launcher/app/src/main/res/values/config.xml`](launcher/app/src/main/res/values/config.xml):-the dock order, apps to hide, your TV's Live TV package, the number of columns, and how many grid-rows stay visible under the dock (`rows_below_dock`). The Inputs button hides itself on sticks and+the dock order, apps to hide, your TV's Live TV package, the number of columns (tiles shrink to fit+from 5 columns up), and how many grid rows stay visible under the dock (`rows_below_dock`). The Inputs button hides itself on sticks andboxes that have no HDMI or tuner.**Language** follows the TV: English, German, Spanish, Catalan and Simplified Chinese so far. If yourdiff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.javaindex 1b53c0963..0249de63b 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java@@ -65,6 +65,29 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {}static final float FOCUS_SCALE = 1.10f;+ /** Design size of a tile (dp); tiles shrink from here when the columns don't fit, see tileWidthPx. */+ static final float DESIGN_W_DP = 180f, DESIGN_H_DP = 101f;++ /**+ * Tile width for a grid of this inner width: the cell minus room for the focus zoom and the glass+ * highlight, capped at the design size so 4 columns on a 1080p TV look exactly as before.+ */+ static int tileWidthPx(int innerWidthPx, int columns, float density) {+ int design = Math.round(DESIGN_W_DP * density);+ if (innerWidthPx <= 0 || columns <= 0) return design;+ int cell = innerWidthPx / columns;+ int fit = (int) ((cell - 12 * density) / FOCUS_SCALE);+ return Math.max(Math.round(80 * density), Math.min(design, fit));+ }++ static int tileHeightPx(int tileWidthPx) {+ return Math.round(tileWidthPx * DESIGN_H_DP / DESIGN_W_DP);+ }++ /** 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);+ }private final Context ctx;private final TileListener listener;@@ -126,6 +149,20 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {@Overridepublic Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_app, parent, false);+ 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);+ View card = v.findViewById(R.id.card);+ ViewGroup.LayoutParams cardLp = card.getLayoutParams();+ cardLp.width = w;+ cardLp.height = h;+ card.setLayoutParams(cardLp);+ View name = v.findViewById(R.id.name);+ ViewGroup.MarginLayoutParams nameLp = (ViewGroup.MarginLayoutParams) name.getLayoutParams();+ nameLp.width = w;+ nameLp.topMargin = h + Math.round(7 * density);+ name.setLayoutParams(nameLp);return new Holder(v, listener);}@@ -258,6 +295,11 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {return Color.HSVToColor(hsv);}+ /** Corner radius for a tile of this width: 16dp at the design width, proportionally less when smaller. */+ static float cornerRadius(int tileWidthPx, float density) {+ return 16f * density * Math.min(1f, tileWidthPx / (DESIGN_W_DP * density));+ }+static final class Holder extends RecyclerView.ViewHolder {final View card;final ImageView banner;@@ -274,11 +316,11 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {name = v.findViewById(R.id.name);final float density = v.getResources().getDisplayMetrics().density;- final float radius = density * 16f;card.setOutlineProvider(new ViewOutlineProvider() {@Overridepublic void getOutline(View view, Outline outline) {- outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), radius);+ // 16dp at the design width, scaled down with the tile so small tiles keep the same shape.+ outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), cornerRadius(view.getWidth(), density));}});card.setClipToOutline(true);diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.javaindex 1aa15dac8..d2852e688 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@ -180,8 +180,11 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {int rowsBelowDock = Math.max(0, getResources().getInteger(R.integer.rows_below_dock));grid.addOnLayoutChangeListener((v, l, t, r, b, ol, ot, or, ob) -> {int h = b - t;- int dockRow = (int) ((145 + 6 + 12) * density); // item height plus DockDecoration offsets- int gridRows = (int) (145 * density * rowsBelowDock);+ // Item height follows the tile size, which follows the column count (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 gridRows = itemH * rowsBelowDock;int want = Math.max(0, h - dockRow - gridRows - (int) (30 * density));if (grid.getPaddingTop() != want) {grid.setPadding(grid.getPaddingLeft(), want, grid.getPaddingRight(), grid.getPaddingBottom());@@ -329,7 +332,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {lp.width = (int) w;lp.height = (int) h;glass.setLayoutParams(lp);- glass.setRadius(16f * density * AppAdapter.FOCUS_SCALE + pad);+ glass.setRadius(AppAdapter.cornerRadius(card.getWidth(), density) * AppAdapter.FOCUS_SCALE + pad);}glassTargetX = x;glassTargetY = y;diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xmlindex 01750dda1..d635c1c18 100644--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@ -31,7 +31,8 @@<!-- Grid rows left visible under the dock on the home screen. 0 = dock sits at the very bottom. --><integer name="rows_below_dock">0</integer>- <!-- Tiles per row in the grid; the dock always has this many slots. -->+ <!-- 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><!-- "Default home" tile that opens Android's home-screen picker, for TVs whose settings have one