aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-12-22 15:56:20 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-12-22 15:56:20 +0000
commitefa960013ac2cbf3909e8f8867a1b9e2dd2791f2 (patch)
tree993f6b809d0b3b8a5f73814ab487c81a542772bd /app/src
parent71a7852c79f145a27b9d22a7ce56540ec2d45831 (diff)
downloadinfinity-for-reddit-efa960013ac2cbf3909e8f8867a1b9e2dd2791f2.tar
infinity-for-reddit-efa960013ac2cbf3909e8f8867a1b9e2dd2791f2.tar.gz
infinity-for-reddit-efa960013ac2cbf3909e8f8867a1b9e2dd2791f2.tar.bz2
infinity-for-reddit-efa960013ac2cbf3909e8f8867a1b9e2dd2791f2.tar.lz
infinity-for-reddit-efa960013ac2cbf3909e8f8867a1b9e2dd2791f2.tar.xz
infinity-for-reddit-efa960013ac2cbf3909e8f8867a1b9e2dd2791f2.tar.zst
infinity-for-reddit-efa960013ac2cbf3909e8f8867a1b9e2dd2791f2.zip
New option in FAB: Filter Posts. Add Gif option in PostFilter.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java61
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java2
-rw-r--r--app/src/main/res/layout/activity_customize_post_filter.xml30
-rw-r--r--app/src/main/res/layout/activity_filtered_thing.xml1
-rw-r--r--app/src/main/res/layout/fragment_fab_more_options_bottom_sheet.xml19
-rw-r--r--app/src/main/res/values/strings.xml3
15 files changed, 224 insertions, 25 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
index 29675703..7c7f450c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
@@ -41,4 +41,8 @@ public interface FragmentCommunicator {
default void changePostFilter(PostFilter postFilter) {
}
+
+ default void filterPosts() {
+
+ };
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
index d6842991..4b06c261 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
@@ -28,6 +28,7 @@ public class PostFilter implements Parcelable {
public boolean containsTextType = true;
public boolean containsLinkType = true;
public boolean containsImageType = true;
+ public boolean containsGifType = true;
public boolean containsVideoType = true;
public boolean containsGalleryType = true;
@@ -72,6 +73,9 @@ public class PostFilter implements Parcelable {
if (!postFilter.containsImageType && post.getPostType() == Post.IMAGE_TYPE) {
return false;
}
+ if (!postFilter.containsGifType && post.getPostType() == Post.GIF_TYPE) {
+ return false;
+ }
if (!postFilter.containsVideoType && post.getPostType() == Post.VIDEO_TYPE) {
return false;
}
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 0f3b2b38..8fef2ae8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
@@ -65,6 +65,12 @@ public class CustomizePostFilterActivity extends BaseActivity {
TextView postTypeImageTextView;
@BindView(R.id.post_type_image_check_box_customize_post_filter_activity)
MaterialCheckBox postTypeImageCheckBox;
+ @BindView(R.id.post_type_gif_linear_layout_customize_post_filter_activity)
+ LinearLayout postTypeGifLinearLayout;
+ @BindView(R.id.post_type_gif_text_view_customize_post_filter_activity)
+ TextView postTypeGifTextView;
+ @BindView(R.id.post_type_gif_check_box_customize_post_filter_activity)
+ MaterialCheckBox postTypeGifCheckBox;
@BindView(R.id.post_type_video_linear_layout_customize_post_filter_activity)
LinearLayout postTypeVideoLinearLayout;
@BindView(R.id.post_type_video_text_view_customize_post_filter_activity)
@@ -182,6 +188,10 @@ public class CustomizePostFilterActivity extends BaseActivity {
postTypeImageCheckBox.performClick();
});
+ postTypeGifLinearLayout.setOnClickListener(view -> {
+ postTypeGifCheckBox.performClick();
+ });
+
postTypeVideoLinearLayout.setOnClickListener(view -> {
postTypeVideoCheckBox.performClick();
});
@@ -217,6 +227,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
postTypeTextTextView.setTextColor(primaryTextColor);
postTypeLinkTextView.setTextColor(primaryTextColor);
postTypeImageTextView.setTextColor(primaryTextColor);
+ postTypeGifTextView.setTextColor(primaryTextColor);
postTypeVideoTextView.setTextColor(primaryTextColor);
postTypeGalleryTextView.setTextColor(primaryTextColor);
onlyNSFWTextView.setTextColor(primaryTextColor);
@@ -288,6 +299,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
postFilter.containsTextType = postTypeTextCheckBox.isChecked();
postFilter.containsLinkType = postTypeLinkCheckBox.isChecked();
postFilter.containsImageType = postTypeImageCheckBox.isChecked();
+ postFilter.containsGifType = postTypeGifCheckBox.isChecked();
postFilter.containsVideoType = postTypeVideoCheckBox.isChecked();
postFilter.containsGalleryType = postTypeGalleryCheckBox.isChecked();
postFilter.onlyNSFW = onlyNSFWSwitch.isChecked();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java
index 633683f3..bd855e40 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java
@@ -161,47 +161,58 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
name = getIntent().getStringExtra(EXTRA_NAME);
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
- int filter = getIntent().getIntExtra(EXTRA_FILTER, Post.TEXT_TYPE);
- switch (filter) {
- case Post.NSFW_TYPE:
- toolbar.setSubtitle(R.string.nsfw);
- break;
- case Post.TEXT_TYPE:
- toolbar.setSubtitle(R.string.text);
- break;
- case Post.LINK_TYPE:
- case Post.NO_PREVIEW_LINK_TYPE:
- toolbar.setSubtitle(R.string.link);
- break;
- case Post.IMAGE_TYPE:
- toolbar.setSubtitle(R.string.image);
- break;
- case Post.VIDEO_TYPE:
- toolbar.setSubtitle(R.string.video);
- break;
- case Post.GIF_TYPE:
- toolbar.setSubtitle(R.string.gif);
- break;
- case Post.GALLERY_TYPE:
- toolbar.setSubtitle(R.string.gallery);
- }
+ int filter = getIntent().getIntExtra(EXTRA_FILTER, -1000);
PostFilter postFilter = new PostFilter();
switch (filter) {
case Post.NSFW_TYPE:
postFilter.onlyNSFW = true;
+ break;
case Post.TEXT_TYPE:
postFilter.containsTextType = true;
+ postFilter.containsLinkType = false;
+ postFilter.containsImageType = false;
+ postFilter.containsGifType = false;
+ postFilter.containsVideoType = false;
+ postFilter.containsGalleryType = false;
break;
case Post.LINK_TYPE:
+ postFilter.containsTextType = false;
postFilter.containsLinkType = true;
+ postFilter.containsImageType = false;
+ postFilter.containsGifType = false;
+ postFilter.containsVideoType = false;
+ postFilter.containsGalleryType = false;
break;
case Post.IMAGE_TYPE:
+ postFilter.containsTextType = false;
+ postFilter.containsLinkType = false;
postFilter.containsImageType = true;
+ postFilter.containsGifType = false;
+ postFilter.containsVideoType = false;
+ postFilter.containsGalleryType = false;
+ break;
+ case Post.GIF_TYPE:
+ postFilter.containsTextType = false;
+ postFilter.containsLinkType = false;
+ postFilter.containsImageType = false;
+ postFilter.containsGifType = true;
+ postFilter.containsVideoType = false;
+ postFilter.containsGalleryType = false;
break;
case Post.VIDEO_TYPE:
+ postFilter.containsTextType = false;
+ postFilter.containsLinkType = false;
+ postFilter.containsImageType = false;
+ postFilter.containsGifType = false;
postFilter.containsVideoType = true;
+ postFilter.containsGalleryType = false;
break;
case Post.GALLERY_TYPE:
+ postFilter.containsTextType = false;
+ postFilter.containsLinkType = false;
+ postFilter.containsImageType = false;
+ postFilter.containsGifType = false;
+ postFilter.containsVideoType = false;
postFilter.containsGalleryType = true;
break;
}
@@ -453,7 +464,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
if (mFragment != null) {
- ((PostFragment) mFragment).changePostFilter(data.getParcelableExtra(CustomizePostFilterActivity.RETURN_EXTRA_POST_FILTER));
+ mFragment.changePostFilter(data.getParcelableExtra(CustomizePostFilterActivity.RETURN_EXTRA_POST_FILTER));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 15de5a52..2d139293 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -594,6 +594,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
break;
+ case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
+ fab.setImageResource(R.drawable.ic_filter_24dp);
+ break;
default:
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
break;
@@ -633,6 +636,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
sectionsPagerAdapter.hideReadPosts();
}
break;
+ case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.filterPosts();
+ }
+ break;
default:
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
break;
@@ -1213,6 +1221,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
break;
}
+ case FABMoreOptionsBottomSheetFragment.FAB_FILTER_POSTS: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.filterPosts();
+ }
+ break;
+ }
}
}
@@ -1536,5 +1550,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
currentFragment.hideReadPosts();
}
}
+
+ void filterPosts() {
+ PostFragment currentFragment = getCurrentFragment();
+ if (currentFragment != null) {
+ currentFragment.filterPosts();
+ }
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 70cea4fb..1771b8dc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -713,6 +713,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
+ fab.setImageResource(R.drawable.ic_filter_24dp);
+ break;
default:
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
break;
@@ -753,6 +756,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
sectionsPagerAdapter.hideReadPosts();
}
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.filterPosts();
+ }
+ break;
default:
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
break;
@@ -1136,6 +1144,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts();
}
+ break;
+ }
+ case FABMoreOptionsBottomSheetFragment.FAB_FILTER_POSTS: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.filterPosts();
+ }
+ break;
}
}
}
@@ -1334,6 +1349,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
}
+ void filterPosts() {
+ if (fragmentManager != null) {
+ Fragment fragment = fragmentManager.findFragmentByTag("f0");
+ if (fragment instanceof PostFragment) {
+ ((PostFragment) fragment).filterPosts();
+ }
+ }
+ }
+
@Override
public int getItemCount() {
return 2;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index c871f8e7..3ddf99f5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -736,6 +736,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
+ fab.setImageResource(R.drawable.ic_filter_24dp);
+ break;
default:
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
break;
@@ -775,6 +778,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
sectionsPagerAdapter.hideReadPosts();
}
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.filterPosts();
+ }
+ break;
default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@@ -1108,6 +1116,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.hideReadPosts();
}
+ break;
+ }
+ case FABMoreOptionsBottomSheetFragment.FAB_FILTER_POSTS: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.filterPosts();
+ }
+ break;
}
}
}
@@ -1445,6 +1460,15 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
}
}
+
+ void filterPosts() {
+ if (fragmentManager != null) {
+ Fragment fragment = fragmentManager.findFragmentByTag("f0");
+ if (fragment instanceof PostFragment) {
+ ((PostFragment) fragment).filterPosts();
+ }
+ }
+ }
}
private void lockSwipeRightToGoBack() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java
index a7311736..3dccf361 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java
@@ -26,6 +26,7 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
public static final int FAB_OPTION_GO_TO_USER = 6;
public static final int FAB_RANDOM = 7;
public static final int FAB_HIDE_READ_POSTS = 8;
+ public static final int FAB_FILTER_POSTS = 9;
@BindView(R.id.submit_post_text_view_fab_more_options_bottom_sheet_fragment)
TextView submitPostTextView;
@@ -45,6 +46,8 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
TextView randomTextView;
@BindView(R.id.hide_read_posts_text_view_fab_more_options_bottom_sheet_fragment)
TextView hideReadPostsTextView;
+ @BindView(R.id.filter_posts_text_view_fab_more_options_bottom_sheet_fragment)
+ TextView filterPostsTextView;
private FABOptionSelectionCallback activity;
public FABMoreOptionsBottomSheetFragment() {
@@ -104,6 +107,11 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
dismiss();
});
+ filterPostsTextView.setOnClickListener(view -> {
+ activity.fabOptionSelected(FAB_FILTER_POSTS);
+ dismiss();
+ });
+
return rootView;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 0757b5da..6edeb8e8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -1257,6 +1257,38 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Override
+ public void filterPosts() {
+ if (postType == PostDataSource.TYPE_SEARCH) {
+ 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);
+ startActivity(intent);
+ } else if (postType == PostDataSource.TYPE_SUBREDDIT) {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ startActivity(intent);
+ } else if(postType == PostDataSource.TYPE_MULTI_REDDIT) {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditPath);
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ startActivity(intent);
+ } else if (postType == PostDataSource.TYPE_USER) {
+ 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);
+ startActivity(intent);
+ } else {
+ Intent intent = new Intent(activity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, activity.getString(R.string.best));
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ startActivity(intent);
+ }
+ }
+
@Subscribe
public void onPostUpdateEvent(PostUpdateEventToPostList event) {
PagedList<Post> posts = mAdapter.getCurrentList();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
index 96b0ef7b..b55c9277 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
@@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.post;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.Html;
+import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
@@ -247,6 +248,9 @@ public class ParsePost {
//Video post
JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY);
int postType = Post.VIDEO_TYPE;
+ if (!redditVideoObject.has(JSONUtils.HLS_URL_KEY)) {
+ Log.i("afasd", "s " + redditVideoObject);
+ }
String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString();
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
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 7f5389b6..5751af30 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -196,6 +196,7 @@ public class SharedPreferencesUtils {
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_USER = 6;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_RANDOM = 7;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS = 8;
+ public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS = 9;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME = 0;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS = 1;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_INBOX = 2;
@@ -210,6 +211,7 @@ public class SharedPreferencesUtils {
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_USER = 6;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM = 7;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS = 8;
+ public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS = 9;
public static final String NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.nsfw_and_spoiler";
public static final String NSFW_BASE = "_nsfw";
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 571f9509..72aeb6bc 100644
--- a/app/src/main/res/layout/activity_customize_post_filter.xml
+++ b/app/src/main/res/layout/activity_customize_post_filter.xml
@@ -134,6 +134,36 @@
</LinearLayout>
<LinearLayout
+ android:id="@+id/post_type_gif_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="8dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <TextView
+ android:id="@+id/post_type_gif_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/post_type_gif"
+ android:fontFamily="?attr/font_default"
+ android:textSize="?attr/font_default" />
+
+ <com.google.android.material.checkbox.MaterialCheckBox
+ android:id="@+id/post_type_gif_check_box_customize_post_filter_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical" />
+
+ </LinearLayout>
+
+ <LinearLayout
android:id="@+id/post_type_video_linear_layout_customize_post_filter_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/app/src/main/res/layout/activity_filtered_thing.xml b/app/src/main/res/layout/activity_filtered_thing.xml
index 59b857af..5aa0207b 100644
--- a/app/src/main/res/layout/activity_filtered_thing.xml
+++ b/app/src/main/res/layout/activity_filtered_thing.xml
@@ -26,6 +26,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
+ app:subtitle="@string/filtered_posts_activity_subtitle"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:navigationIcon="?attr/homeAsUpIndicator" />
diff --git a/app/src/main/res/layout/fragment_fab_more_options_bottom_sheet.xml b/app/src/main/res/layout/fragment_fab_more_options_bottom_sheet.xml
index 6a0773b2..3fd3c62b 100644
--- a/app/src/main/res/layout/fragment_fab_more_options_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_fab_more_options_bottom_sheet.xml
@@ -182,6 +182,25 @@
android:focusable="true"
android:background="?attr/selectableItemBackground" />
+ <TextView
+ android:id="@+id/filter_posts_text_view_fab_more_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/filter_posts"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ app:drawableStartCompat="@drawable/ic_filter_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/values/strings.xml b/app/src/main/res/values/strings.xml
index 17bb15bc..0843d94e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -35,6 +35,7 @@
<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="filtered_posts_activity_subtitle">Filtered Posts</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
@@ -199,6 +200,7 @@
<string name="bottom_sheet_post_link">Link</string>
<string name="bottom_sheet_post_image">Image</string>
<string name="bottom_sheet_post_video">Video</string>
+ <string name="post_type_gif">Gif</string>
<string name="post_type_gallery">Gallery</string>
<string name="select_from_gallery">Select a picture</string>
@@ -952,6 +954,7 @@
<string name="select_video_quality">Select Video Quality</string>
<string name="hide_read_posts">Hide Read Posts</string>
+ <string name="filter_posts">Filter Posts</string>
<string name="only_nsfw">Only NSFW</string>
<string name="only_spoiler">Only Spoiler</string>