Index: chrome/android/java/src/org/chromium/chrome/browser/firstrun/ImageCarousel.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ImageCarousel.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ImageCarousel.java |
index df5a61f7a456b7fccc045f36258de5f03fb01d21..003a9b39d0350388949560826ae35f836777d9c1 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ImageCarousel.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ImageCarousel.java |
@@ -151,6 +151,7 @@ public class ImageCarousel extends FrameLayout implements GestureDetector.OnGest |
private float mPosition = 0f; |
private ImageCarouselPositionChangeListener mListener; |
+ private ImageView mCheckmark; |
private int mLastPosition = 0; |
private boolean mNeedsPositionUpdates = true; |
@@ -221,24 +222,33 @@ public class ImageCarousel extends FrameLayout implements GestureDetector.OnGest |
} |
/** |
- * Sets the ImageCarousel to signed in mode that disables scrolling, animates away the |
- * background images, and displays a checkmark next to the account image that was chosen. |
+ * Sets whether the ImageCarousel is in signed in mode. This mode disables scrolling, animates |
+ * away the background images, and displays a checkmark next to the chosen account image. |
+ * @param isSignedIn Whether the ImageCarousel should in signed in mode or not. |
*/ |
- public void setSignedInMode() { |
- mScrollingDisabled = true; |
- mAccountSelected = true; |
+ public void setSignedInMode(boolean isSignedIn) { |
+ if (isSignedIn == mAccountSelected) return; |
+ |
+ mScrollingDisabled = isSignedIn; |
+ mAccountSelected = isSignedIn; |
setPosition(getCenterPosition()); |
- ImageView checkmark = new ImageView(getContext()); |
- checkmark.setImageResource(R.drawable.verify_checkmark); |
- setLayoutParamsForCheckmark(checkmark); |
- addView(checkmark); |
+ if (mCheckmark == null) { |
+ mCheckmark = new ImageView(getContext()); |
+ mCheckmark.setImageResource(R.drawable.verify_checkmark); |
+ setLayoutParamsForCheckmark(mCheckmark); |
+ addView(mCheckmark); |
+ } |
if (mFadeInOutAnimator != null) mFadeInOutAnimator.cancel(); |
AnimatorSet animatorSet = new AnimatorSet(); |
- animatorSet.playTogether( |
- ObjectAnimator.ofFloat(this, BACKGROUND_IMAGE_ALPHA, 0), |
- ObjectAnimator.ofFloat(checkmark, View.ALPHA, 0.0f, 1.0f)); |
+ if (isSignedIn) { |
+ animatorSet.playTogether(ObjectAnimator.ofFloat(this, BACKGROUND_IMAGE_ALPHA, 0), |
+ ObjectAnimator.ofFloat(mCheckmark, View.ALPHA, 0.0f, 1.0f)); |
+ } else { |
+ animatorSet.playTogether(ObjectAnimator.ofFloat(this, BACKGROUND_IMAGE_ALPHA, 1), |
+ ObjectAnimator.ofFloat(mCheckmark, View.ALPHA, 1.0f, 0.0f)); |
+ } |
mFadeInOutAnimator = animatorSet; |
mFadeInOutAnimator.setDuration(ACCOUNT_SIGNED_IN_ANIMATION_DURATION_MS); |
mFadeInOutAnimator.start(); |
@@ -347,8 +357,6 @@ public class ImageCarousel extends FrameLayout implements GestureDetector.OnGest |
if (mImages == null) return; |
for (int i = 0; i < VIEW_COUNT; i++) { |
- if (mAccountSelected && i != getCenterPosition()) continue; |
- |
ImageView image = mViews[i]; |
updateBitmap(i); |
@@ -367,10 +375,13 @@ public class ImageCarousel extends FrameLayout implements GestureDetector.OnGest |
image.setScaleY(scale); |
image.setScaleX(scale); |
- // alpha is a cos^2 function with a period of 2 and range [0, 1] |
- // alpha is 1 when the image is in the center in the front and 0 when it is in the back. |
- final float alpha = (float) Math.pow(Math.cos(position * Math.PI / 4f), 2); |
- image.setAlpha(alpha); |
+ if (!mAccountSelected || i == getCenterPosition()) { |
newt (away)
2016/02/09 23:08:12
Why this change?
PEConn
2016/02/11 14:44:55
This was for crbug.com/585065 .
I'm removing it fr
|
+ // alpha is a cos^2 function with a period of 2 and range [0, 1] |
+ // alpha is 1 when the image is in the center in the front and 0 when it is in the |
+ // back. |
+ final float alpha = (float) Math.pow(Math.cos(position * Math.PI / 4f), 2); |
+ image.setAlpha(alpha); |
+ } |
} |
} |
@@ -424,4 +435,4 @@ public class ImageCarousel extends FrameLayout implements GestureDetector.OnGest |
view.setTranslationX((mImageWidth - size) / 2f); |
view.setTranslationY((mImageWidth - size) / 2f); |
} |
-} |
+} |