Allow each notification slot to contain any possible action

This commit is contained in:
Stypox 2023-12-29 14:04:18 +01:00
parent aab6580195
commit 9fb8125655
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
4 changed files with 48 additions and 43 deletions

View file

@ -20,6 +20,7 @@ import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import org.schabi.newpipe.player.notification.NotificationConstants;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
@ -67,8 +68,8 @@ public class NotificationActionsPreference extends Preference {
////////////////////////////////////////////////////////////////////////////
private void setupActions(@NonNull final View view) {
compactSlots = NotificationConstants.getCompactSlotsFromPreferences(getContext(),
getSharedPreferences(), 5);
compactSlots = new ArrayList<>(NotificationConstants.getCompactSlotsFromPreferences(
getContext(), getSharedPreferences()));
notificationSlots = IntStream.range(0, 5)
.mapToObj(i -> new NotificationSlot(getContext(), getSharedPreferences(), i, view,
compactSlots.contains(i), this::onToggleCompactSlot))

View file

@ -130,13 +130,13 @@ class NotificationSlot {
.create();
final View.OnClickListener radioButtonsClickListener = v -> {
selectedAction = NotificationConstants.SLOT_ALLOWED_ACTIONS[i][v.getId()];
selectedAction = NotificationConstants.ALL_ACTIONS[v.getId()];
updateInfo();
alertDialog.dismiss();
};
for (int id = 0; id < NotificationConstants.SLOT_ALLOWED_ACTIONS[i].length; ++id) {
final int action = NotificationConstants.SLOT_ALLOWED_ACTIONS[i][id];
for (int id = 0; id < NotificationConstants.ALL_ACTIONS.length; ++id) {
final int action = NotificationConstants.ALL_ACTIONS[id];
final RadioButton radioButton = ListRadioIconItemBinding.inflate(inflater)
.getRoot();