Skip to content

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

On-TV rows-below-dock chips in Launcher settings

PatrickNoFilter2452dc721ec1
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 96f18aae5..e352e0ff9 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -32,6 +32,7 @@ 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";
private static final String THEME_REVISION_NAME = "theme_revision";
private static final String THEME_SIGNATURE_KEY = "theme_signature";
@@ -216,6 +217,8 @@ final class Config {
syncThemeChoices(choices, dir, file);
int chosenColumns = choices.getInt("columns", columns);
if (chosenColumns >= 4 && chosenColumns <= 7) columns = chosenColumns;
+ int chosenRows = choices.getInt(ROWS_BELOW_DOCK_KEY, rowsBelow);
+ if (chosenRows >= 0 && chosenRows <= 3) rowsBelow = chosenRows;
animations = choices.getBoolean("animations", animations);
advancedEffects = choices.getBoolean("advanced_effects", advancedEffects);
File wallpaper = dir != null ? new File(dir, WALLPAPER_NAME) : null;
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 fe5b5e504..3cdc88446 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
@@ -15,10 +15,12 @@ import android.widget.Toast;
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 animationsChoice;
private TextView advancedChoice;
private TextView followThemeChoice;
private int columns;
+ private int rowsBelowDock;
private boolean animations;
private boolean advancedEffects;
@@ -29,6 +31,7 @@ public final class LauncherSettingsActivity extends Activity {
choices = getSharedPreferences(Config.SETTINGS_NAME, MODE_PRIVATE);
Config config = Config.load(this);
columns = config.columns;
+ rowsBelowDock = config.rowsBelowDock;
animations = config.animations;
advancedEffects = config.animations && config.advancedEffects;
@@ -44,12 +47,23 @@ public final class LauncherSettingsActivity extends Activity {
refresh();
});
}
+ int[] rowIds = {R.id.rows0, R.id.rows1, R.id.rows2, R.id.rows3};
+ for (int i = 0; i < rowIds.length; i++) {
+ final int value = i;
+ rowChoices[i] = findViewById(rowIds[i]);
+ rowChoices[i].setOnClickListener(v -> {
+ if (rowsBelowDock == value) return;
+ rowsBelowDock = value;
+ choices.edit().putInt(Config.ROWS_BELOW_DOCK_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)) {
- 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);
}
animationsChoice = findViewById(R.id.animationsChoice);
animationsChoice.setOnClickListener(v -> {
@@ -76,9 +90,10 @@ public final class LauncherSettingsActivity extends Activity {
followThemeChoice = findViewById(R.id.followThemeChoice);
followThemeChoice.setOnClickListener(v -> {
if (!hasOnTvChoices()) return;
- choices.edit().remove("columns").remove("animations").remove("advanced_effects").commit();
+ choices.edit().remove("columns").remove(Config.ROWS_BELOW_DOCK_KEY).remove("animations").remove("advanced_effects").commit();
Config current = Config.load(this);
columns = current.columns;
+ rowsBelowDock = current.rowsBelowDock;
animations = current.animations;
advancedEffects = current.animations && current.advancedEffects;
setResult(RESULT_OK);
@@ -94,6 +109,12 @@ public final class LauncherSettingsActivity extends Activity {
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 setAdvanced(boolean enabled) {
advancedEffects = enabled;
choices.edit().putBoolean("advanced_effects", enabled).apply();
@@ -105,6 +126,9 @@ public final class LauncherSettingsActivity extends Activity {
for (int i = 0; i < columnChoices.length; i++) {
columnChoices[i].setSelected(columns == i + 4);
}
+ for (int i = 0; i < rowChoices.length; i++) {
+ rowChoices[i].setSelected(rowsBelowDock == i);
+ }
animationsChoice.setText(getString(R.string.animations_state,
getString(animations ? R.string.on : R.string.off)));
advancedChoice.setText(getString(R.string.advanced_effects_state,
@@ -115,8 +139,8 @@ public final class LauncherSettingsActivity extends Activity {
}
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");
}
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 b78da53aa..9390cc09b 100644
--- a/launcher/app/src/main/res/layout/activity_launcher_settings.xml
+++ b/launcher/app/src/main/res/layout/activity_launcher_settings.xml
@@ -41,6 +41,26 @@
<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/animationsChoice"
style="@style/SettingsRow"
diff --git a/launcher/app/src/main/res/values-iw/strings.xml b/launcher/app/src/main/res/values-iw/strings.xml
index 82e6ddd43..77054223e 100644
--- a/launcher/app/src/main/res/values-iw/strings.xml
+++ b/launcher/app/src/main/res/values-iw/strings.xml
@@ -88,4 +88,5 @@
<item quantity="other">%1$d אפליקציות</item>
</plurals>
<string name="greeting_with_name">%1$s, %2$s</string>
+ <string name="rows_below_dock_label">שורות מתחת לעגינה</string>
</resources>
diff --git a/launcher/app/src/main/res/values/strings.xml b/launcher/app/src/main/res/values/strings.xml
index 454dba403..a13d84743 100644
--- a/launcher/app/src/main/res/values/strings.xml
+++ b/launcher/app/src/main/res/values/strings.xml
@@ -31,6 +31,7 @@
<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="animations_state">Animations: %1$s</string>
<string name="advanced_effects">Advanced effects</string>
<string name="advanced_effects_state">Advanced effects: %1$s</string>