mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Add options to change the number of columns in PostFragment portrait and landscape modes. Upgrade compileSdkVersion and targetSdkVersion to 30.
This commit is contained in:
parent
462208066a
commit
087ca72fc7
@ -1,11 +1,11 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 30
|
||||
defaultConfig {
|
||||
applicationId "ml.docilealligator.infinityforreddit"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
targetSdkVersion 30
|
||||
versionCode 39
|
||||
versionName "4.0.3"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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";
|
||||
|
@ -228,4 +228,9 @@
|
||||
<item>yyyy.M.d HH:mm</item>
|
||||
<item>yyyy.M.d hh:mm a</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_number_of_columns_in_post_feed">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -387,6 +387,9 @@
|
||||
<string name="settings_default_post_layout">Default Post Layout</string>
|
||||
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
|
||||
<string name="settings_show_thumbnail_on_the_left_in_compact_layout">Show Thumbnail on the Left in Compact Layout</string>
|
||||
<string name="settings_number_of_columns_in_post_feed_title">The Number of Columns in Post Feed</string>
|
||||
<string name="settings_number_of_columns_in_post_feed_portrait_title">Portrait</string>
|
||||
<string name="settings_number_of_columns_in_post_feed_landscape_title">Landscape</string>
|
||||
<string name="settings_swap_tap_and_long_title">Swap Tap and Long Press in Comments</string>
|
||||
<string name="settings_swipe_to_go_back_title">Swipe Right to Go Back</string>
|
||||
<string name="settings_swipe_to_go_back_summary">Does Not Apply to All Pages</string>
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<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"
|
||||
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"
|
||||
app:title="@string/settings_number_of_columns_in_post_feed_landscape_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</PreferenceScreen>
|
@ -62,6 +62,10 @@
|
||||
app:key="show_thumbnail_on_the_left_in_compact_layout"
|
||||
app:title="@string/settings_show_thumbnail_on_the_left_in_compact_layout" />
|
||||
|
||||
<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" />
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?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/settings_tab_info"
|
||||
app:enabled="false" />
|
||||
|
||||
<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"
|
||||
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"
|
||||
app:title="@string/settings_number_of_columns_in_post_feed_landscape_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user