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 5203c56725..70fbd32e3f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -423,9 +423,16 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) { } else { glide.load(subredditData.getBannerUrl()).into(bannerImageView); bannerImageView.setOnClickListener(view -> { + String fileName = Uri.parse(subredditData.getBannerUrl()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, subredditData.getBannerUrl()); - intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, subredditName + "-banner.jpg"); + intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, subredditName + "-banner" + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, subredditName); startActivity(intent); }); @@ -443,9 +450,16 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) { .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0)))) .into(iconGifImageView); iconGifImageView.setOnClickListener(view -> { + String fileName = Uri.parse(subredditData.getIconUrl()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, subredditData.getIconUrl()); - intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, subredditName + "-icon.jpg"); + intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, subredditName + "-icon" + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, subredditName); startActivity(intent); }); 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 a9a2068c99..774a546ba6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -407,9 +407,16 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) { } else { glide.load(userData.getBanner()).into(bannerImageView); bannerImageView.setOnClickListener(view -> { + String fileName = Uri.parse(userData.getBanner()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(this, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, userData.getBanner()); - intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, username + "-banner.jpg"); + intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, username + "-banner" + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, username); startActivity(intent); }); @@ -428,9 +435,16 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) { .into(iconGifImageView); iconGifImageView.setOnClickListener(view -> { + String fileName = Uri.parse(userData.getIconUrl()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(this, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, userData.getIconUrl()); - intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, username + "-icon.jpg"); + intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, username + "-icon" + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, username); startActivity(intent); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java index 88e83e308e..16dab1d0f3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java @@ -2031,10 +2031,17 @@ private void openMedia(Post post, int galleryItemIndex) { intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } else if (post.getPostType() == Post.IMAGE_TYPE) { + String fileName = Uri.parse(post.getUrl()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, post.getUrl()); intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, post.getSubredditName() - + "-" + post.getId() + ".jpg"); + + "-" + post.getId() + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, post.getTitle()); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, post.getSubredditName()); intent.putExtra(ViewImageOrGifActivity.EXTRA_IS_NSFW, post.isNSFW()); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 1aad70b1a8..f3664726e6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -2057,10 +2057,17 @@ class PostDetailImageAndGifAutoplayViewHolder extends PostDetailBaseViewHolder { if (canStartActivity) { canStartActivity = false; if (mPost.getPostType() == Post.IMAGE_TYPE) { + String fileName = Uri.parse(mPost.getUrl()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, mPost.getUrl()); intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mPost.getSubredditNamePrefixed().substring(2) - + "-" + mPost.getId().substring(3) + ".jpg"); + + "-" + mPost.getId().substring(3) + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, mPost.getTitle()); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, mPost.getSubredditName()); mActivity.startActivity(intent); @@ -2291,10 +2298,17 @@ class PostDetailNoPreviewViewHolder extends PostDetailBaseViewHolder { intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW()); mActivity.startActivity(intent); } else if (mPost.getPostType() == Post.IMAGE_TYPE) { + String fileName = Uri.parse(mPost.getUrl()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, mPost.getUrl()); intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mPost.getSubredditName() - + "-" + mPost.getId() + ".jpg"); + + "-" + mPost.getId() + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, mPost.getTitle()); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, mPost.getSubredditName()); mActivity.startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index f3612e1e45..8ac3c78234 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -2134,10 +2134,17 @@ private void openMedia(Post post, int galleryItemIndex) { intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } else if (post.getPostType() == Post.IMAGE_TYPE) { + String fileName = Uri.parse(post.getUrl()).getLastPathSegment(); + int idx = fileName.lastIndexOf('.'); + String extension = ".jpg"; + if (idx != -1) { + extension = fileName.substring(idx); + } + Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, post.getUrl()); intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, post.getSubredditName() - + "-" + post.getId() + ".jpg"); + + "-" + post.getId() + extension); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, post.getTitle()); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, post.getSubredditName()); intent.putExtra(ViewImageOrGifActivity.EXTRA_IS_NSFW, post.isNSFW());