diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/data/Updater.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/data/Updater.kt index 0d498a3d..a93096e2 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/data/Updater.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/data/Updater.kt @@ -112,11 +112,11 @@ object Updater { private val cache = mutableMapOf() fun getLatestRelease(channel: Channel): LatestRelease? { - return cache.getOrPut(channel) { + return cache.getOrPut(Channel.STABLE) { if (BuildConfig.DEBUG) { - fetchLatestDebugCI() ?: fetchLatestRelease(channel) + fetchLatestDebugCI() ?: fetchLatestRelease(Channel.STABLE) } else { - fetchLatestRelease(channel) + fetchLatestRelease(Channel.STABLE) } } } diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt index f174213e..a5053061 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeSettings.kt @@ -75,34 +75,9 @@ class HomeSettings : Routes.Route() { internal fun scheduleUpdateCheck() { val workManager = WorkManager.getInstance(context.androidContext) val updateSettings = context.config.root.global.updateSettings - var configDirty = false - val autoUpdateCheck = updateSettings.autoUpdateCheck.getNullable() ?: run { - configDirty = true - updateSettings.autoUpdateCheck.set(true) - true - } - val frequency = updateSettings.updateCheckFrequency.getNullable() ?: run { - configDirty = true - updateSettings.updateCheckFrequency.set("daily") - "daily" - } - val updateChannel = updateSettings.updateChannel.getNullable() ?: run { - configDirty = true - updateSettings.updateChannel.set("stable") - "stable" - } - if (configDirty) { - context.config.writeConfig() - } + val autoUpdateCheck = updateSettings.autoUpdateCheck.get() if (autoUpdateCheck) { - val repeatInterval = when (frequency) { - "daily" -> 1L - "weekly" -> 7L - "monthly" -> 30L - else -> 1L - } - val constraints = Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build() @@ -112,17 +87,17 @@ class HomeSettings : Routes.Route() { .putString("channel_description", translation["update_notification_channel_description"]) .putString("notification_title", translation["update_notification_title"]) .putString("notification_text", translation["update_notification_text"]) - .putString("update_channel", updateChannel) + .putString("update_channel", "stable") .build() - val workRequest = PeriodicWorkRequestBuilder(repeatInterval, TimeUnit.DAYS) + val workRequest = PeriodicWorkRequestBuilder(1, TimeUnit.DAYS) .setConstraints(constraints) .setInputData(inputData) .build() workManager.enqueueUniquePeriodicWork( "purrfectsnap_update_check", - ExistingPeriodicWorkPolicy.REPLACE, + ExistingPeriodicWorkPolicy.KEEP, workRequest ) } else { diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionHomeView.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionHomeView.kt index 2e8a3537..06f45f6f 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionHomeView.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionHomeView.kt @@ -226,7 +226,6 @@ fun HomeRootSection.AphelionHomeScreen(nav: NavBackStackEntry) { downloadState: UpdateDownloader.DownloadState, downloadProgress: Float, onUpdateAction: () -> Unit, - channelLabel: String, isPurrAuraActive: Boolean, onAboutClick: () -> Unit, avenirNext: FontFamily, @@ -283,7 +282,7 @@ fun HomeRootSection.AphelionHomeScreen(nav: NavBackStackEntry) { horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.CenterHorizontally), verticalArrangement = Arrangement.spacedBy(10.dp) ) { - HeroBadge(translation.format("hero_version_label", "version" to versionName, "channel" to channelLabel)) + HeroBadge(translation.format("hero_version_label", "version" to versionName)) gitHashShort.takeIf { it.isNotBlank() && it.lowercase() != "unknown" }?.let { HeroBadge(translation.format("hero_build_label", "build" to it)) } @@ -453,10 +452,8 @@ fun HomeRootSection.AphelionHomeScreen(nav: NavBackStackEntry) { } } - val updateChannel = context.config.root.global.updateSettings.updateChannel.getNullable() ?: "stable" - val channelLabel = if (updateChannel == "prerelease") translation["channel_label_prerelease"] ?: "" else translation["channel_label_stable"] ?: "" - val latestUpdate by rememberAsyncMutableState(defaultValue = null, keys = arrayOf(updateChannel)) { - Updater.getLatestRelease(if (updateChannel == "prerelease") Channel.PRERELEASE else Channel.STABLE) + val latestUpdate by rememberAsyncMutableState(defaultValue = null) { + Updater.getLatestRelease(Channel.STABLE) } val downloadState by UpdateDownloader.downloadState.collectAsState() val downloadProgress by UpdateDownloader.downloadProgress.collectAsState() @@ -504,7 +501,7 @@ fun HomeRootSection.AphelionHomeScreen(nav: NavBackStackEntry) { changelogLoading = true changelogError = null coroutineScope.launch(Dispatchers.IO) { - val url = if (updateChannel == "prerelease") changelogPrereleaseUrl else changelogStableUrl + val url = changelogStableUrl runCatching { OkHttpClient().newCall(Request.Builder().url(url).build()).execute().use { response -> val body = response.body?.string() ?: throw IllegalStateException("Empty body") @@ -542,7 +539,7 @@ fun HomeRootSection.AphelionHomeScreen(nav: NavBackStackEntry) { fullChangelogLoading = true fullChangelogError = null coroutineScope.launch(Dispatchers.IO) { - val url = if (updateChannel == "prerelease") changelogPrereleaseUrl else changelogStableUrl + val url = changelogStableUrl runCatching { OkHttpClient().newCall(Request.Builder().url(url).build()).execute().use { response -> val body = response.body?.string() ?: throw IllegalStateException("Empty body") @@ -694,7 +691,6 @@ fun HomeRootSection.AphelionHomeScreen(nav: NavBackStackEntry) { downloadState = downloadState, downloadProgress = downloadProgress, onUpdateAction = { latestUpdate?.let { showChangelogDialog = true; loadChangelog() } }, - channelLabel = channelLabel, isPurrAuraActive = isPurrAuraActive, onAboutClick = { routes.about.navigate() }, avenirNext = avenirNext, diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionSettingsView.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionSettingsView.kt index 84e8adff..5fc222b9 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionSettingsView.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/aphelion/AphelionSettingsView.kt @@ -238,22 +238,12 @@ fun HomeSettings.AphelionSettingsScreen(nav: NavBackStackEntry) { RowTitle(title = translation["updates_title"]) Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { var autoUpdateCheck by remember { mutableStateOf(context.config.root.global.updateSettings.autoUpdateCheck.getNullable() ?: true) } - var selectedChannel by remember { mutableStateOf(context.config.root.global.updateSettings.updateChannel.getNullable() ?: "stable") } - var channelMenuExpanded by remember { mutableStateOf(false) } ShiftedRow { Row(modifier = Modifier.fillMaxWidth().heightIn(min = 55.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween) { Text(text = translation["auto_update_check"], fontSize = 14.sp) Switch(checked = autoUpdateCheck, onCheckedChange = { if (context.config.root.global.uiSettings.hapticFeedback.get()) hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress); autoUpdateCheck = it; context.config.root.global.updateSettings.autoUpdateCheck.set(it); context.config.writeConfig(); scheduleUpdateCheck() }, modifier = Modifier.padding(end = 26.dp), colors = purrfectSwitchColors()) } } - AnimatedVisibility(visible = autoUpdateCheck) { - ExposedDropdownMenuBox(expanded = channelMenuExpanded, onExpandedChange = { channelMenuExpanded = it }, modifier = Modifier.fillMaxWidth().padding(horizontal = 26.dp)) { - AestheticDropdownField(value = translation.getOrNull("update_channel_${selectedChannel}") ?: selectedChannel, expanded = channelMenuExpanded, modifier = Modifier.fillMaxWidth().menuAnchor(MenuAnchorType.PrimaryNotEditable), onClick = { channelMenuExpanded = true }) - ExposedDropdownMenu(expanded = channelMenuExpanded, onDismissRequest = { channelMenuExpanded = false }) { - listOf("stable", "prerelease").forEach { channel -> DropdownMenuItem(text = { Text(text = translation.getOrNull("update_channel_${channel}") ?: channel) }, onClick = { selectedChannel = channel; channelMenuExpanded = false; context.config.root.global.updateSettings.updateChannel.set(channel); context.config.writeConfig(); scheduleUpdateCheck() }) } - } - } - } } } diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/legacy/LegacyTheme.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/legacy/LegacyTheme.kt index 3acda50a..26517337 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/legacy/LegacyTheme.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/themes/legacy/LegacyTheme.kt @@ -190,7 +190,6 @@ object LegacyTheme : ThemeContract { downloadState: UpdateDownloader.DownloadState, downloadProgress: Float, onUpdateAction: () -> Unit, - channelLabel: String, isPurrAuraActive: Boolean, onWebsiteClick: () -> Unit, onTelegramClick: () -> Unit, @@ -223,7 +222,7 @@ object LegacyTheme : ThemeContract { horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.CenterHorizontally), verticalArrangement = Arrangement.spacedBy(10.dp) ) { - HeroBadge(translation.format("hero_version_label", "version" to versionName, "channel" to channelLabel)) + HeroBadge(translation.format("hero_version_label", "version" to versionName)) gitHashShort.takeIf { it.isNotBlank() && it.lowercase() != "unknown" }?.let { HeroBadge(translation.format("hero_build_label", "build" to it)) } @@ -345,13 +344,10 @@ object LegacyTheme : ThemeContract { } } } - val updateChannel = context.config.root.global.updateSettings.updateChannel.getNullable() ?: "stable" - val channelLabel = if (updateChannel == "prerelease") translation["channel_label_prerelease"] ?: "" else translation["channel_label_stable"] ?: "" - val latestUpdate by rememberAsyncMutableState(defaultValue = null, keys = arrayOf(updateChannel)) { - val channel = if (updateChannel == "prerelease") Channel.PRERELEASE else Channel.STABLE - Updater.getLatestRelease(channel) + val latestUpdate by rememberAsyncMutableState(defaultValue = null) { + Updater.getLatestRelease(Channel.STABLE) } - val changelogUrl = if (updateChannel == "prerelease") changelogPrereleaseUrl else changelogStableUrl + val changelogUrl = changelogStableUrl val downloadState by UpdateDownloader.downloadState.collectAsState() val downloadProgress by UpdateDownloader.downloadProgress.collectAsState() val coroutineScope = rememberCoroutineScope() @@ -502,7 +498,6 @@ object LegacyTheme : ThemeContract { downloadState = downloadState, downloadProgress = downloadProgress, onUpdateAction = onUpdateButtonClick, - channelLabel = channelLabel, isPurrAuraActive = isPurrAuraActive, onWebsiteClick = { context.androidContext.openLink("https://purrfectsnap.vercel.app/", context.translation["toast_open_link_failed"]) }, onTelegramClick = { context.androidContext.openLink("https://t.me/purrfectsnap_official", context.translation["toast_open_link_failed"]) }, @@ -847,24 +842,12 @@ object LegacyTheme : ThemeContract { RowTitle(title = translation["updates_title"]) Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { var autoUpdateCheck by remember { mutableStateOf(context.config.root.global.updateSettings.autoUpdateCheck.getNullable() ?: true) } - var selectedChannel by remember { mutableStateOf(context.config.root.global.updateSettings.updateChannel.getNullable() ?: "stable") } - var channelMenuExpanded by remember { mutableStateOf(false) } ShiftedRow { Row(modifier = Modifier.fillMaxWidth().heightIn(min = 55.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween) { Text(text = translation["auto_update_check"], fontSize = 14.sp) Switch(checked = autoUpdateCheck, onCheckedChange = { if (context.config.root.global.uiSettings.hapticFeedback.get()) hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress); autoUpdateCheck = it; context.config.root.global.updateSettings.autoUpdateCheck.set(it); context.config.writeConfig(); scheduleUpdateCheck() }, modifier = Modifier.padding(end = 26.dp), colors = purrfectSwitchColors()) } } - AnimatedVisibility(visible = autoUpdateCheck) { - ExposedDropdownMenuBox(expanded = channelMenuExpanded, onExpandedChange = { channelMenuExpanded = it }, modifier = Modifier.fillMaxWidth().padding(horizontal = 26.dp)) { - AestheticDropdownField(value = translation.getOrNull("update_channel_${selectedChannel}") ?: selectedChannel, expanded = channelMenuExpanded, modifier = Modifier.fillMaxWidth().menuAnchor(MenuAnchorType.PrimaryNotEditable), onClick = { channelMenuExpanded = true }) - ExposedDropdownMenu(expanded = channelMenuExpanded, onDismissRequest = { channelMenuExpanded = false }) { - listOf("stable", "prerelease").forEach { channel -> - DropdownMenuItem(text = { Text(text = translation.getOrNull("update_channel_${channel}") ?: channel) }, onClick = { selectedChannel = channel; channelMenuExpanded = false; context.config.root.global.updateSettings.updateChannel.set(channel); context.config.writeConfig(); scheduleUpdateCheck() }) - } - } - } - } } } diff --git a/common/src/main/assets/lang/ar_AE.json b/common/src/main/assets/lang/ar_AE.json index 37e6fdb5..b42bb9a2 100644 --- a/common/src/main/assets/lang/ar_AE.json +++ b/common/src/main/assets/lang/ar_AE.json @@ -202,7 +202,7 @@ "update_content": "الإصدار {version} متاح!", "update_button": "تنزيل", "hero_tagline": "وحدة Xposed تهدف لتحسين تجربة Snapchat الخاصة بك", - "hero_version_label": "الإصدار: {version} - {channel}", + "hero_version_label": "الإصدار: {version}", "hero_build_label": "البناء: {build}", "update_ready_label": "جاهز للتثبيت", "purr_aura_active_label": "PurrAura نشط!", diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json index 2b7149d3..8e4e5440 100644 --- a/common/src/main/assets/lang/en_US.json +++ b/common/src/main/assets/lang/en_US.json @@ -202,7 +202,7 @@ "update_content": "Version {version} is available!", "update_button": "Download", "hero_tagline": "An Xposed Module meant to enhance your Snapchat experience", - "hero_version_label": "Version: {version} - {channel}", + "hero_version_label": "Version: {version}", "hero_build_label": "Build: {build}", "update_ready_label": "Ready to install", "purr_aura_active_label": "PurrAura Active!", diff --git a/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/Global.kt b/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/Global.kt index 90a87b42..5b13f14b 100644 --- a/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/Global.kt +++ b/common/src/main/kotlin/me/eternal/purrfectsnap/common/config/impl/Global.kt @@ -78,8 +78,6 @@ class Global : ConfigContainer() { inner class UpdateSettings : ConfigContainer() { val autoUpdateCheck = boolean("auto_update_check", true) - val updateCheckFrequency = unique("update_check_frequency", "daily", "weekly", "monthly") - val updateChannel = unique("update_channel", "stable", "prerelease") } inner class UISettings : ConfigContainer() {