From f52fd355d8dd615310abd5195eba17299b25853a Mon Sep 17 00:00:00 2001 From: Ivan Kupalov Date: Mon, 27 Apr 2020 21:41:43 +0200 Subject: [PATCH] Add preference to disable swipe gesture for switching tabs, close #1718 (#1752) --- app/src/main/java/com/keylesspalace/tusky/MainActivity.kt | 5 +++++ .../java/com/keylesspalace/tusky/PreferencesActivity.kt | 2 +- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/preferences.xml | 6 ++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt index d1da667e..99f7b64f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt @@ -168,6 +168,11 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje val pageMargin = resources.getDimensionPixelSize(R.dimen.tab_page_margin) viewPager.setPageTransformer(MarginPageTransformer(pageMargin)) + + val uswSwipeForTabs = PreferenceManager.getDefaultSharedPreferences(this) + .getBoolean("enableSwipeForTabs", true) + viewPager.isUserInputEnabled = uswSwipeForTabs + tabLayout.addOnTabSelectedListener(object : OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab) { if (tab.position == notificationTabPosition) { diff --git a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.kt b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.kt index 4adfc4e9..290485bf 100644 --- a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.kt @@ -129,7 +129,7 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference } "statusTextSize", "absoluteTimeView", "showBotOverlay", "animateGifAvatars", - "useBlurhash", "showCardsInTimelines", "confirmReblogs" -> { + "useBlurhash", "showCardsInTimelines", "confirmReblogs", "enableSwipeForTabs" -> { restartActivitiesOnExit = true } "language" -> { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bf480226..9a754467 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -541,6 +541,7 @@ Failed to search Show Notifications filter + Enable swipe gesture to switch between tabs Poll diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index b04ccacc..d2102977 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -84,6 +84,12 @@ android:title="@string/pref_title_confirm_reblogs" app:singleLineTitle="false" /> + +