From be4dd079677f36c84191c3e3194c8e3c2f38eefa Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 11 Apr 2021 13:16:19 +0200 Subject: [PATCH] Opening messages by link --- app/src/github/AndroidManifest.xml | 10 ++++ .../java/eu/faircode/email/ActivityMain.java | 55 +++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/app/src/github/AndroidManifest.xml b/app/src/github/AndroidManifest.xml index 738a171c6e..51dfabcc15 100644 --- a/app/src/github/AndroidManifest.xml +++ b/app/src/github/AndroidManifest.xml @@ -155,6 +155,16 @@ + + + + + + + + + + () { + @Override + protected EntityMessage onExecute(Context context, Bundle args) { + Uri data = args.getParcelable("data"); + String path = data.getPath(); + if (path == null) + return null; + String[] parts = path.split("/"); + if (parts.length < 1) + return null; + long id = Long.parseLong(parts[1]); + + DB db = DB.getInstance(context); + return db.message().getMessage(id); + } + + @Override + protected void onExecuted(Bundle args, EntityMessage message) { + finish(); + + if (message == null) + return; + + Intent thread = new Intent(ActivityMain.this, ActivityView.class); + thread.setAction("thread:" + message.id); + thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + thread.putExtra("account", message.account); + thread.putExtra("folder", message.folder); + thread.putExtra("thread", message.thread); + thread.putExtra("filter_archive", true); + thread.putExtra("pinned", true); + + startActivity(thread); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + // Ignored + } + }.execute(this, args, "message:linked"); + + return; + } + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean eula = prefs.getBoolean("eula", false); boolean sync_on_launch = prefs.getBoolean("sync_on_launch", false);