Added reply to list

pull/155/head
M66B 6 years ago
parent c440309c78
commit f381540b79

File diff suppressed because it is too large Load Diff

@ -2882,6 +2882,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
View anchor = bnvActions.findViewById(R.id.action_reply);
PopupMenu popupMenu = new PopupMenu(context, anchor);
popupMenu.inflate(R.menu.menu_reply);
popupMenu.getMenu().findItem(R.id.menu_reply_list).setVisible(data.message.list_post != null);
popupMenu.getMenu().findItem(R.id.menu_reply_receipt).setVisible(data.message.receipt_to != null);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@ -2894,6 +2895,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.menu_reply_to_all:
onMenuReply(data, "reply_all");
return true;
case R.id.menu_reply_list:
onMenuReply(data, "list");
return true;
case R.id.menu_reply_receipt:
onMenuReply(data, "receipt");
return true;

@ -1191,6 +1191,7 @@ class Core {
message.cc = ccs;
message.bcc = helper.getBcc();
message.reply = helper.getReply();
message.list_post = helper.getListPost();
message.subject = helper.getSubject();
message.size = helper.getSize();
message.content = false;

@ -51,7 +51,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 71,
version = 72,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -745,6 +745,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `answer` ADD COLUMN `hide` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(71, 72) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `list_post` TEXT");
}
})
.build();
}

@ -102,6 +102,7 @@ public class EntityMessage implements Serializable {
public Address[] cc;
public Address[] bcc;
public Address[] reply;
public Address[] list_post;
public String headers;
public Boolean raw;
public String subject;

@ -1709,7 +1709,8 @@ public class FragmentCompose extends FragmentBase {
if (answer > 0)
body = EntityAnswer.getAnswerText(db, answer, null) + body;
} else {
if ("reply".equals(action) || "reply_all".equals(action) || "receipt".equals(action)) {
if ("reply".equals(action) || "reply_all".equals(action) ||
"list".equals(action) || "receipt".equals(action)) {
if (ref.to != null && ref.to.length > 0) {
String to = ((InternetAddress) ref.to[0]).getAddress();
int at = to.indexOf('@');
@ -1721,7 +1722,10 @@ public class FragmentCompose extends FragmentBase {
draft.inreplyto = ref.msgid;
draft.thread = ref.thread;
if ("receipt".equals(action) && ref.receipt_to != null) {
if ("list".equals(action) && ref.list_post != null) {
draft.to = ref.list_post;
draft.from = ref.to;
} else if ("receipt".equals(action) && ref.receipt_to != null) {
draft.to = ref.receipt_to;
draft.from = ref.to;
} else {
@ -1778,6 +1782,8 @@ public class FragmentCompose extends FragmentBase {
draft.subject = context.getString(R.string.title_subject_reply, subject);
else
draft.subject = ref.subject;
} else if ("list".equals(action)) {
draft.subject = ref.subject;
} else if ("receipt".equals(action)) {
draft.subject = context.getString(R.string.title_receipt_subject, subject);
@ -1859,7 +1865,7 @@ public class FragmentCompose extends FragmentBase {
Core.updateMessageSize(context, draft.id);
// Write reference text
if (ref != null && ref.content && !"receipt".equals(action)) {
if (ref != null && ref.content && !"list".equals(action) && !"receipt".equals(action)) {
String refBody = String.format("<p>%s %s:</p>\n<blockquote>%s</blockquote>",
Html.escapeHtml(new Date(ref.received).toString()),
Html.escapeHtml(MessageHelper.formatAddresses(ref.from)),

@ -533,26 +533,6 @@ public class MessageHelper {
return result;
}
Address getSender() throws MessagingException {
String sender = imessage.getHeader("Sender", null);
if (sender == null)
return null;
InternetAddress[] address = null;
try {
address = InternetAddress.parse(sender);
} catch (AddressException ex) {
Log.w(ex);
}
if (address == null || address.length == 0)
return null;
fix(address[0]);
return address[0];
}
Address[] getFrom() throws MessagingException {
return fix(imessage.getFrom());
}
@ -577,6 +557,27 @@ public class MessageHelper {
return null;
}
Address[] getListPost() throws MessagingException {
// https://www.ietf.org/rfc/rfc2369.txt
String list = imessage.getHeader("List-Post", null);
if (list == null || "NO".equals(list))
return null;
InternetAddress[] address = null;
try {
address = InternetAddress.parse(list);
} catch (AddressException ex) {
Log.w(ex);
}
if (address == null || address.length == 0)
return null;
fix(address[0]);
return new Address[]{address[0]};
}
private static Address[] fix(Address[] addresses) {
if (addresses != null)
for (int i = 0; i < addresses.length; i++)

@ -8,6 +8,10 @@
android:id="@+id/menu_reply_to_all"
android:title="@string/title_reply_to_all" />
<item
android:id="@+id/menu_reply_list"
android:title="@string/title_reply_list" />
<item
android:id="@+id/menu_reply_receipt"
android:title="@string/title_reply_receipt" />

@ -374,6 +374,7 @@
<string name="title_reply">Reply</string>
<string name="title_reply_to_sender">Sender</string>
<string name="title_reply_to_all">All</string>
<string name="title_reply_list">List</string>
<string name="title_reply_receipt">Read receipt</string>
<string name="title_reply_template">Template</string>
<string name="title_moving">Moving to %1$s</string>

Loading…
Cancel
Save