Skip to content

Debloat your Android TV, install apps, browse and transfer files on it, all from your phone. Just 3 MB, no tracking, no root, no PC.

Mark launchers already on the TV in the picker, and list any other

jesse-agent-232863bfec4b64a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8b37487..078accf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,9 @@ until this file has a section for its version.
- **Improved:** Debloat ticks a whole group of apps in one tap, from its heading. [#219](../../pull/219)
- Debloat no longer lists the TV's own home app, so it can't be turned off there.
- **Improved:** Install a home screen offers Projectivy and FLauncher, and says how to use any other launcher. [#223](../../pull/223)
+ - A launcher already on the TV is marked Installed or Home now, with Make Home and Open in place of the Play Store.
+ - Any other launcher on the TV is listed under On this TV.
+ - Closing the Play Store without installing goes back to the picker.
## 0.12.0 — 2026-10-28
diff --git a/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt b/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
index 234cb12..1177211 100644
--- a/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
+++ b/adb/src/main/kotlin/app/tellyscope/adb/Actions.kt
@@ -288,10 +288,13 @@ class Actions(private val shell: AdbShell) {
private fun activitiesIn(brief: String): List<String> =
brief.lineSequence().map(String::trim).filter { '/' in it && ' ' !in it }.distinct().toList()
- /** TV apps register under LEANBACK_LAUNCHER only; phone-style apps under LAUNCHER. Try both. */
+ /**
+ * TV apps register under LEANBACK_LAUNCHER only; phone-style apps under LAUNCHER. Try both, then
+ * HOME, for a launcher with no icon of its own.
+ */
private suspend fun open(pkg: String): ActionResult {
var last = ""
- for (category in listOf("android.intent.category.LEANBACK_LAUNCHER", "android.intent.category.LAUNCHER")) {
+ for (category in listOf("android.intent.category.LEANBACK_LAUNCHER", "android.intent.category.LAUNCHER", "android.intent.category.HOME")) {
val r = shell.shell("monkey -p $pkg -c $category 1 2>&1")
if (r.exitCode == 0 && "No activities found" !in r.output && "aborted" !in r.output) {
return ActionResult.Done(undo = null)
diff --git a/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt b/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt
index 49e7f31..d999108 100644
--- a/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt
+++ b/adb/src/test/kotlin/app/tellyscope/adb/ActionsTest.kt
@@ -204,6 +204,17 @@ class ActionsTest {
assertEquals(2, sh.ran.count { it.startsWith("monkey") })
}
+ @Test fun openFallsBackToHomeForALauncherWithNoIcon() = runTest {
+ val none = ok("** No activities found to run, monkey aborted.\n")
+ val sh = FakeShell(mapOf(
+ "monkey -p com.foo -c android.intent.category.LEANBACK_LAUNCHER" to none,
+ "monkey -p com.foo -c android.intent.category.LAUNCHER" to none,
+ "monkey -p com.foo -c android.intent.category.HOME" to ok("Events injected: 1\n"),
+ ))
+ assertEquals(ActionResult.Done(null), Actions(sh).run(Action.OPEN, "com.foo"))
+ assertEquals(3, sh.ran.count { it.startsWith("monkey") })
+ }
+
@Test fun rejectsShellInjection() = runTest {
val sh = FakeShell()
assertFailsWith<IllegalArgumentException> { Actions(sh).run(Action.STOP, "com.foo; reboot") }
diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.kt
index 30f684d..aa28f3e 100644
--- a/app/src/main/java/app/tellyscope/MainActivity.kt
+++ b/app/src/main/java/app/tellyscope/MainActivity.kt
@@ -336,8 +336,11 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {
install = vm::installLauncher,
chooseAnother = vm::pickLauncher,
switch = vm::switchToLauncher,
+ makeHome = vm::makeHome,
+ open = vm::openLauncher,
later = vm::launcherLater,
),
+ snackbar = snackbar,
)
} else if (debloat && state.device.debloat != null) {
// Leaving mid-run only closes the screen; the run goes on, and History has each app.
diff --git a/app/src/main/java/app/tellyscope/ui/Copy.kt b/app/src/main/java/app/tellyscope/ui/Copy.kt
index d0740d3..677e39f 100644
--- a/app/src/main/java/app/tellyscope/ui/Copy.kt
+++ b/app/src/main/java/app/tellyscope/ui/Copy.kt
@@ -175,11 +175,16 @@ object Copy {
const val CHOOSE_HOME = "Choose a home screen"
const val CHOOSE_HOME_TEXT = "Each one replaces the TV's home screen. Tellyscope opens it in the Play Store on the TV; you install it with the remote."
const val RECOMMENDED = "Recommended"
+ /** The picker's section for launchers on the TV that Recommended doesn't list. */
+ const val ON_THIS_TV = "On this TV"
+ const val INSTALLED = "Installed"
+ const val HOME_NOW = "Home now"
+ /** Shows a launcher on the TV, from the picker. */
+ const val OPEN = "Open"
const val USES_SERVICE = "Uses an accessibility service"
const val NO_SERVICE = "Open source · no accessibility service"
- /** Under the picker's list, before the bold [MAKE_HOME]: any other launcher works too. */
- const val OTHER_LAUNCHER = "Prefer another launcher? Install it from the Play Store on your TV, then tap "
- const val OTHER_LAUNCHER_WHERE = " next to it in Tweaks › $HOME_SCREEN."
+ /** Under the picker's list: any other launcher works too, and comes back as On this TV. */
+ const val OTHER_LAUNCHER = "Prefer another launcher? Install it from the Play Store on your TV, then come back here. It shows up under $ON_THIS_TV."
const val NOT_AFFILIATED = "Tellyscope isn't affiliated with any of these launchers or their developers."
const val OPEN_IN_STORE = "Open in Play Store"
const val INSTALL_HOME = "Install a home screen"
@@ -212,6 +217,8 @@ object Copy {
const val CHOOSE_ANOTHER = "Choose another"
fun notInstalled(name: String) = "$name isn't installed"
+ /** The Store closed without an install: back on the picker, still chosen. */
+ fun wasntInstalled(name: String) = "$name wasn't installed"
const val NOT_INSTALLED_TEXT =
"The Play Store closed on the TV before it was installed. If the Store said it isn't available for this TV, choose another launcher."
diff --git a/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.kt b/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.kt
index eea87a7..8288c0b 100644
--- a/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.kt
+++ b/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.kt
@@ -4,14 +4,18 @@
package app.tellyscope.ui
+import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@@ -36,6 +40,8 @@ import androidx.compose.material3.LoadingIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Scaffold
+import androidx.compose.material3.SnackbarHost
+import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
@@ -43,6 +49,7 @@ import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@@ -57,7 +64,7 @@ import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.text.withStyle
+import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import app.tellyscope.data.Action
import app.tellyscope.data.AppInfo
@@ -81,6 +88,13 @@ internal fun offerChoose(apps: List<AppInfo>) = hasPlayStore(apps) && !hasAddedL
internal fun offerLauncher(apps: List<AppInfo>, hidden: Boolean) =
!hidden && offerChoose(apps) && apps.none { it.homeInstead != null || it.homeBack != null }
+/** [pkg] on the TV and on, so the picker offers Make Home or Open on it rather than the Store. */
+internal fun installedLauncher(apps: List<AppInfo>, pkg: String) = apps.firstOrNull { it.packageName == pkg && it.enabled }
+
+/** The picker's On this TV: launchers someone added that Recommended doesn't list, the TV's own left out. */
+internal fun otherLaunchers(apps: List<AppInfo>) =
+ apps.filter { a -> a.enabled && a.answersHome && !a.builtInLauncher && RECOMMENDED.none { it.pkg == a.packageName } }
+
data class LauncherActions(
val close: () -> Unit = {},
/** Opens the Store on the TV at that launcher's page, and watches for the install. */
@@ -89,6 +103,10 @@ data class LauncherActions(
val chooseAnother: (String) -> Unit = {},
/** Yes on the installed launcher, with its accessibility service or without. */
val switch: (service: Boolean) -> Unit = {},
+ /** Make Home in the picker, on a launcher already on the TV. */
+ val makeHome: (pkg: String, service: Boolean) -> Unit = { _, _ -> },
+ /** Open in the picker: shows that launcher on the TV. */
+ val open: (String) -> Unit = {},
val later: () -> Unit = {},
)
@@ -101,24 +119,34 @@ fun LauncherCard(current: String?, onNotNow: () -> Unit, onChoose: () -> Unit) {
/**
* Install a home screen, as one full screen: the picker, then the wait while the TV shows the
* Play Store, then the switch, which ends in the same yes for the accessibility service as Set as
- * default. A TV that didn't open the Store, and a Store closed without installing, each say so.
+ * default. A launcher already on the TV skips the Store: the picker offers Make Home or Open on it.
+ * A TV that didn't open the Store says so; a Store closed without installing goes back to the picker.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
-fun LauncherScreen(device: Device, flow: LauncherFlow, apps: List<AppInfo>, actions: LauncherActions) {
+fun LauncherScreen(
+ device: Device,
+ flow: LauncherFlow,
+ apps: List<AppInfo>,
+ actions: LauncherActions,
+ snackbar: SnackbarHostState = remember { SnackbarHostState() },
+) {
var chosen by rememberSaveable(flow.step, flow.pkg) { mutableStateOf(flow.pkg) }
var askService by rememberSaveable(flow.step) { mutableStateOf(false) }
val label = launcherName(flow.pkg)
- val app = apps.firstOrNull { it.packageName == flow.pkg }
+ val picking = flow.step == LauncherFlow.Step.Pick
+ val app = apps.firstOrNull { it.packageName == if (picking) chosen else flow.pkg }
val current = app?.let { homeLabel(apps, it) }
+ val switch = { service: Boolean -> if (picking) actions.makeHome(chosen, service) else actions.switch(service) }
if (askService && app != null && current != null) {
ServiceDialog(
app.label, current,
- onTurnOn = { actions.switch(true) },
- dismissLabel = Copy.SWITCH_WITHOUT, onOther = { actions.switch(false) }, onDismiss = { askService = false },
+ onTurnOn = { switch(true) },
+ dismissLabel = Copy.SWITCH_WITHOUT, onOther = { switch(false) }, onDismiss = { askService = false },
)
}
Scaffold(
+ snackbarHost = { SnackbarHost(snackbar) },
topBar = {
TopAppBar(
title = { Text(if (flow.step == LauncherFlow.Step.Pick) Copy.CHOOSE_HOME else Copy.INSTALL_HOME) },
@@ -132,10 +160,17 @@ fun LauncherScreen(device: Device, flow: LauncherFlow, apps: List<AppInfo>, acti
verticalAlignment = Alignment.CenterVertically,
) {
when (flow.step) {
- LauncherFlow.Step.Pick -> Button(onClick = { actions.install(chosen) }, contentPadding = ButtonDefaults.ButtonWithIconContentPadding) {
- Icon(OpenInNew, contentDescription = null, Modifier.size(18.dp))
- Spacer(Modifier.width(8.dp))
- Text(Copy.OPEN_IN_STORE)
+ LauncherFlow.Step.Pick -> {
+ val have = installedLauncher(apps, chosen)
+ when {
+ have == null -> IconButtonText(OpenInNew, Copy.OPEN_IN_STORE) { actions.install(chosen) }
+ // Home now, or a TV that can't take it as Home: only Open.
+ !have.home && current != null -> {
+ TextButton(onClick = { actions.open(chosen) }) { Text(Copy.OPEN) }
+ IconButtonText(Icons.Outlined.Home, Copy.MAKE_HOME) { if (have.homeService) askService = true else switch(false) }
+ }
+ else -> IconButtonText(DeviceIcons.Tv, Copy.OPEN) { actions.open(chosen) }
+ }
}
LauncherFlow.Step.Waiting -> TextButton(onClick = { actions.install(flow.pkg) }) { Text(Copy.OPEN_STORE_AGAIN) }
LauncherFlow.Step.Installed -> {
@@ -166,7 +201,7 @@ fun LauncherScreen(device: Device, flow: LauncherFlow, apps: List<AppInfo>, acti
}
val c = MaterialTheme.colorScheme
when (flow.step) {
- LauncherFlow.Step.Pick -> Picker(chosen) { chosen = it }
+ LauncherFlow.Step.Pick -> Picker(chosen, apps) { chosen = it }
LauncherFlow.Step.Waiting -> {
Hero(LauncherIcons.Download, c.secondaryContainer, c.onSecondaryContainer)
Headed(Copy.INSTALL_IT, bold(Copy.installItText(label), label, "Install"))
@@ -206,56 +241,109 @@ fun LauncherScreen(device: Device, flow: LauncherFlow, apps: List<AppInfo>, acti
}
}
-/** The four launchers as one segmented list, one chosen: rounded ends, small gaps, the chosen one filled. */
@Composable
-private fun Picker(chosen: String, onChoose: (String) -> Unit) {
+private fun IconButtonText(icon: ImageVector, text: String, onClick: () -> Unit) {
+ Button(onClick = onClick, contentPadding = ButtonDefaults.ButtonWithIconContentPadding) {
+ Icon(icon, contentDescription = null, Modifier.size(18.dp))
+ Spacer(Modifier.width(8.dp))
+ Text(text)
+ }
+}
+
+/**
+ * The recommended launchers as one segmented list, one chosen: rounded ends, small gaps, the chosen
+ * one filled. Above them, On this TV lists any other launcher someone added, when there is one.
+ * Rows never move: one on the TV carries an Installed or Home now chip where it stands.
+ */
+@Composable
+private fun Picker(chosen: String, apps: List<AppInfo>, onChoose: (String) -> Unit) {
val c = MaterialTheme.colorScheme
+ val others = otherLaunchers(apps)
Text(Copy.CHOOSE_HOME_TEXT, style = MaterialTheme.typography.bodyLarge)
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
+ if (others.isNotEmpty()) {
+ Text(Copy.ON_THIS_TV, style = MaterialTheme.typography.labelLarge, color = c.primary, modifier = Modifier.padding(bottom = 8.dp))
+ Column(Modifier.selectableGroup().padding(bottom = 20.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) {
+ others.forEachIndexed { i, a ->
+ PickRow(segment(i, others.lastIndex), a.packageName == chosen, a.label, a, vertical = 12.dp, onClick = { onChoose(a.packageName) })
+ }
+ }
+ }
Text(Copy.RECOMMENDED, style = MaterialTheme.typography.labelLarge, color = c.primary, modifier = Modifier.padding(bottom = 8.dp))
Column(Modifier.selectableGroup(), verticalArrangement = Arrangement.spacedBy(2.dp)) {
RECOMMENDED.forEachIndexed { i, l ->
- val big = 16.dp
- val small = 4.dp
- val shape = RoundedCornerShape(
- topStart = if (i == 0) big else small, topEnd = if (i == 0) big else small,
- bottomStart = if (i == RECOMMENDED.lastIndex) big else small, bottomEnd = if (i == RECOMMENDED.lastIndex) big else small,
- )
- val on = l.pkg == chosen
- Surface(
- shape = shape,
- color = if (on) c.secondaryContainer else c.surfaceContainer,
- modifier = Modifier.fillMaxWidth().selectable(on, role = Role.RadioButton) { onChoose(l.pkg) },
- ) {
- Row(Modifier.padding(start = 16.dp, top = 16.dp, bottom = 16.dp, end = 8.dp)) {
- Column(Modifier.weight(1f)) {
- Text(l.name, style = MaterialTheme.typography.bodyLarge)
- Text(l.about, style = MaterialTheme.typography.bodyMedium, color = c.onSurfaceVariant)
- Row(Modifier.padding(top = 4.dp), verticalAlignment = Alignment.CenterVertically) {
- Icon(if (l.accessibility) DeviceIcons.Accessibility else LauncherIcons.Code, null, Modifier.size(14.dp), tint = c.onSurfaceVariant)
- Spacer(Modifier.width(6.dp))
- Text(if (l.accessibility) Copy.USES_SERVICE else Copy.NO_SERVICE, style = MaterialTheme.typography.labelMedium, color = c.onSurfaceVariant)
- }
- }
- RadioButton(selected = on, onClick = null)
+ PickRow(segment(i, RECOMMENDED.lastIndex), l.pkg == chosen, l.name, installedLauncher(apps, l.pkg), onClick = { onChoose(l.pkg) }) {
+ Text(l.about, style = MaterialTheme.typography.bodyMedium, color = c.onSurfaceVariant)
+ Row(Modifier.padding(top = 4.dp), verticalAlignment = Alignment.CenterVertically) {
+ Icon(if (l.accessibility) DeviceIcons.Accessibility else LauncherIcons.Code, null, Modifier.size(14.dp), tint = c.onSurfaceVariant)
+ Spacer(Modifier.width(6.dp))
+ Text(if (l.accessibility) Copy.USES_SERVICE else Copy.NO_SERVICE, style = MaterialTheme.typography.labelMedium, color = c.onSurfaceVariant)
}
}
}
}
- Text(
- buildAnnotatedString {
- append(Copy.OTHER_LAUNCHER)
- withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { append(Copy.MAKE_HOME) }
- append(Copy.OTHER_LAUNCHER_WHERE)
- },
- style = MaterialTheme.typography.bodyMedium,
- color = c.onSurfaceVariant,
- modifier = Modifier.padding(top = 12.dp),
- )
+ Text(Copy.OTHER_LAUNCHER, style = MaterialTheme.typography.bodyMedium, color = c.onSurfaceVariant, modifier = Modifier.padding(top = 12.dp))
Text(Copy.NOT_AFFILIATED, style = MaterialTheme.typography.bodySmall, color = c.onSurfaceVariant, modifier = Modifier.padding(top = 12.dp))
}
}
+/** Row [i] of a segmented list ending at [last]: the ends rounded, the joins tight. */
+private fun segment(i: Int, last: Int): RoundedCornerShape {
+ val top = if (i == 0) 16.dp else 4.dp
+ val bottom = if (i == last) 16.dp else 4.dp
+ return RoundedCornerShape(topStart = top, topEnd = top, bottomStart = bottom, bottomEnd = bottom)
+}
+
+/** One launcher in the picker: its name, a chip when [have] is on the TV, then [details]. */
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+private fun PickRow(
+ shape: RoundedCornerShape,
+ on: Boolean,
+ name: String,
+ have: AppInfo?,
+ vertical: Dp = 16.dp,
+ onClick: () -> Unit,
+ details: @Composable () -> Unit = {},
+) {
+ val c = MaterialTheme.colorScheme
+ Surface(
+ shape = shape,
+ color = if (on) c.secondaryContainer else c.surfaceContainer,
+ modifier = Modifier.fillMaxWidth().selectable(on, role = Role.RadioButton, onClick = onClick),
+ ) {
+ Row(Modifier.padding(start = 16.dp, top = vertical, bottom = vertical, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {
+ Column(Modifier.weight(1f)) {
+ // The chip drops under the name rather than squeezing it at large font sizes.
+ FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(4.dp), itemVerticalAlignment = Alignment.CenterVertically) {
+ Text(name, style = MaterialTheme.typography.bodyLarge)
+ have?.let { InstalledChip(home = it.home) }
+ }
+ details()
+ }
+ RadioButton(selected = on, onClick = null)
+ }
+ }
+}
+
+/** Installed, outlined; Home now, filled, so it still stands out on the chosen row. */
+@Composable
+private fun InstalledChip(home: Boolean) {
+ val c = MaterialTheme.colorScheme
+ Surface(
+ shape = RoundedCornerShape(8.dp),
+ color = if (home) c.tertiary else Color.Transparent,
+ contentColor = if (home) c.onTertiary else c.onSurfaceVariant,
+ border = if (home) null else BorderStroke(1.dp, c.outline),
+ ) {
+ Row(Modifier.height(24.dp).padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
+ Icon(if (home) Icons.Outlined.Home else Icons.Default.Check, null, Modifier.size(14.dp))
+ Spacer(Modifier.width(4.dp))
+ Text(if (home) Copy.HOME_NOW else Copy.INSTALLED, style = MaterialTheme.typography.labelMedium)
+ }
+ }
+}
+
@Composable
private fun Hero(icon: ImageVector, bg: Color, fg: Color) {
Box(Modifier.size(64.dp).background(bg, CircleShape), contentAlignment = Alignment.Center) {
diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
index 0b39719..63aa7d4 100644
--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt
@@ -816,8 +816,9 @@ class TellyscopeViewModel(
/**
* Opens the Play Store on the TV at [pkg]'s page, then checks every few seconds whether it's
- * installed, or the Store has closed without it. Where the Store didn't open, it keeps
- * checking while the user searches by hand. After [STORE_WAIT_MS] without it, it stops at [LauncherFlow.Step.Left].
+ * installed, or the Store has closed without it, which goes back to the picker. Where the Store
+ * didn't open, it keeps checking while the user searches by hand. After [STORE_WAIT_MS] without it,
+ * it stops at [LauncherFlow.Step.Left].
*
* Known: a Google sign-in or consent screen inside the Store runs as another app
* (com.google.android.gms), so it can read as leaving the Store and end the wait early.
@@ -827,7 +828,7 @@ class TellyscopeViewModel(
val id = _state.value.selectedId ?: return
launcherJob?.cancel()
val step = { s: LauncherFlow.Step -> updateDevice(id) { it.copy(launcher = it.launcher?.let { _ -> LauncherFlow(s, pkg) }) } }
- // Already on the TV (picked from Tweaks after a launcher was added): no Store detour.
+ // Already on the TV, installed since the picker was drawn (Open Store again after the wait): no Store detour.
_state.value.device.apps.firstOrNull { it.packageName == pkg && it.enabled }?.let { have ->
if (have.homeInstead != null) {
step(LauncherFlow.Step.Installed)
@@ -878,7 +879,9 @@ class TellyscopeViewModel(
}
StoreState.InStore -> seen = true
StoreState.Elsewhere -> if (seen) {
- step(LauncherFlow.Step.Left)
+ // The Store closed without it: back to the picker, still chosen, and the snackbar says so.
+ step(LauncherFlow.Step.Pick)
+ _notice.value = Copy.wasntInstalled(launcherName(pkg))
return@launch
}
}
@@ -889,12 +892,23 @@ class TellyscopeViewModel(
/** Yes on the installed launcher, with its accessibility service or without; the flow closes and the switch runs. */
fun switchToLauncher(service: Boolean) {
+ makeHome(_state.value.device.launcher?.pkg ?: return, service)
+ }
+
+ /** Make Home on [pkg], from the picker or after its install: the flow closes and the switch runs. */
+ fun makeHome(pkg: String, service: Boolean) {
val id = _state.value.selectedId ?: return
- val pkg = _state.value.device.launcher?.pkg ?: return
+ launcherJob?.cancel()
updateDevice(id) { it.copy(launcher = null) }
run(pkg, Action.Home, id = id) { source.makeHome(it, pkg, service) }
}
+ /** Open in the picker: shows the launcher [pkg] on the TV. The picker stays. */
+ fun openLauncher(pkg: String) {
+ val label = _state.value.device.apps.firstOrNull { it.packageName == pkg }?.label ?: launcherName(pkg)
+ open(pkg, label)
+ }
+
/** Not now on the installed launcher: where to switch later. */
fun launcherLater() {
val pkg = _state.value.device.launcher?.pkg ?: return
@@ -1801,18 +1815,20 @@ class TellyscopeViewModel(
}
/** A dock tap: opens the app on the TV, without a history entry. */
- fun launch(app: Docked) {
+ fun launch(app: Docked) = open(app.packageName, app.label)
+
+ private fun open(pkg: String, label: String) {
val id = _state.value.selectedId ?: return
viewModelScope.launch {
val ok = try {
- source.launch(id, app.packageName)
+ source.launch(id, pkg)
} catch (e: CancellationException) {
throw e
} catch (_: Exception) {
_notice.value = Copy.REMOTE_LOST
return@launch
}
- if (!ok) _notice.value = Copy.cantOpen(app.label)
+ if (!ok) _notice.value = Copy.cantOpen(label)
}
}
diff --git a/app/src/test/java/app/tellyscope/LauncherFlowTest.kt b/app/src/test/java/app/tellyscope/LauncherFlowTest.kt
index 557c0c0..9b9b795 100644
--- a/app/src/test/java/app/tellyscope/LauncherFlowTest.kt
+++ b/app/src/test/java/app/tellyscope/LauncherFlowTest.kt
@@ -152,13 +152,25 @@ class LauncherFlowTest {
assertEquals(listOf(PROJECTIVY to false), source.switched)
}
- @Test fun aStoreThatClosesWithoutTheInstallSaysSo() = with(test) {
+ @Test fun aStoreThatClosesWithoutTheInstallGoesBackToThePicker() = with(test) {
source.states = ArrayDeque(listOf(StoreState.InStore, StoreState.Elsewhere))
started().installLauncher(PROJECTIVY)
advanceTimeBy(2 * STORE_POLL_MS + 1)
- assertEquals(LauncherFlow.Step.Left, step)
+ assertEquals(LauncherFlow(LauncherFlow.Step.Pick, PROJECTIVY), vm.state.value.device.launcher)
+ assertEquals(Copy.wasntInstalled("Projectivy Launcher"), vm.notice.value)
+ source.states = ArrayDeque(listOf(StoreState.Installed))
advanceTimeBy(10 * STORE_POLL_MS)
- assertEquals(LauncherFlow.Step.Left, step) // stopped checking
+ assertEquals(LauncherFlow.Step.Pick, step) // stopped checking
+ assertFalse(source.installed)
+ }
+
+ @Test fun makeHomeFromThePickerSwitchesWithoutTheStore() = with(test) {
+ source.installed = true
+ started().makeHome(PROJECTIVY, service = true)
+ runCurrent()
+ assertNull(step)
+ assertTrue(source.opened.isEmpty())
+ assertEquals(listOf(PROJECTIVY to true), source.switched)
}
@Test fun aStoreThatDidntOpenSaysSoAndStillCatchesAnInstallByHand() = with(test) {
@@ -313,6 +325,42 @@ class LauncherScreenTest {
assertEquals(listOf(PROJECTIVY), picks)
}
+ @Test fun aLauncherOnTheTvOffersMakeHomeAndOpenInsteadOfTheStore() {
+ val homes = mutableListOf<Pair<String, Boolean>>()
+ val opens = mutableListOf<String>()
+ val flauncher = AppInfo(FLAUNCHER, "FLauncher", null, false, true, null, "1.0", removable = true, answersHome = true, homeInstead = TV_HOME)
+ compose.setContent {
+ LauncherScreen(tv, LauncherFlow(pkg = FLAUNCHER), listOf(store, stock, flauncher), LauncherActions(makeHome = { p, s -> homes += p to s }, open = { opens += it }))
+ }
+ compose.onNodeWithText(Copy.INSTALLED).assertExists()
+ compose.onNodeWithText(Copy.OPEN_IN_STORE).assertDoesNotExist()
+ compose.onNodeWithText(Copy.OPEN).performClick()
+ compose.onNodeWithText(Copy.MAKE_HOME).performClick()
+ assertEquals(listOf(FLAUNCHER), opens)
+ assertEquals(listOf(FLAUNCHER to false), homes)
+ }
+
+ @Test fun theLauncherOnHomeOffersOnlyOpen() {
+ val flauncher = AppInfo(FLAUNCHER, "FLauncher", null, false, true, null, "1.0", removable = true, answersHome = true, home = true, homeBack = "Google TV Home")
+ compose.setContent { LauncherScreen(tv, LauncherFlow(pkg = FLAUNCHER), listOf(store, stock.copy(home = false), flauncher), LauncherActions()) }
+ compose.onNodeWithText(Copy.HOME_NOW).assertExists()
+ compose.onNodeWithText(Copy.OPEN).assertExists()
+ compose.onNodeWithText(Copy.MAKE_HOME).assertDoesNotExist()
+ }
+
+ @Test fun aLauncherNotRecommendedIsListedOnThisTv() {
+ val wolf = AppInfo("com.wolf.firelauncher", "Wolf Launcher", null, false, true, null, "1.0", removable = true, answersHome = true, homeInstead = TV_HOME)
+ compose.setContent { LauncherScreen(tv, LauncherFlow(), listOf(store, stock, wolf), LauncherActions()) }
+ compose.onNodeWithText(Copy.ON_THIS_TV).assertExists()
+ compose.onNodeWithText("Wolf Launcher").performClick()
+ compose.onNodeWithText(Copy.MAKE_HOME).assertExists()
+ }
+
+ @Test fun noOtherLauncherNoOnThisTv() {
+ compose.setContent { LauncherScreen(tv, LauncherFlow(), listOf(store, stock), LauncherActions()) }
+ compose.onNodeWithText(Copy.ON_THIS_TV).assertDoesNotExist()
+ }
+
@Test fun yesOnAServiceLauncherAsksAboutTheService() {
val switches = mutableListOf<Boolean>()
val projectivy = AppInfo(PROJECTIVY, "Projectivy Launcher", null, false, true, null, "1.0", homeInstead = TV_HOME, homeService = true)