From e64178d53042fed534b7b8d0d4d28ab67ca64d3c Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 9 Feb 2019 19:09:46 +0000 Subject: [PATCH] Scroll up on navigating from summary notification / widget --- .../java/eu/faircode/email/ActivityView.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 39c461279c..78a64c1be4 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -347,15 +347,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB } }); - if (getSupportFragmentManager().getFragments().size() == 0 && - !getIntent().hasExtra(Intent.EXTRA_PROCESS_TEXT)) { - FragmentBase fragment = (unified ? new FragmentMessages() : new FragmentFolders()); - fragment.setArguments(new Bundle()); - - FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); - fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("unified"); - fragmentTransaction.commit(); - } + if (getSupportFragmentManager().getFragments().size() == 0 && !getIntent().hasExtra(Intent.EXTRA_PROCESS_TEXT)) + init(); if (savedInstanceState != null) drawerToggle.setDrawerIndicatorEnabled(savedInstanceState.getBoolean("toggle")); @@ -373,6 +366,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB updateShortcuts(); } + private void init() { + FragmentBase fragment = (unified ? new FragmentMessages() : new FragmentFolders()); + fragment.setArguments(new Bundle()); + + FragmentManager fm = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = fm.beginTransaction(); + for (Fragment existing : fm.getFragments()) + fragmentTransaction.remove(existing); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("unified"); + fragmentTransaction.commit(); + } + private Runnable checkIntent = new Runnable() { @Override public void run() { @@ -388,7 +393,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB setIntent(intent); if ("unified".equals(action)) - getSupportFragmentManager().popBackStack("unified", 0); + init(); else if ("error".equals(action)) onDebugInfo();