mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-24 16:59:22 +00:00
cache launcher update check
This commit is contained in:
3 files changed
+32
-5
No files matched your search
@@ -279,6 +279,15 @@ fun LauncherUpdateInformation(onDismiss: () -> Unit) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
if (nextReleaseName != null && nextRelease == null) {
|
||||||
|
coroutineScope.launch { withContext(Dispatchers.IO) {
|
||||||
|
ReleaseManager.get(context)
|
||||||
|
.checkLauncherUpdate()
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val nextReleaseNameSaved = nextReleaseName
|
val nextReleaseNameSaved = nextReleaseName
|
||||||
if (nextReleaseNameSaved != null) {
|
if (nextReleaseNameSaved != null) {
|
||||||
ModalBottomSheet(onDismissRequest = { onDismiss() }, sheetState = sheetState) {
|
ModalBottomSheet(onDismissRequest = { onDismiss() }, sheetState = sheetState) {
|
||||||
|
|||||||
@@ -251,12 +251,27 @@ class ReleaseManager private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun checkLauncherUpdate() {
|
suspend fun checkLauncherUpdate() {
|
||||||
val launcherRelease = getLatestLauncherUpdate() ?: return
|
val launcherRelease = getLatestLauncherUpdate() ?: return
|
||||||
|
|
||||||
if (launcherRelease.release.tagName != BuildConfig.VERSION_NAME) {
|
// unconditionally track it, we're not using it for checks and it might be good to have
|
||||||
_availableLauncherUpdateTag.value = launcherRelease.getDescription()
|
_availableLauncherUpdateDetails.value = launcherRelease
|
||||||
_availableLauncherUpdateDetails.value = launcherRelease
|
|
||||||
|
val launcherTag = launcherRelease.release.tagName
|
||||||
|
if (launcherTag != BuildConfig.VERSION_NAME) {
|
||||||
|
_availableLauncherUpdateTag.value = launcherTag
|
||||||
|
|
||||||
|
PreferenceUtils.get(applicationContext)
|
||||||
|
.setString(PreferenceUtils.Key.LAST_LAUNCHER_UPDATE, launcherTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkCachedLauncherUpdate() {
|
||||||
|
val lastUpdate = PreferenceUtils.get(applicationContext)
|
||||||
|
.getString(PreferenceUtils.Key.LAST_LAUNCHER_UPDATE) ?: return
|
||||||
|
|
||||||
|
if (lastUpdate != BuildConfig.VERSION_NAME) {
|
||||||
|
_availableLauncherUpdateTag.value = lastUpdate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,6 +290,7 @@ class ReleaseManager private constructor(
|
|||||||
// only check for updates if it's been over 15 minutes since last check
|
// only check for updates if it's been over 15 minutes since last check
|
||||||
val checkMinTime = Clock.System.now().minus(15.minutes).toEpochMilliseconds()
|
val checkMinTime = Clock.System.now().minus(15.minutes).toEpochMilliseconds()
|
||||||
if (!isManual && lastCheckTime > checkMinTime && !fileWasExternallyModified()) {
|
if (!isManual && lastCheckTime > checkMinTime && !fileWasExternallyModified()) {
|
||||||
|
checkCachedLauncherUpdate()
|
||||||
_uiState.value = ReleaseManagerState.Finished()
|
_uiState.value = ReleaseManagerState.Finished()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
|
|||||||
SELECTED_ICON,
|
SELECTED_ICON,
|
||||||
DISABLE_REDESIGN,
|
DISABLE_REDESIGN,
|
||||||
WAIT_PERIOD,
|
WAIT_PERIOD,
|
||||||
LAST_UPDATE_CHECK_TIME
|
LAST_UPDATE_CHECK_TIME,
|
||||||
|
LAST_LAUNCHER_UPDATE,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun defaultValueForBooleanKey(key: Key): Boolean {
|
private fun defaultValueForBooleanKey(key: Key): Boolean {
|
||||||
@@ -205,6 +206,7 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
|
|||||||
Key.SELECTED_ICON -> "PreferenceSelectedIcon"
|
Key.SELECTED_ICON -> "PreferenceSelectedIcon"
|
||||||
Key.WAIT_PERIOD -> "PreferenceWaitPeriod"
|
Key.WAIT_PERIOD -> "PreferenceWaitPeriod"
|
||||||
Key.LAST_UPDATE_CHECK_TIME -> "PreferenceLastUpdateCheckTime"
|
Key.LAST_UPDATE_CHECK_TIME -> "PreferenceLastUpdateCheckTime"
|
||||||
|
Key.LAST_LAUNCHER_UPDATE -> "PreferenceLastLauncherUpdate"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user