Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java

Issue 437423006: Handle abnormal location information (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenuHandler.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
index 6f7f5733db21138c46f76bef09ca54a7f59ae42d..947d5787d6ba8217e58759c93d6c40a40162b0fd 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java
@@ -84,9 +84,10 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
* button)
* @param screenRotation Current device screen rotation.
* @param visibleDisplayFrame The display area rect in which AppMenu is supposed to fit in.
+ * @param screenHeight Current device screen height.
*/
void show(Context context, View anchorView, boolean isByHardwareButton, int screenRotation,
- Rect visibleDisplayFrame) {
+ Rect visibleDisplayFrame, int screenHeight) {
mPopup = new ListPopupWindow(context, null, android.R.attr.popupMenuStyle);
mPopup.setModal(true);
mPopup.setAnchorView(anchorView);
@@ -140,7 +141,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
this, menuItems, LayoutInflater.from(context), showMenuButton);
mPopup.setAdapter(mAdapter);
- setMenuHeight(menuItems.size(), visibleDisplayFrame);
+ setMenuHeight(menuItems.size(), visibleDisplayFrame, screenHeight);
setPopupOffset(mPopup, mCurrentScreenRotation, visibleDisplayFrame);
mPopup.setOnItemClickListener(this);
mPopup.show();
@@ -263,7 +264,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
return mPopup;
}
- private void setMenuHeight(int numMenuItems, Rect appDimensions) {
+ private void setMenuHeight(int numMenuItems, Rect appDimensions, int screenHeight) {
assert mPopup.getAnchorView() != null;
View anchorView = mPopup.getAnchorView();
int[] anchorViewLocation = new int[2];
@@ -271,6 +272,10 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
anchorViewLocation[1] -= appDimensions.top;
int anchorViewImpactHeight = mIsByHardwareButton ? anchorView.getHeight() : 0;
+ // Set appDimensions.height() for abnormal anchorViewLocation.
+ if (anchorViewLocation[1] > screenHeight) {
+ anchorViewLocation[1] = appDimensions.height();
+ }
int availableScreenSpace = Math.max(anchorViewLocation[1],
appDimensions.height() - anchorViewLocation[1] - anchorViewImpactHeight);
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenuHandler.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698