diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-10-30 13:39:17 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-10-30 13:39:17 +0000 |
commit | b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6 (patch) | |
tree | ec349567a5fe305ddcf0f09713c29c71c89dcd8c /app/src/main/java | |
parent | d30a4710588e89045b35ab95672b25e55694b693 (diff) | |
download | infinity-for-reddit-b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6.tar infinity-for-reddit-b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6.tar.gz infinity-for-reddit-b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6.tar.bz2 infinity-for-reddit-b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6.tar.lz infinity-for-reddit-b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6.tar.xz infinity-for-reddit-b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6.tar.zst infinity-for-reddit-b3bfe2f3ca37f036343d6c0e10938b1f5762d4f6.zip |
Remove NSFW toggle in the navigation drawer to comply with the stupid Google Play policy.
Diffstat (limited to '')
3 files changed, 8 insertions, 48 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 0e92206a..5bf73d83 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -52,7 +52,6 @@ import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayoutMediator; import com.google.android.material.textfield.TextInputEditText; -import ml.docilealligator.infinityforreddit.readpost.ReadPostsUtils; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -65,15 +64,10 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Named; -import ml.docilealligator.infinityforreddit.thing.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.post.MarkPostAsReadInterface; -import ml.docilealligator.infinityforreddit.worker.PullNotificationWorker; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RecyclerViewContentScrollingInterface; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.thing.SortType; -import ml.docilealligator.infinityforreddit.thing.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.account.AccountViewModel; import ml.docilealligator.infinityforreddit.adapters.SubredditAutocompleteRecyclerViewAdapter; @@ -106,20 +100,26 @@ import ml.docilealligator.infinityforreddit.fragments.PostFragment; import ml.docilealligator.infinityforreddit.message.ReadMessage; import ml.docilealligator.infinityforreddit.multireddit.MultiReddit; import ml.docilealligator.infinityforreddit.multireddit.MultiRedditViewModel; +import ml.docilealligator.infinityforreddit.post.MarkPostAsReadInterface; import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.post.PostPagingSource; import ml.docilealligator.infinityforreddit.readpost.InsertReadPost; +import ml.docilealligator.infinityforreddit.readpost.ReadPostsUtils; import ml.docilealligator.infinityforreddit.subreddit.ParseSubredditData; import ml.docilealligator.infinityforreddit.subreddit.SubredditData; import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditViewModel; import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData; +import ml.docilealligator.infinityforreddit.thing.FetchSubscribedThing; +import ml.docilealligator.infinityforreddit.thing.SortType; +import ml.docilealligator.infinityforreddit.thing.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.user.FetchUserData; import ml.docilealligator.infinityforreddit.user.UserData; import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; +import ml.docilealligator.infinityforreddit.worker.PullNotificationWorker; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -1303,9 +1303,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Subscribe public void onChangeNSFWEvent(ChangeNSFWEvent changeNSFWEvent) { sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw); - if (adapter != null) { - adapter.setNSFWEnabled(changeNSFWEvent.nsfw); - } } @Subscribe(threadMode = ThreadMode.MAIN) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java index 06adecd3..fcdf046e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/NavigationDrawerRecyclerViewMergedAdapter.java @@ -55,7 +55,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter { postSectionRecyclerViewAdapter = new PostSectionRecyclerViewAdapter(baseActivity, customThemeWrapper, navigationDrawerSharedPreferences, !accountName.equals(Account.ANONYMOUS_ACCOUNT), itemClickListener); preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper, - accountName, nsfwAndSpoilerSharedPreferences, navigationDrawerSharedPreferences, itemClickListener); + navigationDrawerSharedPreferences, itemClickListener); favoriteSubscribedSubredditsSectionRecyclerViewAdapter = new FavoriteSubscribedSubredditsSectionRecyclerViewAdapter( baseActivity, glide, customThemeWrapper, navigationDrawerSharedPreferences, itemClickListener); subscribedSubredditsRecyclerViewAdapter = new SubscribedSubredditsRecyclerViewAdapter(baseActivity, glide, @@ -123,10 +123,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter { accountSectionRecyclerViewAdapter.setInboxCount(inboxCount); } - public void setNSFWEnabled(boolean isNSFWEnabled) { - preferenceSectionRecyclerViewAdapter.setNSFWEnabled(isNSFWEnabled); - } - public void setFavoriteSubscribedSubreddits(List<SubscribedSubredditData> favoriteSubscribedSubreddits) { favoriteSubscribedSubredditsSectionRecyclerViewAdapter.setFavoriteSubscribedSubreddits(favoriteSubscribedSubreddits); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java index e791b35e..5b3d0859 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java @@ -11,7 +11,6 @@ import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.databinding.ItemNavDrawerMenuGroupTitleBinding; @@ -22,19 +21,17 @@ public class PreferenceSectionRecyclerViewAdapter extends RecyclerView.Adapter<R private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1; private static final int VIEW_TYPE_MENU_ITEM = 2; - private static final int PREFERENCES_SECTION_ITEMS = 3; + private static final int PREFERENCES_SECTION_ITEMS = 2; private final BaseActivity baseActivity; private final Resources resources; private final int primaryTextColor; private final int secondaryTextColor; private final int primaryIconColor; - private boolean isNSFWEnabled; private boolean collapsePreferencesSection; private final NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener; public PreferenceSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper, - @NonNull String accountName, SharedPreferences nsfwAndSpoilerSharedPreferences, SharedPreferences navigationDrawerSharedPreferences, NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener) { this.baseActivity = baseActivity; @@ -42,7 +39,6 @@ public class PreferenceSectionRecyclerViewAdapter extends RecyclerView.Adapter<R primaryTextColor = customThemeWrapper.getPrimaryTextColor(); secondaryTextColor = customThemeWrapper.getSecondaryTextColor(); primaryIconColor = customThemeWrapper.getPrimaryIconColor(); - isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false); collapsePreferencesSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_PREFERENCES_SECTION, false); this.itemClickListener = itemClickListener; } @@ -100,30 +96,6 @@ public class PreferenceSectionRecyclerViewAdapter extends RecyclerView.Adapter<R } break; case 2: - setOnClickListener = false; - if (isNSFWEnabled) { - stringId = R.string.disable_nsfw; - drawableId = R.drawable.ic_nsfw_off_day_night_24dp; - } else { - stringId = R.string.enable_nsfw; - drawableId = R.drawable.ic_nsfw_on_day_night_24dp; - } - - holder.itemView.setOnClickListener(view -> { - if (isNSFWEnabled) { - isNSFWEnabled = false; - ((MenuItemViewHolder) holder).binding.textViewItemNavDrawerMenuItem.setText(R.string.enable_nsfw); - ((MenuItemViewHolder) holder).binding.imageViewItemNavDrawerMenuItem.setImageDrawable(ContextCompat.getDrawable(baseActivity, R.drawable.ic_nsfw_on_day_night_24dp)); - itemClickListener.onMenuClick(R.string.disable_nsfw); - } else { - isNSFWEnabled = true; - ((MenuItemViewHolder) holder).binding.textViewItemNavDrawerMenuItem.setText(R.string.disable_nsfw); - ((MenuItemViewHolder) holder).binding.imageViewItemNavDrawerMenuItem.setImageDrawable(ContextCompat.getDrawable(baseActivity, R.drawable.ic_nsfw_off_day_night_24dp)); - itemClickListener.onMenuClick(R.string.enable_nsfw); - } - }); - break; - case 3: stringId = R.string.settings; drawableId = R.drawable.ic_settings_day_night_24dp; } @@ -144,11 +116,6 @@ public class PreferenceSectionRecyclerViewAdapter extends RecyclerView.Adapter<R return collapsePreferencesSection ? 1 : PREFERENCES_SECTION_ITEMS + 1; } - public void setNSFWEnabled(boolean isNSFWEnabled) { - this.isNSFWEnabled = isNSFWEnabled; - notifyItemChanged(3); - } - class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder { ItemNavDrawerMenuGroupTitleBinding binding; |