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
2 changed files with 33 additions and 5 deletions
@@ -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;
}
}