mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 12:57:12 +01:00
Add only NSFW and only Spoiler options in CustomizePostFilterActivity. Fix nsfwTextView OnClickListener in PostRecyclerViewAdapter.
This commit is contained in:
parent
f4d061cecc
commit
71a7852c79
@ -18,6 +18,7 @@ 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.switchmaterial.SwitchMaterial;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
@ -76,6 +77,18 @@ public class CustomizePostFilterActivity extends BaseActivity {
|
||||
TextView postTypeGalleryTextView;
|
||||
@BindView(R.id.post_type_gallery_check_box_customize_post_filter_activity)
|
||||
MaterialCheckBox postTypeGalleryCheckBox;
|
||||
@BindView(R.id.only_nsfw_linear_layout_customize_post_filter_activity)
|
||||
LinearLayout onlyNSFWLinearLayout;
|
||||
@BindView(R.id.only_nsfw_text_view_customize_post_filter_activity)
|
||||
TextView onlyNSFWTextView;
|
||||
@BindView(R.id.only_nsfw_switch_customize_post_filter_activity)
|
||||
SwitchMaterial onlyNSFWSwitch;
|
||||
@BindView(R.id.only_spoiler_linear_layout_customize_post_filter_activity)
|
||||
LinearLayout onlySpoilerLinearLayout;
|
||||
@BindView(R.id.only_spoiler_text_view_customize_post_filter_activity)
|
||||
TextView onlySpoilerTextView;
|
||||
@BindView(R.id.only_spoiler_switch_customize_post_filter_activity)
|
||||
SwitchMaterial onlySpoilerSwitch;
|
||||
@BindView(R.id.title_excludes_strings_text_input_layout_customize_post_filter_activity)
|
||||
TextInputLayout titleExcludesStringsTextInputLayout;
|
||||
@BindView(R.id.title_excludes_strings_text_input_edit_text_customize_post_filter_activity)
|
||||
@ -176,6 +189,14 @@ public class CustomizePostFilterActivity extends BaseActivity {
|
||||
postTypeGalleryLinearLayout.setOnClickListener(view -> {
|
||||
postTypeGalleryCheckBox.performClick();
|
||||
});
|
||||
|
||||
onlyNSFWLinearLayout.setOnClickListener(view -> {
|
||||
onlyNSFWSwitch.performClick();
|
||||
});
|
||||
|
||||
onlySpoilerLinearLayout.setOnClickListener(view -> {
|
||||
onlySpoilerSwitch.performClick();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -198,6 +219,8 @@ public class CustomizePostFilterActivity extends BaseActivity {
|
||||
postTypeImageTextView.setTextColor(primaryTextColor);
|
||||
postTypeVideoTextView.setTextColor(primaryTextColor);
|
||||
postTypeGalleryTextView.setTextColor(primaryTextColor);
|
||||
onlyNSFWTextView.setTextColor(primaryTextColor);
|
||||
onlySpoilerTextView.setTextColor(primaryTextColor);
|
||||
titleExcludesStringsTextInputLayout.setBoxStrokeColor(primaryTextColor);
|
||||
titleExcludesStringsTextInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||
titleExcludesStringsTextInputEditText.setTextColor(primaryTextColor);
|
||||
@ -267,6 +290,8 @@ public class CustomizePostFilterActivity extends BaseActivity {
|
||||
postFilter.containsImageType = postTypeImageCheckBox.isChecked();
|
||||
postFilter.containsVideoType = postTypeVideoCheckBox.isChecked();
|
||||
postFilter.containsGalleryType = postTypeGalleryCheckBox.isChecked();
|
||||
postFilter.onlyNSFW = onlyNSFWSwitch.isChecked();
|
||||
postFilter.onlySpoiler = onlySpoilerSwitch.isChecked();
|
||||
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(RETURN_EXTRA_POST_FILTER, postFilter);
|
||||
|
@ -187,6 +187,8 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
||||
}
|
||||
PostFilter postFilter = new PostFilter();
|
||||
switch (filter) {
|
||||
case Post.NSFW_TYPE:
|
||||
postFilter.onlyNSFW = true;
|
||||
case Post.TEXT_TYPE:
|
||||
postFilter.containsTextType = true;
|
||||
break;
|
||||
|
@ -1444,6 +1444,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
|
||||
void typeChipClicked(int filter);
|
||||
|
||||
void nsfwChipClicked();
|
||||
|
||||
void currentlyBindItem(int position);
|
||||
|
||||
void delayTransition();
|
||||
@ -1668,11 +1670,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
|
||||
mActivity.startActivity(intent);
|
||||
mCallback.nsfwChipClicked();
|
||||
}
|
||||
});
|
||||
typeTextView.setOnClickListener(view -> {
|
||||
@ -2658,11 +2656,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}
|
||||
Post post = getItem(position);
|
||||
if (post != null && !(mActivity instanceof FilteredThingActivity)) {
|
||||
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
|
||||
mActivity.startActivity(intent);
|
||||
mCallback.nsfwChipClicked();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -483,6 +483,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_QUERY, query);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentlyBindItem(int position) {
|
||||
if (maxPosition < position) {
|
||||
@ -531,6 +541,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentlyBindItem(int position) {
|
||||
if (maxPosition < position) {
|
||||
@ -581,6 +600,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditPath);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentlyBindItem(int position) {
|
||||
if (maxPosition < position) {
|
||||
@ -630,6 +658,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, username);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_USER_WHERE, where);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentlyBindItem(int position) {
|
||||
if (maxPosition < position) {
|
||||
@ -670,6 +708,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, activity.getString(R.string.best));
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentlyBindItem(int position) {
|
||||
if (maxPosition < position) {
|
||||
|
@ -193,6 +193,66 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/only_nsfw_linear_layout_customize_post_filter_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/only_nsfw_text_view_customize_post_filter_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/only_nsfw"
|
||||
android:fontFamily="?attr/font_default"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/only_nsfw_switch_customize_post_filter_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/only_spoiler_linear_layout_customize_post_filter_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/only_spoiler_text_view_customize_post_filter_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/only_spoiler"
|
||||
android:fontFamily="?attr/font_default"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/only_spoiler_switch_customize_post_filter_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/title_excludes_strings_text_input_layout_customize_post_filter_activity"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -953,6 +953,8 @@
|
||||
|
||||
<string name="hide_read_posts">Hide Read Posts</string>
|
||||
|
||||
<string name="only_nsfw">Only NSFW</string>
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user