| 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; | |
| 53 | 52 |
| 54 private ControlContainer mControlContainer; | 53 private ControlContainer mControlContainer; |
| 55 private int mTopControlContainerHeight; | 54 private int mTopControlContainerHeight; |
| 56 private int mBottomControlContainerHeight; | 55 private int mBottomControlContainerHeight; |
| 57 private TabModelSelector mTabModelSelector; | 56 private TabModelSelector mTabModelSelector; |
| 58 private TabModelSelectorTabModelObserver mTabModelObserver; | 57 private TabModelSelectorTabModelObserver mTabModelObserver; |
| 59 | 58 |
| 60 private float mRendererTopControlOffset = Float.NaN; | 59 private float mRendererTopControlOffset = Float.NaN; |
| 61 private float mRendererBottomControlOffset = Float.NaN; | 60 private float mRendererBottomControlOffset = Float.NaN; |
| 62 private float mRendererTopContentOffset; | 61 private float mRendererTopContentOffset; |
| 63 private float mPreviousContentOffset = Float.NaN; | 62 private float mPreviousContentOffset = Float.NaN; |
| 64 private float mControlOffsetRatio; | 63 private float mControlOffsetRatio; |
| 65 private float mPreviousControlOffset; | 64 private float mPreviousControlOffset; |
| 66 private boolean mIsEnteringPersistentModeState; | 65 private boolean mIsEnteringPersistentModeState; |
| 67 | 66 |
| 68 private boolean mInGesture; | 67 private boolean mInGesture; |
| 69 private boolean mContentViewScrolling; | 68 private boolean mContentViewScrolling; |
| 70 | 69 |
| 71 private boolean mBrowserControlsPermanentlyHidden; | 70 private boolean mBrowserControlsPermanentlyHidden; |
| 72 private boolean mBrowserControlsAndroidViewHidden; | 71 private boolean mBrowserControlsAndroidViewHidden; |
| 73 | 72 |
| 74 private final ArrayList<FullscreenListener> mListeners = new ArrayList<>(); | 73 private final ArrayList<FullscreenListener> mListeners = new ArrayList<Fulls
creenListener>(); |
| 75 | 74 |
| 76 /** | 75 /** |
| 77 * A listener that gets notified of changes to the fullscreen state. | 76 * A listener that gets notified of changes to the fullscreen state. |
| 78 */ | 77 */ |
| 79 public interface FullscreenListener { | 78 public interface FullscreenListener { |
| 80 /** | 79 /** |
| 81 * Called whenever the content's offset changes. | 80 * Called whenever the content's offset changes. |
| 82 * @param offset The new offset of the content from the top of the scree
n. | 81 * @param offset The new offset of the content from the top of the scree
n. |
| 83 */ | 82 */ |
| 84 public void onContentOffsetChanged(float offset); | 83 public void onContentOffsetChanged(float offset); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 mControlContainer.getView().requestLayout(); | 116 mControlContainer.getView().requestLayout(); |
| 118 } | 117 } |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 /** | 120 /** |
| 122 * Creates an instance of the fullscreen mode manager. | 121 * Creates an instance of the fullscreen mode manager. |
| 123 * @param activity The activity that supports fullscreen. | 122 * @param activity The activity that supports fullscreen. |
| 124 * @param isBottomControls Whether or not the browser controls are at the bo
ttom of the screen. | 123 * @param isBottomControls Whether or not the browser controls are at the bo
ttom of the screen. |
| 125 */ | 124 */ |
| 126 public ChromeFullscreenManager(Activity activity, boolean isBottomControls)
{ | 125 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) { | |
| 139 super(activity.getWindow()); | 126 super(activity.getWindow()); |
| 140 | 127 |
| 141 mActivity = activity; | 128 mActivity = activity; |
| 142 mWindow = activity.getWindow(); | 129 mWindow = activity.getWindow(); |
| 143 mIsBottomControls = isBottomControls; | 130 mIsBottomControls = isBottomControls; |
| 144 mExitFullscreenOnStop = exitFullscreenOnStop; | |
| 145 mBrowserVisibilityDelegate = new BrowserStateBrowserControlsVisibilityDe
legate( | 131 mBrowserVisibilityDelegate = new BrowserStateBrowserControlsVisibilityDe
legate( |
| 146 new Runnable() { | 132 new Runnable() { |
| 147 @Override | 133 @Override |
| 148 public void run() { | 134 public void run() { |
| 149 if (getTab() != null) { | 135 if (getTab() != null) { |
| 150 getTab().updateFullscreenEnabledState(); | 136 getTab().updateFullscreenEnabledState(); |
| 151 } else if (!mBrowserVisibilityDelegate.isHidingBrowserCo
ntrolsEnabled()) { | 137 } else if (!mBrowserVisibilityDelegate.isHidingBrowserCo
ntrolsEnabled()) { |
| 152 setPositionsForTabToNonFullscreen(); | 138 setPositionsForTabToNonFullscreen(); |
| 153 } | 139 } |
| 154 } | 140 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (tab != null && previousTab != getTab()) { | 221 if (tab != null && previousTab != getTab()) { |
| 236 mBrowserVisibilityDelegate.showControlsTransient(); | 222 mBrowserVisibilityDelegate.showControlsTransient(); |
| 237 } | 223 } |
| 238 if (tab == null && !mBrowserVisibilityDelegate.isHidingBrowserControlsEn
abled()) { | 224 if (tab == null && !mBrowserVisibilityDelegate.isHidingBrowserControlsEn
abled()) { |
| 239 setPositionsForTabToNonFullscreen(); | 225 setPositionsForTabToNonFullscreen(); |
| 240 } | 226 } |
| 241 } | 227 } |
| 242 | 228 |
| 243 @Override | 229 @Override |
| 244 public void onActivityStateChange(Activity activity, int newState) { | 230 public void onActivityStateChange(Activity activity, int newState) { |
| 245 if (newState == ActivityState.STOPPED && mExitFullscreenOnStop) { | 231 if (newState == ActivityState.STOPPED) { |
| 246 // Exit fullscreen in onStop to ensure the system UI flags are set c
orrectly when | 232 // Exit fullscreen in onStop to ensure the system UI flags are set c
orrectly when |
| 247 // showing again (on JB MR2+ builds, the omnibox would be covered by
the | 233 // showing again (on JB MR2+ builds, the omnibox would be covered by
the |
| 248 // notification bar when this was done in onStart()). | 234 // notification bar when this was done in onStart()). |
| 249 setPersistentFullscreenMode(false); | 235 setPersistentFullscreenMode(false); |
| 250 } else if (newState == ActivityState.STARTED) { | 236 } else if (newState == ActivityState.STARTED) { |
| 251 ThreadUtils.postOnUiThreadDelayed(new Runnable() { | 237 ThreadUtils.postOnUiThreadDelayed(new Runnable() { |
| 252 @Override | 238 @Override |
| 253 public void run() { | 239 public void run() { |
| 254 mBrowserVisibilityDelegate.showControlsTransient(); | 240 mBrowserVisibilityDelegate.showControlsTransient(); |
| 255 } | 241 } |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 updateVisuals(); | 651 updateVisuals(); |
| 666 } | 652 } |
| 667 } | 653 } |
| 668 | 654 |
| 669 @Override | 655 @Override |
| 670 public void onContentViewScrollingStateChanged(boolean scrolling) { | 656 public void onContentViewScrollingStateChanged(boolean scrolling) { |
| 671 mContentViewScrolling = scrolling; | 657 mContentViewScrolling = scrolling; |
| 672 if (!scrolling) updateVisuals(); | 658 if (!scrolling) updateVisuals(); |
| 673 } | 659 } |
| 674 } | 660 } |
| OLD | NEW |