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

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

Issue 2821223004: [Home] Show the app menu icons as a footer (Closed)
Patch Set: Changes from tedchoc@ review Created 3 years, 8 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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.appmenu; 5 package org.chromium.chrome.browser.appmenu;
6 6
7 import android.animation.Animator; 7 import android.animation.Animator;
8 import android.animation.Animator.AnimatorListener; 8 import android.animation.Animator.AnimatorListener;
9 import android.animation.AnimatorSet; 9 import android.animation.AnimatorSet;
10 import android.content.Context; 10 import android.content.Context;
11 import android.content.res.Resources; 11 import android.content.res.Resources;
12 import android.graphics.Rect; 12 import android.graphics.Rect;
13 import android.graphics.drawable.Drawable; 13 import android.graphics.drawable.Drawable;
14 import android.os.Build; 14 import android.os.Build;
15 import android.support.annotation.IdRes; 15 import android.support.annotation.IdRes;
16 import android.support.annotation.Nullable;
16 import android.view.KeyEvent; 17 import android.view.KeyEvent;
17 import android.view.LayoutInflater; 18 import android.view.LayoutInflater;
18 import android.view.Menu; 19 import android.view.Menu;
19 import android.view.MenuItem; 20 import android.view.MenuItem;
20 import android.view.Surface; 21 import android.view.Surface;
21 import android.view.View; 22 import android.view.View;
22 import android.view.View.MeasureSpec; 23 import android.view.View.MeasureSpec;
23 import android.view.View.OnKeyListener; 24 import android.view.View.OnKeyListener;
24 import android.view.ViewGroup; 25 import android.view.ViewGroup;
25 import android.widget.AdapterView; 26 import android.widget.AdapterView;
(...skipping 26 matching lines...) Expand all
52 private final Menu mMenu; 53 private final Menu mMenu;
53 private final int mItemRowHeight; 54 private final int mItemRowHeight;
54 private final int mItemDividerHeight; 55 private final int mItemDividerHeight;
55 private final int mVerticalFadeDistance; 56 private final int mVerticalFadeDistance;
56 private final int mNegativeSoftwareVerticalOffset; 57 private final int mNegativeSoftwareVerticalOffset;
57 private final int[] mTempLocation; 58 private final int[] mTempLocation;
58 59
59 private ListPopupWindow mPopup; 60 private ListPopupWindow mPopup;
60 private AppMenuAdapter mAdapter; 61 private AppMenuAdapter mAdapter;
61 private AppMenuHandler mHandler; 62 private AppMenuHandler mHandler;
63 private View mPromptView;
62 private int mCurrentScreenRotation = -1; 64 private int mCurrentScreenRotation = -1;
63 private boolean mIsByPermanentButton; 65 private boolean mIsByPermanentButton;
64 private AnimatorSet mMenuItemEnterAnimator; 66 private AnimatorSet mMenuItemEnterAnimator;
65 private AnimatorListener mAnimationHistogramRecorder = AnimationFrameTimeHis togram 67 private AnimatorListener mAnimationHistogramRecorder = AnimationFrameTimeHis togram
66 .getAnimatorRecorder("WrenchMenu.OpeningAnimationFrameTimes"); 68 .getAnimatorRecorder("WrenchMenu.OpeningAnimationFrameTimes");
67 69
68 /** 70 /**
69 * Creates and sets up the App Menu. 71 * Creates and sets up the App Menu.
70 * @param menu Original menu created by the framework. 72 * @param menu Original menu created by the framework.
71 * @param itemRowHeight Desired height for each app menu row. 73 * @param itemRowHeight Desired height for each app menu row.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 Rect visibleDisplayFrame, int screenHeight, @IdRes int footerResourc eId, 154 Rect visibleDisplayFrame, int screenHeight, @IdRes int footerResourc eId,
153 Integer highlightedItemId) { 155 Integer highlightedItemId) {
154 mPopup = new ListPopupWindow(context, null, android.R.attr.popupMenuStyl e); 156 mPopup = new ListPopupWindow(context, null, android.R.attr.popupMenuStyl e);
155 mPopup.setModal(true); 157 mPopup.setModal(true);
156 mPopup.setAnchorView(anchorView); 158 mPopup.setAnchorView(anchorView);
157 mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); 159 mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
158 160
159 int footerHeight = 0; 161 int footerHeight = 0;
160 if (footerResourceId != 0) { 162 if (footerResourceId != 0) {
161 mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW); 163 mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW);
162 View promptView = LayoutInflater.from(context).inflate(footerResourc eId, null); 164 mPromptView = LayoutInflater.from(context).inflate(footerResourceId, null);
163 mPopup.setPromptView(promptView); 165 mPopup.setPromptView(mPromptView);
164 int measureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECI FIED); 166 int measureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECI FIED);
165 promptView.measure(measureSpec, measureSpec); 167 mPromptView.measure(measureSpec, measureSpec);
166 footerHeight = promptView.getMeasuredHeight(); 168 footerHeight = mPromptView.getMeasuredHeight();
169 } else {
170 mPromptView = null;
167 } 171 }
168 mPopup.setOnDismissListener(new OnDismissListener() { 172 mPopup.setOnDismissListener(new OnDismissListener() {
169 @Override 173 @Override
170 public void onDismiss() { 174 public void onDismiss() {
171 if (mPopup.getAnchorView() instanceof ImageButton) { 175 if (mPopup.getAnchorView() instanceof ImageButton) {
172 ((ImageButton) mPopup.getAnchorView()).setSelected(false); 176 ((ImageButton) mPopup.getAnchorView()).setSelected(false);
173 } 177 }
174 178
175 if (mMenuItemEnterAnimator != null) mMenuItemEnterAnimator.cance l(); 179 if (mMenuItemEnterAnimator != null) mMenuItemEnterAnimator.cance l();
176 180
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 @Override 261 @Override
258 public void onLayoutChange(View v, int left, int top, int right, int bottom, 262 public void onLayoutChange(View v, int left, int top, int right, int bottom,
259 int oldLeft, int oldTop, int oldRight, int oldBottom) { 263 int oldLeft, int oldTop, int oldRight, int oldBottom) {
260 mPopup.getListView().removeOnLayoutChangeListener(this); 264 mPopup.getListView().removeOnLayoutChangeListener(this);
261 runMenuItemEnterAnimations(); 265 runMenuItemEnterAnimations();
262 } 266 }
263 }); 267 });
264 } 268 }
265 } 269 }
266 270
271 /**
272 * @return The prompt view for the menu or null if one has not been set.
273 */
274 @Nullable
275 public View getPromptView() {
276 return mPromptView;
277 }
278
267 private boolean isAnchorAtBottom(View anchorView, Rect visibleDisplayFrame) { 279 private boolean isAnchorAtBottom(View anchorView, Rect visibleDisplayFrame) {
268 anchorView.getLocationOnScreen(mTempLocation); 280 anchorView.getLocationOnScreen(mTempLocation);
269 return (mTempLocation[1] + anchorView.getHeight()) == visibleDisplayFram e.bottom; 281 return (mTempLocation[1] + anchorView.getHeight()) == visibleDisplayFram e.bottom;
270 } 282 }
271 283
272 private void setPopupOffset( 284 private void setPopupOffset(
273 ListPopupWindow popup, int screenRotation, Rect appRect, Rect paddin g) { 285 ListPopupWindow popup, int screenRotation, Rect appRect, Rect paddin g) {
274 popup.getAnchorView().getLocationInWindow(mTempLocation); 286 popup.getAnchorView().getLocationInWindow(mTempLocation);
275 int anchorViewX = mTempLocation[0]; 287 int anchorViewX = mTempLocation[0];
276 int anchorHeight = popup.getAnchorView().getHeight(); 288 int anchorHeight = popup.getAnchorView().getHeight();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } else { 455 } else {
444 builder.with((Animator) animatorObject); 456 builder.with((Animator) animatorObject);
445 } 457 }
446 } 458 }
447 } 459 }
448 460
449 mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder); 461 mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder);
450 mMenuItemEnterAnimator.start(); 462 mMenuItemEnterAnimator.start();
451 } 463 }
452 } 464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698