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

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

Issue 1061063005: [Contextual Search] Fix Promo behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync & rebase Created 5 years, 8 months 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
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelAnimation.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelAnimation.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelAnimation.java
index 36c86ca150b090b63fcb4bdae4151bfd04bc1dd6..d33a55bf0e61d5482857dcde6fa1d7e7bb2b3db0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelAnimation.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelAnimation.java
@@ -28,6 +28,7 @@ abstract class ContextualSearchPanelAnimation extends ContextualSearchPanelBase
*/
protected enum Property {
PANEL_HEIGHT,
+ PROMO_VISIBILITY,
FIRST_RUN_PANEL_HEIGHT,
}
@@ -68,6 +69,11 @@ abstract class ContextualSearchPanelAnimation extends ContextualSearchPanelBase
private ChromeAnimation<Animatable<?>> mLayoutAnimations;
/**
+ * Whether the Promo's acceptance animation is running.
+ */
+ private boolean mIsAnimatingPromoAcceptance;
+
+ /**
* The {@link LayoutUpdateHost} used to request a new frame to be updated and rendered.
*/
private final LayoutUpdateHost mUpdateHost;
@@ -178,6 +184,13 @@ abstract class ContextualSearchPanelAnimation extends ContextualSearchPanelBase
// Animation Helpers
// ============================================================================================
+ @Override
+ protected void animatePromoAcceptance() {
+ hidePromoView();
+ mIsAnimatingPromoAcceptance = true;
+ animateProperty(Property.PROMO_VISIBILITY, 1.f, 0.f, BASE_ANIMATION_DURATION_MS);
+ }
+
/**
* Animates the Contextual Search panel after first-run success.
*/
@@ -217,7 +230,17 @@ abstract class ContextualSearchPanelAnimation extends ContextualSearchPanelBase
// Calculate the projected state the Panel will be at the end of the fling movement and the
// duration of the animation given the current velocity and the projected displacement.
- final PanelState projectedState = findNearestPanelStateFromHeight(projectedHeight);
+ PanelState projectedState = findNearestPanelStateFromHeight(projectedHeight);
+
+ // Prevent the fling gesture from moving the Panel from PEEKED to MAXIMIZED if the Panel
+ // Promo is available. This is to make sure the Promo will be visible, considering that
+ // the EXPANDED state is the only one that will show the Promo.
+ if (projectedState == PanelState.MAXIMIZED
+ && getPanelState() == PanelState.PEEKED
+ && isPanelPromoAvailable()) {
+ projectedState = PanelState.EXPANDED;
+ }
+
final float displacement = getPanelHeightFromState(projectedState) - getHeight();
final long duration = calculateAnimationDuration(velocity, displacement);
@@ -321,6 +344,8 @@ abstract class ContextualSearchPanelAnimation extends ContextualSearchPanelBase
public void setProperty(Property prop, float value) {
if (prop == Property.PANEL_HEIGHT) {
setPanelHeight(value);
+ } else if (prop == Property.PROMO_VISIBILITY) {
+ setPromoVisibilityForOptInAnimation(value);
} else if (prop == Property.FIRST_RUN_PANEL_HEIGHT) {
setPanelHeightForPromoOptInAnimation(value);
}
@@ -361,6 +386,11 @@ abstract class ContextualSearchPanelAnimation extends ContextualSearchPanelBase
* Called when layout-specific actions are needed after the animation finishes.
*/
protected void onAnimationFinished() {
+ if (mIsAnimatingPromoAcceptance) {
+ mIsAnimatingPromoAcceptance = false;
+ setPreferenceState(true);
+ }
+
// If animating to a particular PanelState, and after completing
// resizing the Panel to its desired state, then the Panel's state
// should be updated. This method also is called when an animation

Powered by Google App Engine
This is Rietveld 408576698