@@ -114,6 +114,11 @@ public class PeekDisplayView extends LinearLayout {
114
114
115
115
private boolean mIsSettingsInterface = false ;
116
116
117
+ private static final int CLEAR_ALL_MODE_NONE = 0 ;
118
+ private static final int CLEAR_ALL_MODE_COUNT = 1 ;
119
+ private int mClearAllMode = CLEAR_ALL_MODE_COUNT ;
120
+ private int mClearAllCount = 4 ;
121
+
117
122
public PeekDisplayView (Context context , String tag , boolean settingsInterface ) {
118
123
super (context );
119
124
Log .d ("PeekDisplayView" , "PeekDisplayView: Constructor" );
@@ -285,7 +290,8 @@ public void updatePeekStyle(
285
290
int backgroundColor , int iconSize , int iconMarginEnd , int iconPadding ,
286
291
int titleColor , int summaryColor , int cardBackgroundColor , float [] cardBackgroundRadius ,
287
292
int buttonsColor ,
288
- boolean useAppIcons ) {
293
+ boolean useAppIcons ,
294
+ int clearAllMode , int clearAllCount ) {
289
295
Log .d ("PeekDisplayView" , "updatePeekStyle: " + newStyle + " " + newIconStyle + "\n " +
290
296
"backgroundColor: " + backgroundColor + "\n " +
291
297
"iconSize: " + iconSize + "\n " +
@@ -299,7 +305,9 @@ public void updatePeekStyle(
299
305
"useAppIcons: " + useAppIcons );
300
306
boolean requireUpdate = checkChange (newIconStyle , iconSize , backgroundColor , iconMarginEnd , iconPadding ) ||
301
307
newIconStyle != mCurrentPeekStyle .getPeekIconStyle ().getStyle () ||
302
- useAppIcons != mCurrentPeekStyle .useAppIcons ();
308
+ useAppIcons != mCurrentPeekStyle .useAppIcons () ||
309
+ clearAllCount != mClearAllCount ||
310
+ clearAllMode != mClearAllMode ;
303
311
PEEK_STYLE_CUSTOM = new PeekStyle (
304
312
"custom" , 2 ,
305
313
titleColor , summaryColor , cardBackgroundColor , cardBackgroundRadius ,
@@ -318,6 +326,8 @@ public void updatePeekStyle(
318
326
mCurrentPeekStyle = PEEK_STYLE_CUSTOM ;
319
327
break ;
320
328
}
329
+ mClearAllMode = clearAllMode ;
330
+ mClearAllCount = clearAllCount ;
321
331
if (requireUpdate ) {
322
332
List <StatusBarNotification > notif = notificationAdapter .getNotifications ();
323
333
notificationAdapter = new NotificationAdapter ();
@@ -412,7 +422,7 @@ private void inflateView() {
412
422
@ Override
413
423
public void onScrolled (@ NonNull RecyclerView recyclerView , int dx , int dy ) {
414
424
super .onScrolled (recyclerView , dx , dy );
415
- showClearAllButton ();
425
+ if ( mClearAllMode == CLEAR_ALL_MODE_COUNT ) showClearAllButton ();
416
426
}
417
427
});
418
428
addView (view );
@@ -460,7 +470,10 @@ private void clearAllNotifications() {
460
470
private void removeCurrentNotification () {
461
471
if (currentDisplayedNotification != null ) {
462
472
if (mIsSettingsInterface ) {
463
- post (() -> Toast .makeText (appContext , "Remove current notification" , Toast .LENGTH_SHORT ).show ());
473
+ List <StatusBarNotification > newNotif = new ArrayList <>(lastFilteredNotifications );
474
+ newNotif .remove (currentDisplayedNotification );
475
+ updateNotificationShelf (newNotif );
476
+ hideNotificationCard ();
464
477
return ;
465
478
}
466
479
StatusBarNotification sbn = currentDisplayedNotification ;
@@ -515,6 +528,9 @@ public void updateNotificationShelf(List<StatusBarNotification> notificationList
515
528
516
529
int iconMarginEnd = mCurrentPeekStyle .getPeekIconStyle ().getIconSpacing ();
517
530
int newWidth = filteredNotifications .size () <= 4 ? ViewGroup .LayoutParams .WRAP_CONTENT : (4 * getIconSize ()) + (4 * iconMarginEnd );
531
+ if (mClearAllMode == CLEAR_ALL_MODE_NONE ) {
532
+ newWidth = ViewGroup .LayoutParams .MATCH_PARENT ;
533
+ }
518
534
519
535
if (newWidth != lastLayoutWidth ) {
520
536
ViewGroup .LayoutParams layoutParams = notificationShelf .getLayoutParams ();
@@ -523,7 +539,9 @@ public void updateNotificationShelf(List<StatusBarNotification> notificationList
523
539
lastLayoutWidth = newWidth ;
524
540
}
525
541
526
- showOverflow = filteredNotifications .size () > 4 ;
542
+ showOverflow = mClearAllMode == CLEAR_ALL_MODE_COUNT ?
543
+ filteredNotifications .size () > mClearAllCount :
544
+ false ;
527
545
overflowText .setVisibility (showOverflow ? View .VISIBLE : View .GONE );
528
546
clearAllButton .setVisibility (View .GONE );
529
547
}
@@ -769,7 +787,14 @@ private int getIconPadding() {
769
787
public void onBindViewHolder (@ NonNull NotificationViewHolder holder , @ SuppressLint ("RecyclerView" ) int position ) {
770
788
StatusBarNotification notification = notifications .get (position );
771
789
RecyclerView .LayoutParams imageParams = (RecyclerView .LayoutParams ) holder .iconView .getLayoutParams ();
772
- imageParams .setMarginEnd (position != notifications .size () - 1 ? mCurrentPeekStyle .getPeekIconStyle ().getIconSpacing () : 0 );
790
+ int marginEnd = 0 ;
791
+ if (position != notifications .size () - 1 ) {
792
+ marginEnd = mCurrentPeekStyle .getPeekIconStyle ().getIconSpacing ();
793
+ }
794
+ if (getItemCount () > mClearAllCount && mClearAllMode == CLEAR_ALL_MODE_COUNT ) {
795
+ marginEnd = mCurrentPeekStyle .getPeekIconStyle ().getIconSpacing ();
796
+ }
797
+ imageParams .setMarginEnd (marginEnd );
773
798
holder .iconView .setLayoutParams (imageParams );
774
799
Drawable iconDrawable =
775
800
mCurrentPeekStyle .useAppIcons () ?
0 commit comments