Finish affinity

This commit is contained in:
M66B 2021-02-01 20:06:20 +01:00
parent f9c46946c5
commit a4cb6d8b40
1 changed files with 14 additions and 5 deletions

View File

@ -60,6 +60,12 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
@Override
public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
Intent intent = getIntent();
if (intent != null && isShared(intent.getAction())) {
finishAffinity();
return;
}
Intent parent = getParentActivityIntent();
if (parent != null)
if (shouldUpRecreateTask(parent))
@ -78,11 +84,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
private void handle(Intent intent) {
Bundle args;
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action) ||
Intent.ACTION_SENDTO.equals(action) ||
Intent.ACTION_SEND.equals(action) ||
Intent.ACTION_SEND_MULTIPLE.equals(action)) {
if (isShared(action)) {
args = new Bundle();
args.putString("action", "new");
args.putLong("account", -1);
@ -199,4 +201,11 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("compose");
fragmentTransaction.commit();
}
private static boolean isShared(String action) {
return (Intent.ACTION_VIEW.equals(action) ||
Intent.ACTION_SENDTO.equals(action) ||
Intent.ACTION_SEND.equals(action) ||
Intent.ACTION_SEND_MULTIPLE.equals(action));
}
}