Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java |
| index d8b9541f3db316e038f9eddfc50ad7689bdf3f2d..cf5238bac3a84a932df49c5087fbbd0521430d47 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java |
| @@ -12,11 +12,13 @@ import android.graphics.Rect; |
| import android.graphics.drawable.Drawable; |
| import android.os.SystemClock; |
| import android.util.AttributeSet; |
| +import android.view.Gravity; |
| import android.view.MotionEvent; |
| import android.view.View; |
| import android.view.ViewGroup; |
| import android.widget.FrameLayout; |
| import android.widget.ProgressBar; |
| +import android.widget.Toast; |
| import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.Tab; |
| @@ -222,6 +224,31 @@ abstract class ToolbarLayout extends FrameLayout implements Toolbar { |
| } |
| /** |
| + * Shows the content description toast for items on the toolbar, usually after long clicking. |
|
Yusuf
2015/06/29 18:03:17
Lets get rid of mentions about long press since th
Ian Wen
2015/06/29 18:27:42
Done.
|
| + * @param view The view to anchor the toast. |
| + * @param stringResId The resource id for the string in the toast. |
| + * @return Whether a toast has been shown successfully. |
| + */ |
| + protected boolean showLongPressToast(View view, int stringResId) { |
| + if (stringResId != 0) { |
|
Yusuf
2015/06/29 18:03:17
if stringRestId==0 return false;
Then get rid of
Ian Wen
2015/06/29 18:27:42
Done.
|
| + final int screenWidth = getResources().getDisplayMetrics().widthPixels; |
| + final int[] screenPos = new int[2]; |
| + view.getLocationOnScreen(screenPos); |
| + final int width = view.getWidth(); |
| + |
| + Toast toast = Toast.makeText( |
| + getContext(), getResources().getString(stringResId), Toast.LENGTH_SHORT); |
| + toast.setGravity( |
| + Gravity.TOP | Gravity.END, |
| + screenWidth - screenPos[0] - width / 2, |
| + getHeight()); |
| + toast.show(); |
| + return true; |
| + } |
| + return false; |
| + } |
| + |
| + /** |
| * @return The provider for toolbar related data. |
| */ |
| protected ToolbarDataProvider getToolbarDataProvider() { |