diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java
index 4ab3cc0fa5..fb6df789cf 100644
--- a/app/src/main/java/eu/faircode/email/AdapterMessage.java
+++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java
@@ -5721,6 +5721,17 @@ public class AdapterMessage extends RecyclerView.Adapter.
+
+ Copyright 2018-2023 by Marcel Bokhorst (M66B)
+*/
+
+import static android.app.Activity.RESULT_OK;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+
+public class FragmentDialogEditSubject extends FragmentDialogBase {
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
+ final Context context = getContext();
+ View view = LayoutInflater.from(context).inflate(R.layout.dialog_edit_subject, null);
+ final EditText etSubject = view.findViewById(R.id.etSubject);
+
+ Bundle args = getArguments();
+ etSubject.setText(args.getString("subject"));
+
+ etSubject.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (actionId != EditorInfo.IME_ACTION_DONE)
+ return false;
+ AlertDialog dialog = (AlertDialog) getDialog();
+ if (dialog == null)
+ return false;
+ Button btnOk = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
+ if (btnOk == null)
+ return false;
+ btnOk.performClick();
+ return true;
+ }
+ });
+
+ return new AlertDialog.Builder(context)
+ .setView(view)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ args.putString("subject", etSubject.getText().toString());
+ sendResult(RESULT_OK);
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, null)
+ .create();
+ }
+}
diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index 61349b7d88..f8f579fd4e 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -433,6 +433,7 @@ public class FragmentMessages extends FragmentBase
private static final int REQUEST_QUICK_ACTIONS = 27;
static final int REQUEST_BLOCK_SENDERS = 28;
static final int REQUEST_CALENDAR = 29;
+ static final int REQUEST_EDIT_SUBJECT = 30;
static final String ACTION_STORE_RAW = BuildConfig.APPLICATION_ID + ".STORE_RAW";
static final String ACTION_VERIFYDECRYPT = BuildConfig.APPLICATION_ID + ".VERIFYDECRYPT";
@@ -8558,6 +8559,10 @@ public class FragmentMessages extends FragmentBase
if (resultCode == RESULT_OK)
onInsertCalendar(data.getBundleExtra("args"));
break;
+ case REQUEST_EDIT_SUBJECT:
+ if (resultCode == RESULT_OK)
+ onEditSubject(data.getBundleExtra("args"));
+ break;
}
} catch (Throwable ex) {
Log.e(ex);
@@ -10021,6 +10026,34 @@ public class FragmentMessages extends FragmentBase
}.execute(this, args, "insert:calendar");
}
+ private void onEditSubject(Bundle args) {
+ new SimpleTask() {
+ @Override
+ protected Void onExecute(Context context, Bundle args) throws Throwable {
+ long id = args.getLong("id");
+ String subject = args.getString("subject");
+
+ DB db = DB.getInstance(context);
+
+ EntityMessage message = db.message().getMessage(id);
+ if (message == null)
+ return null;
+
+ if (TextUtils.isEmpty(subject))
+ subject = null;
+
+ EntityOperation.queue(context, message, EntityOperation.SUBJECT, subject);
+
+ return null;
+ }
+
+ @Override
+ protected void onException(Bundle args, Throwable ex) {
+ Log.unexpectedError(getParentFragmentManager(), ex);
+ }
+ }.execute(this, args, "edit:subject");
+ }
+
private void onMoveAskAcross(final ArrayList result) {
boolean across = false;
for (MessageTarget target : result)
diff --git a/app/src/main/res/drawable/twotone_subject_24.xml b/app/src/main/res/drawable/twotone_subject_24.xml
new file mode 100644
index 0000000000..5e469923ed
--- /dev/null
+++ b/app/src/main/res/drawable/twotone_subject_24.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/layout/dialog_edit_subject.xml b/app/src/main/res/layout/dialog_edit_subject.xml
new file mode 100644
index 0000000000..cd59c512ba
--- /dev/null
+++ b/app/src/main/res/layout/dialog_edit_subject.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/popup_message_more.xml b/app/src/main/res/menu/popup_message_more.xml
index 0d22d91497..e52bf6536a 100644
--- a/app/src/main/res/menu/popup_message_more.xml
+++ b/app/src/main/res/menu/popup_message_more.xml
@@ -44,6 +44,11 @@
+
+
- Unsubscribe
Create rule
Not spam
+ Edit subject …
Move to …
Move to …
Move to %1$s …