Skip to content

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

Launcher: apps as round logo buttons in the top bar (top_bar_apps)

benny117fa36231d59ae
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 6252d6d4b..007c02f69 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -206,6 +206,8 @@ final class Config {
final boolean handleViewInputs;
/** Hold OK on a tile opens a menu (Move, Remove from Home, App info) instead of App info (config.xml / theme tile_menu). */
final boolean tileMenu;
+ /** Apps shown as round logo buttons in the top bar, left of the network pill, and no longer as tiles (config.xml, top_bar_apps). */
+ final List<String> topBarApps;
private Config(List<String> dockApps, boolean fillDock, List<String> hiddenApps, List<String> libraryApps, String liveTvPackage,
String liveTvAction, String liveTvInputId, Map<String, String> launchActions, Map<String, String> appLabels,
@@ -220,7 +222,7 @@ final class Config {
List<RaceWeekend.Race> raceCalendar, boolean cinematicHome, boolean ambientGlow, boolean appGlow, boolean fadeRows, int homeIdleClockMinutes,
boolean keyFilter, boolean dockGlass, String glowStyle, boolean wallpaperCaptions,
boolean handleViewInputs, boolean tileMenu, boolean dockEvenPadding, boolean cinematicDots, boolean cinematicWhiteFocus, boolean wifiStatusColor, int cinematicScrim, int cinematicArt,
- Map<String, Set<String>> wallpaperMoods, boolean gamepadPassthrough) {
+ Map<String, Set<String>> wallpaperMoods, boolean gamepadPassthrough, List<String> topBarApps) {
this.handleViewInputs = handleViewInputs;
this.tileMenu = tileMenu;
this.inputKeycodes = inputKeycodes;
@@ -300,6 +302,7 @@ final class Config {
this.cinematicScrim = cinematicScrim;
this.wallpaperMoods = wallpaperMoods;
this.gamepadPassthrough = gamepadPassthrough;
+ this.topBarApps = Collections.unmodifiableList(topBarApps);
this.glowStyle = glowStyle(glowStyle);
this.wallpaperCaptions = wallpaperCaptions;
}
@@ -387,6 +390,7 @@ final class Config {
int cinematicScrim = res.getInteger(R.integer.cinematic_scrim);
Map<String, Set<String>> wallpaperMoods = moods(res.getString(R.string.wallpaper_moods));
String glowStyle = res.getString(R.string.glow_style);
+ List<String> topBarApps = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.top_bar_apps)));
boolean applied = false;
File dir = dir(ctx);
@@ -466,8 +470,11 @@ final class Config {
cinematicScrim = integer(json, "cinematic_scrim", cinematicScrim, 0, 100);
JSONObject moods = json.optJSONObject("wallpaper_moods");
if (moods != null) wallpaperMoods = moods(moods);
+ topBarApps = stringList(json, "top_bar_apps", topBarApps);
glowStyle = string(json, "glow_style", glowStyle);
}
+ // A top-bar app is moved there, not copied: it leaves the grid.
+ for (String pkg : topBarApps) if (!hidden.contains(pkg)) hidden.add(pkg);
// A theme push or reset invalidates choices made on the TV. On first use, remember the
// current theme without clearing choices from an older launcher version.
SharedPreferences choices = ctx.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE);
@@ -520,7 +527,7 @@ final class Config {
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, restoreKeyServices, wallpaperEnabled, wallpaper,
wallpapers, rotationMinutes, wallpaperDim, dockOpacity, wallpaperOrder, applied,
festival, inputKeycodes, appKeys, stockHomeRedirect, json == null ? Collections.emptyList() : raceCalendar(json), cinematic, ambientGlow, appGlow, fadeRows,
- Math.max(0, idleClockMinutes), keyFilter, dockGlass, glowStyle, wallpaperCaptions, handleViewInputs, tileMenu, dockEvenPadding, cinematicDots, cinematicWhiteFocus, wifiStatusColor, cinematicScrim, cinematicArt, wallpaperMoods, gamepadPassthrough);
+ Math.max(0, idleClockMinutes), keyFilter, dockGlass, glowStyle, wallpaperCaptions, handleViewInputs, tileMenu, dockEvenPadding, cinematicDots, cinematicWhiteFocus, wifiStatusColor, cinematicScrim, cinematicArt, wallpaperMoods, gamepadPassthrough, topBarApps);
}
/**
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 dca4f8424..aaf521c5f 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -82,6 +82,7 @@ import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
@@ -619,6 +620,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
libraryFromTopBar = true; // closing it goes back to this button, not to the pill after the last row
});
btnLibraryTop.setVisibility(cfg.libraryButton && cfg.appLibrary ? View.VISIBLE : View.GONE);
+ addTopBarApps(cfg.topBarApps);
iconOnlyButtons = cfg.iconOnlyButtons;
topMenu = cfg.topMenu;
wifiIconOnly = iconOnlyButtons && cfg.wifiLabelWidth <= 0;
@@ -677,8 +679,11 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
btnSettings.setOnKeyListener(pillKeys);
btnReorder.setOnKeyListener(pillKeys);
btnLibraryTop.setOnKeyListener(pillKeys);
+ for (View button : topAppButtons) button.setOnKeyListener(pillKeys);
if (advancedEffects) {
- for (View button : new View[]{btnInputs, btnWifi, btnReorder, btnLibraryTop, btnSettings}) {
+ List<View> pills = new ArrayList<>(Arrays.asList(btnInputs, btnWifi, btnReorder, btnLibraryTop, btnSettings));
+ pills.addAll(topAppButtons);
+ for (View button : pills) {
button.setOnFocusChangeListener((view, focused) -> view.animate()
.scaleX(focused ? 1.04f : 1f).scaleY(focused ? 1.04f : 1f)
.setDuration(reducedMotion ? Motion.REDUCED_MS : 160).start());
@@ -2130,13 +2135,52 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
hideHero();
}
- /** The first top-bar button after Inputs that is shown: the network pill, Reorder, then Settings (always there). */
+ /** The first top-bar button after Inputs that is shown, in bar order (top_bar_apps, the network pill, ...); Settings is always there. */
private View firstTopButton() {
- if (btnWifi.getVisibility() == View.VISIBLE) return btnWifi;
- if (btnReorder.getVisibility() == View.VISIBLE) return btnReorder;
+ ViewGroup bar = findViewById(R.id.topButtons);
+ for (int i = 0; i < bar.getChildCount(); i++) {
+ View button = bar.getChildAt(i);
+ if (button != btnInputs && button.getVisibility() == View.VISIBLE) return button;
+ }
return findViewById(R.id.btnSettings);
}
+ /** top_bar_apps buttons, in bar order. */
+ private final List<View> topAppButtons = new ArrayList<>();
+
+ /**
+ * Puts each top_bar_apps app in the top bar as a round pill with the app's own logo, left of the network pill.
+ * The logo keeps its colours: the pill style's tint, which turns the other icons white, is cleared.
+ */
+ private void addTopBarApps(List<String> packages) {
+ ViewGroup bar = findViewById(R.id.topButtons);
+ PackageManager pm = getPackageManager();
+ int size = Math.round(22 * density);
+ for (String pkg : packages) {
+ Intent launch = pm.getLeanbackLaunchIntentForPackage(pkg);
+ if (launch == null) launch = pm.getLaunchIntentForPackage(pkg);
+ if (launch == null) continue; // not installed, or disabled
+ Drawable logo;
+ CharSequence label;
+ try {
+ ApplicationInfo info = pm.getApplicationInfo(pkg, 0);
+ logo = info.loadIcon(pm);
+ label = info.loadLabel(pm);
+ } catch (PackageManager.NameNotFoundException e) {
+ continue;
+ }
+ TextView button = (TextView) getLayoutInflater().inflate(R.layout.top_app_button, bar, false);
+ logo.setBounds(0, 0, size, size);
+ button.setCompoundDrawablesRelative(logo, null, null, null);
+ button.setCompoundDrawableTintList(null);
+ button.setContentDescription(label);
+ Intent target = launch;
+ button.setOnClickListener(v -> open(new Intent(target)));
+ bar.addView(button, bar.indexOfChild(btnWifi));
+ topAppButtons.add(button);
+ }
+ }
+
@Override public void onLibraryUp() {
if (adapter.appCount() == 0) { firstTopButton().requestFocus(); return; }
int lastRow = ((adapter.appCount() - 1) / COLUMNS) * COLUMNS;
diff --git a/launcher/app/src/main/res/layout/top_app_button.xml b/launcher/app/src/main/res/layout/top_app_button.xml
new file mode 100644
index 000000000..53e9b0414
--- /dev/null
+++ b/launcher/app/src/main/res/layout/top_app_button.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- One top_bar_apps button: the round icon pill, its logo set from the app in MainActivity. -->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/TopButtonIcon"
+ android:nextFocusDown="@+id/grid" />
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index f600b7d60..81320b3b5 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -231,6 +231,10 @@
<!-- The Wi-Fi/Ethernet pill in the top bar. false hides it (on Android 14 with Location off it can
only say "Wi-Fi", not the network name). Can also be set with "show_network_pill" in a theme. -->
<bool name="show_network_pill">true</bool>
+ <!-- Apps shown as round buttons with their own logo in the top bar, left of the network pill, in this order.
+ They leave the grid. Missing apps are skipped. Can also be set with "top_bar_apps" in a theme. -->
+ <string-array name="top_bar_apps" translatable="false">
+ </string-array>
<!-- The Inputs pill in the top bar, shown when the TV has inputs to list. false hides it for good; what the
remote's Input button does is unchanged. Can also be set with "show_inputs_pill" in a theme. -->
<bool name="show_inputs_pill">true</bool>
diff --git a/themes/README.md b/themes/README.md
index fd66ad533..6154e277f 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -56,6 +56,7 @@ A new key needs one there in the same pull request.
| `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 |
| `show_network_pill` | bool | The Wi-Fi/Ethernet pill in the top bar (`true` by default); `false` hides it |
+| `top_bar_apps` | list of package names | Apps shown as round buttons with their own logo in the top bar, left of the network pill; they leave the grid |
| `show_inputs_pill` | bool | The Inputs pill in the top bar, shown when the TV has inputs (`true` by default); `false` hides it, and with `top_menu` it also leaves Inputs out of the gear's menu (streamers with no HDMI input, such as the Chromecast with Google TV); what the remote's Input button does is unchanged |
| `icon_only_buttons` | bool | Wi-Fi and Settings as round icon buttons; Inputs keeps its label (`false` by default) |
| `icon_only_inputs` | bool | The Inputs pill as a round icon button too, its label kept as the TalkBack description (`false` by default). Works with or without `icon_only_buttons` |