mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
feat: Auto-updater disabled when user config disable it
Signed-off-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
<bool name="config_default_enable_dot_pagination">true</bool>
|
||||
<bool name="config_default_enable_material_u_popup">true</bool>
|
||||
<bool name="config_default_enable_two_line_allapps">true</bool>
|
||||
<bool name="config_default_test_for_auto_updater">false</bool>
|
||||
<bool name="config_default_enable_nightly_auto_updater">true</bool>
|
||||
|
||||
<item name="config_default_home_icon_size_factor" type="dimen" format="float">1.0</item>
|
||||
<item name="config_default_folder_preview_background_opacity" type="dimen" format="float">1.0</item>
|
||||
|
||||
@@ -518,9 +518,10 @@
|
||||
<string name="major_update_description">You are about to update from Lawnchair <xliff:g example="15" id="current_major_version">%1$s</xliff:g> to Lawnchair <xliff:g example="16" id="next_major_version">%2$s</xliff:g>, please consider carefully as newer major version may be unstable than current version.</string>
|
||||
|
||||
<string name="pro_disabled_by_unknown">Cannot update!</string>
|
||||
<string name="pro_disabled_by_user">Cannot update, turn on Nightly updater in settings!</string>
|
||||
<string name="pro_disabled_by_major_is_newer">Cannot update, This build is way too new!</string>
|
||||
|
||||
<string name="updater">Updater</string>
|
||||
|
||||
<!--
|
||||
|
||||
Backup and restore
|
||||
@@ -606,6 +607,9 @@
|
||||
<string name="home_screen_rotation_label">Home screen rotation</string>
|
||||
<string name="home_screen_rotation_description">Allow home screen rotation when device is rotated</string>
|
||||
|
||||
<string name="auto_updater_label">Auto updater</string>
|
||||
<string name="auto_updater_description">Automatically check for Nightly update when going to About section</string>
|
||||
|
||||
<string name="wallpaper_blur">Blur wallpaper (experimental)</string>
|
||||
<string name="wallpaper_background_blur">Blur intensity</string>
|
||||
<string name="wallpaper_background_blur_factor">Factor threshold</string>
|
||||
|
||||
@@ -52,6 +52,7 @@ import app.lawnchair.ui.preferences.components.HiddenAppsInSearch
|
||||
import app.lawnchair.ui.preferences.data.liveinfo.LiveInformationManager
|
||||
import app.lawnchair.util.kotlinxJson
|
||||
import app.lawnchair.views.overlay.FullScreenOverlayMode
|
||||
import com.android.launcher3.BuildConfig
|
||||
import com.android.launcher3.InvariantDeviceProfile
|
||||
import com.android.launcher3.InvariantDeviceProfile.INDEX_DEFAULT
|
||||
import com.android.launcher3.LauncherAppState
|
||||
@@ -718,9 +719,13 @@ class PreferenceManager2 @Inject constructor(
|
||||
defaultValue = GestureHandlerConfig.NoOp,
|
||||
)
|
||||
|
||||
val debugTestForAutoUpdater = preference(
|
||||
key = booleanPreferencesKey(name = "test_for_auto_updater"),
|
||||
defaultValue = context.resources.getBoolean(R.bool.config_default_test_for_auto_updater),
|
||||
val autoUpdaterNightly = preference(
|
||||
key = booleanPreferencesKey(name = "enable_nightly_auto_updater"),
|
||||
defaultValue = if (BuildConfig.APPLICATION_ID.contains("nightly")) {
|
||||
false
|
||||
} else {
|
||||
context.resources.getBoolean(R.bool.config_default_enable_nightly_auto_updater)
|
||||
}
|
||||
)
|
||||
|
||||
private inline fun <reified T> serializablePreference(
|
||||
|
||||
@@ -135,8 +135,6 @@ sealed interface UpdateState {
|
||||
* @property MAJOR_IS_NEWER Disabled because of current build major version is higher than what is currently offered by updater source.
|
||||
*/
|
||||
enum class UpdateDisabledReason {
|
||||
/** Disabled because of user configuration. */
|
||||
USER_OVERRIDE,
|
||||
/** Disabled because of current build major version is higher than what is currently offered by updater source. */
|
||||
MAJOR_IS_NEWER,
|
||||
}
|
||||
|
||||
@@ -58,7 +58,10 @@ class AboutViewModel(
|
||||
_uiState.update { it.copy(coreTeam = updatedCoreTeam) }
|
||||
}
|
||||
|
||||
if (BuildConfig.APPLICATION_ID.contains("nightly") || prefs2.debugTestForAutoUpdater.firstBlocking()) {
|
||||
// Check if the build variant is Nightly
|
||||
// AND check if user has enabled auto updater (available to Nightly variant)
|
||||
// OR check if user has overridden it in debug flags (available to All variant)
|
||||
if (BuildConfig.APPLICATION_ID.contains("nightly") && prefs2.autoUpdaterNightly.firstBlocking()) {
|
||||
nightlyBuildsRepository.checkForUpdate()
|
||||
viewModelScope.launch {
|
||||
nightlyBuildsRepository.updateState.collect { state ->
|
||||
|
||||
@@ -141,9 +141,6 @@ fun UpdateSection(
|
||||
|
||||
is UpdateState.Disabled -> {
|
||||
var reason = stringResource(R.string.pro_disabled_by_unknown)
|
||||
if (updateState.reason == UpdateDisabledReason.USER_OVERRIDE) {
|
||||
reason = stringResource(R.string.pro_disabled_by_user)
|
||||
}
|
||||
if (updateState.reason == UpdateDisabledReason.MAJOR_IS_NEWER) {
|
||||
reason = stringResource(R.string.pro_disabled_by_major_is_newer)
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ fun DebugMenuPreferences(
|
||||
}
|
||||
|
||||
private val PreferenceManager2.debugFlags: List<Preference<Boolean, Boolean, Preferences.Key<Boolean>>>
|
||||
get() = listOf(showComponentNames, legacyPopupOptionsMigrated, debugTestForAutoUpdater)
|
||||
get() = listOf(showComponentNames, legacyPopupOptionsMigrated)
|
||||
|
||||
private val PreferenceManager2.textFlags: List<Preference<String, String, Preferences.Key<String>>>
|
||||
get() = listOf(additionalFonts, launcherPopupOrder)
|
||||
|
||||
@@ -50,8 +50,10 @@ import app.lawnchair.ui.preferences.components.notificationDotsEnabled
|
||||
import app.lawnchair.ui.preferences.components.notificationServiceEnabled
|
||||
import app.lawnchair.ui.preferences.navigation.GeneralIconPack
|
||||
import app.lawnchair.ui.preferences.navigation.GeneralIconShape
|
||||
import com.android.launcher3.BuildConfig
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.Utilities
|
||||
import com.patrykmichalik.opto.core.firstBlocking
|
||||
|
||||
@Composable
|
||||
fun GeneralPreferences() {
|
||||
@@ -97,6 +99,17 @@ fun GeneralPreferences() {
|
||||
)
|
||||
}
|
||||
}
|
||||
if (BuildConfig.APPLICATION_ID.contains("nightly")) {
|
||||
PreferenceGroup(heading = stringResource(id = R.string.updater)) {
|
||||
Item {
|
||||
SwitchPreference(
|
||||
adapter = prefs2.autoUpdaterNightly.getAdapter(),
|
||||
label = stringResource(id = R.string.auto_updater_label),
|
||||
description = stringResource(id = R.string.auto_updater_description),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
ExpandAndShrink(visible = prefs2.enableFontSelection.asState().value) {
|
||||
PreferenceGroup(heading = stringResource(id = R.string.font_label)) {
|
||||
Item {
|
||||
|
||||
Reference in New Issue
Block a user