Merge "Update widget toast strings" into sc-dev

This commit is contained in:
Steven Ng 2021-03-11 16:43:10 +00:00 committed by Android (Google) Code Review
commit 8e5a0a71f7
2 changed files with 33 additions and 5 deletions

View File

@ -40,9 +40,9 @@
<!-- Widgets -->
<!-- Message to tell the user to press and hold on a widget to add it [CHAR_LIMIT=50] -->
<string name="long_press_widget_to_add">Touch &amp; hold to pick up a widget.</string>
<string name="long_press_widget_to_add">Touch &amp; hold to move a widget.</string>
<!-- Accessibility spoken hint message in widget picker, which allows user to add a widget. Custom action is the label for additional accessibility actions available in this mode [CHAR_LIMIT=100] -->
<string name="long_accessible_way_to_add">Double-tap &amp; hold to pick up a widget or use custom actions.</string>
<string name="long_accessible_way_to_add">Double-tap &amp; hold to move a widget or use custom actions.</string>
<!-- The format string for the dimensions of a widget in the drawer -->
<!-- There is a special version of this format string for Farsi -->
<string name="widget_dims_format">%1$d \u00d7 %2$d</string>
@ -104,9 +104,9 @@
<!-- Drag and drop -->
<!-- Message to tell the user to press and hold on a shortcut to add it [CHAR_LIMIT=50] -->
<string name="long_press_shortcut_to_add">Touch &amp; hold to pick up a shortcut.</string>
<string name="long_press_shortcut_to_add">Touch &amp; hold to move a shortcut.</string>
<!-- Accessibility spoken hint message in deep shortcut menu, which allows user to add a shortcut. Custom action is the label for additional accessibility actions available in this mode [CHAR_LIMIT=200] -->
<string name="long_accessible_way_to_add_shortcut">Double-tap &amp; hold to pick up a shortcut or use custom actions.</string>
<string name="long_accessible_way_to_add_shortcut">Double-tap &amp; hold to move a shortcut or use custom actions.</string>
<skip />
<!-- Error message when user has filled a home screen -->

View File

@ -74,7 +74,18 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView
@Override
public final void onClick(View v) {
mWidgetInstructionToast = showWidgetToast(getContext(), mWidgetInstructionToast);
Object tag = null;
if (v instanceof WidgetCell) {
tag = v.getTag();
} else if (v.getParent() instanceof WidgetCell) {
tag = ((WidgetCell) v.getParent()).getTag();
}
if (tag instanceof PendingAddShortcutInfo) {
mWidgetInstructionToast = showShortcutToast(getContext(), mWidgetInstructionToast);
} else {
mWidgetInstructionToast = showWidgetToast(getContext(), mWidgetInstructionToast);
}
}
@Override
@ -158,4 +169,21 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView
toast.show();
return toast;
}
/**
* Show shortcut tap toast prompting user to drag instead.
*/
private static Toast showShortcutToast(Context context, Toast toast) {
// Let the user know that they have to long press to add a widget
if (toast != null) {
toast.cancel();
}
CharSequence msg = Utilities.wrapForTts(
context.getText(R.string.long_press_shortcut_to_add),
context.getString(R.string.long_accessible_way_to_add_shortcut));
toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
toast.show();
return toast;
}
}