| Index: chrome/android/java/src/org/chromium/chrome/browser/util/AccessibilityUtil.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/AccessibilityUtil.java b/chrome/android/java/src/org/chromium/chrome/browser/util/AccessibilityUtil.java
|
| index 9d4a6ce167c56335f3b9d19a3dbfb85245c9ec53..d643e304be66fbe1d182bdd9cf408e488a6f326e 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/util/AccessibilityUtil.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/util/AccessibilityUtil.java
|
| @@ -10,12 +10,15 @@ import android.content.DialogInterface;
|
| import android.content.Intent;
|
| import android.net.Uri;
|
| import android.support.v7.app.AlertDialog;
|
| +import android.view.Gravity;
|
| +import android.view.View;
|
| import android.view.accessibility.AccessibilityManager;
|
|
|
| import org.chromium.base.ContextUtils;
|
| import org.chromium.base.PackageUtils;
|
| import org.chromium.base.TraceEvent;
|
| import org.chromium.chrome.R;
|
| +import org.chromium.ui.widget.Toast;
|
|
|
| import java.util.List;
|
|
|
| @@ -115,4 +118,30 @@ public class AccessibilityUtil {
|
| AlertDialog dialog = builder.create();
|
| dialog.show();
|
| }
|
| +
|
| + /**
|
| + * Shows the content description toast for items on the toolbar.
|
| + * @param context The context to use for the toast.
|
| + * @param view The view to anchor the toast.
|
| + * @param description The string shown in the toast.
|
| + * @return Whether a toast has been shown successfully.
|
| + */
|
| + public static boolean showAccessibilityToast(
|
| + Context context, View view, CharSequence description) {
|
| + if (description == null) return false;
|
| +
|
| + final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
|
| + final int screenHeight = context.getResources().getDisplayMetrics().heightPixels;
|
| + final int[] screenPos = new int[2];
|
| + view.getLocationOnScreen(screenPos);
|
| + final int width = view.getWidth();
|
| + final int height = view.getHeight();
|
| +
|
| + Toast toast = Toast.makeText(context, description, Toast.LENGTH_SHORT);
|
| + toast.setGravity(Gravity.TOP | Gravity.END, screenWidth - screenPos[0] - width / 2,
|
| + (screenPos[1] < screenHeight / 2) ? screenPos[1] + height / 2
|
| + : screenPos[1] - height * 3 / 2);
|
| + toast.show();
|
| + return true;
|
| + }
|
| }
|
|
|