aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-11-22 17:52:28 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-11-22 17:52:28 +0000
commit7c68239272113e6c913a54723f4196f3d0fb0acc (patch)
treec24ab598918c6265cd10604c022fbb4e4945c4ce /app/src
parent1a104d9033075b3b466c22b3577b636ff25f8990 (diff)
downloadinfinity-for-reddit-7c68239272113e6c913a54723f4196f3d0fb0acc.tar
infinity-for-reddit-7c68239272113e6c913a54723f4196f3d0fb0acc.tar.gz
infinity-for-reddit-7c68239272113e6c913a54723f4196f3d0fb0acc.tar.bz2
infinity-for-reddit-7c68239272113e6c913a54723f4196f3d0fb0acc.tar.lz
infinity-for-reddit-7c68239272113e6c913a54723f4196f3d0fb0acc.tar.xz
infinity-for-reddit-7c68239272113e6c913a54723f4196f3d0fb0acc.tar.zst
infinity-for-reddit-7c68239272113e6c913a54723f4196f3d0fb0acc.zip
Start implementing showing gifs and images in comments.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MediaMetadata.java119
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterPreferenceActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentFilterUsageListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeCommentFilterActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FetchRandomSubredditOrPostActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/HistoryActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SuicidePreventionActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java48
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java31
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java63
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CustomMarkwonAdapter.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlock.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifBlockParser.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java65
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifPlugin.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/MarkdownUtils.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java96
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java13
73 files changed, 411 insertions, 278 deletions
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<MediaMetadata> CREATOR = new Creator<MediaMetadata>() {
+ @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<MediaItem> CREATOR = new Creator<MediaItem>() {
+ @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<Comment
private Locale mLocale;
private ImageAndGifPlugin mImageAndGifPlugin;
private Markwon mMarkwon;
+ private ImageAndGifEntry mImageAndGifEntry;
private RecyclerView.RecycledViewPool recycledViewPool;
private String mAccessToken;
private String mAccountName;
@@ -103,13 +108,15 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
private String mTimeFormatPattern;
private boolean mShowCommentDivider;
private boolean mShowAbsoluteNumberOfVotes;
+ private boolean canStartActivity = true;
private NetworkState networkState;
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
public CommentsListingRecyclerViewAdapter(BaseActivity activity, Retrofit oauthRetrofit,
CustomThemeWrapper customThemeWrapper, Locale locale,
SharedPreferences sharedPreferences, String accessToken,
- String accountName, RetryLoadingMoreCallback retryLoadingMoreCallback) {
+ String accountName, String username,
+ RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK);
mActivity = activity;
mOauthRetrofit = oauthRetrofit;
@@ -173,6 +180,23 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mImageAndGifPlugin = new ImageAndGifPlugin();
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
miscPlugin, mImageAndGifPlugin, mCommentColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
+ mImageAndGifEntry = new ImageAndGifEntry(activity, Glide.with(activity), new ImageAndGifEntry.OnItemClickListener() {
+ @Override
+ public void onItemClick(MediaMetadata mediaMetadata) {
+ Intent intent = new Intent(activity, ViewImageOrGifActivity.class);
+ if (mediaMetadata.isGIF) {
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, mediaMetadata.original.url);
+ } else {
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, mediaMetadata.original.url);
+ }
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, username);
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mediaMetadata.fileName);
+ if (canStartActivity) {
+ canStartActivity = false;
+ activity.startActivity(intent);
+ }
+ }
+ });
recycledViewPool = new RecyclerView.RecycledViewPool();
}
@@ -217,6 +241,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
Utils.setHTMLWithImageToTextView(((CommentBaseViewHolder) holder).awardsTextView, comment.getAwards(), true);
}
+ mImageAndGifPlugin.setMediaMetadataMap(comment.getMediaMetadataMap());
((CommentBaseViewHolder) holder).markwonAdapter.setMarkdown(mMarkwon, comment.getCommentMarkdown());
// noinspection NotifyDataSetChanged
((CommentBaseViewHolder) holder).markwonAdapter.notifyDataSetChanged();
@@ -327,16 +352,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
}
- public void giveAward(String awardsHTML, int position) {
- if (position >= 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<Comment
}
}
+ public void setCanStartActivity(boolean canStartActivity) {
+ this.canStartActivity = canStartActivity;
+ }
+
public interface RetryLoadingMoreCallback {
void retryLoadingMore();
}
@@ -533,7 +552,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
});
commentMarkdownView.setLayoutManager(linearLayoutManager);
- markwonAdapter = MarkdownUtils.createCustomTablesAdapter();
+ markwonAdapter = MarkdownUtils.createCustomTablesAdapter(mImageAndGifEntry);
markwonAdapter.setOnClickListener(view -> {
if (view instanceof SpoilerOnClickTextView) {
if (((SpoilerOnClickTextView) view).isSpoilerOnClick()) {
@@ -541,7 +560,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
return;
}
}
- itemView.callOnClick();
+ if (canStartActivity) {
+ canStartActivity = false;
+ itemView.callOnClick();
+ }
});
commentMarkdownView.setAdapter(markwonAdapter);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 85ba9dae..9702bfb8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -45,6 +45,7 @@ import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
+import ml.docilealligator.infinityforreddit.MediaMetadata;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.SortType;
@@ -52,6 +53,7 @@ import ml.docilealligator.infinityforreddit.VoteThing;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
+import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CommentMoreBottomSheetFragment;
@@ -67,6 +69,7 @@ import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.databinding.ItemCommentBinding;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
+import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry;
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
import ml.docilealligator.infinityforreddit.post.Post;
@@ -96,6 +99,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private Retrofit mOauthRetrofit;
private ImageAndGifPlugin mImageAndGifPlugin;
private Markwon mCommentMarkwon;
+ private ImageAndGifEntry mImageAndGifEntry;
private String mAccessToken;
private String mAccountName;
private Post mPost;
@@ -154,6 +158,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
private int mSearchCommentIndex = -1;
+ private boolean canStartActivity = true;
+
public CommentsRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
CustomThemeWrapper customThemeWrapper,
Executor executor, Retrofit retrofit, Retrofit oauthRetrofit,
@@ -208,6 +214,24 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mImageAndGifPlugin = new ImageAndGifPlugin();
mCommentMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
miscPlugin, mImageAndGifPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
+ mImageAndGifEntry = new ImageAndGifEntry(activity, mGlide, new ImageAndGifEntry.OnItemClickListener() {
+ @Override
+ public void onItemClick(MediaMetadata mediaMetadata) {
+ Intent intent = new Intent(activity, ViewImageOrGifActivity.class);
+ if (mediaMetadata.isGIF) {
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, mediaMetadata.original.url);
+ } else {
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, mediaMetadata.original.url);
+ }
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_IS_NSFW, post.isNSFW());
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, post.getSubredditName());
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mediaMetadata.fileName);
+ if (canStartActivity) {
+ canStartActivity = false;
+ activity.startActivity(intent);
+ }
+ }
+ });
recycledViewPool = new RecyclerView.RecycledViewPool();
mAccessToken = accessToken;
mAccountName = accountName;
@@ -442,6 +466,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
Utils.setHTMLWithImageToTextView(((CommentBaseViewHolder) holder).awardsTextView, comment.getAwards(), true);
}
+ mImageAndGifPlugin.setMediaMetadataMap(comment.getMediaMetadataMap());
((CommentBaseViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
// noinspection NotifyDataSetChanged
((CommentBaseViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
@@ -773,6 +798,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
}
+ public void setCanStartActivity(boolean canStartActivity) {
+ this.canStartActivity = canStartActivity;
+ }
+
private int getParentPosition(int position) {
if (position >= 0 && position < mVisibleComments.size()) {
int childDepth = mVisibleComments.get(position).getDepth();
@@ -1319,7 +1348,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
});
commentMarkdownView.setLayoutManager(linearLayoutManager);
- mMarkwonAdapter = MarkdownUtils.createCustomTablesAdapter();
+ mMarkwonAdapter = MarkdownUtils.createCustomTablesAdapter(mImageAndGifEntry);
commentMarkdownView.setAdapter(mMarkwonAdapter);
itemView.setBackgroundColor(mCommentBackgroundColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
index a2dac6d9..02b88c0f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
@@ -25,6 +25,7 @@ import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
+import ml.docilealligator.infinityforreddit.MediaMetadata;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Rule;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
@@ -37,7 +38,6 @@ import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry;
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
-import ml.docilealligator.infinityforreddit.post.Post;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private BaseActivity activity;
@@ -147,7 +147,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
Glide.with(activity),
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/comment/Comment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java
index 8d981a44..12584a38 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java
@@ -4,8 +4,10 @@ import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
+import java.util.Map;
import ml.docilealligator.infinityforreddit.BuildConfig;
+import ml.docilealligator.infinityforreddit.MediaMetadata;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
public class Comment implements Parcelable {
@@ -59,6 +61,7 @@ public class Comment implements Parcelable {
private boolean isLoadingMoreChildren;
private boolean loadMoreChildrenFailed;
private long editedTimeMillis;
+ private Map<String, MediaMetadata> 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<String, MediaMetadata> 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<String, MediaMetadata>) 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<String, MediaMetadata> 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<String, MediaMetadata> 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<String, MediaMetadata> parseMediaMetadata(JSONObject data) {
+ try {
+ if (data.has(JSONUtils.MEDIA_METADATA_KEY)) {
+ Map<String, MediaMetadata> mediaMetadataMap = new HashMap<>();
+ JSONObject mediaMetadataJSON = data.getJSONObject(JSONUtils.MEDIA_METADATA_KEY);
+ for (Iterator<String> 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<Entry<Node, Holder>> 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<String, Post.MediaMetadata> mediaMetadataMap;
+ private final Pattern gifPattern = Pattern.compile("!\\[gif]\\(giphy\\|\\w+(\\|downsized)?\\)");
+ private Map<String, MediaMetadata> 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<String, Post.MediaMetadata> mediaMetadataMap) {
+ public void setMediaMetadataMap(Map<String, MediaMetadata> 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<ImageAndGifBlock, Ima
private OnItemClickListener onItemClickListener;
private boolean dataSavingMode;
private boolean blurImage;
+ private int colorAccent;
public ImageAndGifEntry(BaseActivity baseActivity, RequestManager glide,
OnItemClickListener onItemClickListener) {
@@ -43,7 +45,7 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
this.saveMemoryCenterInsideDownsampleStrategy = new SaveMemoryCenterInisdeDownsampleStrategy(
Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.POST_FEED_MAX_RESOLUTION, "5000000")));
this.onItemClickListener = onItemClickListener;
-
+ colorAccent = baseActivity.getCustomThemeWrapper().getColorAccent();
String dataSavingModeString = sharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF);
if (dataSavingModeString.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ALWAYS)) {
dataSavingMode = true;
@@ -56,6 +58,7 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
OnItemClickListener onItemClickListener) {
this.baseActivity = baseActivity;
this.glide = glide;
+
SharedPreferences sharedPreferences = baseActivity.getDefaultSharedPreferences();
this.saveMemoryCenterInsideDownsampleStrategy = new SaveMemoryCenterInisdeDownsampleStrategy(
Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.POST_FEED_MAX_RESOLUTION, "5000000")));
@@ -76,6 +79,12 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
holder.binding.progressBarMarkdownImageAndGifBlock.setVisibility(View.VISIBLE);
+ if (node.mediaMetadata.isGIF) {
+ ViewGroup.LayoutParams params = holder.binding.imageViewMarkdownImageAndGifBlock.getLayoutParams();
+ params.width = (int) Utils.convertDpToPixel(160, baseActivity);
+ holder.binding.imageViewMarkdownImageAndGifBlock.setLayoutParams(params);
+ }
+
RequestBuilder<Drawable> imageRequestBuilder;
if (dataSavingMode) {
imageRequestBuilder = glide.load(node.mediaMetadata.downscaled.url).listener(holder.requestListener);
@@ -85,7 +94,7 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
holder.binding.imageViewMarkdownImageAndGifBlock.setRatio((float) node.mediaMetadata.original.y / node.mediaMetadata.original.x);
}
- if (blurImage) {
+ if (blurImage && !node.mediaMetadata.isGIF) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(holder.binding.imageViewMarkdownImageAndGifBlock);
} else {
@@ -96,6 +105,10 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
@Override
public void onViewRecycled(@NonNull Holder holder) {
super.onViewRecycled(holder);
+ ViewGroup.LayoutParams params = holder.binding.imageViewMarkdownImageAndGifBlock.getLayoutParams();
+ params.width = ViewGroup.LayoutParams.MATCH_PARENT;
+ holder.binding.imageViewMarkdownImageAndGifBlock.setLayoutParams(params);
+
glide.clear(holder.binding.imageViewMarkdownImageAndGifBlock);
holder.binding.progressBarMarkdownImageAndGifBlock.setVisibility(View.GONE);
holder.binding.loadImageErrorTextViewMarkdownImageAndGifBlock.setVisibility(View.GONE);
@@ -110,6 +123,8 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
super(binding.getRoot());
this.binding = binding;
+ binding.progressBarMarkdownImageAndGifBlock.setIndeterminateTintList(ColorStateList.valueOf(colorAccent));
+
requestListener = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
@@ -124,27 +139,14 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
return false;
}
};
- binding.getRoot().setOnClickListener(view -> {
+
+ binding.imageViewMarkdownImageAndGifBlock.setOnClickListener(view -> {
if (imageAndGifBlock != null) {
onItemClickListener.onItemClick(imageAndGifBlock.mediaMetadata);
}
});
}
- /*private final RequestListener<Drawable> requestListener = new RequestListener<Drawable>() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- binding.progressBar.setVisibility(View.GONE);
- return false;
- }
-
- @Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<ImageAndGifBlock, Ima
.addListener(requestListener)
.error(R.drawable.ic_error_outline_black_24dp)
.into(target);
- }
-
- void recycle() {
- glide.clear(binding.iv);
- }
-
- @SuppressWarnings("SameParameterValue")
- private int dpToPx(int dp) {
- float density = itemView.getContext().getResources().getDisplayMetrics().density;
- return (int) (dp * density);
- }
-
- private boolean canLoadGif() {
- // ideally this would be injected, but it is a bit unpleasant to do
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
- String dataSavingMode = sharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF);
- Log.i("GifEntry", "datasaving=" + dataSavingMode);
- if (dataSavingMode.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ALWAYS)) {
- return false;
- } else if (dataSavingMode.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ONLY_ON_CELLULAR_DATA)) {
- int networkType = Utils.getConnectedNetwork(itemView.getContext());
- return networkType != Utils.NETWORK_TYPE_CELLULAR;
- } else {
- return true;
- }
}*/
}
public interface OnItemClickListener {
- void onItemClick(Post.MediaMetadata mediaMetadata);
+ void onItemClick(MediaMetadata mediaMetadata);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifPlugin.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifPlugin.java
index 86209454..754ffc14 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifPlugin.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifPlugin.java
@@ -1,7 +1,5 @@
package ml.docilealligator.infinityforreddit.markdown;
-import android.util.Log;
-
import androidx.annotation.NonNull;
import org.commonmark.parser.Parser;
@@ -9,7 +7,7 @@ import org.commonmark.parser.Parser;
import java.util.Map;
import io.noties.markwon.AbstractMarkwonPlugin;
-import ml.docilealligator.infinityforreddit.post.Post;
+import ml.docilealligator.infinityforreddit.MediaMetadata;
public class ImageAndGifPlugin extends AbstractMarkwonPlugin {
@@ -22,7 +20,6 @@ public class ImageAndGifPlugin extends AbstractMarkwonPlugin {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
- Log.i("asdfa", "imageandgifplugin " + markdown + "ooooo");
return super.processMarkdown(markdown);
}
@@ -31,7 +28,7 @@ public class ImageAndGifPlugin extends AbstractMarkwonPlugin {
builder.customBlockParserFactory(factory);
}
- public void setMediaMetadataMap(Map<String, Post.MediaMetadata> mediaMetadataMap) {
+ public void setMediaMetadataMap(Map<String, MediaMetadata> 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<String, Post.MediaMetadata> mediaMetadataMap = parseMediaMetadata(data);
+ Map<String, MediaMetadata> 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<String, Post.MediaMetadata> parseMediaMetadata(JSONObject data) {
+ private static Map<String, MediaMetadata> parseMediaMetadata(JSONObject data) {
try {
if (data.has(JSONUtils.MEDIA_METADATA_KEY)) {
- Map<String, Post.MediaMetadata> mediaMetadataMap = new HashMap<>();
+ Map<String, MediaMetadata> mediaMetadataMap = new HashMap<>();
JSONObject mediaMetadataJSON = data.getJSONObject(JSONUtils.MEDIA_METADATA_KEY);
for (Iterator<String> 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<Post.Preview> previews, Map<String, Post.MediaMetadata> mediaMetadataMap,
+ ArrayList<Post.Preview> previews, Map<String, MediaMetadata> 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<MediaMetadata> CREATOR = new Creator<MediaMetadata>() {
- @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<MediaItem> CREATOR = new Creator<MediaItem>() {
- @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;
}