From 84e4dd09c3bb585c4cfc4166c9f9207610458cf2 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 28 Oct 2020 08:59:57 +0800 Subject: Add an option to filter subreddits in popular and all. --- app/src/main/AndroidManifest.xml | 8 +- .../SubredditFilterPopularAndAllActivity.java | 155 +++++++++++++++++++++ .../SubredditFilterRecyclerViewAdapter.java | 72 ++++++++++ .../infinityforreddit/AppComponent.java | 3 + .../infinityforreddit/RedditDataRoomDatabase.java | 16 ++- .../Settings/FilterPreferenceFragment.java | 38 +++++ .../SubredditFilter/DeleteSubredditFilter.java | 41 ++++++ .../SubredditFilter/InsertSubredditFilter.java | 41 ++++++ .../SubredditFilter/SubredditFilter.java | 37 +++++ .../SubredditFilter/SubredditFilterDao.java | 25 ++++ .../SubredditFilter/SubredditFilterViewModel.java | 36 +++++ .../Utils/SharedPreferencesUtils.java | 1 + app/src/main/res/drawable-night/ic_filter_24dp.xml | 9 ++ app/src/main/res/drawable/ic_filter_24dp.xml | 9 ++ .../activity_subreddit_filter_popular_and_all.xml | 52 +++++++ .../main/res/layout/item_selected_subreddit.xml | 6 +- app/src/main/res/values/strings.xml | 4 + app/src/main/res/xml/filter_preferences.xml | 11 ++ app/src/main/res/xml/main_preferences.xml | 5 + 19 files changed, 565 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditFilterPopularAndAllActivity.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditFilterRecyclerViewAdapter.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FilterPreferenceFragment.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/DeleteSubredditFilter.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/InsertSubredditFilter.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilter.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterDao.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterViewModel.java create mode 100644 app/src/main/res/drawable-night/ic_filter_24dp.xml create mode 100644 app/src/main/res/drawable/ic_filter_24dp.xml create mode 100644 app/src/main/res/layout/activity_subreddit_filter_popular_and_all.xml create mode 100644 app/src/main/res/xml/filter_preferences.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 265a9963..6cbdca3f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,7 +32,13 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:replace="android:label"> - + DeleteSubredditFilter.deleteSubredditFilter(redditDataRoomDatabase, subredditFilter, () -> {})); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + recyclerView.setAdapter(adapter); + recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { + if (dy > 0) { + fab.hide(); + } else if (dy < 0) { + fab.show(); + } + } + }); + + subredditFilterViewModel = new ViewModelProvider(this, + new SubredditFilterViewModel.Factory(redditDataRoomDatabase)) + .get(SubredditFilterViewModel.class); + subredditFilterViewModel.getSubredditFilterLiveData().observe(this, subredditFilters -> adapter.updateSubredditsName(subredditFilters)); + + fab.setOnClickListener(view -> { + EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null); + thingEditText.requestFocus(); + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.choose_a_subreddit) + .setView(thingEditText) + .setPositiveButton(R.string.ok, (dialogInterface, i) + -> { + if (imm != null) { + imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0); + } + SubredditFilter subredditFilter = new SubredditFilter(thingEditText.getText().toString(), SubredditFilter.TYPE_POPULAR_AND_ALL); + InsertSubredditFilter.insertSubredditFilter(redditDataRoomDatabase, subredditFilter, + () -> {}); + }) + .setNegativeButton(R.string.cancel, null) + .setNeutralButton(R.string.search, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (imm != null) { + imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0); + } + } + }) + .setOnDismissListener(dialogInterface -> { + if (imm != null) { + imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0); + } + }) + .show(); + }); + } + + @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() { + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); + } +} \ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditFilterRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditFilterRecyclerViewAdapter.java new file mode 100644 index 00000000..28678b40 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditFilterRecyclerViewAdapter.java @@ -0,0 +1,72 @@ +package ml.docilealligator.infinityforreddit.Adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SubredditFilter.SubredditFilter; + +public class SubredditFilterRecyclerViewAdapter extends RecyclerView.Adapter { + private List subredditFilters; + private ItemClickListener itemClickListener; + + public SubredditFilterRecyclerViewAdapter(ItemClickListener itemClickListener) { + this.itemClickListener = itemClickListener; + } + + public interface ItemClickListener { + void onItemDelete(SubredditFilter subredditFilter); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new SubredditNameViewHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_selected_subreddit, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof SubredditNameViewHolder) { + ((SubredditNameViewHolder) holder).subredditRedditNameTextView.setText(subredditFilters.get(position).getSubredditName()); + } + } + + @Override + public int getItemCount() { + return subredditFilters == null ? 0 : subredditFilters.size(); + } + + public void updateSubredditsName(List subredditFilters) { + this.subredditFilters = subredditFilters; + notifyDataSetChanged(); + } + + class SubredditNameViewHolder extends RecyclerView.ViewHolder { + @BindView(R.id.subreddit_name_item_selected_subreddit) + TextView subredditRedditNameTextView; + @BindView(R.id.delete_image_view_item_selected_subreddit) + ImageView deleteImageView; + + public SubredditNameViewHolder(@NonNull View itemView) { + super(itemView); + + ButterKnife.bind(this, itemView); + + deleteImageView.setOnClickListener(view -> { + itemClickListener.onItemDelete(subredditFilters.get(getAdapterPosition())); + }); + } + } + +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index 4b83ac3f..6fc0c4b8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -35,6 +35,7 @@ import ml.docilealligator.infinityforreddit.Activity.SelectedSubredditsActivity; import ml.docilealligator.infinityforreddit.Activity.SendPrivateMessageActivity; import ml.docilealligator.infinityforreddit.Activity.SettingsActivity; import ml.docilealligator.infinityforreddit.Activity.SubmitCrosspostActivity; +import ml.docilealligator.infinityforreddit.Activity.SubredditFilterPopularAndAllActivity; import ml.docilealligator.infinityforreddit.Activity.SubredditMultiselectionActivity; import ml.docilealligator.infinityforreddit.Activity.SubredditSelectionActivity; import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity; @@ -224,4 +225,6 @@ public interface AppComponent { void inject(FetchRandomSubredditOrPostActivity fetchRandomSubredditOrPostActivity); void inject(MiscellaneousPreferenceFragment miscellaneousPreferenceFragment); + + void inject(SubredditFilterPopularAndAllActivity subredditFilterPopularAndAllActivity); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java index 18ce485d..7e7a6c01 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java @@ -20,6 +20,8 @@ import ml.docilealligator.infinityforreddit.RecentSearchQuery.RecentSearchQuery; import ml.docilealligator.infinityforreddit.RecentSearchQuery.RecentSearchQueryDao; import ml.docilealligator.infinityforreddit.Subreddit.SubredditDao; import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubredditFilter.SubredditFilter; +import ml.docilealligator.infinityforreddit.SubredditFilter.SubredditFilterDao; import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditDao; import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; @@ -28,7 +30,7 @@ import ml.docilealligator.infinityforreddit.User.UserDao; import ml.docilealligator.infinityforreddit.User.UserData; @Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class, - SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class}, version = 11) + SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class, SubredditFilter.class}, version = 12) public abstract class RedditDataRoomDatabase extends RoomDatabase { private static RedditDataRoomDatabase INSTANCE; @@ -40,7 +42,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { RedditDataRoomDatabase.class, "reddit_data") .addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9, - MIGRATION_9_10, MIGRATION_10_11) + MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12) .build(); } } @@ -64,6 +66,8 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { public abstract RecentSearchQueryDao recentSearchQueryDao(); + public abstract SubredditFilterDao subredditFilterDao(); + private static final Migration MIGRATION_1_2 = new Migration(1, 2) { @Override public void migrate(SupportSQLiteDatabase database) { @@ -243,4 +247,12 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { + " ADD COLUMN over_18 INTEGER DEFAULT 0 NOT NULL"); } }; + + private static final Migration MIGRATION_11_12 = new Migration(11, 12) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("CREATE TABLE subreddit_filter" + + "(subreddit_name TEXT NOT NULL, type INTEGER NOT NULL, PRIMARY KEY(subreddit_name, type))"); + } + }; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FilterPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FilterPreferenceFragment.java new file mode 100644 index 00000000..a0555d5d --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/FilterPreferenceFragment.java @@ -0,0 +1,38 @@ +package ml.docilealligator.infinityforreddit.Settings; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; + +import androidx.annotation.NonNull; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragmentCompat; + +import ml.docilealligator.infinityforreddit.Activity.SubredditFilterPopularAndAllActivity; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; + +public class FilterPreferenceFragment extends PreferenceFragmentCompat { + + private Activity activity; + + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + setPreferencesFromResource(R.xml.filter_preferences, rootKey); + + Preference subredditFilterPopularAndAllPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_FILTER_POPULAR_AND_ALL); + + subredditFilterPopularAndAllPreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(activity, SubredditFilterPopularAndAllActivity.class); + activity.startActivity(intent); + return true; + }); + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +} \ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/DeleteSubredditFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/DeleteSubredditFilter.java new file mode 100644 index 00000000..63b856dc --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/DeleteSubredditFilter.java @@ -0,0 +1,41 @@ +package ml.docilealligator.infinityforreddit.SubredditFilter; + +import android.os.AsyncTask; + +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; + +public class DeleteSubredditFilter { + public interface DeleteSubredditFilterListener { + void success(); + } + + public static void deleteSubredditFilter(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter, + DeleteSubredditFilterListener deleteSubredditFilterListener) { + new DeleteSubredditFilterAsyncTask(redditDataRoomDatabase, subredditFilter, deleteSubredditFilterListener).execute(); + } + + private static class DeleteSubredditFilterAsyncTask extends AsyncTask { + private RedditDataRoomDatabase redditDataRoomDatabase; + private SubredditFilter subredditFilter; + private DeleteSubredditFilterListener deleteSubredditFilterListener; + + DeleteSubredditFilterAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter, + DeleteSubredditFilterListener deleteSubredditFilterListener) { + this.redditDataRoomDatabase = redditDataRoomDatabase; + this.subredditFilter = subredditFilter; + this.deleteSubredditFilterListener = deleteSubredditFilterListener; + } + + @Override + protected Void doInBackground(Void... voids) { + redditDataRoomDatabase.subredditFilterDao().deleteSubredditFilter(subredditFilter); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + super.onPostExecute(aVoid); + deleteSubredditFilterListener.success(); + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/InsertSubredditFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/InsertSubredditFilter.java new file mode 100644 index 00000000..b91fa1e2 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/InsertSubredditFilter.java @@ -0,0 +1,41 @@ +package ml.docilealligator.infinityforreddit.SubredditFilter; + +import android.os.AsyncTask; + +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; + +public class InsertSubredditFilter { + public interface InsertSubredditFilterListener { + void success(); + } + + public static void insertSubredditFilter(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter, + InsertSubredditFilterListener insertSubredditFilterListener) { + new InsertSubredditFilterAsyncTask(redditDataRoomDatabase, subredditFilter, insertSubredditFilterListener).execute(); + } + + private static class InsertSubredditFilterAsyncTask extends AsyncTask { + private RedditDataRoomDatabase redditDataRoomDatabase; + private SubredditFilter subredditFilter; + private InsertSubredditFilterListener insertSubredditFilterListener; + + InsertSubredditFilterAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter, + InsertSubredditFilterListener insertSubredditFilterListener) { + this.redditDataRoomDatabase = redditDataRoomDatabase; + this.subredditFilter = subredditFilter; + this.insertSubredditFilterListener = insertSubredditFilterListener; + } + + @Override + protected Void doInBackground(Void... voids) { + redditDataRoomDatabase.subredditFilterDao().insert(subredditFilter); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + super.onPostExecute(aVoid); + insertSubredditFilterListener.success(); + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilter.java new file mode 100644 index 00000000..88ef79f7 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilter.java @@ -0,0 +1,37 @@ +package ml.docilealligator.infinityforreddit.SubredditFilter; + +import androidx.annotation.NonNull; +import androidx.room.ColumnInfo; +import androidx.room.Entity; + +@Entity(tableName = "subreddit_filter", primaryKeys = {"subreddit_name", "type"}) +public class SubredditFilter { + public static int TYPE_POPULAR_AND_ALL = 0; + @NonNull + @ColumnInfo(name = "subreddit_name") + private String subredditName; + @ColumnInfo(name = "type") + private int type; + + public SubredditFilter(@NonNull String subredditName, int type) { + this.subredditName = subredditName; + this.type = type; + } + + @NonNull + public String getSubredditName() { + return subredditName; + } + + public void setSubredditName(@NonNull String subredditName) { + this.subredditName = subredditName; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterDao.java new file mode 100644 index 00000000..fb5d3829 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterDao.java @@ -0,0 +1,25 @@ +package ml.docilealligator.infinityforreddit.SubredditFilter; + +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 SubredditFilterDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insert(SubredditFilter subredditFilter); + + @Query("SELECT * FROM subreddit_filter") + LiveData> getAllSubredditFiltersLiveData(); + + @Query("SELECT * FROM subreddit_filter") + List getAllSubredditFilters(); + + @Delete + void deleteSubredditFilter(SubredditFilter subredditFilter); +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterViewModel.java new file mode 100644 index 00000000..557e879d --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditFilter/SubredditFilterViewModel.java @@ -0,0 +1,36 @@ +package ml.docilealligator.infinityforreddit.SubredditFilter; + +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 SubredditFilterViewModel extends ViewModel { + private LiveData> subredditFilterLiveData; + + public SubredditFilterViewModel(RedditDataRoomDatabase redditDataRoomDatabase) { + subredditFilterLiveData = redditDataRoomDatabase.subredditFilterDao().getAllSubredditFiltersLiveData(); + } + + public LiveData> getSubredditFilterLiveData() { + return subredditFilterLiveData; + } + + public static class Factory extends ViewModelProvider.NewInstanceFactory { + private RedditDataRoomDatabase redditDataRoomDatabase; + + public Factory(RedditDataRoomDatabase redditDataRoomDatabase) { + this.redditDataRoomDatabase = redditDataRoomDatabase; + } + + @NonNull + @Override + public T create(@NonNull Class modelClass) { + return (T) new SubredditFilterViewModel(redditDataRoomDatabase); + } + } +} 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 a2b909eb..940cf3e3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -136,6 +136,7 @@ public class SharedPreferencesUtils { public static final String DATA_SAVING_MODE_ALWAYS = "2"; public static final String NATIONAL_FLAGS = "national_flags"; public static final String RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE = "respect_subreddit_recommended_comment_sort_type"; + public static final String SUBREDDIT_FILTER_POPULAR_AND_ALL = "subreddit_filter_popular_and_all"; 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_filter_24dp.xml b/app/src/main/res/drawable-night/ic_filter_24dp.xml new file mode 100644 index 00000000..641119c4 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_filter_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_filter_24dp.xml b/app/src/main/res/drawable/ic_filter_24dp.xml new file mode 100644 index 00000000..869e7e5e --- /dev/null +++ b/app/src/main/res/drawable/ic_filter_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_subreddit_filter_popular_and_all.xml b/app/src/main/res/layout/activity_subreddit_filter_popular_and_all.xml new file mode 100644 index 00000000..6a342718 --- /dev/null +++ b/app/src/main/res/layout/activity_subreddit_filter_popular_and_all.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_selected_subreddit.xml b/app/src/main/res/layout/item_selected_subreddit.xml index 6e1a570a..2e8ae1c9 100644 --- a/app/src/main/res/layout/item_selected_subreddit.xml +++ b/app/src/main/res/layout/item_selected_subreddit.xml @@ -15,6 +15,7 @@ android:layout_gravity="center_vertical" android:layout_marginEnd="16dp" android:textSize="?attr/font_default" + android:textColor="?attr/primaryTextColor" android:fontFamily="?attr/font_family" /> + android:src="@drawable/ic_delete_24dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0375432b..f5d3bdec 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,6 +33,7 @@ Video %1$d/%2$d Crosspost Give Award + r/all and r/popular Open navigation drawer Close navigation drawer @@ -497,6 +498,9 @@ Miscellaneous Respect Subreddit Recommended Comment Sort Type Comment sort type will not be saved + Filter + Subreddit Filter + r/popular and r/all Cannot get the link diff --git a/app/src/main/res/xml/filter_preferences.xml b/app/src/main/res/xml/filter_preferences.xml new file mode 100644 index 00000000..a0e2a991 --- /dev/null +++ b/app/src/main/res/xml/filter_preferences.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index 8ada3e6c..1dea4177 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -58,6 +58,11 @@ app:title="@string/settings_nsfw_and_spoiler_title" app:fragment="ml.docilealligator.infinityforreddit.Settings.NsfwAndBlurringFragment"/> + +