Animate QS alpha on split shade pull down
When pulling down the shade in split mode, the quick settings alpha should be directly connected to the drag down gesture and the same that we have for the notification shade. Test: manual Bug: 200804740 Fixes: 196722669 Change-Id: I6532c8a78826a5b60609dc66557abc49a3f140c5 Merged-In: I6532c8a78826a5b60609dc66557abc49a3f140c5
This commit is contained in:
@@ -200,10 +200,10 @@ public class Interpolators {
|
||||
/**
|
||||
* Interpolate alpha for notifications background scrim during shade expansion.
|
||||
* @param fraction Shade expansion fraction
|
||||
* @param forNotification If we want the alpha of the notification shade or the scrim.
|
||||
* @param forUiContent If we want the alpha of the scrims, or ui that's on top of them.
|
||||
*/
|
||||
public static float getNotificationScrimAlpha(float fraction, boolean forNotification) {
|
||||
if (forNotification) {
|
||||
public static float getNotificationScrimAlpha(float fraction, boolean forUiContent) {
|
||||
if (forUiContent) {
|
||||
fraction = MathUtils.constrainedMap(0f, 1f, 0.3f, 1f, fraction);
|
||||
} else {
|
||||
fraction = MathUtils.constrainedMap(0f, 1f, 0f, 0.5f, fraction);
|
||||
|
||||
@@ -53,7 +53,16 @@ public interface QS extends FragmentBase {
|
||||
boolean isShowingDetail();
|
||||
void closeDetail();
|
||||
void animateHeaderSlidingOut();
|
||||
void setQsExpansion(float qsExpansionFraction, float headerTranslation);
|
||||
|
||||
/**
|
||||
* Asks QS to update its presentation, according to {@code NotificationPanelViewController}.
|
||||
*
|
||||
* @param qsExpansionFraction How much each UI element in QS should be expanded (QQS to QS.)
|
||||
* @param panelExpansionFraction Whats the expansion of the whole shade.
|
||||
* @param headerTranslation How much we should vertically translate QS.
|
||||
*/
|
||||
void setQsExpansion(float qsExpansionFraction, float panelExpansionFraction,
|
||||
float headerTranslation);
|
||||
void setHeaderListening(boolean listening);
|
||||
void notifyCustomizeChanged();
|
||||
void setContainer(ViewGroup container);
|
||||
@@ -76,13 +85,13 @@ public interface QS extends FragmentBase {
|
||||
/**
|
||||
* If QS should translate as we pull it down, or if it should be static.
|
||||
*/
|
||||
void setTranslateWhileExpanding(boolean shouldTranslate);
|
||||
void setInSplitShade(boolean shouldTranslate);
|
||||
|
||||
/**
|
||||
* Set the amount of pixels we have currently dragged down if we're transitioning to the full
|
||||
* shade. 0.0f means we're not transitioning yet.
|
||||
*/
|
||||
default void setTransitionToFullShadeAmount(float pxAmount, boolean animated) {}
|
||||
default void setTransitionToFullShadeAmount(float pxAmount, float progress) {}
|
||||
|
||||
/**
|
||||
* A rounded corner clipping that makes QS feel as if it were behind everything.
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.android.systemui.qs.TouchAnimator.Builder;
|
||||
import com.android.systemui.qs.TouchAnimator.Listener;
|
||||
import com.android.systemui.qs.dagger.QSScope;
|
||||
import com.android.systemui.qs.tileimpl.HeightOverrideable;
|
||||
import com.android.systemui.statusbar.CrossFadeHelper;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.tuner.TunerService.Tunable;
|
||||
import com.android.wm.shell.animation.Interpolators;
|
||||
@@ -170,19 +169,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
|
||||
}
|
||||
}
|
||||
|
||||
void startAlphaAnimation(boolean show) {
|
||||
if (show == mToShowing) {
|
||||
return;
|
||||
}
|
||||
mToShowing = show;
|
||||
if (show) {
|
||||
CrossFadeHelper.fadeIn(mQs.getView(), QQS_FADE_IN_DURATION, 0 /* delay */);
|
||||
} else {
|
||||
CrossFadeHelper.fadeOut(mQs.getView(), QQS_FADE_OUT_DURATION, 0 /* delay */,
|
||||
null /* endRunnable */);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the keyguard is currently being shown with a collapsed header.
|
||||
*/
|
||||
|
||||
@@ -89,6 +89,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
private int mLayoutDirection;
|
||||
private QSFooter mFooter;
|
||||
private float mLastQSExpansion = -1;
|
||||
private float mLastPanelFraction;
|
||||
private boolean mQsDisabled;
|
||||
private ImageView mQsDragHandler;
|
||||
|
||||
@@ -120,7 +121,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
* When true, QS will translate from outside the screen. It will be clipped with parallax
|
||||
* otherwise.
|
||||
*/
|
||||
private boolean mTranslateWhileExpanding;
|
||||
private boolean mInSplitShade;
|
||||
private boolean mPulseExpanding;
|
||||
|
||||
/**
|
||||
@@ -135,6 +136,12 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
|
||||
private DumpManager mDumpManager;
|
||||
|
||||
/**
|
||||
* Progress of pull down from the center of the lock screen.
|
||||
* @see com.android.systemui.statusbar.LockscreenShadeTransitionController
|
||||
*/
|
||||
private float mFullShadeProgress;
|
||||
|
||||
@Inject
|
||||
public QSFragment(RemoteInputQuickSettingsDisabler remoteInputQsDisabler,
|
||||
InjectionInflationController injectionInflater, QSTileHost qsTileHost,
|
||||
@@ -226,7 +233,8 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
boolean sizeChanged = (oldTop - oldBottom) != (top - bottom);
|
||||
if (sizeChanged) {
|
||||
setQsExpansion(mLastQSExpansion, mLastHeaderTranslation);
|
||||
setQsExpansion(mLastQSExpansion, mLastPanelFraction,
|
||||
mLastHeaderTranslation);
|
||||
}
|
||||
});
|
||||
mQSPanelController.setUsingHorizontalLayoutChangeListener(
|
||||
@@ -410,7 +418,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
mQSAnimator.setShowCollapsedOnKeyguard(showCollapsed);
|
||||
}
|
||||
if (!showCollapsed && isKeyguardState()) {
|
||||
setQsExpansion(mLastQSExpansion, 0);
|
||||
setQsExpansion(mLastQSExpansion, mLastPanelFraction, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -478,33 +486,30 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTranslateWhileExpanding(boolean shouldTranslate) {
|
||||
mTranslateWhileExpanding = shouldTranslate;
|
||||
mQSAnimator.setTranslateWhileExpanding(shouldTranslate);
|
||||
public void setInSplitShade(boolean inSplitShade) {
|
||||
mInSplitShade = inSplitShade;
|
||||
mQSAnimator.setTranslateWhileExpanding(inSplitShade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransitionToFullShadeAmount(float pxAmount, boolean animated) {
|
||||
public void setTransitionToFullShadeAmount(float pxAmount, float progress) {
|
||||
boolean isTransitioningToFullShade = pxAmount > 0;
|
||||
if (isTransitioningToFullShade != mTransitioningToFullShade) {
|
||||
mTransitioningToFullShade = isTransitioningToFullShade;
|
||||
updateShowCollapsedOnKeyguard();
|
||||
setQsExpansion(mLastQSExpansion, mLastHeaderTranslation);
|
||||
}
|
||||
mFullShadeProgress = progress;
|
||||
setQsExpansion(mLastQSExpansion, mLastPanelFraction, mLastHeaderTranslation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQsExpansion(float expansion, float proposedTranslation) {
|
||||
if (DEBUG) Log.d(TAG, "setQSExpansion " + expansion + " " + proposedTranslation);
|
||||
public void setQsExpansion(float expansion, float panelExpansionFraction,
|
||||
float proposedTranslation) {
|
||||
float headerTranslation = mTransitioningToFullShade ? 0 : proposedTranslation;
|
||||
if (mQSAnimator != null) {
|
||||
final boolean showQSOnLockscreen = expansion > 0;
|
||||
final boolean showQSUnlocked = headerTranslation == 0 || !mTranslateWhileExpanding;
|
||||
mQSAnimator.startAlphaAnimation(showQSOnLockscreen || showQSUnlocked
|
||||
|| mTransitioningToFullShade);
|
||||
}
|
||||
float progress = mTransitioningToFullShade ? mFullShadeProgress : panelExpansionFraction;
|
||||
setAlphaAnimationProgress(mInSplitShade ? progress : 1);
|
||||
mContainer.setExpansion(expansion);
|
||||
final float translationScaleY = (mTranslateWhileExpanding
|
||||
final float translationScaleY = (mInSplitShade
|
||||
? 1 : QSAnimator.SHORT_PARALLAX_AMOUNT) * (expansion - 1);
|
||||
boolean onKeyguardAndExpanded = isKeyguardState() && !mShowCollapsedOnKeyguard;
|
||||
if (!mHeaderAnimating && !headerWillBeAnimating()) {
|
||||
@@ -521,6 +526,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
return;
|
||||
}
|
||||
mLastHeaderTranslation = headerTranslation;
|
||||
mLastPanelFraction = panelExpansionFraction;
|
||||
mLastQSExpansion = expansion;
|
||||
mLastKeyguardAndExpanded = onKeyguardAndExpanded;
|
||||
mLastViewHeight = currentHeight;
|
||||
@@ -562,6 +568,17 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
|
||||
updateMediaPositions();
|
||||
}
|
||||
|
||||
private void setAlphaAnimationProgress(float progress) {
|
||||
final View view = getView();
|
||||
if (progress == 0 && view.getVisibility() != View.INVISIBLE) {
|
||||
view.setVisibility(View.INVISIBLE);
|
||||
} else if (progress > 0 && view.getVisibility() != View.VISIBLE) {
|
||||
view.setVisibility((View.VISIBLE));
|
||||
}
|
||||
float alpha = Interpolators.getNotificationScrimAlpha(progress, true /* uiContent */);
|
||||
view.setAlpha(alpha);
|
||||
}
|
||||
|
||||
private void updateQsBounds() {
|
||||
if (mLastQSExpansion == 1.0f) {
|
||||
// Fully expanded, let's set the layout bounds as clip bounds. This is necessary because
|
||||
|
||||
@@ -298,9 +298,8 @@ class LockscreenShadeTransitionController @Inject constructor(
|
||||
nsslController.setTransitionToFullShadeAmount(field)
|
||||
notificationPanelController.setTransitionToFullShadeAmount(field,
|
||||
false /* animate */, 0 /* delay */)
|
||||
// TODO: appear qs also in split shade
|
||||
val qsAmount = if (useSplitShade) 0f else field
|
||||
qS.setTransitionToFullShadeAmount(qsAmount, false /* animate */)
|
||||
val progress = MathUtils.saturate(dragDownAmount / scrimTransitionDistance)
|
||||
qS.setTransitionToFullShadeAmount(field, progress)
|
||||
// TODO: appear media also in split shade
|
||||
val mediaAmount = if (useSplitShade) 0f else field
|
||||
mediaHierarchyManager.setTransitionToFullShadeAmount(mediaAmount)
|
||||
|
||||
@@ -979,7 +979,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
Utils.shouldUseSplitNotificationShade(mResources);
|
||||
mScrimController.setClipsQsScrim(!mShouldUseSplitNotificationShade);
|
||||
if (mQs != null) {
|
||||
mQs.setTranslateWhileExpanding(mShouldUseSplitNotificationShade);
|
||||
mQs.setInSplitShade(mShouldUseSplitNotificationShade);
|
||||
}
|
||||
|
||||
int topMargin = mShouldUseSplitNotificationShade ? mSplitShadeStatusBarHeight :
|
||||
@@ -2208,7 +2208,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
private void updateQsExpansion() {
|
||||
if (mQs == null) return;
|
||||
float qsExpansionFraction = computeQsExpansionFraction();
|
||||
mQs.setQsExpansion(qsExpansionFraction, getHeaderTranslation());
|
||||
mQs.setQsExpansion(qsExpansionFraction, getExpandedFraction(), getHeaderTranslation());
|
||||
mMediaHierarchyManager.setQsExpansion(qsExpansionFraction);
|
||||
int qsPanelBottomY = calculateQsBottomPosition(qsExpansionFraction);
|
||||
mScrimController.setQsPosition(qsExpansionFraction, qsPanelBottomY);
|
||||
@@ -3476,7 +3476,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
mQs.setExpandClickListener(mOnClickListener);
|
||||
mQs.setHeaderClickable(isQsExpansionEnabled());
|
||||
mQs.setOverscrolling(mStackScrollerOverscrolling);
|
||||
mQs.setTranslateWhileExpanding(mShouldUseSplitNotificationShade);
|
||||
mQs.setInSplitShade(mShouldUseSplitNotificationShade);
|
||||
|
||||
// recompute internal state when qspanel height changes
|
||||
mQs.getView().addOnLayoutChangeListener(
|
||||
|
||||
@@ -209,7 +209,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
|
||||
verify(scrimController, never()).setTransitionToFullShadeProgress(anyFloat())
|
||||
verify(notificationPanelController, never()).setTransitionToFullShadeAmount(anyFloat(),
|
||||
anyBoolean(), anyLong())
|
||||
verify(qS, never()).setTransitionToFullShadeAmount(anyFloat(), anyBoolean())
|
||||
verify(qS, never()).setTransitionToFullShadeAmount(anyFloat(), anyFloat())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,7 +220,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
|
||||
verify(scrimController).setTransitionToFullShadeProgress(anyFloat())
|
||||
verify(notificationPanelController).setTransitionToFullShadeAmount(anyFloat(),
|
||||
anyBoolean(), anyLong())
|
||||
verify(qS).setTransitionToFullShadeAmount(anyFloat(), anyBoolean())
|
||||
verify(qS).setTransitionToFullShadeAmount(anyFloat(), anyFloat())
|
||||
verify(depthController).transitionToFullShadeProgress = anyFloat()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user