mirror of https://github.com/M66B/FairEmail.git
Opening messages by link
This commit is contained in:
parent
03be95278d
commit
be4dd07967
|
@ -155,6 +155,16 @@
|
|||
<action android:name="${applicationId}.REFRESH" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="message" />
|
||||
<data android:host="${applicationId}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
@ -47,6 +48,60 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
|
|||
return;
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
Uri data = (intent == null ? null : intent.getData());
|
||||
if (data != null &&
|
||||
"message".equals(data.getScheme()) &&
|
||||
BuildConfig.APPLICATION_ID.equals(data.getHost())) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable("data", data);
|
||||
|
||||
new SimpleTask<EntityMessage>() {
|
||||
@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);
|
||||
|
|
Loading…
Reference in New Issue