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
Merge PR #299: launcher: reorder apps on the TV from a top-bar button
Gathin23042975424290
diff --cc launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.javaindex f15271c90,703943ef9..472915c1b--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java@@@ -153,12 -110,12 +153,16 @@@ public class AppAdapter extends Recycle}private final Context ctx;+ private final int rowsBelowDock;+ private final boolean dockTitle;+ /** The owner's saved order (reorder button, Order): key -> rank. Empty when there is none or it no longer applies. */+ private Map<String, Integer> savedRanks = Collections.emptyMap();+ /** Reorder mode: no empty dock slots, so every position holds a tile that can move. */+ private boolean reordering;private final TileListener listener;private final int dockSize;+ /** config dock_row: false makes the dock apps the first tiles of one plain grid (names shown, no empty slots). */+ private final boolean dockRow;/** Dock order (config.xml dock_apps, or a theme's config.json). */private final List<String> favourites;/** Grid apps fill the dock slots dock_apps leaves free (config.xml, fill_dock). */@@@ -247,7 -199,7 +254,7 @@@}docked = 0;while (docked < fresh.size() && favourites.contains(fresh.get(docked).pkg)) docked++;- emptySlots = dockRow ? DockSlots.empty(docked, dockSize, fresh.size(), fillDock) : 0;- emptySlots = reordering ? 0 : DockSlots.empty(docked, dockSize, fresh.size(), fillDock);++ emptySlots = dockRow && !reordering ? DockSlots.empty(docked, dockSize, fresh.size(), fillDock) : 0;for (int i = 0; i < emptySlots; i++) {fresh.add(docked + i, new Entry(Entry.EMPTY, "", new ComponentName(ctx, "empty-dock-slot-" + i),null, null, null, 0));diff --cc launcher/app/src/main/java/com/gathin/tvhome/Config.javaindex 150908b7f,96e48018d..5f5176703--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java@@@ -52,10 -52,6 +52,12 @@@ final class Configfinal 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;+ /** The dock as its own row: band, no names, parked low (config.xml dock_row). false: one plain grid. */+ final boolean dockRow;++ /** Reorder button in the top bar (config.xml reorder_button); the Settings long-press menu offers it either way. */++ final boolean reorderButton;final String vpnApp;final boolean showHomeSettingsShortcut;/** Background colour behind everything, #RRGGBB; black unless a theme says otherwise. */@@@ -76,7 -72,7 +78,7 @@@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, boolean dockTitle, boolean dockRow, String vpnApp,- boolean shamsiDate, boolean moduleCards, boolean reducedMotion, String vpnApp,++ boolean shamsiDate, boolean moduleCards, boolean reducedMotion, boolean dockTitle, boolean dockRow, boolean reorderButton, String vpnApp,boolean showHomeSettingsShortcut, int backgroundColor, int skyIntensity,int[] settingsKeycodes, boolean settingsKeyPanel, File wallpaper, boolean overlayApplied,Festival festival) {@@@ -95,8 -91,6 +97,9 @@@this.shamsiDate = shamsiDate;this.moduleCards = moduleCards;this.reducedMotion = reducedMotion;+ this.dockTitle = dockTitle;+ this.dockRow = dockRow;++ this.reorderButton = reorderButton;this.vpnApp = vpnApp;this.showHomeSettingsShortcut = showHomeSettingsShortcut;this.backgroundColor = backgroundColor;@@@ -130,8 -124,6 +133,9 @@@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);+ boolean dockRow = res.getBoolean(R.bool.dock_row);++ boolean reorderButton = res.getBoolean(R.bool.reorder_button);String vpn = res.getString(R.string.vpn_app).trim();boolean homeSettings = res.getBoolean(R.bool.show_home_settings_shortcut);int background = 0xFF000000;@@@ -160,8 -152,6 +164,9 @@@shamsi = bool(json, "shamsi_date", shamsi);moduleCards = bool(json, "module_cards", moduleCards);reducedMotion = bool(json, "reduced_motion", reducedMotion);+ dockTitle = bool(json, "dock_title", dockTitle);+ dockRow = bool(json, "dock_row", dockRow);++ reorderButton = bool(json, "reorder_button", reorderButton);vpn = string(json, "vpn_app", vpn);homeSettings = bool(json, "show_home_settings_shortcut", homeSettings);background = color(json, "background_color", background);@@@ -187,7 -177,7 +192,7 @@@return new Config(dock, fillDock, hidden, liveTv, liveTvAction, panelService, panelAction, inputAction,Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,- shamsi, moduleCards, reducedMotion, dockTitle, dockRow, vpn, homeSettings, background,- shamsi, moduleCards, reducedMotion, vpn, homeSettings, background,++ shamsi, moduleCards, reducedMotion, dockTitle, dockRow, reorderButton, vpn, homeSettings, background,Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaper, applied,festival);}diff --cc launcher/app/src/main/java/com/gathin/tvhome/MainActivity.javaindex 18b895734,4f4fb93eb..8c9068880--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@@ -302,7 -300,7 +313,22 @@@ public class MainActivity extends Activ});grid.setHasFixedSize(true);grid.setItemAnimator(null);- grid.addItemDecoration(new DockDecoration(COLUMNS, density));++ // Tiles that scroll out while one is carried come back from the view cache without a rebind; set their++ // dimming again whenever one attaches, so none stays dim after the drop.++ grid.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {++ @Override++ public void onChildViewAttachedToWindow(@NonNull View v) {++ int pos = grid.getChildAdapterPosition(v);++ boolean carried = movingKey != null && pos != RecyclerView.NO_POSITION++ && movingKey.equals(adapter.keyAt(pos));++ v.setAlpha(movingKey == null || carried ? 1f : 0.45f);++ }++++ @Override++ public void onChildViewDetachedFromWindow(@NonNull View v) {++ }++ });+ if (dockRow) grid.addItemDecoration(new DockDecoration(COLUMNS, density));if (animations) {int enterAnim = reducedMotion ? R.anim.tile_enter_reduced : R.anim.tile_enter;float enterDelay = reducedMotion ? 0f : 0.06f;@@@ -379,6 -374,8 +408,9 @@@return true;});btnSettings.setOnClickListener(v -> open(systemIntent(Settings.ACTION_SETTINGS)));+ btnReorder = findViewById(R.id.btnReorder);+ btnReorder.setOnClickListener(v -> toggleReorder());++ btnReorder.setVisibility(cfg.reorderButton ? View.VISIBLE : View.GONE);btnSettings.setOnLongClickListener(v -> {showSettingsMenu();return true;@@@ -404,8 -401,9 +436,9 @@@btnInputs.setOnKeyListener(pillKeys);btnWifi.setOnKeyListener(pillKeys);btnSettings.setOnKeyListener(pillKeys);+ btnReorder.setOnKeyListener(pillKeys);if (advancedEffects) {-- for (View button : new View[]{btnInputs, btnWifi, btnSettings}) {++ for (View button : new View[]{btnInputs, btnWifi, btnReorder, btnSettings}) {button.setOnFocusChangeListener((view, focused) -> view.animate().scaleX(focused ? 1.04f : 1f).scaleY(focused ? 1.04f : 1f).setDuration(160).start());@@@ -642,23 -642,179 +677,199 @@@}}+ /**+ * A Settings button sent as a keycode (settings_key_keycodes, e.g. 83 on TCL Google TV remotes) opens the same+ * thing HomeKeyService would. While that service runs it consumes the key first; without it (not enabled,+ * or switched off by a force-stop) the stock launcher that used to handle the key is gone, and the button did+ * nothing even on Home.+ */- @Override- public boolean dispatchKeyEvent(KeyEvent event) {++ private boolean handleSettingsKey(KeyEvent event) {+ for (int code : settingsKeycodes) {+ if (event.getKeyCode() != code) continue;+ if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {+ open(settingsKeyPanel ? new Intent(this, QuickSettingsActivity.class)+ : systemIntent(Settings.ACTION_SETTINGS));+ }+ return true;+ }- return super.dispatchKeyEvent(event);++ return false;++ }+++ // ---- reorder ---------------------------------------------------------------------------------++ /** Blue the glass turns while reorder mode is on. */+ private static final int REORDER_ACCENT = 0xFF6EC1FF;++ /**+ * Reorder mode (top-bar button). While it is on, every key comes here first:+ * - nothing carried: arrows move focus as usual; OK on a tile picks it up instead of opening the app;+ * Back ends the mode and saves the order.+ * - a tile carried: arrows move it; Back (or OK) puts it down and the mode stays on for the next one.+ * Other keys (volume, Home) pass through; leaving the launcher ends the mode and saves.+ */+ @Override+ public boolean dispatchKeyEvent(KeyEvent event) {++ if (handleSettingsKey(event)) return true;+ if (!reordering) return super.dispatchKeyEvent(event);+ boolean down = event.getAction() == KeyEvent.ACTION_DOWN;+ int code = event.getKeyCode();+ boolean ok = code == KeyEvent.KEYCODE_DPAD_CENTER || code == KeyEvent.KEYCODE_ENTER+ || code == KeyEvent.KEYCODE_NUMPAD_ENTER;+ boolean back = code == KeyEvent.KEYCODE_BACK || code == KeyEvent.KEYCODE_ESCAPE;+ if (movingKey != null) {+ switch (code) {+ case KeyEvent.KEYCODE_DPAD_LEFT:+ case KeyEvent.KEYCODE_DPAD_RIGHT:+ case KeyEvent.KEYCODE_DPAD_UP:+ case KeyEvent.KEYCODE_DPAD_DOWN:+ if (down) moveBy(code);+ return true;+ default:+ if (ok || back) {+ if (!down) drop();+ return true;+ }+ return super.dispatchKeyEvent(event);+ }+ }+ if (back) {+ if (!down) endReorder();+ return true;+ }+ int pos = focusedTilePosition();+ if (ok && pos >= 0) {+ if (!down) pickUp(pos);+ return true; // never opens the app while reordering+ }+ return super.dispatchKeyEvent(event); // arrows navigate; OK on a top-bar pill works as usual+ }++ /** Adapter position of the focused tile, or -1 when focus is not on a tile. */+ private int focusedTilePosition() {+ View f = getCurrentFocus();+ if (f == null || f.getId() != R.id.card || !(f.getParent() instanceof View)) return -1;+ return grid.getChildAdapterPosition((View) f.getParent());+ }++ /** The reorder button: turns the mode on (focus goes back to the last tile), or off again. */+ private void toggleReorder() {+ if (reordering) {+ endReorder();+ return;+ }+ if (adapter.movableCount() < 2) return;+ adapter.setReordering(true);+ if (adapter.hasEmptySlots()) reloadTiles(); // every position must hold a tile that can move+ reordering = true;+ orderAtStart = adapter.movableKeys();+ glass.setAccent(REORDER_ACCENT);+ btnReorder.setActivated(true);+ focusTile(Math.max(0, Math.min(lastFocused, adapter.movableCount() - 1)));+ Toast.makeText(this, R.string.reorder_hint, Toast.LENGTH_LONG).show();+ }++ private void pickUp(int pos) {+ if (pos >= adapter.movableCount()) return; // the "Default home" tile stays put+ movingKey = adapter.keyAt(pos);+ dimOthers();+ }++ /** Puts the carried tile down where it is; the mode stays on. */+ private void drop() {+ movingKey = null;+ dimOthers();+ }++ /** While a tile is carried, every other tile is dimmed so the carried one stands out; otherwise all are full. */+ private void dimOthers() {+ for (int i = 0; i < grid.getChildCount(); i++) {+ View item = grid.getChildAt(i);+ int pos = grid.getChildAdapterPosition(item);+ boolean carried = movingKey != null && movingKey.equals(adapter.keyAt(pos));+ item.setAlpha(movingKey == null || carried ? 1f : 0.45f);+ }+ }++ /** Ends the mode and saves the order if it changed since the mode started. */+ private void endReorder() {+ if (!reordering) return;+ drop();+ reordering = false;+ adapter.setReordering(false);+ glass.setAccent(festive ? festival.accentColor() : 0);+ btnReorder.setActivated(false);+ List<String> keys = adapter.movableKeys();+ List<String> before = orderAtStart;+ orderAtStart = null;+ if (!keys.equals(before)) {+ Order order = new Order(Order.dockKey(dockApps), keys);+ if (Order.save(Order.file(this), order)) {+ adapter.setSavedOrder(Order.ranks(order, dockApps));+ } else {+ Toast.makeText(this, R.string.reorder_not_saved, Toast.LENGTH_SHORT).show();+ }+ }+ if (fillDockLeavesSlots) reloadTiles(); // the empty dock slots left out while reordering come back+ }++ /**+ * Moves the carried tile one step. Left and Right wrap across rows, like a list; Up and Down move a whole row,+ * and Down into a short last row lands on its last tile. Nothing moves past either end or up into the top bar.+ */+ private void moveBy(int keyCode) {+ int from = adapter.positionOf(movingKey);+ int n = adapter.movableCount();+ if (from < 0 || from >= n) {+ drop();+ return;+ }+ int to;- if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) to = from - 1;- else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) to = from + 1;++ // rtl_app_grid (Hebrew) mirrors the grid: position 0 is on the right, so Left moves towards the end.++ if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) to = rtlAppGrid ? from + 1 : from - 1;++ else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) to = rtlAppGrid ? from - 1 : from + 1;+ else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) to = from - COLUMNS;+ else if (from + COLUMNS < n) to = from + COLUMNS;+ else to = from / COLUMNS < (n - 1) / COLUMNS ? n - 1 : from;+ if (to < 0 || to >= n || to == from) return;+ keepScroll(() -> adapter.move(from, to));+ refocusAfterLayout(to);+ }++ /**+ * Applies an adapter change without the grid jumping. After a move the layout manager anchors on the focused+ * tile, keeping it at its old place on screen and shifting every other row; pinning the first visible row at its+ * current offset as the next layout's anchor keeps the scroll where it was. onTileFocused still scrolls+ * afterwards if the moved tile itself ends up off screen.+ */+ private void keepScroll(Runnable change) {+ GridLayoutManager lm = (GridLayoutManager) grid.getLayoutManager();+ int first = lm.findFirstVisibleItemPosition();+ View firstView = first != RecyclerView.NO_POSITION ? lm.findViewByPosition(first) : null;+ int offset = firstView != null ? lm.getDecoratedTop(firstView) - grid.getPaddingTop() : 0;+ change.run();+ if (firstView != null) lm.scrollToPositionWithOffset(first, offset);+ }++ /**+ * Once the grid has applied the change, put the glass (and focus, if the move dropped it) on the tile at pos.+ * The grid has a fixed size, so it applies adapter changes on the next animation frame rather than in a layout+ * pass; until then it cannot find the tile by position. Wait frame by frame (at most 10) for that. No focus+ * change fires for a moved tile, so focusTile's already-focused path calls onTileFocused itself.+ */+ private void refocusAfterLayout(int pos) {+ grid.postOnAnimation(new Runnable() {+ int frames;++ @Override+ public void run() {+ if ((grid.hasPendingAdapterUpdates() || grid.isLayoutRequested()) && ++frames < 10) {+ grid.postOnAnimation(this);+ return;+ }+ focusTile(pos);+ dimOthers(); // views that came into view or were rebound during the move+ }+ });}@Override@@@ -1351,6 -1471,6 +1562,7 @@@addSettingsMenuRow(rows, popup, R.string.launcher_settings, () -> startActivityForResult(new Intent(this, LauncherSettingsActivity.class), LAUNCHER_SETTINGS_REQUEST));if (moduleCards) addSettingsMenuRow(rows, popup, R.string.module_cards, this::showModuleCards);++ addSettingsMenuRow(rows, popup, R.string.reorder, this::toggleReorder);panel.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);popup.setWidth(Math.max((int) (200 * density), panel.getMeasuredWidth()));// Hebrew puts Settings at the left of the header: grow the menu inward from it.diff --cc launcher/app/src/main/res/values/config.xmlindex 30925a3ef,959b86d0f..334447367--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@@ -68,19 -68,9 +68,22 @@@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. -->+ <!-- The dock as its own row: a lighter band, no names under the tiles, parked low on the screen with the top+ shelf above it. false makes the dock apps simply the first tiles of one plain grid (still in dock_apps+ order, no empty slots), with names under every tile and the glow behind every focused tile. -->+ <bool name="dock_row">true</bool>++ <!-- A reorder button (two arrows) in the top bar. Off by default: reordering is also in the Settings++ button's long-press menu, so it needs no extra button on screen. -->++ <bool name="reorder_button">false</bool>++ <!-- 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 andshrink to fit from 5 up (about 144dp at 5, 117dp at 6 on a 1080p TV). --><integer name="columns">4</integer>diff --cc themes/README.mdindex 382c6a500,1ea46d3c8..9c75c5338--- a/themes/README.md+++ b/themes/README.md@@@ -33,9 -33,7 +33,10 @@@ is ignored, and a file that doesn't par| `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 |+| `dock_row` | bool | The dock as its own row with a band (`true`); `false` makes the dock apps the first tiles of one plain grid |++| `reorder_button` | bool | A reorder button in the top bar (`false` by default); reordering is always in the Settings button's long-press menu || `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 |