Skip to content

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

Launcher: input: launch_actions prefix, hide excluded packages from App Library

ahmersdev4861a88d1651
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 41825a1af..ea5b2a292 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -61,6 +61,8 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
/** Hold OK on a tile: the activity shows the tile menu (move, remove from Home, app info). */
void onTileLongPress(int position, View card);
void onLibraryUp();
+ /** A tile whose launch_actions entry is "input:<id>": switch to that TV input instead of opening an app. */
+ void onOpenInput(String inputId);
}
static final class Entry {
@@ -535,6 +537,10 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
// 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 && action.startsWith("input:")) {
+ listener.onOpenInput(action.substring("input:".length()).trim());
+ return;
+ }
if (action != null) {
// NEW_TASK only: with RESET_TASK_IF_NEEDED, Android just brings a running task of the app to the front
// ("Activity not started"), so the screen never opens while the app is up, e.g. MagentaTV's boot-time task.
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java b/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java
index e62db4635..21af9fa8c 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppLibraryDialog.java
@@ -143,7 +143,14 @@ final class AppLibraryDialog {
if (popup.isShowing()) popup.update(width, height);
}
- AppLibraryDialog(Activity activity, boolean animations, boolean reducedMotion, boolean selectionMode, boolean okOpens, Predicate<String> onHome, Runnable changed, Runnable dismissed) {
+ /** Packages kept out of the catalogue entirely, never just hidden from Home: on some boards a hidden
+ * package must never be reachable from here either, e.g. a factory/AT/fac-menu package that can flip a
+ * factory-mode flag with no way back if opened even once (see examples/candy-android-tv-dvb2k/README.md).
+ * Elsewhere this is empty and hidden_apps still only hides an app from Home while leaving it in the
+ * library, unchanged for every package not listed here. */
+ private final Set<String> excludedFromLibrary;
+
+ AppLibraryDialog(Activity activity, boolean animations, boolean reducedMotion, boolean selectionMode, boolean okOpens, Predicate<String> onHome, Runnable changed, Runnable dismissed, Set<String> excludedFromLibrary) {
this.activity = activity;
this.animations = animations;
this.rtl = activity.getResources().getBoolean(R.bool.rtl_app_grid);
@@ -153,6 +160,7 @@ final class AppLibraryDialog {
this.onHome = onHome;
this.changed = changed;
this.dismissed = dismissed;
+ this.excludedFromLibrary = excludedFromLibrary;
density = activity.getResources().getDisplayMetrics().density;
panel = new LinearLayout(activity);
panel.setLayoutDirection(rtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
@@ -229,7 +237,7 @@ final class AppLibraryDialog {
if (info.activityInfo == null || !info.activityInfo.exported) continue;
String pkg = info.activityInfo.packageName;
if (Intent.CATEGORY_LEANBACK_LAUNCHER.equals(category)) tv.add(pkg);
- if (!pkg.equals(self) && !unique.containsKey(pkg)) unique.put(pkg, info);
+ if (!pkg.equals(self) && !excludedFromLibrary.contains(pkg) && !unique.containsKey(pkg)) unique.put(pkg, info);
}
}
Map<String, String> names = new HashMap<>();
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 179614434..28596c7da 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -1619,7 +1619,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
grid.post(() -> {
if (libraryFocusPending && appLibrary == null && hasWindowFocus() && !isFinishing()) focusLibrary();
});
- });
+ }, hiddenApps);
openPopup = appLibrary.popup;
appLibrary.show();
}
@@ -3319,6 +3319,13 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
rows.getChildAt(0).requestFocus();
}
+ /** A tile configured with launch_actions "input:<id>" (config.xml): switch to that TV input directly,
+ * the same path the Inputs menu's own rows use, instead of opening the input's owning app normally. */
+ @Override
+ public void onOpenInput(String inputId) {
+ openInput(inputId);
+ }
+
/**
* Hold OK on a tile: a glass menu next to it. Move starts reorder mode with this tile already picked up;
* Remove from Home takes the shortcut off (only with the app library on, where one press adds it back);