Use overlay action mode
Bug: 5327408
By using actionBar: false with actionModeOverlay: true the
action mode callbacks happen before the action mode animation.
This allows us to animate down the URL bar at the same time if
needed (when the URL is being edited).
Overlay mode fixes the issue with webview being translated, which
was what caused the selection handles to move. Only the selection
handles were affected thanks to b/4982054
Change-Id: I8153de63124eb4e4d02e88637f0cf01658054a14
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c9cb170..361702e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -21,9 +21,9 @@
<style name="BrowserTheme" parent="@android:Theme.Holo">
<item name="android:windowBackground">@color/white</item>
<item name="android:colorBackground">#FFFFFFFF</item>
- <item name="android:windowActionBar">true</item>
- <item name="android:windowNoTitle">false</item>
- <item name="android:windowActionBarOverlay">false</item>
+ <item name="android:windowActionBar">false</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowActionModeOverlay">true</item>
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="DialogWhenLarge" parent="@android:style/Theme.Holo.DialogWhenLarge" >
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 0a54a89..2ccc932 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -211,8 +211,6 @@
private ContentObserver mBookmarksObserver;
private CrashRecoveryHandler mCrashRecoveryHandler;
- private boolean mSimulateActionBarOverlayMode;
-
private boolean mBlockEvents;
public Controller(Activity browser, boolean preloadCrashState) {
@@ -251,7 +249,6 @@
mSystemAllowGeolocationOrigins.start();
openIconDatabase();
- mSimulateActionBarOverlayMode = !BrowserActivity.isTablet(mActivity);
}
void start(final Bundle icicle, final Intent intent) {
@@ -1819,15 +1816,6 @@
void onActionModeStarted(ActionMode mode) {
mUi.onActionModeStarted(mode);
mActionMode = mode;
- if (mSimulateActionBarOverlayMode && !mUi.isEditingUrl()) {
- WebView web = getCurrentWebView();
- // Simulate overlay mode by scrolling the webview the amount it will be
- // pushed down. Actual overlay mode doesn't work for us as otherwise
- // the CAB will, well, overlay the content, which breaks things like
- // find on page.
- int scrollBy = getActionModeHeight();
- web.scrollBy(0, scrollBy);
- }
}
/*
@@ -1856,11 +1844,6 @@
if (!isInCustomActionMode()) return;
mUi.onActionModeFinished(mInLoad);
mActionMode = null;
- if (mSimulateActionBarOverlayMode) {
- WebView web = getCurrentWebView();
- int scrollBy = getActionModeHeight();
- web.scrollBy(0, -scrollBy);
- }
}
boolean isInLoad() {
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index 606a47d..61acef5 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -26,6 +26,7 @@
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.util.Log;
+import android.util.TypedValue;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -52,6 +53,7 @@
private PieControlPhone mPieControl;
private NavScreen mNavScreen;
private NavigationBarPhone mNavigationBar;
+ private int mActionBarHeight;
boolean mExtendedMenuOpen;
boolean mOptionsMenuOpen;
@@ -63,9 +65,13 @@
*/
public PhoneUi(Activity browser, UiController controller) {
super(browser, controller);
- mActivity.getActionBar().hide();
setUseQuickControls(BrowserSettings.getInstance().useQuickControls());
mNavigationBar = (NavigationBarPhone) mTitleBar.getNavigationBar();
+ TypedValue heightValue = new TypedValue();
+ browser.getTheme().resolveAttribute(
+ com.android.internal.R.attr.actionBarSize, heightValue, true);
+ mActionBarHeight = TypedValue.complexToDimensionPixelSize(heightValue.data,
+ browser.getResources().getDisplayMetrics());
}
@Override
@@ -208,18 +214,20 @@
public void onActionModeStarted(ActionMode mode) {
if (!isEditingUrl()) {
hideTitleBar();
+ } else {
+ mTitleBar.animate().translationY(mActionBarHeight);
}
}
@Override
public void onActionModeFinished(boolean inLoad) {
+ mTitleBar.animate().translationY(0);
if (inLoad) {
if (mUseQuickControls) {
mTitleBar.setShowProgressOnly(true);
}
showTitleBar();
}
- mActivity.getActionBar().hide();
}
@Override