From e66b9f88f147eb4d7c95874f727463b39fcb2f04 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 22 Feb 2026 19:37:34 +0700 Subject: [PATCH] feat: Improve toggleable GestureNavContract (#6171) Co-authored-by: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com> --- lawnchair/res/values/strings.xml | 4 +- .../components/SuggestionsPreference.kt | 3 +- .../ExperimentalFeaturesPreferences.kt | 4 +- .../src/app/lawnchair/util/Compatibility.kt | 64 +++++++++---------- 4 files changed, 35 insertions(+), 40 deletions(-) diff --git a/lawnchair/res/values/strings.xml b/lawnchair/res/values/strings.xml index 6f012682dd..7c75157dac 100644 --- a/lawnchair/res/values/strings.xml +++ b/lawnchair/res/values/strings.xml @@ -232,8 +232,8 @@ Folder App - GestureNavContract API - Render launcher animations without root, does not work with heavily modified AOSP + Use GestureNavContract API + Support Android\'s enhanced animations when using gesture navigation. Not all devices support this. May cause animation bugs when in use. GestureNavContract may cause artifacting during animations diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/SuggestionsPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/SuggestionsPreference.kt index fece7ff3dd..0f42837794 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/SuggestionsPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/SuggestionsPreference.kt @@ -11,7 +11,6 @@ import app.lawnchair.preferences.getAdapter import app.lawnchair.preferences2.preferenceManager2 import app.lawnchair.ui.preferences.components.controls.ClickablePreference import app.lawnchair.ui.preferences.components.controls.SwitchPreference -import app.lawnchair.util.isGoogle import com.android.launcher3.R @SuppressLint("WrongConstant") @@ -23,7 +22,7 @@ fun SuggestionsPreference() { val canResolveToSuggestionPreference = context.packageManager.resolveActivity(intent, 0) != null val suggestionSettingsAvailable = hasPkgUsagePermission && canResolveToSuggestionPreference - if (suggestionSettingsAvailable && isGoogle) { + if (suggestionSettingsAvailable) { ClickablePreference( label = stringResource(id = R.string.suggestion_pref_screen_title), onClick = { diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/ExperimentalFeaturesPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/ExperimentalFeaturesPreferences.kt index 9426bd1759..e10b8c97d8 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/ExperimentalFeaturesPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/ExperimentalFeaturesPreferences.kt @@ -36,7 +36,7 @@ import app.lawnchair.util.FileAccessManager import app.lawnchair.util.FileAccessState import app.lawnchair.util.isGestureNavContractCompatible import com.android.launcher3.R -import com.android.launcher3.Utilities.ATLEAST_S +import com.android.launcher3.Utilities import com.android.systemui.shared.system.BlurUtils @Composable @@ -219,7 +219,7 @@ fun ExperimentalFeaturesPreferences( adapter = enableGncAdapter, label = stringResource(id = R.string.gesturenavcontract_label), description = stringResource(id = R.string.gesturenavcontract_description), - enabled = ATLEAST_S, + enabled = Utilities.ATLEAST_Q, ) } Item( diff --git a/lawnchair/src/app/lawnchair/util/Compatibility.kt b/lawnchair/src/app/lawnchair/util/Compatibility.kt index 2a2d51214f..385ba5902a 100644 --- a/lawnchair/src/app/lawnchair/util/Compatibility.kt +++ b/lawnchair/src/app/lawnchair/util/Compatibility.kt @@ -9,12 +9,6 @@ private const val TAG = "Compatibility" val isOnePlusStock = checkOnePlusStock() -val isNothingStock = checkNothingStock() - -val isGoogle = checkGoogle() - -val isSamsung = checkSamsungStock() - val isGestureNavContractCompatible = checkGestureNavContract() private fun checkOnePlusStock(): Boolean = when { @@ -28,43 +22,45 @@ private fun checkOnePlusStock(): Boolean = when { else -> false } -private fun checkNothingStock(): Boolean = when { - getSystemProperty("ro.nothing.version.id", "").isNotEmpty() -> true - getSystemProperty("ro.build.nothing.version", "").isNotEmpty() -> true - getSystemProperty("ro.build.nothing.feature.base", "").isNotEmpty() -> true +private fun checkSamsungStock(): Boolean = when { + getSystemProperty("ro.build.version.oneui", "").isNotEmpty() -> true + getSystemProperty("ro.build.PDA", "").isNotEmpty() && getSystemProperty("ro.build.hidden_ver", "").isNotEmpty() -> true else -> false } -private fun checkGoogle(): Boolean = if (Utilities.ATLEAST_S) { - when { - Build.BRAND.contains("google", true) && - Build.SOC_MODEL.contains("tensor", true) && - Build.SOC_MANUFACTURER.contains("google", true) -> true - - else -> false - } -} else { - when { - Build.BRAND.contains("google", true) && - Build.MANUFACTURER.contains("google", true) && - Build.FINGERPRINT.contains("pixel", true) && - Build.PRODUCT.contains("pixel", true) -> true - - else -> false - } +private fun checkXiaomiStock(): Boolean = when { + getSystemProperty("ro.miui.ui.version.name", "").isNotEmpty() -> true + getSystemProperty("ro.miui.ui.version.code", "").isNotEmpty() -> true + else -> false } -private fun checkSamsungStock(): Boolean = when { - getSystemProperty("ro.build.version.oneui", "").isNotEmpty() -> true - getSystemProperty("ro.config.knox", "").isNotEmpty() -> true - getSystemProperty("ro.build.PDA", "").isNotEmpty() -> true +private fun checkHuaweiHonorStock(): Boolean = when { + getSystemProperty("ro.build.hw_emui_api_level", "").isNotEmpty() -> true + getSystemProperty("ro.config.huawei_smallwindow", "").isNotEmpty() -> true + else -> false +} + +private fun checkOppoStock(): Boolean = when { + getSystemProperty("ro.oppo.version", "").isNotEmpty() -> true + getSystemProperty("ro.build.version.opporom", "").isNotEmpty() -> true + else -> false +} + +private fun checkMeizuStock(): Boolean = when { + getSystemProperty("ro.meizu.build.number", "").isNotEmpty() -> true + getSystemProperty("ro.meizu.project.id", "").isNotEmpty() -> true else -> false } private fun checkGestureNavContract(): Boolean = when { - checkGoogle() -> true - checkNothingStock() -> true - else -> false + !Utilities.ATLEAST_Q -> false + checkOnePlusStock() -> false + checkSamsungStock() -> false + checkXiaomiStock() -> false + checkHuaweiHonorStock() -> false + checkOppoStock() -> false + checkMeizuStock() -> false + else -> true } fun getSystemProperty(property: String, defaultValue: String): String {