From 0bebca4bf80efba188440de732e25e2f3fb7e52f Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 1 Sep 2020 16:26:01 +0200 Subject: [PATCH] Open underlying message list when opening thread from widget for specific folder --- .../java/eu/faircode/email/ActivityView.java | 22 ++++++++++++++++++- .../java/eu/faircode/email/WidgetUnified.java | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index faa1672453..d637cda56b 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -1036,8 +1036,28 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB intent.putExtra("thread", action.split(":", 2)[1]); onViewThread(intent); - } else if (action.equals("widget")) + } else if (action.equals("widget")) { + long account = intent.getLongExtra("account", -1); + long folder = intent.getLongExtra("folder", -1); + if (account > 0 && folder > 0) { + if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { + getSupportFragmentManager().popBackStack("messages", FragmentManager.POP_BACK_STACK_INCLUSIVE); + + Bundle args = new Bundle(); + //args.putString("type", intent.getStringExtra("type")); + args.putLong("account", account); + args.putLong("folder", folder); + + FragmentMessages fragment = new FragmentMessages(); + fragment.setArguments(args); + + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("messages"); + fragmentTransaction.commit(); + } + } onViewThread(intent); + } } if (intent.hasExtra(Intent.EXTRA_PROCESS_TEXT)) { diff --git a/app/src/main/java/eu/faircode/email/WidgetUnified.java b/app/src/main/java/eu/faircode/email/WidgetUnified.java index c86938c7d6..bed23ce26c 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnified.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnified.java @@ -89,6 +89,8 @@ public class WidgetUnified extends AppWidgetProvider { Intent thread = new Intent(context, ActivityView.class); thread.setAction("widget"); + thread.putExtra("account", account); + thread.putExtra("folder", folder); thread.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(type)); thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent piItem = PendingIntent.getActivity(