mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Continue adding post filter.
This commit is contained in:
parent
fa55fb369d
commit
97b5c5d5c6
@ -32,7 +32,11 @@
|
|||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:replace="android:label">
|
tools:replace="android:label">
|
||||||
<activity android:name=".activities.PostFilterPreferenceActivity"
|
<activity android:name=".activities.PostFilterUsageListingActivity"
|
||||||
|
android:parentActivityName=".activities.SettingsActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.PostFilterPreferenceActivity"
|
||||||
android:label="@string/post_filter_preference_activity_label"
|
android:label="@string/post_filter_preference_activity_label"
|
||||||
android:parentActivityName=".activities.SettingsActivity"
|
android:parentActivityName=".activities.SettingsActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
|
@ -22,6 +22,7 @@ import ml.docilealligator.infinityforreddit.activities.InboxActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.LoginActivity;
|
import ml.docilealligator.infinityforreddit.activities.LoginActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.MainActivity;
|
import ml.docilealligator.infinityforreddit.activities.MainActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
|
import ml.docilealligator.infinityforreddit.activities.PostFilterPreferenceActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.PostImageActivity;
|
import ml.docilealligator.infinityforreddit.activities.PostImageActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.PostLinkActivity;
|
import ml.docilealligator.infinityforreddit.activities.PostLinkActivity;
|
||||||
@ -236,4 +237,6 @@ public interface AppComponent {
|
|||||||
void inject(PostHistoryFragment postHistoryFragment);
|
void inject(PostHistoryFragment postHistoryFragment);
|
||||||
|
|
||||||
void inject(PostFilterPreferenceActivity postFilterPreferenceActivity);
|
void inject(PostFilterPreferenceActivity postFilterPreferenceActivity);
|
||||||
|
|
||||||
|
void inject(PostFilterUsageListingActivity postFilterUsageListingActivity);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public void changeName(String oldThemeName) {
|
public void changeName(String oldThemeName) {
|
||||||
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
|
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
|
||||||
EditText themeNameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_name_dialog);
|
EditText themeNameEditText = dialogView.findViewById(R.id.name_edit_text_edit_name_dialog);
|
||||||
themeNameEditText.setText(oldThemeName);
|
themeNameEditText.setText(oldThemeName);
|
||||||
themeNameEditText.requestFocus();
|
themeNameEditText.requestFocus();
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
@ -294,7 +294,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
|
|||||||
.setPositiveButton(R.string.rename, (dialogInterface, i)
|
.setPositiveButton(R.string.rename, (dialogInterface, i)
|
||||||
-> {
|
-> {
|
||||||
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
|
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
|
||||||
EditText themeNameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_name_dialog);
|
EditText themeNameEditText = dialogView.findViewById(R.id.name_edit_text_edit_name_dialog);
|
||||||
themeNameEditText.setText(customTheme.name);
|
themeNameEditText.setText(customTheme.name);
|
||||||
themeNameEditText.requestFocus();
|
themeNameEditText.requestFocus();
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
@ -14,6 +14,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
@ -25,6 +27,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|||||||
import ml.docilealligator.infinityforreddit.adapters.FilterFragmentPostFilterRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.adapters.FilterFragmentPostFilterRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostFilterOptionsBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostFilterOptionsBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.DeletePostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilterViewModel;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilterViewModel;
|
||||||
|
|
||||||
@ -47,6 +50,8 @@ public class PostFilterPreferenceActivity extends BaseActivity {
|
|||||||
RedditDataRoomDatabase redditDataRoomDatabase;
|
RedditDataRoomDatabase redditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper customThemeWrapper;
|
CustomThemeWrapper customThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor executor;
|
||||||
public PostFilterViewModel postFilterViewModel;
|
public PostFilterViewModel postFilterViewModel;
|
||||||
private FilterFragmentPostFilterRecyclerViewAdapter adapter;
|
private FilterFragmentPostFilterRecyclerViewAdapter adapter;
|
||||||
|
|
||||||
@ -94,11 +99,13 @@ public class PostFilterPreferenceActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void applyPostFilterTo(PostFilter postFilter) {
|
public void applyPostFilterTo(PostFilter postFilter) {
|
||||||
|
Intent intent = new Intent(this, PostFilterUsageListingActivity.class);
|
||||||
|
intent.putExtra(PostFilterUsageListingActivity.EXTRA_POST_FILTER, postFilter);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deletePostFilter(PostFilter postFilter) {
|
public void deletePostFilter(PostFilter postFilter) {
|
||||||
|
DeletePostFilter.deletePostFilter(redditDataRoomDatabase, executor, postFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,197 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.activities;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
|
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.dialog.MaterialAlertDialogBuilder;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
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 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.PostFilterUsageRecyclerViewAdapter;
|
||||||
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.NewPostFilterUsageBottomSheetFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostFilterUsageOptionsBottomSheetFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.DeletePostFilterUsage;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsageViewModel;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.SavePostFilterUsage;
|
||||||
|
|
||||||
|
public class PostFilterUsageListingActivity extends BaseActivity {
|
||||||
|
|
||||||
|
public static final String EXTRA_POST_FILTER = "EPF";
|
||||||
|
@BindView(R.id.coordinator_layout_post_filter_application_activity)
|
||||||
|
CoordinatorLayout coordinatorLayout;
|
||||||
|
@BindView(R.id.appbar_layout_post_filter_application_activity)
|
||||||
|
AppBarLayout appBarLayout;
|
||||||
|
@BindView(R.id.toolbar_post_filter_application_activity)
|
||||||
|
Toolbar toolbar;
|
||||||
|
@BindView(R.id.recycler_view_post_filter_application_activity)
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
@BindView(R.id.fab_post_filter_application_activity)
|
||||||
|
FloatingActionButton fab;
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
@Inject
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase;
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper customThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor executor;
|
||||||
|
public PostFilterUsageViewModel postFilterUsageViewModel;
|
||||||
|
private PostFilterUsageRecyclerViewAdapter adapter;
|
||||||
|
private PostFilter postFilter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_post_filter_application);
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
applyCustomTheme();
|
||||||
|
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
postFilter = getIntent().getParcelableExtra(EXTRA_POST_FILTER);
|
||||||
|
|
||||||
|
setTitle(postFilter.name);
|
||||||
|
|
||||||
|
fab.setOnClickListener(view -> {
|
||||||
|
NewPostFilterUsageBottomSheetFragment newPostFilterUsageBottomSheetFragment = new NewPostFilterUsageBottomSheetFragment();
|
||||||
|
newPostFilterUsageBottomSheetFragment.show(getSupportFragmentManager(), newPostFilterUsageBottomSheetFragment.getTag());
|
||||||
|
});
|
||||||
|
|
||||||
|
adapter = new PostFilterUsageRecyclerViewAdapter(this, postFilterUsage -> {
|
||||||
|
PostFilterUsageOptionsBottomSheetFragment postFilterUsageOptionsBottomSheetFragment = new PostFilterUsageOptionsBottomSheetFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(PostFilterUsageOptionsBottomSheetFragment.EXTRA_POST_FILTER_USAGE, postFilterUsage);
|
||||||
|
postFilterUsageOptionsBottomSheetFragment.setArguments(bundle);
|
||||||
|
postFilterUsageOptionsBottomSheetFragment.show(getSupportFragmentManager(), postFilterUsageOptionsBottomSheetFragment.getTag());
|
||||||
|
});
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
postFilterUsageViewModel = new ViewModelProvider(this,
|
||||||
|
new PostFilterUsageViewModel.Factory(redditDataRoomDatabase, postFilter.name)).get(PostFilterUsageViewModel.class);
|
||||||
|
|
||||||
|
postFilterUsageViewModel.getPostFilterUsageListLiveData().observe(this, postFilterUsages -> adapter.setPostFilterUsages(postFilterUsages));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void newPostFilterUsage(int type) {
|
||||||
|
switch (type) {
|
||||||
|
case PostFilterUsage.HOME_TYPE:
|
||||||
|
case PostFilterUsage.SEARCH_TYPE:
|
||||||
|
PostFilterUsage postFilterUsage = new PostFilterUsage(postFilter.name, type, PostFilterUsage.NO_USAGE);
|
||||||
|
SavePostFilterUsage.savePostFilterUsage(redditDataRoomDatabase, executor, postFilterUsage);
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
case PostFilterUsage.USER_TYPE:
|
||||||
|
case PostFilterUsage.MULTIREDDIT_TYPE:
|
||||||
|
editAndPostFilterUsageNameOfUsage(type, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
int primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
|
textInputLayout.setBoxStrokeColor(primaryTextColor);
|
||||||
|
textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
textInputEditText.setTextColor(primaryTextColor);
|
||||||
|
if (nameOfUsage != null && !nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
|
||||||
|
textInputEditText.setText(nameOfUsage);
|
||||||
|
}
|
||||||
|
textInputEditText.requestFocus();
|
||||||
|
switch (type) {
|
||||||
|
case PostFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
textInputEditText.setHint(R.string.settings_tab_subreddit_name);
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.USER_TYPE:
|
||||||
|
textInputEditText.setHint(R.string.settings_tab_username);
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.MULTIREDDIT_TYPE:
|
||||||
|
textInputEditText.setHint(R.string.settings_tab_multi_reddit_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.edit_post_filter_name_of_usage_info)
|
||||||
|
.setView(dialogView)
|
||||||
|
.setPositiveButton(R.string.ok, (editTextDialogInterface, i1)
|
||||||
|
-> {
|
||||||
|
if (imm != null) {
|
||||||
|
imm.hideSoftInputFromWindow(textInputEditText.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
PostFilterUsage postFilterUsage;
|
||||||
|
if (textInputEditText.getText().toString().equals("")) {
|
||||||
|
postFilterUsage = new PostFilterUsage(postFilter.name, type, PostFilterUsage.NO_USAGE);
|
||||||
|
} else {
|
||||||
|
postFilterUsage = new PostFilterUsage(postFilter.name, type, textInputEditText.getText().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
SavePostFilterUsage.savePostFilterUsage(redditDataRoomDatabase, executor, postFilterUsage);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.setOnDismissListener(editTextDialogInterface -> {
|
||||||
|
if (imm != null) {
|
||||||
|
imm.hideSoftInputFromWindow(textInputEditText.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editPostFilterUsage(PostFilterUsage postFilterUsage) {
|
||||||
|
editAndPostFilterUsageNameOfUsage(postFilterUsage.usage, postFilterUsage.nameOfUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePostFilterUsage(PostFilterUsage postFilterUsage) {
|
||||||
|
DeletePostFilterUsage.deletePostFilterUsage(redditDataRoomDatabase, executor, postFilterUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SharedPreferences getDefaultSharedPreferences() {
|
||||||
|
return sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||||
|
return customThemeWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyCustomTheme() {
|
||||||
|
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
||||||
|
}
|
||||||
|
}
|
@ -88,7 +88,7 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((ThemeNameItemViewHolder) holder).themeNameTextView.setText(themeName);
|
((ThemeNameItemViewHolder) holder).themeNameTextView.setText(themeName);
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
View dialogView = activity.getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
|
View dialogView = activity.getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
|
||||||
EditText themeNameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_name_dialog);
|
EditText themeNameEditText = dialogView.findViewById(R.id.name_edit_text_edit_name_dialog);
|
||||||
themeNameEditText.setText(themeName);
|
themeNameEditText.setText(themeName);
|
||||||
themeNameEditText.requestFocus();
|
themeNameEditText.requestFocus();
|
||||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
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.PostFilterUsage;
|
||||||
|
|
||||||
|
public class PostFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
private List<PostFilterUsage> postFilterUsages;
|
||||||
|
private OnItemClickListener onItemClickListener;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public interface OnItemClickListener {
|
||||||
|
void onClick(PostFilterUsage postFilterUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PostFilterUsageRecyclerViewAdapter(Context context,
|
||||||
|
OnItemClickListener onItemClickListener) {
|
||||||
|
this.context = context;
|
||||||
|
this.onItemClickListener = onItemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new PostFilterUsageViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_filter_usage, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
|
PostFilterUsage postFilterUsage = postFilterUsages.get(position);
|
||||||
|
switch (postFilterUsage.usage) {
|
||||||
|
case PostFilterUsage.HOME_TYPE:
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_home);
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_subreddit_all);
|
||||||
|
} else {
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(context.getString(R.string.post_filter_usage_subreddit, postFilterUsage.nameOfUsage));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.USER_TYPE:
|
||||||
|
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_user_all);
|
||||||
|
} else {
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(context.getString(R.string.post_filter_usage_user, postFilterUsage.nameOfUsage));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.MULTIREDDIT_TYPE:
|
||||||
|
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_multireddit_all);
|
||||||
|
} else {
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(context.getString(R.string.post_filter_usage_multireddit, postFilterUsage.nameOfUsage));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.SEARCH_TYPE:
|
||||||
|
((PostFilterUsageViewHolder) holder).usageTextView.setText(R.string.post_filter_usage_search);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return postFilterUsages == null ? 0 : postFilterUsages.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPostFilterUsages(List<PostFilterUsage> postFilterUsages) {
|
||||||
|
this.postFilterUsages = postFilterUsages;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PostFilterUsageViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
TextView usageTextView;
|
||||||
|
|
||||||
|
public PostFilterUsageViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
usageTextView = (TextView) itemView;
|
||||||
|
|
||||||
|
usageTextView.setOnClickListener(view -> {
|
||||||
|
onItemClickListener.onClick(postFilterUsages.get(getAdapterPosition()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
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.PostFilterUsageListingActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
|
||||||
|
|
||||||
|
public class NewPostFilterUsageBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
@BindView(R.id.home_text_view_new_post_filter_usage_bottom_sheet_fragment)
|
||||||
|
TextView homeTextView;
|
||||||
|
@BindView(R.id.subreddit_text_view_new_post_filter_usage_bottom_sheet_fragment)
|
||||||
|
TextView subredditTextView;
|
||||||
|
@BindView(R.id.user_text_view_new_post_filter_usage_bottom_sheet_fragment)
|
||||||
|
TextView userTextView;
|
||||||
|
@BindView(R.id.multireddit_text_view_new_post_filter_usage_bottom_sheet_fragment)
|
||||||
|
TextView multiRedditTextView;
|
||||||
|
@BindView(R.id.search_text_view_new_post_filter_usage_bottom_sheet_fragment)
|
||||||
|
TextView searchTextView;
|
||||||
|
private PostFilterUsageListingActivity activity;
|
||||||
|
|
||||||
|
public NewPostFilterUsageBottomSheetFragment() {
|
||||||
|
// 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_new_post_filter_usage_bottom_sheet, container, false);
|
||||||
|
|
||||||
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
|
homeTextView.setOnClickListener(view -> {
|
||||||
|
activity.newPostFilterUsage(PostFilterUsage.HOME_TYPE);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
subredditTextView.setOnClickListener(view -> {
|
||||||
|
activity.newPostFilterUsage(PostFilterUsage.SUBREDDIT_TYPE);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
userTextView.setOnClickListener(view -> {
|
||||||
|
activity.newPostFilterUsage(PostFilterUsage.USER_TYPE);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
multiRedditTextView.setOnClickListener(view -> {
|
||||||
|
activity.newPostFilterUsage(PostFilterUsage.MULTIREDDIT_TYPE);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
searchTextView.setOnClickListener(view -> {
|
||||||
|
activity.newPostFilterUsage(PostFilterUsage.SEARCH_TYPE);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (PostFilterUsageListingActivity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
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.PostFilterUsageListingActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
|
||||||
|
|
||||||
|
public class PostFilterUsageOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String EXTRA_POST_FILTER_USAGE = "EPFU";
|
||||||
|
|
||||||
|
@BindView(R.id.edit_text_view_post_filter_usage_options_bottom_sheet_fragment)
|
||||||
|
TextView editTextView;
|
||||||
|
@BindView(R.id.delete_text_view_post_filter_usage_options_bottom_sheet_fragment)
|
||||||
|
TextView deleteTextView;
|
||||||
|
private PostFilterUsageListingActivity activity;
|
||||||
|
|
||||||
|
public PostFilterUsageOptionsBottomSheetFragment() {
|
||||||
|
// 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_usage_options_bottom_sheet, container, false);
|
||||||
|
|
||||||
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
|
PostFilterUsage postFilterUsage = getArguments().getParcelable(EXTRA_POST_FILTER_USAGE);
|
||||||
|
|
||||||
|
if (postFilterUsage.usage == PostFilterUsage.HOME_TYPE || postFilterUsage.usage == PostFilterUsage.SEARCH_TYPE) {
|
||||||
|
editTextView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
editTextView.setOnClickListener(view -> {
|
||||||
|
activity.editPostFilterUsage(postFilterUsage);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteTextView.setOnClickListener(view -> {
|
||||||
|
activity.deletePostFilterUsage(postFilterUsage);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (PostFilterUsageListingActivity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.postfilter;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class DeletePostFilter {
|
||||||
|
public static void deletePostFilter(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor, PostFilter postFilter) {
|
||||||
|
executor.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
redditDataRoomDatabase.postFilterDao().deletePostFilter(postFilter);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.postfilter;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class DeletePostFilterUsage {
|
||||||
|
public static void deletePostFilterUsage(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
|
||||||
|
PostFilterUsage postFilterUsage) {
|
||||||
|
executor.execute(() -> redditDataRoomDatabase.postFilterUsageDao().deletePostFilterUsage(postFilterUsage));
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package ml.docilealligator.infinityforreddit.postfilter;
|
package ml.docilealligator.infinityforreddit.postfilter;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.room.ColumnInfo;
|
import androidx.room.ColumnInfo;
|
||||||
import androidx.room.Entity;
|
import androidx.room.Entity;
|
||||||
@ -8,7 +11,14 @@ import androidx.room.ForeignKey;
|
|||||||
@Entity(tableName = "post_filter_usage", primaryKeys = {"name", "usage", "name_of_usage"},
|
@Entity(tableName = "post_filter_usage", primaryKeys = {"name", "usage", "name_of_usage"},
|
||||||
foreignKeys = @ForeignKey(entity = PostFilter.class, parentColumns = "name",
|
foreignKeys = @ForeignKey(entity = PostFilter.class, parentColumns = "name",
|
||||||
childColumns = "name", onDelete = ForeignKey.CASCADE))
|
childColumns = "name", onDelete = ForeignKey.CASCADE))
|
||||||
public class PostFilterUsage {
|
public class PostFilterUsage implements Parcelable {
|
||||||
|
public static final int HOME_TYPE = 1;
|
||||||
|
public static final int SUBREDDIT_TYPE = 2;
|
||||||
|
public static final int USER_TYPE = 3;
|
||||||
|
public static final int MULTIREDDIT_TYPE = 4;
|
||||||
|
public static final int SEARCH_TYPE = 5;
|
||||||
|
public static final String NO_USAGE = "--";
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ColumnInfo(name = "name")
|
@ColumnInfo(name = "name")
|
||||||
public String name;
|
public String name;
|
||||||
@ -21,6 +31,40 @@ public class PostFilterUsage {
|
|||||||
public PostFilterUsage(@NonNull String name, int usage, String nameOfUsage) {
|
public PostFilterUsage(@NonNull String name, int usage, String nameOfUsage) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.usage = usage;
|
this.usage = usage;
|
||||||
|
if (nameOfUsage == null || nameOfUsage.equals("")) {
|
||||||
|
this.nameOfUsage = NO_USAGE;
|
||||||
|
} else {
|
||||||
this.nameOfUsage = nameOfUsage;
|
this.nameOfUsage = nameOfUsage;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PostFilterUsage(Parcel in) {
|
||||||
|
name = in.readString();
|
||||||
|
usage = in.readInt();
|
||||||
|
nameOfUsage = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<PostFilterUsage> CREATOR = new Creator<PostFilterUsage>() {
|
||||||
|
@Override
|
||||||
|
public PostFilterUsage createFromParcel(Parcel in) {
|
||||||
|
return new PostFilterUsage(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PostFilterUsage[] newArray(int size) {
|
||||||
|
return new PostFilterUsage[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel parcel, int i) {
|
||||||
|
parcel.writeString(name);
|
||||||
|
parcel.writeInt(usage);
|
||||||
|
parcel.writeString(nameOfUsage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,22 @@
|
|||||||
package ml.docilealligator.infinityforreddit.postfilter;
|
package ml.docilealligator.infinityforreddit.postfilter;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.room.Dao;
|
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
|
@Dao
|
||||||
public interface PostFilterUsageDao {
|
public interface PostFilterUsageDao {
|
||||||
|
@Query("SELECT * FROM post_filter_usage WHERE name = :name")
|
||||||
|
LiveData<List<PostFilterUsage>> getAllPostFilterUsageLiveData(String name);
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insertPostFilterUsage(PostFilterUsage postFilterUsage);
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
void deletePostFilterUsage(PostFilterUsage postFilterUsage);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
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 PostFilterUsageViewModel extends ViewModel {
|
||||||
|
private LiveData<List<PostFilterUsage>> mPostFilterUsageListLiveData;
|
||||||
|
|
||||||
|
public PostFilterUsageViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String name) {
|
||||||
|
mPostFilterUsageListLiveData = redditDataRoomDatabase.postFilterUsageDao().getAllPostFilterUsageLiveData(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<PostFilterUsage>> getPostFilterUsageListLiveData() {
|
||||||
|
return mPostFilterUsageListLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends ViewModel> T create(Class<T> modelClass) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (T) new PostFilterUsageViewModel(mRedditDataRoomDatabase, mName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.postfilter;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class SavePostFilterUsage {
|
||||||
|
public static void savePostFilterUsage(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
|
||||||
|
PostFilterUsage postFilterUsage) {
|
||||||
|
executor.execute(() -> redditDataRoomDatabase.postFilterUsageDao().insertPostFilterUsage(postFilterUsage));
|
||||||
|
}
|
||||||
|
}
|
53
app/src/main/res/layout/activity_post_filter_application.xml
Normal file
53
app/src/main/res/layout/activity_post_filter_application.xml
Normal file
@ -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_application_activity"
|
||||||
|
tools:context=".activities.PostFilterUsageListingActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appbar_layout_post_filter_application_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_application_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_application_activity">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_post_filter_application_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_application_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_application_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>
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
|
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/theme_name_edit_text_edit_name_dialog"
|
android:id="@+id/name_edit_text_edit_name_dialog"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="24dp"
|
android:padding="24dp"
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
<?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="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="24dp"
|
||||||
|
android:text="@string/edit_post_filter_name_of_usage_info"
|
||||||
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="?attr/font_default"
|
||||||
|
android:fontFamily="?attr/font_family" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/text_input_layout_edit_post_filter_name_of_usage_dialog"
|
||||||
|
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/text_input_edit_text_edit_post_filter_name_of_usage_dialog"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
|
android:textSize="?attr/font_default" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,106 @@
|
|||||||
|
<?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/home_text_view_new_post_filter_usage_bottom_sheet_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/home"
|
||||||
|
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_home_black_24dp"
|
||||||
|
android:drawablePadding="48dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="?attr/selectableItemBackground" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/subreddit_text_view_new_post_filter_usage_bottom_sheet_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/subreddit"
|
||||||
|
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_subreddit_24dp"
|
||||||
|
android:drawablePadding="48dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="?attr/selectableItemBackground" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/user_text_view_new_post_filter_usage_bottom_sheet_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/user"
|
||||||
|
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_user_24dp"
|
||||||
|
android:drawablePadding="48dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="?attr/selectableItemBackground" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/multireddit_text_view_new_post_filter_usage_bottom_sheet_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/multi_reddit"
|
||||||
|
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_multi_reddit_24dp"
|
||||||
|
android:drawablePadding="48dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="?attr/selectableItemBackground" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/search_text_view_new_post_filter_usage_bottom_sheet_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/search"
|
||||||
|
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_search_24dp"
|
||||||
|
android:drawablePadding="48dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="?attr/selectableItemBackground" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
@ -0,0 +1,52 @@
|
|||||||
|
<?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_usage_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/delete_text_view_post_filter_usage_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>
|
14
app/src/main/res/layout/item_post_filter_usage.xml
Normal file
14
app/src/main/res/layout/item_post_filter_usage.xml
Normal file
@ -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" />
|
@ -979,5 +979,16 @@
|
|||||||
<string name="post_filter_name_hint">Post Filter Name</string>
|
<string name="post_filter_name_hint">Post Filter Name</string>
|
||||||
<string name="post_filter_requires_a_name">What is the name of this post filter?</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>
|
<string name="apply_post_filter_to">Apply to</string>
|
||||||
|
<string name="post_filter_usage_home">Home</string>
|
||||||
|
<string name="post_filter_usage_subreddit">Subreddit: %1$s</string>
|
||||||
|
<string name="post_filter_usage_subreddit_all">Subreddit</string>
|
||||||
|
<string name="post_filter_usage_user">User: %1$s</string>
|
||||||
|
<string name="post_filter_usage_user_all">User</string>
|
||||||
|
<string name="post_filter_usage_multireddit">MultiReddit: %1$s</string>
|
||||||
|
<string name="post_filter_usage_multireddit_all">MultiReddit</string>
|
||||||
|
<string name="post_filter_usage_search">Search</string>
|
||||||
|
<string name="subreddit">Subreddit</string>
|
||||||
|
<string name="user">User</string>
|
||||||
|
<string name="edit_post_filter_name_of_usage_info">Leave it blank to apply this post filter to all the subreddits / users / multireddits</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user