Minor refactoring to replace duplicated logic with existing methods.

Bug: 303511250
Test: tested in child change in the topic
Change-Id: I0995ce5fc685257ba69f7e4aa733de74aeb1fde3
This commit is contained in:
Daniel Norman
2023-11-27 21:57:14 +00:00
parent a909150e53
commit 9f6e77a094

View File

@@ -336,9 +336,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
preference.setChecked(false); preference.setChecked(false);
showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE); showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT_TOGGLE);
} else { } else {
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), shortcutTypes, onAllowButtonFromShortcutToggleClicked();
mComponentName);
showPopupDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL);
} }
} else { } else {
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), shortcutTypes, AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), shortcutTypes,
@@ -351,8 +349,11 @@ public class ToggleAccessibilityServicePreferenceFragment extends
public void onSettingsClicked(ShortcutPreference preference) { public void onSettingsClicked(ShortcutPreference preference) {
final boolean isServiceOnOrShortcutAdded = mShortcutPreference.isChecked() final boolean isServiceOnOrShortcutAdded = mShortcutPreference.isChecked()
|| mToggleServiceSwitchPreference.isChecked(); || mToggleServiceSwitchPreference.isChecked();
showPopupDialog(isServiceOnOrShortcutAdded ? DialogEnums.EDIT_SHORTCUT if (!isServiceOnOrShortcutAdded) {
: DialogEnums.ENABLE_WARNING_FROM_SHORTCUT); showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT);
} else {
onAllowButtonFromShortcutClicked();
}
} }
@Override @Override
@@ -467,7 +468,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mIsDialogShown.set(false); mIsDialogShown.set(false);
showPopupDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL); showPopupDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL);
} }
mWarningDialog.dismiss(); if (mWarningDialog != null) {
mWarningDialog.dismiss();
}
} }
private void onDenyButtonFromEnableToggleClicked() { private void onDenyButtonFromEnableToggleClicked() {
@@ -496,7 +499,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mIsDialogShown.set(false); mIsDialogShown.set(false);
showPopupDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL); showPopupDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL);
mWarningDialog.dismiss(); if (mWarningDialog != null) {
mWarningDialog.dismiss();
}
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
} }
@@ -522,7 +527,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mIsDialogShown.set(false); mIsDialogShown.set(false);
showPopupDialog(DialogEnums.EDIT_SHORTCUT); showPopupDialog(DialogEnums.EDIT_SHORTCUT);
mWarningDialog.dismiss(); if (mWarningDialog != null) {
mWarningDialog.dismiss();
}
} }
private void onDenyButtonFromShortcutClicked() { private void onDenyButtonFromShortcutClicked() {
@@ -537,10 +544,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
if (!mShortcutPreference.isChecked()) { if (!mShortcutPreference.isChecked()) {
showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_TOGGLE); showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_TOGGLE);
} else { } else {
handleConfirmServiceEnabled(/* confirmed= */ true); onAllowButtonFromEnableToggleClicked();
if (serviceSupportsAccessibilityButton()) {
showPopupDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL);
}
} }
} else { } else {
mToggleServiceSwitchPreference.setChecked(true); mToggleServiceSwitchPreference.setChecked(true);