Skip to content

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

Launcher: the focus glow stays level with a dock tile under advanced_effects (#2428)

10k11aeb23bec03b8
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
index 4cf0143bf..3c6a51cce 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -476,7 +476,7 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
h.name.setText(e.name);
// The dock has no labels, unless always_show_names asks for them (DockDecoration then makes room in the band).
// In a single row every tile is the dock's kind: the big title above names it.
- boolean dockKind = dockRow && (singleRow || position < dockSize);
+ boolean dockKind = DockSlots.inDockRow(dockRow, singleRow, position, dockSize);
h.name.setVisibility(dockKind && restNameAlpha == 0f ? View.INVISIBLE : View.VISIBLE);
h.inDock = dockKind;
boolean focused = h.card.isFocused(); // a rebind after reload() can hit the focused tile
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/DockSlots.java b/launcher/app/src/main/java/com/gathin/tvhome/DockSlots.java
index ab92c352f..303a61e55 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/DockSlots.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/DockSlots.java
@@ -45,6 +45,11 @@ final class DockSlots {
return n;
}
+ /** Whether a tile sits in the dock row: every tile of a single row, else the first `dockSize` of the grid. */
+ static boolean inDockRow(boolean dockRow, boolean singleRow, int position, int dockSize) {
+ return dockRow && (singleRow || position < dockSize);
+ }
+
/** A position focus can land on: an empty slot sends it to the last dock app. */
static int focusable(int position, int docked, int empty) {
return empty > 0 && position >= docked && position < docked + empty ? docked - 1 : position;
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 a68495feb..142e86d58 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -1721,7 +1721,9 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
float w = card.getWidth() * scale + 2 * pad;
float h = card.getHeight() * scale + 2 * pad;
float x = r.exactCenterX() - w / 2f;
- float y = r.exactCenterY() - h / 2f - (advancedEffects ? 4f * density : 0f);
+ // advanced_effects lifts a focused grid tile by 4dp and the glass follows it; dock tiles stay put (#2135).
+ boolean lifted = advancedEffects && !DockSlots.inDockRow(dockRow, singleRow, position, COLUMNS);
+ float y = r.exactCenterY() - h / 2f - (lifted ? 4f * density : 0f);
ViewGroup.LayoutParams lp = glass.getLayoutParams();
if (lp.width != (int) w || lp.height != (int) h || card.getWidth() != glassCardW) {
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 8aad7ba4c..b66a661c8 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/DockSlotsTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/DockSlotsTest.java
@@ -8,8 +8,20 @@ import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class DockSlotsTest {
+ @Test public void dockRowIsTheFirstColumnsTilesOrEveryTileOfASingleRow() {
+ // #2428: the glass stays level with a dock tile, which advanced_effects no longer lifts.
+ assertTrue(DockSlots.inDockRow(true, false, 0, 6));
+ assertTrue(DockSlots.inDockRow(true, false, 5, 6));
+ assertFalse(DockSlots.inDockRow(true, false, 6, 6));
+ assertTrue(DockSlots.inDockRow(true, true, 40, 6));
+ assertFalse(DockSlots.inDockRow(false, false, 0, 6));
+ assertFalse(DockSlots.inDockRow(false, true, 0, 6));
+ }
+
private static Set<String> set(String... keys) {
return new HashSet<>(Arrays.asList(keys));
}