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: per-app launch action, label and banner
Marcin Woźniak38e989db5c35
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.javaindex e5e2d57bb..ac7882397 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java@@ -189,6 +189,10 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {private final boolean showHomeSettings;/** Calmer motion for weak GPUs (config.xml, reduced_motion): no overshoot, shorter fades. */private final boolean reducedMotion;+ /** Package to the action its tile sends instead of the start screen (config.xml, launch_actions). */+ private final Map<String, String> launchActions;+ /** 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;private final List<Entry> items = new ArrayList<>();AppAdapter(Context ctx, TileListener listener, int dockSize, Config cfg) {@@ -206,6 +210,9 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {this.rowsBelowDock = cfg.rowsBelowDock;this.dockTitle = cfg.dockTitle;this.dockRow = cfg.dockRow;+ this.launchActions = cfg.launchActions;+ this.appLabels = cfg.appLabels;+ this.appBanners = cfg.appBanners;// 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);@@ -248,9 +255,11 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {if (card != null && !card.component.equals(component)) continue; // the card stands in for this tile// Same cleaner as the card prompt: an app label with a bidi override or line separator must not// redraw the tile name as something else (#117).- String label = card != null ? card.label : Cards.cleanLabel(String.valueOf(ri.loadLabel(pm)), pkg);+ 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 = loadBanner(pm, ri);+ Drawable banner = bundledBanner(appBanners.get(pkg));+ if (banner == null) banner = loadBanner(pm, ri);Drawable icon = ri.loadIcon(pm);if (card != null) {fresh.add(new Entry(Entry.CARD, label, component, banner, icon, card.caption, card.accent));@@ -292,6 +301,13 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {notifyDataSetChanged();}+ /** A banner_* drawable bundled with the launcher, or null for none or a name that is not one. */+ private Drawable bundledBanner(String name) {+ if (name == null || !name.startsWith("banner_")) return null;+ int id = ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName());+ return id != 0 ? ctx.getDrawable(id) : null;+ }+private Drawable loadBanner(PackageManager pm, ResolveInfo ri) {int id = ri.activityInfo.banner;if (id == 0) id = ri.activityInfo.applicationInfo.banner;@@ -424,6 +440,12 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {// TV apps launch with the same leanback intent as from the stock launcher or the remote, so an app// already running resumes instead of restarting; only phone apps added from the library use plain MAIN.if (leanbackPackages.contains(e.pkg)) i.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);+ String action = launchActions.get(e.pkg);+ if (action != null) {+ Intent byAction = new Intent(action).setPackage(e.pkg)+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);+ if (ctx.getPackageManager().resolveActivity(byAction, 0) != null) i = byAction;+ }try {ctx.startActivity(i);if (advancedEffects && ctx instanceof Activity) {diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.javaindex 96f18aae5..8a620cbab 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java@@ -16,7 +16,9 @@ import java.nio.charset.StandardCharsets;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;+import java.util.HashMap;import java.util.List;+import java.util.Map;/*** The launcher's settings: the values in res/values/config.xml, with an optional overlay read from@@ -41,6 +43,12 @@ final class Config {final List<String> hiddenApps;final String liveTvPackage;final String liveTvAction;+ /** Package to the action its tile sends instead of opening the start screen (config.xml, launch_actions). */+ final Map<String, String> launchActions;+ /** Package to the name its tile shows instead of the app's label (config.xml, app_labels). */+ final Map<String, String> appLabels;+ /** Package to a bundled banner_* drawable its tile shows instead of the app's art (config.xml, app_banners). */+ final Map<String, String> appBanners;final String sourcePanelService;final String sourcePanelAction;final String inputAction;@@ -92,7 +100,8 @@ final class Config {final Festival festival;private Config(List<String> dockApps, boolean fillDock, List<String> hiddenApps, String liveTvPackage,- String liveTvAction, String sourcePanelService, String sourcePanelAction, String inputAction,+ String liveTvAction, Map<String, String> launchActions, Map<String, String> appLabels,+ Map<String, String> appBanners, String sourcePanelService, String sourcePanelAction, String inputAction,int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,boolean shamsiDate, String greetingName, boolean moduleCards, boolean reducedMotion, boolean dockTitle, boolean dockRow, boolean reorderButton, String vpnApp,boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, int backgroundColor, int skyIntensity,@@ -106,6 +115,9 @@ final class Config {this.hiddenApps = Collections.unmodifiableList(hiddenApps);this.liveTvPackage = liveTvPackage;this.liveTvAction = liveTvAction;+ this.launchActions = Collections.unmodifiableMap(launchActions);+ this.appLabels = Collections.unmodifiableMap(appLabels);+ this.appBanners = Collections.unmodifiableMap(appBanners);this.sourcePanelService = sourcePanelService;this.sourcePanelAction = sourcePanelAction;this.inputAction = inputAction;@@ -149,6 +161,9 @@ final class Config {List<String> hidden = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.hidden_apps)));String liveTv = res.getString(R.string.live_tv_package).trim();String liveTvAction = res.getString(R.string.live_tv_action).trim();+ List<String> launchActions = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.launch_actions)));+ List<String> appLabels = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.app_labels)));+ List<String> appBanners = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.app_banners)));String panelService = res.getString(R.string.source_panel_service).trim();String panelAction = res.getString(R.string.source_panel_action).trim();String inputAction = res.getString(R.string.input_action).trim();@@ -185,6 +200,9 @@ final class Config {hidden = stringList(json, "hidden_apps", hidden);liveTv = string(json, "live_tv_package", liveTv);liveTvAction = string(json, "live_tv_action", liveTvAction);+ launchActions = stringList(json, "launch_actions", launchActions);+ appLabels = stringList(json, "app_labels", appLabels);+ appBanners = stringList(json, "app_banners", appBanners);panelService = string(json, "source_panel_service", panelService);panelAction = string(json, "source_panel_action", panelAction);inputAction = string(json, "input_action", inputAction);@@ -234,7 +252,9 @@ final class Config {Festival festival = json == null ? Festival.NONE : Festival.parse(string(json, "festival", ""),string(json, "festival_until", ""), string(json, "greeting", ""), string(json, "accent_color", ""));- return new Config(dock, fillDock, hidden, liveTv, liveTvAction, panelService, panelAction, inputAction,+ return new Config(dock, fillDock, hidden, liveTv, liveTvAction, packageMap(launchActions), packageMap(appLabels),+ packageMap(appBanners), panelService,+ panelAction, inputAction,Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,shamsi, greetingName, moduleCards, reducedMotion, dockTitle, dockRow, reorderButton, vpn, homeSettings, showStats, library, background,Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaperEnabled, wallpaper,@@ -338,6 +358,18 @@ final class Config {return out;}+ /** "package=value" entries; an entry without both halves is skipped, and a later entry for a package wins. */+ static Map<String, String> packageMap(List<String> entries) {+ Map<String, String> out = new HashMap<>();+ for (String entry : entries) {+ int eq = entry.indexOf('=');+ if (eq <= 0) continue;+ String pkg = entry.substring(0, eq).trim(), value = entry.substring(eq + 1).trim();+ if (!pkg.isEmpty() && !value.isEmpty()) out.put(pkg, value);+ }+ return out;+ }+private static List<String> stringList(JSONObject o, String key, List<String> fallback) {Object v = o.opt(key);if (!(v instanceof JSONArray)) return fallback;diff --git a/launcher/app/src/main/res/drawable/banner_tv.xml b/launcher/app/src/main/res/drawable/banner_tv.xmlnew file mode 100644index 000000000..6bb2ef1e8--- /dev/null+++ b/launcher/app/src/main/res/drawable/banner_tv.xml@@ -0,0 +1,11 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Banner for a Live TV app tile (config.xml, app_banners): a magenta field with the Live TV glyph. -->+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">+ <item android:width="320dp" android:height="180dp">+ <shape android:shape="rectangle">+ <gradient android:angle="315" android:startColor="#FFE20074" android:endColor="#FF8C0049" />+ </shape>+ </item>+ <item android:width="76dp" android:height="76dp" android:gravity="center"+ android:drawable="@drawable/ic_livetv" />+</layer-list>diff --git a/launcher/app/src/main/res/raw/keep.xml b/launcher/app/src/main/res/raw/keep.xmlnew file mode 100644index 000000000..f5ab67661--- /dev/null+++ b/launcher/app/src/main/res/raw/keep.xml@@ -0,0 +1,4 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- app_banners names drawables at run time, which resource shrinking cannot see: keep every banner_*. -->+<resources xmlns:tools="http://schemas.android.com/tools"+ tools:keep="@drawable/banner_*" />diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xmlindex d415e695b..1b3ff5ad5 100644--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@ -33,6 +33,20 @@to that package instead, and the app starts normally. Leave empty to omit. --><string name="live_tv_action" translatable="false"></string>+ <!-- Tiles that open a screen of the app instead of its start screen: "package=action", sent to that package.+ A tile whose action no longer resolves opens the app normally. MagentaTV's program guide:+ com.telekom.onetv.tv.pl=com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE. -->+ <string-array name="launch_actions">+ </string-array>++ <!-- A tile's name instead of the app's own: "package=Name". It also shows above the dock. -->+ <string-array name="app_labels">+ </string-array>+ <!-- A tile's artwork instead of the app's banner: "package=drawable", a banner_* drawable bundled with the+ launcher (res/drawable). banner_tv is a magenta field with the Live TV glyph. -->+ <string-array name="app_banners">+ </string-array>+<!-- TVs with no TvInputManager have no HDMI list to read, but their own source-selection panelstill switches inputs (TCL Android TV 9 again). When nothing could be listed, the Inputs menuoffers one row that starts this service: component first, then action. Leave empty to omit. -->diff --git a/launcher/app/src/test/java/com/gathin/tvhome/PackageMapTest.java b/launcher/app/src/test/java/com/gathin/tvhome/PackageMapTest.javanew file mode 100644index 000000000..839c4ac2d--- /dev/null+++ b/launcher/app/src/test/java/com/gathin/tvhome/PackageMapTest.java@@ -0,0 +1,34 @@+package com.gathin.tvhome;++import org.junit.Test;++import java.util.Arrays;+import java.util.Collections;+import java.util.Map;++import static org.junit.Assert.assertEquals;+import static org.junit.Assert.assertTrue;++public class PackageMapTest {+ @Test public void anEntryMapsItsPackageToItsAction() {+ Map<String, String> m = Config.packageMap(Collections.singletonList(+ "com.telekom.onetv.tv.pl=com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE"));+ assertEquals("com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE", m.get("com.telekom.onetv.tv.pl"));+ }++ @Test public void spacesAroundTheHalvesAreTrimmed() {+ assertEquals("a.ACTION", Config.packageMap(Collections.singletonList(" a.pkg = a.ACTION ")).get("a.pkg"));+ }++ @Test public void entriesWithoutBothHalvesAreSkipped() {+ assertTrue(Config.packageMap(Arrays.asList("a.pkg", "=a.ACTION", "a.pkg=", "")).isEmpty());+ }++ @Test public void aValueMayContainAnEqualsSign() {+ assertEquals("a=b", Config.packageMap(Collections.singletonList("a.pkg=a=b")).get("a.pkg"));+ }++ @Test public void aLaterEntryForAPackageWins() {+ assertEquals("second", Config.packageMap(Arrays.asList("a.pkg=first", "a.pkg=second")).get("a.pkg"));+ }+}diff --git a/themes/README.md b/themes/README.mdindex f81ca920c..19084ef13 100644--- a/themes/README.md+++ b/themes/README.md@@ -30,6 +30,9 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can| `fill_dock` | bool | Fill the dock slots `dock_apps` leaves free with the first grid apps (true by default); false leaves them empty || `hidden_apps` | list of package names | Never shown as tiles || `live_tv_package`, `live_tv_action` | string | The Live TV app and, if it has no leanback entry, the action to start it with |+| `launch_actions` | list of `"package=action"` | Tiles that open a screen of the app instead of its start screen; an action that no longer resolves opens the app normally (MagentaTV's guide: `com.telekom.onetv.tv.pl=com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE`) |+| `app_labels` | list of `"package=Name"` | A tile's name instead of the app's own (MagentaTV as `com.telekom.onetv.tv.pl=TV`) |+| `app_banners` | list of `"package=banner_name"` | A tile's artwork from a `banner_*` drawable bundled with the launcher (`banner_tv`: magenta with the Live TV glyph) || `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 |