mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-04 07:17:12 +01:00
Add an option to disable pull to refresh.
This commit is contained in:
parent
9444599f4b
commit
ef514a85c7
@ -30,6 +30,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|||||||
import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment;
|
import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.InterfacePreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.InterfacePreferenceFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
|
||||||
|
|
||||||
@ -86,6 +87,8 @@ public class SettingsActivity extends BaseActivity implements
|
|||||||
setTitle(R.string.settings_interface_title);
|
setTitle(R.string.settings_interface_title);
|
||||||
} else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof FontPreferenceFragment) {
|
} else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof FontPreferenceFragment) {
|
||||||
setTitle(R.string.settings_font_title);
|
setTitle(R.string.settings_font_title);
|
||||||
|
} else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof GesturesAndButtonsPreferenceFragment) {
|
||||||
|
setTitle(R.string.settings_gestures_and_buttons_title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Fragment;
|
||||||
|
|
||||||
|
public class ChangePullToRefreshEvent {
|
||||||
|
public boolean pullToRefresh;
|
||||||
|
|
||||||
|
public ChangePullToRefreshEvent(boolean pullToRefresh) {
|
||||||
|
this.pullToRefresh = pullToRefresh;
|
||||||
|
}
|
||||||
|
}
|
@ -174,7 +174,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
private boolean isShown = false;
|
private boolean isShown = false;
|
||||||
private boolean savePostFeedScrolledPosition;
|
private boolean savePostFeedScrolledPosition;
|
||||||
private boolean vibrateWhenActionTriggered;
|
private boolean vibrateWhenActionTriggered;
|
||||||
private boolean enableSwipeAction;
|
|
||||||
private PostRecyclerViewAdapter mAdapter;
|
private PostRecyclerViewAdapter mAdapter;
|
||||||
private RecyclerView.SmoothScroller smoothScroller;
|
private RecyclerView.SmoothScroller smoothScroller;
|
||||||
private Window window;
|
private Window window;
|
||||||
@ -345,6 +344,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
|
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
@ -401,7 +401,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
||||||
savePostFeedScrolledPosition = mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false);
|
savePostFeedScrolledPosition = mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false);
|
||||||
vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true);
|
vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true);
|
||||||
enableSwipeAction = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SWIPE_ACTION, false);
|
boolean enableSwipeAction = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SWIPE_ACTION, false);
|
||||||
Locale locale = getResources().getConfiguration().locale;
|
Locale locale = getResources().getConfiguration().locale;
|
||||||
|
|
||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
if (postType == PostDataSource.TYPE_SEARCH) {
|
||||||
@ -1202,6 +1202,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onChangePullToRefreshEvent(ChangePullToRefreshEvent changePullToRefreshEvent) {
|
||||||
|
mSwipeRefreshLayout.setEnabled(changePullToRefreshEvent.pullToRefresh);
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshAdapter() {
|
private void refreshAdapter() {
|
||||||
int previousPosition = -1;
|
int previousPosition = -1;
|
||||||
if (mLinearLayoutManager != null) {
|
if (mLinearLayoutManager != null) {
|
||||||
|
@ -8,6 +8,7 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Fragment.ChangePullToRefreshEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
@ -41,6 +43,7 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
|
|||||||
SwitchPreference lockBottomAppBarSwitch = findPreference(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR);
|
SwitchPreference lockBottomAppBarSwitch = findPreference(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR);
|
||||||
SwitchPreference swipeUpToHideJumpToNextTopLevelCommentButtonSwitch =
|
SwitchPreference swipeUpToHideJumpToNextTopLevelCommentButtonSwitch =
|
||||||
findPreference(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON);
|
findPreference(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON);
|
||||||
|
SwitchPreference pullToRefreshSwitch = findPreference(SharedPreferencesUtils.PULL_TO_REFRESH);
|
||||||
|
|
||||||
if (lockJumpToNextTopLevelCommentButtonSwitch != null && lockBottomAppBarSwitch != null &&
|
if (lockJumpToNextTopLevelCommentButtonSwitch != null && lockBottomAppBarSwitch != null &&
|
||||||
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch != null) {
|
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch != null) {
|
||||||
@ -65,6 +68,16 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
|
|||||||
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true);
|
swipeUpToHideJumpToNextTopLevelCommentButtonSwitch.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pullToRefreshSwitch != null) {
|
||||||
|
pullToRefreshSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
EventBus.getDefault().post(new ChangePullToRefreshEvent((Boolean) newValue));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,6 +122,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 PULL_TO_REFRESH = "pull_to_refresh";
|
||||||
|
|
||||||
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_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";
|
public static final String MAIN_PAGE_TAB_1_TITLE = "_main_page_tab_1_title";
|
||||||
|
@ -482,6 +482,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_pull_to_refresh_title">Pull to Refresh</string>
|
||||||
|
|
||||||
<string name="no_link_available">Cannot get the link</string>
|
<string name="no_link_available">Cannot get the link</string>
|
||||||
|
|
||||||
|
@ -39,6 +39,11 @@
|
|||||||
app:key="swap_tap_and_long_in_comments"
|
app:key="swap_tap_and_long_in_comments"
|
||||||
app:title="@string/settings_swap_tap_and_long_title" />
|
app:title="@string/settings_swap_tap_and_long_title" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:defaultValue="true"
|
||||||
|
app:key="pull_to_refresh"
|
||||||
|
app:title="@string/settings_pull_to_refresh_title" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
app:title="@string/settings_swipe_action_title"
|
app:title="@string/settings_swipe_action_title"
|
||||||
app:fragment="ml.docilealligator.infinityforreddit.Settings.SwipeActionPreferenceFragment" />
|
app:fragment="ml.docilealligator.infinityforreddit.Settings.SwipeActionPreferenceFragment" />
|
||||||
|
Loading…
Reference in New Issue
Block a user