Skip to content

Commit

Permalink
Support for imgflip links
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Sep 7, 2016
1 parent 010836d commit 74e57bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Preference to hide floating toolbar over images
Preference to make link text non-clickable
For albums with only one image, the image is now shown immediately
Fixed bug with huge "load more comments" links
Support for imgflip links

73/1.9.5.1
Comment swipe actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ public static boolean openWebBrowser(AppCompatActivity activity, Uri uri, final
lvmePattern = Pattern.compile(".*[^A-Za-z]livememe\\.com/(\\w+).*"),
gfycatPattern = Pattern.compile(".*[^A-Za-z]gfycat\\.com/(\\w+).*"),
streamablePattern = Pattern.compile(".*[^A-Za-z]streamable\\.com/(\\w+).*"),
reddituploadsPattern = Pattern.compile(".*[^A-Za-z]i\\.reddituploads\\.com/(\\w+).*");
reddituploadsPattern = Pattern.compile(".*[^A-Za-z]i\\.reddituploads\\.com/(\\w+).*"),
imgflipPattern = Pattern.compile(".*[^A-Za-z]imgflip\\.com/i/(\\w+).*");

public static boolean isProbablyAnImage(final String url) {

Expand Down Expand Up @@ -344,6 +345,17 @@ public static boolean isProbablyAnImage(final String url) {
}
}

{
final Matcher matchImgflip = imgflipPattern.matcher(url);

if(matchImgflip.find()) {
final String imgId = matchImgflip.group(1);
if(imgId.length() > 3) {
return true;
}
}
}

return getImageUrlPatternMatch(url) != null;
}

Expand Down Expand Up @@ -519,6 +531,19 @@ public static void getImageInfo(
}
}

{
final Matcher matchImgflip = imgflipPattern.matcher(url);

if(matchImgflip.find()) {
final String imgId = matchImgflip.group(1);
if(imgId.length() > 3) {
final String imageUrl = "https://i.imgflip.com/" + imgId + ".jpg";
listener.onSuccess(new ImageInfo(imageUrl));
return;
}
}
}

final String imageUrlPatternMatch = getImageUrlPatternMatch(url);

if(imageUrlPatternMatch != null) {
Expand Down

0 comments on commit 74e57bc

Please sign in to comment.