From 967046607af5db6161058e751402c32fdb8709c0 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 15 May 2022 18:35:09 +0200 Subject: [PATCH] Fix issue #52 - Clicking on push notifications open notification timeline with the correct account --- .../java/app/fedilab/android/BaseMainActivity.java | 10 +++++++++- .../main/java/app/fedilab/android/helper/Helper.java | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 7b219c64..b65159f4 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -198,12 +198,20 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt editor.putString(PREF_USER_TOKEN, account.token); editor.commit(); Intent mainActivity = new Intent(this, MainActivity.class); + mainActivity.putExtra(Helper.INTENT_ACTION, Helper.OPEN_NOTIFICATION); startActivity(mainActivity); - intent.removeExtra(Helper.INTENT_ACTION); finish(); } catch (DBException e) { e.printStackTrace(); } + } else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) { + final Handler handler = new Handler(); + handler.postDelayed(() -> { + binding.bottomNavView.getMenu().getItem(3).setChecked(true); + binding.viewPager.setCurrentItem(3); + }, 1000); + intent.removeExtra(Helper.INTENT_ACTION); + } } diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 31038013..8bb6a022 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -242,6 +242,7 @@ public class Helper { public static final int NOTIFICATION_INTENT = 1; + public static final int OPEN_NOTIFICATION = 2; public static final String INTENT_TARGETED_ACCOUNT = "INTENT_TARGETED_ACCOUNT"; public static final String TEMP_MEDIA_DIRECTORY = "TEMP_MEDIA_DIRECTORY";