From 7c68239272113e6c913a54723f4196f3d0fb0acc Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:52:28 -0500 Subject: Start implementing showing gifs and images in comments. --- .../infinityforreddit/MediaMetadata.java | 119 +++++++++++++++++++++ .../activities/AccountPostsActivity.java | 2 +- .../activities/AccountSavedThingActivity.java | 2 +- .../infinityforreddit/activities/BaseActivity.java | 2 +- .../activities/CommentActivity.java | 6 +- .../CommentFilterPreferenceActivity.java | 2 +- .../CommentFilterUsageListingActivity.java | 2 +- .../activities/CreateMultiRedditActivity.java | 2 +- .../activities/CustomThemeListingActivity.java | 2 +- .../activities/CustomizeCommentFilterActivity.java | 2 +- .../activities/CustomizePostFilterActivity.java | 2 +- .../activities/CustomizeThemeActivity.java | 2 +- .../activities/EditCommentActivity.java | 2 +- .../activities/EditMultiRedditActivity.java | 2 +- .../activities/EditPostActivity.java | 2 +- .../activities/EditProfileActivity.java | 2 +- .../FetchRandomSubredditOrPostActivity.java | 2 +- .../activities/FilteredPostsActivity.java | 2 +- .../activities/FullMarkdownActivity.java | 6 +- .../activities/HistoryActivity.java | 2 +- .../activities/InboxActivity.java | 2 +- .../activities/LockScreenActivity.java | 2 +- .../activities/LoginActivity.java | 2 +- .../infinityforreddit/activities/MainActivity.java | 2 +- .../activities/MultiredditSelectionActivity.java | 2 +- .../activities/PostFilterPreferenceActivity.java | 2 +- .../activities/PostFilterUsageListingActivity.java | 2 +- .../activities/PostGalleryActivity.java | 2 +- .../activities/PostImageActivity.java | 2 +- .../activities/PostLinkActivity.java | 2 +- .../activities/PostPollActivity.java | 2 +- .../activities/PostTextActivity.java | 2 +- .../activities/PostVideoActivity.java | 2 +- .../activities/ReportActivity.java | 2 +- .../activities/RulesActivity.java | 2 +- .../activities/SearchActivity.java | 2 +- .../activities/SearchResultActivity.java | 2 +- .../activities/SearchSubredditsResultActivity.java | 2 +- .../activities/SearchUsersResultActivity.java | 2 +- .../activities/SelectUserFlairActivity.java | 2 +- .../SelectedSubredditsAndUsersActivity.java | 2 +- .../activities/SendPrivateMessageActivity.java | 2 +- .../activities/SettingsActivity.java | 2 +- .../activities/SubmitCrosspostActivity.java | 2 +- .../SubredditMultiselectionActivity.java | 2 +- .../activities/SubredditSelectionActivity.java | 2 +- .../activities/SubscribedThingListingActivity.java | 2 +- .../activities/SuicidePreventionActivity.java | 2 +- .../activities/TrendingActivity.java | 2 +- .../activities/ViewMultiRedditDetailActivity.java | 2 +- .../activities/ViewPostDetailActivity.java | 2 +- .../activities/ViewPrivateMessagesActivity.java | 2 +- .../activities/ViewSubredditDetailActivity.java | 2 +- .../activities/ViewUserDetailActivity.java | 11 +- .../activities/WebViewActivity.java | 2 +- .../infinityforreddit/activities/WikiActivity.java | 6 +- .../CommentsListingRecyclerViewAdapter.java | 48 ++++++--- .../adapters/CommentsRecyclerViewAdapter.java | 31 +++++- .../adapters/RulesRecyclerViewAdapter.java | 4 +- .../infinityforreddit/comment/Comment.java | 27 +++-- .../infinityforreddit/comment/ParseComment.java | 63 ++++++++++- .../customviews/CustomMarkwonAdapter.java | 5 + .../fragments/CommentsListingFragment.java | 24 +++-- .../fragments/SidebarFragment.java | 4 +- .../fragments/ViewPostDetailFragment.java | 3 + .../markdown/ImageAndGifBlock.java | 6 +- .../markdown/ImageAndGifBlockParser.java | 17 ++- .../markdown/ImageAndGifEntry.java | 65 ++++------- .../markdown/ImageAndGifPlugin.java | 7 +- .../infinityforreddit/markdown/MarkdownUtils.java | 3 +- .../infinityforreddit/post/ParsePost.java | 23 ++-- .../infinityforreddit/post/Post.java | 96 +---------------- .../infinityforreddit/utils/Utils.java | 13 +-- 73 files changed, 411 insertions(+), 278 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/MediaMetadata.java (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MediaMetadata.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MediaMetadata.java new file mode 100644 index 00000000..3a75e6c1 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MediaMetadata.java @@ -0,0 +1,119 @@ +package ml.docilealligator.infinityforreddit; + +import android.net.Uri; +import android.os.Parcel; +import android.os.Parcelable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public class MediaMetadata implements Parcelable { + public String id; + //E.g. Image + public String e; + public String fileName; + public boolean isGIF; + public MediaItem original; + public MediaItem downscaled; + + public MediaMetadata(String id, String e, MediaItem original, MediaItem downscaled) { + this.id = id; + this.e = e; + isGIF = !e.equalsIgnoreCase("image"); + String path = Uri.parse(original.url).getPath(); + this.fileName = path == null ? (isGIF ? "Animated.gif" : "Image.jpg") : path.substring(1); + this.original = original; + this.downscaled = downscaled; + } + + protected MediaMetadata(Parcel in) { + id = in.readString(); + e = in.readString(); + fileName = in.readString(); + isGIF = in.readByte() != 0; + original = in.readParcelable(MediaItem.class.getClassLoader()); + downscaled = in.readParcelable(MediaItem.class.getClassLoader()); + } + + public static final Creator CREATOR = new Creator() { + @Override + public MediaMetadata createFromParcel(Parcel in) { + return new MediaMetadata(in); + } + + @Override + public MediaMetadata[] newArray(int size) { + return new MediaMetadata[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeString(id); + dest.writeString(e); + dest.writeString(fileName); + dest.writeByte((byte) (isGIF ? 1 : 0)); + dest.writeParcelable(original, flags); + dest.writeParcelable(downscaled, flags); + } + + public static class MediaItem implements Parcelable { + public int x; + public int y; + //Image or gif + public String url; + //Only for gifs + @Nullable + public String mp4Url; + + public MediaItem(int x, int y, String url) { + this.x = x; + this.y = y; + this.url = url; + } + + public MediaItem(int x, int y, String url, String mp4Url) { + this.x = x; + this.y = y; + this.url = url; + this.mp4Url = mp4Url; + } + + protected MediaItem(Parcel in) { + x = in.readInt(); + y = in.readInt(); + url = in.readString(); + mp4Url = in.readString(); + } + + public static final Creator CREATOR = new Creator() { + @Override + public MediaItem createFromParcel(Parcel in) { + return new MediaItem(in); + } + + @Override + public MediaItem[] newArray(int size) { + return new MediaItem[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeInt(x); + dest.writeInt(y); + dest.writeString(url); + dest.writeString(mp4Url); + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java index e66bb9ea..1f5d229c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java @@ -136,7 +136,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java index cc4e3eb6..5c99c275 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java @@ -139,7 +139,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java index 40a81378..a9b49c95 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java @@ -227,7 +227,7 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo public abstract SharedPreferences getDefaultSharedPreferences(); - protected abstract CustomThemeWrapper getCustomThemeWrapper(); + public abstract CustomThemeWrapper getCustomThemeWrapper(); protected abstract void applyCustomTheme(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java index 3ad2c699..6096f1c4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java @@ -49,6 +49,7 @@ import io.noties.markwon.recycler.MarkwonAdapter; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import ml.docilealligator.infinityforreddit.AnyAccountAccessTokenAuthenticator; import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.UploadImageEnabledActivity; @@ -67,7 +68,6 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; -import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; import okhttp3.ConnectionPool; @@ -215,7 +215,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA miscPlugin, imageAndGifPlugin, parentTextColor, parentSpoilerBackgroundColor, null); MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter(new ImageAndGifEntry(this, mGlide, new ImageAndGifEntry.OnItemClickListener() { @Override - public void onItemClick(Post.MediaMetadata mediaMetadata) { + public void onItemClick(MediaMetadata mediaMetadata) { } })); @@ -318,7 +318,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java index 11a1aa9a..b4d1fb8d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java @@ -143,7 +143,7 @@ public class CommentFilterPreferenceActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return customThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java index 2a05936f..fc5dac54 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java @@ -165,7 +165,7 @@ public class CommentFilterUsageListingActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return customThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java index 9bc280e2..9f07ddc3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java @@ -222,7 +222,7 @@ public class CreateMultiRedditActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java index 3e983761..4a87a47b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java @@ -147,7 +147,7 @@ public class CustomThemeListingActivity extends BaseActivity implements } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return customThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java index 991bc7a9..77534e7c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java @@ -157,7 +157,7 @@ public class CustomizeCommentFilterActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } 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 815f89ee..f2581883 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java @@ -375,7 +375,7 @@ public class CustomizePostFilterActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java index 1372c235..22f66c27 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java @@ -250,7 +250,7 @@ public class CustomizeThemeActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return customThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java index 661c568d..caa8fcac 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java @@ -172,7 +172,7 @@ public class EditCommentActivity extends BaseActivity implements UploadImageEnab } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java index ab214588..11322efc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java @@ -278,7 +278,7 @@ public class EditMultiRedditActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java index 5e022426..13a6434d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java @@ -181,7 +181,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java index 96bfcad3..4d57dd00 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java @@ -336,7 +336,7 @@ public class EditProfileActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java index e5e8a3b8..050dc613 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java @@ -94,7 +94,7 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java index 1305733b..b5a00239 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java @@ -254,7 +254,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java index e6084948..92d6589c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java @@ -37,6 +37,7 @@ import io.noties.markwon.MarkwonPlugin; import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.recycler.MarkwonAdapter; import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; @@ -47,7 +48,6 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; -import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class FullMarkdownActivity extends BaseActivity { @@ -149,7 +149,7 @@ public class FullMarkdownActivity extends BaseActivity { MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter(new ImageAndGifEntry(this, Glide.with(this), new ImageAndGifEntry.OnItemClickListener() { @Override - public void onItemClick(Post.MediaMetadata mediaMetadata) { + public void onItemClick(MediaMetadata mediaMetadata) { } })); @@ -205,7 +205,7 @@ public class FullMarkdownActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java index 986e82f8..3a3a938e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java @@ -140,7 +140,7 @@ public class HistoryActivity extends BaseActivity implements ActivityToolbarInte } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java index 38ecb45e..0a02d0e6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java @@ -218,7 +218,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java index 0224648c..d4e44233 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java @@ -89,7 +89,7 @@ public class LockScreenActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java index 5171ee04..7b1cb7cc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java @@ -307,7 +307,7 @@ public class LoginActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } 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 d91d1c87..12a1dfce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -353,7 +353,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java index c8d99a0b..25108607 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java @@ -135,7 +135,7 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java index e54b9730..92108ae3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java @@ -213,7 +213,7 @@ public class PostFilterPreferenceActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return customThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java index 37759e57..80f317dc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java @@ -199,7 +199,7 @@ public class PostFilterUsageListingActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return customThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java index b5a63083..1d980bae 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -424,7 +424,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java index 3c76b394..a1620880 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java @@ -426,7 +426,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java index caa5c873..3bfb4573 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java @@ -401,7 +401,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java index 1b9e3cc3..3ba6983c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java @@ -405,7 +405,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java index 58968bc3..6205d54a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java @@ -423,7 +423,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java index 7289835d..f405ad4c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java @@ -443,7 +443,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java index 4f928827..58948363 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java @@ -189,7 +189,7 @@ public class ReportActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java index 54991517..7ffa36a5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java @@ -161,7 +161,7 @@ public class RulesActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index 5e3426f8..fdedff7d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -398,7 +398,7 @@ public class SearchActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index dc3da1d5..06a2567a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -226,7 +226,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java index bef51c3e..58a098ba 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java @@ -131,7 +131,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java index 86f064e0..376f2975 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java @@ -130,7 +130,7 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java index 1dc61d96..1a0930fb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java @@ -224,7 +224,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java index bc89f1de..aa782922 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java @@ -186,7 +186,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java index 0f12c15c..9bc8b422 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java @@ -167,7 +167,7 @@ public class SendPrivateMessageActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java index e0b584b4..801dd5a5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java @@ -120,7 +120,7 @@ public class SettingsActivity extends BaseActivity implements } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java index 97c82b66..c72ad868 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java @@ -434,7 +434,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java index 0a36fe79..4c3fe53a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java @@ -220,7 +220,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java index 0fe3a7f6..297c80b7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java @@ -176,7 +176,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java index 83df55cd..979e0731 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -207,7 +207,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java index 82f27104..4be5bdd2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java @@ -73,7 +73,7 @@ public class SuicidePreventionActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java index c4ecdcfc..053f6be9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java @@ -319,7 +319,7 @@ public class TrendingActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index 0b836895..e51058b3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -830,7 +830,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java index 76fec098..e88f9e22 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java @@ -324,7 +324,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java index a32fc8cc..1946aacb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java @@ -302,7 +302,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } 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 521b0dd1..9101cfbc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -508,7 +508,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } 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 2fb72f3f..52fedcb7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -594,7 +594,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } @@ -1708,15 +1708,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } } - void giveAward(String awardsHTML, int position) { - if (fragmentManager != null) { - Fragment fragment = fragmentManager.findFragmentByTag("f1"); - if (fragment instanceof CommentsListingFragment) { - ((CommentsListingFragment) fragment).giveAward(awardsHTML, position); - } - } - } - void editComment(String commentMarkdown, int position) { if (fragmentManager != null) { Fragment fragment = fragmentManager.findFragmentByTag("f1"); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java index adff13a1..87d66393 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java @@ -115,7 +115,7 @@ public class WebViewActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java index 714dc5c1..16c1c748 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java @@ -43,6 +43,7 @@ import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.recycler.MarkwonAdapter; import me.saket.bettermovementmethod.BetterLinkMovementMethod; import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.apis.RedditAPI; import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment; @@ -55,7 +56,6 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; -import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -186,7 +186,7 @@ public class WikiActivity extends BaseActivity { markwonAdapter = MarkdownUtils.createTablesAdapter(new ImageAndGifEntry(this, mGlide, new ImageAndGifEntry.OnItemClickListener() { @Override - public void onItemClick(Post.MediaMetadata mediaMetadata) { + public void onItemClick(MediaMetadata mediaMetadata) { } })); @@ -301,7 +301,7 @@ public class WikiActivity extends BaseActivity { } @Override - protected CustomThemeWrapper getCustomThemeWrapper() { + public CustomThemeWrapper getCustomThemeWrapper() { return mCustomThemeWrapper; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java index 76c0cc64..5abbbe8c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java @@ -24,6 +24,7 @@ import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; +import com.bumptech.glide.Glide; import com.google.android.material.button.MaterialButton; import java.util.Locale; @@ -36,12 +37,14 @@ import io.noties.markwon.MarkwonConfiguration; import io.noties.markwon.MarkwonPlugin; import io.noties.markwon.core.MarkwonTheme; import me.saket.bettermovementmethod.BetterLinkMovementMethod; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.VoteThing; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; +import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity; import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.bottomsheetfragments.CommentMoreBottomSheetFragment; @@ -55,6 +58,7 @@ import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView; import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager; import ml.docilealligator.infinityforreddit.databinding.ItemCommentBinding; +import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils; @@ -82,6 +86,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter= 0 && position < getItemCount()) { - Comment comment = getItem(position); - if (comment != null) { - comment.addAwards(awardsHTML); - notifyItemChanged(position); - } - } - } - public void editComment(String commentContentMarkdown, int position) { Comment comment = getItem(position); if (comment != null) { @@ -345,6 +360,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter { if (view instanceof SpoilerOnClickTextView) { if (((SpoilerOnClickTextView) view).isSpoilerOnClick()) { @@ -541,7 +560,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter= 0 && position < mVisibleComments.size()) { int childDepth = mVisibleComments.get(position).getDepth(); @@ -1319,7 +1348,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter { private BaseActivity activity; @@ -147,7 +147,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter mediaMetadataMap; public Comment(String id, String fullName, String author, String authorFlair, String authorFlairHTML, String linkAuthor, @@ -66,7 +69,7 @@ public class Comment implements Parcelable { String linkId, String subredditName, String parentId, int score, int voteType, boolean isSubmitter, String distinguished, String permalink, String awards, int depth, boolean collapsed, boolean hasReply, - boolean scoreHidden, boolean saved, long edited) { + boolean scoreHidden, boolean saved, long edited, Map mediaMetadataMap) { this.id = id; this.fullName = fullName; this.author = author; @@ -93,6 +96,7 @@ public class Comment implements Parcelable { this.isExpanded = false; this.hasExpandedBefore = false; this.editedTimeMillis = edited; + this.mediaMetadataMap = mediaMetadataMap; placeholderType = NOT_PLACEHOLDER; } @@ -147,6 +151,7 @@ public class Comment implements Parcelable { placeholderType = in.readInt(); isLoadingMoreChildren = in.readByte() != 0; loadMoreChildrenFailed = in.readByte() != 0; + mediaMetadataMap = (Map) in.readValue(getClass().getClassLoader()); } public String getId() { @@ -398,6 +403,18 @@ public class Comment implements Parcelable { this.loadMoreChildrenFailed = loadMoreChildrenFailed; } + public boolean isEdited() { + return editedTimeMillis != 0; + } + + public long getEditedTimeMillis() { + return editedTimeMillis; + } + + public Map getMediaMetadataMap() { + return mediaMetadataMap; + } + @Override public int describeContents() { return 0; @@ -436,12 +453,6 @@ public class Comment implements Parcelable { parcel.writeInt(placeholderType); parcel.writeByte((byte) (isLoadingMoreChildren ? 1 : 0)); parcel.writeByte((byte) (loadMoreChildrenFailed ? 1 : 0)); - } - - public boolean isEdited() { - return editedTimeMillis != 0; - } - public long getEditedTimeMillis() { - return editedTimeMillis; + parcel.writeValue(mediaMetadataMap); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java index 01d3f95f..4ba92570 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java @@ -15,9 +15,13 @@ import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.concurrent.Executor; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.commentfilter.CommentFilter; import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -267,7 +271,10 @@ public class ParseComment { String distinguished = singleCommentData.getString(JSONUtils.DISTINGUISHED_KEY); String commentMarkdown = ""; if (!singleCommentData.isNull(JSONUtils.BODY_KEY)) { - commentMarkdown = Utils.parseInlineGifInComments(Utils.modifyMarkdown(Utils.trimTrailingWhitespace(singleCommentData.getString(JSONUtils.BODY_KEY)))); + commentMarkdown = Utils.parseInlineRedditImages( + Utils.parseInlineGifInComments( + Utils.modifyMarkdown( + Utils.trimTrailingWhitespace(singleCommentData.getString(JSONUtils.BODY_KEY))))); if (!singleCommentData.isNull(JSONUtils.MEDIA_METADATA_KEY)) { JSONObject mediaMetadataObject = singleCommentData.getJSONObject(JSONUtils.MEDIA_METADATA_KEY); commentMarkdown = Utils.parseInlineEmotes(commentMarkdown, mediaMetadataObject); @@ -312,10 +319,62 @@ public class ParseComment { // this key can either be a bool (false) or a long (edited timestamp) long edited = singleCommentData.optLong(JSONUtils.EDITED_KEY) * 1000; + Map mediaMetadataMap = parseMediaMetadata(singleCommentData); + return new Comment(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(), linkAuthor, submitTime, commentMarkdown, commentRawText, linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished, - permalink, awardingsBuilder.toString(), depth, collapsed, hasReply, scoreHidden, saved, edited); + permalink, awardingsBuilder.toString(), depth, collapsed, hasReply, scoreHidden, saved, edited, + mediaMetadataMap); + } + + @Nullable + private static Map parseMediaMetadata(JSONObject data) { + try { + if (data.has(JSONUtils.MEDIA_METADATA_KEY)) { + Map mediaMetadataMap = new HashMap<>(); + JSONObject mediaMetadataJSON = data.getJSONObject(JSONUtils.MEDIA_METADATA_KEY); + for (Iterator it = mediaMetadataJSON.keys(); it.hasNext();) { + try { + String k = it.next(); + JSONObject media = mediaMetadataJSON.getJSONObject(k); + String e = media.getString(JSONUtils.E_KEY); + JSONArray downscales = media.getJSONArray(JSONUtils.P_KEY); + JSONObject downscaledItemJSON; + if (downscales.length() <= 3) { + downscaledItemJSON = downscales.getJSONObject(downscales.length() - 1); + } else { + downscaledItemJSON = downscales.getJSONObject(3); + } + MediaMetadata.MediaItem downscaledItem = new MediaMetadata.MediaItem(downscaledItemJSON.getInt(JSONUtils.X_KEY), + downscaledItemJSON.getInt(JSONUtils.Y_KEY), downscaledItemJSON.getString(JSONUtils.U_KEY)); + if (e.equalsIgnoreCase("Image")) { + JSONObject originalItemJSON = media.getJSONObject(JSONUtils.S_KEY); + MediaMetadata.MediaItem originalItem = new MediaMetadata.MediaItem(originalItemJSON.getInt(JSONUtils.X_KEY), + originalItemJSON.getInt(JSONUtils.Y_KEY), originalItemJSON.getString(JSONUtils.U_KEY)); + + String id = media.getString(JSONUtils.ID_KEY); + mediaMetadataMap.put(id, new MediaMetadata(id, e, originalItem, downscaledItem)); + } else if (e.equalsIgnoreCase("AnimatedImage")) { + JSONObject originalItemJSON = media.getJSONObject(JSONUtils.S_KEY); + MediaMetadata.MediaItem originalItem = new MediaMetadata.MediaItem(originalItemJSON.getInt(JSONUtils.X_KEY), + originalItemJSON.getInt(JSONUtils.Y_KEY), originalItemJSON.getString(JSONUtils.GIF_KEY), + originalItemJSON.getString(JSONUtils.MP4_KEY)); + + String id = media.getString(JSONUtils.ID_KEY); + mediaMetadataMap.put(id, new MediaMetadata(id, e, originalItem, downscaledItem)); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + return mediaMetadataMap; + } + } catch (JSONException e) { + e.printStackTrace(); + } + + return null; } @Nullable diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomMarkwonAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomMarkwonAdapter.java index fb10d036..48432ff8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomMarkwonAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomMarkwonAdapter.java @@ -23,6 +23,7 @@ import io.noties.markwon.MarkwonReducer; import io.noties.markwon.recycler.MarkwonAdapter; import io.noties.markwon.recycler.SimpleEntry; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.markdown.ImageAndGifBlock; public class CustomMarkwonAdapter extends MarkwonAdapter { private final SparseArray> entries; @@ -137,6 +138,10 @@ public class CustomMarkwonAdapter extends MarkwonAdapter { } } } + + if (node instanceof ImageAndGifBlock && !holder.itemView.hasOnClickListeners()) { + holder.itemView.setOnClickListener(onClickListener); + } } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java index 23440d2c..fe5f3b66 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java @@ -262,11 +262,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity); mCommentRecyclerView.setLayoutManager(mLinearLayoutManager); - mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper, - getResources().getConfiguration().locale, mSharedPreferences, - getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME), - () -> mCommentViewModel.retryLoadingMore()); - String username = getArguments().getString(EXTRA_USERNAME); String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.name()); if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) { @@ -276,6 +271,11 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase())); } + mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper, + getResources().getConfiguration().locale, mSharedPreferences, + getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME), + username, () -> mCommentViewModel.retryLoadingMore()); + mCommentRecyclerView.setAdapter(mAdapter); if (mActivity instanceof RecyclerViewContentScrollingInterface) { @@ -334,6 +334,14 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni } } + @Override + public void onResume() { + super.onResume(); + if (mAdapter != null) { + mAdapter.setCanStartActivity(true); + } + } + public void changeSortType(SortType sortType) { mCommentViewModel.changeSortType(sortType); this.sortType = sortType; @@ -399,12 +407,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni return sortType; } - public void giveAward(String awardsHTML, int position) { - if (mAdapter != null) { - mAdapter.giveAward(awardsHTML, position); - } - } - public void editComment(String commentMarkdown, int position) { if (mAdapter != null) { mAdapter.editComment(commentMarkdown, position); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java index 81653baa..3b42ee22 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java @@ -35,6 +35,7 @@ import io.noties.markwon.core.MarkwonTheme; import io.noties.markwon.recycler.MarkwonAdapter; import me.saket.bettermovementmethod.BetterLinkMovementMethod; import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; @@ -47,7 +48,6 @@ import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFi import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry; import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin; import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils; -import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData; import ml.docilealligator.infinityforreddit.subreddit.SubredditData; import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel; @@ -153,7 +153,7 @@ public class SidebarFragment extends Fragment { Glide.with(this), new ImageAndGifEntry.OnItemClickListener() { @Override - public void onItemClick(Post.MediaMetadata mediaMetadata) { + public void onItemClick(MediaMetadata mediaMetadata) { } })); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 0a220c6d..902bffca 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -1205,6 +1205,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (mPostAdapter != null) { mPostAdapter.setCanStartActivity(true); } + if (mCommentsAdapter != null) { + mCommentsAdapter.setCanStartActivity(true); + } if (mRecyclerView != null) { mRecyclerView.onWindowVisibilityChanged(View.VISIBLE); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlock.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlock.java index ce456f92..d336c5b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlock.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlock.java @@ -2,12 +2,12 @@ package ml.docilealligator.infinityforreddit.markdown; import org.commonmark.node.CustomBlock; -import ml.docilealligator.infinityforreddit.post.Post; +import ml.docilealligator.infinityforreddit.MediaMetadata; public class ImageAndGifBlock extends CustomBlock { - public Post.MediaMetadata mediaMetadata; + public MediaMetadata mediaMetadata; - public ImageAndGifBlock(Post.MediaMetadata mediaMetadata) { + public ImageAndGifBlock(MediaMetadata mediaMetadata) { this.mediaMetadata = mediaMetadata; } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlockParser.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlockParser.java index 029a5b83..d45aa177 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlockParser.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlockParser.java @@ -12,13 +12,13 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import ml.docilealligator.infinityforreddit.post.Post; +import ml.docilealligator.infinityforreddit.MediaMetadata; public class ImageAndGifBlockParser extends AbstractBlockParser { private ImageAndGifBlock imageAndGifBlock; - ImageAndGifBlockParser(Post.MediaMetadata mediaMetadata) { + ImageAndGifBlockParser(MediaMetadata mediaMetadata) { this.imageAndGifBlock = new ImageAndGifBlock(mediaMetadata); } @@ -34,7 +34,8 @@ public class ImageAndGifBlockParser extends AbstractBlockParser { public static class Factory extends AbstractBlockParserFactory { private final Pattern redditPreviewPattern = Pattern.compile("!\\[img]\\(https://preview.redd.it/\\w+.(jpg|png)((\\?+[-a-zA-Z0-9()@:%_+.~#?&/=]*)|)\\)"); - private Map mediaMetadataMap; + private final Pattern gifPattern = Pattern.compile("!\\[gif]\\(giphy\\|\\w+(\\|downsized)?\\)"); + private Map mediaMetadataMap; private final int fromIndex = "![img](https://preview.redd.it/".length(); @Override @@ -50,10 +51,18 @@ public class ImageAndGifBlockParser extends AbstractBlockParser { } } } + + matcher = gifPattern.matcher(line); + if (matcher.find()) { + if (matcher.end() == line.length()) { + String id = line.substring("![gif](".length(), line.length() - 1); + return mediaMetadataMap.containsKey(id) ? BlockStart.of(new ImageAndGifBlockParser(mediaMetadataMap.get(id))) : BlockStart.none(); + } + } return BlockStart.none(); } - public void setMediaMetadataMap(Map mediaMetadataMap) { + public void setMediaMetadataMap(Map mediaMetadataMap) { this.mediaMetadataMap = mediaMetadataMap; } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java index 89e3dcce..77e470cd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java @@ -1,6 +1,7 @@ package ml.docilealligator.infinityforreddit.markdown; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.View; @@ -20,10 +21,10 @@ import com.bumptech.glide.request.target.Target; import io.noties.markwon.Markwon; import io.noties.markwon.recycler.MarkwonAdapter; import jp.wasabeef.glide.transformations.BlurTransformation; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.databinding.MarkdownImageAndGifBlockBinding; -import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -34,6 +35,7 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry imageRequestBuilder; if (dataSavingMode) { imageRequestBuilder = glide.load(node.mediaMetadata.downscaled.url).listener(holder.requestListener); @@ -85,7 +94,7 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { @@ -124,27 +139,14 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry { + + binding.imageViewMarkdownImageAndGifBlock.setOnClickListener(view -> { if (imageAndGifBlock != null) { onItemClickListener.onItemClick(imageAndGifBlock.mediaMetadata); } }); } - /*private final RequestListener requestListener = new RequestListener() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - binding.progressBar.setVisibility(View.GONE); - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - binding.progressBar.setVisibility(View.GONE); - return false; - } - };*/ - /*public Holder(@NonNull AdapterGifEntryBinding binding) { super(binding.getRoot()); this.binding = binding; @@ -216,35 +218,10 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry mediaMetadataMap) { + public void setMediaMetadataMap(Map mediaMetadataMap) { factory.setMediaMetadataMap(mediaMetadataMap); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/MarkdownUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/MarkdownUtils.java index f1fc8cdb..5ff708ed 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/MarkdownUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/MarkdownUtils.java @@ -108,11 +108,12 @@ public class MarkdownUtils { * Creates a CustomMarkwonAdapter configured with support for tables. */ @NonNull - public static CustomMarkwonAdapter createCustomTablesAdapter() { + public static CustomMarkwonAdapter createCustomTablesAdapter(ImageAndGifEntry imageAndGifEntry) { return CustomMarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text) .include(TableBlock.class, TableEntry.create(builder -> builder .tableLayout(R.layout.adapter_table_block, R.id.table_layout) .textLayoutIsRoot(R.layout.view_table_entry_cell))) + .include(ImageAndGifBlock.class, imageAndGifEntry) .build(); } } 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 08fd7023..81e95c0c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -22,6 +22,7 @@ import java.util.concurrent.Executor; import java.util.regex.Matcher; import java.util.regex.Pattern; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.postfilter.PostFilter; import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -232,7 +233,7 @@ public class ParsePost { } } - Map mediaMetadataMap = parseMediaMetadata(data); + Map mediaMetadataMap = parseMediaMetadata(data); if (data.has(JSONUtils.CROSSPOST_PARENT_LIST)) { //Cross post //data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0) out of bounds???????????? @@ -257,10 +258,10 @@ public class ParsePost { } @Nullable - private static Map parseMediaMetadata(JSONObject data) { + private static Map parseMediaMetadata(JSONObject data) { try { if (data.has(JSONUtils.MEDIA_METADATA_KEY)) { - Map mediaMetadataMap = new HashMap<>(); + Map mediaMetadataMap = new HashMap<>(); JSONObject mediaMetadataJSON = data.getJSONObject(JSONUtils.MEDIA_METADATA_KEY); for (Iterator it = mediaMetadataJSON.keys(); it.hasNext();) { try { @@ -274,14 +275,14 @@ public class ParsePost { } else { downscaledItemJSON = downscales.getJSONObject(3); } - Post.MediaMetadata.MediaItem downscaledItem = new Post.MediaMetadata.MediaItem(downscaledItemJSON.getInt(JSONUtils.X_KEY), + MediaMetadata.MediaItem downscaledItem = new MediaMetadata.MediaItem(downscaledItemJSON.getInt(JSONUtils.X_KEY), downscaledItemJSON.getInt(JSONUtils.Y_KEY), downscaledItemJSON.getString(JSONUtils.U_KEY)); JSONObject originalItemJSON = media.getJSONObject(JSONUtils.S_KEY); - Post.MediaMetadata.MediaItem originalItem = new Post.MediaMetadata.MediaItem(originalItemJSON.getInt(JSONUtils.X_KEY), + MediaMetadata.MediaItem originalItem = new MediaMetadata.MediaItem(originalItemJSON.getInt(JSONUtils.X_KEY), originalItemJSON.getInt(JSONUtils.Y_KEY), originalItemJSON.getString(JSONUtils.U_KEY)); String id = media.getString(JSONUtils.ID_KEY); - mediaMetadataMap.put(id, new Post.MediaMetadata(id, media.getString(JSONUtils.E_KEY), + mediaMetadataMap.put(id, new MediaMetadata(id, media.getString(JSONUtils.E_KEY), originalItem, downscaledItem)); } catch (JSONException e) { e.printStackTrace(); @@ -299,7 +300,7 @@ public class ParsePost { private static Post parseData(JSONObject data, String permalink, String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String authorFlair, String authorFlairHTML, long postTimeMillis, String title, - ArrayList previews, Map mediaMetadataMap, + ArrayList previews, Map mediaMetadataMap, int score, int voteType, int nComments, int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, @@ -366,7 +367,7 @@ public class ParsePost { if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { - post.setSelfText(Utils.modifyMarkdown(Utils.parseInlineRedditImages(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY))))); + post.setSelfText(Utils.parseInlineRedditImages(Utils.modifyMarkdown(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY))))); } String authority = uri.getAuthority(); @@ -552,7 +553,7 @@ public class ParsePost { if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { - post.setSelfText(Utils.modifyMarkdown(Utils.parseInlineRedditImages(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY))))); + post.setSelfText(Utils.parseInlineRedditImages(Utils.modifyMarkdown(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY))))); } post.setPreviews(previews); @@ -627,7 +628,7 @@ public class ParsePost { if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { - post.setSelfText(Utils.modifyMarkdown(Utils.parseInlineRedditImages(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY))))); + post.setSelfText(Utils.parseInlineRedditImages(Utils.modifyMarkdown(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY))))); } String authority = uri.getAuthority(); @@ -771,7 +772,7 @@ public class ParsePost { if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { - String selfText = Utils.modifyMarkdown(Utils.parseInlineRedditImages(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY)))); + String selfText = Utils.parseInlineRedditImages(Utils.modifyMarkdown(Utils.trimTrailingWhitespace(data.getString(JSONUtils.SELFTEXT_KEY)))); post.setSelfText(selfText); if (data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { post.setSelfTextPlainTrimmed(""); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java index 379d63b6..930f7225 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -1,6 +1,5 @@ package ml.docilealligator.infinityforreddit.post; -import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -10,6 +9,7 @@ import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.Map; +import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.utils.APIUtils; /** @@ -767,98 +767,4 @@ public class Post implements Parcelable { parcel.writeString(previewCaptionUrl); } } - - public static class MediaMetadata implements Parcelable { - public String id; - //E.g. Image - public String e; - public String fileName; - public MediaItem original; - public MediaItem downscaled; - - public MediaMetadata(String id, String e, MediaItem original, MediaItem downscaled) { - this.id = id; - this.e = e; - String path = Uri.parse(original.url).getPath(); - this.fileName = path == null ? "Image.jpg" : path.substring(1); - this.original = original; - this.downscaled = downscaled; - } - - protected MediaMetadata(Parcel in) { - id = in.readString(); - e = in.readString(); - fileName = in.readString(); - original = in.readParcelable(MediaItem.class.getClassLoader()); - downscaled = in.readParcelable(MediaItem.class.getClassLoader()); - } - - public static final Creator CREATOR = new Creator() { - @Override - public MediaMetadata createFromParcel(Parcel in) { - return new MediaMetadata(in); - } - - @Override - public MediaMetadata[] newArray(int size) { - return new MediaMetadata[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeString(id); - dest.writeString(e); - dest.writeString(fileName); - dest.writeParcelable(original, flags); - dest.writeParcelable(downscaled, flags); - } - - public static class MediaItem implements Parcelable { - public int x; - public int y; - public String url; - - public MediaItem(int x, int y, String url) { - this.x = x; - this.y = y; - this.url = url; - } - - protected MediaItem(Parcel in) { - x = in.readInt(); - y = in.readInt(); - url = in.readString(); - } - - public static final Creator CREATOR = new Creator() { - @Override - public MediaItem createFromParcel(Parcel in) { - return new MediaItem(in); - } - - @Override - public MediaItem[] newArray(int size) { - return new MediaItem[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeInt(x); - dest.writeInt(y); - dest.writeString(url); - } - } - } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java index f5f3b163..0efed43b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java @@ -38,7 +38,6 @@ import com.google.android.material.snackbar.Snackbar; import com.google.android.material.tabs.TabLayout; import com.google.android.material.textfield.TextInputLayout; -import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.xmlpull.v1.XmlPullParserException; @@ -88,7 +87,7 @@ public final class Utils { } public static String parseInlineGifInComments(String markdown) { - StringBuilder markdownStringBuilder = new StringBuilder(markdown); + /*StringBuilder markdownStringBuilder = new StringBuilder(markdown); Pattern inlineGifPattern = REGEX_PATTERNS[3]; Matcher matcher = inlineGifPattern.matcher(markdownStringBuilder); while (matcher.find()) { @@ -107,17 +106,18 @@ public final class Utils { Matcher matcher3 = inlineGifPattern3.matcher(markdownStringBuilder); while (matcher3.find()) { markdownStringBuilder.replace(matcher3.start(), matcher3.end(), - "![gif](https://reddit-meta-production.s3.amazonaws.com/public/fortnitebr/emotes/snoomoji_emotes/" + "![emote](https://reddit-meta-production.s3.amazonaws.com/public/fortnitebr/emotes/snoomoji_emotes/" + markdownStringBuilder.substring( - matcher3.start() + "![gif](emote|".length(), matcher3.end() - 1).replace('|', '/') + ".gif)"); + matcher3.start() + "![emote](emote|".length(), matcher3.end() - 1).replace('|', '/') + ".gif)"); matcher3 = inlineGifPattern3.matcher(markdownStringBuilder); } - return markdownStringBuilder.toString(); + return markdownStringBuilder.toString();*/ + return markdown; } public static String parseInlineEmotes(String markdown, JSONObject mediaMetadataObject) throws JSONException { - JSONArray mediaMetadataNames = mediaMetadataObject.names(); + /*JSONArray mediaMetadataNames = mediaMetadataObject.names(); if (mediaMetadataNames != null) { for (int i = 0; i < mediaMetadataNames.length(); i++) { if (!mediaMetadataNames.isNull(i)) { @@ -146,6 +146,7 @@ public final class Utils { } } } + return markdown;*/ return markdown; } -- cgit v1.2.3