1313
1414import java .lang .annotation .Retention ;
1515import java .lang .annotation .RetentionPolicy ;
16- import java .util .ArrayList ;
16+ import java .util .Collection ;
1717import java .util .List ;
1818import java .util .SortedSet ;
1919import java .util .TreeSet ;
@@ -65,10 +65,16 @@ private NotificationConstants() {
6565 public static final int CLOSE = 11 ;
6666
6767 @ Retention (RetentionPolicy .SOURCE )
68- @ IntDef ({NOTHING , PREVIOUS , NEXT , REWIND , FORWARD , SMART_REWIND_PREVIOUS , SMART_FORWARD_NEXT ,
69- PLAY_PAUSE , PLAY_PAUSE_BUFFERING , REPEAT , SHUFFLE , CLOSE })
68+ @ IntDef ({NOTHING , PREVIOUS , NEXT , REWIND , FORWARD ,
69+ SMART_REWIND_PREVIOUS , SMART_FORWARD_NEXT , PLAY_PAUSE , PLAY_PAUSE_BUFFERING , REPEAT ,
70+ SHUFFLE , CLOSE })
7071 public @interface Action { }
7172
73+ @ Action
74+ public static final int [] ALL_ACTIONS = {NOTHING , PREVIOUS , NEXT , REWIND , FORWARD ,
75+ SMART_REWIND_PREVIOUS , SMART_FORWARD_NEXT , PLAY_PAUSE , PLAY_PAUSE_BUFFERING , REPEAT ,
76+ SHUFFLE , CLOSE };
77+
7278 @ DrawableRes
7379 public static final int [] ACTION_ICONS = {
7480 0 ,
@@ -95,16 +101,6 @@ private NotificationConstants() {
95101 CLOSE ,
96102 };
97103
98- @ Action
99- public static final int [][] SLOT_ALLOWED_ACTIONS = {
100- new int [] {PREVIOUS , REWIND , SMART_REWIND_PREVIOUS },
101- new int [] {REWIND , PLAY_PAUSE , PLAY_PAUSE_BUFFERING },
102- new int [] {NEXT , FORWARD , SMART_FORWARD_NEXT , PLAY_PAUSE , PLAY_PAUSE_BUFFERING },
103- new int [] {NOTHING , PREVIOUS , NEXT , REWIND , FORWARD , SMART_REWIND_PREVIOUS ,
104- SMART_FORWARD_NEXT , REPEAT , SHUFFLE , CLOSE },
105- new int [] {NOTHING , NEXT , FORWARD , SMART_FORWARD_NEXT , REPEAT , SHUFFLE , CLOSE },
106- };
107-
108104 public static final int [] SLOT_PREF_KEYS = {
109105 R .string .notification_slot_0_key ,
110106 R .string .notification_slot_1_key ,
@@ -165,29 +161,26 @@ public static String getActionName(@NonNull final Context context, @Action final
165161 /**
166162 * @param context the context to use
167163 * @param sharedPreferences the shared preferences to query values from
168- * @param slotCount remove indices >= than this value (set to {@code 5} to do nothing, or make
169- * it lower if there are slots with empty actions)
170164 * @return a sorted list of the indices of the slots to use as compact slots
171165 */
172- public static List <Integer > getCompactSlotsFromPreferences (
166+ public static Collection <Integer > getCompactSlotsFromPreferences (
173167 @ NonNull final Context context ,
174- final SharedPreferences sharedPreferences ,
175- final int slotCount ) {
168+ final SharedPreferences sharedPreferences ) {
176169 final SortedSet <Integer > compactSlots = new TreeSet <>();
177170 for (int i = 0 ; i < 3 ; i ++) {
178171 final int compactSlot = sharedPreferences .getInt (
179172 context .getString (SLOT_COMPACT_PREF_KEYS [i ]), Integer .MAX_VALUE );
180173
181174 if (compactSlot == Integer .MAX_VALUE ) {
182175 // settings not yet populated, return default values
183- return new ArrayList <>( SLOT_COMPACT_DEFAULTS ) ;
176+ return SLOT_COMPACT_DEFAULTS ;
184177 }
185178
186- // a negative value (-1) is set when the user does not want a particular compact slot
187- if ( compactSlot >= 0 && compactSlot < slotCount ) {
179+ if ( compactSlot >= 0 ) {
180+ // compact slot is < 0 if there are less than 3 checked checkboxes
188181 compactSlots .add (compactSlot );
189182 }
190183 }
191- return new ArrayList <>( compactSlots ) ;
184+ return compactSlots ;
192185 }
193186}
0 commit comments