From f5b89f855fa7358cc6e365bae32f710d77a987a7 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Thu, 3 Aug 2023 21:49:19 +0200 Subject: [PATCH] Show the correct tab title when opening the activity (#3915) The previous code used `notificationTabPosition`, which was never changed, so always 0. This meant that if you e.g., got to `MainActivity` by clicking on a notification, and the notification tab was current, the title would still show "Home". Fix that by using the existing `position` variable which represents the currently selected tab, and ensure the correct title is shown. Fixes #3864. --- app/src/main/java/com/keylesspalace/tusky/MainActivity.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt index 2c6cd1a1..da060aa8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt @@ -158,7 +158,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje private lateinit var header: AccountHeaderView - private var notificationTabPosition = 0 private var onTabSelectedListener: OnTabSelectedListener? = null private var unreadAnnouncementsCount = 0 @@ -754,8 +753,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje activeTabLayout.addOnTabSelectedListener(it) } - val activeTabPosition = if (selectNotificationTab) notificationTabPosition else 0 - supportActionBar?.title = tabs[activeTabPosition].title(this@MainActivity) + supportActionBar?.title = tabs[position].title(this@MainActivity) binding.mainToolbar.setOnClickListener { (tabAdapter.getFragment(activeTabLayout.selectedTabPosition) as? ReselectableFragment)?.onReselect() }