Skip to content

Commit 2b0501b

Browse files
author
Adam Cohen
committed
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
1 parent 545043e commit 2b0501b

File tree

3 files changed

+55
-27
lines changed

3 files changed

+55
-27
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetCarousel.java

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package com.android.internal.policy.impl.keyguard;
1717

1818
import android.animation.Animator;
19-
import android.animation.AnimatorListenerAdapter;
2019
import android.animation.AnimatorSet;
2120
import android.animation.ObjectAnimator;
2221
import android.animation.PropertyValuesHolder;
@@ -27,10 +26,10 @@
2726
import android.view.animation.DecelerateInterpolator;
2827
import android.view.animation.Interpolator;
2928

30-
import java.util.ArrayList;
31-
3229
import com.android.internal.R;
3330

31+
import java.util.ArrayList;
32+
3433
public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
3534

3635
private float mAdjacentPagesAngle;
@@ -56,17 +55,30 @@ protected float getMaxScrollProgress() {
5655
return MAX_SCROLL_PROGRESS;
5756
}
5857

59-
public float getAlphaForPage(int screenCenter, int index) {
58+
public float getAlphaForPage(int screenCenter, int index, boolean showSidePages) {
6059
View child = getChildAt(index);
6160
if (child == null) return 0f;
6261

62+
boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
6363
float scrollProgress = getScrollProgress(screenCenter, child, index);
64-
if (!isOverScrollChild(index, scrollProgress)) {
64+
65+
if (isOverScrollChild(index, scrollProgress)) {
66+
return 1.0f;
67+
} else if ((showSidePages && inVisibleRange) || index == getNextPage()) {
6568
scrollProgress = getBoundedScrollProgress(screenCenter, child, index);
6669
float alpha = 1.0f - 1.0f * Math.abs(scrollProgress / MAX_SCROLL_PROGRESS);
6770
return alpha;
6871
} else {
69-
return 1.0f;
72+
return 0f;
73+
}
74+
}
75+
76+
public float getOutlineAlphaForPage(int screenCenter, int index, boolean showSidePages) {
77+
boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
78+
if (inVisibleRange) {
79+
return super.getOutlineAlphaForPage(screenCenter, index, showSidePages);
80+
} else {
81+
return 0f;
7082
}
7183
}
7284

@@ -75,24 +87,32 @@ private void updatePageAlphaValues(int screenCenter) {
7587
mChildrenOutlineFadeAnimation.cancel();
7688
mChildrenOutlineFadeAnimation = null;
7789
}
90+
boolean showSidePages = mShowingInitialHints || isPageMoving();
7891
if (!isReordering(false)) {
7992
for (int i = 0; i < getChildCount(); i++) {
8093
KeyguardWidgetFrame child = getWidgetPageAt(i);
8194
if (child != null) {
82-
child.setBackgroundAlpha(getOutlineAlphaForPage(screenCenter, i));
83-
child.setContentAlpha(getAlphaForPage(screenCenter, i));
95+
float outlineAlpha = getOutlineAlphaForPage(screenCenter, i, showSidePages);
96+
float contentAlpha = getAlphaForPage(screenCenter, i,showSidePages);
97+
child.setBackgroundAlpha(outlineAlpha);
98+
child.setContentAlpha(contentAlpha);
8499
}
85100
}
86101
}
87102
}
88103

89104
public void showInitialPageHints() {
105+
mShowingInitialHints = true;
90106
int count = getChildCount();
91107
for (int i = 0; i < count; i++) {
108+
boolean inVisibleRange = i >= getNextPage() - 1 && i <= getNextPage() + 1;
92109
KeyguardWidgetFrame child = getWidgetPageAt(i);
93-
if (i >= mCurrentPage - 1 && i <= mCurrentPage + 1) {
94-
child.fadeFrame(this, true, KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER,
95-
CHILDREN_OUTLINE_FADE_IN_DURATION);
110+
if (inVisibleRange) {
111+
child.setBackgroundAlpha(KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
112+
child.setContentAlpha(1f);
113+
} else {
114+
child.setBackgroundAlpha(0f);
115+
child.setContentAlpha(0f);
96116
}
97117
}
98118
}
@@ -220,8 +240,8 @@ void animatePagesToCarousel() {
220240

221241
for (int i = 0; i < count; i++) {
222242
KeyguardWidgetFrame child = getWidgetPageAt(i);
223-
float finalAlpha = getAlphaForPage(mScreenCenter, i);
224-
float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i);
243+
float finalAlpha = getAlphaForPage(mScreenCenter, i, true);
244+
float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true);
225245
getTransformForPage(mScreenCenter, i, mTmpTransform);
226246

227247
boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@ public void fadeFrame(Object caller, boolean takeControl, float alpha, int durat
424424
mBgAlphaController = caller;
425425
}
426426

427-
if (mBgAlphaController != caller) return;
427+
if (mBgAlphaController != caller && mBgAlphaController != null) {
428+
return;
429+
}
428430

429431
if (mFrameFade != null) {
430432
mFrameFade.cancel();

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
7070
private Callbacks mCallbacks;
7171

7272
private int mWidgetToResetAfterFadeOut;
73+
protected boolean mShowingInitialHints = false;
7374

7475
// Bouncer
7576
private int mBouncerZoomInOutDuration = 250;
@@ -244,7 +245,6 @@ public void addWidget(View widget) {
244245
addWidget(widget, -1);
245246
}
246247

247-
248248
public void onRemoveView(View v, final boolean deletePermanently) {
249249
final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
250250
if (mCallbacks != null) {
@@ -458,12 +458,21 @@ float backgroundAlphaInterpolator(float r) {
458458
private void updatePageAlphaValues(int screenCenter) {
459459
}
460460

461-
public float getAlphaForPage(int screenCenter, int index) {
462-
return 1f;
461+
public float getAlphaForPage(int screenCenter, int index, boolean showSidePages) {
462+
if (showSidePages) {
463+
return 1f;
464+
} else {
465+
return index == mCurrentPage ? 1.0f : 0f;
466+
}
463467
}
464468

465-
public float getOutlineAlphaForPage(int screenCenter, int index) {
466-
return getAlphaForPage(screenCenter, index) * KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER;
469+
public float getOutlineAlphaForPage(int screenCenter, int index, boolean showSidePages) {
470+
if (showSidePages) {
471+
return getAlphaForPage(screenCenter, index, showSidePages)
472+
* KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER;
473+
} else {
474+
return 0f;
475+
}
467476
}
468477

469478
protected boolean isOverScrollChild(int index, float scrollProgress) {
@@ -562,12 +571,12 @@ void hideOutlinesAndSidePages() {
562571
}
563572

564573
public void showInitialPageHints() {
574+
mShowingInitialHints = true;
565575
int count = getChildCount();
566576
for (int i = 0; i < count; i++) {
567577
KeyguardWidgetFrame child = getWidgetPageAt(i);
568578
if (i != mCurrentPage) {
569-
child.fadeFrame(this, true, KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER,
570-
CHILDREN_OUTLINE_FADE_IN_DURATION);
579+
child.setBackgroundAlpha(KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
571580
child.setContentAlpha(0f);
572581
} else {
573582
child.setBackgroundAlpha(0f);
@@ -576,10 +585,6 @@ public void showInitialPageHints() {
576585
}
577586
}
578587

579-
public void showSidePageHints() {
580-
animateOutlinesAndSidePages(true, -1);
581-
}
582-
583588
@Override
584589
void setCurrentPage(int currentPage) {
585590
super.setCurrentPage(currentPage);
@@ -658,7 +663,7 @@ void animateOutlinesAndSidePages(final boolean show, int duration) {
658663
for (int i = 0; i < count; i++) {
659664
float finalContentAlpha;
660665
if (show) {
661-
finalContentAlpha = getAlphaForPage(mScreenCenter, i);
666+
finalContentAlpha = getAlphaForPage(mScreenCenter, i, true);
662667
} else if (!show && i == curPage) {
663668
finalContentAlpha = 1f;
664669
} else {
@@ -670,7 +675,7 @@ void animateOutlinesAndSidePages(final boolean show, int duration) {
670675
ObjectAnimator a = ObjectAnimator.ofPropertyValuesHolder(child, alpha);
671676
anims.add(a);
672677

673-
float finalOutlineAlpha = show ? getOutlineAlphaForPage(mScreenCenter, i) : 0f;
678+
float finalOutlineAlpha = show ? getOutlineAlphaForPage(mScreenCenter, i, true) : 0f;
674679
child.fadeFrame(this, show, finalOutlineAlpha, duration);
675680
}
676681

@@ -696,6 +701,7 @@ public void onAnimationEnd(Animator animation) {
696701
frame.resetSize();
697702
}
698703
mWidgetToResetAfterFadeOut = -1;
704+
mShowingInitialHints = false;
699705
}
700706
updateWidgetFramesImportantForAccessibility();
701707
}

0 commit comments

Comments
 (0)