Commit 86258312 authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Android] Hide the keyboard accessory sheet before switching tabs

Before this CL, the (non-horizontal) tab switcher would initiate the tab
switching before emitting an event that the scene is changing.
For the keyboard accessory, this meant that changes to the old scene
are not applied anymore. Most importantly, hiding the keyboard-replacing
sheet would restore the layout size too late and the tab would appear
cropped.

This CL notifies a scene as soon as it is detached to give it the time
to clean up. Now, the keyboard accessory can restore the layout and the
transition into a full-sized tab is restored again.

Bug: 876254
Change-Id: I8f17a51ce3f4b7de4ee41483f79240323ec9acea
Reviewed-on: https://chromium-review.googlesource.com/1196406
Commit-Queue: Friedrich Horschig [CEST] <fhorschig@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587701}
parent 4ced1fac
......@@ -107,10 +107,13 @@ class ManualFillingMediator
public void onTabSelectionHinted(int tabId) {}
@Override
public void onSceneChange(Layout layout) {
public void onSceneStartShowing(Layout layout) {
// Includes events like side-swiping between tabs and triggering contextual search.
mKeyboardAccessory.dismiss();
}
@Override
public void onSceneChange(Layout layout) {}
};
private final TabObserver mTabObserver = new EmptyTabObserver() {
......@@ -179,7 +182,7 @@ class ManualFillingMediator
// TODO(fhorschig): Look for stronger signals than |keyboardVisibilityChanged|.
// This variable remembers the last state of |keyboardVisibilityChanged| which might not be
// sufficient for edge cases like hardware keyboards, floating keyboards, etc.
private void onKeyboardVisibilityChanged(boolean isShowing) {
void onKeyboardVisibilityChanged(boolean isShowing) {
if (!mKeyboardAccessory.hasContents()) return; // Exit early to not affect the layout.
if (isShowing) {
mKeyboardAccessory.requestShowing();
......
......@@ -828,6 +828,11 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider,
oldLayout.forceAnimationToFinish();
oldLayout.detachViews();
}
// TODO(fhorschig): This might be removed as soon as keyboard replacements get triggered
// by the normal keyboard hiding signals.
for (SceneChangeObserver observer : mSceneChangeObservers) {
observer.onSceneStartShowing(layout);
}
layout.contextChanged(mHost.getContext());
layout.attachViews(mContentContainer);
mActiveLayout = layout;
......
......@@ -15,6 +15,12 @@ public interface SceneChangeObserver {
*/
void onTabSelectionHinted(int tabId);
/**
* Called briefly before the given {@link Layout} becomes active.
* @param layout A {@link Layout} that is soon to be active.
*/
default void onSceneStartShowing(Layout layout) {}
/**
* Called when the active {@link Layout} changes.
* @param layout The new active {@link Layout}.
......
......@@ -84,8 +84,8 @@ public class ManualFillingIntegrationTest {
mHelper.createTestTab();
// Focus the field to bring up the accessory.
mHelper.clickPasswordField();
onView(withId(R.id.keyboard_accessory)).check(doesNotExist());
mHelper.clickPasswordField();
mHelper.waitForKeyboard();
// Check that ONLY the accessory is there but the sheet is still hidden.
......
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