Skip to content

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

Inputs menu: size to the widest row; hide HDMI status when every port claims connected

Jatin-LeafLoans1c3daca3ea83
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 0732c3a65..6414beffe 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -412,6 +412,15 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
if (ha != hb) return ha ? -1 : 1;
return String.valueOf(a.loadLabel(this)).compareToIgnoreCase(String.valueOf(b.loadLabel(this)));
});
+ // Some TVs (Sony) report every HDMI port as connected whether or not anything is plugged in,
+ // so drop the HDMI status then. A TV with every port really in use loses it too.
+ int hdmiPorts = 0, hdmiConnected = 0;
+ for (TvInputInfo info : inputs) {
+ if (!info.isPassthroughInput() || info.getType() != TvInputInfo.TYPE_HDMI) continue;
+ hdmiPorts++;
+ if (tim.getInputState(info.getId()) == TvInputManager.INPUT_STATE_CONNECTED) hdmiConnected++;
+ }
+ boolean hdmiStateBogus = hdmiPorts > 1 && hdmiConnected == hdmiPorts;
for (TvInputInfo info : inputs) {
if (!info.isPassthroughInput()) continue;
CharSequence l = info.loadLabel(this);
@@ -419,7 +428,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
boolean hdmi = info.getType() == TvInputInfo.TYPE_HDMI;
if (hdmi && !label.toUpperCase().contains("HDMI")) label = "HDMI " + label;
final String id = info.getId();
- int state = tim.getInputState(id);
+ int state = hdmi && hdmiStateBogus ? -1 : tim.getInputState(id);
if (!hdmi && rows.getChildCount() > 0 && !sawNonHdmi) addSeparator(rows);
if (!hdmi) sawNonHdmi = true;
addInputRow(rows, popup, hdmi ? R.drawable.ic_input : R.drawable.ic_av, label, state,
@@ -437,6 +446,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
return;
}
+ // Fit the widest row: TVs that report a status on every port (Sony) would otherwise squeeze the names out.
+ panel.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
+ popup.setWidth(Math.max(width, panel.getMeasuredWidth()));
+
// Drop in: fade and unfold from the top edge.
panel.setAlpha(0f);
panel.setPivotY(0f);
diff --git a/launcher/app/src/main/res/layout/item_input.xml b/launcher/app/src/main/res/layout/item_input.xml
index 5a519ca49..7de4d65c1 100644
--- a/launcher/app/src/main/res/layout/item_input.xml
+++ b/launcher/app/src/main/res/layout/item_input.xml
@@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="10dp"
- android:layout_marginEnd="4dp"
+ android:layout_marginEnd="12dp"
android:textColor="@drawable/pill_text"
android:duplicateParentState="true"
android:textSize="15sp"