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.
This commit is contained in:
Nik Clayton 2023-08-03 21:49:19 +02:00 committed by GitHub
parent 79b637c97a
commit f5b89f855f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -158,7 +158,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
private lateinit var header: AccountHeaderView private lateinit var header: AccountHeaderView
private var notificationTabPosition = 0
private var onTabSelectedListener: OnTabSelectedListener? = null private var onTabSelectedListener: OnTabSelectedListener? = null
private var unreadAnnouncementsCount = 0 private var unreadAnnouncementsCount = 0
@ -754,8 +753,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
activeTabLayout.addOnTabSelectedListener(it) activeTabLayout.addOnTabSelectedListener(it)
} }
val activeTabPosition = if (selectNotificationTab) notificationTabPosition else 0 supportActionBar?.title = tabs[position].title(this@MainActivity)
supportActionBar?.title = tabs[activeTabPosition].title(this@MainActivity)
binding.mainToolbar.setOnClickListener { binding.mainToolbar.setOnClickListener {
(tabAdapter.getFragment(activeTabLayout.selectedTabPosition) as? ReselectableFragment)?.onReselect() (tabAdapter.getFragment(activeTabLayout.selectedTabPosition) as? ReselectableFragment)?.onReselect()
} }