mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Setting swipe action threshold is available.
This commit is contained in:
parent
878328c01c
commit
428734bdde
@ -0,0 +1,9 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
|
public class ChangeSwipeActionThresholdEvent {
|
||||||
|
public float swipeActionThreshold;
|
||||||
|
|
||||||
|
public ChangeSwipeActionThresholdEvent(float swipeActionThreshold) {
|
||||||
|
this.swipeActionThreshold = swipeActionThreshold;
|
||||||
|
}
|
||||||
|
}
|
@ -81,6 +81,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVote
|
|||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeSwipeActionThresholdEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVibrateWhenActionTriggeredEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVibrateWhenActionTriggeredEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
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() {
|
private void refreshAdapter() {
|
||||||
int previousPosition = -1;
|
int previousPosition = -1;
|
||||||
if (mLinearLayoutManager != null) {
|
if (mLinearLayoutManager != null) {
|
||||||
|
@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Settings;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeDisableSwipingBetweenTabsEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeDisableSwipingBetweenTabsEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeEnableSwipeActionSwitchEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeEnableSwipeActionSwitchEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeSwipeActionThresholdEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVibrateWhenActionTriggeredEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVibrateWhenActionTriggeredEvent;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
@ -22,6 +24,7 @@ public class SwipeActionPreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
SwitchPreference enableSwipeActionSwitch = findPreference(SharedPreferencesUtils.ENABLE_SWIPE_ACTION);
|
SwitchPreference enableSwipeActionSwitch = findPreference(SharedPreferencesUtils.ENABLE_SWIPE_ACTION);
|
||||||
SwitchPreference vibrateWhenActionTriggeredSwitch = findPreference(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED);
|
SwitchPreference vibrateWhenActionTriggeredSwitch = findPreference(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED);
|
||||||
SwitchPreference disableSwipingBetweenTabsSwitch = findPreference(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS);
|
SwitchPreference disableSwipingBetweenTabsSwitch = findPreference(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS);
|
||||||
|
ListPreference swipeActionThresholdListPreference = findPreference(SharedPreferencesUtils.SWIPE_ACTION_THRESHOLD);
|
||||||
|
|
||||||
if (enableSwipeActionSwitch != null) {
|
if (enableSwipeActionSwitch != null) {
|
||||||
enableSwipeActionSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
enableSwipeActionSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
@ -42,5 +45,12 @@ public class SwipeActionPreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (swipeActionThresholdListPreference != null) {
|
||||||
|
swipeActionThresholdListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
EventBus.getDefault().post(new ChangeSwipeActionThresholdEvent(Float.parseFloat((String) newValue)));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -119,6 +119,7 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String VIBRATE_WHEN_ACTION_TRIGGERED = "vibrate_when_action_triggered";
|
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 DISABLE_SWIPING_BETWEEN_TABS = "disable_swiping_between_tabs";
|
||||||
public static final String ENABLE_SWIPE_ACTION = "enable_swipe_action";
|
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 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 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";
|
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_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_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 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_SUBSCRIPTIONS = 0;
|
||||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS = 1;
|
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS = 1;
|
||||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_INBOX = 2;
|
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_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_CHANGE_POST_LAYOUT = 3;
|
||||||
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SEARCH = 4;
|
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_HOME = 0;
|
||||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS = 1;
|
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS = 1;
|
||||||
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX = 2;
|
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX = 2;
|
||||||
|
@ -259,4 +259,15 @@
|
|||||||
<item>Search</item>
|
<item>Search</item>
|
||||||
</string-array>
|
</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>
|
</resources>
|
@ -471,6 +471,7 @@
|
|||||||
<string name="settings_vibrate_when_action_triggered_title">Vibrate the phone when the action is triggered</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="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_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_pull_to_refresh_title">Pull to Refresh</string>
|
||||||
<string name="settings_security_title">Security</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>
|
<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>
|
||||||
|
@ -16,4 +16,12 @@
|
|||||||
app:key="disable_swiping_between_tabs"
|
app:key="disable_swiping_between_tabs"
|
||||||
app:title="@string/settings_disable_swiping_between_tabs_title" />
|
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>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user