Merge "Reduce notification section gap on lockscreen; increase gap when going to shade" into tm-dev
This commit is contained in:
@@ -561,6 +561,9 @@
|
|||||||
<!-- The height of the gap between adjacent notification sections. -->
|
<!-- The height of the gap between adjacent notification sections. -->
|
||||||
<dimen name="notification_section_divider_height">@dimen/notification_side_paddings</dimen>
|
<dimen name="notification_section_divider_height">@dimen/notification_side_paddings</dimen>
|
||||||
|
|
||||||
|
<!-- The height of the gap between adjacent notification sections on lockscreen. -->
|
||||||
|
<dimen name="notification_section_divider_height_lockscreen">4dp</dimen>
|
||||||
|
|
||||||
<!-- Size of the face pile shown on one-line (children of a group) conversation notifications -->
|
<!-- Size of the face pile shown on one-line (children of a group) conversation notifications -->
|
||||||
<dimen name="conversation_single_line_face_pile_size">24dp</dimen>
|
<dimen name="conversation_single_line_face_pile_size">24dp</dimen>
|
||||||
|
|
||||||
|
|||||||
@@ -85,9 +85,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
|||||||
private NotificationShelfController mController;
|
private NotificationShelfController mController;
|
||||||
private float mActualWidth = -1;
|
private float mActualWidth = -1;
|
||||||
|
|
||||||
/** Fraction of lockscreen to shade animation (on lockscreen swipe down). */
|
|
||||||
private float mFractionToShade;
|
|
||||||
|
|
||||||
public NotificationShelf(Context context, AttributeSet attrs) {
|
public NotificationShelf(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
@@ -233,13 +230,6 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
|||||||
mActualWidth = actualWidth;
|
mActualWidth = actualWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fractionToShade Fraction of lockscreen to shade transition
|
|
||||||
*/
|
|
||||||
public void setFractionToShade(float fractionToShade) {
|
|
||||||
mFractionToShade = fractionToShade;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Actual width of shelf, accounting for possible ongoing width animation
|
* @return Actual width of shelf, accounting for possible ongoing width animation
|
||||||
*/
|
*/
|
||||||
@@ -411,7 +401,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
|
|||||||
|| !mShowNotificationShelf
|
|| !mShowNotificationShelf
|
||||||
|| numViewsInShelf < 1f;
|
|| numViewsInShelf < 1f;
|
||||||
|
|
||||||
final float fractionToShade = Interpolators.STANDARD.getInterpolation(mFractionToShade);
|
final float fractionToShade = Interpolators.STANDARD.getInterpolation(
|
||||||
|
mAmbientState.getFractionToShade());
|
||||||
final float shortestWidth = mShelfIcons.calculateWidthFor(numViewsInShelf);
|
final float shortestWidth = mShelfIcons.calculateWidthFor(numViewsInShelf);
|
||||||
updateActualWidth(fractionToShade, shortestWidth);
|
updateActualWidth(fractionToShade, shortestWidth);
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,23 @@ public class AmbientState {
|
|||||||
private boolean mAppearing;
|
private boolean mAppearing;
|
||||||
private float mPulseHeight = MAX_PULSE_HEIGHT;
|
private float mPulseHeight = MAX_PULSE_HEIGHT;
|
||||||
|
|
||||||
|
/** Fraction of lockscreen to shade animation (on lockscreen swipe down). */
|
||||||
|
private float mFractionToShade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fractionToShade Fraction of lockscreen to shade transition
|
||||||
|
*/
|
||||||
|
public void setFractionToShade(float fractionToShade) {
|
||||||
|
mFractionToShade = fractionToShade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return fractionToShade Fraction of lockscreen to shade transition
|
||||||
|
*/
|
||||||
|
public float getFractionToShade() {
|
||||||
|
return mFractionToShade;
|
||||||
|
}
|
||||||
|
|
||||||
/** How we much we are sleeping. 1f fully dozing (AOD), 0f fully awake (for all other states) */
|
/** How we much we are sleeping. 1f fully dozing (AOD), 0f fully awake (for all other states) */
|
||||||
private float mDozeAmount = 0.0f;
|
private float mDozeAmount = 0.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -2295,7 +2295,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|
|||||||
int visibleIndex
|
int visibleIndex
|
||||||
) {
|
) {
|
||||||
return mStackScrollAlgorithm.getGapHeightForChild(mSectionsManager, visibleIndex, current,
|
return mStackScrollAlgorithm.getGapHeightForChild(mSectionsManager, visibleIndex, current,
|
||||||
previous);
|
previous, mAmbientState.getFractionToShade(), mAmbientState.isOnKeyguard());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||||
@@ -5501,7 +5501,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|
|||||||
* where it remains until the next lockscreen-to-shade transition.
|
* where it remains until the next lockscreen-to-shade transition.
|
||||||
*/
|
*/
|
||||||
public void setFractionToShade(float fraction) {
|
public void setFractionToShade(float fraction) {
|
||||||
mShelf.setFractionToShade(fraction);
|
mAmbientState.setFractionToShade(fraction);
|
||||||
requestChildrenUpdate();
|
requestChildrenUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class StackScrollAlgorithm {
|
|||||||
|
|
||||||
private int mPaddingBetweenElements;
|
private int mPaddingBetweenElements;
|
||||||
private int mGapHeight;
|
private int mGapHeight;
|
||||||
|
private int mGapHeightOnLockscreen;
|
||||||
private int mCollapsedSize;
|
private int mCollapsedSize;
|
||||||
|
|
||||||
private StackScrollAlgorithmState mTempAlgorithmState = new StackScrollAlgorithmState();
|
private StackScrollAlgorithmState mTempAlgorithmState = new StackScrollAlgorithmState();
|
||||||
@@ -87,6 +88,8 @@ public class StackScrollAlgorithm {
|
|||||||
mPinnedZTranslationExtra = res.getDimensionPixelSize(
|
mPinnedZTranslationExtra = res.getDimensionPixelSize(
|
||||||
R.dimen.heads_up_pinned_elevation);
|
R.dimen.heads_up_pinned_elevation);
|
||||||
mGapHeight = res.getDimensionPixelSize(R.dimen.notification_section_divider_height);
|
mGapHeight = res.getDimensionPixelSize(R.dimen.notification_section_divider_height);
|
||||||
|
mGapHeightOnLockscreen = res.getDimensionPixelSize(
|
||||||
|
R.dimen.notification_section_divider_height_lockscreen);
|
||||||
mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
|
mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
|
||||||
mMarginBottom = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
|
mMarginBottom = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
|
||||||
}
|
}
|
||||||
@@ -305,7 +308,8 @@ public class StackScrollAlgorithm {
|
|||||||
ambientState.getSectionProvider(), i,
|
ambientState.getSectionProvider(), i,
|
||||||
view, getPreviousView(i, state));
|
view, getPreviousView(i, state));
|
||||||
if (applyGapHeight) {
|
if (applyGapHeight) {
|
||||||
currentY += mGapHeight;
|
currentY += getGapForLocation(
|
||||||
|
ambientState.getFractionToShade(), ambientState.isOnKeyguard());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambientState.getShelf() != null) {
|
if (ambientState.getShelf() != null) {
|
||||||
@@ -454,8 +458,10 @@ public class StackScrollAlgorithm {
|
|||||||
ambientState.getSectionProvider(), i,
|
ambientState.getSectionProvider(), i,
|
||||||
view, getPreviousView(i, algorithmState));
|
view, getPreviousView(i, algorithmState));
|
||||||
if (applyGapHeight) {
|
if (applyGapHeight) {
|
||||||
algorithmState.mCurrentYPosition += expansionFraction * mGapHeight;
|
final float gap = getGapForLocation(
|
||||||
algorithmState.mCurrentExpandedYPosition += mGapHeight;
|
ambientState.getFractionToShade(), ambientState.isOnKeyguard());
|
||||||
|
algorithmState.mCurrentYPosition += expansionFraction * gap;
|
||||||
|
algorithmState.mCurrentExpandedYPosition += gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewState.yTranslation = algorithmState.mCurrentYPosition;
|
viewState.yTranslation = algorithmState.mCurrentYPosition;
|
||||||
@@ -539,16 +545,29 @@ public class StackScrollAlgorithm {
|
|||||||
SectionProvider sectionProvider,
|
SectionProvider sectionProvider,
|
||||||
int visibleIndex,
|
int visibleIndex,
|
||||||
View child,
|
View child,
|
||||||
View previousChild) {
|
View previousChild,
|
||||||
|
float fractionToShade,
|
||||||
|
boolean onKeyguard) {
|
||||||
|
|
||||||
if (childNeedsGapHeight(sectionProvider, visibleIndex, child,
|
if (childNeedsGapHeight(sectionProvider, visibleIndex, child,
|
||||||
previousChild)) {
|
previousChild)) {
|
||||||
return mGapHeight;
|
return getGapForLocation(fractionToShade, onKeyguard);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
float getGapForLocation(float fractionToShade, boolean onKeyguard) {
|
||||||
|
if (fractionToShade > 0f) {
|
||||||
|
return MathUtils.lerp(mGapHeightOnLockscreen, mGapHeight, fractionToShade);
|
||||||
|
}
|
||||||
|
if (onKeyguard) {
|
||||||
|
return mGapHeightOnLockscreen;
|
||||||
|
}
|
||||||
|
return mGapHeight;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does a given child need a gap, i.e spacing before a view?
|
* Does a given child need a gap, i.e spacing before a view?
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class NotificationShelfTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setFractionToShade(fraction: Float) {
|
private fun setFractionToShade(fraction: Float) {
|
||||||
shelf.setFractionToShade(fraction)
|
whenever(ambientState.fractionToShade).thenReturn(fraction)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setOnLockscreen(isOnLockscreen: Boolean) {
|
private fun setOnLockscreen(isOnLockscreen: Boolean) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.android.systemui.statusbar.notification.stack
|
package com.android.systemui.statusbar.notification.stack
|
||||||
|
|
||||||
|
import android.annotation.DimenRes
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
@@ -31,6 +32,14 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
|
|||||||
mStatusBarKeyguardViewManager
|
mStatusBarKeyguardViewManager
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val testableResources = mContext.orCreateTestableResources
|
||||||
|
|
||||||
|
private fun px(@DimenRes id: Int): Float =
|
||||||
|
testableResources.resources.getDimensionPixelSize(id).toFloat()
|
||||||
|
|
||||||
|
private val bigGap = px(R.dimen.notification_section_divider_height)
|
||||||
|
private val smallGap = px(R.dimen.notification_section_divider_height_lockscreen)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
whenever(notificationRow.viewState).thenReturn(expandableViewState)
|
whenever(notificationRow.viewState).thenReturn(expandableViewState)
|
||||||
@@ -80,4 +89,25 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
|
|||||||
val centeredY = ambientState.stackY + fullHeight / 2f - emptyShadeView.height / 2f
|
val centeredY = ambientState.stackY + fullHeight / 2f - emptyShadeView.height / 2f
|
||||||
assertThat(emptyShadeView.viewState?.yTranslation).isEqualTo(centeredY)
|
assertThat(emptyShadeView.viewState?.yTranslation).isEqualTo(centeredY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getGapForLocation_onLockscreen_returnsSmallGap() {
|
||||||
|
val gap = stackScrollAlgorithm.getGapForLocation(
|
||||||
|
/* fractionToShade= */ 0f, /* onKeyguard= */ true)
|
||||||
|
assertThat(gap).isEqualTo(smallGap)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getGapForLocation_goingToShade_interpolatesGap() {
|
||||||
|
val gap = stackScrollAlgorithm.getGapForLocation(
|
||||||
|
/* fractionToShade= */ 0.5f, /* onKeyguard= */ true)
|
||||||
|
assertThat(gap).isEqualTo(smallGap * 0.5f + bigGap * 0.5f)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getGapForLocation_notOnLockscreen_returnsBigGap() {
|
||||||
|
val gap = stackScrollAlgorithm.getGapForLocation(
|
||||||
|
/* fractionToShade= */ 0f, /* onKeyguard= */ false)
|
||||||
|
assertThat(gap).isEqualTo(bigGap)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user