Skip to content

Commit 4b9710e

Browse files
author
Selim Cinek
committed
Made sure that the media section has no background
The background is unnecessary and UX wise doesn't look good when scrolling. We therefore remove it from the media header. Because the screen animation still depends on having the bounds calculated correctly, we now make all of the background views ExpandableViews instead of ActivatableNotificationRows. Bug: 154137987 Test: add media notification, observe no background, normal screen on / off animation Change-Id: Ie18af9d61d8d128c7a9397660910403e87c6fd51
1 parent 7f65760 commit 4b9710e

10 files changed

Lines changed: 123 additions & 124 deletions

packages/SystemUI/res/layout/keyguard_media_header.xml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,4 @@
2424
android:paddingEnd="0dp"
2525
android:focusable="true"
2626
android:clickable="true"
27-
>
28-
29-
<!-- Background views required by ActivatableNotificationView. -->
30-
<com.android.systemui.statusbar.notification.row.NotificationBackgroundView
31-
android:id="@+id/backgroundNormal"
32-
android:layout_width="match_parent"
33-
android:layout_height="match_parent"
34-
/>
35-
36-
<com.android.systemui.statusbar.notification.row.NotificationBackgroundView
37-
android:id="@+id/backgroundDimmed"
38-
android:layout_width="match_parent"
39-
android:layout_height="match_parent"
40-
/>
41-
42-
<com.android.systemui.statusbar.notification.FakeShadowView
43-
android:id="@+id/fake_shadow"
44-
android:layout_width="match_parent"
45-
android:layout_height="match_parent"
46-
/>
47-
48-
</com.android.systemui.statusbar.notification.stack.MediaHeaderView>
27+
/>

packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
123123
private float mAppearAnimationFraction = -1.0f;
124124
private float mAppearAnimationTranslation;
125125
private int mNormalColor;
126-
private boolean mLastInSection;
127-
private boolean mFirstInSection;
128126
private boolean mIsBelowSpeedBump;
129127

130128
private float mNormalBackgroundVisibilityAmount;
@@ -430,27 +428,21 @@ public void setDistanceToTopRoundness(float distanceToTopRoundness) {
430428
mBackgroundDimmed.setDistanceToTopRoundness(distanceToTopRoundness);
431429
}
432430

433-
public boolean isLastInSection() {
434-
return mLastInSection;
435-
}
436-
437-
public boolean isFirstInSection() {
438-
return mFirstInSection;
439-
}
440-
441431
/** Sets whether this view is the last notification in a section. */
432+
@Override
442433
public void setLastInSection(boolean lastInSection) {
443434
if (lastInSection != mLastInSection) {
444-
mLastInSection = lastInSection;
435+
super.setLastInSection(lastInSection);
445436
mBackgroundNormal.setLastInSection(lastInSection);
446437
mBackgroundDimmed.setLastInSection(lastInSection);
447438
}
448439
}
449440

450441
/** Sets whether this view is the first notification in a section. */
442+
@Override
451443
public void setFirstInSection(boolean firstInSection) {
452444
if (firstInSection != mFirstInSection) {
453-
mFirstInSection = firstInSection;
445+
super.setFirstInSection(firstInSection);
454446
mBackgroundNormal.setFirstInSection(firstInSection);
455447
mBackgroundDimmed.setFirstInSection(firstInSection);
456448
}
@@ -963,6 +955,7 @@ public boolean isHeadsUp() {
963955
return false;
964956
}
965957

958+
@Override
966959
public int getHeadsUpHeightWithoutHeader() {
967960
return getHeight();
968961
}

packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,7 @@ private void initDimens() {
262262
setClipToOutline(mAlwaysRoundBothCorners);
263263
}
264264

265-
/**
266-
* Set the topRoundness of this view.
267-
* @return Whether the roundness was changed.
268-
*/
265+
@Override
269266
public boolean setTopRoundness(float topRoundness, boolean animate) {
270267
if (mTopRoundness != topRoundness) {
271268
mTopRoundness = topRoundness;
@@ -302,10 +299,7 @@ protected float getCurrentBackgroundRadiusBottom() {
302299
return mCurrentBottomRoundness * mOutlineRadius;
303300
}
304301

305-
/**
306-
* Set the bottom roundness of this view.
307-
* @return Whether the roundness was changed.
308-
*/
302+
@Override
309303
public boolean setBottomRoundness(float bottomRoundness, boolean animate) {
310304
if (mBottomRoundness != bottomRoundness) {
311305
mBottomRoundness = bottomRoundness;

packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {
6767
protected int mContentShift;
6868
private final ExpandableViewState mViewState;
6969
private float mContentTranslation;
70+
protected boolean mLastInSection;
71+
protected boolean mFirstInSection;
7072

7173
public ExpandableView(Context context, AttributeSet attrs) {
7274
super(context, attrs);
@@ -771,6 +773,44 @@ public boolean wantsAddAndRemoveAnimations() {
771773
return true;
772774
}
773775

776+
/** Sets whether this view is the first notification in a section. */
777+
public void setFirstInSection(boolean firstInSection) {
778+
mFirstInSection = firstInSection;
779+
}
780+
781+
/** Sets whether this view is the last notification in a section. */
782+
public void setLastInSection(boolean lastInSection) {
783+
mLastInSection = lastInSection;
784+
}
785+
786+
public boolean isLastInSection() {
787+
return mLastInSection;
788+
}
789+
790+
public boolean isFirstInSection() {
791+
return mFirstInSection;
792+
}
793+
794+
/**
795+
* Set the topRoundness of this view.
796+
* @return Whether the roundness was changed.
797+
*/
798+
public boolean setTopRoundness(float topRoundness, boolean animate) {
799+
return false;
800+
}
801+
802+
/**
803+
* Set the bottom roundness of this view.
804+
* @return Whether the roundness was changed.
805+
*/
806+
public boolean setBottomRoundness(float bottomRoundness, boolean animate) {
807+
return false;
808+
}
809+
810+
public int getHeadsUpHeightWithoutHeader() {
811+
return getHeight();
812+
}
813+
774814
/**
775815
* A listener notifying when {@link #getActualHeight} changes.
776816
*/

packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class AmbientState {
6464
private int mZDistanceBetweenElements;
6565
private int mBaseZHeight;
6666
private int mMaxLayoutHeight;
67-
private ActivatableNotificationView mLastVisibleBackgroundChild;
67+
private ExpandableView mLastVisibleBackgroundChild;
6868
private float mCurrentScrollVelocity;
6969
private int mStatusBarState;
7070
private float mExpandingVelocity;
@@ -346,11 +346,11 @@ public void setLayoutMaxHeight(int maxLayoutHeight) {
346346
* view in the shade, without the clear all button.
347347
*/
348348
public void setLastVisibleBackgroundChild(
349-
ActivatableNotificationView lastVisibleBackgroundChild) {
349+
ExpandableView lastVisibleBackgroundChild) {
350350
mLastVisibleBackgroundChild = lastVisibleBackgroundChild;
351351
}
352352

353-
public ActivatableNotificationView getLastVisibleBackgroundChild() {
353+
public ExpandableView getLastVisibleBackgroundChild() {
354354
return mLastVisibleBackgroundChild;
355355
}
356356

packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/MediaHeaderView.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,35 @@
1616

1717
package com.android.systemui.statusbar.notification.stack;
1818

19+
import android.animation.AnimatorListenerAdapter;
1920
import android.content.Context;
2021
import android.util.AttributeSet;
21-
import android.view.View;
2222
import android.view.ViewGroup;
2323

24-
import com.android.systemui.R;
25-
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
24+
import com.android.systemui.statusbar.notification.row.ExpandableView;
2625

2726
/**
2827
* Root view to insert Lock screen media controls into the notification stack.
2928
*/
30-
public class MediaHeaderView extends ActivatableNotificationView {
31-
32-
private View mContentView;
29+
public class MediaHeaderView extends ExpandableView {
3330

3431
public MediaHeaderView(Context context, AttributeSet attrs) {
3532
super(context, attrs);
3633
}
3734

3835
@Override
39-
protected void onFinishInflate() {
40-
super.onFinishInflate();
36+
public long performRemoveAnimation(long duration, long delay, float translationDirection,
37+
boolean isHeadsUpAnimation, float endLocation, Runnable onFinishedRunnable,
38+
AnimatorListenerAdapter animationListener) {
39+
return 0;
4140
}
4241

4342
@Override
44-
protected View getContentView() {
45-
return mContentView;
46-
}
47-
48-
/**
49-
* Sets the background color, to be used when album art changes.
50-
* @param color background
51-
*/
52-
public void setBackgroundColor(int color) {
53-
setTintColor(color);
43+
public void performAddAnimation(long delay, long duration, boolean isHeadsUpAppear) {
44+
// No animation, it doesn't need it, this would be local
5445
}
5546

5647
public void setContentView(ViewGroup contentView) {
57-
mContentView = contentView;
5848
addView(contentView);
5949
ViewGroup.LayoutParams layoutParams = contentView.getLayoutParams();
6050
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;

packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager;
2222
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
23-
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
2423
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
2524
import com.android.systemui.statusbar.notification.row.ExpandableView;
2625
import com.android.systemui.statusbar.phone.KeyguardBypassController;
@@ -37,10 +36,10 @@
3736
@Singleton
3837
public class NotificationRoundnessManager implements OnHeadsUpChangedListener {
3938

40-
private final ActivatableNotificationView[] mFirstInSectionViews;
41-
private final ActivatableNotificationView[] mLastInSectionViews;
42-
private final ActivatableNotificationView[] mTmpFirstInSectionViews;
43-
private final ActivatableNotificationView[] mTmpLastInSectionViews;
39+
private final ExpandableView[] mFirstInSectionViews;
40+
private final ExpandableView[] mLastInSectionViews;
41+
private final ExpandableView[] mTmpFirstInSectionViews;
42+
private final ExpandableView[] mTmpLastInSectionViews;
4443
private final KeyguardBypassController mBypassController;
4544
private boolean mExpanded;
4645
private HashSet<ExpandableView> mAnimatedChildren;
@@ -53,10 +52,10 @@ public class NotificationRoundnessManager implements OnHeadsUpChangedListener {
5352
KeyguardBypassController keyguardBypassController,
5453
NotificationSectionsFeatureManager sectionsFeatureManager) {
5554
int numberOfSections = sectionsFeatureManager.getNumberOfBuckets();
56-
mFirstInSectionViews = new ActivatableNotificationView[numberOfSections];
57-
mLastInSectionViews = new ActivatableNotificationView[numberOfSections];
58-
mTmpFirstInSectionViews = new ActivatableNotificationView[numberOfSections];
59-
mTmpLastInSectionViews = new ActivatableNotificationView[numberOfSections];
55+
mFirstInSectionViews = new ExpandableView[numberOfSections];
56+
mLastInSectionViews = new ExpandableView[numberOfSections];
57+
mTmpFirstInSectionViews = new ExpandableView[numberOfSections];
58+
mTmpLastInSectionViews = new ExpandableView[numberOfSections];
6059
mBypassController = keyguardBypassController;
6160
}
6261

@@ -80,14 +79,14 @@ public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
8079
updateView(entry.getRow(), false /* animate */);
8180
}
8281

83-
private void updateView(ActivatableNotificationView view, boolean animate) {
82+
private void updateView(ExpandableView view, boolean animate) {
8483
boolean changed = updateViewWithoutCallback(view, animate);
8584
if (changed) {
8685
mRoundingChangedCallback.run();
8786
}
8887
}
8988

90-
private boolean updateViewWithoutCallback(ActivatableNotificationView view,
89+
private boolean updateViewWithoutCallback(ExpandableView view,
9190
boolean animate) {
9291
float topRoundness = getRoundness(view, true /* top */);
9392
float bottomRoundness = getRoundness(view, false /* top */);
@@ -100,8 +99,7 @@ private boolean updateViewWithoutCallback(ActivatableNotificationView view,
10099
return (firstInSection || lastInSection) && (topChanged || bottomChanged);
101100
}
102101

103-
private boolean isFirstInSection(ActivatableNotificationView view,
104-
boolean includeFirstSection) {
102+
private boolean isFirstInSection(ExpandableView view, boolean includeFirstSection) {
105103
int numNonEmptySections = 0;
106104
for (int i = 0; i < mFirstInSectionViews.length; i++) {
107105
if (view == mFirstInSectionViews[i]) {
@@ -114,7 +112,7 @@ private boolean isFirstInSection(ActivatableNotificationView view,
114112
return false;
115113
}
116114

117-
private boolean isLastInSection(ActivatableNotificationView view, boolean includeLastSection) {
115+
private boolean isLastInSection(ExpandableView view, boolean includeLastSection) {
118116
int numNonEmptySections = 0;
119117
for (int i = mLastInSectionViews.length - 1; i >= 0; i--) {
120118
if (view == mLastInSectionViews[i]) {
@@ -127,7 +125,7 @@ private boolean isLastInSection(ActivatableNotificationView view, boolean includ
127125
return false;
128126
}
129127

130-
private float getRoundness(ActivatableNotificationView view, boolean top) {
128+
private float getRoundness(ExpandableView view, boolean top) {
131129
if ((view.isPinned() || view.isHeadsUpAnimatingAway()) && !mExpanded) {
132130
return 1.0f;
133131
}
@@ -174,14 +172,14 @@ public void updateRoundedChildren(NotificationSection[] sections) {
174172
}
175173

176174
private boolean handleRemovedOldViews(NotificationSection[] sections,
177-
ActivatableNotificationView[] oldViews, boolean first) {
175+
ExpandableView[] oldViews, boolean first) {
178176
boolean anyChanged = false;
179-
for (ActivatableNotificationView oldView : oldViews) {
177+
for (ExpandableView oldView : oldViews) {
180178
if (oldView != null) {
181179
boolean isStillPresent = false;
182180
boolean adjacentSectionChanged = false;
183181
for (NotificationSection section : sections) {
184-
ActivatableNotificationView newView =
182+
ExpandableView newView =
185183
(first ? section.getFirstVisibleChild()
186184
: section.getLastVisibleChild());
187185
if (newView == oldView) {
@@ -207,14 +205,14 @@ private boolean handleRemovedOldViews(NotificationSection[] sections,
207205
}
208206

209207
private boolean handleAddedNewViews(NotificationSection[] sections,
210-
ActivatableNotificationView[] oldViews, boolean first) {
208+
ExpandableView[] oldViews, boolean first) {
211209
boolean anyChanged = false;
212210
for (NotificationSection section : sections) {
213-
ActivatableNotificationView newView =
211+
ExpandableView newView =
214212
(first ? section.getFirstVisibleChild() : section.getLastVisibleChild());
215213
if (newView != null) {
216214
boolean wasAlreadyPresent = false;
217-
for (ActivatableNotificationView oldView : oldViews) {
215+
for (ExpandableView oldView : oldViews) {
218216
if (oldView == newView) {
219217
wasAlreadyPresent = true;
220218
break;

0 commit comments

Comments
 (0)