| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.fullscreen; | 5 package org.chromium.chrome.browser.fullscreen; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
| 9 import android.view.Gravity; | 9 import android.view.Gravity; |
| 10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // The amount of time to delay the control show request after returning to a
once visible | 43 // The amount of time to delay the control show request after returning to a
once visible |
| 44 // activity. This delay is meant to allow Android to run its Activity focus
ing animation and | 44 // activity. This delay is meant to allow Android to run its Activity focus
ing animation and |
| 45 // have the controls scroll back in smoothly once that has finished. | 45 // have the controls scroll back in smoothly once that has finished. |
| 46 private static final long ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS = 100; | 46 private static final long ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS = 100; |
| 47 | 47 |
| 48 private final Activity mActivity; | 48 private final Activity mActivity; |
| 49 private final Window mWindow; | 49 private final Window mWindow; |
| 50 private final BrowserStateBrowserControlsVisibilityDelegate mBrowserVisibili
tyDelegate; | 50 private final BrowserStateBrowserControlsVisibilityDelegate mBrowserVisibili
tyDelegate; |
| 51 private final boolean mIsBottomControls; | 51 private final boolean mIsBottomControls; |
| 52 private final boolean mExitFullscreenOnStop; |
| 52 | 53 |
| 53 private ControlContainer mControlContainer; | 54 private ControlContainer mControlContainer; |
| 54 private int mTopControlContainerHeight; | 55 private int mTopControlContainerHeight; |
| 55 private int mBottomControlContainerHeight; | 56 private int mBottomControlContainerHeight; |
| 56 private TabModelSelector mTabModelSelector; | 57 private TabModelSelector mTabModelSelector; |
| 57 private TabModelSelectorTabModelObserver mTabModelObserver; | 58 private TabModelSelectorTabModelObserver mTabModelObserver; |
| 58 | 59 |
| 59 private float mRendererTopControlOffset = Float.NaN; | 60 private float mRendererTopControlOffset = Float.NaN; |
| 60 private float mRendererBottomControlOffset = Float.NaN; | 61 private float mRendererBottomControlOffset = Float.NaN; |
| 61 private float mRendererTopContentOffset; | 62 private float mRendererTopContentOffset; |
| 62 private float mPreviousContentOffset = Float.NaN; | 63 private float mPreviousContentOffset = Float.NaN; |
| 63 private float mControlOffsetRatio; | 64 private float mControlOffsetRatio; |
| 64 private float mPreviousControlOffset; | 65 private float mPreviousControlOffset; |
| 65 private boolean mIsEnteringPersistentModeState; | 66 private boolean mIsEnteringPersistentModeState; |
| 66 | 67 |
| 67 private boolean mInGesture; | 68 private boolean mInGesture; |
| 68 private boolean mContentViewScrolling; | 69 private boolean mContentViewScrolling; |
| 69 | 70 |
| 70 private boolean mBrowserControlsPermanentlyHidden; | 71 private boolean mBrowserControlsPermanentlyHidden; |
| 71 private boolean mBrowserControlsAndroidViewHidden; | 72 private boolean mBrowserControlsAndroidViewHidden; |
| 72 | 73 |
| 73 private final ArrayList<FullscreenListener> mListeners = new ArrayList<Fulls
creenListener>(); | 74 private final ArrayList<FullscreenListener> mListeners = new ArrayList<>(); |
| 74 | 75 |
| 75 /** | 76 /** |
| 76 * A listener that gets notified of changes to the fullscreen state. | 77 * A listener that gets notified of changes to the fullscreen state. |
| 77 */ | 78 */ |
| 78 public interface FullscreenListener { | 79 public interface FullscreenListener { |
| 79 /** | 80 /** |
| 80 * Called whenever the content's offset changes. | 81 * Called whenever the content's offset changes. |
| 81 * @param offset The new offset of the content from the top of the scree
n. | 82 * @param offset The new offset of the content from the top of the scree
n. |
| 82 */ | 83 */ |
| 83 public void onContentOffsetChanged(float offset); | 84 public void onContentOffsetChanged(float offset); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 mControlContainer.getView().requestLayout(); | 117 mControlContainer.getView().requestLayout(); |
| 117 } | 118 } |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 /** | 121 /** |
| 121 * Creates an instance of the fullscreen mode manager. | 122 * Creates an instance of the fullscreen mode manager. |
| 122 * @param activity The activity that supports fullscreen. | 123 * @param activity The activity that supports fullscreen. |
| 123 * @param isBottomControls Whether or not the browser controls are at the bo
ttom of the screen. | 124 * @param isBottomControls Whether or not the browser controls are at the bo
ttom of the screen. |
| 124 */ | 125 */ |
| 125 public ChromeFullscreenManager(Activity activity, boolean isBottomControls)
{ | 126 public ChromeFullscreenManager(Activity activity, boolean isBottomControls)
{ |
| 127 this(activity, isBottomControls, true); |
| 128 } |
| 129 |
| 130 /** |
| 131 * Creates an instance of the fullscreen mode manager. |
| 132 * @param activity The activity that supports fullscreen. |
| 133 * @param isBottomControls Whether or not the browser controls are at the bo
ttom of the screen. |
| 134 * @param exitFullscreenOnStop Whether fullscreen mode should exit on stop -
should be |
| 135 * true for Activities that are not always fulls
creen. |
| 136 */ |
| 137 public ChromeFullscreenManager( |
| 138 Activity activity, boolean isBottomControls, boolean exitFullscreenO
nStop) { |
| 126 super(activity.getWindow()); | 139 super(activity.getWindow()); |
| 127 | 140 |
| 128 mActivity = activity; | 141 mActivity = activity; |
| 129 mWindow = activity.getWindow(); | 142 mWindow = activity.getWindow(); |
| 130 mIsBottomControls = isBottomControls; | 143 mIsBottomControls = isBottomControls; |
| 144 mExitFullscreenOnStop = exitFullscreenOnStop; |
| 131 mBrowserVisibilityDelegate = new BrowserStateBrowserControlsVisibilityDe
legate( | 145 mBrowserVisibilityDelegate = new BrowserStateBrowserControlsVisibilityDe
legate( |
| 132 new Runnable() { | 146 new Runnable() { |
| 133 @Override | 147 @Override |
| 134 public void run() { | 148 public void run() { |
| 135 if (getTab() != null) { | 149 if (getTab() != null) { |
| 136 getTab().updateFullscreenEnabledState(); | 150 getTab().updateFullscreenEnabledState(); |
| 137 } else if (!mBrowserVisibilityDelegate.isHidingBrowserCo
ntrolsEnabled()) { | 151 } else if (!mBrowserVisibilityDelegate.isHidingBrowserCo
ntrolsEnabled()) { |
| 138 setPositionsForTabToNonFullscreen(); | 152 setPositionsForTabToNonFullscreen(); |
| 139 } | 153 } |
| 140 } | 154 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if (tab != null && previousTab != getTab()) { | 235 if (tab != null && previousTab != getTab()) { |
| 222 mBrowserVisibilityDelegate.showControlsTransient(); | 236 mBrowserVisibilityDelegate.showControlsTransient(); |
| 223 } | 237 } |
| 224 if (tab == null && !mBrowserVisibilityDelegate.isHidingBrowserControlsEn
abled()) { | 238 if (tab == null && !mBrowserVisibilityDelegate.isHidingBrowserControlsEn
abled()) { |
| 225 setPositionsForTabToNonFullscreen(); | 239 setPositionsForTabToNonFullscreen(); |
| 226 } | 240 } |
| 227 } | 241 } |
| 228 | 242 |
| 229 @Override | 243 @Override |
| 230 public void onActivityStateChange(Activity activity, int newState) { | 244 public void onActivityStateChange(Activity activity, int newState) { |
| 231 if (newState == ActivityState.STOPPED) { | 245 if (newState == ActivityState.STOPPED && mExitFullscreenOnStop) { |
| 232 // Exit fullscreen in onStop to ensure the system UI flags are set c
orrectly when | 246 // Exit fullscreen in onStop to ensure the system UI flags are set c
orrectly when |
| 233 // showing again (on JB MR2+ builds, the omnibox would be covered by
the | 247 // showing again (on JB MR2+ builds, the omnibox would be covered by
the |
| 234 // notification bar when this was done in onStart()). | 248 // notification bar when this was done in onStart()). |
| 235 setPersistentFullscreenMode(false); | 249 setPersistentFullscreenMode(false); |
| 236 } else if (newState == ActivityState.STARTED) { | 250 } else if (newState == ActivityState.STARTED) { |
| 237 ThreadUtils.postOnUiThreadDelayed(new Runnable() { | 251 ThreadUtils.postOnUiThreadDelayed(new Runnable() { |
| 238 @Override | 252 @Override |
| 239 public void run() { | 253 public void run() { |
| 240 mBrowserVisibilityDelegate.showControlsTransient(); | 254 mBrowserVisibilityDelegate.showControlsTransient(); |
| 241 } | 255 } |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 updateVisuals(); | 665 updateVisuals(); |
| 652 } | 666 } |
| 653 } | 667 } |
| 654 | 668 |
| 655 @Override | 669 @Override |
| 656 public void onContentViewScrollingStateChanged(boolean scrolling) { | 670 public void onContentViewScrollingStateChanged(boolean scrolling) { |
| 657 mContentViewScrolling = scrolling; | 671 mContentViewScrolling = scrolling; |
| 658 if (!scrolling) updateVisuals(); | 672 if (!scrolling) updateVisuals(); |
| 659 } | 673 } |
| 660 } | 674 } |
| OLD | NEW |