Skip to content

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

Add on-TV layout and motion settings

roninriddle95810a08da87
diff --git a/README.md b/README.md
index d49efe57e..d89cd3ded 100644
--- a/README.md
+++ b/README.md
@@ -168,6 +168,8 @@ network, no background services. It needs JDK 17 and Android SDK platform 34 to
`brew install openjdk@17 android-commandlinetools` and `sdkmanager "platforms;android-34" "build-tools;34.0.0"`.
- **Configure** in [`config.xml`](launcher/app/src/main/res/values/config.xml): dock order, hidden apps, the Live TV package, columns (tiles shrink from 5 up), rows under the dock, an optional VPN app for the network pill.
+- **On-TV launcher settings:** press Settings to choose 4, 5, 6 or 7 apps per row, turn animations on or off, and opt into advanced effects. The advanced option adds tile lift, icon zoom and smooth ambient-colour transitions; it may use more memory, depending on the TV. Choices stay on this TV and override the built-in config and pushed themes. TV system settings remain available from this screen.
+- **Change the default home:** Launcher Settings opens Android's home picker; choose the original launcher to stop using CleanYourTV as Home, or choose CleanYourTV to return. The original launcher must still be enabled. If the install script disabled it, use the restore script below first. Some TVs provide no home picker, so the setting reports that limitation.
- **Themes** set the same keys plus a background colour and a wallpaper from a `config.json` pushed to the TV, no rebuild. Three ship in [`themes/`](themes/), documented there.
- **Language** follows the TV: English, German, Spanish, Catalan, French, Russian, Simplified Chinese, Thai. Android 13+ can set it for the launcher alone: `tools/tv.py 'cmd locale set-app-locales com.gathin.tvhome --locales ca'`.
- **Module cards** let any TV app declare its own tile (label, caption, glow). The launcher asks you once per app, Keep hidden by default, and remembers the answer for that app's signing key and card name. Hold OK on Settings to change your mind. How to make one: [`docs/modules.md`](docs/modules.md); the contract: [`docs/specs/card.md`](docs/specs/card.md).
diff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xml
index 51bc9fa13..8fa874ee8 100644
--- a/launcher/app/src/main/AndroidManifest.xml
+++ b/launcher/app/src/main/AndroidManifest.xml
@@ -54,11 +54,10 @@
</activity>
<activity
- android:name=".HomeSettingsActivity"
+ android:name=".LauncherSettingsActivity"
android:exported="false"
- android:taskAffinity=""
android:excludeFromRecents="true"
- android:theme="@android:style/Theme.NoDisplay" />
+ android:screenOrientation="landscape" />
<!-- Home button for remotes that send KEYCODE_ALL_APPS (Xiaomi). Opt-in: HOME_KEY_SERVICE=1
build-and-install.sh; see HomeKeyService. -->
<service
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 489e74250..e437be4d7 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -1,5 +1,6 @@
package com.gathin.tvhome;
+import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -50,7 +51,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
}
static final class Entry {
- static final int APP = 0, HOME_SETTINGS = 1, CARD = 2;
+ static final int APP = 0, CARD = 2;
final int kind;
final String label;
@@ -79,7 +80,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
}
}
- static final float FOCUS_SCALE = 1.10f;
+ static final float FOCUS_SCALE = 1.12f;
/** Design size of a tile (dp); tiles shrink from here when the columns don't fit, see tileWidthPx. */
static final float DESIGN_W_DP = 180f, DESIGN_H_DP = 101f;
@@ -111,7 +112,8 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
private final List<String> favourites;
/** Never shown as tiles (res/values/config.xml, hidden_apps). */
private final Set<String> hidden;
- private final boolean showHomeSettings;
+ private final boolean animations;
+ private final boolean advancedEffects;
private final List<Entry> items = new ArrayList<>();
AppAdapter(Context ctx, TileListener listener, int dockSize, Config cfg) {
@@ -120,7 +122,8 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
this.dockSize = dockSize;
this.favourites = cfg.dockApps;
this.hidden = new HashSet<>(cfg.hiddenApps);
- this.showHomeSettings = cfg.showHomeSettingsShortcut;
+ this.animations = cfg.animations;
+ this.advancedEffects = cfg.animations && cfg.advancedEffects;
// Tiles keep their identity across reload(), so a focused tile stays on its app instead of
// its view being rebound to whatever app now sits in that slot.
setHasStableIds(true);
@@ -165,13 +168,6 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
if (ca != cb) return ca ? -1 : 1;
return a.label.compareToIgnoreCase(b.label);
});
- // Optional "Default home" tile (config.xml), only when this TV actually has a home-screen picker.
- if (showHomeSettings
- && pm.resolveActivity(new Intent(Settings.ACTION_HOME_SETTINGS), 0) != null) {
- fresh.add(new Entry(Entry.HOME_SETTINGS, ctx.getString(R.string.home_settings),
- new ComponentName(ctx, HomeSettingsActivity.class), null,
- ctx.getDrawable(R.drawable.ic_home_settings), null, 0));
- }
items.clear();
items.addAll(fresh);
notifyDataSetChanged();
@@ -195,7 +191,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
nameLp.width = w;
nameLp.topMargin = h + Math.round(7 * density);
name.setLayoutParams(nameLp);
- return new Holder(v, listener);
+ return new Holder(v, listener, animations, advancedEffects);
}
@Override
@@ -205,8 +201,12 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
h.name.setVisibility(position < dockSize ? View.INVISIBLE : View.VISIBLE); // the dock has no labels
boolean focused = h.card.isFocused(); // a rebind after reload() can hit the focused tile
h.name.setAlpha(focused ? 1f : 0f);
- h.card.setScaleX(focused ? FOCUS_SCALE : 1f);
- h.card.setScaleY(focused ? FOCUS_SCALE : 1f);
+ h.card.setScaleX(focused && animations ? focusScale() : 1f);
+ h.card.setScaleY(focused && animations ? focusScale() : 1f);
+ h.card.setTranslationY(focused && advancedEffects ? -4f * ctx.getResources().getDisplayMetrics().density : 0f);
+ h.card.setTranslationZ(focused && advancedEffects ? 8f * ctx.getResources().getDisplayMetrics().density : 0f);
+ h.banner.setScaleX(focused && advancedEffects ? 1.035f : 1f);
+ h.banner.setScaleY(focused && advancedEffects ? 1.035f : 1f);
if (e.banner != null) {
h.banner.setImageDrawable(e.banner);
h.banner.setVisibility(View.VISIBLE);
@@ -234,17 +234,15 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
/** Opens the tile's activity by explicit component, with no extras: a card can name nothing else. */
private void launch(Entry e) {
- if (e.kind == Entry.HOME_SETTINGS) {
- ctx.startActivity(new Intent(ctx, HomeSettingsActivity.class)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
- return;
- }
Intent i = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER)
.setComponent(e.component)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
try {
ctx.startActivity(i);
+ if (advancedEffects && ctx instanceof Activity) {
+ ((Activity) ctx).overridePendingTransition(R.anim.app_open_enter, R.anim.app_open_exit);
+ }
} catch (Exception ex) {
Toast.makeText(ctx, ctx.getString(R.string.cant_open, e.label), Toast.LENGTH_SHORT).show();
}
@@ -278,6 +276,10 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
return position >= 0 && position < items.size() ? items.get(position).label : "";
}
+ float focusScale() {
+ return !animations ? 1f : advancedEffects ? 1.12f : 1.10f;
+ }
+
/** A vivid colour sampled from the app's banner (or icon), cached per entry; a card's accent when it set one. */
int ambientColorAt(int position) {
if (position < 0 || position >= items.size()) return 0xFF444444;
@@ -340,7 +342,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
final TextView label;
final TextView name;
- Holder(View v, TileListener listener) {
+ Holder(View v, TileListener listener, boolean animations, boolean advancedEffects) {
super(v);
card = v.findViewById(R.id.card);
banner = v.findViewById(R.id.banner);
@@ -367,14 +369,35 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {
});
card.setOnFocusChangeListener((view, focused) -> {
- float s = focused ? FOCUS_SCALE : 1.0f;
- view.animate().scaleX(s).scaleY(s)
- .setDuration(focused ? 260 : 180)
- .setInterpolator(new OvershootInterpolator(focused ? 1.6f : 0f))
- .start();
- name.animate().alpha(focused ? 1f : 0f)
- .translationY(focused ? density * 4f : -density * 6f)
- .setDuration(220).start();
+ view.animate().cancel();
+ banner.animate().cancel();
+ name.animate().cancel();
+ float scale = !animations ? 1f : advancedEffects ? 1.12f : 1.10f;
+ float s = focused ? scale : 1f;
+ if (animations) {
+ view.animate().scaleX(s).scaleY(s)
+ .translationY(focused && advancedEffects ? -4f * density : 0f)
+ .translationZ(focused && advancedEffects ? 8f * density : 0f)
+ .setDuration(advancedEffects ? (focused ? 220 : 170) : (focused ? 260 : 180))
+ .setInterpolator(new OvershootInterpolator(focused ? (advancedEffects ? 0.7f : 1.6f) : 0f))
+ .start();
+ if (advancedEffects) {
+ banner.animate().scaleX(focused ? 1.035f : 1f).scaleY(focused ? 1.035f : 1f)
+ .setDuration(280).start();
+ }
+ name.animate().alpha(focused ? 1f : 0f)
+ .translationY(focused ? density * 4f : -density * 6f)
+ .setDuration(220).start();
+ } else {
+ view.setScaleX(1f);
+ view.setScaleY(1f);
+ view.setTranslationY(0f);
+ view.setTranslationZ(0f);
+ banner.setScaleX(1f);
+ banner.setScaleY(1f);
+ name.setAlpha(focused ? 1f : 0f);
+ name.setTranslationY(0f);
+ }
int pos = getBindingAdapterPosition();
if (focused && listener != null && pos != RecyclerView.NO_POSITION) {
listener.onTileFocused(pos, view);
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 36c5e9a7c..70da89a7a 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -30,6 +30,7 @@ final class Config {
private static final String TAG = "TvHome.Config";
static final String FILE_NAME = "config.json";
static final String WALLPAPER_NAME = "wallpaper.jpg";
+ static final String SETTINGS_NAME = "launcher_settings";
final List<String> dockApps;
final List<String> hiddenApps;
@@ -39,11 +40,12 @@ final class Config {
final String sourcePanelAction;
final String inputAction;
final int columns;
+ final boolean animations;
+ final boolean advancedEffects;
final int rowsBelowDock;
final boolean shamsiDate;
final boolean moduleCards;
final String vpnApp;
- final boolean showHomeSettingsShortcut;
/** Background colour behind everything, #RRGGBB; black unless a theme says otherwise. */
final int backgroundColor;
/** Full-screen picture behind the launcher, or null for the plain colour. */
@@ -53,8 +55,8 @@ final class Config {
private Config(List<String> dockApps, List<String> hiddenApps, String liveTvPackage, String liveTvAction,
String sourcePanelService, String sourcePanelAction, String inputAction,
- int columns, int rowsBelowDock,
- boolean shamsiDate, boolean moduleCards, String vpnApp, boolean showHomeSettingsShortcut, int backgroundColor,
+ int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,
+ boolean shamsiDate, boolean moduleCards, String vpnApp, int backgroundColor,
File wallpaper, boolean overlayApplied) {
this.dockApps = Collections.unmodifiableList(dockApps);
this.hiddenApps = Collections.unmodifiableList(hiddenApps);
@@ -65,10 +67,11 @@ final class Config {
this.inputAction = inputAction;
this.columns = columns;
this.rowsBelowDock = rowsBelowDock;
+ this.animations = animations;
+ this.advancedEffects = advancedEffects;
this.shamsiDate = shamsiDate;
this.moduleCards = moduleCards;
this.vpnApp = vpnApp;
- this.showHomeSettingsShortcut = showHomeSettingsShortcut;
this.backgroundColor = backgroundColor;
this.wallpaper = wallpaper;
this.overlayApplied = overlayApplied;
@@ -90,10 +93,11 @@ final class Config {
String inputAction = res.getString(R.string.input_action).trim();
int columns = res.getInteger(R.integer.columns);
int rowsBelow = res.getInteger(R.integer.rows_below_dock);
+ boolean animations = res.getBoolean(R.bool.animations);
+ boolean advancedEffects = res.getBoolean(R.bool.advanced_effects);
boolean shamsi = res.getBoolean(R.bool.shamsi_date);
boolean moduleCards = res.getBoolean(R.bool.module_cards);
String vpn = res.getString(R.string.vpn_app).trim();
- boolean homeSettings = res.getBoolean(R.bool.show_home_settings_shortcut);
int background = 0xFF000000;
boolean applied = false;
@@ -111,19 +115,27 @@ final class Config {
inputAction = string(json, "input_action", inputAction);
columns = integer(json, "columns", columns, 1, 8);
rowsBelow = integer(json, "rows_below_dock", rowsBelow, 0, 3);
+ animations = bool(json, "animations", animations);
+ advancedEffects = bool(json, "advanced_effects", advancedEffects);
shamsi = bool(json, "shamsi_date", shamsi);
moduleCards = bool(json, "module_cards", moduleCards);
vpn = string(json, "vpn_app", vpn);
- homeSettings = bool(json, "show_home_settings_shortcut", homeSettings);
background = color(json, "background_color", background);
}
+ // Choices made with the remote override the shipped configuration and a pushed theme.
+ android.content.SharedPreferences choices = ctx.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE);
+ int chosenColumns = choices.getInt("columns", columns);
+ if (chosenColumns >= 4 && chosenColumns <= 7) columns = chosenColumns;
+ animations = choices.getBoolean("animations", animations);
+ advancedEffects = choices.getBoolean("advanced_effects", advancedEffects);
File wallpaper = dir != null ? new File(dir, WALLPAPER_NAME) : null;
if (wallpaper != null && !(wallpaper.isFile() && wallpaper.length() > 0)) wallpaper = null;
// A theme can also switch the wallpaper off while the file is still there.
if (json != null && json.has("wallpaper") && !bool(json, "wallpaper", true)) wallpaper = null;
return new Config(dock, hidden, liveTv, liveTvAction, panelService, panelAction, inputAction,
- Math.max(1, columns), Math.max(0, rowsBelow), shamsi, moduleCards, vpn, homeSettings, background,
+ Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,
+ shamsi, moduleCards, vpn, background,
wallpaper, applied);
}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeSettingsActivity.java
deleted file mode 100644
index ef0b22b3c..000000000
--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeSettingsActivity.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.gathin.tvhome;
-
-import android.app.Activity;
-import android.content.ActivityNotFoundException;
-import android.content.Intent;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.widget.Toast;
-
-/** Lets the user change HOME through the system UI, without shell or privileged permissions. */
-public class HomeSettingsActivity extends Activity {
- @Override
- protected void onCreate(Bundle state) {
- super.onCreate(state);
- try {
- startActivity(new Intent(Settings.ACTION_HOME_SETTINGS));
- Toast.makeText(this, R.string.home_settings_help, Toast.LENGTH_LONG).show();
- } catch (ActivityNotFoundException | SecurityException unavailable) {
- Toast.makeText(this, R.string.not_available, Toast.LENGTH_LONG).show();
- } finally {
- finish();
- }
- }
-}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
new file mode 100644
index 000000000..8023ef3c6
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
@@ -0,0 +1,103 @@
+package com.gathin.tvhome;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/** Remote-friendly settings owned by the launcher; system settings stay one row away. */
+public final class LauncherSettingsActivity extends Activity {
+ private SharedPreferences choices;
+ private final TextView[] columnChoices = new TextView[4];
+ private TextView animationsChoice;
+ private TextView advancedChoice;
+ private int columns;
+ private boolean animations;
+ private boolean advancedEffects;
+
+ @Override
+ protected void onCreate(Bundle state) {
+ super.onCreate(state);
+ setContentView(R.layout.activity_launcher_settings);
+ choices = getSharedPreferences(Config.SETTINGS_NAME, MODE_PRIVATE);
+ Config config = Config.load(this);
+ columns = config.columns;
+ animations = config.animations;
+ advancedEffects = config.animations && config.advancedEffects;
+
+ int[] ids = {R.id.columns4, R.id.columns5, R.id.columns6, R.id.columns7};
+ for (int i = 0; i < ids.length; i++) {
+ final int value = i + 4;
+ columnChoices[i] = findViewById(ids[i]);
+ columnChoices[i].setOnClickListener(v -> {
+ if (columns == value) return;
+ columns = value;
+ choices.edit().putInt("columns", value).apply();
+ setResult(RESULT_OK);
+ refresh();
+ });
+ }
+ animationsChoice = findViewById(R.id.animationsChoice);
+ animationsChoice.setOnClickListener(v -> {
+ animations = !animations;
+ if (!animations) advancedEffects = false;
+ choices.edit().putBoolean("animations", animations)
+ .putBoolean("advanced_effects", advancedEffects).apply();
+ setResult(RESULT_OK);
+ refresh();
+ });
+ advancedChoice = findViewById(R.id.advancedChoice);
+ advancedChoice.setOnClickListener(v -> {
+ if (advancedEffects) {
+ setAdvanced(false);
+ } else {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.advanced_effects)
+ .setMessage(R.string.advanced_effects_warning)
+ .setPositiveButton(R.string.enable, (dialog, which) -> setAdvanced(true))
+ .setNegativeButton(android.R.string.cancel, null)
+ .show();
+ }
+ });
+ findViewById(R.id.defaultHomeChoice).setOnClickListener(v -> {
+ Toast.makeText(this, R.string.home_settings_help, Toast.LENGTH_LONG).show();
+ open(new Intent(Settings.ACTION_HOME_SETTINGS));
+ });
+ findViewById(R.id.tvSettingsChoice).setOnClickListener(v ->
+ open(new Intent(Settings.ACTION_SETTINGS)));
+ refresh();
+ columnChoices[Math.max(0, Math.min(columns - 4, 3))].requestFocus();
+ }
+
+ private void setAdvanced(boolean enabled) {
+ advancedEffects = enabled;
+ choices.edit().putBoolean("advanced_effects", enabled).apply();
+ setResult(RESULT_OK);
+ refresh();
+ }
+
+ private void refresh() {
+ for (int i = 0; i < columnChoices.length; i++) {
+ columnChoices[i].setSelected(columns == i + 4);
+ }
+ animationsChoice.setText(getString(R.string.animations_state,
+ getString(animations ? R.string.on : R.string.off)));
+ advancedChoice.setText(getString(R.string.advanced_effects_state,
+ getString(advancedEffects ? R.string.on : R.string.off)));
+ advancedChoice.setEnabled(animations);
+ advancedChoice.setAlpha(animations ? 1f : 0.5f);
+ }
+
+ private void open(Intent intent) {
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException | SecurityException e) {
+ Toast.makeText(this, R.string.not_available, Toast.LENGTH_LONG).show();
+ }
+ }
+}
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 e91721b0d..37c29d1f5 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -1,5 +1,7 @@
package com.gathin.tvhome;
+import android.animation.ArgbEvaluator;
+import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
@@ -68,6 +70,7 @@ import java.util.Set;
*/
public class MainActivity extends Activity implements AppAdapter.TileListener {
+ private static final int LAUNCHER_SETTINGS_REQUEST = 42;
/** Tiles per row and dock slots (res/values/config.xml, columns). Set in onCreate. */
static int COLUMNS = 4;
private static final long MINUTE_MS = 60_000L;
@@ -85,7 +88,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private TextView heroName;
private GradientDrawable ambientGlow;
private int ambientColor;
+ private ValueAnimator ambientAnimator;
private boolean heroShown;
+ private boolean animations;
+ private boolean advancedEffects;
private TextView greeting;
private View btnInputs;
private TextView btnWifi;
@@ -181,6 +187,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
// config.xml, overlaid by config.json from a pushed theme (see Config and tools/theme.sh).
Config cfg = Config.load(this);
COLUMNS = cfg.columns;
+ animations = cfg.animations;
+ advancedEffects = cfg.animations && cfg.advancedEffects;
liveTvPkg = cfg.liveTvPackage;
liveTvAction = cfg.liveTvAction;
inputAction = cfg.inputAction;
@@ -218,8 +226,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
grid.setHasFixedSize(true);
grid.setItemAnimator(null);
grid.addItemDecoration(new DockDecoration(COLUMNS, density));
- grid.setLayoutAnimation(new LayoutAnimationController(
- AnimationUtils.loadAnimation(this, R.anim.tile_enter), 0.06f));
+ if (animations) {
+ grid.setLayoutAnimation(new LayoutAnimationController(
+ AnimationUtils.loadAnimation(this, R.anim.tile_enter), 0.06f));
+ }
adapter = new AppAdapter(this, this, COLUMNS, cfg);
grid.setAdapter(adapter);
@@ -264,7 +274,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
}
});
for (SpringAnimation s : new SpringAnimation[]{springX, springY}) {
- s.setSpring(new SpringForce().setStiffness(260f).setDampingRatio(0.58f));
+ s.setSpring(new SpringForce().setStiffness(advancedEffects ? 320f : 260f)
+ .setDampingRatio(advancedEffects ? 0.76f : 0.58f));
}
btnInputs = findViewById(R.id.btnInputs);
@@ -275,7 +286,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
open(new Intent(Settings.ACTION_WIFI_SETTINGS));
return true;
});
- btnSettings.setOnClickListener(v -> open(new Intent(Settings.ACTION_SETTINGS)));
+ btnSettings.setOnClickListener(v -> startActivityForResult(
+ new Intent(this, LauncherSettingsActivity.class), LAUNCHER_SETTINGS_REQUEST));
btnSettings.setOnLongClickListener(v -> {
if (!moduleCards) return false; // off: a long press does nothing, as before the feature
showModuleCards();
@@ -297,6 +309,13 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
btnInputs.setOnKeyListener(pillKeys);
btnWifi.setOnKeyListener(pillKeys);
btnSettings.setOnKeyListener(pillKeys);
+ if (advancedEffects) {
+ for (View button : new View[]{btnInputs, btnWifi, btnSettings}) {
+ button.setOnFocusChangeListener((view, focused) -> view.animate()
+ .scaleX(focused ? 1.04f : 1f).scaleY(focused ? 1.04f : 1f)
+ .setDuration(160).start());
+ }
+ }
// Hide the glass when focus leaves the tiles.
getWindow().getDecorView().getViewTreeObserver().addOnGlobalFocusChangeListener((oldF, newF) -> {
@@ -364,6 +383,12 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
handler.postDelayed(minuteTick, MINUTE_MS);
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == LAUNCHER_SETTINGS_REQUEST && resultCode == RESULT_OK) recreate();
+ }
+
/** Rebuilds the tiles (and the module cards), then puts focus back where it was. */
private void reloadApps(boolean animate) {
// Capture the app before rebinding can move focus and overwrite its key.
@@ -378,7 +403,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
ambient.setAlpha(0f);
}
reloadTiles();
- if (animate) grid.scheduleLayoutAnimation();
+ if (animate && animations) grid.scheduleLayoutAnimation();
if (restoreFocus) {
// Follow the same app, or the nearest remaining slot when it was removed.
@@ -429,6 +454,9 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
@Override
protected void onPause() {
super.onPause();
+ stopAmbientAnimation();
+ heroName.animate().cancel();
+ ambient.animate().cancel();
unregisterReceiver(packageReceiver);
handler.removeCallbacks(minuteTick);
// Nothing of ours stays on screen over another app; an undecided prompt simply returns next time.
@@ -469,17 +497,18 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
Rect r = new Rect(0, 0, card.getWidth(), card.getHeight());
root.offsetDescendantRectToMyCoords(card, r);
float pad = 6f * density; // matches GlassView's glow inset
- float w = card.getWidth() * AppAdapter.FOCUS_SCALE + 2 * pad;
- float h = card.getHeight() * AppAdapter.FOCUS_SCALE + 2 * pad;
+ float scale = adapter.focusScale();
+ 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;
+ float y = r.exactCenterY() - h / 2f - (advancedEffects ? 4f * density : 0f);
ViewGroup.LayoutParams lp = glass.getLayoutParams();
if (lp.width != (int) w || lp.height != (int) h) {
lp.width = (int) w;
lp.height = (int) h;
glass.setLayoutParams(lp);
- glass.setRadius(AppAdapter.cornerRadius(card.getWidth(), density) * AppAdapter.FOCUS_SCALE + pad);
+ glass.setRadius(AppAdapter.cornerRadius(card.getWidth(), density) * scale + pad);
}
glassTargetX = x;
glassTargetY = y;
@@ -488,8 +517,14 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
springY.cancel();
glass.setTranslationX(x);
glass.setTranslationY(y);
- glass.animate().alpha(1f).setDuration(180).start();
+ if (animations) glass.animate().alpha(1f).setDuration(180).start();
+ else glass.setAlpha(1f);
glassShown = true;
+ } else if (!animations) {
+ springX.cancel();
+ springY.cancel();
+ glass.setTranslationX(x);
+ glass.setTranslationY(y);
} else {
springX.animateToFinalPosition(x);
springY.animateToFinalPosition(y - glassScrollShift);
@@ -499,7 +534,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
// Dock: park it at the bottom of the screen and show the top shelf for this app.
int decoratedTop = item.getTop() - (int) (6 * density);
int dy = decoratedTop - grid.getPaddingTop();
- if (Math.abs(dy) > 1) grid.smoothScrollBy(0, dy);
+ if (Math.abs(dy) > 1) {
+ if (animations) grid.smoothScrollBy(0, dy);
+ else grid.scrollBy(0, dy);
+ }
showHero(position, r.top - dy);
} else {
hideHero();
@@ -517,7 +555,23 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
float y = dockTopInRoot - 14 * density - 26 * density - heroName.getHeight();
boolean changed = !label.contentEquals(heroName.getText());
+ if (!animations) {
+ heroName.animate().cancel();
+ ambient.animate().cancel();
+ heroName.setText(label);
+ heroName.setY(y);
+ heroName.setTranslationX(0f);
+ heroName.setAlpha(1f);
+ setAmbient(color);
+ ambient.setAlpha(1f);
+ heroShown = true;
+ return;
+ }
+
if (!heroShown) {
+ stopAmbientAnimation();
+ heroName.animate().cancel();
+ ambient.animate().cancel();
heroName.setText(label);
heroName.setY(y);
heroName.setTranslationX(0f);
@@ -526,13 +580,16 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
ambient.animate().alpha(1f).setDuration(600).start();
heroShown = true;
} else if (changed) {
+ if (advancedEffects) heroName.animate().cancel();
heroName.animate().alpha(0f).translationX(-12 * density).setDuration(120).withEndAction(() -> {
heroName.setText(label);
heroName.setY(y);
heroName.setTranslationX(12 * density);
heroName.animate().alpha(1f).translationX(0f).setDuration(200).start();
}).start();
- if (color != ambientColor) {
+ if (advancedEffects) {
+ transitionAmbient(color);
+ } else if (color != ambientColor) {
ambient.animate().alpha(0.35f).setDuration(200).withEndAction(() -> {
setAmbient(color);
ambient.animate().alpha(1f).setDuration(500).start();
@@ -549,17 +606,49 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
ambientGlow.setColors(new int[]{0x5C000000 | c, 0x26000000 | c, 0x00000000 | c});
}
+ private void transitionAmbient(int color) {
+ // A rapid focus change continues from the colour actually displayed on screen.
+ stopAmbientAnimation();
+ ambient.animate().cancel();
+ if (color == ambientColor) {
+ ambient.animate().alpha(1f).setDuration(180).start();
+ return;
+ }
+ ambient.animate().alpha(1f).setDuration(180).start();
+ ambientAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), ambientColor, color);
+ ambientAnimator.setDuration(360);
+ ambientAnimator.addUpdateListener(animation -> setAmbient((int) animation.getAnimatedValue()));
+ ambientAnimator.start();
+ }
+
+ private void stopAmbientAnimation() {
+ if (ambientAnimator != null) {
+ ambientAnimator.cancel();
+ ambientAnimator = null;
+ }
+ }
+
private void hideHero() {
if (!heroShown) return;
+ stopAmbientAnimation();
+ heroName.animate().cancel();
+ ambient.animate().cancel();
heroShown = false;
- heroName.animate().alpha(0f).setDuration(160).start();
- ambient.animate().alpha(0f).setDuration(300).start();
+ if (animations) {
+ heroName.animate().alpha(0f).setDuration(160).start();
+ ambient.animate().alpha(0f).setDuration(300).start();
+ } else {
+ heroName.setAlpha(0f);
+ ambient.setAlpha(0f);
+ }
}
private void hideGlass() {
if (!glassShown) return;
glassShown = false;
- glass.animate().alpha(0f).setDuration(160).start();
+ glass.animate().cancel();
+ if (animations) glass.animate().alpha(0f).setDuration(160).start();
+ else glass.setAlpha(0f);
}
// ---- navigation ------------------------------------------------------------------------------
@@ -603,6 +692,14 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
return;
}
// Not laid out yet: scroll there, then focus once the scroll settles.
+ if (!animations) {
+ grid.scrollToPosition(pos);
+ grid.post(() -> {
+ RecyclerView.ViewHolder h = grid.findViewHolderForAdapterPosition(pos);
+ if (h != null) h.itemView.findViewById(R.id.card).requestFocus();
+ });
+ return;
+ }
grid.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView rv, int newState) {
diff --git a/launcher/app/src/main/res/anim/app_open_enter.xml b/launcher/app/src/main/res/anim/app_open_enter.xml
new file mode 100644
index 000000000..d85118382
--- /dev/null
+++ b/launcher/app/src/main/res/anim/app_open_enter.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:interpolator/decelerate_cubic"
+ android:duration="200">
+ <alpha android:fromAlpha="0.65" android:toAlpha="1.0" />
+ <scale android:fromXScale="0.97" android:toXScale="1.0"
+ android:fromYScale="0.97" android:toYScale="1.0"
+ android:pivotX="50%" android:pivotY="50%" />
+</set>
diff --git a/launcher/app/src/main/res/anim/app_open_exit.xml b/launcher/app/src/main/res/anim/app_open_exit.xml
new file mode 100644
index 000000000..94568b41b
--- /dev/null
+++ b/launcher/app/src/main/res/anim/app_open_exit.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:interpolator/decelerate_cubic"
+ android:duration="200">
+ <alpha android:fromAlpha="1.0" android:toAlpha="0.25" />
+ <scale android:fromXScale="1.0" android:toXScale="1.025"
+ android:fromYScale="1.0" android:toYScale="1.025"
+ android:pivotX="50%" android:pivotY="50%" />
+</set>
diff --git a/launcher/app/src/main/res/drawable/ic_home_settings.xml b/launcher/app/src/main/res/drawable/ic_home_settings.xml
deleted file mode 100644
index cc319d69d..000000000
--- a/launcher/app/src/main/res/drawable/ic_home_settings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp" android:height="48dp"
- android:viewportWidth="24" android:viewportHeight="24">
- <path android:fillColor="#FFFFFFFF"
- android:pathData="M12,3L2,12H5V21H10V15H14V21H19V12H22Z" />
-</vector>
diff --git a/launcher/app/src/main/res/drawable/settings_choice_bg.xml b/launcher/app/src/main/res/drawable/settings_choice_bg.xml
new file mode 100644
index 000000000..3539d96ec
--- /dev/null
+++ b/launcher/app/src/main/res/drawable/settings_choice_bg.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_focused="true">
+ <shape android:shape="rectangle">
+ <solid android:color="#5574A987" />
+ <corners android:radius="14dp" />
+ <stroke android:width="2dp" android:color="#FFB9E7C7" />
+ </shape>
+ </item>
+ <item android:state_selected="true">
+ <shape android:shape="rectangle">
+ <solid android:color="#334DAE6D" />
+ <corners android:radius="14dp" />
+ <stroke android:width="1dp" android:color="#FF4DAE6D" />
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <solid android:color="#FF242B34" />
+ <corners android:radius="14dp" />
+ </shape>
+ </item>
+</selector>
diff --git a/launcher/app/src/main/res/layout/activity_launcher_settings.xml b/launcher/app/src/main/res/layout/activity_launcher_settings.xml
new file mode 100644
index 000000000..19cd1ea43
--- /dev/null
+++ b/launcher/app/src/main/res/layout/activity_launcher_settings.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#FF101419"
+ android:fillViewport="true">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingStart="72dp"
+ android:paddingEnd="72dp"
+ android:paddingTop="38dp"
+ android:paddingBottom="38dp">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/launcher_settings"
+ android:textColor="#FFFFFFFF"
+ android:textSize="34sp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="28dp"
+ android:text="@string/columns_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/columns4" style="@style/SettingsColumnChoice" android:text="4" />
+ <TextView android:id="@+id/columns5" style="@style/SettingsColumnChoice" android:text="5" />
+ <TextView android:id="@+id/columns6" style="@style/SettingsColumnChoice" android:text="6" />
+ <TextView android:id="@+id/columns7" style="@style/SettingsColumnChoice" android:text="7" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/animationsChoice"
+ style="@style/SettingsRow"
+ android:layout_marginTop="28dp" />
+
+ <TextView
+ android:id="@+id/advancedChoice"
+ style="@style/SettingsRow"
+ android:layout_marginTop="10dp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/advanced_effects_warning"
+ android:textColor="#FFACB8C1"
+ android:textSize="14sp" />
+
+ <TextView
+ android:id="@+id/defaultHomeChoice"
+ style="@style/SettingsRow"
+ android:layout_marginTop="28dp"
+ android:text="@string/home_settings" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="7dp"
+ android:text="@string/home_settings_help"
+ android:textColor="#FFACB8C1"
+ android:textSize="14sp" />
+
+ <TextView
+ android:id="@+id/tvSettingsChoice"
+ style="@style/SettingsRow"
+ android:layout_marginTop="18dp"
+ android:text="@string/tv_settings" />
+ </LinearLayout>
+</ScrollView>
diff --git a/launcher/app/src/main/res/values-zh-rCN/strings.xml b/launcher/app/src/main/res/values-zh-rCN/strings.xml
index 119ab3ede..18b3f0511 100644
--- a/launcher/app/src/main/res/values-zh-rCN/strings.xml
+++ b/launcher/app/src/main/res/values-zh-rCN/strings.xml
@@ -4,6 +4,18 @@
<string name="inputs">输入源</string>
<string name="wifi">无线网络</string>
<string name="settings">设置</string>
+ <string name="home_settings">选择默认桌面</string>
+ <string name="home_settings_help">选择原始桌面即可关闭简洁桌面的默认桌面状态;需要切回时选择简洁桌面。原始桌面必须仍处于启用状态;若安装脚本已停用它,请先用恢复脚本启用。电视还须提供系统桌面选择页。</string>
+ <string name="launcher_settings">简洁桌面设置</string>
+ <string name="columns_label">每行应用数量</string>
+ <string name="animations_state">动态效果:%1$s</string>
+ <string name="advanced_effects">高级动态效果</string>
+ <string name="advanced_effects_state">高级动态效果:%1$s</string>
+ <string name="advanced_effects_warning">增加卡片上浮、图标缩放和背景颜色平滑过渡;可能增加内存占用,实际变化取决于电视。</string>
+ <string name="tv_settings">电视系统设置</string>
+ <string name="on">开</string>
+ <string name="off">关</string>
+ <string name="enable">开启</string>
<string name="choose_input">输入源</string>
<string name="connected">已连接</string>
<string name="standby">待机</string>
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 369800c56..20ebb9bc5 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -54,9 +54,9 @@
shrink to fit from 5 up (about 144dp at 5, 117dp at 6 on a 1080p TV). -->
<integer name="columns">4</integer>
- <!-- "Default home" tile that opens Android's home-screen picker, for TVs whose settings have one
- (most Android TVs don't; the tile only appears when the page exists). Off by default. -->
- <bool name="show_home_settings_shortcut">false</bool>
+ <!-- Basic motion is on; advanced effects are opt-in in the launcher's own Settings screen. -->
+ <bool name="animations">true</bool>
+ <bool name="advanced_effects">false</bool>
<!-- Module cards: an app that declares a card (docs/specs/card.md) can stand in for its tile with its own
label, caption and glow colour, once you answer Show on the prompt. false: never look for cards or ask. -->
diff --git a/launcher/app/src/main/res/values/strings.xml b/launcher/app/src/main/res/values/strings.xml
index aa641180e..e8c5b281c 100644
--- a/launcher/app/src/main/res/values/strings.xml
+++ b/launcher/app/src/main/res/values/strings.xml
@@ -22,8 +22,18 @@
<string name="dream_name">Clock</string>
<string name="vpn">VPN</string>
<string name="vpn_off">VPN off</string>
- <string name="home_settings">Default home</string>
- <string name="home_settings_help">Choose a home screen in system settings, then press Home.</string>
+ <string name="home_settings">Choose default home</string>
+ <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="animations_state">Animations: %1$s</string>
+ <string name="advanced_effects">Advanced effects</string>
+ <string name="advanced_effects_state">Advanced effects: %1$s</string>
+ <string name="advanced_effects_warning">Adds a lifted tile, icon zoom and smooth colour transitions. May increase memory use; the actual difference depends on your TV.</string>
+ <string name="tv_settings">TV system settings</string>
+ <string name="on">On</string>
+ <string name="off">Off</string>
+ <string name="enable">Enable</string>
<string name="input_key_service_description">Opens the input switcher when the remote\'s Input button is pressed.</string>
<string name="home_key_name">Home button</string>
<string name="home_key_description">Makes the remote\'s Home button open this launcher.</string>
diff --git a/launcher/app/src/main/res/values/styles.xml b/launcher/app/src/main/res/values/styles.xml
index 05fcc97aa..bf6e7eac1 100644
--- a/launcher/app/src/main/res/values/styles.xml
+++ b/launcher/app/src/main/res/values/styles.xml
@@ -25,4 +25,23 @@
<item name="android:clickable">true</item>
</style>
<style name="TopButton" parent="TopButtonBase" />
+
+ <style name="SettingsRow">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">52dp</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:paddingStart">18dp</item>
+ <item name="android:paddingEnd">18dp</item>
+ <item name="android:background">@drawable/settings_choice_bg</item>
+ <item name="android:textColor">#FFFFFFFF</item>
+ <item name="android:textSize">18sp</item>
+ <item name="android:focusable">true</item>
+ <item name="android:clickable">true</item>
+ </style>
+ <style name="SettingsColumnChoice" parent="SettingsRow">
+ <item name="android:layout_width">0dp</item>
+ <item name="android:layout_weight">1</item>
+ <item name="android:layout_marginEnd">10dp</item>
+ <item name="android:gravity">center</item>
+ </style>
</resources>
diff --git a/themes/README.md b/themes/README.md
index 7e3440bb6..e4963b253 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -3,6 +3,8 @@
A theme is a folder with a `config.json` and, optionally, a `wallpaper.jpg`. Pushing one changes the
launcher's dock, layout and look on the TV without rebuilding the APK: the launcher reads
`config.json` as an overlay over its built-in `config.xml` the next time it starts.
+Choices made in the launcher's on-TV Settings screen (columns and effects) take priority over both;
+`tools/theme.sh --reset` does not erase those choices.
```bash
TV_HOST=192.168.1.50 tools/theme.sh themes/aurora # push a theme and restart Home
@@ -33,7 +35,8 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `shamsi_date` | bool | Show the Solar Hijri date above the Gregorian one |
| `module_cards` | bool | Look for module cards and ask about them (`true`); `false` turns the feature off |
| `vpn_app` | string | App the network pill opens when a VPN is configured; also shows a red "VPN off" badge while no VPN is up |
-| `show_home_settings_shortcut` | bool | The "Default home" tile, where the TV has a home picker |
+| `animations` | bool | Basic focus, glass, title and tile entrance motion; true by default |
+| `advanced_effects` | bool | Optional lifted tile, icon zoom, smooth ambient colour and app opening effects; false by default |
| `background_color` | `#RRGGBB` | Colour behind everything; black by default |
| `wallpaper` | bool | Show `wallpaper.jpg` from the theme folder (`true`), or ignore it (`false`) |