compose: details: Request required permissions for manual download too
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -135,7 +135,7 @@ fun AppDetailsScreen(
|
|||||||
exodusReport = exodusReport,
|
exodusReport = exodusReport,
|
||||||
onNavigateUp = onNavigateUp,
|
onNavigateUp = onNavigateUp,
|
||||||
onNavigateToAppDetails = onNavigateToAppDetails,
|
onNavigateToAppDetails = onNavigateToAppDetails,
|
||||||
onDownload = { viewModel.enqueueDownload(app!!) },
|
onDownload = { requestedApp -> viewModel.enqueueDownload(requestedApp) },
|
||||||
onFavorite = { viewModel.toggleFavourite(app!!) },
|
onFavorite = { viewModel.toggleFavourite(app!!) },
|
||||||
onCancelDownload = { viewModel.cancelDownload(app!!) },
|
onCancelDownload = { viewModel.cancelDownload(app!!) },
|
||||||
onUninstall = { AppInstaller.uninstall(context, packageName) },
|
onUninstall = { AppInstaller.uninstall(context, packageName) },
|
||||||
@@ -201,7 +201,7 @@ private fun ScreenContentApp(
|
|||||||
exodusReport: Report? = null,
|
exodusReport: Report? = null,
|
||||||
onNavigateUp: () -> Unit = {},
|
onNavigateUp: () -> Unit = {},
|
||||||
onNavigateToAppDetails: (packageName: String) -> Unit = {},
|
onNavigateToAppDetails: (packageName: String) -> Unit = {},
|
||||||
onDownload: () -> Unit = {},
|
onDownload: (requestedApp: App) -> Unit = {},
|
||||||
onFavorite: () -> Unit = {},
|
onFavorite: () -> Unit = {},
|
||||||
onCancelDownload: () -> Unit = {},
|
onCancelDownload: () -> Unit = {},
|
||||||
onUninstall: () -> Unit = {},
|
onUninstall: () -> Unit = {},
|
||||||
@@ -239,9 +239,9 @@ private fun ScreenContentApp(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onInstall() {
|
fun onInstall(requestedApp: App = app) {
|
||||||
if (isPermittedToInstall(context, app)) {
|
if (isPermittedToInstall(context, app)) {
|
||||||
onDownload()
|
onDownload(requestedApp)
|
||||||
onNavigateBack()
|
onNavigateBack()
|
||||||
} else {
|
} else {
|
||||||
val requiredPermissions = setOfNotNull(
|
val requiredPermissions = setOfNotNull(
|
||||||
@@ -486,7 +486,8 @@ private fun ScreenContentApp(
|
|||||||
|
|
||||||
is ExtraScreen.ManualDownload -> ManualDownloadScreen(
|
is ExtraScreen.ManualDownload -> ManualDownloadScreen(
|
||||||
packageName = app.packageName,
|
packageName = app.packageName,
|
||||||
onNavigateUp = ::onNavigateBack
|
onNavigateUp = ::onNavigateBack,
|
||||||
|
onRequestInstall = { requestedApp -> onInstall(requestedApp) }
|
||||||
)
|
)
|
||||||
|
|
||||||
is Screen.DevProfile -> DevProfileScreen(
|
is Screen.DevProfile -> DevProfileScreen(
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ import kotlinx.coroutines.launch
|
|||||||
fun ManualDownloadScreen(
|
fun ManualDownloadScreen(
|
||||||
packageName: String,
|
packageName: String,
|
||||||
onNavigateUp: () -> Unit,
|
onNavigateUp: () -> Unit,
|
||||||
|
onRequestInstall: (requestedApp: App) -> Unit,
|
||||||
viewModel: AppDetailsViewModel = hiltViewModel(key = packageName),
|
viewModel: AppDetailsViewModel = hiltViewModel(key = packageName),
|
||||||
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo()
|
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo()
|
||||||
) {
|
) {
|
||||||
@@ -76,18 +77,12 @@ fun ManualDownloadScreen(
|
|||||||
else -> stringResource(R.string.title_manual_download)
|
else -> stringResource(R.string.title_manual_download)
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(key1 = state) {
|
|
||||||
if (state is AppState.Downloading) {
|
|
||||||
onNavigateUp()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScreenContent(
|
ScreenContent(
|
||||||
state = state,
|
state = state,
|
||||||
topAppBarTitle = topAppBarTitle,
|
topAppBarTitle = topAppBarTitle,
|
||||||
currentVersionCode = app!!.versionCode,
|
currentVersionCode = app!!.versionCode,
|
||||||
onNavigateUp = onNavigateUp,
|
onNavigateUp = onNavigateUp,
|
||||||
onDownload = { versionCode ->
|
onRequestInstall = { versionCode ->
|
||||||
val requestedApp = app!!.copy(
|
val requestedApp = app!!.copy(
|
||||||
versionCode = versionCode,
|
versionCode = versionCode,
|
||||||
dependencies = app!!.dependencies.copy(
|
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,
|
topAppBarTitle: String? = null,
|
||||||
currentVersionCode: Long = 0L,
|
currentVersionCode: Long = 0L,
|
||||||
onNavigateUp: () -> Unit = {},
|
onNavigateUp: () -> Unit = {},
|
||||||
onDownload: (versionCode: Long) -> Unit = {},
|
onRequestInstall: (versionCode: Long) -> Unit = {},
|
||||||
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo()
|
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo()
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@@ -200,7 +195,7 @@ private fun ScreenContent(
|
|||||||
modifier = Modifier.weight(1F),
|
modifier = Modifier.weight(1F),
|
||||||
enabled = !state.inProgress(),
|
enabled = !state.inProgress(),
|
||||||
onClick = {
|
onClick = {
|
||||||
onDownload(versionCode.text.toLong())
|
onRequestInstall(versionCode.text.toLong())
|
||||||
focusManager.clearFocus()
|
focusManager.clearFocus()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user