aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-10-19 20:12:47 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-10-19 20:12:47 +0000
commit2ac4a7f8059fdef8bd151e72f294d453d9c163c2 (patch)
tree27de9a3ce105c3fce7312a01e58b37033915dc8a /app/src/main/java/ml/docilealligator
parent3a52b39a04b3a4d2c3b6180aa2f152ea50911ff7 (diff)
downloadinfinity-for-reddit-2ac4a7f8059fdef8bd151e72f294d453d9c163c2.tar
infinity-for-reddit-2ac4a7f8059fdef8bd151e72f294d453d9c163c2.tar.gz
infinity-for-reddit-2ac4a7f8059fdef8bd151e72f294d453d9c163c2.tar.bz2
infinity-for-reddit-2ac4a7f8059fdef8bd151e72f294d453d9c163c2.tar.lz
infinity-for-reddit-2ac4a7f8059fdef8bd151e72f294d453d9c163c2.tar.xz
infinity-for-reddit-2ac4a7f8059fdef8bd151e72f294d453d9c163c2.tar.zst
infinity-for-reddit-2ac4a7f8059fdef8bd151e72f294d453d9c163c2.zip
Continue adding comment filter.
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java173
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java82
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentFilterUsageOptionsBottomSheetFragment.java58
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java52
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsageViewModel.java40
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/DeleteCommentFilterUsage.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/SaveCommentFilterUsage.java12
10 files changed, 432 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 2bb4f6ec..1cb8956a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -10,6 +10,7 @@ import ml.docilealligator.infinityforreddit.activities.AccountPostsActivity;
import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.CommentFilterPreferenceActivity;
+import ml.docilealligator.infinityforreddit.activities.CommentFilterUsageListingActivity;
import ml.docilealligator.infinityforreddit.activities.CreateMultiRedditActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemePreviewActivity;
@@ -313,6 +314,8 @@ public interface AppComponent {
void inject(CustomizeCommentFilterActivity customizeCommentFilterActivity);
+ void inject(CommentFilterUsageListingActivity commentFilterUsageListingActivity);
+
@Component.Factory
interface Factory {
AppComponent create(@BindsInstance Application application);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java
index 170c5335..71b2a765 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java
@@ -89,7 +89,7 @@ public class CommentFilterPreferenceActivity extends BaseActivity {
public void applyCommentFilterTo(CommentFilter commentFilter) {
Intent intent = new Intent(this, CommentFilterUsageListingActivity.class);
- intent.putExtra(CommentFilterUsageListingActivity.EXTRA_POST_FILTER, commentFilter);
+ intent.putExtra(CommentFilterUsageListingActivity.EXTRA_COMMENT_FILTER, commentFilter);
startActivity(intent);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
index 587addcf..b174e9e8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java
@@ -1,18 +1,183 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
import android.os.Bundle;
+import android.os.Handler;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
-import androidx.appcompat.app.AppCompatActivity;
+import androidx.annotation.NonNull;
+import androidx.lifecycle.ViewModelProvider;
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.textfield.TextInputEditText;
+import com.google.android.material.textfield.TextInputLayout;
+
+import java.util.concurrent.Executor;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.adapters.CommentFilterUsageRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.CommentFilterUsageOptionsBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.NewCommentFilterUsageBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilter;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilterUsage;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilterUsageViewModel;
+import ml.docilealligator.infinityforreddit.commentfilter.DeleteCommentFilterUsage;
+import ml.docilealligator.infinityforreddit.commentfilter.SaveCommentFilterUsage;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.databinding.ActivityCommentFilterUsageListingBinding;
+import ml.docilealligator.infinityforreddit.utils.Utils;
-public class CommentFilterUsageListingActivity extends AppCompatActivity {
+public class CommentFilterUsageListingActivity extends BaseActivity {
- public static final String EXTRA_POST_FILTER = "EPF";
+ public static final String EXTRA_COMMENT_FILTER = "ECF";
+ @Inject
+ @Named("default")
+ SharedPreferences sharedPreferences;
+ @Inject
+ RedditDataRoomDatabase redditDataRoomDatabase;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
+ @Inject
+ Executor executor;
+ private ActivityCommentFilterUsageListingBinding binding;
+ public CommentFilterUsageViewModel commentFilterUsageViewModel;
+ private CommentFilterUsageRecyclerViewAdapter adapter;
+ private CommentFilter commentFilter;
@Override
protected void onCreate(Bundle savedInstanceState) {
+ ((Infinity) getApplication()).getAppComponent().inject(this);
+
+ setImmersiveModeNotApplicable();
+
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_comment_filter_usage_listing);
+ binding = ActivityCommentFilterUsageListingBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
+
+ applyCustomTheme();
+
+ setSupportActionBar(binding.toolbarCommentFilterUsageListingActivity);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ commentFilter = getIntent().getParcelableExtra(EXTRA_COMMENT_FILTER);
+
+ setTitle(commentFilter.name);
+
+ binding.fabCommentFilterUsageListingActivity.setOnClickListener(view -> {
+ NewCommentFilterUsageBottomSheetFragment newCommentFilterUsageBottomSheetFragment = new NewCommentFilterUsageBottomSheetFragment();
+ newCommentFilterUsageBottomSheetFragment.show(getSupportFragmentManager(), newCommentFilterUsageBottomSheetFragment.getTag());
+ });
+
+ adapter = new CommentFilterUsageRecyclerViewAdapter(this, customThemeWrapper, commentFilterUsage -> {
+ CommentFilterUsageOptionsBottomSheetFragment commentFilterUsageOptionsBottomSheetFragment = new CommentFilterUsageOptionsBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putParcelable(CommentFilterUsageOptionsBottomSheetFragment.EXTRA_COMMENT_FILTER_USAGE, commentFilterUsage);
+ commentFilterUsageOptionsBottomSheetFragment.setArguments(bundle);
+ commentFilterUsageOptionsBottomSheetFragment.show(getSupportFragmentManager(), commentFilterUsageOptionsBottomSheetFragment.getTag());
+ });
+ binding.recyclerViewCommentFilterUsageListingActivity.setAdapter(adapter);
+
+ commentFilterUsageViewModel = new ViewModelProvider(this,
+ new CommentFilterUsageViewModel.Factory(redditDataRoomDatabase, commentFilter.name)).get(CommentFilterUsageViewModel.class);
+
+ commentFilterUsageViewModel.getCommentFilterUsageListLiveData().observe(this, commentFilterUsages -> adapter.setCommentFilterUsages(commentFilterUsages));
+ }
+
+ public void newCommentFilterUsage(int type) {
+ switch (type) {
+ case CommentFilterUsage.SUBREDDIT_TYPE:
+ case CommentFilterUsage.USER_TYPE:
+ editAndCommentFilterUsageNameOfUsage(type, null);
+ break;
+ }
+ }
+
+ private void editAndCommentFilterUsageNameOfUsage(int type, String nameOfUsage) {
+ View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_post_or_comment_filter_name_of_usage, null);
+ TextView messageTextView = dialogView.findViewById(R.id.message_text_view_edit_post_or_comment_filter_name_of_usage_dialog);
+ messageTextView.setVisibility(View.GONE);
+ TextInputLayout textInputLayout = dialogView.findViewById(R.id.text_input_layout_edit_post_or_comment_filter_name_of_usage_dialog);
+ TextInputEditText textInputEditText = dialogView.findViewById(R.id.text_input_edit_text_edit_post_or_comment_filter_name_of_usage_dialog);
+ int primaryTextColor = customThemeWrapper.getPrimaryTextColor();
+ textInputLayout.setBoxStrokeColor(primaryTextColor);
+ textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
+ textInputEditText.setTextColor(primaryTextColor);
+ if (nameOfUsage != null) {
+ textInputEditText.setText(nameOfUsage);
+ }
+ textInputEditText.requestFocus();
+ int titleStringId = R.string.subreddit;
+ switch (type) {
+ case CommentFilterUsage.SUBREDDIT_TYPE:
+ textInputEditText.setHint(R.string.settings_tab_subreddit_name);
+ break;
+ case CommentFilterUsage.USER_TYPE:
+ textInputEditText.setHint(R.string.settings_tab_username);
+ titleStringId = R.string.user;
+ break;
+ }
+
+ Utils.showKeyboard(this, new Handler(), textInputEditText);
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(titleStringId)
+ .setView(dialogView)
+ .setPositiveButton(R.string.ok, (editTextDialogInterface, i1)
+ -> {
+ Utils.hideKeyboard(this);
+
+ CommentFilterUsage commentFilterUsage;
+ if (!textInputEditText.getText().toString().equals("")) {
+ commentFilterUsage = new CommentFilterUsage(commentFilter.name, type, textInputEditText.getText().toString());
+ SaveCommentFilterUsage.saveCommentFilterUsage(redditDataRoomDatabase, executor, commentFilterUsage);
+ }
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .setOnDismissListener(editTextDialogInterface -> {
+ Utils.hideKeyboard(this);
+ })
+ .show();
+ }
+
+ public void editCommentFilterUsage(CommentFilterUsage commentFilterUsage) {
+ editAndCommentFilterUsageNameOfUsage(commentFilterUsage.usage, commentFilterUsage.nameOfUsage);
+ }
+
+ public void deleteCommentFilterUsage(CommentFilterUsage commentFilterUsage) {
+ DeleteCommentFilterUsage.deleteCommentFilterUsage(redditDataRoomDatabase, executor, commentFilterUsage);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ protected SharedPreferences getDefaultSharedPreferences() {
+ return sharedPreferences;
+ }
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return customThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutCommentFilterUsageListingActivity, binding.collapsingToolbarLayoutCommentFilterUsageListingActivity, binding.toolbarCommentFilterUsageListingActivity);
+ applyFABTheme(binding.fabCommentFilterUsageListingActivity);
+ binding.getRoot().setBackgroundColor(customThemeWrapper.getBackgroundColor());
}
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
index f92bf933..bb3265fa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
@@ -1,13 +1,11 @@
package ml.docilealligator.infinityforreddit.activities;
-import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.os.Handler;
import android.view.MenuItem;
import android.view.View;
-import android.view.inputmethod.InputMethodManager;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
@@ -127,9 +125,9 @@ public class PostFilterUsageListingActivity extends BaseActivity {
}
private void editAndPostFilterUsageNameOfUsage(int type, String nameOfUsage) {
- View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_post_filter_name_of_usage, null);
- TextInputLayout textInputLayout = dialogView.findViewById(R.id.text_input_layout_edit_post_filter_name_of_usage_dialog);
- TextInputEditText textInputEditText = dialogView.findViewById(R.id.text_input_edit_text_edit_post_filter_name_of_usage_dialog);
+ View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_post_or_comment_filter_name_of_usage, null);
+ TextInputLayout textInputLayout = dialogView.findViewById(R.id.text_input_layout_edit_post_or_comment_filter_name_of_usage_dialog);
+ TextInputEditText textInputEditText = dialogView.findViewById(R.id.text_input_edit_text_edit_post_or_comment_filter_name_of_usage_dialog);
int primaryTextColor = customThemeWrapper.getPrimaryTextColor();
textInputLayout.setBoxStrokeColor(primaryTextColor);
textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java
new file mode 100644
index 00000000..a6f510fd
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentFilterUsageRecyclerViewAdapter.java
@@ -0,0 +1,82 @@
+package ml.docilealligator.infinityforreddit.adapters;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.List;
+
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilterUsage;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+
+public class CommentFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+ private List<CommentFilterUsage> commentFilterUsages;
+ private BaseActivity activity;
+ private CustomThemeWrapper customThemeWrapper;
+ private CommentFilterUsageRecyclerViewAdapter.OnItemClickListener onItemClickListener;
+
+ public interface OnItemClickListener {
+ void onClick(CommentFilterUsage commentFilterUsage);
+ }
+
+ public CommentFilterUsageRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
+ CommentFilterUsageRecyclerViewAdapter.OnItemClickListener onItemClickListener) {
+ this.activity = activity;
+ this.customThemeWrapper = customThemeWrapper;
+ this.onItemClickListener = onItemClickListener;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ return new CommentFilterUsageRecyclerViewAdapter.CommentFilterUsageViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_filter_usage, parent, false));
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ CommentFilterUsage commentFilterUsage = commentFilterUsages.get(position);
+ switch (commentFilterUsage.usage) {
+ case CommentFilterUsage.SUBREDDIT_TYPE:
+ ((CommentFilterUsageRecyclerViewAdapter.CommentFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_subreddit, commentFilterUsage.nameOfUsage));
+ break;
+ case CommentFilterUsage.USER_TYPE:
+ ((CommentFilterUsageRecyclerViewAdapter.CommentFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_user, commentFilterUsage.nameOfUsage));
+ break;
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return commentFilterUsages == null ? 0 : commentFilterUsages.size();
+ }
+
+ public void setCommentFilterUsages(List<CommentFilterUsage> commentFilterUsages) {
+ this.commentFilterUsages = commentFilterUsages;
+ notifyDataSetChanged();
+ }
+
+ private class CommentFilterUsageViewHolder extends RecyclerView.ViewHolder {
+ TextView usageTextView;
+
+ public CommentFilterUsageViewHolder(@NonNull View itemView) {
+ super(itemView);
+ usageTextView = (TextView) itemView;
+
+ usageTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
+
+ if (activity.typeface != null) {
+ usageTextView.setTypeface(activity.typeface);
+ }
+
+ usageTextView.setOnClickListener(view -> {
+ onItemClickListener.onClick(commentFilterUsages.get(getBindingAdapterPosition()));
+ });
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentFilterUsageOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentFilterUsageOptionsBottomSheetFragment.java
new file mode 100644
index 00000000..988dfdad
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CommentFilterUsageOptionsBottomSheetFragment.java
@@ -0,0 +1,58 @@
+package ml.docilealligator.infinityforreddit.bottomsheetfragments;
+
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+
+import ml.docilealligator.infinityforreddit.activities.CommentFilterUsageListingActivity;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilterUsage;
+import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
+import ml.docilealligator.infinityforreddit.databinding.FragmentCommentFilterUsageOptionsBottomSheetBinding;
+import ml.docilealligator.infinityforreddit.utils.Utils;
+
+public class CommentFilterUsageOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
+
+ public static final String EXTRA_COMMENT_FILTER_USAGE = "ECFU";
+
+ private CommentFilterUsageListingActivity activity;
+
+ public CommentFilterUsageOptionsBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ FragmentCommentFilterUsageOptionsBottomSheetBinding binding = FragmentCommentFilterUsageOptionsBottomSheetBinding.inflate(inflater, container, false);
+
+ CommentFilterUsage commentFilterUsage = getArguments().getParcelable(EXTRA_COMMENT_FILTER_USAGE);
+
+ binding.editTextViewCommentFilterUsageOptionsBottomSheetFragment.setOnClickListener(view -> {
+ activity.editCommentFilterUsage(commentFilterUsage);
+ dismiss();
+ });
+
+ binding.deleteTextViewCommentFilterUsageOptionsBottomSheetFragment.setOnClickListener(view -> {
+ activity.deleteCommentFilterUsage(commentFilterUsage);
+ dismiss();
+ });
+
+ if (activity.typeface != null) {
+ Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
+ }
+
+ return binding.getRoot();
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ activity = (CommentFilterUsageListingActivity) context;
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java
new file mode 100644
index 00000000..2ff59d2b
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewCommentFilterUsageBottomSheetFragment.java
@@ -0,0 +1,52 @@
+package ml.docilealligator.infinityforreddit.bottomsheetfragments;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+
+import ml.docilealligator.infinityforreddit.activities.CommentFilterUsageListingActivity;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilterUsage;
+import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
+import ml.docilealligator.infinityforreddit.databinding.FragmentNewCommentFilterUsageBottomSheetBinding;
+import ml.docilealligator.infinityforreddit.utils.Utils;
+
+public class NewCommentFilterUsageBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
+ private CommentFilterUsageListingActivity activity;
+
+ public NewCommentFilterUsageBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ FragmentNewCommentFilterUsageBottomSheetBinding binding = FragmentNewCommentFilterUsageBottomSheetBinding.inflate(inflater, container, false);
+
+ binding.subredditTextViewNewCommentFilterUsageBottomSheetFragment.setOnClickListener(view -> {
+ activity.newCommentFilterUsage(CommentFilterUsage.SUBREDDIT_TYPE);
+ dismiss();
+ });
+
+ binding.userTextViewNewCommentFilterUsageBottomSheetFragment.setOnClickListener(view -> {
+ activity.newCommentFilterUsage(CommentFilterUsage.USER_TYPE);
+ dismiss();
+ });
+
+ if (activity.typeface != null) {
+ Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
+ }
+
+ return binding.getRoot();
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ activity = (CommentFilterUsageListingActivity) context;
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsageViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsageViewModel.java
new file mode 100644
index 00000000..89a03f41
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/CommentFilterUsageViewModel.java
@@ -0,0 +1,40 @@
+package ml.docilealligator.infinityforreddit.commentfilter;
+
+import androidx.annotation.NonNull;
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.ViewModel;
+import androidx.lifecycle.ViewModelProvider;
+
+import java.util.List;
+
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+
+public class CommentFilterUsageViewModel extends ViewModel {
+ private LiveData<List<CommentFilterUsage>> mCommentFilterUsageListLiveData;
+
+ public CommentFilterUsageViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String name) {
+ mCommentFilterUsageListLiveData = redditDataRoomDatabase.commentFilterUsageDao().getAllCommentFilterUsageLiveData(name);
+ }
+
+ public LiveData<List<CommentFilterUsage>> getCommentFilterUsageListLiveData() {
+ return mCommentFilterUsageListLiveData;
+ }
+
+ public static class Factory extends ViewModelProvider.NewInstanceFactory {
+
+ private final RedditDataRoomDatabase mRedditDataRoomDatabase;
+ private final String mName;
+
+ public Factory(RedditDataRoomDatabase redditDataRoomDatabase, String name) {
+ mRedditDataRoomDatabase = redditDataRoomDatabase;
+ mName = name;
+ }
+
+ @NonNull
+ @Override
+ public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
+ //noinspection unchecked
+ return (T) new CommentFilterUsageViewModel(mRedditDataRoomDatabase, mName);
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/DeleteCommentFilterUsage.java b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/DeleteCommentFilterUsage.java
new file mode 100644
index 00000000..69051515
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/DeleteCommentFilterUsage.java
@@ -0,0 +1,12 @@
+package ml.docilealligator.infinityforreddit.commentfilter;
+
+import java.util.concurrent.Executor;
+
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+
+public class DeleteCommentFilterUsage {
+ public static void deleteCommentFilterUsage(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
+ CommentFilterUsage commentFilterUsage) {
+ executor.execute(() -> redditDataRoomDatabase.commentFilterUsageDao().deleteCommentFilterUsage(commentFilterUsage));
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/SaveCommentFilterUsage.java b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/SaveCommentFilterUsage.java
new file mode 100644
index 00000000..8060d9c0
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/commentfilter/SaveCommentFilterUsage.java
@@ -0,0 +1,12 @@
+package ml.docilealligator.infinityforreddit.commentfilter;
+
+import java.util.concurrent.Executor;
+
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+
+public class SaveCommentFilterUsage {
+ public static void saveCommentFilterUsage(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
+ CommentFilterUsage commentFilterUsage) {
+ executor.execute(() -> redditDataRoomDatabase.commentFilterUsageDao().insert(commentFilterUsage));
+ }
+}