Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.snackbar; | 5 package org.chromium.chrome.browser.snackbar; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.util.AttributeSet; | 8 import android.util.AttributeSet; |
| 9 import android.view.View; | |
| 10 import android.view.View.MeasureSpec; | |
| 9 import android.widget.FrameLayout; | 11 import android.widget.FrameLayout; |
| 10 | 12 |
| 11 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; | 13 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; |
| 12 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager.Fullscreen Listener; | 14 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager.Fullscreen Listener; |
| 13 | 15 |
| 14 /** | 16 /** |
| 15 * The container that holds both infobars and snackbars. It will be translated u p and down when the | 17 * The container that holds both infobars and snackbars. It will be translated u p and down when the |
| 16 * bottom controls' offset changes. | 18 * bottom controls' offset changes. |
| 17 */ | 19 */ |
| 18 public class BottomContainer extends FrameLayout implements FullscreenListener { | 20 public class BottomContainer extends FrameLayout implements FullscreenListener { |
| 19 | 21 |
| 20 private ChromeFullscreenManager mFullscreenManager; | 22 private ChromeFullscreenManager mFullscreenManager; |
| 21 | 23 |
| 22 /** | 24 /** |
| 23 * Constructor for XML inflation. | 25 * Constructor for XML inflation. |
| 24 */ | 26 */ |
| 25 public BottomContainer(Context context, AttributeSet attrs) { | 27 public BottomContainer(Context context, AttributeSet attrs) { |
| 26 super(context, attrs); | 28 super(context, attrs); |
| 27 } | 29 } |
| 28 | 30 |
| 29 /** | 31 /** |
| 30 * Initializes this container. | 32 * Initializes this container. |
| 31 */ | 33 */ |
| 32 public void initialize(ChromeFullscreenManager fullscreenManager) { | 34 public void initialize(ChromeFullscreenManager fullscreenManager) { |
| 33 mFullscreenManager = fullscreenManager; | 35 mFullscreenManager = fullscreenManager; |
| 34 mFullscreenManager.addListener(this); | 36 mFullscreenManager.addListener(this); |
| 35 setTranslationY(-fullscreenManager.getBottomControlsHeight()); | 37 setTranslationY(-fullscreenManager.getBottomControlsHeight()); |
| 36 } | 38 } |
| 37 | 39 |
| 40 @Override | |
| 41 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
| 42 int height = 0; | |
|
Ted C
2017/07/18 16:41:18
Why do we need this? Is this view set as MATCH_PA
| |
| 43 int width = MeasureSpec.getSize(widthMeasureSpec); | |
| 44 int count = getChildCount(); | |
| 45 for (int i = 0; i < count; i++) { | |
| 46 final View child = getChildAt(i); | |
| 47 if (child.getVisibility() == GONE) continue; | |
| 48 measureChild(child, widthMeasureSpec, heightMeasureSpec); | |
| 49 width = Math.max(width, child.getMeasuredWidth()); | |
| 50 height = Math.max(height, child.getMeasuredHeight()); | |
| 51 } | |
| 52 height = Math.max(height, getSuggestedMinimumHeight()); | |
| 53 width = Math.max(width, getSuggestedMinimumWidth()); | |
| 54 setMeasuredDimension(width, height); | |
| 55 } | |
| 56 | |
| 38 // FullscreenListner methods | 57 // FullscreenListner methods |
| 39 @Override | 58 @Override |
| 40 public void onControlsOffsetChanged(float topOffset, float bottomOffset, boo lean needsAnimate) { | 59 public void onControlsOffsetChanged(float topOffset, float bottomOffset, boo lean needsAnimate) { |
| 41 setTranslationY(bottomOffset - mFullscreenManager.getBottomControlsHeigh t()); | 60 setTranslationY(bottomOffset - mFullscreenManager.getBottomControlsHeigh t()); |
| 42 } | 61 } |
| 43 | 62 |
| 44 @Override | 63 @Override |
| 45 public void onBottomControlsHeightChanged(int bottomControlsHeight) { | 64 public void onBottomControlsHeightChanged(int bottomControlsHeight) { |
| 46 setTranslationY(-bottomControlsHeight); | 65 setTranslationY(-bottomControlsHeight); |
| 47 } | 66 } |
| 48 | 67 |
| 49 @Override | 68 @Override |
| 50 public void onContentOffsetChanged(float offset) { } | 69 public void onContentOffsetChanged(float offset) { } |
| 51 | 70 |
| 52 @Override | 71 @Override |
| 53 public void onToggleOverlayVideoMode(boolean enabled) { } | 72 public void onToggleOverlayVideoMode(boolean enabled) { } |
| 54 } | 73 } |
| OLD | NEW |