feat(MultiFingerMultiTap): Add two-finger triple-tap shortcut on magnification dialog

The shortcut is separate from single-finger triple-tap. It’s under hardware shortcut and above/outside of Advanced section.

Bug: 297805269
Test: manual
Test: atest ToggleScreenMagnificationPreferenceFragmentTest
Change-Id: Id74cf3e457c04e167f3100d977b6c70c5d601026
This commit is contained in:
Jean Chen
2023-10-18 23:11:54 +08:00
parent 066909bc07
commit 48d73aa3f3
8 changed files with 269 additions and 0 deletions

View File

@@ -42,12 +42,14 @@ import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreferenceCompat;
import androidx.preference.TwoStatePreference;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.Flags;
import com.android.settings.DialogCreatable;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
@@ -83,6 +85,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
private CheckBox mSoftwareTypeCheckBox;
private CheckBox mHardwareTypeCheckBox;
private CheckBox mTripleTapTypeCheckBox;
@Nullable private CheckBox mTwoFingerTripleTapTypeCheckBox;
private DialogCreatable mDialogDelegate;
private MagnificationFollowTypingPreferenceController mFollowTypingPreferenceController;
@@ -330,6 +333,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
if (mTripleTapTypeCheckBox.isChecked()) {
value |= UserShortcutType.TRIPLETAP;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (mTwoFingerTripleTapTypeCheckBox.isChecked()) {
value |= UserShortcutType.TWOFINGERTRIPLETAP;
}
}
return value;
}
@@ -343,6 +351,15 @@ public class ToggleScreenMagnificationPreferenceFragment extends
mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogHardwareView, mHardwareTypeCheckBox);
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
final View dialogTwoFignerTripleTapView =
dialog.findViewById(R.id.two_finger_triple_tap_shortcut);
mTwoFingerTripleTapTypeCheckBox = dialogTwoFignerTripleTapView.findViewById(
R.id.checkbox);
setDialogTextAreaClickListener(
dialogTwoFignerTripleTapView, mTwoFingerTripleTapTypeCheckBox);
}
final View dialogTripleTapView = dialog.findViewById(R.id.triple_tap_shortcut);
mTripleTapTypeCheckBox = dialogTripleTapView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogTripleTapView, mTripleTapTypeCheckBox);
@@ -378,6 +395,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
hasShortcutType(value, UserShortcutType.HARDWARE));
mTripleTapTypeCheckBox.setChecked(
hasShortcutType(value, UserShortcutType.TRIPLETAP));
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
mTwoFingerTripleTapTypeCheckBox.setChecked(
hasShortcutType(value, UserShortcutType.TWOFINGERTRIPLETAP));
}
}
private int restoreOnConfigChangedValue() {
@@ -453,6 +474,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
R.string.accessibility_shortcut_triple_tap_keyword);
list.add(tripleTapTitle);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (hasShortcutType(shortcutTypes, UserShortcutType.TWOFINGERTRIPLETAP)) {
final CharSequence twoFingerTripleTapTitle = context.getText(
R.string.accessibility_shortcut_two_finger_triple_tap_keyword);
list.add(twoFingerTripleTapTitle);
}
}
// Show software shortcut if first time to use.
if (list.isEmpty()) {
@@ -618,6 +646,12 @@ public class ToggleScreenMagnificationPreferenceFragment extends
if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
optInMagnificationValueToSettings(context, UserShortcutType.TRIPLETAP);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (((shortcutTypes & UserShortcutType.TWOFINGERTRIPLETAP)
== UserShortcutType.TWOFINGERTRIPLETAP)) {
optInMagnificationValueToSettings(context, UserShortcutType.TWOFINGERTRIPLETAP);
}
}
}
private static void optInMagnificationValueToSettings(Context context,
@@ -628,6 +662,15 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (shortcutType == UserShortcutType.TWOFINGERTRIPLETAP) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
ON);
return;
}
}
if (hasMagnificationValueInSettings(context, shortcutType)) {
return;
}
@@ -668,6 +711,12 @@ public class ToggleScreenMagnificationPreferenceFragment extends
if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
optOutMagnificationValueFromSettings(context, UserShortcutType.TRIPLETAP);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (((shortcutTypes & UserShortcutType.TWOFINGERTRIPLETAP)
== UserShortcutType.TWOFINGERTRIPLETAP)) {
optOutMagnificationValueFromSettings(context, UserShortcutType.TWOFINGERTRIPLETAP);
}
}
}
private static void optOutMagnificationValueFromSettings(Context context,
@@ -678,6 +727,15 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (shortcutType == UserShortcutType.TWOFINGERTRIPLETAP) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
OFF);
return;
}
}
final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
targetKey);
@@ -713,6 +771,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
exist |= hasMagnificationValueInSettings(context, UserShortcutType.TRIPLETAP);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (((shortcutTypes & UserShortcutType.TWOFINGERTRIPLETAP)
== UserShortcutType.TWOFINGERTRIPLETAP)) {
exist |= hasMagnificationValueInSettings(context,
UserShortcutType.TWOFINGERTRIPLETAP);
}
}
return exist;
}
@@ -723,6 +788,14 @@ public class ToggleScreenMagnificationPreferenceFragment extends
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF) == ON;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (shortcutType == UserShortcutType.TWOFINGERTRIPLETAP) {
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
OFF) == ON;
}
}
final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
targetKey);
@@ -752,6 +825,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
if (hasMagnificationValuesInSettings(context, UserShortcutType.TRIPLETAP)) {
shortcutTypes |= UserShortcutType.TRIPLETAP;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (hasMagnificationValuesInSettings(context, UserShortcutType.TWOFINGERTRIPLETAP)) {
shortcutTypes |= UserShortcutType.TWOFINGERTRIPLETAP;
}
}
return shortcutTypes;
}