aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeDisableSwipingBetweenTabsEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/swipe_action_preferences.xml5
6 files changed, 35 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index 330059a9..dea3aaf2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -72,6 +72,7 @@ import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSh
import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeDisableSwipingBetweenTabsEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
@@ -199,6 +200,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private boolean showBottomAppBar;
private boolean mConfirmToExit;
private boolean mLockBottomAppBar;
+ private boolean mDisableSwipingBetweenTabs;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -265,6 +267,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
+ mDisableSwipingBetweenTabs = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false);
if (savedInstanceState != null) {
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
@@ -585,7 +588,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
sectionsPagerAdapter = new SectionsPagerAdapter(fragmentManager, getLifecycle());
viewPager2.setAdapter(sectionsPagerAdapter);
viewPager2.setOffscreenPageLimit(3);
- viewPager2.requestDisallowInterceptTouchEvent(true);
+ viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
if (mAccessToken == null) {
switch (position) {
@@ -963,6 +966,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mLockBottomAppBar = changeLockBottomAppBarEvent.lockBottomAppBar;
}
+ @Subscribe
+ public void onChangeDisableSwipingBetweenTabsEvent(ChangeDisableSwipingBetweenTabsEvent changeDisableSwipingBetweenTabsEvent) {
+ mDisableSwipingBetweenTabs = changeDisableSwipingBetweenTabsEvent.disableSwipingBetweenTabs;
+ viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
+ }
+
@Override
public void onLongPress() {
if (sectionsPagerAdapter != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeDisableSwipingBetweenTabsEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeDisableSwipingBetweenTabsEvent.java
new file mode 100644
index 00000000..371954e8
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeDisableSwipingBetweenTabsEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeDisableSwipingBetweenTabsEvent {
+ public boolean disableSwipingBetweenTabs;
+
+ public ChangeDisableSwipingBetweenTabsEvent(boolean disableSwipingBetweenTabs) {
+ this.disableSwipingBetweenTabs = disableSwipingBetweenTabs;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java
index 80358559..115cd4d3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java
@@ -7,6 +7,7 @@ import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
+import ml.docilealligator.infinityforreddit.Event.ChangeDisableSwipingBetweenTabsEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVibrateWhenActionTriggeredEvent;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
@@ -18,6 +19,7 @@ public class SwipeActionPreferenceFragment extends PreferenceFragmentCompat {
setPreferencesFromResource(R.xml.swipe_action_preferences, rootKey);
SwitchPreference vibrateWhenActionTriggeredSwitch = findPreference(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED);
+ SwitchPreference disableSwipingBetweenTabsSwitch = findPreference(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS);
if (vibrateWhenActionTriggeredSwitch != null) {
vibrateWhenActionTriggeredSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -25,5 +27,12 @@ public class SwipeActionPreferenceFragment extends PreferenceFragmentCompat {
return true;
});
}
+
+ if (disableSwipingBetweenTabsSwitch != null) {
+ disableSwipingBetweenTabsSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeDisableSwipingBetweenTabsEvent((Boolean) newValue));
+ return true;
+ });
+ }
}
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
index 1beff64f..338afe81 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -120,6 +120,7 @@ public class SharedPreferencesUtils {
public static final String VIDEO_DOWNLOAD_LOCATION = "video_download_location";
public static final String SEPARATE_FOLDER_FOR_EACH_SUBREDDIT = "separate_folder_for_each_subreddit";
public static final String VIBRATE_WHEN_ACTION_TRIGGERED = "vibrate_when_action_triggered";
+ public static final String DISABLE_SWIPING_BETWEEN_TABS = "disable_swiping_between_tabs";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
public static final String MAIN_PAGE_TAB_1_TITLE = "_main_page_tab_1_title";
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 882a9dc4..46edd1fd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -480,6 +480,7 @@
<string name="settings_separate_folder_for_each_subreddit">Separate Folder for Each Subreddit</string>
<string name="settings_swipe_action_title">Swipe Action</string>
<string name="settings_vibrate_when_action_triggered_title">Vibrate the phone when the action is triggered</string>
+ <string name="settings_disable_swiping_between_tabs_title">Disable Swiping Between Tabs</string>
<string name="no_link_available">Cannot get the link</string>
diff --git a/app/src/main/res/xml/swipe_action_preferences.xml b/app/src/main/res/xml/swipe_action_preferences.xml
index daba347b..8cf502b8 100644
--- a/app/src/main/res/xml/swipe_action_preferences.xml
+++ b/app/src/main/res/xml/swipe_action_preferences.xml
@@ -6,4 +6,9 @@
app:key="vibrate_when_action_triggered"
app:title="@string/settings_vibrate_when_action_triggered_title" />
+ <SwitchPreference
+ app:defaultValue="false"
+ app:key="disable_swiping_between_tabs"
+ app:title="@string/settings_disable_swiping_between_tabs_title" />
+
</PreferenceScreen> \ No newline at end of file