From 187fc532a5584559c4908ea0eb60e14c89c62742 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 12 Sep 2018 12:35:52 +0000 Subject: [PATCH] Scroll up when navigating from new messages notification --- .../java/eu/faircode/email/ActivitySetup.java | 2 +- .../java/eu/faircode/email/ActivityView.java | 17 +++++++++-------- .../eu/faircode/email/FragmentMessages.java | 4 ++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index f122d29e..f9830588 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -98,7 +98,7 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On public void onBackStackChanged() { if (getSupportFragmentManager().getBackStackEntryCount() == 0) { if (hasAccount) - startActivity(new Intent(this, ActivityView.class).putExtra("setup", true)); + startActivity(new Intent(this, ActivityView.class)); finish(); } } diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 2dbe8eb1..ba6ffd26 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -82,7 +82,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB private ListView drawerList; private ActionBarDrawerToggle drawerToggle; - private boolean newIntent = false; + private boolean newMessages = false; private long attachment = -1; private static final int ATTACHMENT_BUFFER_SIZE = 8192; // bytes @@ -357,10 +357,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB @Override protected void onNewIntent(Intent intent) { - if (intent.getBooleanExtra("setup", false)) - intent.getExtras().remove("setup"); - else - newIntent = true; checkIntent(intent); super.onNewIntent(intent); } @@ -378,9 +374,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB iff.addAction(ACTION_STORE_ATTACHMENT); lbm.registerReceiver(receiver, iff); - if (newIntent) { - newIntent = false; - getSupportFragmentManager().popBackStack("unified", 0); + if (newMessages) { + newMessages = false; + FragmentManager fm = getSupportFragmentManager(); + fm.popBackStack("unified", 0); + FragmentMessages fragment = (FragmentMessages) fm.findFragmentById(R.id.content_frame); + fragment.onNewMessages(); } } @@ -439,6 +438,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB intent.setAction(null); setIntent(intent); + newMessages = true; + Bundle args = new Bundle(); args.putLong("time", new Date().getTime()); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 57ac6c83..cd0edb88 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -670,4 +670,8 @@ public class FragmentMessages extends FragmentEx { fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("folders"); fragmentTransaction.commit(); } + + void onNewMessages() { + rvMessage.scrollToPosition(0); + } }