aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-12-25 16:26:30 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-12-25 16:26:30 +0000
commitfa55fb369dd4c893f300e75bfadb705a9e82233f (patch)
treebba546bc28100d4ddf5c95a654819c606730d092 /app/src
parent265805038df07da33808f1d539ab8f02d4a84f6a (diff)
downloadinfinity-for-reddit-fa55fb369dd4c893f300e75bfadb705a9e82233f.tar
infinity-for-reddit-fa55fb369dd4c893f300e75bfadb705a9e82233f.tar.gz
infinity-for-reddit-fa55fb369dd4c893f300e75bfadb705a9e82233f.tar.bz2
infinity-for-reddit-fa55fb369dd4c893f300e75bfadb705a9e82233f.tar.lz
infinity-for-reddit-fa55fb369dd4c893f300e75bfadb705a9e82233f.tar.xz
infinity-for-reddit-fa55fb369dd4c893f300e75bfadb705a9e82233f.tar.zst
infinity-for-reddit-fa55fb369dd4c893f300e75bfadb705a9e82233f.zip
Replace Filter settings with Post Filter.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/AndroidManifest.xml7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java90
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java127
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FilterFragmentPostFilterRecyclerViewAdapter.java85
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterOptionsBottomSheetFragment.java68
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterViewModel.java36
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/drawable-night/ic_apply_to_24dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_apply_to_24dp.xml9
-rw-r--r--app/src/main/res/layout/activity_customize_post_filter.xml28
-rw-r--r--app/src/main/res/layout/activity_post_filter_preference.xml53
-rw-r--r--app/src/main/res/layout/fragment_post_filter_options_bottom_sheet.xml70
-rw-r--r--app/src/main/res/layout/fragment_post_history.xml3
-rw-r--r--app/src/main/res/layout/item_filter_fragment_header.xml25
-rw-r--r--app/src/main/res/layout/item_post_filter.xml14
-rw-r--r--app/src/main/res/values-de/strings.xml2
-rw-r--r--app/src/main/res/values-es/strings.xml2
-rw-r--r--app/src/main/res/values-fr/strings.xml2
-rw-r--r--app/src/main/res/values-hi/strings.xml2
-rw-r--r--app/src/main/res/values-hr/strings.xml2
-rw-r--r--app/src/main/res/values-it/strings.xml2
-rw-r--r--app/src/main/res/values-ja/strings.xml2
-rw-r--r--app/src/main/res/values-pt-rBR/strings.xml2
-rw-r--r--app/src/main/res/values-tr-rTR/strings.xml2
-rw-r--r--app/src/main/res/values-zh-rCN/strings.xml2
-rw-r--r--app/src/main/res/values/strings.xml29
-rw-r--r--app/src/main/res/xml/main_preferences.xml4
33 files changed, 622 insertions, 112 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4374f488..d6f42976 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -32,9 +32,14 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="android:label">
- <activity android:name=".activities.CustomizePostFilterActivity"
+ <activity android:name=".activities.PostFilterPreferenceActivity"
+ android:label="@string/post_filter_preference_activity_label"
android:parentActivityName=".activities.SettingsActivity"
+ android:theme="@style/AppTheme.NoActionBar" />
+ <activity
+ android:name=".activities.CustomizePostFilterActivity"
android:label="@string/customize_post_filter_activity_label"
+ android:parentActivityName=".activities.SettingsActivity"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize" />
<activity
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 2f881530..d6c8ccf1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -6,22 +6,23 @@ import dagger.Component;
import ml.docilealligator.infinityforreddit.activities.AccountPostsActivity;
import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
-import ml.docilealligator.infinityforreddit.activities.CustomizePostFilterActivity;
-import ml.docilealligator.infinityforreddit.activities.FullMarkdownActivity;
import ml.docilealligator.infinityforreddit.activities.CreateMultiRedditActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemePreviewActivity;
+import ml.docilealligator.infinityforreddit.activities.CustomizePostFilterActivity;
import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.activities.EditCommentActivity;
import ml.docilealligator.infinityforreddit.activities.EditMultiRedditActivity;
import ml.docilealligator.infinityforreddit.activities.EditPostActivity;
import ml.docilealligator.infinityforreddit.activities.FetchRandomSubredditOrPostActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
+import ml.docilealligator.infinityforreddit.activities.FullMarkdownActivity;
import ml.docilealligator.infinityforreddit.activities.GiveAwardActivity;
import ml.docilealligator.infinityforreddit.activities.InboxActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.LoginActivity;
import ml.docilealligator.infinityforreddit.activities.MainActivity;
+import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
import ml.docilealligator.infinityforreddit.activities.PostImageActivity;
import ml.docilealligator.infinityforreddit.activities.PostLinkActivity;
import ml.docilealligator.infinityforreddit.activities.PostTextActivity;
@@ -233,4 +234,6 @@ public interface AppComponent {
void inject(CustomizePostFilterActivity customizePostFilterActivity);
void inject(PostHistoryFragment postHistoryFragment);
+
+ void inject(PostFilterPreferenceActivity postFilterPreferenceActivity);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
index 5a3d6185..3c2d675d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
@@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.activities;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
@@ -10,9 +9,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -24,7 +20,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.checkbox.MaterialCheckBox;
-import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.switchmaterial.SwitchMaterial;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
@@ -48,6 +43,7 @@ import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class CustomizePostFilterActivity extends BaseActivity {
public static final String EXTRA_POST_FILTER = "EPF";
+ public static final String EXTRA_FROM_SETTINGS = "EFS";
public static final String RETURN_EXTRA_POST_FILTER = "REPF";
private static final String POST_FILTER_STATE = "PFS";
@@ -59,6 +55,10 @@ public class CustomizePostFilterActivity extends BaseActivity {
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_customize_post_filter_activity)
Toolbar toolbar;
+ @BindView(R.id.name_text_input_layout_customize_post_filter_activity)
+ TextInputLayout nameTextInputLayout;
+ @BindView(R.id.name_text_input_edit_text_customize_post_filter_activity)
+ TextInputEditText nameTextInputEditText;
@BindView(R.id.post_type_text_linear_layout_customize_post_filter_activity)
LinearLayout postTypeTextLinearLayout;
@BindView(R.id.post_type_text_text_view_customize_post_filter_activity)
@@ -165,6 +165,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
@Inject
Executor mExecutor;
private PostFilter postFilter;
+ private boolean fromSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -191,6 +192,8 @@ public class CustomizePostFilterActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
+ fromSettings = getIntent().getBooleanExtra(EXTRA_FROM_SETTINGS, false);
+
postTypeTextLinearLayout.setOnClickListener(view -> {
postTypeTextCheckBox.performClick();
});
@@ -235,6 +238,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
}
private void bindView() {
+ nameTextInputEditText.setText(postFilter.name);
postTypeTextCheckBox.setChecked(postFilter.containTextType);
postTypeLinkCheckBox.setChecked(postFilter.containLinkType);
postTypeImageCheckBox.setChecked(postFilter.containImageType);
@@ -270,6 +274,9 @@ public class CustomizePostFilterActivity extends BaseActivity {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
+ nameTextInputLayout.setBoxStrokeColor(primaryTextColor);
+ nameTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
+ nameTextInputEditText.setTextColor(primaryTextColor);
postTypeTextTextView.setTextColor(primaryTextColor);
postTypeLinkTextView.setTextColor(primaryTextColor);
postTypeImageTextView.setTextColor(primaryTextColor);
@@ -319,6 +326,9 @@ public class CustomizePostFilterActivity extends BaseActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.customize_post_filter_activity, menu);
+ if (fromSettings) {
+ menu.findItem(R.id.action_save_customize_post_filter_activity).setVisible(false);
+ }
applyMenuItemTheme(menu);
return true;
}
@@ -329,7 +339,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
finish();
return true;
} else if (item.getItemId() == R.id.action_save_customize_post_filter_activity) {
- PostFilter postFilter = constructPostFilter();
+ constructPostFilter();
Intent returnIntent = new Intent();
returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter);
setResult(Activity.RESULT_OK, returnIntent);
@@ -337,63 +347,25 @@ public class CustomizePostFilterActivity extends BaseActivity {
return true;
} else if (item.getItemId() == R.id.action_save_to_database_customize_post_filter_activity) {
- PostFilter postFilter = constructPostFilter();
-
- View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
- EditText nameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_name_dialog);
- nameEditText.setHint(R.string.post_filter_name_hint);
- nameEditText.setText(postFilter.name);
- nameEditText.requestFocus();
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- if (imm != null) {
- imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ constructPostFilter();
+
+ if (!postFilter.name.equals("")) {
+ Handler handler = new Handler();
+ SavePostFilter.savePostFilter(mRedditDataRoomDatabase, mExecutor, postFilter, () -> handler.post(() -> {
+ Intent returnIntent = new Intent();
+ returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter);
+ setResult(Activity.RESULT_OK, returnIntent);
+ finish();
+ }));
+ } else {
+ Toast.makeText(CustomizePostFilterActivity.this, R.string.post_filter_requires_a_name, Toast.LENGTH_LONG).show();
}
- new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
- .setTitle(R.string.edit_theme_name)
- .setView(dialogView)
- .setPositiveButton(R.string.ok, (dialogInterface, i)
- -> {
- if (imm != null) {
- imm.hideSoftInputFromWindow(nameEditText.getWindowToken(), 0);
- }
- if (!nameEditText.getText().toString().equals("")) {
- postFilter.name = nameEditText.getText().toString();
- Handler handler = new Handler();
- SavePostFilter.savePostFilter(mRedditDataRoomDatabase, mExecutor, postFilter, new SavePostFilter.SavePostFilterListener() {
- @Override
- public void success() {
- handler.post(() -> {
- Intent returnIntent = new Intent();
- returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter);
- setResult(Activity.RESULT_OK, returnIntent);
- finish();
- });
- }
-
- @Override
- public void failed(int errorCode) {
- handler.post(() -> Toast.makeText(CustomizePostFilterActivity.this, R.string.duplicate_post_filter, Toast.LENGTH_LONG).show());
- }
- });
- }
- })
- .setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
- if (imm != null) {
- imm.hideSoftInputFromWindow(nameEditText.getWindowToken(), 0);
- }
- })
- .setOnDismissListener(dialogInterface -> {
- if (imm != null) {
- imm.hideSoftInputFromWindow(nameEditText.getWindowToken(), 0);
- }
- })
- .show();
}
return false;
}
- private PostFilter constructPostFilter() {
- PostFilter postFilter = new PostFilter();
+ private void constructPostFilter() {
+ postFilter.name = nameTextInputEditText.getText().toString();
postFilter.maxVote = maxVoteTextInputEditText.getText() == null || maxVoteTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(maxVoteTextInputEditText.getText().toString());
postFilter.minVote = minVoteTextInputEditText.getText() == null || minVoteTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(minVoteTextInputEditText.getText().toString());
postFilter.maxComments = maxCommentsTextInputEditText.getText() == null || maxCommentsTextInputEditText.getText().toString().equals("") ? -1 : Integer.parseInt(maxCommentsTextInputEditText.getText().toString());
@@ -414,8 +386,6 @@ public class CustomizePostFilterActivity extends BaseActivity {
postFilter.containGalleryType = postTypeGalleryCheckBox.isChecked();
postFilter.onlyNSFW = onlyNSFWSwitch.isChecked();
postFilter.onlySpoiler = onlySpoilerSwitch.isChecked();
-
- return postFilter;
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
new file mode 100644
index 00000000..b6ff5e9d
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
@@ -0,0 +1,127 @@
+package ml.docilealligator.infinityforreddit.activities;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.MenuItem;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.lifecycle.ViewModelProvider;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.adapters.FilterFragmentPostFilterRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostFilterOptionsBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
+import ml.docilealligator.infinityforreddit.postfilter.PostFilterViewModel;
+
+public class PostFilterPreferenceActivity extends BaseActivity {
+
+ @BindView(R.id.coordinator_layout_post_filter_preference_activity)
+ CoordinatorLayout coordinatorLayout;
+ @BindView(R.id.appbar_layout_post_filter_preference_activity)
+ AppBarLayout appBarLayout;
+ @BindView(R.id.toolbar_post_filter_preference_activity)
+ Toolbar toolbar;
+ @BindView(R.id.recycler_view_post_filter_preference_activity)
+ RecyclerView recyclerView;
+ @BindView(R.id.fab_post_filter_preference_activity)
+ FloatingActionButton fab;
+ @Inject
+ @Named("default")
+ SharedPreferences sharedPreferences;
+ @Inject
+ RedditDataRoomDatabase redditDataRoomDatabase;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
+ public PostFilterViewModel postFilterViewModel;
+ private FilterFragmentPostFilterRecyclerViewAdapter adapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ ((Infinity) getApplication()).getAppComponent().inject(this);
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_post_filter_preference);
+
+ ButterKnife.bind(this);
+
+ applyCustomTheme();
+
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ fab.setOnClickListener(view -> {
+ Intent intent = new Intent(PostFilterPreferenceActivity.this, CustomizePostFilterActivity.class);
+ intent.putExtra(CustomizePostFilterActivity.EXTRA_FROM_SETTINGS, true);
+ startActivity(intent);
+ });
+
+ adapter = new FilterFragmentPostFilterRecyclerViewAdapter(postFilter -> {
+ PostFilterOptionsBottomSheetFragment postFilterOptionsBottomSheetFragment = new PostFilterOptionsBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putParcelable(PostFilterOptionsBottomSheetFragment.EXTRA_POST_FILTER, postFilter);
+ postFilterOptionsBottomSheetFragment.setArguments(bundle);
+ postFilterOptionsBottomSheetFragment.show(getSupportFragmentManager(), postFilterOptionsBottomSheetFragment.getTag());
+ });
+
+ recyclerView.setAdapter(adapter);
+
+ postFilterViewModel = new ViewModelProvider(this,
+ new PostFilterViewModel.Factory(redditDataRoomDatabase)).get(PostFilterViewModel.class);
+
+ postFilterViewModel.getPostFilterListLiveData().observe(this, postFilters -> adapter.setPostFilterList(postFilters));
+ }
+
+ public void editPostFilter(PostFilter postFilter) {
+ Intent intent = new Intent(PostFilterPreferenceActivity.this, CustomizePostFilterActivity.class);
+ intent.putExtra(CustomizePostFilterActivity.EXTRA_POST_FILTER, postFilter);
+ intent.putExtra(CustomizePostFilterActivity.EXTRA_FROM_SETTINGS, true);
+ startActivity(intent);
+ }
+
+ public void applyPostFilterTo(PostFilter postFilter) {
+
+ }
+
+ public void deletePostFilter(PostFilter postFilter) {
+
+ }
+
+ @Override
+ protected SharedPreferences getDefaultSharedPreferences() {
+ return sharedPreferences;
+ }
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return customThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ return true;
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
index df889ed7..c8e19cb3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
@@ -22,12 +22,12 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
-import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
-import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
-import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.settings.AboutPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment;
import ml.docilealligator.infinityforreddit.settings.CustomizeMainPageTabsFragment;
@@ -85,13 +85,16 @@ public class SettingsActivity extends BaseActivity implements
getSupportFragmentManager().addOnBackStackChangedListener(() -> {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
setTitle(R.string.settings_activity_label);
- } else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof AboutPreferenceFragment) {
+ return;
+ }
+ Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity);
+ if (fragment instanceof AboutPreferenceFragment) {
setTitle(R.string.settings_about_master_title);
- } else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof InterfacePreferenceFragment) {
+ } else if (fragment instanceof InterfacePreferenceFragment) {
setTitle(R.string.settings_interface_title);
- } else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof FontPreferenceFragment) {
+ } else if (fragment instanceof FontPreferenceFragment) {
setTitle(R.string.settings_font_title);
- } else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof GesturesAndButtonsPreferenceFragment) {
+ } else if (fragment instanceof GesturesAndButtonsPreferenceFragment) {
setTitle(R.string.settings_gestures_and_buttons_title);
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FilterFragmentPostFilterRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FilterFragmentPostFilterRecyclerViewAdapter.java
new file mode 100644
index 00000000..a7cc4981
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FilterFragmentPostFilterRecyclerViewAdapter.java
@@ -0,0 +1,85 @@
+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.postfilter.PostFilter;
+
+public class FilterFragmentPostFilterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+
+ private static final int VIEW_TYPE_HEADER = 1;
+ private static final int VIEW_TYPE_POST_FILTER = 2;
+
+ private final OnItemClickListener onItemClickListener;
+ private List<PostFilter> postFilterList;
+
+ public interface OnItemClickListener {
+ void onItemClick(PostFilter postFilter);
+ }
+
+ public FilterFragmentPostFilterRecyclerViewAdapter(OnItemClickListener onItemClickListener) {
+ this.onItemClickListener = onItemClickListener;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ if (position == 0) {
+ return VIEW_TYPE_HEADER;
+ }
+ return VIEW_TYPE_POST_FILTER;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ if (viewType == VIEW_TYPE_HEADER) {
+ return new HeaderViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_filter_fragment_header, parent, false));
+ } else {
+ return new PostFilterViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_filter, parent, false));
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ if (holder instanceof PostFilterViewHolder) {
+ ((PostFilterViewHolder) holder).textView.setText(postFilterList.get(position - 1).name);
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return postFilterList == null ? 1 : 1 + postFilterList.size();
+ }
+
+ public void setPostFilterList(List<PostFilter> postFilterList) {
+ this.postFilterList = postFilterList;
+ notifyDataSetChanged();
+ }
+
+ private class PostFilterViewHolder extends RecyclerView.ViewHolder {
+ TextView textView;
+
+ public PostFilterViewHolder(@NonNull View itemView) {
+ super(itemView);
+ textView = (TextView) itemView;
+ itemView.setOnClickListener(view -> {
+ onItemClickListener.onItemClick(postFilterList.get(getAdapterPosition() - 1));
+ });
+ }
+ }
+
+ private static class HeaderViewHolder extends RecyclerView.ViewHolder {
+
+ public HeaderViewHolder(@NonNull View itemView) {
+ super(itemView);
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterOptionsBottomSheetFragment.java
new file mode 100644
index 00000000..bf1aff0b
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterOptionsBottomSheetFragment.java
@@ -0,0 +1,68 @@
+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 android.widget.TextView;
+
+import androidx.annotation.NonNull;
+
+import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
+import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
+
+public class PostFilterOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+
+ @BindView(R.id.edit_text_view_post_filter_options_bottom_sheet_fragment)
+ TextView editTextView;
+ @BindView(R.id.apply_to_text_view_post_filter_options_bottom_sheet_fragment)
+ TextView applyToTextView;
+ @BindView(R.id.delete_text_view_post_filter_options_bottom_sheet_fragment)
+ TextView deleteTextView;
+ public static final String EXTRA_POST_FILTER = "EPF";
+ private PostFilterPreferenceActivity activity;
+
+ public PostFilterOptionsBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ View rootView = inflater.inflate(R.layout.fragment_post_filter_options_bottom_sheet, container, false);
+
+ ButterKnife.bind(this, rootView);
+
+ PostFilter postFilter = getArguments().getParcelable(EXTRA_POST_FILTER);
+
+ editTextView.setOnClickListener(view -> {
+ activity.editPostFilter(postFilter);
+ dismiss();
+ });
+
+ applyToTextView.setOnClickListener(view -> {
+ activity.applyPostFilterTo(postFilter);
+ dismiss();
+ });
+
+ deleteTextView.setOnClickListener(view -> {
+ activity.deletePostFilter(postFilter);
+ dismiss();
+ });
+
+ return rootView;
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ activity = (PostFilterPreferenceActivity) context;
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java
index b23db7a1..67ae558d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilter.java
@@ -168,6 +168,7 @@ public class PostFilter implements Parcelable {
}
protected PostFilter(Parcel in) {
+ name = in.readString();
maxVote = in.readInt();
minVote = in.readInt();
maxComments = in.readInt();
@@ -209,6 +210,7 @@ public class PostFilter implements Parcelable {
@Override
public void writeToParcel(Parcel parcel, int i) {
+ parcel.writeString(name);
parcel.writeInt(maxVote);
parcel.writeInt(minVote);
parcel.writeInt(maxComments);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java
index baddaa8f..0e08e44a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java
@@ -2,10 +2,13 @@ package ml.docilealligator.infinityforreddit.postfilter;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
+import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
+import java.util.List;
+
@Dao
public interface PostFilterDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
@@ -14,9 +17,12 @@ public interface PostFilterDao {
@Query("DELETE FROM post_filter")
void deleteAllPostFilters();
+ @Delete
+ void deletePostFilter(PostFilter postFilter);
+
@Query("SELECT * FROM post_filter WHERE name = :name LIMIT 1")
PostFilter getPostFilter(String name);
@Query("SELECT * FROM post_filter")
- LiveData<PostFilter> getAllPostFiltersLiveData();
+ LiveData<List<PostFilter>> getAllPostFiltersLiveData();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterViewModel.java
new file mode 100644
index 00000000..48acd7f7
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterViewModel.java
@@ -0,0 +1,36 @@
+package ml.docilealligator.infinityforreddit.postfilter;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.ViewModel;
+import androidx.lifecycle.ViewModelProvider;
+
+import java.util.List;
+
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+
+public class PostFilterViewModel extends ViewModel {
+ private LiveData<List<PostFilter>> mPostFilterListLiveData;
+
+ public PostFilterViewModel(RedditDataRoomDatabase redditDataRoomDatabase) {
+ mPostFilterListLiveData = redditDataRoomDatabase.postFilterDao().getAllPostFiltersLiveData();
+ }
+
+ public LiveData<List<PostFilter>> getPostFilterListLiveData() {
+ return mPostFilterListLiveData;
+ }
+
+ public static class Factory extends ViewModelProvider.NewInstanceFactory {
+
+ private final RedditDataRoomDatabase mRedditDataRoomDatabase;
+
+ public Factory(RedditDataRoomDatabase redditDataRoomDatabase) {
+ mRedditDataRoomDatabase = redditDataRoomDatabase;
+ }
+
+ @Override
+ public <T extends ViewModel> T create(Class<T> modelClass) {
+ //noinspection unchecked
+ return (T) new PostFilterViewModel(mRedditDataRoomDatabase);
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java
index f129a4dd..f7362925 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java
@@ -5,23 +5,16 @@ import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
public class SavePostFilter {
- public static final int ERROR_DUPLICATE_NAME = 1;
-
public interface SavePostFilterListener {
//Need to make sure it is running in the UI thread.
void success();
- void failed(int errorCode);
}
public static void savePostFilter(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
PostFilter postFilter, SavePostFilterListener savePostFilterListener) {
executor.execute(() -> {
- if (redditDataRoomDatabase.postFilterDao().getPostFilter(postFilter.name) == null) {
- redditDataRoomDatabase.postFilterDao().insert(postFilter);
- savePostFilterListener.success();
- } else {
- savePostFilterListener.failed(ERROR_DUPLICATE_NAME);
- }
+ redditDataRoomDatabase.postFilterDao().insert(postFilter);
+ savePostFilterListener.success();
});
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java
index e9adbe8b..92a53a90 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MainPreferenceFragment.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.settings;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -16,6 +17,7 @@ import javax.inject.Named;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import static androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG;
@@ -34,6 +36,7 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
((Infinity) activity.getApplication()).getAppComponent().inject(this);
Preference securityPreference = findPreference(SharedPreferencesUtils.SECURITY);
+ Preference postFilterPreference = findPreference(SharedPreferencesUtils.POST_FILTER);
BiometricManager biometricManager = BiometricManager.from(activity);
if (biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL) != BiometricManager.BIOMETRIC_SUCCESS) {
@@ -41,6 +44,14 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
securityPreference.setVisible(false);
}
}
+
+ if (postFilterPreference != null) {
+ postFilterPreference.setOnPreferenceClickListener(preference -> {
+ Intent intent = new Intent(activity, PostFilterPreferenceActivity.class);
+ activity.startActivity(intent);
+ return true;
+ });
+ }
}
@Override
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 1f3fab50..a8f0aa34 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -148,6 +148,7 @@ public class SharedPreferencesUtils {
public static final String LANGUAGE = "language";
public static final String LANGUAGE_DEFAULT_VALUE = "auto";
public static final String ENABLE_SEARCH_HISTORY = "enable_search_history";
+ public static final String POST_FILTER = "post_filter";
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/res/drawable-night/ic_apply_to_24dp.xml b/app/src/main/res/drawable-night/ic_apply_to_24dp.xml
new file mode 100644
index 00000000..ee73a4df
--- /dev/null
+++ b/app/src/main/res/drawable-night/ic_apply_to_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M11,11h2.12l6.16,-6.16l-2.12,-2.12L11,8.88V11zM20.71,2L20,1.29c-0.39,-0.39 -1.02,-0.39 -1.41,0l-0.72,0.72l2.12,2.12l0.72,-0.72C21.1,3.02 21.1,2.39 20.71,2zM17.9,9.05C17.96,9.41 18,9.79 18,10.2c0,1.71 -1.08,4.64 -6,9.14c-4.92,-4.49 -6,-7.43 -6,-9.14C6,6.17 9.09,4 12,4c0.32,0 0.65,0.03 0.97,0.08l1.65,-1.65C13.78,2.16 12.9,2 12,2c-4.2,0 -8,3.22 -8,8.2c0,3.32 2.67,7.25 8,11.8c5.33,-4.55 8,-8.48 8,-11.8c0,-1.01 -0.16,-1.94 -0.45,-2.8L17.9,9.05z"
+ android:fillColor="#FFFFFF"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_apply_to_24dp.xml b/app/src/main/res/drawable/ic_apply_to_24dp.xml
new file mode 100644
index 00000000..23e47b34
--- /dev/null
+++ b/app/src/main/res/drawable/ic_apply_to_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M11,11h2.12l6.16,-6.16l-2.12,-2.12L11,8.88V11zM20.71,2L20,1.29c-0.39,-0.39 -1.02,-0.39 -1.41,0l-0.72,0.72l2.12,2.12l0.72,-0.72C21.1,3.02 21.1,2.39 20.71,2zM17.9,9.05C17.96,9.41 18,9.79 18,10.2c0,1.71 -1.08,4.64 -6,9.14c-4.92,-4.49 -6,-7.43 -6,-9.14C6,6.17 9.09,4 12,4c0.32,0 0.65,0.03 0.97,0.08l1.65,-1.65C13.78,2.16 12.9,2 12,2c-4.2,0 -8,3.22 -8,8.2c0,3.32 2.67,7.25 8,11.8c5.33,-4.55 8,-8.48 8,-11.8c0,-1.01 -0.16,-1.94 -0.45,-2.8L17.9,9.05z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/app/src/main/res/layout/activity_customize_post_filter.xml b/app/src/main/res/layout/activity_customize_post_filter.xml
index 72aeb6bc..b7940c7a 100644
--- a/app/src/main/res/layout/activity_customize_post_filter.xml
+++ b/app/src/main/res/layout/activity_customize_post_filter.xml
@@ -43,6 +43,26 @@
android:layout_height="wrap_content"
android:orientation="vertical">
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/name_text_input_layout_customize_post_filter_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
+
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/name_text_input_edit_text_customize_post_filter_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:fontFamily="?attr/font_family"
+ android:textSize="?attr/font_default"
+ android:hint="@string/post_filter_name_hint" />
+
+ </com.google.android.material.textfield.TextInputLayout>
+
<LinearLayout
android:id="@+id/post_type_text_linear_layout_customize_post_filter_activity"
android:layout_width="match_parent"
@@ -339,7 +359,7 @@
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
- android:hint="@string/excludes_subreddits_hint" />
+ android:hint="@string/exclude_subreddits_hint" />
</com.google.android.material.textfield.TextInputLayout>
@@ -359,7 +379,7 @@
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
- android:hint="@string/excludes_users_hint" />
+ android:hint="@string/exclude_users_hint" />
</com.google.android.material.textfield.TextInputLayout>
@@ -379,7 +399,7 @@
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
- android:hint="@string/excludes_flairs_hint" />
+ android:hint="@string/exclude_flairs_hint" />
</com.google.android.material.textfield.TextInputLayout>
@@ -399,7 +419,7 @@
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
- android:hint="@string/contains_flairs_hint" />
+ android:hint="@string/contain_flairs_hint" />
</com.google.android.material.textfield.TextInputLayout>
diff --git a/app/src/main/res/layout/activity_post_filter_preference.xml b/app/src/main/res/layout/activity_post_filter_preference.xml
new file mode 100644
index 00000000..7db6ad95
--- /dev/null
+++ b/app/src/main/res/layout/activity_post_filter_preference.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:id="@+id/coordinator_layout_post_filter_preference_activity"
+ tools:context=".activities.PostFilterPreferenceActivity">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/appbar_layout_post_filter_preference_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_post_filter_preference_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:titleEnabled="false"
+ app:toolbarId="@+id/toolbar_post_filter_preference_activity">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar_post_filter_preference_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?attr/actionBarSize"
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:navigationIcon="?attr/homeAsUpIndicator" />
+
+ </com.google.android.material.appbar.CollapsingToolbarLayout>
+
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/recycler_view_post_filter_preference_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+ <com.google.android.material.floatingactionbutton.FloatingActionButton
+ android:id="@+id/fab_post_filter_preference_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/fab_margin"
+ android:layout_gravity="bottom|end"
+ app:backgroundTint="?attr/colorPrimaryLightTheme"
+ app:srcCompat="@drawable/ic_add_day_night_24dp"
+ app:tint="@android:color/white" />
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_post_filter_options_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_filter_options_bottom_sheet.xml
new file mode 100644
index 00000000..a9c9310e
--- /dev/null
+++ b/app/src/main/res/layout/fragment_post_filter_options_bottom_sheet.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:paddingBottom="8dp"
+ android:overScrollMode="never">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/edit_text_view_post_filter_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/edit"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ app:drawableStartCompat="@drawable/ic_edit_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/apply_to_text_view_post_filter_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/apply_post_filter_to"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ app:drawableStartCompat="@drawable/ic_apply_to_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/delete_text_view_post_filter_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/delete"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ app:drawableStartCompat="@drawable/ic_delete_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ </LinearLayout>
+
+</androidx.core.widget.NestedScrollView> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_post_history.xml b/app/src/main/res/layout/fragment_post_history.xml
index 9ed65c7f..325d74e1 100644
--- a/app/src/main/res/layout/fragment_post_history.xml
+++ b/app/src/main/res/layout/fragment_post_history.xml
@@ -4,8 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:orientation="vertical"
- tools:context=".settings.NsfwAndBlurringFragment">
+ tools:context=".settings.PostHistoryFragment">
<LinearLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/item_filter_fragment_header.xml b/app/src/main/res/layout/item_filter_fragment_header.xml
new file mode 100644
index 00000000..af3b2b00
--- /dev/null
+++ b/app/src/main/res/layout/item_filter_fragment_header.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:drawablePadding="32dp"
+ android:text="@string/restart_app_see_changes"
+ android:textColor="@color/settingsSubtitleColor"
+ android:gravity="center_vertical"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ app:drawableStartCompat="@drawable/ic_info_preference_24dp" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="@color/dividerColor" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_post_filter.xml b/app/src/main/res/layout/item_post_filter.xml
new file mode 100644
index 00000000..62a5e886
--- /dev/null
+++ b/app/src/main/res/layout/item_post_filter.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="72dp"
+ android:paddingEnd="16dp"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_16"
+ android:fontFamily="?attr/font_family"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" /> \ No newline at end of file
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index e6e64517..d4068354 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -892,7 +892,7 @@ Reiter könnten den Inhalt verlieren, wenn zu anderen gewechselt wird. Selbes Ve
<string name="settings_miscellaneous_title">"Sonstiges"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"Vom Subreddit vorgeschlagenen Kommentar Sortier-Typ respektieren"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"Kommentar Sortier-Typ wird nicht gespeichert"</string>
- <string name="settings_filter_title">"Filter"</string>
+ <string name="settings_post_filter_title">"Filter"</string>
<string name="settings_subreddit_filter_category">"Verstecke Subreddits"</string>
<string name="settings_subreddit_filter_popular_and_all">"In r/popular und r/all"</string>
<string name="settings_credits_ufo_capturing_animation_title">"UFO-Aufnahmeanimation"</string>
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index fba9fb2b..6419c67e 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -872,6 +872,6 @@ Videos de Reddit están en menor resolución"</string>
<string name="downloading">"Descargando"</string>
<string name="subreddit_filter_popular_and_all_activity_label">"r/all y r/popular"</string>
<string name="settings_miscellaneous_title">"Misceláneo"</string>
- <string name="settings_filter_title">"Filtrar"</string>
+ <string name="settings_post_filter_title">"Filtrar"</string>
<string name="select_video_quality">"Seleccione calidad del video"</string>
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 2a25371e..24a5fbcf 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -930,7 +930,7 @@ Les onglets pourraient perdre tout leur contenu quand vous passez d'un onglet à
<string name="settings_miscellaneous_title">"Divers"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"Respecter l'ordre de tri recommandé par le subreddit pour les commentaires "</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"L'ordre de tri des commentaires ne sera pas sauvegardé "</string>
- <string name="settings_filter_title">"Filtre"</string>
+ <string name="settings_post_filter_title">"Filtre"</string>
<string name="settings_subreddit_filter_category">"Cacher des Subreddits"</string>
<string name="settings_subreddit_filter_popular_and_all">"Dans r/popular et r/all"</string>
<string name="settings_credits_ufo_capturing_animation_title">"Animation de capture de l'OVNI"</string>
diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml
index 61990aa4..158888e1 100644
--- a/app/src/main/res/values-hi/strings.xml
+++ b/app/src/main/res/values-hi/strings.xml
@@ -918,7 +918,7 @@ https://play.google.com/store/apps/details?id=ml.docilealligator.infinityforredd
<string name="settings_miscellaneous_title">"विविध "</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"सबरैडिट द्वारा संस्तुतित टिप्पणी क्रम प्रकार बनाए रखें "</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"टिप्पणी क्रम प्रकार सरंक्षित नहीं किया जाएगा "</string>
- <string name="settings_filter_title">"छंटनी "</string>
+ <string name="settings_post_filter_title">"छंटनी "</string>
<string name="settings_subreddit_filter_category">"सबरैडिट छुपाएं "</string>
<string name="settings_subreddit_filter_popular_and_all">"r/popular एवं r/all में "</string>
<string name="settings_credits_ufo_capturing_animation_title">"UFO बंदी बनाते हुए एनिमेशन "</string>
diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml
index e92edeab..5ee49cff 100644
--- a/app/src/main/res/values-hr/strings.xml
+++ b/app/src/main/res/values-hr/strings.xml
@@ -880,7 +880,7 @@ Poruka: %2$s"</string>
<string name="settings_miscellaneous_title">"Razno"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"Poštuj tip sortiranja komentara preporučen na podredditu"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"Tip sortiranja komentara neće biti spremljen"</string>
- <string name="settings_filter_title">"Filter"</string>
+ <string name="settings_post_filter_title">"Filter"</string>
<string name="settings_subreddit_filter_category">"Sakrij podreddite"</string>
<string name="settings_subreddit_filter_popular_and_all">"U r/popular i r/all"</string>
<string name="settings_credits_ufo_capturing_animation_title">"UFO Capturing Animation"</string>
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index d9af97a8..d404728c 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -935,7 +935,7 @@ I video di Reddit sono in minore risoluzione."</string>
<!-- Fuzzy -->
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"Il tipo di ordinamento dei commenti non verrà salvato"</string>
- <string name="settings_filter_title">"Filtro"</string>
+ <string name="settings_post_filter_title">"Filtro"</string>
<!-- Fuzzy -->
<string name="settings_subreddit_filter_category">"Nascondi i Subreddit"</string>
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index a0b55ad4..01c478b6 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -926,7 +926,7 @@ https://play.google.com/store/apps/details?id=ml.docilealligator.infinityforredd
<string name="settings_miscellaneous_title">"その他の設定"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"Subredditで推奨されているコメントの並び順を使用"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"コメントの並び順は保存されません"</string>
- <string name="settings_filter_title">"フィルター"</string>
+ <string name="settings_post_filter_title">"フィルター"</string>
<string name="settings_subreddit_filter_category">"Subredditを非表示"</string>
<string name="settings_subreddit_filter_popular_and_all">"r/all と r/popular 内"</string>
<string name="settings_credits_ufo_capturing_animation_title">"UFO捕獲アニメーション"</string>
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 73021efd..81f4493a 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -849,7 +849,7 @@ Os vídeos do Reddit ficam em menor resolução."</string>
<string name="settings_miscellaneous_title">"Miscelãnea"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"Respeitar modo de classificação de comentário recomendado pelo subreddit"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"Modo de classificação de comentário não será salvo"</string>
- <string name="settings_filter_title">"Filtrar"</string>
+ <string name="settings_post_filter_title">"Filtrar"</string>
<string name="settings_subreddit_filter_category">"Ocultar subreddits"</string>
<string name="settings_subreddit_filter_popular_and_all">"Em r/popular e r/all"</string>
<string name="settings_credits_ufo_capturing_animation_title">"Animação de captura de OVNIs"</string>
diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml
index b845444a..37f7aff0 100644
--- a/app/src/main/res/values-tr-rTR/strings.xml
+++ b/app/src/main/res/values-tr-rTR/strings.xml
@@ -863,7 +863,7 @@ Sekmeler, başkalarına geçtikten sonra tüm içeriği kaybedebilir. Bu, sayfay
<string name="settings_miscellaneous_title">"Diğerleri"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"İlgili Subreddit Önerilen Yorum Sıralaması Türü"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"Yorum sıralaması türü kaydedilemedi"</string>
- <string name="settings_filter_title">"Filtrele"</string>
+ <string name="settings_post_filter_title">"Filtrele"</string>
<string name="settings_subreddit_filter_category">"Subredditleri Gizle"</string>
<string name="settings_subreddit_filter_popular_and_all">"r/popular ve r/all"</string>
<string name="settings_credits_ufo_capturing_animation_title">"UFO Yakalama Animasyonu"</string>
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 2f9c2a2e..e27facdb 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -913,7 +913,7 @@ https://play.google.com/store/apps/details?id=ml.docilealligator.infinityforredd
<string name="settings_miscellaneous_title">"其他"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">"关于板块推荐评论排序类型"</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">"评论排序类型将不会保存"</string>
- <string name="settings_filter_title">"过滤器"</string>
+ <string name="settings_post_filter_title">"过滤器"</string>
<string name="settings_subreddit_filter_category">"隐藏版块"</string>
<string name="settings_subreddit_filter_popular_and_all">"在“r/all”和“r/popular”板块中"</string>
<string name="settings_credits_ufo_capturing_animation_title">"开屏UFO动画"</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index afeeb6f4..4d50431b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -34,8 +34,9 @@
<string name="submit_crosspost_activity_label">Crosspost</string>
<string name="give_award_activity_label">Give Award</string>
<string name="subreddit_filter_popular_and_all_activity_label">r/all and r/popular</string>
- <string name="customize_post_filter_activity_label">Post Filter</string>
+ <string name="customize_post_filter_activity_label">Customize Post Filter</string>
<string name="filtered_posts_activity_subtitle">Filtered Posts</string>
+ <string name="post_filter_preference_activity_label">Post Filter</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
@@ -504,7 +505,7 @@
<string name="settings_miscellaneous_title">Miscellaneous</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_title">Respect Subreddit Recommended Comment Sort Type</string>
<string name="settings_respect_subreddit_recommended_comment_sort_type_summary">Comment sort type will not be saved</string>
- <string name="settings_filter_title">Filter</string>
+ <string name="settings_post_filter_title">Post Filter</string>
<string name="settings_subreddit_filter_category">Hide Subreddits</string>
<string name="settings_subreddit_filter_popular_and_all">In r/popular and r/all</string>
<string name="settings_credits_ufo_capturing_animation_title">UFO Capturing Animation</string>
@@ -965,18 +966,18 @@
<string name="only_spoiler">Only Spoiler</string>
<string name="title_excludes_strings_hint">Title: excludes keywords</string>
<string name="title_excludes_regex_hint">Title: excludes regex</string>
- <string name="excludes_subreddits_hint">Excludes subreddits</string>
- <string name="excludes_users_hint">Excludes users</string>
- <string name="excludes_flairs_hint">Exclude flairs</string>
- <string name="contains_flairs_hint">Contains flairs</string>
- <string name="min_vote_hint">Min vote</string>
- <string name="max_vote_hint">Max vote</string>
- <string name="min_comments_hint">Min comments</string>
- <string name="max_comments_hint">Max comments</string>
- <string name="min_awards_hint">Min awards</string>
- <string name="max_awards_hint">Max awards</string>
+ <string name="exclude_subreddits_hint">Exclude subreddits</string>
+ <string name="exclude_users_hint">Exclude users</string>
+ <string name="exclude_flairs_hint">Exclude flairs</string>
+ <string name="contain_flairs_hint">Contain flairs</string>
+ <string name="min_vote_hint">Min vote (-1: no restriction)</string>
+ <string name="max_vote_hint">Max vote (-1: no restriction)</string>
+ <string name="min_comments_hint">Min comments (-1: no restriction)</string>
+ <string name="max_comments_hint">Max comments (-1: no restriction)</string>
+ <string name="min_awards_hint">Min awards (-1: no restriction)</string>
+ <string name="max_awards_hint">Max awards (-1: no restriction)</string>
<string name="post_filter_name_hint">Post Filter Name</string>
- <string name="duplicate_post_filter">Duplicate post filter found. Please use another name.</string>
-
+ <string name="post_filter_requires_a_name">What is the name of this post filter?</string>
+ <string name="apply_post_filter_to">Apply to</string>
</resources>
diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml
index 334ebd1a..e2dac88d 100644
--- a/app/src/main/res/xml/main_preferences.xml
+++ b/app/src/main/res/xml/main_preferences.xml
@@ -63,9 +63,9 @@
app:fragment="ml.docilealligator.infinityforreddit.settings.PostHistoryFragment" />
<Preference
+ app:key="post_filter"
app:icon="@drawable/ic_filter_24dp"
- app:title="@string/settings_filter_title"
- app:fragment="ml.docilealligator.infinityforreddit.settings.FilterPreferenceFragment"/>
+ app:title="@string/settings_post_filter_title" />
<Preference
app:icon="@drawable/ic_miscellaneous_24dp"