feat: Improve toggleable GestureNavContract (#6171)

Co-authored-by: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com>
This commit is contained in:
Pun Butrach
2026-02-22 19:37:34 +07:00
committed by GitHub
parent 0f0a75726d
commit e66b9f88f1
4 changed files with 35 additions and 40 deletions

View File

@@ -232,8 +232,8 @@
<string name="folder_shape_label">Folder</string>
<string name="app_icon_shape_label">App</string>
<string name="gesturenavcontract_label">GestureNavContract API</string>
<string name="gesturenavcontract_description">Render launcher animations without root, does not work with heavily modified AOSP</string>
<string name="gesturenavcontract_label">Use GestureNavContract API</string>
<string name="gesturenavcontract_description">Support Android\'s enhanced animations when using gesture navigation. Not all devices support this. May cause animation bugs when in use.</string>
<string name="gesturenavcontract_warning_incompatibility">GestureNavContract may cause artifacting during animations</string>

View File

@@ -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 = {

View File

@@ -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(

View File

@@ -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 {