diff --git a/app/build.gradle b/app/build.gradle index 0d10836c..0ef1b854 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -132,7 +132,7 @@ dependencies { implementation "com.github.Piasy.BigImageViewer:GlideImageViewFactory:$bivVersion" // Markdown - def markwonVersion = "4.6.0" + def markwonVersion = "4.6.2" implementation "io.noties.markwon:core:$markwonVersion" implementation "io.noties.markwon:ext-strikethrough:$markwonVersion" implementation "io.noties.markwon:linkify:$markwonVersion" diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 04b23880..87025e50 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -208,6 +208,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 0) { + if (nAwards > 0 && !mHideTheNumberOfAwards) { ((PostBaseViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE); if (nAwards == 1) { ((PostBaseViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.one_award)); @@ -652,6 +657,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 0) { + if (nAwards > 0 && !mHideTheNumberOfAwards) { ((PostCompactBaseViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE); if (nAwards == 1) { ((PostCompactBaseViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.one_award)); @@ -1138,6 +1149,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { + if (defaultPostLayoutList != null) { + defaultPostLayoutList.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ChangeDefaultPostLayoutEvent(Integer.parseInt((String) newValue))); return true; }); } - if (showDividerInCompactLayout != null) { - showDividerInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> { + if (showDividerInCompactLayoutSwitch != null) { + showDividerInCompactLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue)); return true; }); } - if (showThumbnailOnTheRightInCompactLayout != null) { - showThumbnailOnTheRightInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> { + if (showThumbnailOnTheRightInCompactLayoutSwitch != null) { + showThumbnailOnTheRightInCompactLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ShowThumbnailOnTheRightInCompactLayoutEvent((Boolean) newValue)); return true; }); } - if (showAbsoluteNumberOfVotes != null) { - showAbsoluteNumberOfVotes.setOnPreferenceChangeListener((preference, newValue) -> { + if (showAbsoluteNumberOfVotesSwitch != null) { + showAbsoluteNumberOfVotesSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ChangeShowAbsoluteNumberOfVotesEvent((Boolean) newValue)); return true; }); @@ -71,5 +75,19 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if (hidePostTypeSwitch != null) { + hidePostTypeSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeHidePostTypeEvent((Boolean) newValue)); + return true; + }); + } + + if (hideTheNumberOfAwardsSwitch != null) { + hideTheNumberOfAwardsSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeHideTheNumberOfAwardsEvent((Boolean) newValue)); + return true; + }); + } } } \ No newline at end of file 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 86c562fc..965f8145 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -163,6 +163,8 @@ public class SharedPreferencesUtils { public static final String USER_DEFAULT_SORT_TYPE = "user_default_sort_type"; public static final String USER_DEFAULT_SORT_TIME = "user_default_sort_time"; public static final String CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT = "click_to_show_media_in_gallery_layout"; + public static final String HIDE_POST_TYPE = "hide_post_type"; + public static final String HIDE_THE_NUMBER_OF_AWARDS = "hide_the_number_of_awards"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java index a43b0ffc..de048168 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java @@ -15,6 +15,7 @@ import android.widget.TextView; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.text.HtmlCompat; @@ -49,30 +50,6 @@ public class Utils { .replaceAll("(^|^ *|\\n *)######(?!($|\\s|#))", "$0 ")); return fixSuperScript(regexed); - //Fix superscript - /*int startIndex = regexed.indexOf("^"); - while (startIndex >= 0 && startIndex + 1 < regexed.length()) { - char currentChar = regexed.charAt(startIndex + 1); - if (currentChar == '^') { - regexed.insert(startIndex, '^'); - startIndex = regexed.indexOf("^", startIndex + 1); - } else if (currentChar == ' ' || currentChar == '\n') { - regexed.insert(startIndex + 1, '^'); - startIndex = regexed.indexOf("^", startIndex + 2); - } else if (currentChar == '(') { - int closeBracketIndex = regexed.indexOf(")", startIndex + 2); - if (closeBracketIndex > 0) { - - } - } else { - if (startIndex + 1 == regexed.length() - 1) { - regexed.append('^'); - startIndex++; - } - startIndex++; - } - } - return regexed.toString();*/ } public static String fixSuperScript(StringBuilder regexed) { @@ -309,7 +286,7 @@ public class Utils { @Nullable public static Drawable getTintedDrawable(Context context, int drawableId, int color) { - Drawable drawable = context.getDrawable(drawableId); + Drawable drawable = ContextCompat.getDrawable(context, drawableId); if (drawable != null) { Drawable wrappedDrawable = DrawableCompat.wrap(drawable).mutate(); DrawableCompat.setTint(wrappedDrawable, color); diff --git a/app/src/main/res/layout/item_post_card_2_text.xml b/app/src/main/res/layout/item_post_card_2_text.xml index af8fe398..a133cd52 100644 --- a/app/src/main/res/layout/item_post_card_2_text.xml +++ b/app/src/main/res/layout/item_post_card_2_text.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools" - android:paddingTop="8dp" + android:paddingTop="12dp" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground" diff --git a/app/src/main/res/layout/item_post_card_2_video_autoplay.xml b/app/src/main/res/layout/item_post_card_2_video_autoplay.xml index 9047c717..da85dcea 100644 --- a/app/src/main/res/layout/item_post_card_2_video_autoplay.xml +++ b/app/src/main/res/layout/item_post_card_2_video_autoplay.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools" - android:paddingTop="8dp" + android:paddingTop="16dp" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground" diff --git a/app/src/main/res/layout/item_post_card_2_with_preview.xml b/app/src/main/res/layout/item_post_card_2_with_preview.xml index 4007aae2..07e17a71 100644 --- a/app/src/main/res/layout/item_post_card_2_with_preview.xml +++ b/app/src/main/res/layout/item_post_card_2_with_preview.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools" - android:paddingTop="8dp" + android:paddingTop="16dp" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground" diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 4686b42d..132c8cbc 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -43,12 +43,14 @@ Card Layout + Card Layout 2 Compact Layout Gallery Layout 0 + 3 1 2 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e47b5201..97c0a842 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -385,8 +385,8 @@ Time Format Post Default Post Layout - Show Divider in Compact Layout - Show Thumbnail on the Left in Compact Layout + Show Divider + Show Thumbnail on the Left The Number of Columns in Post Feed Portrait Landscape @@ -491,8 +491,8 @@ Pull to Refresh Security Require Authentication to Go to Account Section in Navigation Drawer - Long Press to Hide Toolbar in Compact Layout - Toolbar in Compact Layout Hidden by Default + Long Press to Hide Toolbar + Hide Toolbar by Default Customize Bottom Navigation Bar Main Page Other Pages @@ -535,6 +535,8 @@ User Default Sort Type User Default Sort Time Click to Show Media in Gallery Layout + Hide Post Type + Hide the Number of Awards Cannot get the link diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml index 6dfbff12..bafe60fd 100644 --- a/app/src/main/res/xml/post_preferences.xml +++ b/app/src/main/res/xml/post_preferences.xml @@ -10,6 +10,23 @@ app:title="@string/settings_default_post_layout" app:useSimpleSummaryProvider="true" /> + + + + + + + + - -