diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-08-25 01:34:50 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-08-25 01:34:50 +0000 |
commit | 087ca72fc75708184fa7154afb69e2907538c66e (patch) | |
tree | f2293702cce7b19f155f9d434ffda054e5cc5021 /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | 462208066adb90187e07194a995c732215b82581 (diff) | |
download | infinity-for-reddit-087ca72fc75708184fa7154afb69e2907538c66e.tar infinity-for-reddit-087ca72fc75708184fa7154afb69e2907538c66e.tar.gz infinity-for-reddit-087ca72fc75708184fa7154afb69e2907538c66e.tar.bz2 infinity-for-reddit-087ca72fc75708184fa7154afb69e2907538c66e.tar.lz infinity-for-reddit-087ca72fc75708184fa7154afb69e2907538c66e.tar.xz infinity-for-reddit-087ca72fc75708184fa7154afb69e2907538c66e.tar.zst infinity-for-reddit-087ca72fc75708184fa7154afb69e2907538c66e.zip |
Add options to change the number of columns in PostFragment portrait and landscape modes. Upgrade compileSdkVersion and targetSdkVersion to 30.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
3 files changed, 24 insertions, 1 deletions
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 997984bc..c481cd05 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -260,7 +260,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator { activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int windowWidth = displayMetrics.widthPixels; - if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && !resources.getBoolean(R.bool.isTablet)) { + 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, "1")); + } + + if (nColumns == 1) { mLinearLayoutManager = new LinearLayoutManager(activity); mPostRecyclerView.setLayoutManager(mLinearLayoutManager); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/NumberOfColumnsInPostFeedPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/NumberOfColumnsInPostFeedPreferenceFragment.java new file mode 100644 index 00000000..04052e07 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/NumberOfColumnsInPostFeedPreferenceFragment.java @@ -0,0 +1,14 @@ +package ml.docilealligator.infinityforreddit.Settings; + +import android.os.Bundle; + +import androidx.preference.PreferenceFragmentCompat; + +import ml.docilealligator.infinityforreddit.R; + +public class NumberOfColumnsInPostFeedPreferenceFragment extends PreferenceFragmentCompat { + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + setPreferencesFromResource(R.xml.number_of_columns_in_post_feed_preferences, rootKey); + } +} 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 617981bc..81222569 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -80,6 +80,8 @@ public class SharedPreferencesUtils { public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout"; public static final String SHOW_DIVIDER_IN_COMPACT_LAYOUT = "show_divider_in_compact_layout"; 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 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"; |