diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/AppSelectionAdapter.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/AppSelectionAdapter.kt index 499184e8..499e1d8e 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/AppSelectionAdapter.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/AppSelectionAdapter.kt @@ -144,9 +144,6 @@ internal class AppSelectionAdapter( fun bind(item: SelectableAppItem) { v.background = clickableBackground - v.setOnClickListener { - checkBox.toggle() - } checkBox.setOnCheckedChangeListener(null) checkBox.isChecked = item.selected @@ -155,6 +152,11 @@ internal class AppSelectionAdapter( } checkBox.visibility = if (item.hasIcon == null) INVISIBLE else VISIBLE progressBar.visibility = if (item.hasIcon == null) VISIBLE else INVISIBLE + if (item.hasIcon == null) { + v.setOnClickListener(null) + } else v.setOnClickListener { + checkBox.toggle() + } val isSpecial = item.metadata.isInternalSystem appIcon.scaleType = FIT_CENTER diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt index dc3af875..630e10a9 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt @@ -153,6 +153,13 @@ internal class ApkRestore( packageName: String, metadata: PackageMetadata, ) { + // show that app is in progress, before we start downloading stuff + mInstallResult.update { + it.update(packageName) { result -> + result.copy(state = IN_PROGRESS) + } + } + // cache the APK and get its hash val (cachedApk, sha256) = cacheApk(backup.version, backup.token, backup.salt, packageName) diff --git a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt index 562766b7..b1bd25ff 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt @@ -194,6 +194,13 @@ internal class ApkBackupRestoreTest : TransportTest() { assertEquals(IN_PROGRESS, it.installResults[packageName]?.state) assertFalse(it.isFinished) } + awaitItem().also { + assertFalse(it.hasFailed) + assertEquals(1, it.total) + assertEquals(1, it.list.size) + assertEquals(IN_PROGRESS, it.installResults[packageName]?.state) + assertFalse(it.isFinished) + } awaitItem().also { assertFalse(it.hasFailed) assertEquals(1, it.total) diff --git a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt index 8d2548c4..6679be3a 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt @@ -46,6 +46,7 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir @@ -758,6 +759,14 @@ internal class ApkRestoreTest : TransportTest() { } private suspend fun TurbineTestContext.awaitInProgressItem(): InstallResult { + awaitItem().also { item -> + val result = item[packageName] + assertEquals(IN_PROGRESS, result.state) + assertFalse(item.hasFailed) + assertEquals(1, item.total) + assertEquals(1, item.list.size) + assertNull(result.icon) + } val item = awaitItem() // name and icon are available now val result = item[packageName]