Skip to content

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

Merge PR #382: On-TV wallpaper picker from the theme wallpapers/ collection

Gathin233855b48bd186
diff --cc launcher/app/src/main/java/com/gathin/tvhome/Config.java
index 0d1a3f208,2b143dcd8..69b6eebd8
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@@ -34,7 -32,7 +34,8 @@@ final class Config
static final String FILE_NAME = "config.json";
static final String WALLPAPER_NAME = "wallpaper.jpg";
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";
private static final String THEME_REVISION_NAME = "theme_revision";
private static final String THEME_SIGNATURE_KEY = "theme_signature";
@@@ -275,11 -272,12 +295,12 @@@
// 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("advanced_effects").remove(WALLPAPER_CHOICE_KEY);
++ .remove("advanced_effects").remove(ROWS_BELOW_DOCK_KEY).remove(WALLPAPER_CHOICE_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).putString(THEME_SIGNATURE_KEY, signature).commit();
- .remove(WALLPAPER_CHOICE_KEY)
++ .remove(ROWS_BELOW_DOCK_KEY).remove(WALLPAPER_CHOICE_KEY)
+ .putString(THEME_SIGNATURE_KEY, signature).commit();
}
}
diff --cc launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
index 3cdc88446,a573cbc3b..b48bc9e49
--- a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
@@@ -15,7 -18,7 +18,8 @@@ import java.util.List
public final class LauncherSettingsActivity extends Activity {
private SharedPreferences choices;
private final TextView[] columnChoices = new TextView[4];
+ private final TextView[] rowChoices = new TextView[4];
+ private TextView wallpaperChoice;
private TextView animationsChoice;
private TextView advancedChoice;
private TextView followThemeChoice;
@@@ -62,9 -51,12 +66,11 @@@
// 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)) {
- LinearLayout row = (LinearLayout) columnChoices[0].getParent();
- row.removeAllViews();
- for (int i = columnChoices.length - 1; i >= 0; i--) row.addView(columnChoices[i]);
+ reverseRow(columnChoices);
+ reverseRow(rowChoices);
}
+ wallpaperChoice = findViewById(R.id.wallpaperChoice);
+ wallpaperChoice.setOnClickListener(v -> showWallpaperPicker());
animationsChoice = findViewById(R.id.animationsChoice);
animationsChoice.setOnClickListener(v -> {
animations = !animations;
@@@ -90,10 -82,10 +96,11 @@@
followThemeChoice = findViewById(R.id.followThemeChoice);
followThemeChoice.setOnClickListener(v -> {
if (!hasOnTvChoices()) return;
- choices.edit().remove("columns").remove(Config.ROWS_BELOW_DOCK_KEY).remove("animations").remove("advanced_effects").commit();
- choices.edit().remove("columns").remove("animations").remove("advanced_effects")
- .remove(Config.WALLPAPER_CHOICE_KEY).commit();
++ choices.edit().remove("columns").remove(Config.ROWS_BELOW_DOCK_KEY).remove("animations")
++ .remove("advanced_effects").remove(Config.WALLPAPER_CHOICE_KEY).commit();
Config current = Config.load(this);
columns = current.columns;
+ rowsBelowDock = current.rowsBelowDock;
animations = current.animations;
advancedEffects = current.animations && current.advancedEffects;
setResult(RESULT_OK);
@@@ -109,12 -101,47 +116,56 @@@
columnChoices[Math.max(0, Math.min(columns - 4, 3))].requestFocus();
}
+ private void reverseRow(TextView[] views) {
+ LinearLayout row = (LinearLayout) views[0].getParent();
+ row.removeAllViews();
+ for (int i = views.length - 1; i >= 0; i--) row.addView(views[i]);
+ }
+
+ private void showWallpaperPicker() {
+ File dir = Config.dir(this);
- List<File> images = WallpaperRotation.images(
- dir == null ? null : new File(dir, "wallpapers"));
++ List<File> images = new java.util.ArrayList<>(WallpaperRotation.images(
++ dir == null ? null : new File(dir, "wallpapers")));
++ // A theme with a single wallpaper.jpg offers that picture too (Config maps the choice back to it).
++ File single = dir == null ? null : new File(dir, Config.WALLPAPER_NAME);
++ if (single != null && single.isFile()) images.add(0, single);
+ String[] labels = new String[images.size() + 1];
+ for (int i = 0; i < images.size(); i++) labels[i] = images.get(i).getName();
+ labels[images.size()] = getString(R.string.wallpaper_none);
+ String current = choices.getString(Config.WALLPAPER_CHOICE_KEY, null);
+ int checked = "none".equals(current) ? images.size()
+ : indexOf(images, current);
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.wallpaper_label)
+ .setSingleChoiceItems(labels, checked, (dialog, which) -> {
+ dialog.dismiss();
+ if (which == images.size()) {
+ choices.edit().putString(Config.WALLPAPER_CHOICE_KEY, "none").apply();
+ } else {
+ choices.edit().putString(Config.WALLPAPER_CHOICE_KEY,
+ images.get(which).getName()).apply();
+ }
+ setResult(RESULT_OK);
+ Toast.makeText(this, R.string.wallpaper_applied, Toast.LENGTH_SHORT).show();
+ refresh();
+ })
+ .setNeutralButton(R.string.wallpaper_theme_default, (dialog, which) -> {
+ choices.edit().remove(Config.WALLPAPER_CHOICE_KEY).apply();
+ setResult(RESULT_OK);
+ refresh();
+ })
+ .setNegativeButton(android.R.string.cancel, null)
+ .show();
+ }
+
+ private static int indexOf(List<File> images, String name) {
+ if (name == null) return -1;
+ for (int i = 0; i < images.size(); i++) {
+ if (images.get(i).getName().equals(name)) return i;
+ }
+ return -1;
+ }
+
private void setAdvanced(boolean enabled) {
advancedEffects = enabled;
choices.edit().putBoolean("advanced_effects", enabled).apply();
@@@ -139,8 -168,9 +195,9 @@@
}
private boolean hasOnTvChoices() {
- return choices.contains("columns") || choices.contains("animations")
- || choices.contains("advanced_effects")
+ return choices.contains("columns") || choices.contains(Config.ROWS_BELOW_DOCK_KEY)
- || choices.contains("animations") || choices.contains("advanced_effects");
++ || choices.contains("animations") || choices.contains("advanced_effects")
+ || choices.contains(Config.WALLPAPER_CHOICE_KEY);
}
private void open(Intent intent) {
diff --cc launcher/app/src/main/res/layout/activity_launcher_settings.xml
index 9390cc09b,063d27b28..2a598211d
--- a/launcher/app/src/main/res/layout/activity_launcher_settings.xml
+++ b/launcher/app/src/main/res/layout/activity_launcher_settings.xml
@@@ -41,26 -41,11 +41,31 @@@
<TextView android:id="@+id/columns7" style="@style/SettingsColumnChoice" android:text="7" />
</LinearLayout>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="18dp"
+ android:text="@string/rows_below_dock_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/rows0" style="@style/SettingsColumnChoice" android:text="0" />
+ <TextView android:id="@+id/rows1" style="@style/SettingsColumnChoice" android:text="1" />
+ <TextView android:id="@+id/rows2" style="@style/SettingsColumnChoice" android:text="2" />
+ <TextView android:id="@+id/rows3" style="@style/SettingsColumnChoice" android:text="3" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/wallpaperChoice"
+ style="@style/SettingsRow"
+ android:layout_marginTop="28dp" />
+
<TextView
android:id="@+id/animationsChoice"
style="@style/SettingsRow"
diff --cc launcher/app/src/main/res/values-iw/strings.xml
index 77054223e,b8d042705..c075b5f83
--- a/launcher/app/src/main/res/values-iw/strings.xml
+++ b/launcher/app/src/main/res/values-iw/strings.xml
@@@ -88,5 -88,9 +88,10 @@@
<item quantity="other">%1$d אפליקציות</item>
</plurals>
<string name="greeting_with_name">%1$s, %2$s</string>
+ <string name="rows_below_dock_label">שורות מתחת לעגינה</string>
+ <string name="wallpaper_label">טפט</string>
+ <string name="wallpaper_state">טפט: %1$s</string>
+ <string name="wallpaper_none">ללא</string>
+ <string name="wallpaper_applied">הטפט שונה</string>
+ <string name="wallpaper_theme_default">ברירת המחדל של ערכת הנושא</string>
</resources>
diff --cc launcher/app/src/main/res/values/strings.xml
index a13d84743,c55773db2..42873213b
--- a/launcher/app/src/main/res/values/strings.xml
+++ b/launcher/app/src/main/res/values/strings.xml
@@@ -31,7 -31,11 +31,12 @@@
<string name="home_settings_help">Select your original home to stop using CleanYourTV as Home, or CleanYourTV to switch back. The original launcher must be enabled and your TV must provide a home picker; use the restore script first if it was disabled.</string>
<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="wallpaper_label">Wallpaper</string>
+ <string name="wallpaper_state">Wallpaper: %1$s</string>
+ <string name="wallpaper_none">None</string>
+ <string name="wallpaper_applied">Wallpaper changed</string>
+ <string name="wallpaper_theme_default">Theme default</string>
<string name="animations_state">Animations: %1$s</string>
<string name="advanced_effects">Advanced effects</string>
<string name="advanced_effects_state">Advanced effects: %1$s</string>
diff --cc themes/README.md
index bd7791407,f81ca920c..c579ca5a4
--- a/themes/README.md
+++ b/themes/README.md
@@@ -91,6 -87,6 +91,10 @@@ another app, an overdue background chan
to the screen size. There is no download service, Internet permission or computer-side scheduler.
The original system idle screensaver is left unchanged.
++On the TV, Launcher settings has a Wallpaper row: pick one picture from the collection (or the theme's
++`wallpaper.jpg`), or None. A pick shows that one picture and stops the rotation until you choose Theme
++default, press Follow theme, or push a theme again.
++
## Reduced motion
`"reduced_motion": true` keeps the look but calms the movement: the highlight spring is stiff instead