Commit 02d0b527 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Keep bottom sheet open when opening background tab

This change allows the bottom sheet to remain open while a tab
is being opened in the background. In practice, this means allowing
the bottom sheet to show in the SimpleAnimationLayout.

Bug: 829572
Change-Id: I27228e64636cd4e50c56ad9fff24867321147c16
Reviewed-on: https://chromium-review.googlesource.com/1000547
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549199}
parent 5fbb6b8c
...@@ -14,6 +14,7 @@ import org.chromium.chrome.browser.compositor.layouts.Layout; ...@@ -14,6 +14,7 @@ import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager; import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.SceneChangeObserver; import org.chromium.chrome.browser.compositor.layouts.SceneChangeObserver;
import org.chromium.chrome.browser.compositor.layouts.StaticLayout; import org.chromium.chrome.browser.compositor.layouts.StaticLayout;
import org.chromium.chrome.browser.compositor.layouts.phone.SimpleAnimationLayout;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager; import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchObserver; import org.chromium.chrome.browser.contextualsearch.ContextualSearchObserver;
import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection; import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection;
...@@ -117,10 +118,10 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis ...@@ -117,10 +118,10 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis
public void onSceneChange(Layout layout) { public void onSceneChange(Layout layout) {
// If the tab did not change, reshow the existing content. Once the tab actually // If the tab did not change, reshow the existing content. Once the tab actually
// changes, existing content and requests will be cleared. // changes, existing content and requests will be cleared.
if (layout instanceof StaticLayout && mWasShownForCurrentTab if (canShowInLayout(layout) && mWasShownForCurrentTab && !mBottomSheet.isSheetOpen()
&& mBottomSheet.getCurrentSheetContent() != null) { && mBottomSheet.getCurrentSheetContent() != null) {
mBottomSheet.setSheetState(BottomSheet.SHEET_STATE_PEEK, true); mBottomSheet.setSheetState(BottomSheet.SHEET_STATE_PEEK, true);
} else { } else if (!canShowInLayout(layout)) {
mBottomSheet.setSheetState(BottomSheet.SHEET_STATE_HIDDEN, false); mBottomSheet.setSheetState(BottomSheet.SHEET_STATE_HIDDEN, false);
} }
} }
...@@ -234,7 +235,7 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis ...@@ -234,7 +235,7 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis
*/ */
public boolean requestContentPreload(BottomSheetContent content) { public boolean requestContentPreload(BottomSheetContent content) {
if (content == mBottomSheet.getCurrentSheetContent()) return true; if (content == mBottomSheet.getCurrentSheetContent()) return true;
if (!isValidLayoutShowing()) return false; if (!canShowInLayout(mLayoutManager.getActiveLayout())) return false;
boolean shouldSuppressExistingContent = mBottomSheet.getCurrentSheetContent() != null boolean shouldSuppressExistingContent = mBottomSheet.getCurrentSheetContent() != null
&& mBottomSheet.getSheetState() <= BottomSheet.SHEET_STATE_PEEK && mBottomSheet.getSheetState() <= BottomSheet.SHEET_STATE_PEEK
...@@ -334,10 +335,11 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis ...@@ -334,10 +335,11 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis
} }
/** /**
* @return Whether the browser is in a layout that supports showing the bottom sheet. * @param layout A {@link Layout} to check if the sheet can be shown in.
* @return Whether the bottom sheet can show in the specified layout.
*/ */
protected boolean isValidLayoutShowing() { protected boolean canShowInLayout(Layout layout) {
return mLayoutManager.getActiveLayout() instanceof StaticLayout; return layout instanceof StaticLayout || layout instanceof SimpleAnimationLayout;
} }
/** /**
......
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