| 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.annotation.SuppressLint; |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 public Menu getMenu() { | 433 public Menu getMenu() { |
| 434 return mMenu; | 434 return mMenu; |
| 435 } | 435 } |
| 436 | 436 |
| 437 private void setMenuHeight(int numMenuItems, Rect appDimensions, | 437 private void setMenuHeight(int numMenuItems, Rect appDimensions, |
| 438 int screenHeight, Rect padding, int footerHeight) { | 438 int screenHeight, Rect padding, int footerHeight) { |
| 439 assert mPopup.getAnchorView() != null; | 439 assert mPopup.getAnchorView() != null; |
| 440 View anchorView = mPopup.getAnchorView(); | 440 View anchorView = mPopup.getAnchorView(); |
| 441 anchorView.getLocationInWindow(mTempLocation); | 441 anchorView.getLocationInWindow(mTempLocation); |
| 442 int anchorViewY = mTempLocation[1] - appDimensions.top; | 442 int anchorViewY = mTempLocation[1] - appDimensions.top; |
| 443 if (isAnchorAtBottom(anchorView, appDimensions)) { | 443 |
| 444 // The framework's PopupWindow positioning changed between N and M. Pre-
N, increasing the |
| 445 // height here causes the menu to be cut-off in landscape mode. See crbu
g.com/722105. |
| 446 // TODO(twellington): stop using ListPopupWindow for the app menu. |
| 447 if (isAnchorAtBottom(anchorView, appDimensions) |
| 448 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| 444 anchorViewY += mPopup.getAnchorView().getHeight(); | 449 anchorViewY += mPopup.getAnchorView().getHeight(); |
| 445 } | 450 } |
| 451 |
| 446 int anchorViewImpactHeight = mIsByPermanentButton ? anchorView.getHeight
() : 0; | 452 int anchorViewImpactHeight = mIsByPermanentButton ? anchorView.getHeight
() : 0; |
| 447 | 453 |
| 448 // Set appDimensions.height() for abnormal anchorViewLocation. | 454 // Set appDimensions.height() for abnormal anchorViewLocation. |
| 449 if (anchorViewY > screenHeight) { | 455 if (anchorViewY > screenHeight) { |
| 450 anchorViewY = appDimensions.height(); | 456 anchorViewY = appDimensions.height(); |
| 451 } | 457 } |
| 452 int availableScreenSpace = Math.max( | 458 int availableScreenSpace = Math.max( |
| 453 anchorViewY, appDimensions.height() - anchorViewY - anchorViewIm
pactHeight); | 459 anchorViewY, appDimensions.height() - anchorViewY - anchorViewIm
pactHeight); |
| 454 | 460 |
| 455 availableScreenSpace -= padding.bottom + footerHeight; | 461 availableScreenSpace -= padding.bottom + footerHeight; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 } else { | 496 } else { |
| 491 builder.with((Animator) animatorObject); | 497 builder.with((Animator) animatorObject); |
| 492 } | 498 } |
| 493 } | 499 } |
| 494 } | 500 } |
| 495 | 501 |
| 496 mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder); | 502 mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder); |
| 497 mMenuItemEnterAnimator.start(); | 503 mMenuItemEnterAnimator.start(); |
| 498 } | 504 } |
| 499 } | 505 } |
| OLD | NEW |