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.
Report a problem and Help add this TV
jesse-agent-232d125318d7edb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c5c9ad5..e6f56a7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ until this file has a section for its version.## 0.8.0 — 2026-10-25+- **New:** Report a problem or help add your TV: GitHub opens with the report filled in. [#127](../../pull/127)- **New:** About shows the app's version and its GitHub page. [#125](../../pull/125)- **New:** Dock up to four apps on the Remote, one tap to open. [#120](../../pull/120)- **Improved:** Restart TV sits in the Remote's top bar and waits with you. [#120](../../pull/120)diff --git a/NOTICE b/NOTICEindex d9aaa92..b239b09 100644--- a/NOTICE+++ b/NOTICE@@ -29,6 +29,8 @@ Upload files button that of "upload", the empty Movies folder that of"movie", the links in Settings that of "open_in_new", and the Remote'srestart, waiting, can't-reach and dock menu icons those of "restart_alt","hourglass_top", "link_off", "swap_horiz" and "remove_circle_outline".+Report a problem, Help add this TV and Add the rest use those of+"bug_report", "add_to_queue" and "content_copy".--------------------------------------------------------------------------------Store badges in docs/badges/ (README only, not in the app)diff --git a/app/src/main/java/app/tellyscope/MainActivity.kt b/app/src/main/java/app/tellyscope/MainActivity.ktindex 0d07e03..3567e77 100644--- a/app/src/main/java/app/tellyscope/MainActivity.kt+++ b/app/src/main/java/app/tellyscope/MainActivity.kt@@ -36,6 +36,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycleimport androidx.lifecycle.viewmodel.compose.viewModelimport androidx.lifecycle.viewmodel.initializerimport androidx.lifecycle.viewmodel.viewModelFactory+import app.tellyscope.adb.AppFactsimport app.tellyscope.adb.Connectorimport app.tellyscope.adb.StatsProfileimport app.tellyscope.data.AdbDeviceSource@@ -52,6 +53,8 @@ import app.tellyscope.ui.Doneimport app.tellyscope.ui.PermissionScreenimport app.tellyscope.ui.RemoteActionsimport app.tellyscope.ui.RemoteScreen+import app.tellyscope.ui.ReportKind+import app.tellyscope.ui.ReportScreenimport app.tellyscope.ui.ScanScreenimport app.tellyscope.ui.SettingsScreenimport app.tellyscope.ui.TellyscopeViewModel@@ -95,6 +98,7 @@ class MainActivity : ComponentActivity() {AndroidPhoneStorage(applicationContext),updates = if (scenario != null) null else updateCheck(),folds = FoldBook(File(filesDir, "folds.properties")),+ appFacts = AppFacts(installedVersion(), "${Build.MANUFACTURER} ${Build.MODEL}, Android ${Build.VERSION.RELEASE}"),)}},@@ -106,9 +110,11 @@ class MainActivity : ComponentActivity() {}}+ @Suppress("DEPRECATION") // the flags overload is API 33++ private fun installedVersion() = packageManager.getPackageInfo(packageName, 0).versionName.orEmpty()+private fun updateCheck(): UpdateCheck {- @Suppress("DEPRECATION") // the flags overload is API 33+- val version = packageManager.getPackageInfo(packageName, 0).versionName.orEmpty()+ val version = installedVersion()// Alpha builds install as app.tellyscope.alpha (app/build.gradle.kts).return UpdateCheck(File(filesDir, "updates.properties"), version, alpha = packageName.endsWith(".alpha"))}@@ -197,6 +203,9 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {onOpenWifi = { context.openWifiSettings() },phoneKey = remember { Connector.fingerprint() },)+ } else if (state.report != null) {+ BackHandler { vm.closeReport() }+ state.report?.let { ReportScreen(it, onOpened = vm::reportOpened, close = vm::closeReport) }} else if (remote) {BackHandler { remote = false }DisposableEffect(Unit) { onDispose { vm.closeRemote() } }@@ -229,6 +238,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {checkUpdates = state.checkUpdates,alphaBuild = state.alphaBuild,onCheckUpdates = vm::setCheckUpdates,+ onReport = { vm.openReport(ReportKind.Problem) },back = { settings = false },snackbar = snackbar,)@@ -245,6 +255,7 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {tv = state.selected,tvApps = state.device.apps,busy = state.device.busy != null,+ onHelpAdd = { vm.openReport(ReportKind.NewTv) },)} else {DeviceTabsScreen(@@ -267,6 +278,10 @@ fun TellyscopeApp(vm: TellyscopeViewModel) {allowDowngrade = vm::allowDowngrade,install = vm::install,closeSideload = vm::closeSideload,+ reportInstall = { s ->+ vm.closeSideload()+ vm.openReport(ReportKind.Problem, s.app?.let { "Tried to install ${it.label} ${it.info.versionName.orEmpty()}".trim() }.orEmpty(), s.detail)+ },openInstalled = vm::openInstalled,folder = vm::folder,pickFile = { folder -> vm.folder(folder); pickFile.launch(arrayOf("*/*")) },diff --git a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.ktindex 6858d52..201db59 100644--- a/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/AdbDeviceSource.kt@@ -15,6 +15,7 @@ import app.tellyscope.adb.HomeResultimport app.tellyscope.adb.InstallResultimport app.tellyscope.adb.Progressimport app.tellyscope.adb.Sideload+import app.tellyscope.adb.TvFactsimport app.tellyscope.adb.TvFileimport app.tellyscope.adb.TvFolderimport app.tellyscope.adb.Actions@@ -654,6 +655,8 @@ class AdbDeviceSource(context: Context) : DeviceSource {override suspend fun answerRequest(deviceId: String, request: ConnectionRequest, allow: Boolean, always: Boolean) =ConnectionPrompt(session(deviceId)).answer(request, allow, always)+ override suspend fun facts(deviceId: String) = TvFacts.read(session(deviceId))+/*** The history key for a TV, read from it once connected and saved with it. Until it has* answered (offline since install) the address stands in, and that history moves over whendiff --git a/app/src/main/java/app/tellyscope/data/DeviceSource.kt b/app/src/main/java/app/tellyscope/data/DeviceSource.ktindex ee615cd..6eda182 100644--- a/app/src/main/java/app/tellyscope/data/DeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/DeviceSource.kt@@ -9,6 +9,7 @@ import app.tellyscope.adb.InstallResultimport app.tellyscope.adb.InstalledVersionimport app.tellyscope.adb.Progressimport app.tellyscope.adb.RemoteKey+import app.tellyscope.adb.TvFactsimport app.tellyscope.adb.TvFileimport app.tellyscope.adb.TvFolderimport app.tellyscope.adb.Tweak@@ -156,4 +157,7 @@ interface DeviceSource {* when the prompt was gone or showed another fingerprint by then.*/suspend fun answerRequest(deviceId: String, request: ConnectionRequest, allow: Boolean, always: Boolean): Boolean++ /** What a report says about the TV: model, Android, the apps it came with. Throws if it's gone. */+ suspend fun facts(deviceId: String): TvFacts}diff --git a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.ktindex 18e9a1b..66b3198 100644--- a/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt+++ b/app/src/main/java/app/tellyscope/data/FakeDeviceSource.kt@@ -8,6 +8,7 @@ import app.tellyscope.adb.InstallResultimport app.tellyscope.adb.InstalledVersionimport app.tellyscope.adb.Progressimport app.tellyscope.adb.RemoteKey+import app.tellyscope.adb.TvFactsimport app.tellyscope.adb.TvFileimport app.tellyscope.adb.TvFolderimport app.tellyscope.adb.Tweak@@ -365,7 +366,18 @@ class FakeDeviceSource(override suspend fun answerRequest(deviceId: String, request: ConnectionRequest, allow: Boolean, always: Boolean) = false+ override suspend fun facts(deviceId: String) = TvFacts(+ manufacturer = "XGIMI", model = "Horizon Pro", device = "XK03H", androidVersion = "11", sdk = 30,+ build = "RTT1.230922.001", stockPackages = fakeStock, userApps = 7, identifiers = emptySet(),+ )+private companion object {+ /** Enough stock apps that a cleanyourtv report spills into "Add the rest". */+ val fakeStock = listOf(+ "com.google.android.youtube.tv", "com.netflix.ninja", "com.amazon.amazonvideo.livingroom", "com.xgimi.ota",+ "com.xgimi.assistant", "com.xgimi.vcontrol", "com.xgimi.filemanager", "com.xgimi.gallery",+ ) + (1..240).map { "com.xgimi.service$it" } + (1..60).map { "com.android.component$it" }+val fakeList = DeviceList(id = "xgimi-horizon-pro",name = "XGIMI Horizon Pro",diff --git a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt b/app/src/main/java/app/tellyscope/ui/DeviceScreen.ktindex eb60746..7bbcd90 100644--- a/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/DeviceScreen.kt@@ -84,6 +84,8 @@ data class DeviceActions(val allowDowngrade: (Boolean) -> Unit = {},val install: () -> Unit = {},val closeSideload: () -> Unit = {},+ /** Report a problem from a failed install, with what the TV said. */+ val reportInstall: (SideloadUi) -> Unit = {},val openInstalled: () -> Unit = {},val folder: (TvFolder) -> Unit = {},/** Shows that folder, then opens the system picker for a file to send into it. */diff --git a/app/src/main/java/app/tellyscope/ui/ListsCard.kt b/app/src/main/java/app/tellyscope/ui/ListsCard.ktindex 75defbf..1b5c75d 100644--- a/app/src/main/java/app/tellyscope/ui/ListsCard.kt+++ b/app/src/main/java/app/tellyscope/ui/ListsCard.kt@@ -31,8 +31,11 @@ import androidx.compose.material.icons.filled.Clearimport androidx.compose.material.icons.filled.Searchimport androidx.compose.material3.AlertDialogimport androidx.compose.material3.Button+import androidx.compose.material3.Card+import androidx.compose.material3.CardDefaultsimport androidx.compose.material3.Checkboximport androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.material3.FilledTonalButtonimport androidx.compose.material3.Iconimport androidx.compose.material3.IconButtonimport androidx.compose.material3.ListItem@@ -65,6 +68,7 @@ import androidx.compose.ui.unit.dpimport app.tellyscope.data.AppInfoimport app.tellyscope.data.Deviceimport app.tellyscope.data.DeviceKind+import app.tellyscope.data.DeviceStateimport app.tellyscope.data.ListEntryimport app.tellyscope.data.RELEASESimport app.tellyscope.data.Suggested@@ -104,6 +108,8 @@ fun DebloatScreen(tvApps: List<AppInfo> = emptyList(),/** Something is running on this TV: Disable waits for it, like the Apps tab does. */busy: Boolean = false,+ /** Help add this TV to cleanyourtv, offered when a search finds no list. */+ onHelpAdd: () -> Unit = {},) {val ready = lists as? Suggestions.Readyval devices = when (lists) {@@ -206,6 +212,8 @@ fun DebloatScreen(return@LazyColumn}if (missed != null) item { Muted("No list for \u201c$missed\u201d. Pick the closest model.") }+ // Only a connected TV can say which apps it came with.+ if (missed != null && tv?.state == DeviceState.Online) item { HelpAddCard(onHelpAdd) }// Every list, by maker, with the maker in view while scrolling.devices.groupBy { makers.getValue(it.id).lowercase().filter(Char::isLetterOrDigit) }.toSortedMap().forEach { (key, group) ->stickyHeader(key = "m:$key") {@@ -293,6 +301,28 @@ fun DebloatScreen(}}+/** No list for this TV: send its model and stock apps to cleanyourtv, where the lists come from. */+@Composable+private fun HelpAddCard(onHelpAdd: () -> Unit) {+ Card(+ colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainer),+ modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),+ ) {+ Row(Modifier.padding(16.dp)) {+ Icon(AddToQueue, contentDescription = null, tint = MaterialTheme.colorScheme.primary)+ Spacer(Modifier.width(16.dp))+ Column(Modifier.weight(1f)) {+ Text("Not in the list? Help add this TV", style = MaterialTheme.typography.titleSmall)+ Text(+ "Send its model and stock apps to cleanyourtv, where Tellyscope\u2019s lists come from. You see the text first.",+ style = MaterialTheme.typography.bodyMedium,+ )+ FilledTonalButton(onClick = onHelpAdd, modifier = Modifier.align(Alignment.End).padding(top = 8.dp)) { Text("Help add this TV") }+ }+ }+ }+}+/** How well the list fits the TV: its model on its Android, near enough, or not at all. */private enum class Match { Exact, Loose, None }@@ -360,7 +390,7 @@ fun AboutDialog(commit: String?, onDismiss: () -> Unit, version: String = instalText("Version $version", style = MaterialTheme.typography.titleSmall)Text("Made by ${REPO.removePrefix("https://github.com/").substringBefore('/')}", style = MaterialTheme.typography.bodyMedium)Row(- Modifier.clickable(role = Role.Button) { runCatching { browser.openUri(REPO) } }.padding(vertical = 4.dp),+ Modifier.heightIn(min = 48.dp).clickable(role = Role.Button) { runCatching { browser.openUri(REPO) } },verticalAlignment = Alignment.CenterVertically,) {Text(REPO.removePrefix("https://"), style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)diff --git a/app/src/main/java/app/tellyscope/ui/ReportScreen.kt b/app/src/main/java/app/tellyscope/ui/ReportScreen.ktnew file mode 100644index 0000000..6a6e8a4--- /dev/null+++ b/app/src/main/java/app/tellyscope/ui/ReportScreen.kt@@ -0,0 +1,336 @@+// SPDX-License-Identifier: GPL-3.0-only+// The copy and report icons are the Material Icons "content_copy" and "bug_report" (Apache-2.0), see NOTICE.++package app.tellyscope.ui++import androidx.activity.compose.BackHandler+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+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.heightIn+import androidx.compose.foundation.layout.imePadding+import androidx.compose.foundation.layout.navigationBarsPadding+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.Close+import androidx.compose.material.icons.filled.Lock+import androidx.compose.material3.Button+import androidx.compose.material3.ButtonDefaults+import androidx.compose.material3.Card+import androidx.compose.material3.CardDefaults+import androidx.compose.material3.DropdownMenuItem+import androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.material3.ExposedDropdownMenu+import androidx.compose.material3.ExposedDropdownMenuAnchorType+import androidx.compose.material3.ExposedDropdownMenuBox+import androidx.compose.material3.ExposedDropdownMenuDefaults+import androidx.compose.material3.HorizontalDivider+import androidx.compose.material3.Icon+import androidx.compose.material3.IconButton+import androidx.compose.material3.ListItem+import androidx.compose.material3.ListItemDefaults+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.OutlinedTextField+import androidx.compose.material3.Scaffold+import androidx.compose.material3.Surface+import androidx.compose.material3.Text+import androidx.compose.material3.TextButton+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+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.PathFillType+import androidx.compose.ui.graphics.SolidColor+import androidx.compose.ui.graphics.vector.ImageVector+import androidx.compose.ui.graphics.vector.PathParser+import androidx.compose.ui.platform.LocalClipboardManager+import androidx.compose.ui.platform.LocalUriHandler+import androidx.compose.ui.text.AnnotatedString+import androidx.compose.ui.text.font.FontFamily+import androidx.compose.ui.unit.dp+import app.tellyscope.adb.Report+import app.tellyscope.adb.Reports++/**+ * Report a problem, or Help add this TV: what the TV said about itself, the form's dropdowns, what+ * the user writes, then exactly what goes to GitHub. Open GitHub opens the pre-filled form; the user+ * posts it from their own account. A report that didn't fit the link comes back here with the rest.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun ReportScreen(r: ReportUi, onOpened: (Report) -> Unit, close: () -> Unit) {+ val browser = LocalUriHandler.current+ val posted = r.posted+ var addingRest by rememberSaveable { mutableStateOf(false) }+ if (posted?.rest != null && addingRest) {+ AddRestScreen(posted, back = { addingRest = false }, done = close)+ return+ }++ var connection by rememberSaveable { mutableStateOf(r.connection) }+ var outcome by rememberSaveable { mutableStateOf<Reports.Outcome?>(null) }+ var stage by rememberSaveable { mutableStateOf<Reports.Stage?>(null) }+ var details by rememberSaveable { mutableStateOf(r.details) }+ // Null until the form's required dropdown is picked, and for a new TV, until it's been read.+ val report = remember(r.tv, r.log, connection, outcome, stage, details) {+ when (r.kind) {+ ReportKind.Problem -> outcome?.let { Reports.problem(r.app, r.tv, connection, it, details, r.log) }+ ReportKind.NewTv -> if (r.tv == null) null else stage?.let { Reports.newTv(r.app, r.tv, it, details) }+ }+ }+ val newTv = r.kind == ReportKind.NewTv+ Scaffold(+ topBar = {+ TopAppBar(+ title = {+ Column {+ Text(if (newTv) "Help add this TV" else "Report a problem")+ Text(+ if (newTv) "Opens cleanyourtv’s “My TV” form on GitHub" else "Opens an issue on Tellyscope’s GitHub",+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ },+ navigationIcon = { IconButton(onClick = close) { Icon(Icons.Default.Close, contentDescription = "Close") } },+ )+ },+ bottomBar = {+ if (posted == null) Actions(+ note = "You post it from your own GitHub account. " + (+ report?.rest?.let { "What doesn’t fit the link can go in a comment after you post." }+ ?: "Tellyscope sends nothing by itself."+ ),+ cancel = close,+ ) {+ Button(+ onClick = { report?.let { runCatching { browser.openUri(it.link) }; onOpened(it) } },+ enabled = report != null,+ ) { ButtonIcon(OpenInNew); Text("Open GitHub") }+ }+ },+ ) { pad ->+ Column(+ Modifier.fillMaxSize().padding(pad).imePadding().verticalScroll(rememberScrollState()).padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(16.dp),+ ) {+ if (posted != null) {+ PostedCard(posted, notNow = close, addRest = { addingRest = true })+ return@Column+ }+ // Read from the TV, so shown as facts rather than fields to edit.+ Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainer)) {+ val tv = r.tv+ val reading = if (r.reading) "Reading the TV…" else "No TV connected"+ Fact(if (newTv) "TV model" else "TV", tv?.name ?: reading)+ HorizontalDivider(color = MaterialTheme.colorScheme.surface)+ Fact("Android version and firmware build", tv?.android ?: reading)+ }+ if (newTv) {+ Choice("How far did you get?", stage, Reports.Stage.entries, { it.option }) { stage = it }+ } else {+ Choice(+ "How did you connect?", connection, Reports.Connection.entries, { it.option },+ help = "Filled in from this connection; change it if it’s wrong.",+ ) { connection = it }+ Choice("What happened?", outcome, Reports.Outcome.entries, { it.option }) { outcome = it }+ }+ OutlinedTextField(+ details, { details = it },+ label = { Text("Details (optional)") },+ placeholder = { Text(if (newTv) "Anything else?" else "What were you doing?") },+ minLines = 3,+ modifier = Modifier.fillMaxWidth(),+ )+ Text("What gets sent", style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary)+ if (report == null) {+ Text(+ when {+ newTv && r.tv == null -> if (r.reading) "Reading the TV…" else "Connect the TV to list its apps."+ newTv -> "Pick how far you got to see the report."+ else -> "Pick what happened to see the report."+ },+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ } else {+ Sent(report.text)+ }+ Removed()+ }+ }+}++/** The cut part of a posted report, as a comment: copied, then the user's newest issue opens to paste it. */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun AddRestScreen(posted: Report, back: () -> Unit, done: () -> Unit) {+ val browser = LocalUriHandler.current+ val clipboard = LocalClipboardManager.current+ val rest = posted.rest.orEmpty()+ BackHandler(onBack = back)+ Scaffold(+ topBar = {+ TopAppBar(+ title = {+ Column {+ Text("Add the rest")+ Text(+ "As a comment on your newest issue on ${posted.repo.substringAfter('/')}",+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ },+ navigationIcon = { IconButton(onClick = back) { Icon(Icons.Default.Close, contentDescription = "Close") } },+ )+ },+ bottomBar = {+ Actions(+ note = "Opens your newest issue on ${posted.repo}. If it’s not the right one, pick yours from the list there.",+ cancel = back,+ ) {+ Button(onClick = {+ clipboard.setText(AnnotatedString(rest))+ runCatching { browser.openUri(posted.myIssues) }+ done()+ }) { ButtonIcon(CopyIcon); Text("Copy and open your issue") }+ }+ },+ ) { pad ->+ Column(+ Modifier.fillMaxSize().padding(pad).verticalScroll(rememberScrollState()).padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(16.dp),+ ) {+ Text(+ "This is the comment. GitHub can’t fill in a comment from a link, so Tellyscope copies it and opens " ++ "your issue: tap the comment box there and paste.",+ style = MaterialTheme.typography.bodyMedium,+ )+ Sent(rest, tall = true)+ Removed()+ }+ }+}++/** Back from GitHub with part of the report cut: offer to add it. */+@Composable+private fun PostedCard(posted: Report, notNow: () -> Unit, addRest: () -> Unit) {+ val lines = posted.rest.orEmpty().lines().size - 1+ Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer)) {+ Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {+ Text("Posted it? Add the rest as a comment", style = MaterialTheme.typography.titleMedium)+ Text(+ if (posted.repo == Reports.CLEANYOURTV) "$lines apps didn’t fit in the link. Adding them helps cleanyourtv write the full list."+ else "Part of the report didn’t fit in the link. Adding it helps us find the problem.",+ style = MaterialTheme.typography.bodyMedium,+ )+ Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End)) {+ TextButton(onClick = notNow) { Text("Not now") }+ Button(onClick = addRest) { Text("Add the rest") }+ }+ }+ }+}++@Composable+private fun Fact(label: String, value: String) = ListItem(+ overlineContent = { Text(label) },+ headlineContent = { Text(value) },+ colors = ListItemDefaults.colors(containerColor = Color.Transparent),+)++/** One of the form's dropdowns, its options word for word. */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+private fun <T> Choice(label: String, value: T?, options: List<T>, text: (T) -> String, help: String? = null, onPick: (T) -> Unit) {+ var open by remember { mutableStateOf(false) }+ ExposedDropdownMenuBox(open, onExpandedChange = { open = it }) {+ OutlinedTextField(+ value?.let(text) ?: "Choose one", {},+ readOnly = true,+ label = { Text(label) },+ supportingText = help?.let { { Text(it) } },+ trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(open) },+ modifier = Modifier.fillMaxWidth().menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),+ )+ ExposedDropdownMenu(open, onDismissRequest = { open = false }) {+ options.forEach { o -> DropdownMenuItem(text = { Text(text(o)) }, onClick = { open = false; onPick(o) }) }+ }+ }+}++/** What goes to GitHub, as it'll read there. */+@Composable+private fun Sent(text: String, tall: Boolean = false) {+ Surface(color = MaterialTheme.colorScheme.surfaceContainer, shape = MaterialTheme.shapes.large, modifier = Modifier.fillMaxWidth()) {+ Text(+ text,+ style = MaterialTheme.typography.bodySmall.copy(fontFamily = FontFamily.Monospace),+ modifier = Modifier.heightIn(max = if (tall) 420.dp else 280.dp).verticalScroll(rememberScrollState()).padding(16.dp),+ )+ }+}++@Composable+private fun Removed() = Row(verticalAlignment = Alignment.CenterVertically) {+ Icon(Icons.Default.Lock, null, Modifier.size(16.dp), tint = MaterialTheme.colorScheme.primary)+ Spacer(Modifier.width(8.dp))+ Text(+ "Removed first: serial numbers, IP addresses, ADB keys and fingerprints.",+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+}++/** The bottom bar: what happens next, then Cancel and the one action. */+@Composable+private fun Actions(note: String, cancel: () -> Unit, action: @Composable () -> Unit) {+ Surface(color = MaterialTheme.colorScheme.surfaceContainer) {+ Column(Modifier.fillMaxWidth().navigationBarsPadding().imePadding().padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {+ Text(note, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End)) {+ TextButton(onClick = cancel) { Text("Cancel") }+ action()+ }+ }+ }+}++@Composable+private fun ButtonIcon(icon: ImageVector) {+ Icon(icon, null, Modifier.size(ButtonDefaults.IconSize))+ Spacer(Modifier.width(ButtonDefaults.IconSpacing))+}++private fun icon(name: String, path: String) = ImageVector.Builder(name, 24.dp, 24.dp, 24f, 24f)+ .addPath(PathParser().parsePathString(path).toNodes(), pathFillType = PathFillType.NonZero, fill = SolidColor(Color.Black))+ .build()++private val CopyIcon = icon(+ "ContentCopy",+ "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z",+)++internal val BugReport = icon(+ "BugReport",+ "M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z",+)++internal val AddToQueue = icon(+ "AddToQueue",+ "M21 3H3c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2zm0 14H3V5h18v12zm-5-7v2h-3v3h-2v-3H8v-2h3V7h2v3h3z",+)diff --git a/app/src/main/java/app/tellyscope/ui/SettingsScreen.kt b/app/src/main/java/app/tellyscope/ui/SettingsScreen.ktindex 9294be8..4d53eb6 100644--- a/app/src/main/java/app/tellyscope/ui/SettingsScreen.kt+++ b/app/src/main/java/app/tellyscope/ui/SettingsScreen.kt@@ -65,8 +65,8 @@ internal const val CLEANYOURTV = "https://github.com/Gathin23/cleanyourtv"internal val OWN_LISTS_GUIDE = RELEASES.removeSuffix("/releases") + "/blob/main/CONTRIBUTING.md#using-your-own-lists"/**- * App-wide choices, not tied to one TV: update checks first, then a folded Advanced with where the- * debloat lists come from and how to use your own.+ * App-wide choices, not tied to one TV: update checks and Report a problem first, then a folded+ * Advanced with where the debloat lists come from and how to use your own.*/@OptIn(ExperimentalMaterial3Api::class)@Composable@@ -80,6 +80,7 @@ fun SettingsScreen(alphaBuild: Boolean,onCheckUpdates: (Boolean) -> Unit,back: () -> Unit,+ onReport: () -> Unit = {},snackbar: SnackbarHostState = remember { SnackbarHostState() },) {var editing by rememberSaveable { mutableStateOf(false) }@@ -103,9 +104,9 @@ fun SettingsScreen(contentPadding = PaddingValues(start = 16.dp, end = 16.dp, bottom = 32.dp),verticalArrangement = Arrangement.spacedBy(12.dp),) {- if (checkUpdates != null) item {+ item {Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainer)) {- Row(+ if (checkUpdates != null) Row(Modifier.fillMaxWidth().toggleable(checkUpdates, role = Role.Switch, onValueChange = onCheckUpdates).padding(16.dp),@@ -119,8 +120,20 @@ fun SettingsScreen(style = MaterialTheme.typography.bodyMedium,)}+ Spacer(Modifier.width(16.dp))Switch(checked = checkUpdates, onCheckedChange = null)}+ if (checkUpdates != null) HorizontalDivider(color = MaterialTheme.colorScheme.surface)+ Row(Modifier.fillMaxWidth().clickable(onClick = onReport).padding(16.dp), verticalAlignment = Alignment.CenterVertically) {+ Icon(BugReport, contentDescription = null, tint = MaterialTheme.colorScheme.onSurfaceVariant)+ Spacer(Modifier.width(16.dp))+ Column(Modifier.weight(1f)) {+ Text("Report a problem", style = MaterialTheme.typography.titleSmall)+ Text("Opens an issue on Tellyscope\u2019s GitHub. You see the text first.", style = MaterialTheme.typography.bodyMedium)+ }+ Spacer(Modifier.width(16.dp))+ Icon(Icons.AutoMirrored.Filled.KeyboardArrowRight, contentDescription = null)+ }}}item {diff --git a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.ktindex 4d09ec7..85c561f 100644--- a/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt+++ b/app/src/main/java/app/tellyscope/ui/TellyscopeViewModel.kt@@ -5,6 +5,7 @@ package app.tellyscope.uiimport android.net.Uriimport androidx.lifecycle.ViewModelimport androidx.lifecycle.viewModelScope+import app.tellyscope.adb.AppFactsimport app.tellyscope.adb.ConnectionRequestimport app.tellyscope.adb.InstallKindimport app.tellyscope.adb.StatsProfile@@ -13,6 +14,9 @@ import app.tellyscope.adb.InstalledVersionimport app.tellyscope.adb.Progressimport app.tellyscope.adb.Remoteimport app.tellyscope.adb.RemoteKey+import app.tellyscope.adb.Report+import app.tellyscope.adb.Reports+import app.tellyscope.adb.TvFactsimport app.tellyscope.adb.TvFileimport app.tellyscope.adb.TvFolderimport app.tellyscope.adb.Tweak@@ -53,6 +57,9 @@ import kotlinx.coroutines.launchimport kotlinx.coroutines.sync.Muteximport kotlinx.coroutines.sync.withLockimport kotlinx.coroutines.withTimeoutOrNull+import java.text.SimpleDateFormat+import java.util.Date+import java.util.Localeimport java.util.concurrent.ConcurrentHashMap/** Per-row connect state on the scan screen. */@@ -116,6 +123,26 @@ data class SideloadUi(val kind: InstallKind? get() = app?.let { installKind(it.info, installed) }}+/** Report a problem goes to Tellyscope's tracker; Help add this TV to cleanyourtv's. */+enum class ReportKind { Problem, NewTv }++/** The report screen. The form itself (dropdowns, what the user writes) lives on the screen. */+data class ReportUi(+ val kind: ReportKind,+ val app: AppFacts,+ /** How the TV is connected, or COULD_NOT_CONNECT with no TV online. */+ val connection: Reports.Connection,+ /** The TV, read when the screen opened; null while reading, with no TV online, or if it went away. */+ val tv: TvFacts? = null,+ val reading: Boolean = false,+ /** What the entry point already knows, to start the user's details: the app that failed to install. */+ val details: String = "",+ /** This session's messages, then the TV's own words for a failed install. */+ val log: String? = null,+ /** Opened on GitHub with something cut: the screen offers to add it as a comment. */+ val posted: Report? = null,+)+data class FilesUi(val folder: TvFolder = TvFolder.DOWNLOAD,/** Null while loading. */@@ -144,6 +171,8 @@ data class UiState(val update: Update? = null,/** The Apps tabs whose System section the user folded away. */val foldedSystem: Set<AppsTab> = emptySet(),+ /** The report screen; null when it's closed. */+ val report: ReportUi? = null,) {val selected: Device? get() = devices.firstOrNull { it.id == selectedId }}@@ -170,6 +199,9 @@ data class Restart(val since: Long, val down: Boolean = false, val waitFrom: Lon}}+/** The newest messages a report's log keeps. */+private const val LOG_LINES = 200+/** Most TVs are back within this; after it the Remote asks whether to keep waiting. */const val RESTART_WAIT_MS = 60_000L@@ -193,6 +225,8 @@ class TellyscopeViewModel(private val clock: () -> Long = System::currentTimeMillis,private val updates: UpdateCheck? = null,private val folds: FoldBook? = null,+ /** This build and phone, for reports. */+ private val appFacts: AppFacts = AppFacts("unknown", "unknown phone"),) : ViewModel() {private val _state = MutableStateFlow(UiState(now = clock()))@@ -206,6 +240,9 @@ class TellyscopeViewModel(private val _notice = MutableStateFlow<String?>(null)val notice: StateFlow<String?> = _notice.asStateFlow()+ /** This session's messages, newest last, for a report's log. Kept in memory only. */+ private val sessionLog = ArrayDeque<String>()+/** Last stats per TV, so an offline page shows where it stood instead of blanks. Lives as long as the app. */private val lastSnapshot = mutableMapOf<String, Snapshot>()@@ -253,6 +290,7 @@ class TellyscopeViewModel(}}rescan()+ viewModelScope.launch { notice.collect { it?.let(::log) } }viewModelScope.launch {// Off Wi-Fi a scan has nothing to sweep; start over the moment the phone joins one.source.lanUp().collect {@@ -616,12 +654,45 @@ class TellyscopeViewModel(runCatching { source.apps(id) }.onSuccess { apps -> updateDevice(id) { it.copy(apps = apps) } }}is InstallResult.Refused -> updateDevice(id) {+ log("Install ${app.info.packageName} ${app.info.versionName.orEmpty()}: ${r.detail ?: r.reason}")it.copy(sideload = ready.copy(step = SideloadUi.Step.Failed, error = Copy.installRefused(r.reason, app.label), detail = r.detail))}}}}+ private fun log(line: String) = synchronized(sessionLog) {+ sessionLog.addLast(SimpleDateFormat("HH:mm:ss", Locale.ROOT).format(Date(clock())) + " " + line)+ while (sessionLog.size > LOG_LINES) sessionLog.removeFirst()+ }++ /**+ * Opens the report screen about the selected TV, reading it if it's online. [details] starts what+ * the user writes; [said] is what the TV answered, added to the log.+ */+ fun openReport(kind: ReportKind, details: String = "", said: String? = null) {+ val tv = _state.value.selected?.takeIf { it.state == DeviceState.Online }+ val log = synchronized(sessionLog) { sessionLog.toList() } + listOfNotNull(said?.let { "The TV said: $it" })+ val connection = when (tv?.hit?.kind) {+ ScanKind.Classic -> Reports.Connection.PORT_5555+ ScanKind.Wireless -> Reports.Connection.WIRELESS_DEBUGGING+ null -> Reports.Connection.COULD_NOT_CONNECT+ }+ _state.update { it.copy(report = ReportUi(kind, appFacts, connection, reading = tv != null, details = details, log = log.joinToString("\n").ifEmpty { null })) }+ tv ?: return+ viewModelScope.launch {+ val facts = try { source.facts(tv.id) } catch (e: CancellationException) { throw e } catch (_: Exception) { null }+ _state.update { st -> st.copy(report = st.report?.copy(tv = facts, reading = false)) }+ }+ }++ /** The report went to GitHub: done, unless something was cut, which the screen then offers to add. */+ fun reportOpened(report: Report) {+ _state.update { st -> st.copy(report = if (report.rest == null) null else st.report?.copy(posted = report)) }+ }++ fun closeReport() = _state.update { it.copy(report = null) }+/** Cancel or Done on the install dialog. Not while installing: the dialog has no button then. */fun closeSideload() {if (_state.value.device.sideload?.step == SideloadUi.Step.Installing) returndiff --git a/app/src/main/java/app/tellyscope/ui/Transfers.kt b/app/src/main/java/app/tellyscope/ui/Transfers.ktindex bf9eb0f..f201b17 100644--- a/app/src/main/java/app/tellyscope/ui/Transfers.kt+++ b/app/src/main/java/app/tellyscope/ui/Transfers.kt@@ -274,6 +274,7 @@ fun SideloadDialog(s: SideloadUi, actions: DeviceActions) {when (s.step) {SideloadUi.Step.Reading, SideloadUi.Step.Ready -> TextButton(onClick = actions.closeSideload) { Text("Cancel") }SideloadUi.Step.Installed -> TextButton(onClick = actions.closeSideload) { Text("Done") }+ SideloadUi.Step.Failed -> TextButton(onClick = { actions.reportInstall(s) }) { Text("Report a problem") }else -> Unit}},diff --git a/app/src/test/java/app/tellyscope/ReportFlowTest.kt b/app/src/test/java/app/tellyscope/ReportFlowTest.ktnew file mode 100644index 0000000..4bf2210--- /dev/null+++ b/app/src/test/java/app/tellyscope/ReportFlowTest.kt@@ -0,0 +1,133 @@+// SPDX-License-Identifier: GPL-3.0-only++package app.tellyscope++import androidx.lifecycle.viewModelScope+import app.tellyscope.adb.AppFacts+import app.tellyscope.adb.Reports+import app.tellyscope.adb.TvFacts+import app.tellyscope.data.Device+import app.tellyscope.data.DeviceSource+import app.tellyscope.data.DeviceState+import app.tellyscope.data.Docked+import app.tellyscope.data.FakeDeviceSource+import app.tellyscope.data.ScanHit+import app.tellyscope.data.ScanKind+import app.tellyscope.data.Snapshot+import app.tellyscope.ui.Copy+import app.tellyscope.ui.ReportKind+import app.tellyscope.ui.TellyscopeViewModel+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.ExperimentalCoroutinesApi+import kotlinx.coroutines.cancel+import kotlinx.coroutines.flow.emptyFlow+import kotlinx.coroutines.test.StandardTestDispatcher+import kotlinx.coroutines.test.TestScope+import kotlinx.coroutines.test.resetMain+import kotlinx.coroutines.test.runCurrent+import kotlinx.coroutines.test.setMain+import org.junit.After+import org.junit.Assert.assertEquals+import org.junit.Assert.assertFalse+import org.junit.Assert.assertNotNull+import org.junit.Assert.assertNull+import org.junit.Assert.assertTrue+import org.junit.Before+import org.junit.Test++/** One TV called Projector on wireless debugging; its state and its read are set by the test. */+private class ReportTv : DeviceSource by FakeDeviceSource(FakeDeviceSource.Scenario.Empty, clock = { 0L }) {+ var state = DeviceState.Online+ var readable = true+ val facts = TvFacts("XGIMI", "XGIMI Horizon Pro", "XK03H", "11", 30, "RTT1", listOf("com.xgimi.ota"), 3, emptySet())++ override suspend fun known() = listOf(+ Device("tv", ScanHit("tv", 5555, ScanKind.Wireless, "tv", null), state, null, null, null, 0L, nickname = "Projector"),+ )++ override fun live(deviceId: String) = emptyFlow<Snapshot>()+ override suspend fun launch(deviceId: String, packageName: String) = false+ override suspend fun facts(deviceId: String) = if (readable) facts else throw java.io.IOException("gone")+}++@OptIn(ExperimentalCoroutinesApi::class)+class ReportFlowTest {+ private val dispatcher = StandardTestDispatcher()+ private val test = TestScope(dispatcher)+ private val tv = ReportTv()+ private val app = AppFacts("0.8.0", "Pixel 8, Android 16")+ private lateinit var vm: TellyscopeViewModel++ @Before fun setUp() = Dispatchers.setMain(dispatcher)++ @After fun tearDown() {+ if (::vm.isInitialized) vm.viewModelScope.cancel()+ Dispatchers.resetMain()+ }++ private fun start() = with(test) {+ vm = TellyscopeViewModel(tv, clock = { 0L }, appFacts = app)+ runCurrent()+ }++ @Test fun aReportReadsTheTvAndKnowsHowItConnected() = with(test) {+ start()+ vm.openReport(ReportKind.Problem)+ assertTrue(vm.state.value.report!!.reading)+ assertEquals(Reports.Connection.WIRELESS_DEBUGGING, vm.state.value.report!!.connection)+ runCurrent()+ val r = vm.state.value.report!!+ assertFalse(r.reading)+ assertEquals(tv.facts, r.tv)+ assertEquals(app, r.app)+ }++ @Test fun theLogHoldsWhatTheAppSaidThenWhatTheTvSaid() = with(test) {+ start()+ vm.launch(Docked("org.xbmc.kodi", "Kodi"))+ runCurrent()+ vm.openReport(ReportKind.Problem, "Tried to install Kodi", said = "INSTALL_FAILED_UPDATE_INCOMPATIBLE")+ val r = vm.state.value.report!!+ assertEquals("Tried to install Kodi", r.details)+ assertEquals(listOf("00:00:00 " + Copy.cantOpen("Kodi"), "The TV said: INSTALL_FAILED_UPDATE_INCOMPATIBLE"), r.log!!.lines().map { it.replaceFirst(Regex("^\\d\\d:\\d\\d:\\d\\d"), "00:00:00") })+ }++ @Test fun withNoTvOnlineItSaysItCouldNotConnect() = with(test) {+ tv.state = DeviceState.Offline+ start()+ vm.openReport(ReportKind.Problem)+ runCurrent()+ val r = vm.state.value.report!!+ assertEquals(Reports.Connection.COULD_NOT_CONNECT, r.connection)+ assertNull(r.tv)+ assertFalse(r.reading)+ }++ @Test fun aTvThatWentAwayLeavesTheReportWithoutIt() = with(test) {+ tv.readable = false+ start()+ vm.openReport(ReportKind.NewTv)+ runCurrent()+ assertNull(vm.state.value.report!!.tv)+ assertFalse(vm.state.value.report!!.reading)+ }++ @Test fun aReportThatFitClosesOneThatDidntWaitsForTheRest() = with(test) {+ start()+ vm.openReport(ReportKind.NewTv)+ runCurrent()+ val whole = Reports.newTv(app, tv.facts, Reports.Stage.HERE_IS_MY_LIST, "")+ vm.reportOpened(whole)+ assertNull(vm.state.value.report)++ vm.openReport(ReportKind.NewTv)+ runCurrent()+ val big = tv.facts.copy(stockPackages = (1..600).map { "com.example.stock$it" })+ val cut = Reports.newTv(app, big, Reports.Stage.HERE_IS_MY_LIST, "")+ assertNotNull(cut.rest)+ vm.reportOpened(cut)+ assertEquals(cut, vm.state.value.report!!.posted)+ vm.closeReport()+ assertNull(vm.state.value.report)+ }+}diff --git a/app/src/test/java/app/tellyscope/ScreenshotTest.kt b/app/src/test/java/app/tellyscope/ScreenshotTest.ktindex 92dca77..0fa3a8a 100644--- a/app/src/test/java/app/tellyscope/ScreenshotTest.kt+++ b/app/src/test/java/app/tellyscope/ScreenshotTest.kt@@ -35,10 +35,12 @@ import androidx.compose.ui.test.hasScrollActionimport androidx.compose.ui.test.hasTextimport androidx.compose.ui.test.onNodeWithTagimport app.tellyscope.adb.ApkInfo+import app.tellyscope.adb.AppFactsimport app.tellyscope.adb.ConnectionRequestimport app.tellyscope.adb.InstallRefusalimport app.tellyscope.adb.InstalledVersionimport app.tellyscope.adb.Progress+import app.tellyscope.adb.Reportsimport app.tellyscope.adb.TvFileimport app.tellyscope.adb.TvFolderimport app.tellyscope.data.Action@@ -90,6 +92,10 @@ import app.tellyscope.ui.SideloadUiimport app.tellyscope.ui.TransferUiimport app.tellyscope.ui.brandsimport app.tellyscope.ui.name+import app.tellyscope.ui.AddRestScreen+import app.tellyscope.ui.ReportKind+import app.tellyscope.ui.ReportScreen+import app.tellyscope.ui.ReportUiimport app.tellyscope.ui.SettingsScreenimport app.tellyscope.data.RELEASESimport androidx.compose.ui.platform.UriHandler@@ -1077,6 +1083,101 @@ class ScreenshotTest {compose.onNodeWithText("Chromecast with Google TV 4K").assertExists()}+ @Test fun debloat_helpAdd() {+ // No list for this TV's maker, and the TV is connected: offer to send its apps to cleanyourtv.+ val asked = mutableListOf<Unit>()+ val tv = deviceState().selected+ shot("85_debloat_help_add", before = notThisTv) { DebloatScreen(makerLists(), {}, {}, {}, tvMakers = listOf("TPV"), tv = tv, onHelpAdd = { asked += Unit }) }+ compose.onNodeWithText("Not in the list? Help add this TV").assertExists()+ compose.onNodeWithText("Help add this TV").performClick()+ assertEquals(1, asked.size)+ }++ private val reportApp = AppFacts("0.8.0", "Pixel 8, Android 16")++ private fun reportUi(kind: ReportKind, details: String = "", log: String? = null) = runBlocking {+ ReportUi(kind, reportApp, Reports.Connection.WIRELESS_DEBUGGING, tv = fake.facts(xgimi.ip), details = details, log = log)+ }++ /** Opens the form's dropdown that still says "Choose one" and picks [option]. */+ private fun choose(option: String) = {+ compose.onNodeWithText("Choose one").performClick()+ compose.mainClock.advanceTimeBy(1_000)+ compose.onNodeWithText(option).performClick()+ Unit+ }++ @Test fun report_problem() = reportProblem(dark = false)++ @Test fun report_problem_dark() = reportProblem(dark = true)++ /** From a failed install: the TV as facts, the dropdowns, what the user wrote, then what gets sent. */+ private fun reportProblem(dark: Boolean) {+ val r = reportUi(+ ReportKind.Problem, "Tried to install Kodi 21.2",+ log = "21:04:11 Connected to Projector\n21:04:19 Install org.xbmc.kodi 21.2: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]",+ )+ val opened = mutableListOf<String>()+ val links = object : UriHandler { override fun openUri(uri: String) { opened += uri } }+ shot("86_report_problem", dark, before = choose(Reports.Outcome.MISBEHAVED.option)) {+ CompositionLocalProvider(LocalUriHandler provides links) { ReportScreen(r, {}, {}) }+ }+ compose.onNodeWithText("XGIMI Horizon Pro (XK03H)").assertExists()+ compose.onNodeWithText(Reports.Connection.WIRELESS_DEBUGGING.option).assertExists()+ compose.onNodeWithText("Tellyscope sends nothing by itself", substring = true).assertExists()+ compose.onNodeWithText("Open GitHub").performClick()+ assertTrue(opened.single().startsWith("https://github.com/") && "template=device_report.yml" in opened.single())+ }++ @Test fun report_problemWaitsForWhatHappened() {+ shot("86_report_problem_empty") { ReportScreen(reportUi(ReportKind.Problem), {}, {}) }+ compose.onNodeWithText("Pick what happened to see the report.").assertExists()+ compose.onNodeWithText("Open GitHub").assertIsNotEnabled()+ }++ @Test fun report_newTv() = reportNewTv(dark = false)++ @Test fun report_newTv_dark() = reportNewTv(dark = true)++ private fun reportNewTv(dark: Boolean) {+ shot("87_report_new_tv", dark, before = choose(Reports.Stage.HERE_IS_MY_LIST.option)) { ReportScreen(reportUi(ReportKind.NewTv), {}, {}) }+ compose.onNodeWithText("Help add this TV").assertExists()+ compose.onNodeWithText("can go in a comment after you post", substring = true).assertExists()+ }++ private fun posted() = runBlocking { Reports.newTv(reportApp, fake.facts(xgimi.ip), Reports.Stage.HERE_IS_MY_LIST, "") }++ @Test fun report_posted() = reportPosted(dark = false)++ @Test fun report_posted_dark() = reportPosted(dark = true)++ /** Back from GitHub with apps that didn't fit: the card offering to add them. */+ private fun reportPosted(dark: Boolean) {+ val p = posted()+ val left = p.rest!!.lines().size - 1+ shot("88_report_posted", dark) { ReportScreen(reportUi(ReportKind.NewTv).copy(posted = p), {}, {}) }+ compose.onNodeWithText("Posted it? Add the rest as a comment").assertExists()+ compose.onNodeWithText("$left apps didn\u2019t fit", substring = true).assertExists()+ compose.onNodeWithText("Add the rest").performClick()+ compose.mainClock.advanceTimeBy(1_000)+ compose.onNodeWithText("Copy and open your issue").assertExists()+ }++ @Test fun report_addRest() = addRest(dark = false)++ @Test fun report_addRest_dark() = addRest(dark = true)++ private fun addRest(dark: Boolean) {+ val p = posted()+ val opened = mutableListOf<String>()+ val links = object : UriHandler { override fun openUri(uri: String) { opened += uri } }+ var done = false+ shot("89_report_add_rest", dark) { CompositionLocalProvider(LocalUriHandler provides links) { AddRestScreen(p, {}, { done = true }) } }+ compose.onNodeWithText("Copy and open your issue").performClick()+ assertEquals(listOf(p.myIssues), opened)+ assertTrue(done)+ }+@Test fun debloat_pickByHand() {val lists = makerLists()val picked = mutableListOf<String>()