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
@@ -0,0 +1,11 @@
<!-- Using the download icon from Google's Material Icons. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M480,640L280,440L336,382L440,486L440,160L520,160L520,486L624,382L680,440L480,640ZM240,800Q207,800 183.5,776.5Q160,753 160,720L160,600L240,600L240,720Q240,720 240,720Q240,720 240,720L720,720Q720,720 720,720Q720,720 720,720L720,600L800,600L800,720Q800,753 776.5,776.5Q753,800 720,800L240,800Z"/>
</vector>
+3 -1
View File
@@ -6,11 +6,13 @@
<string name="game_not_found">Geometry Dash was not found.</string>
<string name="launcher_launch">Launch</string>
<string name="launcher_settings">Settings</string>
<string name="launcher_download">Download</string>
<string name="launcher_title">Geode</string>
<string name="launcher_logo_alt">geode logo</string>
<string name="launcher_launch_icon_alt">play icon</string>
<string name="launcher_download_icon_alt">download icon</string>
<string name="launcher_settings_icon_alt">settings icon</string>
<string name="geode_download_title">Geode is not installed</string>
<string name="geode_download_title">Geode is not installed.</string>
<string name="geode_download_description">Geode is downloading. Please wait.</string>
<plurals name="automatically_load_countdown">
<item quantity="one">Automatically launching game in %1$d second.</item>