Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1348)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java

Issue 1536623003: [Contextual Search] Keep Panel upon orientation change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Changwan's comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
index c519959ad2457e0b68058243cf77f7f26be48a88..631f21a454f0076fc1b93cdc606f960e109a71ed 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
@@ -314,7 +314,7 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
*/
private OverlayPanelContent createNewOverlayPanelContentInternal() {
OverlayPanelContent content = mContentFactory.createNewOverlayPanelContent();
- // Adds a ContentViewClient to override the default fullscreen size.
+
content.setContentViewClient(new ContentViewClient() {
@Override
public int getDesiredWidthMeasureSpec() {
@@ -338,6 +338,7 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
}
}
});
+
return content;
}
@@ -490,6 +491,32 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
return true;
}
+ /**
+ * Handles the device orientation change.
+ */
+ public void onOrientationChanged() {
+ if (isNarrowSizePanelSupported()) {
+ // TODO(pedrosimonetti): We cannot preserve the panel when rotating from/to a
+ // narrow version of the Panel because the Content is resized before the Panel
+ // gets a notification of the resize.
+ closePanel(StateChangeReason.UNKNOWN, false);
+ } else {
+ updatePanelForOrientationChange();
+ }
+ }
+
+ /**
+ * Updates the Panel so it preserves its state when the orientation changes.
+ */
+ protected void updatePanelForOrientationChange() {
+ // NOTE(pedrosimonetti): We cannot tell where the selection will be after the
+ // orientation change, so we are setting the selection position to zero, which
+ // means the base page will be positioned in its original state and we won't
+ // try to keep the selection in view.
+ updateBasePageSelectionYPx(0.f);
+ resizePanelToState(getPanelState(), StateChangeReason.UNKNOWN);
+ }
+
// ============================================================================================
// Generic Event Handling
// ============================================================================================
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698