From 0d93d7c9961aa36fc2d86857a4b345d36351cbe6 Mon Sep 17 00:00:00 2001 From: Andrew Rasch Date: Sun, 26 Sep 2021 20:10:12 -0400 Subject: Enable folding phone support for card view Updated card view to allow for separate column numbers for folded vs unfolded state. Organized strings.xml. --- .../infinityforreddit/fragments/PostFragment.java | 10 +++++++++- .../utils/SharedPreferencesUtils.java | 3 +++ app/src/main/res/values/strings.xml | 7 ++++--- .../number_of_columns_in_post_feed_preferences.xml | 23 ++++++++++++++++++++++ .../number_of_columns_in_post_feed_preferences.xml | 23 ++++++++++++++++++++++ 5 files changed, 62 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index 8098dba8..cd066a1f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -1142,6 +1142,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } private int getNColumns(Resources resources) { + final boolean foldEnabled = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_FOLD_SUPPORT, false); if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { switch (postLayout) { case SharedPreferencesUtils.POST_LAYOUT_CARD_2: @@ -1152,7 +1153,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator { return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_GALLERY_LAYOUT, "2")); default: if (getResources().getBoolean(R.bool.isTablet)) { - return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT, "2")); + if (foldEnabled) { + return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT_UNFOLDED, "2")); + } else { + return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT, "2")); + } } return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_PORTRAIT, "1")); } @@ -1165,6 +1170,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator { case SharedPreferencesUtils.POST_LAYOUT_GALLERY: return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_GALLERY_LAYOUT, "2")); default: + if (getResources().getBoolean(R.bool.isTablet) && foldEnabled) { + return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_UNFOLDED, "2")); + } return Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE, "2")); } } 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 1d5838e1..e1694e47 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -82,6 +82,8 @@ 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_UNFOLDED = "number_of_columns_in_post_feed_portrait_unfolded"; + public static final String NUMBER_OF_COLUMNS_IN_POST_FEED_LANDSCAPE_UNFOLDED = "number_of_columns_in_post_feed_landscape_unfolded"; 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"; @@ -186,6 +188,7 @@ public class SharedPreferencesUtils { public static final String DEFAULT_LINK_POST_LAYOUT_KEY = "default_link_post_layout"; public static final String USE_BOTTOM_TOOLBAR_IN_MEDIA_VIEWER = "use_bottom_toolbar_in_media_viewer"; public static final String LOCK_SCREEN_ANIMATION = "lock_screen_animation"; + public static final String ENABLE_FOLD_SUPPORT = "enable_fold_support"; public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 294a075a..86ac03db 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,6 +89,7 @@ Delete Logs Share RPAN Link Share Post Link + Go to Wiki Error occurred when parsing the JSON response Error Retrieving the token @@ -408,6 +409,8 @@ The Number of Columns in Post Feed Portrait Landscape + Portrait (Unfolded) + Landscape (Unfolded) Swap Tap and Long Press in Comments Swipe Right to Go Back Does Not Apply to All Pages @@ -1043,6 +1046,7 @@ Go to Subreddit Go to User Name + Go To Top Random Random Subreddit Random NSFW Subreddit @@ -1192,7 +1196,4 @@ 12 hours 24 hours - Go To Top - Go to Wiki - diff --git a/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml b/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml index 3114805a..b4a6b1fa 100644 --- a/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml +++ b/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml @@ -5,6 +5,11 @@ app:summary="@string/restart_app_see_changes" app:enabled="false" /> + + @@ -24,6 +29,24 @@ app:title="@string/settings_number_of_columns_in_post_feed_landscape_title" app:useSimpleSummaryProvider="true" /> + + + + diff --git a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml index 82c54e21..fc973f4d 100644 --- a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml +++ b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml @@ -7,6 +7,11 @@ app:summary="@string/restart_app_see_changes" app:enabled="false" /> + + @@ -26,6 +31,24 @@ app:title="@string/settings_number_of_columns_in_post_feed_landscape_title" app:useSimpleSummaryProvider="true" /> + + + + -- cgit v1.2.3 From 8fdbf3761384120debcb0e5cd5404468c6d631ec Mon Sep 17 00:00:00 2001 From: Andrew Rasch Date: Sun, 26 Sep 2021 20:14:44 -0400 Subject: Added strings.xml entry for switchpref. --- app/src/main/res/values/strings.xml | 1 + .../main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml | 2 +- app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 86ac03db..425f0d74 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -603,6 +603,7 @@ App Lock Require authentication before using the app App Lock Timeout + Enable folding phone support Cannot get the link diff --git a/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml b/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml index b4a6b1fa..db9e1e4e 100644 --- a/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml +++ b/app/src/main/res/xml-sw600dp/number_of_columns_in_post_feed_preferences.xml @@ -8,7 +8,7 @@ + app:title="@string/settings_enable_fold_support" /> diff --git a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml index fc973f4d..5785b189 100644 --- a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml +++ b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml @@ -10,7 +10,7 @@ + app:title="@string/settings_enable_fold_support" /> -- cgit v1.2.3