Skip to content

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

launcher: dock band opacity in Launcher settings

quanghm27c135a1bb3268
diff --git a/README.md b/README.md
index e90b28262..3cdc06e79 100644
--- a/README.md
+++ b/README.md
@@ -440,7 +440,7 @@ The **TV** needs Android 8.0 (API 26) or newer: `minSdk` is a compile-time floor
| What | How it works |
|---|---|
| **Configure** | Dock order, hidden apps, Live TV app, 4 to 7 tiles per row, reduced motion. All in [`config.xml`](launcher/app/src/main/res/values/config.xml) |
-| **Settings on the TV** | Hold OK on the Settings pill for Launcher settings: tiles per row, animations, advanced effects |
+| **Settings on the TV** | Hold OK on the Settings pill for Launcher settings: tiles per row, dock band opacity, animations, advanced effects |
| **Themes** | Background, wallpaper and layout from a `config.json` pushed over Wi-Fi, no rebuild. Five ship in [`themes/`](themes/) |
| **24 languages** | Follows the TV's language, with a fully mirrored right-to-left layout for Hebrew |
| **App library** | Optional: browse every installed app and add or remove Home shortcuts. See [the app library guide](docs/app-library.md) |
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index 9fa072656..68b2be577 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -39,6 +39,7 @@ final class Config {
static final String SETTINGS_NAME = "launcher_settings";
static final String ROWS_BELOW_DOCK_KEY = "rows_below_dock";
static final String WALLPAPER_CHOICE_KEY = "wallpaper_choice";
+ static final String DOCK_OPACITY_KEY = "dock_opacity";
private static final String THEME_REVISION_NAME = "theme_revision";
private static final String THEME_SIGNATURE_KEY = "theme_signature";
@@ -391,6 +392,7 @@ final class Config {
int rotationMinutes = json == null ? 0 : integer(json, "wallpaper_rotation_minutes", 0, 0, 1440);
int wallpaperDim = json == null ? 0 : integer(json, "wallpaper_dim", 0, 0, 90);
int dockOpacity = json == null ? 100 : integer(json, "dock_opacity", 100, 30, 100);
+ dockOpacity = chosenDockOpacity(choices.getInt(DOCK_OPACITY_KEY, -1), dockOpacity);
String wallpaperOrder = json == null ? WallpaperRotation.ORDER_SHUFFLE
: string(json, "wallpaper_order", WallpaperRotation.ORDER_SHUFFLE);
// An unknown order must not silently change how an existing collection rotates.
@@ -474,15 +476,21 @@ final class Config {
// explicit theme push or reset by the updated tools.
SharedPreferences.Editor editor = choices.edit();
if (!"absent".equals(token)) editor.remove("columns").remove("animations")
- .remove("advanced_effects").remove(ROWS_BELOW_DOCK_KEY).remove(WALLPAPER_CHOICE_KEY);
+ .remove("advanced_effects").remove(ROWS_BELOW_DOCK_KEY).remove(WALLPAPER_CHOICE_KEY)
+ .remove(DOCK_OPACITY_KEY);
editor.putString(THEME_SIGNATURE_KEY, signature).commit();
} else if (!seen.equals(signature)) {
choices.edit().remove("columns").remove("animations").remove("advanced_effects")
- .remove(ROWS_BELOW_DOCK_KEY).remove(WALLPAPER_CHOICE_KEY)
+ .remove(ROWS_BELOW_DOCK_KEY).remove(WALLPAPER_CHOICE_KEY).remove(DOCK_OPACITY_KEY)
.putString(THEME_SIGNATURE_KEY, signature).commit();
}
}
+ /** The dock band opacity chosen in Launcher settings, or the theme's when none (or an out-of-range one) is saved. */
+ static int chosenDockOpacity(int chosen, int theme) {
+ return chosen >= 30 && chosen <= 100 ? chosen : theme;
+ }
+
private static String fileStamp(File file) {
return file != null && file.isFile() ? file.length() + "@" + file.lastModified() : "absent";
}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
index 925a2a9d6..129a3430c 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
@@ -19,12 +19,15 @@ public final class LauncherSettingsActivity extends Activity {
private SharedPreferences choices;
private final TextView[] columnChoices = new TextView[4];
private final TextView[] rowChoices = new TextView[4];
+ private static final int[] DOCK_OPACITIES = {100, 70, 50, 30};
+ private final TextView[] dockChoices = new TextView[DOCK_OPACITIES.length];
private TextView wallpaperChoice;
private TextView animationsChoice;
private TextView advancedChoice;
private TextView followThemeChoice;
private int columns;
private int rowsBelowDock;
+ private int dockOpacity;
private boolean animations;
private boolean advancedEffects;
@@ -36,6 +39,7 @@ public final class LauncherSettingsActivity extends Activity {
Config config = Config.load(this);
columns = config.columns;
rowsBelowDock = config.rowsBelowDock;
+ dockOpacity = config.dockOpacity;
animations = config.animations;
advancedEffects = config.animations && config.advancedEffects;
@@ -63,11 +67,24 @@ public final class LauncherSettingsActivity extends Activity {
refresh();
});
}
+ int[] dockIds = {R.id.dock100, R.id.dock70, R.id.dock50, R.id.dock30};
+ for (int i = 0; i < dockIds.length; i++) {
+ final int value = DOCK_OPACITIES[i];
+ dockChoices[i] = findViewById(dockIds[i]);
+ dockChoices[i].setOnClickListener(v -> {
+ if (dockOpacity == value) return;
+ dockOpacity = value;
+ choices.edit().putInt(Config.DOCK_OPACITY_KEY, value).apply();
+ setResult(RESULT_OK);
+ refresh();
+ });
+ }
// Keep the numeric choices increasing in the Hebrew reading direction. Reorder the
// actual views so D-pad focus follows their positions without changing the saved values.
if (getResources().getBoolean(R.bool.rtl_app_grid)) {
reverseRow(columnChoices);
reverseRow(rowChoices);
+ reverseRow(dockChoices);
}
wallpaperChoice = findViewById(R.id.wallpaperChoice);
wallpaperChoice.setOnClickListener(v -> showWallpaperPicker());
@@ -97,10 +114,12 @@ public final class LauncherSettingsActivity extends Activity {
followThemeChoice.setOnClickListener(v -> {
if (!hasOnTvChoices()) return;
choices.edit().remove("columns").remove(Config.ROWS_BELOW_DOCK_KEY).remove("animations")
- .remove("advanced_effects").remove(Config.WALLPAPER_CHOICE_KEY).commit();
+ .remove("advanced_effects").remove(Config.WALLPAPER_CHOICE_KEY)
+ .remove(Config.DOCK_OPACITY_KEY).commit();
Config current = Config.load(this);
columns = current.columns;
rowsBelowDock = current.rowsBelowDock;
+ dockOpacity = current.dockOpacity;
animations = current.animations;
advancedEffects = current.animations && current.advancedEffects;
setResult(RESULT_OK);
@@ -180,6 +199,9 @@ public final class LauncherSettingsActivity extends Activity {
for (int i = 0; i < rowChoices.length; i++) {
rowChoices[i].setSelected(rowsBelowDock == i);
}
+ for (int i = 0; i < dockChoices.length; i++) {
+ dockChoices[i].setSelected(dockOpacity == DOCK_OPACITIES[i]);
+ }
animationsChoice.setText(getString(R.string.animations_state,
getString(animations ? R.string.on : R.string.off)));
advancedChoice.setText(getString(R.string.advanced_effects_state,
@@ -197,7 +219,7 @@ public final class LauncherSettingsActivity extends Activity {
private boolean hasOnTvChoices() {
return choices.contains("columns") || choices.contains(Config.ROWS_BELOW_DOCK_KEY)
|| choices.contains("animations") || choices.contains("advanced_effects")
- || choices.contains(Config.WALLPAPER_CHOICE_KEY);
+ || choices.contains(Config.WALLPAPER_CHOICE_KEY) || choices.contains(Config.DOCK_OPACITY_KEY);
}
private void open(Intent intent) {
diff --git a/launcher/app/src/main/res/layout/activity_launcher_settings.xml b/launcher/app/src/main/res/layout/activity_launcher_settings.xml
index 2a598211d..4aaba26e4 100644
--- a/launcher/app/src/main/res/layout/activity_launcher_settings.xml
+++ b/launcher/app/src/main/res/layout/activity_launcher_settings.xml
@@ -61,6 +61,26 @@
<TextView android:id="@+id/rows3" style="@style/SettingsColumnChoice" android:text="3" />
</LinearLayout>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="18dp"
+ android:text="@string/dock_opacity_label"
+ android:textColor="#FFFFFFFF"
+ android:textSize="20sp" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:orientation="horizontal">
+
+ <TextView android:id="@+id/dock100" style="@style/SettingsColumnChoice" android:text="100%" />
+ <TextView android:id="@+id/dock70" style="@style/SettingsColumnChoice" android:text="70%" />
+ <TextView android:id="@+id/dock50" style="@style/SettingsColumnChoice" android:text="50%" />
+ <TextView android:id="@+id/dock30" style="@style/SettingsColumnChoice" android:text="30%" />
+ </LinearLayout>
+
<TextView
android:id="@+id/wallpaperChoice"
style="@style/SettingsRow"
diff --git a/launcher/app/src/main/res/values-vi/strings.xml b/launcher/app/src/main/res/values-vi/strings.xml
index c36910cc6..ffb55f2a7 100644
--- a/launcher/app/src/main/res/values-vi/strings.xml
+++ b/launcher/app/src/main/res/values-vi/strings.xml
@@ -28,6 +28,7 @@
<string name="home_settings_help">Chọn màn hình chính gốc để thôi dùng CleanYourTV, hoặc chọn CleanYourTV để dùng lại. Launcher gốc phải đang bật và TV phải có mục chọn màn hình chính; nếu launcher gốc đã bị tắt, hãy chạy script khôi phục trước.</string>
<string name="launcher_settings">Cài đặt launcher</string>
<string name="columns_label">Số ứng dụng mỗi hàng</string>
+ <string name="dock_opacity_label">Độ đậm của thanh dock</string>
<string name="animations_state">Hiệu ứng: %1$s</string>
<string name="advanced_effects">Hiệu ứng nâng cao</string>
<string name="advanced_effects_state">Hiệu ứng nâng cao: %1$s</string>
diff --git a/launcher/app/src/main/res/values/strings.xml b/launcher/app/src/main/res/values/strings.xml
index 04ee1dccf..1a385d403 100644
--- a/launcher/app/src/main/res/values/strings.xml
+++ b/launcher/app/src/main/res/values/strings.xml
@@ -48,6 +48,7 @@
<string name="launcher_settings">Launcher settings</string>
<string name="columns_label">Apps per row</string>
<string name="rows_below_dock_label">Rows below dock</string>
+ <string name="dock_opacity_label">Dock band opacity</string>
<string name="wallpaper_label">Wallpaper</string>
<string name="wallpaper_state">Wallpaper: %1$s</string>
<string name="wallpaper_none">None</string>
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/DockOpacityTest.java b/launcher/app/src/test/java/com/gathin/tvhome/DockOpacityTest.java
new file mode 100644
index 000000000..07db364dc
--- /dev/null
+++ b/launcher/app/src/test/java/com/gathin/tvhome/DockOpacityTest.java
@@ -0,0 +1,25 @@
+package com.gathin.tvhome;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DockOpacityTest {
+ @Test public void aChoiceMadeOnTheTvWinsOverTheTheme() {
+ // Theme says 80, the owner picked 30 in Launcher settings.
+ assertEquals(30, Config.chosenDockOpacity(30, 80));
+ assertEquals(100, Config.chosenDockOpacity(100, 80));
+ }
+
+ @Test public void noChoiceKeepsTheThemeValue() {
+ // -1 is what Config passes when nothing is saved (or a theme push cleared it).
+ assertEquals(80, Config.chosenDockOpacity(-1, 80));
+ }
+
+ @Test public void anOutOfRangeChoiceIsIgnored() {
+ // Below 30 the band would vanish and the dock lose its shape; the theme key has the same floor.
+ assertEquals(80, Config.chosenDockOpacity(0, 80));
+ assertEquals(80, Config.chosenDockOpacity(29, 80));
+ assertEquals(80, Config.chosenDockOpacity(101, 80));
+ }
+}
diff --git a/themes/README.md b/themes/README.md
index 9c1c549bf..d14b542f5 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -76,7 +76,7 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `wallpaper_rotation_minutes` | 0 to 1440 | Rotate images in the theme's `wallpapers/` folder at this interval; 0 keeps the single-image behaviour. A negative or non-numeric value is ignored, and 0 means "no rotation", not "every minute" |
| `wallpaper_order` | `shuffle` or `sequential` | How a collection advances. `shuffle` (the default, and what launchers did before this key existed) avoids repeating the current picture; `sequential` walks the folder in filename order and wraps at the end. An unknown value falls back to `shuffle` |
| `wallpaper_dim` | 0 to 90 | Black overlay over wallpaper images, in percent; 0 by default and no shade view at all |
-| `dock_opacity` | 30 to 100 | Opacity of the dock's band, in percent, so a wallpaper shows through it; 100 by default (the cinematic shelf keeps its own translucent band) |
+| `dock_opacity` | 30 to 100 | Opacity of the dock's band, in percent, so a wallpaper shows through it; 100 by default (the cinematic shelf keeps its own translucent band). Launcher settings on the TV offers 100, 70, 50 or 30, which wins until the next theme push or Follow theme |
| `wallpaper_captions` | bool | With a rotating collection, the shown picture's name under the top-right buttons, from `wallpapers/captions.txt` (`001.jpg<TAB>Dusk over the peaks`, one per line); a picture without a line shows no name (`false` by default) |
| `festival` | string | Turns on a festive skin: the network pill becomes a diya whose flame follows the connection, Inputs a temple bell, Settings a marigold, and the first Home of the day gets a petal shower. `dussehra` and `diwali` have built-in greetings |
| `festival_until` | `YYYY-MM-DD` | Last day the festive skin shows; it switches itself off after that. A malformed date turns it off |