From 0d9fb97bbb4859ebb3a3ed69f356bd7213bffb4e Mon Sep 17 00:00:00 2001 From: tom5079 Date: Sun, 1 May 2022 15:42:03 +0900 Subject: [PATCH] Show update button in Explore menu when installed version is not the latest --- .../xyz/quaver/pupil/ui/SourceSelector.kt | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/xyz/quaver/pupil/ui/SourceSelector.kt b/app/src/main/java/xyz/quaver/pupil/ui/SourceSelector.kt index 2a2aeb50..0afc1b2e 100644 --- a/app/src/main/java/xyz/quaver/pupil/ui/SourceSelector.kt +++ b/app/src/main/java/xyz/quaver/pupil/ui/SourceSelector.kt @@ -260,24 +260,35 @@ fun Explore() { sourceInfo.version ) { DownloadApkAction(actionState) { - IconButton(onClick = { - if (sourceInfo.name in localSources) { - context.startActivity( - Intent( - Settings.ACTION_APPLICATION_DETAILS_SETTINGS, - Uri.fromParts("package", localSources[sourceInfo.name]!!.packagePath, null) - ) - ) - } else coroutineScope.launch { - val file = actionState.download(sourceInfo) - context.launchApkInstaller(file) + if (localSources[sourceInfo.name]?.version != sourceInfo.version) { + TextButton(onClick = { + coroutineScope.launch { + val file = actionState.download(sourceInfo) + context.launchApkInstaller(file) + } + }) { + Text("UPDATE") + } + } else { + IconButton(onClick = { + if (sourceInfo.name in localSources) { + context.startActivity( + Intent( + Settings.ACTION_APPLICATION_DETAILS_SETTINGS, + Uri.fromParts("package", localSources[sourceInfo.name]!!.packagePath, null) + ) + ) + } else coroutineScope.launch { + val file = actionState.download(sourceInfo) + context.launchApkInstaller(file) + } + }) { + Icon( + if (sourceInfo.name !in localSources) Icons.Default.Download + else Icons.Outlined.Info, + contentDescription = "download" + ) } - }) { - Icon( - if (sourceInfo.name !in localSources) Icons.Default.Download - else Icons.Outlined.Info, - contentDescription = "download" - ) } } }