Bug 1358554 - On Android devices that use static action bar prevent content from sliding down after a long press r=jchen

Only show real toolbar chrome for fixed action bar. Showing the static
snapshot causes the content to shift.

MozReview-Commit-ID: D4EN8qbe8Fu
This commit is contained in:
Randall Barker 2017-04-21 12:16:26 -07:00
Родитель 288df523ef
Коммит b81353aaae
2 изменённых файлов: 21 добавлений и 36 удалений

Просмотреть файл

@ -258,6 +258,12 @@ public class BrowserApp extends GeckoApp
private static final int ADDON_MENU_OFFSET = 1000;
public static final String TAB_HISTORY_FRAGMENT_TAG = "tabHistoryFragment";
// When the static action bar is shown, only the real toolbar chrome should be
// shown when the toolbar is visible. Causing the toolbar animator to also
// show the snapshot causes the content to shift under the users finger.
// See: Bug 1358554
private boolean mShowingToolbarChromeForActionBar;
private static class MenuItemInfo {
public int id;
public String label;
@ -386,7 +392,10 @@ public class BrowserApp extends GeckoApp
updateHomePagerForTab(tab);
}
mDynamicToolbar.persistTemporaryVisibility();
if (mShowingToolbarChromeForActionBar) {
mDynamicToolbar.setVisible(true, VisibilityTransition.IMMEDIATE);
mShowingToolbarChromeForActionBar = false;
}
break;
case START:
if (Tabs.getInstance().isSelectedTab(tab)) {
@ -4036,6 +4045,7 @@ public class BrowserApp extends GeckoApp
return this;
}
/* Implementing ActionModeCompat.Presenter */
@Override
public void startActionMode(final ActionModeCompat.Callback callback) {
@ -4044,9 +4054,11 @@ public class BrowserApp extends GeckoApp
mActionBarFlipper.showNext();
DynamicToolbarAnimator toolbar = mLayerView.getDynamicToolbarAnimator();
// If the toolbar is dynamic and not currently showing, just slide it in
// If the toolbar is dynamic and not currently showing, just show the real toolbar
// and keep the animated snapshot hidden
if (mDynamicToolbar.isEnabled() && toolbar.getCurrentToolbarHeight() == 0) {
mDynamicToolbar.setTemporarilyVisible(true, VisibilityTransition.ANIMATE);
toggleToolbarChrome(true);
mShowingToolbarChromeForActionBar = true;
}
mDynamicToolbar.setPinned(true, PinReason.ACTION_MODE);
@ -4075,9 +4087,12 @@ public class BrowserApp extends GeckoApp
mActionBarFlipper.showPrevious();
// Only slide the urlbar out if it was hidden when the action mode started
// Don't animate hiding it so that there's no flash as we switch back to url mode
mDynamicToolbar.setTemporarilyVisible(false, VisibilityTransition.IMMEDIATE);
// Hide the real toolbar chrome if it was hidden before the action bar
// was shown.
if (mShowingToolbarChromeForActionBar) {
toggleToolbarChrome(false);
mShowingToolbarChromeForActionBar = false;
}
}
public static interface TabStripInterface {

Просмотреть файл

@ -149,36 +149,6 @@ public class DynamicToolbar {
}
}
public void setTemporarilyVisible(boolean visible, VisibilityTransition transition) {
ThreadUtils.assertOnUiThread();
if (layerView == null) {
return;
}
if (visible == temporarilyVisible) {
// nothing to do
return;
}
temporarilyVisible = visible;
final boolean isImmediate = transition == VisibilityTransition.IMMEDIATE;
if (visible) {
layerView.getDynamicToolbarAnimator().showToolbar(isImmediate);
} else {
layerView.getDynamicToolbarAnimator().hideToolbar(isImmediate);
}
}
public void persistTemporaryVisibility() {
ThreadUtils.assertOnUiThread();
if (temporarilyVisible) {
temporarilyVisible = false;
setVisible(true, VisibilityTransition.IMMEDIATE);
}
}
public void setPinned(boolean pinned, PinReason reason) {
ThreadUtils.assertOnUiThread();
if (layerView == null) {