Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloaded file extensions #1495

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down