Commit f0859470 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Remove |areBrowserControlsFullyVisible| from helper class

This CL addresses a TODO left in TabBrowserControlsOffsetHelper.
The method is deleted, and call site uses the method of
ChromeFullscreenManager directly.

Bug: 966272
Change-Id: If1bf007e33da38444361d303fe8fa734749268ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1630081Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarJinsuk Kim <jinsukkim@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664521}
parent 2136c755
...@@ -43,8 +43,7 @@ import org.chromium.ui.modelutil.PropertyModelChangeProcessor; ...@@ -43,8 +43,7 @@ import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
* The presenter that displays a single tab modal dialog. * The presenter that displays a single tab modal dialog.
*/ */
public class TabModalPresenter public class TabModalPresenter
extends ModalDialogManager.Presenter implements TabBrowserControlsOffsetHelper.Observer, extends ModalDialogManager.Presenter implements ChromeFullscreenManager.FullscreenListener {
ChromeFullscreenManager.FullscreenListener {
private static final int ENTER_EXIT_ANIMATION_DURATION_MS = 200; private static final int ENTER_EXIT_ANIMATION_DURATION_MS = 200;
/** The activity displaying the dialogs. */ /** The activity displaying the dialogs. */
...@@ -121,8 +120,7 @@ public class TabModalPresenter ...@@ -121,8 +120,7 @@ public class TabModalPresenter
} }
public void destroy() { public void destroy() {
if (mChromeFullscreenManager != null) mChromeFullscreenManager.removeListener(this); mChromeFullscreenManager.removeListener(this);
} }
// ModalDialogManager.Presenter implementation. // ModalDialogManager.Presenter implementation.
...@@ -140,7 +138,7 @@ public class TabModalPresenter ...@@ -140,7 +138,7 @@ public class TabModalPresenter
setBrowserControlsAccess(true); setBrowserControlsAccess(true);
// Don't show the dialog container before browser controls are guaranteed fully visible. // Don't show the dialog container before browser controls are guaranteed fully visible.
if (getControlsOffsetHelper().areBrowserControlsFullyVisible()) { if (mChromeFullscreenManager.areBrowserControlsFullyVisible()) {
runEnterAnimation(mDialogView); runEnterAnimation(mDialogView);
} else { } else {
mRunEnterAnimationOnCallback = true; mRunEnterAnimationOnCallback = true;
...@@ -168,25 +166,20 @@ public class TabModalPresenter ...@@ -168,25 +166,20 @@ public class TabModalPresenter
mDialogView = null; mDialogView = null;
} }
// TabBrowserControlsOffsetHelper.Observer implementation.
@Override
public void onBrowserControlsFullyVisible(Tab tab) {
if (getDialogModel() == null) return;
assert mActiveTab == tab;
if (mRunEnterAnimationOnCallback) {
mRunEnterAnimationOnCallback = false;
runEnterAnimation(mDialogView);
}
}
// ChromeFullscreenManager.FullscreenListener implementation. // ChromeFullscreenManager.FullscreenListener implementation.
@Override @Override
public void onContentOffsetChanged(int offset) {} public void onContentOffsetChanged(int offset) {}
@Override @Override
public void onControlsOffsetChanged(int topOffset, int bottomOffset, boolean needsAnimate) {} public void onControlsOffsetChanged(int topOffset, int bottomOffset, boolean needsAnimate) {
if (getDialogModel() == null || !mRunEnterAnimationOnCallback
|| !mChromeFullscreenManager.areBrowserControlsFullyVisible()) {
return;
}
mRunEnterAnimationOnCallback = false;
runEnterAnimation(mDialogView);
}
@Override @Override
public void onToggleOverlayVideoMode(boolean enabled) {} public void onToggleOverlayVideoMode(boolean enabled) {}
...@@ -197,10 +190,6 @@ public class TabModalPresenter ...@@ -197,10 +190,6 @@ public class TabModalPresenter
mShouldUpdateContainerLayoutParams = true; mShouldUpdateContainerLayoutParams = true;
} }
private TabBrowserControlsOffsetHelper getControlsOffsetHelper() {
return TabBrowserControlsOffsetHelper.from(mActiveTab);
}
/** /**
* Change view hierarchy for the dialog container to be either the front most or beneath the * Change view hierarchy for the dialog container to be either the front most or beneath the
* toolbar. * toolbar.
...@@ -296,7 +285,6 @@ public class TabModalPresenter ...@@ -296,7 +285,6 @@ public class TabModalPresenter
assert mActiveTab assert mActiveTab
!= null : "Tab modal dialogs should be shown on top of an active tab."; != null : "Tab modal dialogs should be shown on top of an active tab.";
getControlsOffsetHelper().addObserver(this);
// Hide contextual search panel so that bottom toolbar will not be // Hide contextual search panel so that bottom toolbar will not be
// obscured and back press is not overridden. // obscured and back press is not overridden.
ContextualSearchManager contextualSearchManager = ContextualSearchManager contextualSearchManager =
...@@ -329,7 +317,6 @@ public class TabModalPresenter ...@@ -329,7 +317,6 @@ public class TabModalPresenter
menuButton.setEnabled(false); menuButton.setEnabled(false);
} else { } else {
getControlsOffsetHelper().removeObserver(this);
// Show the action bar back if it was dismissed when the dialogs were showing. // Show the action bar back if it was dismissed when the dialogs were showing.
if (mDidClearTextControls) { if (mDidClearTextControls) {
mDidClearTextControls = false; mDidClearTextControls = false;
...@@ -357,7 +344,8 @@ public class TabModalPresenter ...@@ -357,7 +344,8 @@ public class TabModalPresenter
if (isShowing) mActiveTab.exitFullscreenMode(); if (isShowing) mActiveTab.exitFullscreenMode();
// Also need to update browser control state after dismissal to refresh the constraints. // Also need to update browser control state after dismissal to refresh the constraints.
TabBrowserControlsOffsetHelper offsetHelper = getControlsOffsetHelper(); TabBrowserControlsOffsetHelper offsetHelper =
TabBrowserControlsOffsetHelper.from(mActiveTab);
if (isShowing && mActiveTab.areRendererInputEventsIgnored()) { if (isShowing && mActiveTab.areRendererInputEventsIgnored()) {
offsetHelper.showAndroidControls(true); offsetHelper.showAndroidControls(true);
} else { } else {
......
...@@ -8,7 +8,6 @@ import android.animation.Animator; ...@@ -8,7 +8,6 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import org.chromium.base.ObserverList;
import org.chromium.base.UserData; import org.chromium.base.UserData;
import org.chromium.base.UserDataHost; import org.chromium.base.UserDataHost;
import org.chromium.chrome.browser.fullscreen.FullscreenManager; import org.chromium.chrome.browser.fullscreen.FullscreenManager;
...@@ -29,18 +28,7 @@ public class TabBrowserControlsOffsetHelper implements VrModeObserver, UserData ...@@ -29,18 +28,7 @@ public class TabBrowserControlsOffsetHelper implements VrModeObserver, UserData
*/ */
private static final int MAX_CONTROLS_ANIMATION_DURATION_MS = 200; private static final int MAX_CONTROLS_ANIMATION_DURATION_MS = 200;
/**
* An interface for notification about browser controls offset updates.
*/
public interface Observer {
/**
* Called when the browser controls are fully visible on screen.
*/
void onBrowserControlsFullyVisible(Tab tab);
}
private final Tab mTab; private final Tab mTab;
private final ObserverList<Observer> mObservers = new ObserverList<>();
private final TabObserver mTabObserver; private final TabObserver mTabObserver;
private int mPreviousTopControlsOffsetY; private int mPreviousTopControlsOffsetY;
...@@ -99,30 +87,6 @@ public class TabBrowserControlsOffsetHelper implements VrModeObserver, UserData ...@@ -99,30 +87,6 @@ public class TabBrowserControlsOffsetHelper implements VrModeObserver, UserData
return mIsControlsOffsetOverridden; return mIsControlsOffsetOverridden;
} }
/**
* @return Whether the browser controls are fully visible on screen.
* TODO(jinsukkim): Have clients listen to ChromFullscreenManager directly
* and remove this method.
*/
public boolean areBrowserControlsFullyVisible() {
final FullscreenManager manager = FullscreenManager.from(mTab);
return Float.compare(0f, manager.getBrowserControlHiddenRatio()) == 0;
}
/**
* @param observer The observer to be added to get notifications from this class.
*/
public void addObserver(Observer observer) {
mObservers.addObserver(observer);
}
/**
* @param observer The observer to be removed to cancel notifications from this class.
*/
public void removeObserver(Observer observer) {
mObservers.removeObserver(observer);
}
/** /**
* Called when offset values related with fullscreen functionality has been changed by the * Called when offset values related with fullscreen functionality has been changed by the
* compositor. * compositor.
...@@ -216,11 +180,6 @@ public class TabBrowserControlsOffsetHelper implements VrModeObserver, UserData ...@@ -216,11 +180,6 @@ public class TabBrowserControlsOffsetHelper implements VrModeObserver, UserData
} else { } else {
manager.setPositionsForTab(topControlsOffset, bottomControlsOffset, topContentOffset); manager.setPositionsForTab(topControlsOffset, bottomControlsOffset, topContentOffset);
} }
if (!areBrowserControlsFullyVisible()) return;
for (Observer observer : mObservers) {
observer.onBrowserControlsFullyVisible(mTab);
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment