Titlebar auto hide fixes.
- Remove setTranslationY on webview during scroll.
- Use WebView API setFullscreen when Tab goes to
fullscreen mode.
Change-Id: I33960cec02ade01ddacad719298ea53a4723145b
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index c6238f4..f05de19 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -115,7 +115,6 @@
private NavigationBarBase mNavigationBar;
protected PieControl mPieControl;
private boolean mBlockFocusAnimations;
- private boolean mFullScreen;
public BaseUi(Activity browser, UiController controller) {
mActivity = browser;
@@ -146,7 +145,6 @@
mTitleBar.setProgress(100);
mNavigationBar = mTitleBar.getNavigationBar();
mUrlBarAutoShowManager = new UrlBarAutoShowManager(this);
- mFullScreen = false;
}
private void cancelStopToast() {
@@ -195,8 +193,9 @@
if (mCustomView != null) {
mUiController.hideCustomView();
return true;
- } else if (mFullScreen) {
- setTabFullscreen(false);
+ } else if ((mTabControl.getCurrentTab() != null) &&
+ (mTabControl.getCurrentTab().isTabFullScreen())) {
+ mTabControl.getCurrentTab().setTabFullscreen(false);
return true;
}
return false;
@@ -809,9 +808,7 @@
final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
if (enabled) {
winParams.flags |= bits;
- mFullScreen = true;
} else {
- mFullScreen = false;
winParams.flags &= ~bits;
if (mCustomView != null) {
mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
@@ -822,38 +819,6 @@
win.setAttributes(winParams);
}
- public boolean isTabFullScreen() {
- return mFullScreen;
- }
-
- public void setTabFullscreen(boolean enabled) {
- setFullscreen(enabled);
- FrameLayout main = (FrameLayout) mActivity.getWindow()
- .getDecorView().findViewById(android.R.id.content);
- boolean hide_title_on_scroll =
- mActivity.getResources().getBoolean(R.bool.hide_title_on_scroll);
- LinearLayout titleBarParent = (LinearLayout) main.findViewById(R.id.vertical_layout);
- if (titleBarParent != null) {
- if (enabled) {
- if (!hide_title_on_scroll) {
- titleBarParent.removeView(mFixedTitlebarContainer);
- }
- else {
- mContentView.removeView(mTitleBar);
- }
- } else {
- if (!hide_title_on_scroll) {
- titleBarParent.addView(mFixedTitlebarContainer, 1);
- }
- else {
- mContentView.addView(mTitleBar,
- new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
- LayoutParams.WRAP_CONTENT));
- }
- }
- }
- }
-
public void transalateTitleBar(float topControlsOffsetYPix) {
if (mTitleBar != null && !mInActionMode) {
mTitleBar.bringToFront();
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index d0a27b9..fab2ec0 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -201,6 +201,7 @@
private Handler mHandler;
private boolean mUpdateThumbnail;
private Timestamp timestamp;
+ private boolean mFullScreen = false;
/**
* See {@link #clearBackStackWhenItemAdded(String)}.
@@ -724,6 +725,13 @@
mCurrentState.mIncognito = view.isPrivateBrowsingEnabled();
}
+ protected void setTabFullscreen(boolean fullScreen) {
+ if (mMainView != null) {
+ mFullScreen = fullScreen;
+ mMainView.setFullScreen(fullScreen);
+ }
+ }
+
// -------------------------------------------------------------------------
// WebChromeClient implementation for the main WebView
// -------------------------------------------------------------------------
@@ -749,7 +757,8 @@
public void toggleFullscreenModeForTab(boolean enterFullscreen) {
if (mWebViewController instanceof Controller) {
Controller controller = (Controller)mWebViewController;
- controller.getUi().setTabFullscreen(enterFullscreen);
+ controller.getUi().setFullscreen(enterFullscreen);
+ setTabFullscreen(enterFullscreen);
}
}
@@ -760,19 +769,13 @@
mContext.getResources().getBoolean(R.bool.hide_title_on_scroll);
if (mWebViewController instanceof Controller && hide_title_on_scroll) {
Controller controller = (Controller)mWebViewController;
- mMainView.setTranslationY(contentOffsetYPix);
controller.getUi().transalateTitleBar(topControlsOffsetYPix);
}
}
@Override
public boolean isTabFullScreen() {
- if (mWebViewController instanceof Controller) {
- Controller controller = (Controller)mWebViewController;
- return controller.getUi().isTabFullScreen();
- } else {
- return false;
- }
+ return mFullScreen;
}
@Override
@@ -1404,6 +1407,10 @@
}
}
+ public boolean isTabFullScreen() {
+ return mFullScreen;
+ }
+
/**
* Destroy the tab's main WebView and subWindow if any
*/
diff --git a/src/com/android/browser/UI.java b/src/com/android/browser/UI.java
index eb7d023..bf5c5e5 100644
--- a/src/com/android/browser/UI.java
+++ b/src/com/android/browser/UI.java
@@ -138,10 +138,6 @@
void setFullscreen(boolean enabled);
- void setTabFullscreen(boolean enabled);
-
- boolean isTabFullScreen();
-
void setUseQuickControls(boolean enabled);
void transalateTitleBar(float topControlsOffsetYPix);