Skip to content

Commit f05773d

Browse files
committed
feat: open module configuration from the store install bar
1 parent 5e4dcb9 commit f05773d

24 files changed

Lines changed: 60 additions & 44 deletions

File tree

manager-ui/src/main/kotlin/org/matrix/vector/ui/store/RepoDetailsScreen.kt

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ fun RepoDetailsScreen(
113113
packageName: String,
114114
onNavigateBack: () -> Unit,
115115
onOpenUrl: (String) -> Unit,
116+
onOpenScope: (packageName: String, userId: Int) -> Unit,
116117
dataSource: StoreDataSource,
117118
settings: StoreSettings,
118119
host: StoreInstallHost? = null,
@@ -137,6 +138,7 @@ fun RepoDetailsScreen(
137138
val installedScope by viewModel.installedScope.collectAsState()
138139
val installedIsLegacy by viewModel.installedIsLegacy.collectAsState()
139140
val install by viewModel.installState.collectAsState()
141+
val installedUserId by viewModel.installedUserId.collectAsState()
140142

141143
var choosing by remember { mutableStateOf<Release?>(null) }
142144
var optionsOpen by remember { mutableStateOf(false) }
@@ -204,6 +206,8 @@ fun RepoDetailsScreen(
204206
else choosing = release
205207
},
206208
onAcknowledge = viewModel::acknowledgeInstall,
209+
installedUserId = installedUserId,
210+
onOpenScope = { onOpenScope(packageName, it) },
207211
)
208212
}
209213
},
@@ -378,6 +382,9 @@ private fun InstallBar(
378382
install: InstallStep,
379383
onInstall: (Release) -> Unit,
380384
onAcknowledge: () -> Unit,
385+
/** The installed copy's user id, so the "Manage" button can open the configuration screen. */
386+
installedUserId: Int?,
387+
onOpenScope: (userId: Int) -> Unit,
381388
) {
382389
val context = LocalContext.current
383390
val newest = state.releases.firstOrNull { it.apks.isNotEmpty() } ?: return
@@ -449,31 +456,46 @@ private fun InstallBar(
449456
}
450457
}
451458
else -> {
452-
Button(
453-
onClick = {
454-
onAcknowledge()
455-
onInstall(newest)
456-
},
457-
modifier = Modifier.fillMaxWidth(),
458-
) {
459-
Icon(
460-
Icons.Rounded.Download,
461-
contentDescription = null,
462-
modifier = Modifier.size(18.dp),
463-
)
464-
Spacer(Modifier.width(8.dp))
465-
Text(
466-
when {
467-
state.upgradable ->
468-
stringResource(
469-
if (state.sameVersion) UiR.string.store_badge_reinstall
470-
else UiR.string.store_badge_update,
471-
state.latest?.versionName.orEmpty(),
472-
)
473-
state.installed != null -> stringResource(UiR.string.store_reinstall)
474-
else -> stringResource(UiR.string.store_install)
475-
}
476-
)
459+
// Installed and current — the next thing is to configure it, not reinstall it.
460+
if (state.installed != null && !state.upgradable && installedUserId != null) {
461+
FilledTonalButton(
462+
onClick = { onOpenScope(installedUserId) },
463+
modifier = Modifier.fillMaxWidth(),
464+
) {
465+
Icon(
466+
Icons.Rounded.Tune,
467+
contentDescription = null,
468+
modifier = Modifier.size(18.dp),
469+
)
470+
Spacer(Modifier.width(8.dp))
471+
Text(stringResource(UiR.string.nav_manage))
472+
}
473+
} else {
474+
Button(
475+
onClick = {
476+
onAcknowledge()
477+
onInstall(newest)
478+
},
479+
modifier = Modifier.fillMaxWidth(),
480+
) {
481+
Icon(
482+
Icons.Rounded.Download,
483+
contentDescription = null,
484+
modifier = Modifier.size(18.dp),
485+
)
486+
Spacer(Modifier.width(8.dp))
487+
Text(
488+
when {
489+
state.upgradable ->
490+
stringResource(
491+
if (state.sameVersion) UiR.string.store_badge_reinstall
492+
else UiR.string.store_badge_update,
493+
state.latest?.versionName.orEmpty(),
494+
)
495+
else -> stringResource(UiR.string.store_install)
496+
}
497+
)
498+
}
477499
}
478500
}
479501
}

manager-ui/src/main/kotlin/org/matrix/vector/ui/store/RepoDetailsViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ class RepoDetailsViewModel(
9393
val installedIsLegacy: StateFlow<Boolean> =
9494
host?.installedIsLegacy ?: MutableStateFlow(false).asStateFlow()
9595

96+
/** The user id of the installed copy, for the configuration screen; null when nothing is installed. */
97+
val installedUserId: StateFlow<Int?> =
98+
host?.installedUserId ?: MutableStateFlow<Int?>(null).asStateFlow()
99+
96100
private val _detail = MutableStateFlow<OnlineModule?>(null)
97101
private val _fetch = MutableStateFlow(DetailFetch.Loading)
98102

manager-ui/src/main/kotlin/org/matrix/vector/ui/store/StoreInstallHost.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ interface StoreInstallHost {
2323
/** Whether the installed copy is a legacy-framework module (its scope names are swapped). */
2424
val installedIsLegacy: StateFlow<Boolean>
2525

26+
/** The user id of the installed copy, for the configuration screen; null when nothing is installed. */
27+
val installedUserId: StateFlow<Int?>
28+
2629
/** Download and install [asset], recording it against [releaseVersion]. */
2730
fun install(asset: ReleaseAsset, releaseVersion: RepoVersion?)
2831

manager-ui/src/main/res/values-ar/strings_store.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
<string name="store_open_module">فتح صفحة الوحدة</string>
5959
<!-- Install -->
6060
<string name="store_install">تثبيت</string>
61-
<string name="store_reinstall">إعادة التثبيت</string>
6261
<string name="store_choose_asset">اختر ملفًا للتثبيت</string>
6362
<plurals name="store_asset_downloads">
6463
<item quantity="zero">لا تنزيلات</item>

manager-ui/src/main/res/values-de/strings_store.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<string name="store_open_module">Modulseite öffnen</string>
4343

4444
<string name="store_install">Installieren</string>
45-
<string name="store_reinstall">Neu installieren</string>
4645
<string name="store_choose_asset">Datei zur Installation wählen</string>
4746
<plurals name="store_asset_downloads">
4847
<item quantity="one">%1$d Download</item>

manager-ui/src/main/res/values-es/strings_store.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<string name="store_open_module">Abrir la página del módulo</string>
4343

4444
<string name="store_install">Instalar</string>
45-
<string name="store_reinstall">Reinstalar</string>
4645
<string name="store_choose_asset">Elige el archivo que instalar</string>
4746
<plurals name="store_asset_downloads">
4847
<item quantity="one">%1$d descarga</item>

manager-ui/src/main/res/values-fa/strings_store.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
<string name="store_open_module">باز کردن صفحهٔ ماژول</string>
5151
<!-- Install -->
5252
<string name="store_install">نصب</string>
53-
<string name="store_reinstall">نصب دوباره</string>
5453
<string name="store_choose_asset">پرونده‌ای برای نصب برگزینید</string>
5554
<plurals name="store_asset_downloads">
5655
<item quantity="one">%1$d بارگیری</item>

manager-ui/src/main/res/values-fr/strings_store.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<string name="store_open_module">Ouvrir la page du module</string>
4343

4444
<string name="store_install">Installer</string>
45-
<string name="store_reinstall">Réinstaller</string>
4645
<string name="store_choose_asset">Choisir un fichier à installer</string>
4746
<plurals name="store_asset_downloads">
4847
<item quantity="one">%1$d téléchargement</item>

manager-ui/src/main/res/values-in/strings_store.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
<string name="store_open_module">Buka halaman modul</string>
4141

4242
<string name="store_install">Pasang</string>
43-
<string name="store_reinstall">Pasang ulang</string>
4443
<string name="store_choose_asset">Pilih berkas untuk dipasang</string>
4544
<plurals name="store_asset_downloads">
4645
<item quantity="other">%1$d unduhan</item>

manager-ui/src/main/res/values-it/strings_store.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<string name="store_open_module">Apri la pagina del modulo</string>
4343

4444
<string name="store_install">Installa</string>
45-
<string name="store_reinstall">Reinstalla</string>
4645
<string name="store_choose_asset">Scegli un file da installare</string>
4746
<plurals name="store_asset_downloads">
4847
<item quantity="one">%1$d download</item>

0 commit comments

Comments
 (0)