Redesign roles of variable mUserShortcutTypesCache & mUserShortcutTypes

* mUserShortcutTypesCache -> get value from savedInstanceState only
* mUserShortcutTypes -> use local variables to replace its mission

Bug: 158540780
Test: atest ToggleFeaturePreferenceFragmentTest
Change-Id: I1473f89ed743261f616e8d19733bae829c9dbb02
This commit is contained in:
jasonwshsu
2020-08-25 04:27:36 +08:00
parent c79680cbae
commit 9f54ab9afa
3 changed files with 159 additions and 109 deletions

View File

@@ -313,12 +313,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override
public void onSettingsClicked(ShortcutPreference preference) {
// Do not restore shortcut in shortcut chooser dialog when shortcutPreference is turned off.
mUserShortcutTypesCache = mShortcutPreference.isChecked()
? retrieveUserShortcutType(getPrefContext(), mComponentName.flattenToString(),
UserShortcutType.SOFTWARE)
: UserShortcutType.EMPTY;
final boolean isServiceOnOrShortcutAdded = mShortcutPreference.isChecked()
|| mToggleServiceDividerSwitchPreference.isChecked();
showPopupDialog(isServiceOnOrShortcutAdded ? DialogEnums.EDIT_SHORTCUT