Фикс вечной кнопки
This commit is contained in:
@@ -298,6 +298,12 @@ object UpdateManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
|
// Сбрасываем состояние — установщик запущен, баннер больше не нужен
|
||||||
|
activeApkPath = null
|
||||||
|
activeApkVersion = null
|
||||||
|
persistState(context)
|
||||||
|
_updateState.value = UpdateState.Idle
|
||||||
|
_downloadProgress.value = 0
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Failed to launch installer", e)
|
Log.e(TAG, "Failed to launch installer", e)
|
||||||
_updateState.value = UpdateState.Error("Failed to open installer: ${e.message}")
|
_updateState.value = UpdateState.Error("Failed to open installer: ${e.message}")
|
||||||
@@ -390,8 +396,19 @@ object UpdateManager {
|
|||||||
if (!restoredPath.isNullOrBlank()) {
|
if (!restoredPath.isNullOrBlank()) {
|
||||||
val apk = File(restoredPath)
|
val apk = File(restoredPath)
|
||||||
if (apk.exists()) {
|
if (apk.exists()) {
|
||||||
|
// Показываем баннер только если сохранённая версия НОВЕЕ текущей
|
||||||
|
val isNewer = !restoredVersion.isNullOrBlank() &&
|
||||||
|
compareVersions(restoredVersion, appVersion) > 0
|
||||||
|
if (isNewer) {
|
||||||
_downloadProgress.value = 100
|
_downloadProgress.value = 100
|
||||||
_updateState.value = UpdateState.ReadyToInstall(apk.absolutePath)
|
_updateState.value = UpdateState.ReadyToInstall(apk.absolutePath)
|
||||||
|
} else {
|
||||||
|
// APK уже устарел (юзер обновился или скачал ту же версию) — удаляем
|
||||||
|
apk.delete()
|
||||||
|
activeApkPath = null
|
||||||
|
activeApkVersion = null
|
||||||
|
persistState(context)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
activeApkPath = null
|
activeApkPath = null
|
||||||
activeApkVersion = null
|
activeApkVersion = null
|
||||||
|
|||||||
Reference in New Issue
Block a user