Added option to permanently delete from notifications

pull/214/head
M66B 10 months ago
parent 334783cd3a
commit eecc43e89e

@ -231,6 +231,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAdjacentPortrait;
private SwitchCompat swAdjacentLandscape;
private SwitchCompat swDeleteConfirmation;
private SwitchCompat swDeleteNotification;
private SwitchCompat swDmarcViewer;
private EditText etKeywords;
private SwitchCompat swTestIab;
@ -291,7 +292,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"webp", "animate_images",
"easy_correct", "paste_plain", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "save_user_flags", "mdn",
"app_chooser", "app_chooser_share", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape",
"delete_confirmation", "global_keywords", "test_iab"
"delete_confirmation", "delete_notification", "global_keywords", "test_iab"
));
private final static String[] RESET_QUESTIONS = new String[]{
@ -472,6 +473,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAdjacentPortrait = view.findViewById(R.id.swAdjacentPortrait);
swAdjacentLandscape = view.findViewById(R.id.swAdjacentLandscape);
swDeleteConfirmation = view.findViewById(R.id.swDeleteConfirmation);
swDeleteNotification = view.findViewById(R.id.swDeleteNotification);
swDmarcViewer = view.findViewById(R.id.swDmarcViewer);
etKeywords = view.findViewById(R.id.etKeywords);
swTestIab = view.findViewById(R.id.swTestIab);
@ -1644,6 +1646,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swDeleteNotification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("delete_notification", checked).apply();
}
});
swDmarcViewer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -2393,6 +2402,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAdjacentPortrait.setChecked(prefs.getBoolean("adjacent_portrait", false));
swAdjacentLandscape.setChecked(prefs.getBoolean("adjacent_landscape", false));
swDeleteConfirmation.setChecked(prefs.getBoolean("delete_confirmation", true));
swDeleteNotification.setChecked(prefs.getBoolean("delete_notification", false));
swDmarcViewer.setChecked(Helper.isComponentEnabled(getContext(), ActivityDMARC.class));
etKeywords.setText(prefs.getString("global_keywords", null));
swTestIab.setChecked(prefs.getBoolean("test_iab", false));

@ -703,8 +703,7 @@ class NotificationHelper {
String sound = prefs.getString("sound", null);
boolean alert_once = prefs.getBoolean("alert_once", true);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
boolean delete_confirmation = prefs.getBoolean("delete_confirmation", true);
boolean delete_notification = prefs.getBoolean("delete_notification", false);
// Get contact info
Map<Long, Address[]> messageFrom = new HashMap<>();
@ -1073,8 +1072,8 @@ class NotificationHelper {
List<NotificationCompat.Action> wactions = new ArrayList<>();
if (notify_trash &&
perform_expunge &&
message.accountProtocol == EntityAccount.TYPE_IMAP) {
!delete_notification &&
message.accountProtocol == EntityAccount.TYPE_IMAP && perform_expunge) {
EntityFolder folder = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
if (folder != null && !folder.id.equals(message.folder)) {
Intent trash = new Intent(context, ServiceUI.class)
@ -1094,7 +1093,7 @@ class NotificationHelper {
wactions.add(actionTrash.build());
}
} else if (notify_trash &&
(!delete_confirmation ||
(delete_notification ||
(message.accountProtocol == EntityAccount.TYPE_POP && message.accountLeaveDeleted) ||
(message.accountProtocol == EntityAccount.TYPE_IMAP && !perform_expunge))) {
Intent delete = new Intent(context, ServiceUI.class)
@ -1104,7 +1103,7 @@ class NotificationHelper {
context, ServiceUI.PI_DELETE, delete, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action.Builder actionDelete = new NotificationCompat.Action.Builder(
R.drawable.twotone_delete_forever_24,
context.getString(R.string.title_advanced_notify_action_delete),
context.getString(R.string.title_delete_permanently),
piDelete)
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_DELETE)
.setShowsUserInterface(false)

@ -2008,6 +2008,31 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDeleteConfirmation" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDeleteNotification"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_delete_notification"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDeleteConfirmationHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvDeleteNotificationHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_deletion_confirmation_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorError"
android:textStyle="bold|italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDeleteNotification" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDmarcViewer"
android:layout_width="0dp"
@ -2016,7 +2041,7 @@
android:text="@string/title_advanced_dmarc_viewer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDeleteConfirmationHint"
app:layout_constraintTop_toBottomOf="@id/tvDeleteNotificationHint"
app:switchPadding="12dp" />
<EditText

@ -963,7 +963,8 @@
<string name="title_advanced_portrait_mode" translatable="false">Portrait mode</string>
<string name="title_advanced_landscape_mode" translatable="false">Landscape mode</string>
<string name="title_advanced_delete_confirmation" translatable="false">Permanent deletion confirmation</string>
<string name="title_advanced_deletion_confirmation_hint" translatable="false">If you turn this off, please do not complain if you accidentally delete messages irreversibly</string>
<string name="title_advanced_delete_notification" translatable="false">Delete permanently from notifications</string>
<string name="title_advanced_deletion_confirmation_hint" translatable="false">If you change this setting, please do not complain if you accidentally deleted messages irreversibly</string>
<string name="title_advanced_dmarc_viewer" translatable="false">DMARC viewer</string>
<string name="title_advanced_global_keywords" translatable="false">Global keywords</string>
<string name="title_advanced_test_iab" translatable="false">Test IAB</string>

Loading…
Cancel
Save