aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-05-15 00:52:23 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-05-15 00:52:23 +0000
commit49ffafdfd492ea8e6190e36457813f05311b008d (patch)
tree0f2fc53596bc01d93c8ea651682c155976106b0b /app
parentb9a2a1adead1f741d43d79f35cda44330c391580 (diff)
downloadinfinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar
infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.gz
infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.bz2
infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.lz
infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.xz
infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.zst
infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.zip
Hiding post fliar in PostFragment is now available.
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/post_preferences.xml5
8 files changed, 56 insertions, 8 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 8541e228..9cf2874c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -79,16 +79,16 @@ dependencies {
// Reactive stuff for event and async related
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
- implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
+ implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
// HTTP clients
def retrofitVersion = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
- implementation 'com.squareup.okhttp3:okhttp:4.2.2'
+ implementation 'com.squareup.okhttp3:okhttp:4.9.1'
// Dependency injection
- def daggerVersion = "2.30.1"
+ def daggerVersion = "2.34"
implementation "com.google.dagger:dagger:$daggerVersion"
annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
@@ -120,7 +120,7 @@ dependencies {
/**** User Interface (frontend) ****/
//Image loading
- def glideVersion = "4.11.0"
+ def glideVersion = "4.12.0"
implementation "com.github.bumptech.glide:glide:$glideVersion"
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
implementation 'jp.wasabeef:glide-transformations:4.3.0'
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 95be0ca5..4565a71c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -210,6 +210,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mMarkPostsAsReadOnScroll;
private boolean mHideReadPostsAutomatically;
private boolean mHidePostType;
+ private boolean mHidePostFlair;
private boolean mHideTheNumberOfAwards;
private boolean mHideSubredditAndUserPrefix;
private boolean mHideTheNumberOfVotes;
@@ -287,6 +288,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHideReadPostsAutomatically = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false);
mHidePostType = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_TYPE, false);
+ mHidePostFlair = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_FLAIR, false);
mHideTheNumberOfAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
mHideSubredditAndUserPrefix = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
@@ -622,8 +624,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (flair != null && !flair.equals("")) {
- ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair, false);
+ if (mHidePostFlair) {
+ ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.GONE);
+ } else {
+ ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
+ Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair, false);
+ }
}
if (nAwards > 0 && !mHideTheNumberOfAwards) {
@@ -1123,8 +1129,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (flair != null && !flair.equals("")) {
- ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair, false);
+ if (mHidePostFlair) {
+ ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.GONE);
+ } else {
+ ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
+ Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair, false);
+ }
}
if (nAwards > 0 && !mHideTheNumberOfAwards) {
@@ -1801,6 +1811,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mHidePostType = hidePostType;
}
+ public void setHidePostFlair(boolean hidePostFlair) {
+ mHidePostFlair = hidePostFlair;
+ }
+
public void setHideTheNumberOfAwards(boolean hideTheNumberOfAwards) {
mHideTheNumberOfAwards = hideTheNumberOfAwards;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java
new file mode 100644
index 00000000..f3a9a7a4
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeHidePostFlairEvent {
+ public boolean hidePostFlair;
+
+ public ChangeHidePostFlairEvent(boolean hidePostFlair) {
+ this.hidePostFlair = hidePostFlair;
+ }
+}
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 7110e057..19bfaeb5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -85,6 +85,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeDataSavingModeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent;
import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
@@ -1826,6 +1827,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Subscribe
+ public void onChangeHidePostFlairEvent(ChangeHidePostFlairEvent event) {
+ if (mAdapter != null) {
+ mAdapter.setHidePostFlair(event.hidePostFlair);
+ refreshAdapter();
+ }
+ }
+
+ @Subscribe
public void onChangeHideTheNumberOfAwardsEvent(ChangeHideTheNumberOfAwardsEvent event) {
if (mAdapter != null) {
mAdapter.setHideTheNumberOfAwards(event.hideTheNumberOfAwards);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
index c45a2c1a..f3a4f30c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
@@ -12,6 +12,7 @@ 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.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent;
@@ -36,6 +37,7 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference longPressToHideToolbarInCompactLayoutSwitch = findPreference(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT);
SwitchPreference postCompactLayoutToolbarHiddenByDefaultSwitch = findPreference(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT);
SwitchPreference hidePostTypeSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_TYPE);
+ SwitchPreference hidePostFlairSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_FLAIR);
SwitchPreference hideTheNumberOfAwardsSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS);
SwitchPreference hideSubredditAndUserPrefixSwitch = findPreference(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX);
SwitchPreference hideTheNumberOfVotesSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES);
@@ -90,6 +92,13 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat {
});
}
+ if (hidePostFlairSwitch != null) {
+ hidePostFlairSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeHidePostFlairEvent((Boolean) newValue));
+ return true;
+ });
+ }
+
if (hideTheNumberOfAwardsSwitch != null) {
hideTheNumberOfAwardsSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeHideTheNumberOfAwardsEvent((Boolean) newValue));
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 1125d71a..3242c63c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -165,6 +165,7 @@ public class SharedPreferencesUtils {
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_POST_FLAIR = "hide_post_flair";
public static final String HIDE_THE_NUMBER_OF_AWARDS = "hide_the_number_of_awards";
public static final String HIDE_SUBREDDIT_AND_USER_PREFIX = "hide_subreddit_and_user_prefix";
public static final String HIDE_THE_NUMBER_OF_VOTES = "hide_the_number_of_votes";
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c3456e0e..6dd4979f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -541,6 +541,7 @@
<string name="settings_user_default_sort_time_title">User Default Sort Time</string>
<string name="settings_click_to_show_media_in_gallery_layout">Click to Show Media in Gallery Layout</string>
<string name="settings_hide_post_type">Hide Post Type</string>
+ <string name="settings_hide_post_flair">Hide Post Flair</string>
<string name="settings_hide_the_number_of_awards">Hide the Number of Awards</string>
<string name="settings_hide_subreddit_and_user_prefix">Hide Subreddit and User Prefix</string>
<string name="settings_hide_the_number_of_votes">Hide the Number of Votes</string>
diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml
index 7e47f86c..7ea526a5 100644
--- a/app/src/main/res/xml/post_preferences.xml
+++ b/app/src/main/res/xml/post_preferences.xml
@@ -21,6 +21,11 @@
<SwitchPreference
app:defaultValue="false"
+ app:key="hide_post_flair"
+ app:title="@string/settings_hide_post_flair" />
+
+ <SwitchPreference
+ app:defaultValue="false"
app:key="hide_the_number_of_awards"
app:title="@string/settings_hide_the_number_of_awards" />