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: tidy Philips "Name&TYPE" input labels, hide "null"
geryc492a229e4d2
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/InputNames.java b/launcher/app/src/main/java/com/gathin/tvhome/InputNames.javanew file mode 100644index 000000000..4091ef2c5--- /dev/null+++ b/launcher/app/src/main/java/com/gathin/tvhome/InputNames.java@@ -0,0 +1,38 @@+package com.gathin.tvhome;++import java.util.Locale;++/**+ * Philips (TP Vision) saves an input's name from its Sources menu as "Name&TYPE", the type picking the icon there+ * ("Xbox&GAME_CONSOLE", "Ordinateur&COMPUTER"), and an unnamed port as the text "null". Shown as is, the Inputs+ * menu read "Xbox&GAME_CONSOLE · HDMI 1" and "null · HDMI 4". This gives "🎮 Xbox" and no name; the TV's own+ * setting is left as it is.+ */+final class InputNames {+ private InputNames() {+ }++ static String tidy(CharSequence raw) {+ if (raw == null) return null;+ String s = raw.toString().trim();+ if (s.isEmpty() || s.equals("null")) return null;+ int amp = s.lastIndexOf('&');+ // Only a type in Philips' form (three or more capitals, digits or underscores) is taken off, so "Tom & Jerry" stays.+ if (amp < 0 || !s.substring(amp + 1).matches("[A-Z][A-Z0-9_]{2,}")) return s;+ String name = s.substring(0, amp).trim();+ String emoji = emoji(s.substring(amp + 1));+ if (name.isEmpty()) return emoji;+ return emoji == null ? name : emoji + " " + name;+ }++ private static String emoji(String type) {+ String t = type.toUpperCase(Locale.ROOT);+ if (t.contains("GAME")) return "🎮"; // 🎮+ if (t.contains("COMPUTER") || t.equals("PC")) return "💻"; // 💻+ if (t.contains("BLU") || t.contains("DVD") || t.contains("DISC")) return "📀"; // 📀+ if (t.contains("BOX") || t.contains("STB") || t.contains("SAT") || t.contains("CABLE")) return "📡"; // 📡+ if (t.contains("AUDIO") || t.contains("SOUND") || t.contains("AMP")) return "🔊"; // 🔊+ if (t.contains("CAM")) return "📷"; // 📷+ return null;+ }+}diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.javaindex d992768a0..c4183a74c 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@ -2957,7 +2957,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {String label = l == null ? info.getId() : l.toString();boolean hdmi = info.getType() == TvInputInfo.TYPE_HDMI;if (hdmi && !label.toUpperCase(Locale.ROOT).contains("HDMI")) label = "HDMI " + label;- CharSequence custom = info.loadCustomLabel(this);+ CharSequence custom = InputNames.tidy(info.loadCustomLabel(this));boolean named = custom != null && custom.length() > 0 && !custom.toString().equals(label);if (!hdmi && rows.getChildCount() > 0 && !sawNonHdmi) addSeparator(rows);if (!hdmi) sawNonHdmi = true;@@ -2967,7 +2967,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {// Settings > Inputs), then the port. Opening the device's input also makes it the CEC// active source, which wakes it.for (TvInputInfo device : devices) {- CharSequence name = device.loadCustomLabel(this);+ CharSequence name = InputNames.tidy(device.loadCustomLabel(this));if (name == null || name.length() == 0) name = named ? custom : device.loadLabel(this);String deviceLabel = name == null || name.length() == 0 ? label : name + " \u00B7 " + label;final String deviceId = device.getId();diff --git a/launcher/app/src/test/java/com/gathin/tvhome/InputNamesTest.java b/launcher/app/src/test/java/com/gathin/tvhome/InputNamesTest.javanew file mode 100644index 000000000..3c96ab1d7--- /dev/null+++ b/launcher/app/src/test/java/com/gathin/tvhome/InputNamesTest.java@@ -0,0 +1,35 @@+package com.gathin.tvhome;++import org.junit.Test;++import static org.junit.Assert.assertEquals;+import static org.junit.Assert.assertNull;++public class InputNamesTest {+ @Test public void philipsTypeBecomesAnEmoji() {+ assertEquals("🎮 Xbox", InputNames.tidy("Xbox&GAME_CONSOLE"));+ assertEquals("🎮 Switch", InputNames.tidy("Switch &GAME_CONSOLE"));+ assertEquals("💻 Ordinateur", InputNames.tidy("Ordinateur&COMPUTER"));+ }++ @Test public void anUnknownTypeLeavesTheNameAlone() {+ assertEquals("Box", InputNames.tidy("Box&SOMETHING_NEW"));+ }++ @Test public void aTypeWithNoNameIsJustItsEmoji() {+ assertEquals("🎮", InputNames.tidy("&GAME_CONSOLE"));+ }++ @Test public void theTextNullAndBlanksAreNoName() {+ assertNull(InputNames.tidy("null"));+ assertNull(InputNames.tidy(" "));+ assertNull(InputNames.tidy(null));+ }++ @Test public void otherNamesAreKept() {+ assertEquals("MacBook Pro", InputNames.tidy("MacBook Pro"));+ assertEquals("Tom & Jerry", InputNames.tidy("Tom & Jerry"));+ assertEquals("AT&T", InputNames.tidy("AT&T"));+ assertEquals("R&D", InputNames.tidy("R&D"));+ }+}