Fix a couple issues with page / outline alphas (issue 7488857)

-> Fix bug where page hints didn't disappear on boot
-> Fix bug where you see a weird rotated page under the
   lock affordance (usually after adding a widget)

Change-Id: I75b04ceadbc296d033cc9fb1cff32ab9d6e5ce9b
This commit is contained in:
Adam Cohen
2012-11-21 16:49:13 -08:00
parent 545043e59e
commit 2b0501bf58
3 changed files with 55 additions and 27 deletions

View File

@@ -16,7 +16,6 @@
package com.android.internal.policy.impl.keyguard;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
@@ -27,10 +26,10 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import java.util.ArrayList;
import com.android.internal.R;
import java.util.ArrayList;
public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
private float mAdjacentPagesAngle;
@@ -56,17 +55,30 @@ public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
return MAX_SCROLL_PROGRESS;
}
public float getAlphaForPage(int screenCenter, int index) {
public float getAlphaForPage(int screenCenter, int index, boolean showSidePages) {
View child = getChildAt(index);
if (child == null) return 0f;
boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
float scrollProgress = getScrollProgress(screenCenter, child, index);
if (!isOverScrollChild(index, scrollProgress)) {
if (isOverScrollChild(index, scrollProgress)) {
return 1.0f;
} else if ((showSidePages && inVisibleRange) || index == getNextPage()) {
scrollProgress = getBoundedScrollProgress(screenCenter, child, index);
float alpha = 1.0f - 1.0f * Math.abs(scrollProgress / MAX_SCROLL_PROGRESS);
return alpha;
} else {
return 1.0f;
return 0f;
}
}
public float getOutlineAlphaForPage(int screenCenter, int index, boolean showSidePages) {
boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
if (inVisibleRange) {
return super.getOutlineAlphaForPage(screenCenter, index, showSidePages);
} else {
return 0f;
}
}
@@ -75,24 +87,32 @@ public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
mChildrenOutlineFadeAnimation.cancel();
mChildrenOutlineFadeAnimation = null;
}
boolean showSidePages = mShowingInitialHints || isPageMoving();
if (!isReordering(false)) {
for (int i = 0; i < getChildCount(); i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (child != null) {
child.setBackgroundAlpha(getOutlineAlphaForPage(screenCenter, i));
child.setContentAlpha(getAlphaForPage(screenCenter, i));
float outlineAlpha = getOutlineAlphaForPage(screenCenter, i, showSidePages);
float contentAlpha = getAlphaForPage(screenCenter, i,showSidePages);
child.setBackgroundAlpha(outlineAlpha);
child.setContentAlpha(contentAlpha);
}
}
}
}
public void showInitialPageHints() {
mShowingInitialHints = true;
int count = getChildCount();
for (int i = 0; i < count; i++) {
boolean inVisibleRange = i >= getNextPage() - 1 && i <= getNextPage() + 1;
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (i >= mCurrentPage - 1 && i <= mCurrentPage + 1) {
child.fadeFrame(this, true, KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER,
CHILDREN_OUTLINE_FADE_IN_DURATION);
if (inVisibleRange) {
child.setBackgroundAlpha(KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
child.setContentAlpha(1f);
} else {
child.setBackgroundAlpha(0f);
child.setContentAlpha(0f);
}
}
}
@@ -220,8 +240,8 @@ public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
for (int i = 0; i < count; i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
float finalAlpha = getAlphaForPage(mScreenCenter, i);
float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i);
float finalAlpha = getAlphaForPage(mScreenCenter, i, true);
float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true);
getTransformForPage(mScreenCenter, i, mTmpTransform);
boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);

View File

@@ -424,7 +424,9 @@ public class KeyguardWidgetFrame extends FrameLayout {
mBgAlphaController = caller;
}
if (mBgAlphaController != caller) return;
if (mBgAlphaController != caller && mBgAlphaController != null) {
return;
}
if (mFrameFade != null) {
mFrameFade.cancel();

View File

@@ -70,6 +70,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
private Callbacks mCallbacks;
private int mWidgetToResetAfterFadeOut;
protected boolean mShowingInitialHints = false;
// Bouncer
private int mBouncerZoomInOutDuration = 250;
@@ -244,7 +245,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
addWidget(widget, -1);
}
public void onRemoveView(View v, final boolean deletePermanently) {
final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
if (mCallbacks != null) {
@@ -458,12 +458,21 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
private void updatePageAlphaValues(int screenCenter) {
}
public float getAlphaForPage(int screenCenter, int index) {
return 1f;
public float getAlphaForPage(int screenCenter, int index, boolean showSidePages) {
if (showSidePages) {
return 1f;
} else {
return index == mCurrentPage ? 1.0f : 0f;
}
}
public float getOutlineAlphaForPage(int screenCenter, int index) {
return getAlphaForPage(screenCenter, index) * KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER;
public float getOutlineAlphaForPage(int screenCenter, int index, boolean showSidePages) {
if (showSidePages) {
return getAlphaForPage(screenCenter, index, showSidePages)
* KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER;
} else {
return 0f;
}
}
protected boolean isOverScrollChild(int index, float scrollProgress) {
@@ -562,12 +571,12 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
}
public void showInitialPageHints() {
mShowingInitialHints = true;
int count = getChildCount();
for (int i = 0; i < count; i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (i != mCurrentPage) {
child.fadeFrame(this, true, KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER,
CHILDREN_OUTLINE_FADE_IN_DURATION);
child.setBackgroundAlpha(KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
child.setContentAlpha(0f);
} else {
child.setBackgroundAlpha(0f);
@@ -576,10 +585,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
}
}
public void showSidePageHints() {
animateOutlinesAndSidePages(true, -1);
}
@Override
void setCurrentPage(int currentPage) {
super.setCurrentPage(currentPage);
@@ -658,7 +663,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
for (int i = 0; i < count; i++) {
float finalContentAlpha;
if (show) {
finalContentAlpha = getAlphaForPage(mScreenCenter, i);
finalContentAlpha = getAlphaForPage(mScreenCenter, i, true);
} else if (!show && i == curPage) {
finalContentAlpha = 1f;
} else {
@@ -670,7 +675,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
ObjectAnimator a = ObjectAnimator.ofPropertyValuesHolder(child, alpha);
anims.add(a);
float finalOutlineAlpha = show ? getOutlineAlphaForPage(mScreenCenter, i) : 0f;
float finalOutlineAlpha = show ? getOutlineAlphaForPage(mScreenCenter, i, true) : 0f;
child.fadeFrame(this, show, finalOutlineAlpha, duration);
}
@@ -696,6 +701,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
frame.resetSize();
}
mWidgetToResetAfterFadeOut = -1;
mShowingInitialHints = false;
}
updateWidgetFramesImportantForAccessibility();
}