Skip to content

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

Launcher: Add to dock works when the app already sits in the free place

Shivamingale38b98e7034c35
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 eda36c898..786b6040b 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -1602,9 +1602,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
adapter.move(pos, slot);
adapter.move(adapter.positionOf(slotKey), pos);
});
- dockInSession.add(adapter.keyAt(slot));
if (pos >= COLUMNS) dockInSession.remove(slotKey);
}
+ // Outside the check: with no empty slots shown, the chosen app may already sit in the free place.
+ dockInSession.add(adapter.keyAt(slot));
endReorder();
refocusAfterLayout(slot);
}
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/DockSlotsTest.java b/launcher/app/src/test/java/com/gathin/tvhome/DockSlotsTest.java
index b66a661c8..b0e50e05a 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/DockSlotsTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/DockSlotsTest.java
@@ -59,6 +59,13 @@ public class DockSlotsTest {
assertEquals(4, DockSlots.dockCount(keys, 4, dock));
}
+ @Test public void anAppChosenForTheFreePlaceItAlreadySitsInJoinsTheDock() {
+ // Reorder mode shows no empty slot, so "my5" sits in the free 4th place; Add to dock chose it for that place.
+ List<String> keys = Arrays.asList("tivimate", "jellyfin", "iplayer", "my5", "vlc");
+ assertEquals(4, DockSlots.dockCount(keys, 4, set("tivimate", "jellyfin", "iplayer", "my5")));
+ assertEquals(0, DockSlots.empty(4, 4, 5, false));
+ }
+
@Test public void fewerTilesThanDockSlotsStillPutTheDockFirst() {
List<String> keys = Arrays.asList("a", "b");
assertEquals(Arrays.asList("b", "a"), DockSlots.dockFirst(keys, 4, set("b")));