Customize the number of columns in Post Feed for every post layout.

This commit is contained in:
Alex Ning 2021-02-17 21:44:59 +08:00
parent 9b9a1aa308
commit 52d6691ae7
13 changed files with 323 additions and 195 deletions

View File

@ -319,25 +319,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int windowWidth = displayMetrics.widthPixels;
int nColumns;
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
nColumns = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT, "1"));
} else {
nColumns = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE, "2"));
}
if (nColumns == 1) {
mLinearLayoutManager = new LinearLayoutManager(activity);
mPostRecyclerView.setLayoutManager(mLinearLayoutManager);
} else {
mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mPostRecyclerView.setLayoutManager(mStaggeredGridLayoutManager);
StaggeredGridLayoutManagerItemOffsetDecoration itemDecoration =
new StaggeredGridLayoutManagerItemOffsetDecoration(activity, R.dimen.staggeredLayoutManagerItemOffset);
mPostRecyclerView.addItemDecoration(itemDecoration);
windowWidth /= 2;
}
mGlide = Glide.with(activity);
lazyModeRunnable = new LazyModeRunnable() {
@ -747,6 +728,19 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
});
}
int nColumns = getNColumns(resources);
if (nColumns == 1) {
mLinearLayoutManager = new LinearLayoutManager(activity);
mPostRecyclerView.setLayoutManager(mLinearLayoutManager);
} else {
mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mPostRecyclerView.setLayoutManager(mStaggeredGridLayoutManager);
StaggeredGridLayoutManagerItemOffsetDecoration itemDecoration =
new StaggeredGridLayoutManagerItemOffsetDecoration(activity, R.dimen.staggeredLayoutManagerItemOffset);
mPostRecyclerView.addItemDecoration(itemDecoration);
windowWidth /= 2;
}
mAdapter.setHideReadPostsIndex(hideReadPostsIndex);
if (activity instanceof ActivityToolbarInterface) {
@ -919,6 +913,28 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return rootView;
}
private int getNColumns(Resources resources) {
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
switch (postLayout) {
case SharedPreferencesUtils.POST_LAYOUT_COMPACT:
return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_COMPACT_LAYOUT, "1"));
case SharedPreferencesUtils.POST_LAYOUT_GALLERY:
return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_GALLERY_LAYOUT, "2"));
default:
return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT, "1"));
}
} else {
switch (postLayout) {
case SharedPreferencesUtils.POST_LAYOUT_COMPACT:
return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_COMPACT_LAYOUT, "2"));
case SharedPreferencesUtils.POST_LAYOUT_GALLERY:
return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_GALLERY_LAYOUT, "2"));
default:
return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE, "2"));
}
}
}
private void initializeAndBindPostViewModel(String accessToken) {
if (postType == PostDataSource.TYPE_SEARCH) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
@ -1237,6 +1253,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void changePostLayout(int postLayout) {
this.postLayout = postLayout;
switch (postType) {
case PostDataSource.TYPE_FRONT_PAGE:
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
@ -1255,6 +1272,23 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
break;
}
int nColumns = getNColumns(getResources());
if (nColumns == 1) {
mLinearLayoutManager = new LinearLayoutManager(activity);
mPostRecyclerView.setLayoutManager(mLinearLayoutManager);
mStaggeredGridLayoutManager = null;
if (mPostRecyclerView.getItemDecorationCount() > 0) {
mPostRecyclerView.removeItemDecorationAt(0);
}
} else if (nColumns == 2) {
mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mPostRecyclerView.setLayoutManager(mStaggeredGridLayoutManager);
StaggeredGridLayoutManagerItemOffsetDecoration itemDecoration =
new StaggeredGridLayoutManagerItemOffsetDecoration(activity, R.dimen.staggeredLayoutManagerItemOffset);
mPostRecyclerView.addItemDecoration(itemDecoration);
mLinearLayoutManager = null;
}
if (mAdapter != null) {
mAdapter.setPostLayout(postLayout);
refreshAdapter();

View File

@ -0,0 +1,15 @@
package ml.docilealligator.infinityforreddit.settings;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import ml.docilealligator.infinityforreddit.R;
public class CommentPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.comment_preferences, rootKey);
}
}

View File

@ -35,7 +35,7 @@ public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentComp
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.gestures_and_buttons_preference, rootKey);
setPreferencesFromResource(R.xml.gestures_and_buttons_preferences, rootKey);
((Infinity) activity.getApplication()).getAppComponent().inject(this);
SwitchPreference lockJumpToNextTopLevelCommentButtonSwitch =

View File

@ -4,39 +4,26 @@ package ml.docilealligator.infinityforreddit.settings;
import android.os.Build;
import android.os.Bundle;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeShowAbsoluteNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.events.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.events.ShowDividerInCompactLayoutPreferenceEvent;
import ml.docilealligator.infinityforreddit.events.ShowThumbnailOnTheRightInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.interface_preference, rootKey);
setPreferencesFromResource(R.xml.interface_preferences, rootKey);
Preference immersiveInterfaceEntryPreference = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_ENTRY_KEY);
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
SwitchPreference showThumbnailOnTheRightInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_LEFT_IN_COMPACT_LAYOUT);
SwitchPreference showAbsoluteNumberOfVotes = findPreference(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES);
SwitchPreference longPressToHideToolbarInCompactLayoutSwitch = findPreference(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT);
SwitchPreference postCompactLayoutToolbarHiddenByDefaultSwitch = findPreference(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT);
if (immersiveInterfaceEntryPreference != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
immersiveInterfaceEntryPreference.setVisible(true);
@ -55,47 +42,5 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
return true;
});
}
if (defaultPostLayoutSwitch != null) {
defaultPostLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeDefaultPostLayoutEvent(Integer.parseInt((String) newValue)));
return true;
});
}
if (showDividerInCompactLayout != null) {
showDividerInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue));
return true;
});
}
if (showThumbnailOnTheRightInCompactLayout != null) {
showThumbnailOnTheRightInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ShowThumbnailOnTheRightInCompactLayoutEvent((Boolean) newValue));
return true;
});
}
if (showAbsoluteNumberOfVotes != null) {
showAbsoluteNumberOfVotes.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeShowAbsoluteNumberOfVotesEvent((Boolean) newValue));
return true;
});
}
if (longPressToHideToolbarInCompactLayoutSwitch != null) {
longPressToHideToolbarInCompactLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeLongPressToHideToolbarInCompactLayoutEvent((Boolean) newValue));
return true;
});
}
if (postCompactLayoutToolbarHiddenByDefaultSwitch != null) {
postCompactLayoutToolbarHiddenByDefaultSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeCompactLayoutToolbarHiddenByDefaultEvent((Boolean) newValue));
return true;
});
}
}
}

View File

@ -0,0 +1,75 @@
package ml.docilealligator.infinityforreddit.settings;
import android.os.Bundle;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeLongPressToHideToolbarInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeShowAbsoluteNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.events.ShowDividerInCompactLayoutPreferenceEvent;
import ml.docilealligator.infinityforreddit.events.ShowThumbnailOnTheRightInCompactLayoutEvent;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class PostPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.post_preferences, rootKey);
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
SwitchPreference showThumbnailOnTheRightInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_LEFT_IN_COMPACT_LAYOUT);
SwitchPreference showAbsoluteNumberOfVotes = findPreference(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES);
SwitchPreference longPressToHideToolbarInCompactLayoutSwitch = findPreference(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT);
SwitchPreference postCompactLayoutToolbarHiddenByDefaultSwitch = findPreference(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT);
if (defaultPostLayoutSwitch != null) {
defaultPostLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeDefaultPostLayoutEvent(Integer.parseInt((String) newValue)));
return true;
});
}
if (showDividerInCompactLayout != null) {
showDividerInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue));
return true;
});
}
if (showThumbnailOnTheRightInCompactLayout != null) {
showThumbnailOnTheRightInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ShowThumbnailOnTheRightInCompactLayoutEvent((Boolean) newValue));
return true;
});
}
if (showAbsoluteNumberOfVotes != null) {
showAbsoluteNumberOfVotes.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeShowAbsoluteNumberOfVotesEvent((Boolean) newValue));
return true;
});
}
if (longPressToHideToolbarInCompactLayoutSwitch != null) {
longPressToHideToolbarInCompactLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeLongPressToHideToolbarInCompactLayoutEvent((Boolean) newValue));
return true;
});
}
if (postCompactLayoutToolbarHiddenByDefaultSwitch != null) {
postCompactLayoutToolbarHiddenByDefaultSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeCompactLayoutToolbarHiddenByDefaultEvent((Boolean) newValue));
return true;
});
}
}
}

View File

@ -79,6 +79,10 @@ public class SharedPreferencesUtils {
public static final String SHOW_THUMBNAIL_ON_THE_LEFT_IN_COMPACT_LAYOUT = "show_thumbnail_on_the_left_in_compact_layout";
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT = "number_of_columns_in_post_feed_portrait";
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE = "number_of_columns_in_post_feed_landscape";
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_COMPACT_LAYOUT = "number_of_columns_in_post_feed_portrait_compact_layout";
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_COMPACT_LAYOUT = "number_of_columns_in_post_feed_landscape_compact_layout";
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_GALLERY_LAYOUT = "number_of_columns_in_post_feed_portrait_gallery_layout";
public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_GALLERY_LAYOUT = "number_of_columns_in_post_feed_landscape_gallery_layout";
public static final String SWIPE_RIGHT_TO_GO_BACK = "swipe_to_go_back_from_post_detail";
public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments";
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";

View File

@ -1020,5 +1020,7 @@
<string name="have_trouble_login_title">Having Trouble Login</string>
<string name="have_trouble_login_message">Do you want to try another way to login?</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreference
app:defaultValue="false"
app:key="show_top_level_comments_first"
app:title="@string/settings_show_top_level_comments_first_title" />
<SwitchPreference
app:defaultValue="false"
app:key="show_comment_divider"
app:title="@string/settings_show_comment_divider_title" />
<SwitchPreference
app:defaultValue="false"
app:key="comment_toolbar_hidden"
app:title="@string/settings_comment_toolbar_hidden" />
<SwitchPreference
app:defaultValue="true"
app:key="comment_toolbar_hide_on_click"
app:title="@string/settings_comment_toolbar_hide_on_click" />
<SwitchPreference
app:defaultValue="false"
app:key="fully_collapse_comment"
android:title="@string/settings_fully_collapse_comment_title" />
</PreferenceScreen>

View File

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
app:title="@string/settings_font_title"
app:icon="@drawable/ic_font_size_24dp"
app:fragment="ml.docilealligator.infinityforreddit.settings.FontPreferenceFragment" />
<Preference
app:key="immersive_interface_entry"
app:title="@string/settings_immersive_interface_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.ImmersiveInterfacePreferenceFragment"
app:isPreferenceVisible="false" />
<Preference
app:title="@string/settings_customize_tabs_in_main_page_title"
app:summary="@string/only_for_logged_in_user"
app:fragment="ml.docilealligator.infinityforreddit.settings.CustomizeMainPageTabsFragment" />
<Preference
app:title="@string/settings_customize_bottom_app_bar_title"
app:summary="@string/only_for_logged_in_user"
app:fragment="ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment" />
<SwitchPreference
app:defaultValue="false"
app:key="bottom_app_bar"
app:title="@string/settings_enable_bottom_app_bar_title"
app:summary="@string/settings_enable_bottom_app_bar_summary" />
<Preference
app:title="@string/settings_time_format_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.TimeFormatPreferenceFragment" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_subreddit_description"
app:title="@string/settings_hide_subreddit_description_title" />
<PreferenceCategory
app:title="@string/settings_category_post_and_comment_title" />
<SwitchPreference
app:defaultValue="false"
app:key="vote_buttons_on_the_right"
app:title="@string/settings_vote_buttons_on_the_right_title" />
<SwitchPreference
app:defaultValue="true"
app:key="show_absolute_number_of_votes"
app:title="@string/settings_show_absolute_number_of_votes_title" />
<PreferenceCategory
app:title="@string/settings_category_post_title" />
<ListPreference
app:defaultValue="0"
android:entries="@array/settings_default_post_layout"
app:entryValues="@array/settings_default_post_layout_values"
app:key="default_post_layout"
app:title="@string/settings_default_post_layout"
app:useSimpleSummaryProvider="true" />
<SwitchPreference
app:defaultValue="true"
app:key="show_divider_in_compact_layout"
app:title="@string/settings_show_divider_in_compact_layout" />
<SwitchPreference
app:defaultValue="false"
app:key="show_thumbnail_on_the_left_in_compact_layout"
app:title="@string/settings_show_thumbnail_on_the_left_in_compact_layout" />
<SwitchPreference
app:defaultValue="false"
app:key="long_press_to_hide_toolbar_in_compact_layout"
app:title="@string/settings_long_press_to_hide_toolbar_in_compact_layout_title" />
<SwitchPreference
app:defaultValue="false"
app:key="post_compact_layout_toolbar_hidden_by_default"
app:title="@string/settings_post_compact_layout_toolbar_hidden_by_default_title" />
<Preference
app:title="@string/settings_number_of_columns_in_post_feed_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.NumberOfColumnsInPostFeedPreferenceFragment" />
<PreferenceCategory
app:title="@string/settings_category_comment_title" />
<SwitchPreference
app:defaultValue="false"
app:key="show_top_level_comments_first"
app:title="@string/settings_show_top_level_comments_first_title" />
<SwitchPreference
app:defaultValue="false"
app:key="show_comment_divider"
app:title="@string/settings_show_comment_divider_title" />
<SwitchPreference
app:defaultValue="false"
app:key="comment_toolbar_hidden"
app:title="@string/settings_comment_toolbar_hidden" />
<SwitchPreference
app:defaultValue="true"
app:key="comment_toolbar_hide_on_click"
app:title="@string/settings_comment_toolbar_hide_on_click" />
<SwitchPreference
app:defaultValue="false"
app:key="fully_collapse_comment"
android:title="@string/settings_fully_collapse_comment_title" />
</PreferenceScreen>

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
app:title="@string/settings_font_title"
app:icon="@drawable/ic_font_size_24dp"
app:fragment="ml.docilealligator.infinityforreddit.settings.FontPreferenceFragment" />
<Preference
app:key="immersive_interface_entry"
app:title="@string/settings_immersive_interface_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.ImmersiveInterfacePreferenceFragment"
app:isPreferenceVisible="false" />
<Preference
app:title="@string/settings_customize_tabs_in_main_page_title"
app:summary="@string/only_for_logged_in_user"
app:fragment="ml.docilealligator.infinityforreddit.settings.CustomizeMainPageTabsFragment" />
<Preference
app:title="@string/settings_customize_bottom_app_bar_title"
app:summary="@string/only_for_logged_in_user"
app:fragment="ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment" />
<SwitchPreference
app:defaultValue="false"
app:key="bottom_app_bar"
app:title="@string/settings_enable_bottom_app_bar_title"
app:summary="@string/settings_enable_bottom_app_bar_summary" />
<Preference
app:title="@string/settings_time_format_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.TimeFormatPreferenceFragment" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_subreddit_description"
app:title="@string/settings_hide_subreddit_description_title" />
<Preference
app:title="@string/settings_category_post_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.PostPreferenceFragment" />
<Preference
app:title="@string/settings_category_comment_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.CommentPreferenceFragment" />
<PreferenceCategory
app:title="@string/settings_category_post_and_comment_title" />
<SwitchPreference
app:defaultValue="false"
app:key="vote_buttons_on_the_right"
app:title="@string/settings_vote_buttons_on_the_right_title" />
<SwitchPreference
app:defaultValue="true"
app:key="show_absolute_number_of_votes"
app:title="@string/settings_show_absolute_number_of_votes_title" />
</PreferenceScreen>

View File

@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
android:icon="@drawable/ic_info_preference_24dp"
app:summary="@string/restart_app_see_changes"
app:enabled="false" />
<PreferenceCategory />
<PreferenceCategory
android:title="@string/post_layout_card" />
<ListPreference
app:defaultValue="1"
@ -23,4 +25,43 @@
app:key="number_of_columns_in_post_feed_landscape"
app:title="@string/settings_number_of_columns_in_post_feed_landscape_title"
app:useSimpleSummaryProvider="true" />
<PreferenceCategory
android:title="@string/post_layout_compact" />
<ListPreference
app:defaultValue="1"
app:entries="@array/settings_number_of_columns_in_post_feed"
app:entryValues="@array/settings_number_of_columns_in_post_feed"
app:key="number_of_columns_in_post_feed_portrait_compact_layout"
app:title="@string/settings_number_of_columns_in_post_feed_portrait_title"
app:useSimpleSummaryProvider="true" />
<ListPreference
app:defaultValue="2"
app:entries="@array/settings_number_of_columns_in_post_feed"
app:entryValues="@array/settings_number_of_columns_in_post_feed"
app:key="number_of_columns_in_post_feed_landscape_compact_layout"
app:title="@string/settings_number_of_columns_in_post_feed_landscape_title"
app:useSimpleSummaryProvider="true" />
<PreferenceCategory
android:title="@string/post_layout_gallery" />
<ListPreference
app:defaultValue="2"
app:entries="@array/settings_number_of_columns_in_post_feed"
app:entryValues="@array/settings_number_of_columns_in_post_feed"
app:key="number_of_columns_in_post_feed_portrait_gallery_layout"
app:title="@string/settings_number_of_columns_in_post_feed_portrait_title"
app:useSimpleSummaryProvider="true" />
<ListPreference
app:defaultValue="2"
app:entries="@array/settings_number_of_columns_in_post_feed"
app:entryValues="@array/settings_number_of_columns_in_post_feed"
app:key="number_of_columns_in_post_feed_landscape_gallery_layout"
app:title="@string/settings_number_of_columns_in_post_feed_landscape_title"
app:useSimpleSummaryProvider="true" />
</PreferenceScreen>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ListPreference
app:defaultValue="0"
android:entries="@array/settings_default_post_layout"
app:entryValues="@array/settings_default_post_layout_values"
app:key="default_post_layout"
app:title="@string/settings_default_post_layout"
app:useSimpleSummaryProvider="true" />
<SwitchPreference
app:defaultValue="true"
app:key="show_divider_in_compact_layout"
app:title="@string/settings_show_divider_in_compact_layout" />
<SwitchPreference
app:defaultValue="false"
app:key="show_thumbnail_on_the_left_in_compact_layout"
app:title="@string/settings_show_thumbnail_on_the_left_in_compact_layout" />
<SwitchPreference
app:defaultValue="false"
app:key="long_press_to_hide_toolbar_in_compact_layout"
app:title="@string/settings_long_press_to_hide_toolbar_in_compact_layout_title" />
<SwitchPreference
app:defaultValue="false"
app:key="post_compact_layout_toolbar_hidden_by_default"
app:title="@string/settings_post_compact_layout_toolbar_hidden_by_default_title" />
<Preference
app:title="@string/settings_number_of_columns_in_post_feed_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.NumberOfColumnsInPostFeedPreferenceFragment" />
</PreferenceScreen>