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

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

Issue 2848453002: dynamic context menu resizing (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.contextmenu; 5 package org.chromium.chrome.browser.contextmenu;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.support.v4.view.ViewPager; 8 import android.support.v4.view.ViewPager;
9 import android.util.AttributeSet; 9 import android.util.AttributeSet;
10 import android.view.View; 10 import android.view.View;
11 11
12 import org.chromium.chrome.R; 12 import org.chromium.chrome.R;
13 13
14 /** 14 /**
15 * When there is more than one view for the context menu to display, it wraps th e display in a view 15 * When there is more than one view for the context menu to display, it wraps th e display in a view
16 * pager. 16 * pager.
17 */ 17 */
18 public class TabularContextMenuViewPager extends ViewPager { 18 public class TabularContextMenuViewPager extends ViewPager {
19
19 public TabularContextMenuViewPager(Context context) { 20 public TabularContextMenuViewPager(Context context) {
20 super(context); 21 super(context);
21 } 22 }
22 23
23 public TabularContextMenuViewPager(Context context, AttributeSet attrs) { 24 public TabularContextMenuViewPager(Context context, AttributeSet attrs) {
24 super(context, attrs); 25 super(context, attrs);
25 } 26 }
26 27
27 /** 28 /**
28 * Used to show the full ViewPager dialog. Without this the dialog would hav e no height or 29 * Used to show the full ViewPager dialog. Without this the dialog would hav e no height or
29 * width. 30 * width.
30 */ 31 */
31 @Override 32 @Override
32 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 33 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
33 int maxHeight = 0; 34 int menuHeight = 0;
34 int tabHeight = 0; 35 int tabHeight = 0;
36 //getCurrentItem() does not take into account the tab layout unlike getC hildCount()
gone 2017/04/27 18:14:14 space after // end with a period https://google.g
gone 2017/05/02 17:15:41 Welp, that's required because that's how ViewPager
Daniel Park 2017/05/02 17:32:24 Done.
37 int currentItemsIndex = getCurrentItem() + 1;
38
35 for (int i = 0; i < getChildCount(); i++) { 39 for (int i = 0; i < getChildCount(); i++) {
36 View child = getChildAt(i); 40 View child = getChildAt(i);
37 child.measure(widthMeasureSpec, 41 child.measure(widthMeasureSpec,
38 MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.UNSPECIFI ED)); 42 MeasureSpec.makeMeasureSpec(menuHeight, MeasureSpec.UNSPECIF IED));
gone 2017/04/27 18:14:14 makeMeasureSpec(0, MeasureSpec.UNSPECIFIED). Sett
Daniel Park 2017/05/02 17:32:24 Done.
39 int measuredHeight = child.getMeasuredHeight(); 43 int measuredHeight = child.getMeasuredHeight();
40
gone 2017/04/27 18:14:14 Put this line back. It' a comment sandwich otherw
Daniel Park 2017/05/02 17:57:58 Done.
41 // The ViewPager also considers the tab layout one of its children, and needs to be 44 // The ViewPager also considers the tab layout one of its children, and needs to be
42 // treated separately from getting the largest height. 45 // treated separately from getting the largest height.
43 if (child.getId() == R.id.tab_layout && child.getVisibility() != GON E) { 46 if (child.getId() == R.id.tab_layout && child.getVisibility() != GON E) {
44 tabHeight = measuredHeight; 47 tabHeight = measuredHeight;
45 } else { 48 } else if (i == currentItemsIndex) {
46 maxHeight = Math.max(maxHeight, child.getMeasuredHeight()); 49 menuHeight = child.getMeasuredHeight();
50 break;
47 } 51 }
48 } 52 }
49 maxHeight += tabHeight; 53 menuHeight += tabHeight;
gone 2017/04/27 18:14:14 int fullHeight = menuHeight + tabHeight?
Daniel Park 2017/05/02 17:32:24 Done.
50 heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.E XACTLY); 54
55 heightMeasureSpec = MeasureSpec.makeMeasureSpec(menuHeight, MeasureSpec. EXACTLY);
51 super.onMeasure(widthMeasureSpec, heightMeasureSpec); 56 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
52 } 57 }
58
53 } 59 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698