OLD | NEW |
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.annotation.SuppressLint; |
10 import android.content.Context; | 11 import android.content.Context; |
11 import android.content.res.Resources; | 12 import android.content.res.Resources; |
12 import android.graphics.Rect; | 13 import android.graphics.Rect; |
13 import android.graphics.drawable.Drawable; | 14 import android.graphics.drawable.Drawable; |
14 import android.os.Build; | 15 import android.os.Build; |
15 import android.support.annotation.IdRes; | 16 import android.support.annotation.IdRes; |
16 import android.support.annotation.Nullable; | 17 import android.support.annotation.Nullable; |
17 import android.view.KeyEvent; | 18 import android.view.KeyEvent; |
18 import android.view.LayoutInflater; | 19 import android.view.LayoutInflater; |
19 import android.view.Menu; | 20 import android.view.Menu; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 * @param screenRotation Current device screen rotation. | 144 * @param screenRotation Current device screen rotation. |
144 * @param visibleDisplayFrame The display area rect in which AppMenu is supp
osed to fit in. | 145 * @param visibleDisplayFrame The display area rect in which AppMenu is supp
osed to fit in. |
145 * @param screenHeight Current device screen height. | 146 * @param screenHeight Current device screen height. |
146 * @param footerResourceId The resource id for a view to add to the end o
f the menu list. Can | 147 * @param footerResourceId The resource id for a view to add to the end o
f the menu list. Can |
147 * be 0 if no such view is required. | 148 * be 0 if no such view is required. |
148 * @param highlightedItemId The resource id of the menu item that should b
e highlighted. Can | 149 * @param highlightedItemId The resource id of the menu item that should b
e highlighted. Can |
149 * be {@code null} if no item should be highlight
ed. Note that | 150 * be {@code null} if no item should be highlight
ed. Note that |
150 * {@code 0} is dedicated to custom menu items an
d can be declared by | 151 * {@code 0} is dedicated to custom menu items an
d can be declared by |
151 * external apps. | 152 * external apps. |
152 */ | 153 */ |
| 154 @SuppressLint("ResourceType") |
153 void show(Context context, View anchorView, boolean isByPermanentButton, int
screenRotation, | 155 void show(Context context, View anchorView, boolean isByPermanentButton, int
screenRotation, |
154 Rect visibleDisplayFrame, int screenHeight, @IdRes int footerResourc
eId, | 156 Rect visibleDisplayFrame, int screenHeight, @IdRes int footerResourc
eId, |
155 Integer highlightedItemId) { | 157 Integer highlightedItemId) { |
156 mPopup = new ListPopupWindow(context, null, android.R.attr.popupMenuStyl
e); | 158 mPopup = new ListPopupWindow(context, null, android.R.attr.popupMenuStyl
e); |
157 mPopup.setModal(true); | 159 mPopup.setModal(true); |
158 mPopup.setAnchorView(anchorView); | 160 mPopup.setAnchorView(anchorView); |
159 mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); | 161 mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); |
160 | 162 |
161 int footerHeight = 0; | 163 int footerHeight = 0; |
162 if (footerResourceId != 0) { | 164 if (footerResourceId != 0) { |
163 mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW); | 165 mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW); |
| 166 // TODO(crbug.com/635567): Fix lint error properly. |
164 mPromptView = LayoutInflater.from(context).inflate(footerResourceId,
null); | 167 mPromptView = LayoutInflater.from(context).inflate(footerResourceId,
null); |
165 mPopup.setPromptView(mPromptView); | 168 mPopup.setPromptView(mPromptView); |
166 int measureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECI
FIED); | 169 int measureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECI
FIED); |
167 mPromptView.measure(measureSpec, measureSpec); | 170 mPromptView.measure(measureSpec, measureSpec); |
168 footerHeight = mPromptView.getMeasuredHeight(); | 171 footerHeight = mPromptView.getMeasuredHeight(); |
169 } else { | 172 } else { |
170 mPromptView = null; | 173 mPromptView = null; |
171 } | 174 } |
172 mPopup.setOnDismissListener(new OnDismissListener() { | 175 mPopup.setOnDismissListener(new OnDismissListener() { |
173 @Override | 176 @Override |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 } else { | 458 } else { |
456 builder.with((Animator) animatorObject); | 459 builder.with((Animator) animatorObject); |
457 } | 460 } |
458 } | 461 } |
459 } | 462 } |
460 | 463 |
461 mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder); | 464 mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder); |
462 mMenuItemEnterAnimator.start(); | 465 mMenuItemEnterAnimator.start(); |
463 } | 466 } |
464 } | 467 } |
OLD | NEW |