aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeSwipeActionThresholdEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java3
-rw-r--r--app/src/main/res/values/arrays.xml11
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/swipe_action_preferences.xml8
7 files changed, 46 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeSwipeActionThresholdEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeSwipeActionThresholdEvent.java
new file mode 100644
index 00000000..d040e0fe
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeSwipeActionThresholdEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeSwipeActionThresholdEvent {
+ public float swipeActionThreshold;
+
+ public ChangeSwipeActionThresholdEvent(float swipeActionThreshold) {
+ this.swipeActionThreshold = swipeActionThreshold;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 5918ddb1..fcf7db71 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -81,6 +81,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVote
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeSwipeActionThresholdEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVibrateWhenActionTriggeredEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
@@ -1228,6 +1229,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Subscribe
+ public void onChangeSwipeActionThresholdEvent(ChangeSwipeActionThresholdEvent changeSwipeActionThresholdEvent) {
+ swipeActionThreshold = changeSwipeActionThresholdEvent.swipeActionThreshold;
+ }
+
private void refreshAdapter() {
int previousPosition = -1;
if (mLinearLayoutManager != null) {
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 c9d2908c..78844f06 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/SwipeActionPreferenceFragment.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Settings;
import android.os.Bundle;
+import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
@@ -9,6 +10,7 @@ import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.Event.ChangeDisableSwipingBetweenTabsEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeEnableSwipeActionSwitchEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeSwipeActionThresholdEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVibrateWhenActionTriggeredEvent;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
@@ -22,6 +24,7 @@ public class SwipeActionPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference enableSwipeActionSwitch = findPreference(SharedPreferencesUtils.ENABLE_SWIPE_ACTION);
SwitchPreference vibrateWhenActionTriggeredSwitch = findPreference(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED);
SwitchPreference disableSwipingBetweenTabsSwitch = findPreference(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS);
+ ListPreference swipeActionThresholdListPreference = findPreference(SharedPreferencesUtils.SWIPE_ACTION_THRESHOLD);
if (enableSwipeActionSwitch != null) {
enableSwipeActionSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -42,5 +45,12 @@ public class SwipeActionPreferenceFragment extends PreferenceFragmentCompat {
return true;
});
}
+
+ if (swipeActionThresholdListPreference != null) {
+ swipeActionThresholdListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeSwipeActionThresholdEvent(Float.parseFloat((String) 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 2c48bc67..99f90024 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -119,6 +119,7 @@ public class SharedPreferencesUtils {
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 ENABLE_SWIPE_ACTION = "enable_swipe_action";
+ public static final String SWIPE_ACTION_THRESHOLD = "swipe_action_threshold";
public static final String PULL_TO_REFRESH = "pull_to_refresh";
public static final String REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER = "require_auth_to_account_section";
public static final String LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT = "long_press_to_hide_toolbar_in_compact_layout";
@@ -164,7 +165,6 @@ public class SharedPreferencesUtils {
public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3 = "other_activities_bottom_app_bar_option_3";
public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4 = "other_activities_bottom_app_bar_option_4";
public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB = "other_activities_bottom_app_bar_fab";
-
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS = 0;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS = 1;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_INBOX = 2;
@@ -174,7 +174,6 @@ public class SharedPreferencesUtils {
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE = 2;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT = 3;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SEARCH = 4;
-
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME = 0;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS = 1;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX = 2;
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index f0685277..41eedb8e 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -259,4 +259,15 @@
<item>Search</item>
</string-array>
+ <string-array name="settings_swipe_action_threshold">
+ <item>0.1</item>
+ <item>0.2</item>
+ <item>0.3</item>
+ <item>0.4</item>
+ <item>0.5</item>
+ <item>0.6</item>
+ <item>0.7</item>
+ <item>0.8</item>
+ </string-array>
+
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4c209afb..0e83c1d8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -471,6 +471,7 @@
<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="settings_enable_swipe_action_title">Enable Swipe Action</string>
+ <string name="settings_swipe_action_threshold">Threshold</string>
<string name="settings_pull_to_refresh_title">Pull to Refresh</string>
<string name="settings_security_title">Security</string>
<string name="settings_require_authentication_to_go_to_account_section_in_navigation_drawer_title">Require Authentication to Go to Account Section in Navigation Drawer</string>
diff --git a/app/src/main/res/xml/swipe_action_preferences.xml b/app/src/main/res/xml/swipe_action_preferences.xml
index 423035a7..60a34c1b 100644
--- a/app/src/main/res/xml/swipe_action_preferences.xml
+++ b/app/src/main/res/xml/swipe_action_preferences.xml
@@ -16,4 +16,12 @@
app:key="disable_swiping_between_tabs"
app:title="@string/settings_disable_swiping_between_tabs_title" />
+ <ListPreference
+ app:defaultValue="0.3"
+ app:entries="@array/settings_swipe_action_threshold"
+ app:entryValues="@array/settings_swipe_action_threshold"
+ app:key="swipe_action_threshold"
+ app:title="@string/settings_swipe_action_threshold"
+ app:useSimpleSummaryProvider="true" />
+
</PreferenceScreen> \ No newline at end of file