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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java

Issue 2738843003: [Home] Add a bottom navigation bar for the BottomSheet (Closed)
Patch Set: Move proguard exception to different file Created 3 years, 9 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 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.widget; 5 package org.chromium.chrome.browser.widget;
6 6
7 import android.animation.Animator; 7 import android.animation.Animator;
8 import android.animation.AnimatorListenerAdapter; 8 import android.animation.AnimatorListenerAdapter;
9 import android.animation.ValueAnimator; 9 import android.animation.ValueAnimator;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 public Tab getActiveTab() { 439 public Tab getActiveTab() {
440 return mTabModelSelector.getCurrentTab(); 440 return mTabModelSelector.getCurrentTab();
441 } 441 }
442 442
443 @Override 443 @Override
444 public boolean isVisible() { 444 public boolean isVisible() {
445 return mCurrentState != SHEET_STATE_PEEK; 445 return mCurrentState != SHEET_STATE_PEEK;
446 } 446 }
447 447
448 /** 448 /**
449 * Gets the minimum offset of the bottom sheet.
450 * @return The min offset.
451 */
452 public float getMinOffset() {
453 return getPeekRatio() * mContainerHeight;
454 }
455
456 /**
457 * Gets the sheet's offset from the bottom of the screen.
458 * @return The sheet's distance from the bottom of the screen.
459 */
460 public float getSheetOffsetFromBottom() {
461 return mContainerHeight - getTranslationY();
462 }
463
464 /**
449 * Determines if a touch event is inside the toolbar. This assumes the toolb ar is the full 465 * Determines if a touch event is inside the toolbar. This assumes the toolb ar is the full
450 * width of the screen and that the toolbar is at the top of the bottom shee t. 466 * width of the screen and that the toolbar is at the top of the bottom shee t.
451 * @param e The motion event to test. 467 * @param e The motion event to test.
452 * @return True if the event occured in the toolbar region. 468 * @return True if the event occured in the toolbar region.
453 */ 469 */
454 private boolean isTouchEventInToolbar(MotionEvent e) { 470 private boolean isTouchEventInToolbar(MotionEvent e) {
455 if (mControlContainer == null) return false; 471 if (mControlContainer == null) return false;
456 472
457 mControlContainer.getLocationInWindow(mLocationArray); 473 mControlContainer.getLocationInWindow(mLocationArray);
458 474
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 604
589 /** 605 /**
590 * Gets the maximum offset of the bottom sheet. 606 * Gets the maximum offset of the bottom sheet.
591 * @return The max offset. 607 * @return The max offset.
592 */ 608 */
593 private float getMaxOffset() { 609 private float getMaxOffset() {
594 return getFullRatio() * mContainerHeight; 610 return getFullRatio() * mContainerHeight;
595 } 611 }
596 612
597 /** 613 /**
598 * Gets the minimum offset of the bottom sheet.
599 * @return The min offset.
600 */
601 private float getMinOffset() {
602 return getPeekRatio() * mContainerHeight;
603 }
604
605 /**
606 * Gets the sheet's offset from the bottom of the screen.
607 * @return The sheet's distance from the bottom of the screen.
608 */
609 private float getSheetOffsetFromBottom() {
610 return mContainerHeight - getTranslationY();
611 }
612
613 /**
614 * Sets the sheet's offset relative to the bottom of the screen. 614 * Sets the sheet's offset relative to the bottom of the screen.
615 * @param offset The offset that the sheet should be. 615 * @param offset The offset that the sheet should be.
616 */ 616 */
617 private void setSheetOffsetFromBottom(float offset) { 617 private void setSheetOffsetFromBottom(float offset) {
618 if (MathUtils.areFloatsEqual(getSheetOffsetFromBottom(), getMinOffset()) 618 if (MathUtils.areFloatsEqual(getSheetOffsetFromBottom(), getMinOffset())
619 && offset > getMinOffset()) { 619 && offset > getMinOffset()) {
620 onSheetOpened(); 620 onSheetOpened();
621 } else if (MathUtils.areFloatsEqual(offset, getMinOffset()) 621 } else if (MathUtils.areFloatsEqual(offset, getMinOffset())
622 && getSheetOffsetFromBottom() > getMinOffset()) { 622 && getSheetOffsetFromBottom() > getMinOffset()) {
623 onSheetClosed(); 623 onSheetClosed();
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 @Override 805 @Override
806 public void onFadingViewVisibilityChanged(boolean visible) {} 806 public void onFadingViewVisibilityChanged(boolean visible) {}
807 807
808 private boolean canMoveSheet() { 808 private boolean canMoveSheet() {
809 boolean isInOverviewMode = mTabModelSelector != null 809 boolean isInOverviewMode = mTabModelSelector != null
810 && (mTabModelSelector.getCurrentTab() == null 810 && (mTabModelSelector.getCurrentTab() == null
811 || mTabModelSelector.getCurrentTab().getActivity().is InOverviewMode()); 811 || mTabModelSelector.getCurrentTab().getActivity().is InOverviewMode());
812 return !isToolbarAndroidViewHidden() && !isInOverviewMode; 812 return !isToolbarAndroidViewHidden() && !isInOverviewMode;
813 } 813 }
814 } 814 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698