String tweaks reported on Transifex (#6942)

This commit is contained in:
ByteHamster 2024-02-25 15:31:59 +01:00 committed by GitHub
parent 9cfbae183c
commit a7068cc24a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 24 deletions

View File

@ -97,43 +97,31 @@ public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
}
}
private void showFullNotificationButtonsDialog() {
final Context context = getActivity();
final List<Integer> preferredButtons = UserPreferences.getFullNotificationButtons();
final String[] allButtonNames = context.getResources().getStringArray(
R.array.full_notification_buttons_options);
final int[] buttonIDs = {
final int[] buttonIds = {
UserPreferences.NOTIFICATION_BUTTON_SKIP,
UserPreferences.NOTIFICATION_BUTTON_NEXT_CHAPTER,
UserPreferences.NOTIFICATION_BUTTON_PLAYBACK_SPEED,
UserPreferences.NOTIFICATION_BUTTON_SLEEP_TIMER,
};
final int exactItems = 2;
final DialogInterface.OnClickListener completeListener = (dialog, which) ->
UserPreferences.setFullNotificationButtons(preferredButtons);
final String title = context.getResources().getString(
R.string.pref_full_notification_buttons_title);
final String title = context.getResources().getString(R.string.pref_full_notification_buttons_title);
showNotificationButtonsDialog(preferredButtons, allButtonNames, buttonIDs, title,
exactItems, completeListener
);
}
private void showNotificationButtonsDialog(List<Integer> preferredButtons,
String[] allButtonNames, int[] buttonIds, String title,
int exactItems, DialogInterface.OnClickListener completeListener) {
boolean[] checked = new boolean[allButtonNames.length]; // booleans default to false in java
final Context context = getActivity();
// Clear buttons that are not part of the setting anymore
for (int i = preferredButtons.size() - 1; i >= 0; i--) {
boolean isValid = false;
for (int j = 0; j < checked.length; j++) {
if (buttonIds[j] == preferredButtons.get(i)) {
isValid = true;
break;
}
}
@ -142,7 +130,7 @@ public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
}
}
for(int i=0; i < checked.length; i++) {
for (int i = 0; i < checked.length; i++) {
if (preferredButtons.contains(buttonIds[i])) {
checked[i] = true;
}
@ -152,7 +140,6 @@ public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
builder.setTitle(title);
builder.setMultiChoiceItems(allButtonNames, checked, (dialog, which, isChecked) -> {
checked[which] = isChecked;
if (isChecked) {
preferredButtons.add(buttonIds[which]);
} else {
@ -168,19 +155,17 @@ public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setOnClickListener(v -> {
if (preferredButtons.size() != exactItems) {
if (preferredButtons.size() != 2) {
ListView selectionView = dialog.getListView();
Snackbar.make(
selectionView,
String.format(context.getResources().getString(
R.string.pref_compact_notification_buttons_dialog_error_exact), exactItems),
context.getResources().getString(R.string.pref_compact_notification_buttons_dialog_error_exact),
Snackbar.LENGTH_SHORT).show();
} else {
completeListener.onClick(dialog, AlertDialog.BUTTON_POSITIVE);
dialog.cancel();
}
}
);
});
}
}

View File

@ -488,9 +488,9 @@
<string name="pref_expandNotify_sum">This usually expands the notification to show playback buttons.</string>
<string name="pref_persistNotify_title">Persistent playback controls</string>
<string name="pref_persistNotify_sum">Keep notification and lockscreen controls when playback is paused</string>
<string name="pref_compact_notification_buttons_dialog_error_exact">You must select exactly %1$d items.</string>
<string name="pref_compact_notification_buttons_dialog_error_exact">You must select exactly two items</string>
<string name="pref_full_notification_buttons_title">Set notification buttons</string>
<string name="pref_full_notification_buttons_sum">Change the playback buttons on the playback notification.</string>
<string name="pref_full_notification_buttons_sum">Change the buttons on the playback notification</string>
<string name="pref_enqueue_location_title">Enqueue location</string>
<string name="pref_enqueue_location_sum">Add episodes to: %1$s</string>
<string name="enqueue_location_back">Back</string>