show download button if geode not installed

This commit is contained in:
qimiko committed 2024-01-08 01:49:27 -07:00
1 parent 4c44b30df0
commit f8d7f7f788
4 files changed
+44 -14

No files matched your search

@@ -323,18 +323,31 @@ fun MainScreen(
)
}
}
} else if (gdInstalled && !geodeInstalled) {
} else if (gdInstalled) {
Text(
context.getString(R.string.geode_download_title),
modifier = Modifier.padding(12.dp)
)
OutlinedButton(onClick = { onSettings(context) }) {
Icon(
Icons.Filled.Settings,
contentDescription = context.getString(R.string.launcher_settings_icon_alt)
)
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text(context.getString(R.string.launcher_settings))
Row {
Button(
onClick = { releaseViewModel.runReleaseCheck() },
enabled = !releaseViewModel.isInUpdate
) {
Icon(
painterResource(R.drawable.icon_download),
contentDescription = context.getString(R.string.launcher_download_icon_alt)
)
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text(context.getString(R.string.launcher_download))
}
Spacer(Modifier.size(2.dp))
IconButton(onClick = { onSettings(context) }) {
Icon(
Icons.Filled.Settings,
contentDescription = context.getString(R.string.launcher_settings_icon_alt)
)
}
}
} else {
Text(
@@ -106,8 +106,7 @@ class ReleaseManager private constructor(
_uiState.value = ReleaseManagerState.InDownload(progress, outOf)
}
val geodeName = LaunchUtils.getGeodeFilename()
val geodeFile = getGeodeOutputPath(geodeName)
val geodeFile = getGeodeOutputPath()
// work around a permission issue from adb push
if (geodeFile.exists()) {
@@ -117,7 +116,7 @@ class ReleaseManager private constructor(
DownloadUtils.extractFileFromZipStream(
fileStream,
geodeFile.outputStream(),
geodeName
geodeFile.name
)
} catch (e: Exception) {
sendError(e)
@@ -147,8 +146,11 @@ class ReleaseManager private constructor(
val currentVersion = sharedPreferences.getLong(PreferenceUtils.Key.CURRENT_VERSION_TIMESTAMP)
val latestVersion = release.getDescriptor()
// make sure geode is still here. just in case
val geodeFile = getGeodeOutputPath()
// check if an update is needed
if (latestVersion <= currentVersion) {
if (latestVersion <= currentVersion && geodeFile.exists()) {
_uiState.value = ReleaseManagerState.Finished()
return
}
@@ -172,7 +174,9 @@ class ReleaseManager private constructor(
}
}
private fun getGeodeOutputPath(geodeName: String): File {
private fun getGeodeOutputPath(): File {
val geodeName = LaunchUtils.getGeodeFilename()
val fallbackPath = File(applicationContext.filesDir, "launcher")
val geodeDirectory = applicationContext.getExternalFilesDir("") ?: fallbackPath