compose: details: Request required permissions for manual download too

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2025-10-13 12:58:42 +08:00
parent e4ff958263
commit acf7b74a2d
2 changed files with 11 additions and 15 deletions

View File

@@ -135,7 +135,7 @@ fun AppDetailsScreen(
exodusReport = exodusReport,
onNavigateUp = onNavigateUp,
onNavigateToAppDetails = onNavigateToAppDetails,
onDownload = { viewModel.enqueueDownload(app!!) },
onDownload = { requestedApp -> viewModel.enqueueDownload(requestedApp) },
onFavorite = { viewModel.toggleFavourite(app!!) },
onCancelDownload = { viewModel.cancelDownload(app!!) },
onUninstall = { AppInstaller.uninstall(context, packageName) },
@@ -201,7 +201,7 @@ private fun ScreenContentApp(
exodusReport: Report? = null,
onNavigateUp: () -> Unit = {},
onNavigateToAppDetails: (packageName: String) -> Unit = {},
onDownload: () -> Unit = {},
onDownload: (requestedApp: App) -> Unit = {},
onFavorite: () -> Unit = {},
onCancelDownload: () -> Unit = {},
onUninstall: () -> Unit = {},
@@ -239,9 +239,9 @@ private fun ScreenContentApp(
}
}
fun onInstall() {
fun onInstall(requestedApp: App = app) {
if (isPermittedToInstall(context, app)) {
onDownload()
onDownload(requestedApp)
onNavigateBack()
} else {
val requiredPermissions = setOfNotNull(
@@ -486,7 +486,8 @@ private fun ScreenContentApp(
is ExtraScreen.ManualDownload -> ManualDownloadScreen(
packageName = app.packageName,
onNavigateUp = ::onNavigateBack
onNavigateUp = ::onNavigateBack,
onRequestInstall = { requestedApp -> onInstall(requestedApp) }
)
is Screen.DevProfile -> DevProfileScreen(

View File

@@ -66,6 +66,7 @@ import kotlinx.coroutines.launch
fun ManualDownloadScreen(
packageName: String,
onNavigateUp: () -> Unit,
onRequestInstall: (requestedApp: App) -> Unit,
viewModel: AppDetailsViewModel = hiltViewModel(key = packageName),
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo()
) {
@@ -76,18 +77,12 @@ fun ManualDownloadScreen(
else -> stringResource(R.string.title_manual_download)
}
LaunchedEffect(key1 = state) {
if (state is AppState.Downloading) {
onNavigateUp()
}
}
ScreenContent(
state = state,
topAppBarTitle = topAppBarTitle,
currentVersionCode = app!!.versionCode,
onNavigateUp = onNavigateUp,
onDownload = { versionCode ->
onRequestInstall = { versionCode ->
val requestedApp = app!!.copy(
versionCode = versionCode,
dependencies = app!!.dependencies.copy(
@@ -96,7 +91,7 @@ fun ManualDownloadScreen(
}
)
)
viewModel.enqueueDownload(requestedApp)
onRequestInstall(requestedApp)
}
)
}
@@ -107,7 +102,7 @@ private fun ScreenContent(
topAppBarTitle: String? = null,
currentVersionCode: Long = 0L,
onNavigateUp: () -> Unit = {},
onDownload: (versionCode: Long) -> Unit = {},
onRequestInstall: (versionCode: Long) -> Unit = {},
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo()
) {
@@ -200,7 +195,7 @@ private fun ScreenContent(
modifier = Modifier.weight(1F),
enabled = !state.inProgress(),
onClick = {
onDownload(versionCode.text.toLong())
onRequestInstall(versionCode.text.toLong())
focusManager.clearFocus()
}
) {