Skip to content

Commit

Permalink
Remove NSFW toggle in the navigation drawer to comply with the stupid…
Browse files Browse the repository at this point in the history
… Google Play policy.
  • Loading branch information
Docile-Alligator committed Oct 30, 2024
1 parent d30a471 commit b3bfe2f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
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;
Expand All @@ -65,15 +64,10 @@
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;
Expand Down Expand Up @@ -106,20 +100,26 @@
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;
Expand Down Expand Up @@ -1303,9 +1303,6 @@ public void onAccountSwitchEvent(SwitchAccountEvent event) {
@Subscribe
public void onChangeNSFWEvent(ChangeNSFWEvent changeNSFWEvent) {
sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw);
if (adapter != null) {
adapter.setNSFWEnabled(changeNSFWEvent.nsfw);
}
}

@Subscribe(threadMode = ThreadMode.MAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void closeAccountManagement() {
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,
Expand Down Expand Up @@ -123,10 +123,6 @@ public void setInboxCount(int inboxCount) {
accountSectionRecyclerViewAdapter.setInboxCount(inboxCount);
}

public void setNSFWEnabled(boolean isNSFWEnabled) {
preferenceSectionRecyclerViewAdapter.setNSFWEnabled(isNSFWEnabled);
}

public void setFavoriteSubscribedSubreddits(List<SubscribedSubredditData> favoriteSubscribedSubreddits) {
favoriteSubscribedSubredditsSectionRecyclerViewAdapter.setFavoriteSubscribedSubreddits(favoriteSubscribedSubreddits);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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;
Expand All @@ -22,27 +21,24 @@ 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;
resources = baseActivity.getResources();
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;
}
Expand Down Expand Up @@ -100,30 +96,6 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
}
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;
}
Expand All @@ -144,11 +116,6 @@ public int getItemCount() {
return collapsePreferencesSection ? 1 : PREFERENCES_SECTION_ITEMS + 1;
}

public void setNSFWEnabled(boolean isNSFWEnabled) {
this.isNSFWEnabled = isNSFWEnabled;
notifyItemChanged(3);
}

class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {
ItemNavDrawerMenuGroupTitleBinding binding;

Expand Down

0 comments on commit b3bfe2f

Please sign in to comment.