From 4498b51a1f2deb504a56e1348e896993be8d2611 Mon Sep 17 00:00:00 2001 From: "kingshuk.j@samsung.com" <kingshuk.j@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> Date: Tue, 5 Aug 2014 05:46:08 +0000 Subject: [PATCH] [Android] Account for status bar offset when position paste popup The paste PopupMenu was getting clipped by the status bar when the insertion handle was brought close to the status bar. Update the position of the PopupMenu using the height of the status bar. BUG=397915 Review URL: https://codereview.chromium.org/421173002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287467 0039d316-1c4b-4281-b951-d872f2087c98 --- AUTHORS | 1 + .../content/browser/input/PastePopupMenu.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 7d8f75727c0a8..9bee90f80a006 100644 --- a/AUTHORS +++ b/AUTHORS @@ -225,6 +225,7 @@ Kevin Lee Helpingstine <sig11@reprehensible.net> Kevin M. McCormick <mckev@amazon.com> Kihong Kwon <kihong.kwon@samsung.com> Kim Christensen <kimworking@gmail.com> +Kingshuk Jana <kingshuk.j@samsung.com> Klemen Forstnerič <klemen.forstneric@gmail.com> Krzysztof Wolanski <k.wolanski@samsung.com> Kunal Thakar <kunalt@gmail.com> diff --git a/content/public/android/java/src/org/chromium/content/browser/input/PastePopupMenu.java b/content/public/android/java/src/org/chromium/content/browser/input/PastePopupMenu.java index 0745d207edb7d..b2127709b32de 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/PastePopupMenu.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/PastePopupMenu.java @@ -27,6 +27,7 @@ public class PastePopupMenu implements OnClickListener { private int mRawPositionY; private int mPositionX; private int mPositionY; + private int mStatusBarHeight; private final View[] mPasteViews; private final int[] mPasteViewLayouts; private final int mLineOffsetY; @@ -81,6 +82,13 @@ public class PastePopupMenu implements OnClickListener { 5.0f, mContext.getResources().getDisplayMetrics()); mWidthOffsetX = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30.0f, mContext.getResources().getDisplayMetrics()); + + final int statusBarHeightResourceId = + mContext.getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (statusBarHeightResourceId > 0) { + mStatusBarHeight = + mContext.getResources().getDimensionPixelSize(statusBarHeightResourceId); + } } /** @@ -131,8 +139,13 @@ public class PastePopupMenu implements OnClickListener { coords[0] += mPositionX; coords[1] += mPositionY; + int minOffsetY = 0; + if (mParent.getSystemUiVisibility() == View.SYSTEM_UI_FLAG_VISIBLE) { + minOffsetY = mStatusBarHeight; + } + final int screenWidth = mContext.getResources().getDisplayMetrics().widthPixels; - if (coords[1] < 0) { + if (coords[1] < minOffsetY) { updateContent(false); // Update dimensions from new view contentView = mContainer.getContentView();