Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| index 7ac8418ccaeb0746e9951454f101a8ff60b727f7..85b78ae4f378b59e2ea3ba8df90b9680302b36de 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| @@ -12,6 +12,7 @@ import org.chromium.base.VisibleForTesting; |
| import org.chromium.chrome.browser.ChromeActivity; |
| import org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressObserver; |
| import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContent; |
| +import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation; |
| import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost; |
| import org.chromium.chrome.browser.contextualsearch.ContextualSearchManagementDelegate; |
| import org.chromium.content.browser.ContentViewClient; |
| @@ -227,6 +228,21 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| // first thing with significant logic that runs in this method which is why |
| // onPanelStateChanged is not called here. |
| PanelState fromState = getPanelState(); |
| + |
| + if (toState == PanelState.PEEKED |
| + && (fromState == PanelState.CLOSED || fromState == PanelState.UNDEFINED)) { |
| + |
| + // If the peek promo is visible, it should animate when the SearchBar peeks. |
| + if (getPeekPromoControl().isVisible()) { |
| + new Handler().postDelayed(new Runnable() { |
|
Theresa
2015/10/02 17:34:45
What does using postDelayed achieve if the delay i
pedro (no code reviews)
2015/10/02 20:29:08
postDelayed with delay 0 lets the CPU "breathe for
David Trainor- moved to gerrit
2015/10/02 20:49:20
I think post() calls postDelayed(0). You could pr
pedro (no code reviews)
2015/10/02 22:15:57
That's a good point. I now recall I was concerned
|
| + @Override |
| + public void run() { |
| + getPeekPromoControl().animateAppearance(); |
| + } |
| + }, 0); |
| + } |
| + } |
| + |
| super.setPanelState(toState, reason); |
| mPanelMetrics.onPanelStateChanged(fromState, toState, reason); |
| } |
| @@ -246,6 +262,9 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| super.onPromoButtonClick(accepted); |
| mManagementDelegate.logPromoOutcome(); |
| setIsPromoActive(false); |
| + |
| + // Should hide the Peek Promo so it's not visible anymore when animating away. |
| + getPeekPromoControl().hide(); |
| } |
| // ============================================================================================ |
| @@ -279,6 +298,7 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| @Override |
| protected void onClose(StateChangeReason reason) { |
| destroySearchBarControl(); |
| + destroyPeekPromoControl(); |
| if (mOverlayPanelContent != null) { |
| mOverlayPanelContent.destroyContentView(); |
| } |
| @@ -532,26 +552,21 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| // Panel Delegate |
| // ============================================================================================ |
| - /** |
| - * Sets that the Search Content View was seen. |
| - */ |
| @Override |
| public void setWasSearchContentViewSeen() { |
| mPanelMetrics.setWasSearchContentViewSeen(); |
| } |
| - /** |
| - * Sets whether the promo is active. |
| - */ |
| @Override |
| - public void setIsPromoActive(boolean shown) { |
| - mPanelMetrics.setIsPromoActive(shown); |
| + public void setIsPromoActive(boolean isActive) { |
| + mPanelMetrics.setIsPromoActive(isActive); |
| + } |
| + |
| + @Override |
| + public void showPeekPromo() { |
| + getPeekPromoControl().show(); |
| } |
| - /** |
| - * Records timing information when the search results have fully loaded. |
| - * @param wasPrefetch Whether the request was prefetch-enabled. |
| - */ |
| @Override |
| public void onSearchResultsLoaded(boolean wasPrefetch) { |
| mPanelMetrics.onSearchResultsLoaded(wasPrefetch); |
| @@ -622,15 +637,16 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| @Override |
| public void closePanel(StateChangeReason reason, boolean animate) { |
| + super.closePanel(reason, animate); |
| + |
| // If the close action is animated, the Layout will be hidden when |
| // the animation is finished, so we should only hide the Layout |
| // here when not animating. |
| if (!animate && mSearchPanelHost != null) { |
| mSearchPanelHost.hideLayout(true); |
| } |
| - mHasSearchContentViewBeenTouched = false; |
| - super.closePanel(reason, animate); |
| + mHasSearchContentViewBeenTouched = false; |
| } |
| @Override |
| @@ -718,6 +734,40 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| mPanelMetrics.setDidSearchInvolvePromo(); |
| } |
| + @Override |
| + public <T extends Enum<?>> void addToAnimation(ChromeAnimation.Animatable<T> object, T prop, |
| + float start, float end, long duration, |
| + long startTime) { |
| + super.addToAnimation(object, prop, start, end, duration, startTime); |
| + } |
| + |
| + // ============================================================================================ |
| + // Panel Rendering |
| + // ============================================================================================ |
| + |
| + // TODO(pedrosimonetti): generalize the dispatching of panel updates. |
| + |
| + @Override |
| + protected void updatePanelForCloseOrPeek(float percentage) { |
| + super.updatePanelForCloseOrPeek(percentage); |
| + |
| + getPeekPromoControl().onUpdateFromCloseToPeek(percentage); |
| + } |
| + |
| + @Override |
| + protected void updatePanelForExpansion(float percentage) { |
| + super.updatePanelForExpansion(percentage); |
| + |
| + getPeekPromoControl().onUpdateFromPeekToExpand(percentage); |
| + } |
| + |
| + @Override |
| + protected void updatePanelForMaximization(float percentage) { |
| + super.updatePanelForMaximization(percentage); |
| + |
| + getPeekPromoControl().onUpdateFromExpandToMaximize(percentage); |
| + } |
| + |
| // ============================================================================================ |
| // ContextualSearchBarControl |
| // ============================================================================================ |
| @@ -813,6 +863,39 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| } |
| // ============================================================================================ |
| + // Peek Promo |
| + // ============================================================================================ |
| + |
| + private ContextualSearchPeekPromoControl mPeekPromoControl; |
| + |
| + /** |
| + * Creates the ContextualSearchPeekPromoControl, if needed. |
| + */ |
| + public ContextualSearchPeekPromoControl getPeekPromoControl() { |
| + assert mContainerView != null; |
| + assert mResourceLoader != null; |
| + |
| + if (mPeekPromoControl == null) { |
| + mPeekPromoControl = |
| + new ContextualSearchPeekPromoControl(this, mContext, mContainerView, |
| + mResourceLoader); |
| + } |
| + |
| + assert mPeekPromoControl != null; |
| + return mPeekPromoControl; |
| + } |
| + |
| + /** |
| + * Destroys the ContextualSearchPeekPromoControl. |
| + */ |
| + private void destroyPeekPromoControl() { |
| + if (mPeekPromoControl != null) { |
| + mPeekPromoControl.destroy(); |
| + mPeekPromoControl = null; |
| + } |
| + } |
| + |
| + // ============================================================================================ |
| // Panel Content |
| // ============================================================================================ |