Skip to content

Commit

Permalink
Support for makeameme links
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Oct 2, 2016
1 parent 985e448 commit 7555ed7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For albums with only one image, the image is now shown immediately
When sending PMs, input fields are cleared if send succeeded
Show action bar back button in two-pane mode (thanks to mariokmk)
Fixed bug with huge "load more comments" links
Support for imgflip links
Support for imgflip and makeameme links
Added Dutch translation (thanks to Beleg-Cuthalion)

74/1.9.5.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ public static boolean openWebBrowser(AppCompatActivity activity, Uri uri, final
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+).*"),
imgflipPattern = Pattern.compile(".*[^A-Za-z]imgflip\\.com/i/(\\w+).*");
imgflipPattern = Pattern.compile(".*[^A-Za-z]imgflip\\.com/i/(\\w+).*"),
makeamemePattern = Pattern.compile(".*[^A-Za-z]makeameme\\.org/meme/([\\w\\-]+).*");

public static boolean isProbablyAnImage(final String url) {

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

{
final Matcher matchMakeameme = makeamemePattern.matcher(url);

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

return getImageUrlPatternMatch(url) != null;
}

Expand Down Expand Up @@ -544,6 +556,19 @@ public static void getImageInfo(
}
}

{
final Matcher matchMakeameme = makeamemePattern.matcher(url);

if(matchMakeameme.find()) {
final String imgId = matchMakeameme.group(1);
if(imgId.length() > 3) {
final String imageUrl = "https://media.makeameme.org/created/" + imgId + ".jpg";
listener.onSuccess(new ImageInfo(imageUrl));
return;
}
}
}

final String imageUrlPatternMatch = getImageUrlPatternMatch(url);

if(imageUrlPatternMatch != null) {
Expand Down

0 comments on commit 7555ed7

Please sign in to comment.