forked from geode-sdk/android-launcher
remove dismissing an update
This commit is contained in:
3 files changed
+6
-38
No files matched your search
@@ -61,7 +61,7 @@ fun downloadLauncherUpdate(context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String, onDismiss: () -> Unit) {
|
fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
ElevatedCard(modifier) {
|
ElevatedCard(modifier) {
|
||||||
@@ -80,20 +80,13 @@ fun LauncherUpdateIndicator(modifier: Modifier = Modifier, openTo: String, onDis
|
|||||||
modifier = Modifier.padding(horizontal = 10.dp)
|
modifier = Modifier.padding(horizontal = 10.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(modifier = Modifier.align(Alignment.End)) {
|
TextButton(
|
||||||
TextButton(onClick = onDismiss) {
|
onClick = { downloadUrl(context, openTo) },
|
||||||
Text(stringResource(R.string.launcher_update_dismiss))
|
modifier = Modifier.align(Alignment.End)
|
||||||
}
|
) {
|
||||||
|
|
||||||
Spacer(Modifier.size(4.dp))
|
|
||||||
|
|
||||||
TextButton(onClick = { downloadUrl(context, openTo) }) {
|
|
||||||
Text(stringResource(R.string.launcher_download))
|
Text(stringResource(R.string.launcher_download))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,10 +256,7 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
|
|||||||
|
|
||||||
LauncherUpdateIndicator(
|
LauncherUpdateIndicator(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
openTo = updateUrl,
|
openTo = updateUrl
|
||||||
onDismiss = {
|
|
||||||
releaseViewModel.dismissLauncherUpdate()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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? {
|
private suspend fun getLatestRelease(): Release? {
|
||||||
val sharedPreferences = PreferenceUtils.get(applicationContext)
|
val sharedPreferences = PreferenceUtils.get(applicationContext)
|
||||||
val useNightly = sharedPreferences.getBoolean(PreferenceUtils.Key.RELEASE_CHANNEL)
|
val useNightly = sharedPreferences.getBoolean(PreferenceUtils.Key.RELEASE_CHANNEL)
|
||||||
@@ -167,13 +158,6 @@ class ReleaseManager private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkLauncherUpdate(launcherUpdate: Release) {
|
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) {
|
if (launcherUpdate.tagName != BuildConfig.VERSION_NAME) {
|
||||||
_availableLauncherUpdate.value = launcherUpdate
|
_availableLauncherUpdate.value = launcherUpdate
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,10 +98,4 @@ class ReleaseViewModel(private val application: Application): ViewModel() {
|
|||||||
syncUiState(releaseFlow)
|
syncUiState(releaseFlow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dismissLauncherUpdate() {
|
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
|
||||||
ReleaseManager.get(application).dismissLauncherUpdate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user