Apply new flow to hint user about triple-tap will delay when user select triple-tap shortcut on window-mode.

Root Cause: Original content in magnification switch shortcut dialog needs to have different versions for different accessibility software shortcuts. Use the generic content and new flow to replace it.

Solution: Apply new flow from UX suggestion.

Bug: 210593079
Test: make RunSettingsRoboTests ROBOTEST_FILTER=MagnificationModePreferenceControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityDialogUtilsTest
Change-Id: Id09b8847cca4fce1f3fb77770a03bff53ae05855
This commit is contained in:
jasonwshsu
2022-03-16 17:31:11 +08:00
parent ca73aa40ef
commit 3b96a2c57e
6 changed files with 179 additions and 231 deletions

View File

@@ -36,7 +36,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -131,7 +130,6 @@ public class AccessibilityDialogUtils {
DialogType.EDIT_SHORTCUT_GENERIC_SUW,
DialogType.EDIT_SHORTCUT_MAGNIFICATION,
DialogType.EDIT_SHORTCUT_MAGNIFICATION_SUW,
DialogType.EDIT_MAGNIFICATION_SWITCH_SHORTCUT,
})
public @interface DialogType {
@@ -139,7 +137,6 @@ public class AccessibilityDialogUtils {
int EDIT_SHORTCUT_GENERIC_SUW = 1;
int EDIT_SHORTCUT_MAGNIFICATION = 2;
int EDIT_SHORTCUT_MAGNIFICATION_SUW = 3;
int EDIT_MAGNIFICATION_SWITCH_SHORTCUT = 4;
}
/**
@@ -159,27 +156,6 @@ public class AccessibilityDialogUtils {
return alertDialog;
}
/**
* Method to show the magnification edit shortcut dialog in Magnification.
*
* @param context A valid context
* @param positiveBtnListener The positive button listener
* @return A magnification edit shortcut dialog in Magnification
*/
public static Dialog createMagnificationSwitchShortcutDialog(Context context,
CustomButtonsClickListener positiveBtnListener) {
final View contentView = createSwitchShortcutDialogContentView(context);
final AlertDialog alertDialog = new AlertDialog.Builder(context)
.setView(contentView)
.setTitle(context.getString(
R.string.accessibility_magnification_switch_shortcut_title))
.create();
setCustomButtonsClickListener(alertDialog, contentView,
positiveBtnListener, /* negativeBtnListener= */ null);
setScrollIndicators(contentView);
return alertDialog;
}
/**
* Updates the software shortcut in edit shortcut dialog.
*
@@ -233,56 +209,6 @@ public class AccessibilityDialogUtils {
View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_BOTTOM);
}
interface CustomButtonsClickListener {
void onClick(@CustomButton int which);
}
/**
* Annotation for customized dialog button type.
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({
CustomButton.POSITIVE,
CustomButton.NEGATIVE,
})
public @interface CustomButton {
int POSITIVE = 1;
int NEGATIVE = 2;
}
private static void setCustomButtonsClickListener(Dialog dialog, View contentView,
CustomButtonsClickListener positiveBtnListener,
CustomButtonsClickListener negativeBtnListener) {
final Button positiveButton = contentView.findViewById(
R.id.custom_positive_button);
final Button negativeButton = contentView.findViewById(
R.id.custom_negative_button);
if (positiveButton != null) {
positiveButton.setOnClickListener(v -> {
if (positiveBtnListener != null) {
positiveBtnListener.onClick(CustomButton.POSITIVE);
}
dialog.dismiss();
});
}
if (negativeButton != null) {
negativeButton.setOnClickListener(v -> {
if (negativeBtnListener != null) {
negativeBtnListener.onClick(CustomButton.NEGATIVE);
}
dialog.dismiss();
});
}
}
private static View createSwitchShortcutDialogContentView(Context context) {
return createEditDialogContentView(context, DialogType.EDIT_MAGNIFICATION_SWITCH_SHORTCUT);
}
/**
* Get a content View for the edit shortcut dialog.
*
@@ -325,12 +251,6 @@ public class AccessibilityDialogUtils {
initMagnifyShortcut(context, contentView);
initAdvancedWidget(contentView);
break;
case DialogType.EDIT_MAGNIFICATION_SWITCH_SHORTCUT:
contentView = inflater.inflate(
R.layout.accessibility_edit_magnification_shortcut, null);
final ImageView image = contentView.findViewById(R.id.image);
image.setImageResource(retrieveSoftwareShortcutImageResId(context));
break;
default:
throw new IllegalArgumentException();
}
@@ -548,18 +468,24 @@ public class AccessibilityDialogUtils {
* @param context A valid context
* @param dialogTitle The title of the dialog
* @param customView The customized view
* @param listener This listener will be invoked when the positive button in the dialog is
* clicked
* @param positiveButtonText The text of the positive button
* @param positiveListener This listener will be invoked when the positive button in the dialog
* is clicked
* @param negativeButtonText The text of the negative button
* @param negativeListener This listener will be invoked when the negative button in the dialog
* is clicked
* @return the {@link Dialog} with the given view
*/
public static Dialog createCustomDialog(Context context, CharSequence dialogTitle,
View customView, DialogInterface.OnClickListener listener) {
View customView, CharSequence positiveButtonText,
DialogInterface.OnClickListener positiveListener, CharSequence negativeButtonText,
DialogInterface.OnClickListener negativeListener) {
final AlertDialog alertDialog = new AlertDialog.Builder(context)
.setView(customView)
.setTitle(dialogTitle)
.setCancelable(true)
.setPositiveButton(R.string.save, listener)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(positiveButtonText, positiveListener)
.setNegativeButton(negativeButtonText, negativeListener)
.create();
if (customView instanceof ScrollView || customView instanceof AbsListView) {
setScrollIndicators(customView);