mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 08:42:38 +00:00
remove dismissing an update
This commit is contained in:
3 files changed
+7
-39
No files matched your search
@@ -61,7 +61,7 @@ fun downloadLauncherUpdate(context: Context) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String, onDismiss: () -> Unit) {
|
||||
fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String) {
|
||||
val context = LocalContext.current
|
||||
|
||||
ElevatedCard(modifier) {
|
||||
@@ -80,19 +80,12 @@ fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String, onDis
|
||||
modifier = Modifier.padding(horizontal = 10.dp)
|
||||
)
|
||||
|
||||
Row(modifier = Modifier.align(Alignment.End)) {
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text(stringResource(R.string.launcher_update_dismiss))
|
||||
}
|
||||
|
||||
Spacer(Modifier.size(4.dp))
|
||||
|
||||
TextButton(onClick = { downloadUrl(context, openTo) }) {
|
||||
Text(stringResource(R.string.launcher_download))
|
||||
}
|
||||
TextButton(
|
||||
onClick = { downloadUrl(context, openTo) },
|
||||
modifier = Modifier.align(Alignment.End)
|
||||
) {
|
||||
Text(stringResource(R.string.launcher_download))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,10 +256,7 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
|
||||
|
||||
LauncherUpdateIndicator(
|
||||
modifier = modifier,
|
||||
openTo = updateUrl,
|
||||
onDismiss = {
|
||||
releaseViewModel.dismissLauncherUpdate()
|
||||
}
|
||||
openTo = updateUrl
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -91,15 +91,6 @@ class ReleaseManager private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun dismissLauncherUpdate() {
|
||||
val update = availableLauncherUpdate.value ?: return
|
||||
|
||||
val sharedPreferences = PreferenceUtils.get(applicationContext)
|
||||
sharedPreferences.setString(PreferenceUtils.Key.LAST_DISMISSED_UPDATE, update.tagName)
|
||||
|
||||
_availableLauncherUpdate.value = null
|
||||
}
|
||||
|
||||
private suspend fun getLatestRelease(): Release? {
|
||||
val sharedPreferences = PreferenceUtils.get(applicationContext)
|
||||
val useNightly = sharedPreferences.getBoolean(PreferenceUtils.Key.RELEASE_CHANNEL)
|
||||
@@ -167,13 +158,6 @@ class ReleaseManager private constructor(
|
||||
}
|
||||
|
||||
private fun checkLauncherUpdate(launcherUpdate: Release) {
|
||||
val sharedPreferences = PreferenceUtils.get(applicationContext)
|
||||
val lastDismissedVersion = sharedPreferences.getString(PreferenceUtils.Key.LAST_DISMISSED_UPDATE)
|
||||
|
||||
if (!lastDismissedVersion.isNullOrEmpty() && launcherUpdate.tagName == lastDismissedVersion) {
|
||||
return
|
||||
}
|
||||
|
||||
if (launcherUpdate.tagName != BuildConfig.VERSION_NAME) {
|
||||
_availableLauncherUpdate.value = launcherUpdate
|
||||
}
|
||||
|
||||
@@ -98,10 +98,4 @@ class ReleaseViewModel(private val application: Application): ViewModel() {
|
||||
syncUiState(releaseFlow)
|
||||
}
|
||||
}
|
||||
|
||||
fun dismissLauncherUpdate() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
ReleaseManager.get(application).dismissLauncherUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user