From da941652b37062de0078a09459659867a36a6538 Mon Sep 17 00:00:00 2001 From: jhonboy121 Date: Tue, 27 Sep 2022 23:09:10 +0530 Subject: [PATCH] Cherish: use a new task stack for app lock fragments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixes fragments staying in recents on going home * also made other preferences do binder calls asynchronously Signed-off-by: jhonboy121 Signed-off-by: Hưng Phan --- res/values/cherish_strings.xml | 1 + res/xml/cherish_settings_app_lock.xml | 38 +++++++++++++ res/xml/cherish_settings_misc.xml | 9 ++- .../AppLockBiometricPreferenceController.kt | 56 +++++++++++++------ .../applock/AppLockNotificationRedactionPC.kt | 2 +- .../applock/AppLockSettingsFragment.kt | 31 +++++----- .../AppLockSettingsPreferenceController.kt | 20 ++++--- .../security/applock/AppLockSubSettings.kt | 26 +++++++++ 8 files changed, 141 insertions(+), 42 deletions(-) create mode 100644 res/xml/cherish_settings_app_lock.xml create mode 100644 src/com/cherish/settings/security/applock/AppLockSubSettings.kt diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index ceebe45..2cf3e55 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -602,6 +602,7 @@ App lock + Apps will require fingerprint authentication to launch Unlock Enable debugging Disable debugging diff --git a/res/xml/cherish_settings_app_lock.xml b/res/xml/cherish_settings_app_lock.xml new file mode 100644 index 0000000..d8b3ead --- /dev/null +++ b/res/xml/cherish_settings_app_lock.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/xml/cherish_settings_misc.xml b/res/xml/cherish_settings_misc.xml index 7fef609..efb3b3e 100644 --- a/res/xml/cherish_settings_misc.xml +++ b/res/xml/cherish_settings_misc.xml @@ -31,13 +31,20 @@ android:summary="@string/laboratory_ignore_window_secure_summary" android:defaultValue="false"/> - + + + = listOf( + AppLockBiometricPreferenceController(context, lifecycleScope) + ) + companion object { private const val TAG = "AppLockSettingsFragment" @@ -75,6 +78,6 @@ class AppLockSettingsFragment : DashboardFragment(), private const val MENU_ITEM_DEBUG_ID = 101 @JvmField - val SEARCH_INDEX_DATA_PROVIDER = BaseSearchIndexProvider(R.xml.app_lock_package_config_settings) + val SEARCH_INDEX_DATA_PROVIDER = BaseSearchIndexProvider(R.xml.cherish_settings_app_lock) } -} +} \ No newline at end of file diff --git a/src/com/cherish/settings/security/applock/AppLockSettingsPreferenceController.kt b/src/com/cherish/settings/security/applock/AppLockSettingsPreferenceController.kt index a399c58..4961996 100644 --- a/src/com/cherish/settings/security/applock/AppLockSettingsPreferenceController.kt +++ b/src/com/cherish/settings/security/applock/AppLockSettingsPreferenceController.kt @@ -36,16 +36,20 @@ import com.android.settings.core.SubSettingLauncher import com.android.settings.password.ConfirmDeviceCredentialActivity import com.android.settings.security.SecuritySettings import com.android.settingslib.core.lifecycle.Lifecycle -import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType +import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE import com.android.settings.core.BasePreferenceController +import com.android.settings.SettingsActivity +import com.android.settings.core.SettingsBaseActivity +import com.android.settingslib.core.instrumentation.MetricsFeatureProvider + class AppLockSettingsPreferenceController( context: Context, preferenceKey: String, private val host: SecuritySettings?, lifecycle: Lifecycle?, ) : BasePreferenceController(context, preferenceKey), - LifecycleEventObserver { + LifecycleEventObserver { private val lockPatternUtils = LockPatternUtils(context) private val appLockManager = context.getSystemService(AppLockManager::class.java) @@ -58,15 +62,13 @@ class AppLockSettingsPreferenceController( StartActivityForResult() ) { if (it?.resultCode == Activity.RESULT_OK) { - SubSettingLauncher(mContext) + val intent = SubSettingLauncher(mContext) .setDestination(AppLockSettingsFragment::class.qualifiedName) .setSourceMetricsCategory(host.metricsCategory) - .setTransitionType(TransitionType.TRANSITION_SLIDE) - .addFlags( - Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS or - Intent.FLAG_ACTIVITY_NEW_TASK - ) - .launch() + .setTransitionType(TRANSITION_SLIDE) + .toIntent() + intent.setClass(mContext, AppLockSubSettings::class.java) + mContext.startActivity(intent) } } } diff --git a/src/com/cherish/settings/security/applock/AppLockSubSettings.kt b/src/com/cherish/settings/security/applock/AppLockSubSettings.kt new file mode 100644 index 0000000..392f531 --- /dev/null +++ b/src/com/cherish/settings/security/applock/AppLockSubSettings.kt @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 FlamingoOS Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.cherish.settings.security.applock + +import com.android.settings.SettingsActivity + +class AppLockSubSettings : SettingsActivity() { + + override protected fun isValidFragment(fragmentName: String): Boolean { + return AppLockSettingsFragment::class.qualifiedName == fragmentName + } +} \ No newline at end of file