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: opt-in quick settings panel for the remote's Settings button
Jose Berumen93b69087c9ae
diff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xmlindex cf9e6f5dc..bc71caba5 100644--- a/launcher/app/src/main/AndroidManifest.xml+++ b/launcher/app/src/main/AndroidManifest.xml@@ -64,6 +64,16 @@android:exported="false"android:excludeFromRecents="true"android:screenOrientation="landscape" />+ <!-- Remote Settings button panel (settings_key_panel); own task so the app behind stays put. -->+ <activity+ android:name=".QuickSettingsActivity"+ android:exported="false"+ android:taskAffinity=""+ android:launchMode="singleTop"+ android:excludeFromRecents="true"+ android:noHistory="true"+ android:screenOrientation="landscape"+ android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" /><activityandroid:name=".HomeSettingsActivity"android:exported="false"diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.javaindex f346f6afd..2b3511969 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java@@ -56,6 +56,10 @@ final class Config {final int backgroundColor;/** Time-of-day backdrop, 0 to 100 (config.xml, sky_intensity); 0 keeps the plain background. */final int skyIntensity;+ /** Remote keycodes that open Settings through HomeKeyService (config.xml, settings_key_keycodes). */+ final int[] settingsKeycodes;+ /** The Settings button opens the quick settings panel instead of the TV's Settings (settings_key_panel). */+ final boolean settingsKeyPanel;/** Full-screen picture behind the launcher, or null for the plain colour. */final File wallpaper;/** Whether the overlay file was present and parsed. */@@ -66,7 +70,7 @@ final class Config {int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,boolean shamsiDate, boolean moduleCards, boolean reducedMotion, String vpnApp,boolean showHomeSettingsShortcut, int backgroundColor, int skyIntensity,- File wallpaper, boolean overlayApplied) {+ int[] settingsKeycodes, boolean settingsKeyPanel, File wallpaper, boolean overlayApplied) {this.dockApps = Collections.unmodifiableList(dockApps);this.hiddenApps = Collections.unmodifiableList(hiddenApps);this.liveTvPackage = liveTvPackage;@@ -85,6 +89,8 @@ final class Config {this.showHomeSettingsShortcut = showHomeSettingsShortcut;this.backgroundColor = backgroundColor;this.skyIntensity = skyIntensity;+ this.settingsKeycodes = settingsKeycodes;+ this.settingsKeyPanel = settingsKeyPanel;this.wallpaper = wallpaper;this.overlayApplied = overlayApplied;}@@ -114,6 +120,8 @@ final class Config {boolean homeSettings = res.getBoolean(R.bool.show_home_settings_shortcut);int background = 0xFF000000;int skyIntensity = res.getInteger(R.integer.sky_intensity);+ int[] settingsKeycodes = res.getIntArray(R.array.settings_key_keycodes);+ boolean settingsKeyPanel = res.getBoolean(R.bool.settings_key_panel);boolean applied = false;File dir = dir(ctx);@@ -139,6 +147,8 @@ final class Config {homeSettings = bool(json, "show_home_settings_shortcut", homeSettings);background = color(json, "background_color", background);skyIntensity = integer(json, "sky_intensity", skyIntensity, 0, 100);+ settingsKeycodes = intArray(json, "settings_key_keycodes", settingsKeycodes);+ settingsKeyPanel = bool(json, "settings_key_panel", settingsKeyPanel);}// 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.@@ -156,7 +166,7 @@ final class Config {return new Config(dock, hidden, liveTv, liveTvAction, panelService, panelAction, inputAction,Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,shamsi, moduleCards, reducedMotion, vpn, homeSettings, background,- Math.max(0, Math.min(100, skyIntensity)), wallpaper, applied);+ Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaper, applied);}private static void syncThemeChoices(SharedPreferences choices, File dir, File config) {@@ -240,6 +250,21 @@ final class Config {}}+ /** Keycodes 1 to 400 only; a list with anything else in it is ignored as a whole. */+ private static int[] intArray(JSONObject o, String key, int[] fallback) {+ Object v = o.opt(key);+ if (!(v instanceof JSONArray)) return fallback;+ JSONArray a = (JSONArray) v;+ int[] out = new int[a.length()];+ for (int i = 0; i < a.length(); i++) {+ Object item = a.opt(i);+ if (!(item instanceof Number)) return fallback;+ out[i] = ((Number) item).intValue();+ if (out[i] < 1 || out[i] > 400) return fallback;+ }+ 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/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.javaindex ad79b3b2d..9a09a5b0e 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java@@ -20,12 +20,16 @@ public class HomeKeyService extends AccessibilityService {/** Remote buttons that should open Settings (config.xml, settings_key_scancodes and settings_key_keycodes). */private int[] settingsScancodes = new int[0];private int[] settingsKeycodes = new int[0];+ private boolean settingsPanel;@Overrideprotected void onServiceConnected() {super.onServiceConnected();settingsScancodes = getResources().getIntArray(R.array.settings_key_scancodes);- settingsKeycodes = getResources().getIntArray(R.array.settings_key_keycodes);+ // Keycodes and the panel choice can also come from a theme; theme.sh restarts this service.+ Config config = Config.load(this);+ settingsKeycodes = config.settingsKeycodes;+ settingsPanel = config.settingsKeyPanel;}private boolean isSettingsKey(KeyEvent event) {@@ -40,7 +44,9 @@ public class HomeKeyService extends AccessibilityService {// The stock launcher handled the remote's Settings button; with it disabled the button does nothing.if (isSettingsKey(event)) {if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {- startActivity(new Intent(Settings.ACTION_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));+ Intent open = settingsPanel ? new Intent(this, QuickSettingsActivity.class)+ : new Intent(Settings.ACTION_SETTINGS);+ startActivity(open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));}return 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 653182d8e..dd248758b 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@ -76,6 +76,8 @@ import java.util.Set;public class MainActivity extends Activity implements AppAdapter.TileListener {private static final int LAUNCHER_SETTINGS_REQUEST = 42;+ /** Sent by QuickSettingsActivity: open Launcher settings from here so Home rebuilds when they close. */+ static final String ACTION_LAUNCHER_SETTINGS = "com.gathin.tvhome.action.LAUNCHER_SETTINGS";/** Tiles per row and dock slots (res/values/config.xml, columns). Set in onCreate. */static int COLUMNS = 4;private boolean rtlAppGrid;@@ -369,6 +371,15 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN).build(), vpnCallback);}+ // Not after recreate(): the launch intent survives it and would open the settings again.+ if (savedInstanceState == null) openLauncherSettingsIfAsked(getIntent());+ }++ private boolean openLauncherSettingsIfAsked(Intent intent) {+ if (intent == null || !ACTION_LAUNCHER_SETTINGS.equals(intent.getAction())) return false;+ setIntent(new Intent(Intent.ACTION_MAIN));+ startActivityForResult(new Intent(this, LauncherSettingsActivity.class), LAUNCHER_SETTINGS_REQUEST);+ return true;}/**@@ -405,6 +416,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {@Overrideprotected void onNewIntent(Intent intent) {super.onNewIntent(intent);+ if (openLauncherSettingsIfAsked(intent)) return;if (intent == null || !intent.hasCategory(Intent.CATEGORY_HOME)) return;grid.scrollToPosition(0);lastFocused = 0;diff --git a/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.javanew file mode 100644index 000000000..36ff5030c--- /dev/null+++ b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java@@ -0,0 +1,72 @@+package com.gathin.tvhome;++import android.app.Activity;+import android.content.ActivityNotFoundException;+import android.content.Intent;+import android.os.Bundle;+import android.provider.Settings;+import android.view.View;+import android.widget.ImageView;+import android.widget.LinearLayout;+import android.widget.TextView;+import android.widget.Toast;++/**+ * The panel the remote's Settings button opens when {@code settings_key_panel} is on (HomeKeyService):+ * a few glass rows under the Settings pill, over Home or whatever app is playing. Translucent and in a+ * task of its own, so the app behind keeps running and Back returns to it. Pressing Settings again+ * closes the panel.+ */+public final class QuickSettingsActivity extends Activity {++ @Override+ protected void onCreate(Bundle state) {+ super.onCreate(state);+ setContentView(R.layout.activity_quick_settings);+ findViewById(R.id.scrim).setOnClickListener(v -> finish());+ LinearLayout rows = findViewById(R.id.rows);+ addRow(rows, R.drawable.ic_settings, R.string.tv_settings, 0, new Intent(Settings.ACTION_SETTINGS));+ addRow(rows, R.drawable.ic_picture, R.string.quick_picture, 0, new Intent(Settings.ACTION_DISPLAY_SETTINGS));+ addRow(rows, R.drawable.ic_wifi, R.string.quick_network, 0, new Intent(Settings.ACTION_WIFI_SETTINGS));+ addRow(rows, R.drawable.ic_apps, R.string.quick_apps, R.string.quick_apps_hint,+ new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));+ // Through Home, so it rebuilds with the new choices when Launcher settings closes.+ addRow(rows, R.drawable.ic_home_settings, R.string.launcher_settings, 0,+ new Intent(this, MainActivity.class).setAction(MainActivity.ACTION_LAUNCHER_SETTINGS));+ rows.getChildAt(0).requestFocus();+ }++ /** Settings pressed again while the panel is up. */+ @Override+ protected void onNewIntent(Intent intent) {+ super.onNewIntent(intent);+ finish();+ }++ /** Anything else taking the screen (Home, an app, a screensaver) closes the panel. */+ @Override+ protected void onPause() {+ super.onPause();+ finish();+ overridePendingTransition(0, 0);+ }++ private void addRow(LinearLayout rows, int icon, int title, int status, Intent target) {+ View row = getLayoutInflater().inflate(R.layout.item_input, rows, false);+ ((ImageView) row.findViewById(R.id.icon)).setImageResource(icon);+ ((TextView) row.findViewById(R.id.title)).setText(title);+ row.findViewById(R.id.dot).setVisibility(View.GONE);+ TextView hint = row.findViewById(R.id.status);+ if (status != 0) hint.setText(status);+ else hint.setVisibility(View.GONE);+ row.setOnClickListener(v -> {+ try {+ startActivity(target.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));+ } catch (ActivityNotFoundException e) {+ Toast.makeText(this, R.string.not_available, Toast.LENGTH_SHORT).show();+ }+ finish();+ });+ rows.addView(row);+ }+}diff --git a/launcher/app/src/main/res/drawable/ic_apps.xml b/launcher/app/src/main/res/drawable/ic_apps.xmlnew file mode 100644index 000000000..36d9edeb4--- /dev/null+++ b/launcher/app/src/main/res/drawable/ic_apps.xml@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="utf-8"?>+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="22dp" android:height="22dp"+ android:viewportWidth="24" android:viewportHeight="24">+ <path android:fillColor="#FFFFFFFF"+ android:pathData="M4,4h4v4H4zM10,4h4v4h-4zM16,4h4v4h-4zM4,10h4v4H4zM10,10h4v4h-4zM16,10h4v4h-4zM4,16h4v4H4zM10,16h4v4h-4zM16,16h4v4h-4z" />+</vector>diff --git a/launcher/app/src/main/res/drawable/ic_picture.xml b/launcher/app/src/main/res/drawable/ic_picture.xmlnew file mode 100644index 000000000..127bf965e--- /dev/null+++ b/launcher/app/src/main/res/drawable/ic_picture.xml@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="utf-8"?>+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="22dp" android:height="22dp"+ android:viewportWidth="24" android:viewportHeight="24">+ <path android:fillColor="#FFFFFFFF"+ android:pathData="M21,3H3C1.9,3 1,3.9 1,5v12c0,1.1 0.9,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5C23,3.9 22.1,3 21,3zM21,17H3V5h18V17z" />+</vector>diff --git a/launcher/app/src/main/res/layout/activity_quick_settings.xml b/launcher/app/src/main/res/layout/activity_quick_settings.xmlnew file mode 100644index 000000000..e5d10a516--- /dev/null+++ b/launcher/app/src/main/res/layout/activity_quick_settings.xml@@ -0,0 +1,27 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Quick settings opened by the remote's Settings button: the Inputs dropdown's glass panel, placed+ under the Settings pill so it lines up on Home and sits top right over any app. -->+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"+ android:id="@+id/scrim"+ android:layout_width="match_parent"+ android:layout_height="match_parent">++ <LinearLayout+ android:id="@+id/panel"+ android:layout_width="220dp"+ android:layout_height="wrap_content"+ android:layout_gravity="top|end"+ android:layout_marginTop="105dp"+ android:layout_marginEnd="56dp"+ android:orientation="vertical"+ android:background="@drawable/glass_panel"+ android:padding="6dp"+ android:elevation="12dp">++ <LinearLayout+ android:id="@+id/rows"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:orientation="vertical" />+ </LinearLayout>+</FrameLayout>diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xmlindex 11b7e2214..d2336b782 100644--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@ -52,6 +52,10 @@with `tools/tv.py 'logcat -v time -s InputReader:D'` while pressing the button. Leave empty to omit. --><integer-array name="settings_key_keycodes"></integer-array>+ <!-- What those Settings buttons open: false, the TV's Settings; true, a small glass panel at the top right+ with TV settings, Launcher settings, Apps (re-enable an app) and Network, over whatever is on screen.+ Both keys can also be set from a theme's config.json ("settings_key_keycodes": [83]). -->+ <bool name="settings_key_panel">false</bool><!-- Show the Solar Hijri (Shamsi) date used in Iran and Afghanistan, e.g. "27 Mehr 1405", above theGregorian date. -->diff --git a/launcher/app/src/main/res/values/strings.xml b/launcher/app/src/main/res/values/strings.xmlindex 5c7f0e834..1d9082b8e 100644--- a/launcher/app/src/main/res/values/strings.xml+++ b/launcher/app/src/main/res/values/strings.xml@@ -33,6 +33,10 @@<string name="follow_theme">Follow theme (reset on-TV choices)</string><string name="follow_theme_hint">Uses the current theme or built-in layout and motion settings. Pushing or resetting a theme also clears your on-TV choices.</string><string name="tv_settings">TV system settings</string>+ <string name="quick_picture">Picture</string>+ <string name="quick_network">Network</string>+ <string name="quick_apps">Apps</string>+ <string name="quick_apps_hint">Re-enable</string><string name="on">On</string><string name="off">Off</string><string name="enable">Enable</string>diff --git a/themes/README.md b/themes/README.mdindex e9ef44ba4..34b8fc131 100644--- a/themes/README.md+++ b/themes/README.md@@ -42,6 +42,8 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can| `background_color` | `#RRGGBB` | Colour behind everything; black by default || `sky_intensity` | 0 to 100 | Time-of-day backdrop: a dark gradient that follows the clock, 0 hides it (default) || `wallpaper` | bool | Show `wallpaper.jpg` from the theme folder (`true`), or ignore it (`false`) |+| `settings_key_keycodes` | list of keycodes | Remote buttons that open Settings, for `HomeKeyService` (TCL Google TV gear: `[83]`) |+| `settings_key_panel` | bool | Those buttons open a small quick settings panel (TV settings, Picture, Network, Apps, Launcher settings) instead of the TV's Settings |## Wallpapers