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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java

Issue 2959853002: Adding smarter resizing logic for the context menu on orientation changes (Closed)
Patch Set: Created 3 years, 6 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 | « chrome/android/java/res/values/dimens.xml ('k') | no next file » | 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/contextmenu/TabularContextMenuViewPager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java
index 55a3ad51463e8baa21ae31e467cace64f72fc229..19f58a6e01541e1bed4e7041819bf92093ba9ac2 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java
@@ -16,7 +16,8 @@ import org.chromium.chrome.R;
* pager.
*/
public class TabularContextMenuViewPager extends ViewPager {
- private static final double MAX_WIDTH_PROPORTION = 0.75;
+ private final int mContextMenuMinimumPaddingPx =
+ getResources().getDimensionPixelSize(R.dimen.context_menu_min_padding);
public TabularContextMenuViewPager(Context context) {
super(context);
@@ -38,13 +39,14 @@ public class TabularContextMenuViewPager extends ViewPager {
// getCurrentItem() does not take into account the tab layout unlike getChildCount().
int currentItemsIndex = getCurrentItem() + 1;
- // TODO(injae): Fix sizing on orientation changes (crbug.com/731173)
- int contextMenuWidth = (int) Math.min(
- getResources().getDisplayMetrics().widthPixels * MAX_WIDTH_PROPORTION,
+ // set the context menu width
gone 2017/06/26 21:57:23 English sentences, capital letters and punctuation
Daniel Park 2017/06/29 18:22:58 Done.
+ int deviceWidthPx = getResources().getDisplayMetrics().widthPixels;
+ int contextMenuWidth = Math.min(deviceWidthPx - 2 * mContextMenuMinimumPaddingPx,
getResources().getDimensionPixelSize(R.dimen.context_menu_max_width));
widthMeasureSpec = MeasureSpec.makeMeasureSpec(contextMenuWidth, MeasureSpec.EXACTLY);
+ // figure out which view is about to displayed & measure that view's height
gone 2017/06/26 21:57:23 This current only applies to the block at line 62,
Daniel Park 2017/06/29 18:22:58 Done.
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
@@ -61,7 +63,11 @@ public class TabularContextMenuViewPager extends ViewPager {
break;
}
}
+
+ // set the context menu height
int fullHeight = menuHeight + tabHeight;
+ int deviceHeightPx = getResources().getDisplayMetrics().heightPixels;
+ fullHeight = Math.min(fullHeight, deviceHeightPx - 2 * mContextMenuMinimumPaddingPx);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(fullHeight, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
« no previous file with comments | « chrome/android/java/res/values/dimens.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698