Remove obsolete launcher integration and reduce navigation jank

This commit is contained in:
Elijah Kuntz 2026-10-19 14:48:08 -07:00
parent ac0a892c5f
commit 2739b278cd
21 changed files with 394 additions and 129 deletions

View file

@ -6,8 +6,8 @@ android {
applicationId 'tv.luma.launcher'
minSdk 26
targetSdk 34
versionCode 14
versionName '1.1.11'
versionCode 15
versionName '1.1.12'
}
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8; targetCompatibility JavaVersion.VERSION_1_8 }
}

View file

@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tv.luma.launcher" android:versionCode="14" android:versionName="1.1.11">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tv.luma.launcher" android:versionCode="15" android:versionName="1.1.12">
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="34" />
<uses-feature android:name="android.software.leanback" android:required="true" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />

View file

@ -6,28 +6,11 @@ import android.content.Intent;
/** Private, explicit cross-process controls; only Luma's own UID can call this receiver. */
public final class HomeControlReceiver extends BroadcastReceiver {
static final String FALLBACK = "tv.luma.launcher.ALLOW_PROJECTIVY";
static final String DISABLE = "tv.luma.launcher.DISABLE_HOME_OVERRIDE";
static void setFallback(Context context, boolean allow) {
if (isFallback(context) == allow) return;
context
.getSharedPreferences("home-routing", Context.MODE_PRIVATE)
.edit()
.putBoolean("fallback", allow)
.apply();
}
static boolean isFallback(Context context) {
return context
.getSharedPreferences("home-routing", Context.MODE_PRIVATE)
.getBoolean("fallback", false);
}
@Override
public void onReceive(Context context, Intent intent) {
if (FALLBACK.equals(intent.getAction())) setFallback(context, true);
else if (DISABLE.equals(intent.getAction()) && LumaHomeService.active != null) {
if (DISABLE.equals(intent.getAction()) && LumaHomeService.active != null) {
LumaHomeService.active.disableSelf();
}
}

View file

@ -18,7 +18,6 @@ public final class LumaHomeService extends AccessibilityService {
public boolean onKeyEvent(KeyEvent event) {
if (event.getKeyCode() != KeyEvent.KEYCODE_HOME) return false;
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
HomeControlReceiver.setFallback(this, false);
openLuma();
}
return true;
@ -32,11 +31,6 @@ public final class LumaHomeService extends AccessibilityService {
// Class names only: no view hierarchy, text, screenshots, or content inspection.
if (pkg.equals("com.google.android.apps.tv.launcherx")
&& cls.equals("com.google.android.apps.tv.launcherx.home.HomeActivity")) {
HomeControlReceiver.setFallback(this, false);
openLuma();
} else if (pkg.equals("com.spocky.projengmenu")
&& cls.equals("com.spocky.projengmenu.ui.home.MainActivity")
&& !HomeControlReceiver.isFallback(this)) {
openLuma();
}
}

View file

@ -389,7 +389,7 @@ public final class MainActivity extends Activity {
currentDialog = null;
saverDownloading = false;
}
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setKeepScreenOn(false);
handler.removeCallbacks(idleSaver);
stopSaver(false);
scene.pause();
@ -690,10 +690,6 @@ public final class MainActivity extends Activity {
}
private void launch(AppRepository.App a) {
if (a.component.getPackageName().equals("com.spocky.projengmenu")) {
fallback();
return;
}
try {
Intent i =
new Intent(Intent.ACTION_MAIN)
@ -706,34 +702,6 @@ public final class MainActivity extends Activity {
}
}
private void fallback() {
// Wait for the private router process to allow this explicit fallback launch.
sendOrderedBroadcast(
new Intent(this, HomeControlReceiver.class).setAction(HomeControlReceiver.FALLBACK),
null,
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
openProjectivy();
}
},
handler,
Activity.RESULT_OK,
null,
null);
}
private void openProjectivy() {
try {
Intent i = getPackageManager().getLeanbackLaunchIntentForPackage("com.spocky.projengmenu");
if (i == null) i = getPackageManager().getLaunchIntentForPackage("com.spocky.projengmenu");
if (i != null) startActivity(i);
else toast("Projectivy is not available");
} catch (Exception e) {
toast("Unable to open Projectivy");
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
@ -861,7 +829,10 @@ public final class MainActivity extends Activity {
: "A new Luma version is available",
this::updatesSettings);
action(
p, "Default launcher", "Home button routing and fallback", this::defaultLauncherSettings);
p,
"Default launcher",
"Home button routing and system defaults",
this::defaultLauncherSettings);
action(
p,
"Plex media rows",
@ -881,14 +852,6 @@ public final class MainActivity extends Activity {
toast("Settings unavailable");
}
});
action(
p,
"Open Projectivy",
"Your existing launcher is always available",
() -> {
dismiss();
fallback();
});
action(
p,
"About Luma",
@ -1199,8 +1162,7 @@ public final class MainActivity extends Activity {
"System Home: "
+ (nativeHome ? "Luma" : "Managed by this TV")
+ "\nHome button override: "
+ (enabled ? "On" : "Off")
+ "\nProjectivy stays installed and available as your fallback.");
+ (enabled ? "On" : "Off"));
action(
p,
"Choose default Home app",
@ -1253,8 +1215,7 @@ public final class MainActivity extends Activity {
panel(
"Enable Home routing",
"In Android Accessibility, enable Luma Home button.\n\n"
+ "In Projectivy settings → General, turn off Override current launcher to"
+ " avoid competing Home handlers. Projectivy itself stays available.");
+ "This routes the Home button to Luma.");
action(
help,
"Open Accessibility settings",
@ -1273,14 +1234,6 @@ public final class MainActivity extends Activity {
action(help, "Back", null, this::defaultLauncherSettings);
}
});
action(
p,
"Open Projectivy",
"Use your fallback without turning Luma off",
() -> {
dismiss();
fallback();
});
action(p, "Back", null, this::showSettings);
}
@ -1492,7 +1445,7 @@ public final class MainActivity extends Activity {
"No ads or analytics. Wallpaper, app artwork, and Plex requests stop when another app"
+ " opens. Image caches are bounded and cleared when Luma leaves the screen.\n\n"
+ "Menu opens settings. Hold OK on an app to customize it. Back stays on Luma. Open"
+ " Projectivy from Settings or its app tile.\n\n"
+ " Android settings from Luma settings.\n\n"
+ "Manage Home routing and scheduled update checks in Settings.",
13,
Ui.MUTED);
@ -1995,12 +1948,19 @@ public final class MainActivity extends Activity {
return super.dispatchTouchEvent(event);
}
private void setKeepScreenOn(boolean enabled) {
int flag = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
boolean current = (getWindow().getAttributes().flags & flag) != 0;
if (current == enabled) return;
if (enabled) getWindow().addFlags(flag);
else getWindow().clearFlags(flag);
}
private void resetSaverTimer() {
handler.removeCallbacks(idleSaver);
int minutes = prefs.getInt("saverTimeout", 10);
if (foreground && (minutes > 0 || saver != null))
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
else getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if (foreground && (minutes > 0 || saver != null)) setKeepScreenOn(true);
else setKeepScreenOn(false);
if (foreground && saver == null && currentDialog == null && minutes > 0)
handler.postDelayed(idleSaver, minutes * 60000L);
}
@ -2013,7 +1973,7 @@ public final class MainActivity extends Activity {
scene.pause();
scroll.stopAnimation();
saver = new SaverView(this);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setKeepScreenOn(true);
root.addView(saver, new FrameLayout.LayoutParams(-1, -1));
saver.requestFocus();
}
@ -2023,7 +1983,7 @@ public final class MainActivity extends Activity {
saver.stop();
root.removeView(saver);
saver = null;
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setKeepScreenOn(false);
if (resume && foreground) {
scene.resume();
AppTile tile = tiles.get(selected);

View file

@ -32,7 +32,7 @@ final class SceneView extends View {
private ValueAnimator animator, colorAnimator;
private boolean useTintMask;
private boolean accentPending;
// Let the 160 ms focus lift finish; passing selections need no full-screen transition.
// Keep full-screen color work out of continuous D-pad navigation; tile focus stays immediate.
private final Runnable accentUpdate =
() -> {
accentPending = false;
@ -120,7 +120,7 @@ final class SceneView extends View {
targetAccent = color;
removeCallbacks(accentUpdate);
accentPending = animate && motion && active && frame != null;
if (accentPending) postDelayed(accentUpdate, 160);
if (accentPending) postDelayed(accentUpdate, 250);
else applyAccent(color, animate);
}
@ -132,6 +132,8 @@ final class SceneView extends View {
return;
}
if (colorAnimator != null) colorAnimator.cancel();
// Coalesced navigation may return to the color that is already displayed.
if (accent == color) return;
if (!animate || !motion || frame == null) {
accent = color;
invalidate();

View file

@ -1,4 +1,4 @@
<resources>
<string name="home_override_name">Luma Home button</string>
<string name="home_override_description">Opens Luma when you press Home or the stock launcher appears. Does not read screen content. Projectivy remains available from Luma settings. Turn off other launcher Home overrides to avoid conflicts.</string>
<string name="home_override_description">Opens Luma when you press Home or the stock launcher appears. Does not read screen content. Turn off other launcher Home overrides to avoid conflicts.</string>
</resources>

View file

@ -1,6 +1,6 @@
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeWindowStateChanged"
android:packageNames="com.google.android.apps.tv.launcherx,com.spocky.projengmenu"
android:packageNames="com.google.android.apps.tv.launcherx"
android:accessibilityFeedbackType="feedbackGeneric"
android:notificationTimeout="80"
android:accessibilityFlags="flagRequestFilterKeyEvents"