可选择关闭预见式返回动画 #183
This commit is contained in:
@@ -12,6 +12,7 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.window.OnBackInvokedDispatcher
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
@@ -81,6 +82,19 @@ abstract class BaseActivity<VB : ViewBinding>(
|
||||
initTheme()
|
||||
window.decorView.disableAutoFill()
|
||||
AppContextWrapper.applyLocaleAndFont(this)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
val enable = !AppConfig.isPredictiveBackEnabled
|
||||
if (enable) {
|
||||
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||
OnBackInvokedDispatcher.PRIORITY_DEFAULT
|
||||
) {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
} else {
|
||||
//不注册才是启用
|
||||
}
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q)
|
||||
|
||||
@@ -209,4 +209,5 @@ object PreferKey {
|
||||
const val colorImage = "colorImage"
|
||||
const val bookshelfRefreshingLimit = "bookshelfRefreshingLimit"
|
||||
const val systemMediaControlCompatibilityChange = "systemMediaControlCompatibilityChange"
|
||||
const val isPredictiveBackEnabled = "isPredictiveBackEnabled"
|
||||
}
|
||||
|
||||
@@ -846,5 +846,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.systemMediaControlCompatibilityChange, value)
|
||||
}
|
||||
|
||||
var isPredictiveBackEnabled: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.isPredictiveBackEnabled, true)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.isPredictiveBackEnabled, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +185,10 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
}, 100)
|
||||
}
|
||||
|
||||
PreferKey.isPredictiveBackEnabled -> {
|
||||
toastOnUi("重启以应用")
|
||||
}
|
||||
|
||||
PreferKey.cPrimary -> {
|
||||
val color = getPrefInt(key, ThemeStore.primaryColor(requireContext()))
|
||||
ThemeStore.editTheme(requireContext())
|
||||
|
||||
@@ -138,6 +138,13 @@
|
||||
app:entries="@array/default_home_page"
|
||||
app:entryValues="@array/default_home_page_value" />
|
||||
|
||||
|
||||
<io.legado.app.lib.prefs.SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="isPredictiveBackEnabled"
|
||||
android:summary="仅部分设备可用"
|
||||
android:title="预见性返回手势" />
|
||||
|
||||
</io.legado.app.lib.prefs.PreferenceCategory>
|
||||
|
||||
<io.legado.app.lib.prefs.PreferenceCategory
|
||||
|
||||
Reference in New Issue
Block a user