Disable tab swiping by preference in profile and search (#2889)

The "Enable swipe gesture to switch between tabs" preference was ignored
on the tabs on a profile page ("Posts", "With Replies", "Pinned", "Media"),
and search ("Posts", "Accounts", "Hashtags").

Fix this.

While I'm here, replace a string for the preference name in MainActivity.kt
with a constant.

Fixes https://github.com/tuskyapp/Tusky/issues/2874.
This commit is contained in:
Nik Clayton 2022-12-01 19:51:13 +01:00 committed by GitHub
commit 330401c7d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View file

@ -103,6 +103,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
private lateinit var accountFieldAdapter: AccountFieldAdapter
private val preferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
private var followState: FollowState = FollowState.NOT_FOLLOWING
private var blocking: Boolean = false
private var muting: Boolean = false
@ -243,6 +245,9 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
val pageMargin = resources.getDimensionPixelSize(R.dimen.tab_page_margin)
binding.accountFragmentViewPager.setPageTransformer(MarginPageTransformer(pageMargin))
val enableSwipeForTabs = preferences.getBoolean(PrefKeys.ENABLE_SWIPE_FOR_TABS, true)
binding.accountFragmentViewPager.isUserInputEnabled = enableSwipeForTabs
binding.accountTabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabReselected(tab: TabLayout.Tab?) {
tab?.position?.let { position ->