summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Miranda <jonmiranda@google.com>2018-03-22 15:59:06 -0700
committerJon Miranda <jonmiranda@google.com>2018-03-22 16:32:33 -0700
commita589814dba4911a0333fc15ec4f897472dabf5b7 (patch)
treef16b5b80f6a941bbd623b4c53817068377c7841a
parentf6a8f955ed985cbd6586b825975e9de60c0a18f6 (diff)
downloadandroid_packages_apps_Trebuchet-a589814dba4911a0333fc15ec4f897472dabf5b7.tar.gz
android_packages_apps_Trebuchet-a589814dba4911a0333fc15ec4f897472dabf5b7.tar.bz2
android_packages_apps_Trebuchet-a589814dba4911a0333fc15ec4f897472dabf5b7.zip
Show instruction toast when user taps on drag handle.
Bug: 74369785 Change-Id: I7017266efcb0db70a8d151eed10442292cb61e70
-rw-r--r--res/values/strings.xml5
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutTextView.java26
2 files changed, 27 insertions, 4 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0b45b8ec9..7d5d81c60 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -72,6 +72,11 @@
<string name="notifications_header">Notifications</string>
<!-- 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>
+ <!-- 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=100] -->
+ <string name="long_accessible_way_to_add_shortcut">Double-tap &amp; hold to pick up a shortcut or use custom actions.</string>
+
<skip />
<!-- Error message when user has filled a home screen -->
<string name="out_of_space">No more room on this Home screen.</string>
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
index 1a5297dc7..c809f27cd 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
@@ -22,6 +22,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import android.widget.Toast;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
@@ -33,7 +34,9 @@ import com.android.launcher3.Utilities;
public class DeepShortcutTextView extends BubbleTextView {
private final Rect mDragHandleBounds = new Rect();
private final int mDragHandleWidth;
- private boolean mShouldPerformClick = true;
+ private boolean mShowInstructionToast = false;
+
+ private Toast mInstructionToast;
public DeepShortcutTextView(Context context) {
this(context, null, 0);
@@ -70,14 +73,29 @@ public class DeepShortcutTextView extends BubbleTextView {
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- // Ignore clicks on the drag handle (long clicks still start the drag).
- mShouldPerformClick = !mDragHandleBounds.contains((int) ev.getX(), (int) ev.getY());
+ // Show toast if user touches the drag handle (long clicks still start the drag).
+ mShowInstructionToast = mDragHandleBounds.contains((int) ev.getX(), (int) ev.getY());
}
return super.onTouchEvent(ev);
}
@Override
public boolean performClick() {
- return mShouldPerformClick && super.performClick();
+ if (mShowInstructionToast) {
+ showToast();
+ return true;
+ }
+ return super.performClick();
+ }
+
+ private void showToast() {
+ if (mInstructionToast != null) {
+ mInstructionToast.cancel();
+ }
+ CharSequence msg = Utilities.wrapForTts(
+ getContext().getText(R.string.long_press_shortcut_to_add),
+ getContext().getString(R.string.long_accessible_way_to_add_shortcut));
+ mInstructionToast = Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT);
+ mInstructionToast.show();
}
}