Link to message thread

This commit is contained in:
M66B 2021-04-12 10:30:49 +02:00
parent c2ea061d34
commit 96c160eb62
3 changed files with 15 additions and 6 deletions

View File

@ -66,12 +66,18 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
if (path == null) if (path == null)
return null; return null;
String[] parts = path.split("/"); String[] parts = path.split("/");
if (parts.length < 1) if (parts.length < 3)
return null; return null;
long id = Long.parseLong(parts[1]);
long account = Long.parseLong(parts[1]);
String msgid = parts[2];
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
return db.message().getMessage(id); List<EntityMessage> messages = db.message().getMessagesByMsgId(account, msgid);
if (messages == null || messages.size() == 0)
return null;
return messages.get(0);
} }
@Override @Override

View File

@ -4825,13 +4825,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (!TextUtils.isEmpty(message.subject)) if (!TextUtils.isEmpty(message.subject))
result.put("subject", message.subject); result.put("subject", message.subject);
String link = "message://" + BuildConfig.APPLICATION_ID + "/" + message.id;
Document document = JsoupEx.parse(file); Document document = JsoupEx.parse(file);
Element a = document.createElement("a"); Element a = document.createElement("a");
a.text(context.getString(R.string.app_name)); a.text(context.getString(R.string.app_name));
a.attr("href", link); a.attr("href", message.getLink());
document.body().appendElement("p").appendChild(a); document.body().appendElement("p").appendChild(a);

View File

@ -24,6 +24,7 @@ import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -239,6 +240,10 @@ public class EntityMessage implements Serializable {
return "<" + UUID.randomUUID() + "@" + domain + '>'; return "<" + UUID.randomUUID() + "@" + domain + '>';
} }
String getLink() {
return "message://" + BuildConfig.APPLICATION_ID + "/" + this.account + "/" + Uri.encode(this.msgid);
}
boolean replySelf(List<TupleIdentityEx> identities, long account) { boolean replySelf(List<TupleIdentityEx> identities, long account) {
Address[] senders = (reply == null || reply.length == 0 ? from : reply); Address[] senders = (reply == null || reply.length == 0 ? from : reply);
if (identities != null && senders != null) if (identities != null && senders != null)