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.
Android TV: offer Download directly beside the Play Store
jesse-agent-23201118808dfc7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e3bb49a..696d2da 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,7 @@ until this file has a section for its version.- **Fixed:** On Fire TV, Make Home sets Projectivy as Home through its accessibility service. [#235](../../pull/235)- **Fixed:** The Projectivy install dialog on Fire TV closes when the install finishes. [#235](../../pull/235)+- **New:** On Android TV, Projectivy can also be downloaded directly, after a warning. [#PR](../../pull/PR)## 0.13.0 — 2026-10-29diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.ktindex 68d981a..47c1790 100644--- a/app/src/main/java/app/tellyscope/MainActivity.kt+++ b/app/src/main/java/app/tellyscope/MainActivity.kt@@ -347,6 +347,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {fireDismiss = vm::dismissProjectivy,),snackbar = snackbar,+ direct = vm.directDownload,)} 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.ktindex 254e6ad..eb0c07b 100644--- a/app/src/main/java/app/tellyscope/ui/Copy.kt+++ b/app/src/main/java/app/tellyscope/ui/Copy.kt@@ -183,6 +183,8 @@ object Copy {const val INSTALL_ONE = "Install it"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."+ /** After [CHOOSE_HOME_TEXT] when Download directly is offered. */+ const val CAN_DOWNLOAD = "Some can also be downloaded directly."const val NO_LAUNCHER_LIST = "Couldn't load the list of home screens. Check the phone's internet and try again."const val RECOMMENDED = "Recommended"/** The picker's section for launchers on the TV that Recommended doesn't list. */@@ -196,7 +198,9 @@ object Copy {/** 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 GET_FROM_STORE = "Get it from Play Store"+ const val STORE_RECOMMENDED = "Play Store recommended: it updates itself"+ const val DOWNLOAD_DIRECTLY = "Download directly"const val INSTALL_HOME = "Install a home screen"const val INSTALL_IT = "Install it on your TV"@@ -236,12 +240,23 @@ object Copy {fun installProjectivyOn(tv: String) = "Install Projectivy on $tv?"- fun downloadsFrom(name: String, version: String, size: Long) = "Tellyscope downloads $name $version (${bytes(size)}) from:"+ fun downloadsFrom(name: String) = "Tellyscope downloads $name from the developer's own release page:"++ fun release(version: String, size: Long) = "Release $version · ${bytes(size)}"const val SIGNED_CHECK ="and checks it's signed by Projectivy's developer before installing it on the TV. Tellyscope isn't affiliated with Projectivy."const val DOWNLOAD_AND_INSTALL = "Download and install"+ /** Download directly on a TV with the Play Store: what Tellyscope checks, what it doesn't, and the safer way. */+ fun downloadDirectly(name: String) = "Download $name directly?"++ const val DIRECT_CHECK =+ "Tellyscope checks the app carries the developer's signature. It does not scan the app for malicious code, and the app won't update on its own."+ const val STORE_SAFER = "Getting it from Play Store is safer and keeps it updated."+ const val DOWNLOAD_ANYWAY = "Download anyway"+ const val STORE_INSTEAD = "Get it from the Play Store on the TV instead."+fun downloading(percent: Int) = "Downloading · $percent%"fun installingOn(tv: String) = "Installing on $tv…"diff --git a/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.kt b/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.ktindex 7cdedcb..393c349 100644--- a/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.kt+++ b/app/src/main/java/app/tellyscope/ui/LauncherFlowUi.kt@@ -6,7 +6,6 @@ package app.tellyscope.uiimport androidx.compose.foundation.BorderStrokeimport androidx.compose.foundation.background-import androidx.compose.foundation.clickableimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Column@@ -41,7 +40,9 @@ import androidx.compose.material3.Iconimport androidx.compose.material3.IconButtonimport androidx.compose.material3.LinearWavyProgressIndicatorimport androidx.compose.material3.LoadingIndicator+import androidx.compose.material3.MaterialShapesimport androidx.compose.material3.MaterialTheme+import androidx.compose.material3.OutlinedButtonimport androidx.compose.material3.RadioButtonimport androidx.compose.material3.Scaffoldimport androidx.compose.material3.SnackbarHost@@ -50,6 +51,7 @@ import androidx.compose.material3.Surfaceimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.material3.TopAppBar+import androidx.compose.material3.toShapeimport androidx.compose.runtime.Composableimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOf@@ -58,6 +60,7 @@ import androidx.compose.runtime.saveable.rememberSaveableimport androidx.compose.runtime.setValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clipimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.graphics.PathFillTypeimport androidx.compose.ui.graphics.SolidColor@@ -69,12 +72,13 @@ import androidx.compose.ui.text.AnnotatedStringimport androidx.compose.ui.text.SpanStyleimport androidx.compose.ui.text.buildAnnotatedStringimport androidx.compose.ui.text.font.FontWeight-import androidx.compose.ui.text.style.TextDecoration+import androidx.compose.ui.text.style.TextOverflowimport androidx.compose.ui.unit.Dpimport androidx.compose.ui.unit.dpimport app.tellyscope.data.Actionimport app.tellyscope.data.AppInfoimport app.tellyscope.data.Device+import app.tellyscope.data.LauncherReleaseimport app.tellyscope.data.PROJECTIVYimport app.tellyscope.data.PROJECTIVY_RELEASESimport app.tellyscope.data.isFireOs@@ -106,6 +110,9 @@ internal fun offerChoose(apps: List<AppInfo>, fire: Boolean = false) = (hasPlaySinternal fun offerLauncher(apps: List<AppInfo>, hidden: Boolean, fire: Boolean = false) =!hidden && offerChoose(apps, fire) && apps.none { it.homeInstead != null || it.homeBack != null }+/** Download directly is offered on [pkg] beside the Store: only launchers whose download and signer are pinned. */+internal fun downloadable(pkg: String) = pkg == PROJECTIVY+/** [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 }@@ -148,7 +155,8 @@ fun LauncherCard(current: String?, onNotNow: () -> Unit, onChoose: () -> Unit, f* Play Store, then the switch, which ends in the same yes for the accessibility service as Set as* 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.- * On Fire OS ([LauncherFlow.fire]) the picker is Projectivy alone, which Tellyscope downloads and installs.+ * On Fire OS ([LauncherFlow.fireOs]) the picker is Projectivy alone, which Tellyscope downloads and installs.+ * [direct]: a launcher that is [downloadable] also offers Download directly, under the Store and after a warning.*/@OptIn(ExperimentalMaterial3Api::class)@Composable@@ -158,6 +166,7 @@ fun LauncherScreen(apps: List<AppInfo>,actions: LauncherActions,snackbar: SnackbarHostState = remember { SnackbarHostState() },+ direct: Boolean = false,) {var chosen by rememberSaveable(flow.step, flow.pkg) { mutableStateOf(flow.pkg) }var askService by rememberSaveable(flow.step) { mutableStateOf(false) }@@ -181,7 +190,7 @@ fun LauncherScreen(title = {Text(when {- flow.fire != null -> Copy.INSTALL_PROJECTIVY+ flow.fireOs -> Copy.INSTALL_PROJECTIVYflow.step == LauncherFlow.Step.Pick -> Copy.CHOOSE_HOMEelse -> Copy.INSTALL_HOME},@@ -197,12 +206,25 @@ fun LauncherScreen(verticalAlignment = Alignment.CenterVertically,) {when (flow.step) {- LauncherFlow.Step.Pick -> if (flow.fire != null) {- IconButtonText(LauncherIcons.Download, Copy.INSTALL_PROJECTIVY, enabled = flow.fire.step == null) { actions.fireCheck() }+ LauncherFlow.Step.Pick -> if (flow.fireOs) {+ IconButtonText(LauncherIcons.Download, Copy.INSTALL_PROJECTIVY, enabled = flow.fire?.step == null) { actions.fireCheck() }} else {val have = installedLauncher(apps, chosen)when {- have == null -> IconButtonText(OpenInNew, Copy.OPEN_IN_STORE) { actions.install(chosen) }+ have == null -> Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp)) {+ val both = direct && downloadable(chosen)+ if (both) {+ Row(Modifier.align(Alignment.CenterHorizontally), verticalAlignment = Alignment.CenterVertically) {+ Icon(Icons.Default.Check, null, Modifier.size(16.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)+ Spacer(Modifier.width(6.dp))+ Text(Copy.STORE_RECOMMENDED, style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)+ }+ }+ IconButtonText(OpenInNew, Copy.GET_FROM_STORE, Modifier.fillMaxWidth()) { actions.install(chosen) }+ if (both) {+ OutlinedButton(onClick = actions.fireCheck, enabled = flow.fire == null, modifier = Modifier.fillMaxWidth()) { Text(Copy.DOWNLOAD_DIRECTLY) }+ }+ }// 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) }@@ -240,7 +262,7 @@ fun LauncherScreen(}val c = MaterialTheme.colorSchemewhen (flow.step) {- LauncherFlow.Step.Pick -> if (flow.fire != null) FirePick() else Picker(chosen, apps) { chosen = it }+ LauncherFlow.Step.Pick -> if (flow.fireOs) FirePick() else Picker(chosen, apps, direct) { chosen = it }LauncherFlow.Step.Waiting -> {Hero(LauncherIcons.Download, c.secondaryContainer, c.onSecondaryContainer)Headed(Copy.INSTALL_IT, bold(Copy.installItText(label), label, "Install"))@@ -282,8 +304,8 @@ fun LauncherScreen(}@Composable-private fun IconButtonText(icon: ImageVector, text: String, enabled: Boolean = true, onClick: () -> Unit) {- Button(onClick = onClick, enabled = enabled, contentPadding = ButtonDefaults.ButtonWithIconContentPadding) {+private fun IconButtonText(icon: ImageVector, text: String, modifier: Modifier = Modifier, enabled: Boolean = true, onClick: () -> Unit) {+ Button(onClick = onClick, modifier = modifier, enabled = enabled, contentPadding = ButtonDefaults.ButtonWithIconContentPadding) {Icon(icon, contentDescription = null, Modifier.size(18.dp))Spacer(Modifier.width(8.dp))Text(text)@@ -296,10 +318,11 @@ private fun IconButtonText(icon: ImageVector, text: String, enabled: Boolean = t* 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) {+private fun Picker(chosen: String, apps: List<AppInfo>, direct: Boolean, onChoose: (String) -> Unit) {val c = MaterialTheme.colorSchemeval others = otherLaunchers(apps)- Text(Copy.CHOOSE_HOME_TEXT, style = MaterialTheme.typography.bodyLarge)+ val canDownload = direct && RECOMMENDED.any { downloadable(it.pkg) && installedLauncher(apps, it.pkg) == null }+ Text(if (canDownload) Copy.CHOOSE_HOME_TEXT + " " + Copy.CAN_DOWNLOAD else 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))@@ -347,26 +370,28 @@ private fun FirePick() {}/**- * Fire OS's install, one dialog per [FireInstall.Step]: where it downloads from, the link opening that release- * page on the phone, then the download and the install with no way out, then what went wrong.+ * Fire OS's install, one dialog per [FireInstall.Step]: where it downloads from, the source row opening that release+ * page on the phone, then the download and the install with no way out, then what went wrong. After Download+ * directly ([FireInstall.store]) the confirm is a warning, and it and a wrong signature offer the Play Store instead.*/@OptIn(ExperimentalMaterial3ExpressiveApi::class)@Composableprivate fun FireDialog(f: FireInstall, device: Device, actions: LauncherActions) {val step = f.step?.takeIf { it != FireInstall.Step.Checking } ?: return- val c = MaterialTheme.colorSchemeval uri = LocalUriHandler.currentval label = launcherName(PROJECTIVY)val release = f.releaseval failed = step == FireInstall.Step.NotProjectivy || step == FireInstall.Step.NoDownload || step == FireInstall.Step.Refused+ val warn = step == FireInstall.Step.Confirm && f.store+ val store = { actions.install(PROJECTIVY) }AlertDialog(onDismissRequest = {},properties = Sticky,- icon = if (failed) ({ Icon(Icons.Default.Warning, null) }) else null,+ icon = if (failed || warn) ({ WarningBadge() }) else null,title = {Text(when (step) {- FireInstall.Step.Confirm -> Copy.installProjectivyOn(name(device))+ FireInstall.Step.Confirm -> if (f.store) Copy.downloadDirectly(label) else Copy.installProjectivyOn(name(device))FireInstall.Step.NotProjectivy -> Copy.NOT_PROJECTIVYFireInstall.Step.NoDownload -> Copy.NO_DOWNLOADFireInstall.Step.Refused -> "Couldn't install $label"@@ -378,22 +403,21 @@ private fun FireDialog(f: FireInstall, device: Device, actions: LauncherActions)Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {when (step) {FireInstall.Step.Confirm -> if (release != null) {- Text(Copy.downloadsFrom(label, release.version, release.size), style = MaterialTheme.typography.bodyMedium)- Row(Modifier.clickable(role = Role.Button) { uri.openUri(release.page) }, horizontalArrangement = Arrangement.spacedBy(6.dp)) {- Icon(OpenInNew, null, Modifier.size(18.dp), tint = c.primary)- Text(- release.page.removePrefix("https://"),- style = MaterialTheme.typography.bodyMedium.copy(textDecoration = TextDecoration.Underline),- color = c.primary,- )+ Text(Copy.downloadsFrom(label), style = MaterialTheme.typography.bodyMedium)+ SourceRow(release) { uri.openUri(release.page) }+ if (f.store) {+ Text(Copy.DIRECT_CHECK, style = MaterialTheme.typography.bodyMedium)+ Text(Copy.STORE_SAFER, style = MaterialTheme.typography.bodyMedium)+ } else {+ Text(Copy.SIGNED_CHECK, style = MaterialTheme.typography.bodyMedium)}- Text(Copy.SIGNED_CHECK, style = MaterialTheme.typography.bodyMedium)}FireInstall.Step.Downloading, FireInstall.Step.Installing -> {+ val c = MaterialTheme.colorSchemeColumn {Text(PROJECTIVY, style = SmallNumber, color = c.onSurfaceVariant)release?.let { Text("Version ${it.version} · ${Copy.bytes(it.size)}", style = SmallNumber, color = c.onSurfaceVariant) }- Text("from " + PROJECTIVY_RELEASES.removePrefix("https://").removeSuffix("/releases"), style = SmallNumber, color = c.onSurfaceVariant)+ Text("from " + PROJECTIVY_SOURCE, style = SmallNumber, color = c.onSurfaceVariant)}val p = f.progress?.fraction// Past the last byte the TV is still unpacking: no bar stuck at 100%.@@ -405,7 +429,10 @@ private fun FireDialog(f: FireInstall, device: Device, actions: LauncherActions))Text(Copy.INSTALL_KEEP_OPEN, style = MaterialTheme.typography.bodySmall, color = c.onSurfaceVariant)}- FireInstall.Step.NotProjectivy -> Text(Copy.NOT_PROJECTIVY_TEXT, style = MaterialTheme.typography.bodyMedium)+ FireInstall.Step.NotProjectivy -> {+ Text(Copy.NOT_PROJECTIVY_TEXT, style = MaterialTheme.typography.bodyMedium)+ if (f.store) Text(Copy.STORE_INSTEAD, style = MaterialTheme.typography.bodyMedium)+ }FireInstall.Step.NoDownload -> Text(Copy.NO_DOWNLOAD_TEXT, style = MaterialTheme.typography.bodyMedium)FireInstall.Step.Refused -> Text(f.error.orEmpty(), style = MaterialTheme.typography.bodyMedium)FireInstall.Step.Checking -> Unit@@ -414,15 +441,29 @@ private fun FireDialog(f: FireInstall, device: Device, actions: LauncherActions)},confirmButton = {when (step) {- FireInstall.Step.Confirm -> Button(onClick = actions.fireInstall) { Text(Copy.DOWNLOAD_AND_INSTALL) }- FireInstall.Step.NotProjectivy, FireInstall.Step.NoDownload -> Button(onClick = actions.fireCheck) { Text(Copy.TRY_AGAIN) }+ // The safe way first and filled; the download only as the outlined second.+ FireInstall.Step.Confirm -> if (f.store) {+ Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {+ IconButtonText(OpenInNew, Copy.GET_FROM_STORE, Modifier.fillMaxWidth(), onClick = store)+ OutlinedButton(onClick = actions.fireInstall, modifier = Modifier.fillMaxWidth()) { Text(Copy.DOWNLOAD_ANYWAY) }+ TextButton(onClick = actions.fireDismiss, modifier = Modifier.fillMaxWidth()) { Text("Cancel") }+ }+ } else {+ Button(onClick = actions.fireInstall) { Text(Copy.DOWNLOAD_AND_INSTALL) }+ }+ FireInstall.Step.NotProjectivy -> if (f.store) {+ IconButtonText(OpenInNew, Copy.GET_FROM_STORE, onClick = store)+ } else {+ Button(onClick = actions.fireCheck) { Text(Copy.TRY_AGAIN) }+ }+ FireInstall.Step.NoDownload -> Button(onClick = actions.fireCheck) { Text(Copy.TRY_AGAIN) }FireInstall.Step.Refused -> Button(onClick = actions.fireDismiss) { Text("OK") }else -> Unit}},dismissButton = {when (step) {- FireInstall.Step.Confirm -> TextButton(onClick = actions.fireDismiss) { Text("Cancel") }+ FireInstall.Step.Confirm -> if (!f.store) TextButton(onClick = actions.fireDismiss) { Text("Cancel") }FireInstall.Step.NotProjectivy -> TextButton(onClick = actions.fireDismiss) { Text("Close") }FireInstall.Step.NoDownload -> TextButton(onClick = { actions.fireDismiss(); uri.openUri(release?.page ?: PROJECTIVY_RELEASES) }) {Text(Copy.OPEN_DOWNLOAD_PAGE)@@ -433,6 +474,42 @@ private fun FireDialog(f: FireInstall, device: Device, actions: LauncherActions))}+/** Projectivy's repo, as the source row and the progress dialog name it. */+private val PROJECTIVY_SOURCE = PROJECTIVY_RELEASES.removePrefix("https://").removeSuffix("/releases")++/** Where the download comes from, as one tappable row: the repo, then the release and its size; it opens the release page. */+@Composable+private fun SourceRow(release: LauncherRelease, onOpen: () -> Unit) {+ val c = MaterialTheme.colorScheme+ Surface(+ onClick = onOpen,+ shape = MaterialTheme.shapes.medium,+ color = c.surfaceContainerHighest,+ modifier = Modifier.fillMaxWidth(),+ ) {+ Row(Modifier.padding(horizontal = 12.dp, vertical = 10.dp), verticalAlignment = Alignment.CenterVertically) {+ Icon(LauncherIcons.Code, null, Modifier.size(20.dp), tint = c.onSurfaceVariant)+ Spacer(Modifier.width(12.dp))+ Column(Modifier.weight(1f)) {+ Text(PROJECTIVY_SOURCE, style = MaterialTheme.typography.bodyMedium, color = c.primary, maxLines = 1, overflow = TextOverflow.Ellipsis)+ Text(Copy.release(release.version, release.size), style = MaterialTheme.typography.bodySmall, color = c.onSurfaceVariant)+ }+ Spacer(Modifier.width(8.dp))+ Icon(OpenInNew, null, Modifier.size(18.dp), tint = c.primary)+ }+ }+}++/** The warning and the failures: a filled warning in the error colour's cookie, so it reads at a glance. */+@OptIn(ExperimentalMaterial3ExpressiveApi::class)+@Composable+private fun WarningBadge() {+ val c = MaterialTheme.colorScheme+ Box(Modifier.size(56.dp).clip(MaterialShapes.Cookie9Sided.toShape()).background(c.errorContainer), contentAlignment = Alignment.Center) {+ Icon(Icons.Default.Warning, null, Modifier.size(32.dp), tint = c.onErrorContainer)+ }+}+/** 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.dpdiff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.ktindex 7882dc5..8df3ea8 100644--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt@@ -175,6 +175,9 @@ data class ResetUi(*/data class LauncherFlow(val step: Step = Step.Pick, val pkg: String = RECOMMENDED.first().pkg, val fire: FireInstall? = null) {enum class Step { Pick, Waiting, NoStore, Left, Installed }++ /** Fire OS: Projectivy alone, with no Play Store; not Download directly beside the Store ([FireInstall.store]). */+ val fireOs get() = fire != null && !fire.store}/**@@ -182,12 +185,15 @@ data class LauncherFlow(val step: Step = Step.Pick, val pkg: String = RECOMMENDE* Play Store, so Tellyscope reads the latest release ([Step.Checking]), asks ([Step.Confirm]), downloads and* checks it ([Step.Downloading]), installs it over adb ([Step.Installing]), then moves to [LauncherFlow.Step.Installed].* A null [step] is the screen with no dialog. [error] is the TV's refusal, for [Step.Refused].+ * [store]: Download directly on a TV with the Play Store, from the picker ([downloadable]); its dialogs offer the+ * Store instead, and closing one goes back to the picker.*/data class FireInstall(val step: Step? = null,val release: LauncherRelease? = null,val progress: Progress? = null,val error: String? = null,+ val store: Boolean = false,) {enum class Step { Checking, Confirm, Downloading, Installing, NotProjectivy, NoDownload, Refused }}@@ -855,21 +861,28 @@ class TellyscopeViewModel(private fun setFire(id: String, f: (FireInstall) -> FireInstall) =updateDevice(id) { d -> d.copy(launcher = d.launcher?.let { l -> l.fire?.let { l.copy(fire = f(it)) } }) }- /** Install Projectivy on Fire OS: reads the latest release, for the confirm dialog to show where it comes from. */+ /** Download directly is offered beside the Play Store: there's a way to download, as on Fire OS. */+ val directDownload get() = launcherDownload != null++ /**+ * Install Projectivy on Fire OS, or Download directly in the picker: reads the latest release, for the+ * confirm dialog to show where it comes from.+ */fun checkProjectivy() {val id = _state.value.selectedId ?: returnval download = launcherDownload ?: return+ val store = _state.value.device.launcher?.let { it.fire?.store ?: true } ?: returnlauncherJob?.cancel()- setFire(id) { FireInstall(FireInstall.Step.Checking) }+ updateDevice(id) { d -> d.copy(launcher = d.launcher?.copy(pkg = PROJECTIVY, fire = FireInstall(FireInstall.Step.Checking, store = store))) }launcherJob = viewModelScope.launch {val release = try {download.latest()} catch (e: CancellationException) {throw e} catch (_: Exception) {- return@launch setFire(id) { FireInstall(FireInstall.Step.NoDownload) }+ return@launch setFire(id) { FireInstall(FireInstall.Step.NoDownload, store = store) }}- setFire(id) { FireInstall(FireInstall.Step.Confirm, release) }+ setFire(id) { FireInstall(FireInstall.Step.Confirm, release, store = store) }}}@@ -904,7 +917,7 @@ class TellyscopeViewModel(when (result) {// The install dialog closes with it: Installing would keep it up, and Close and Cancel wait on that.InstallResult.Done -> launcherInstalled(id, PROJECTIVY) { step ->- updateDevice(id) { it.copy(launcher = it.launcher?.copy(step = step, fire = FireInstall())) }+ updateDevice(id) { it.copy(launcher = it.launcher?.let { l -> l.copy(step = step, fire = if (l.fire?.store == true) null else FireInstall()) }) }}is InstallResult.Refused -> setFire(id) {it.copy(step = FireInstall.Step.Refused, error = Copy.installRefused(result.reason, launcherName(PROJECTIVY)))@@ -913,12 +926,12 @@ class TellyscopeViewModel(}}- /** Cancel, Close or OK on a Fire OS dialog: back to the screen. Not while the install runs. */+ /** Cancel, Close or OK on a Fire OS dialog: back to the screen, or to the picker after Download directly. Not while the install runs. */fun dismissProjectivy() {val id = _state.value.selectedId ?: returnif (_state.value.device.launcher?.fire?.step == FireInstall.Step.Installing) returnlauncherJob?.cancel()- setFire(id) { FireInstall() }+ updateDevice(id) { d -> d.copy(launcher = d.launcher?.let { l -> l.copy(fire = if (l.fire?.store == true) null else FireInstall()) }) }}/** Not now on the Apps tab's card: it stays away on this TV, and Tweaks keeps the way in. */diff --git a/app/src/test/java/app/tellyscope/FireOsTest.kt b/app/src/test/java/app/tellyscope/FireOsTest.ktindex fd4ea76..57307ee 100644--- a/app/src/test/java/app/tellyscope/FireOsTest.kt+++ b/app/src/test/java/app/tellyscope/FireOsTest.kt@@ -85,16 +85,16 @@ private fun release(assets.joinToString { (name, url) -> """{"name": "$name", "browser_download_url": "$url", "size": $size}""" }}]}"""-/** A Fire TV with no Play Store, which takes whatever Tellyscope installs. */-private class FireTv : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scenario.Empty, clock = { 0L }) {+/** A Fire TV with no Play Store, which takes whatever Tellyscope installs; or [tv] with [own] on it. */+private class FireTv(val tv: Device = amazon, val own: List<AppInfo> = listOf(fireHome)) : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scenario.Empty, clock = { 0L }) {val installs = mutableListOf<ApkInfo>()var refuse: InstallResult? = null- override suspend fun known() = listOf(amazon)+ override suspend fun known() = listOf(tv)override fun live(deviceId: String): Flow<Snapshot> = emptyFlow()override suspend fun suggestions(deviceId: String, apps: suspend () -> List<AppInfo>) = Suggestions.Unavailableoverride suspend fun history(deviceId: String) = emptyList<HistoryEntry>()- override suspend fun apps(deviceId: String) = listOf(fireHome) ++ override suspend fun apps(deviceId: String) = own +if (installs.isEmpty()) emptyList() else listOf(AppInfo(PROJECTIVY, "Projectivy Launcher", null, false, true, null, "1.0", homeInstead = FIRE_TV_LAUNCHER, homeService = true))override suspend fun install(deviceId: String, apks: List<File>, apk: ApkInfo, allowDowngrade: Boolean, onProgress: (Progress) -> Unit): InstallResult {@@ -121,7 +121,7 @@ private class FakeDownload(var signedByDeveloper: Boolean = true) : LauncherDownclass FireOsTest {private val dispatcher = StandardTestDispatcher()private val test = TestScope(dispatcher)- private val source = FireTv()+ private var source = FireTv()private val download = FakeDownload()private var vm: TellyscopeViewModel? = null@@ -225,4 +225,35 @@ class FireOsTest {assertEquals(FireInstall.Step.NotProjectivy, v.state.value.device.launcher?.fire?.step)assertEquals(LauncherFlow.Step.Pick, v.state.value.device.launcher?.step)}++ @Test fun withThePlayStoreDownloadDirectlyWarnsFirstThenInstalls() = with(test) {+ source = FireTv(androidTv, listOf(store, tvHome))+ val v = opened()+ assertNull(v.state.value.device.launcher?.fire)+ assertTrue(v.directDownload)++ v.checkProjectivy()+ runCurrent()+ val warning = v.state.value.device.launcher?.fire+ assertEquals(FireInstall.Step.Confirm, warning?.step)+ assertEquals(true, warning?.store)+ assertTrue(source.installs.isEmpty())++ v.installProjectivy()+ runCurrent()+ assertEquals(listOf(PROJECTIVY), source.installs.map { it.packageName })+ assertEquals(LauncherFlow.Step.Installed, v.state.value.device.launcher?.step)+ assertNull(v.state.value.device.launcher?.fire)+ }++ @Test fun cancellingTheWarningGoesBackToThePicker() = with(test) {+ source = FireTv(androidTv, listOf(store, tvHome))+ val v = opened()+ v.checkProjectivy()+ runCurrent()+ v.dismissProjectivy()+ assertEquals(LauncherFlow.Step.Pick, v.state.value.device.launcher?.step)+ assertNull(v.state.value.device.launcher?.fire)+ assertEquals(0, download.fetched)+ }}diff --git a/app/src/test/java/app/tellyscope/LauncherFlowTest.kt b/app/src/test/java/app/tellyscope/LauncherFlowTest.ktindex 9b9b795..8f040ba 100644--- a/app/src/test/java/app/tellyscope/LauncherFlowTest.kt+++ b/app/src/test/java/app/tellyscope/LauncherFlowTest.kt@@ -308,10 +308,32 @@ class LauncherScreenTest {val installs = mutableListOf<String>()compose.setContent { LauncherScreen(tv, LauncherFlow(), listOf(store, stock), LauncherActions(install = { installs += it })) }compose.onNodeWithText("FLauncher").performScrollTo().performClick() // under the bottom bar on a small screen- compose.onNodeWithText(Copy.OPEN_IN_STORE).performClick()+ compose.onNodeWithText(Copy.GET_FROM_STORE).performClick()assertEquals(listOf(FLAUNCHER), installs)}+ @Test fun theStoreComesFirstAndOnlyAPinnedLauncherDownloadsDirectly() {+ val installs = mutableListOf<String>()+ var downloads = 0+ compose.setContent {+ LauncherScreen(tv, LauncherFlow(pkg = PROJECTIVY), listOf(store, stock), LauncherActions(install = { installs += it }, fireCheck = { downloads++ }), direct = true)+ }+ compose.onNodeWithText(Copy.STORE_RECOMMENDED).assertExists()+ compose.onNodeWithText(Copy.DOWNLOAD_DIRECTLY).performClick()+ compose.onNodeWithText(Copy.GET_FROM_STORE).performClick()+ assertEquals(1, downloads)+ assertEquals(listOf(PROJECTIVY), installs)+ compose.onNodeWithText("FLauncher").performScrollTo().performClick()+ compose.onNodeWithText(Copy.DOWNLOAD_DIRECTLY).assertDoesNotExist()+ compose.onNodeWithText(Copy.GET_FROM_STORE).assertExists()+ }++ @Test fun withoutADownloadOnlyTheStoreIsOffered() {+ compose.setContent { LauncherScreen(tv, LauncherFlow(pkg = PROJECTIVY), listOf(store, stock), LauncherActions()) }+ compose.onNodeWithText(Copy.DOWNLOAD_DIRECTLY).assertDoesNotExist()+ compose.onNodeWithText(Copy.STORE_RECOMMENDED).assertDoesNotExist()+ }+@Test fun theStoreDidntOpenOffersAnotherOrARetry() {val installs = mutableListOf<String>()val picks = mutableListOf<String>()@@ -333,7 +355,7 @@ class LauncherScreenTest {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.GET_FROM_STORE).assertDoesNotExist()compose.onNodeWithText(Copy.OPEN).performClick()compose.onNodeWithText(Copy.MAKE_HOME).performClick()assertEquals(listOf(FLAUNCHER), opens)