Merge branch 'trz/rebase' into trz/rename
This commit is contained in:
commit
2dac6c8f36
2 changed files with 28 additions and 4 deletions
|
@ -19,10 +19,16 @@ import github.ankushsachdeva.emojicon.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
|
import android.util.Pair;
|
||||||
|
import android.util.Patterns;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -1440,13 +1446,20 @@ public final class EmojiconHandler {
|
||||||
spannable.removeSpan(oldSpans[i]);
|
spannable.removeSpan(oldSpans[i]);
|
||||||
}
|
}
|
||||||
boolean hasChanges = false;
|
boolean hasChanges = false;
|
||||||
|
|
||||||
|
Matcher webUrlMatcher = Patterns.WEB_URL.matcher(spannable);
|
||||||
|
Set<Pair<Integer, Integer>> webUrls = new HashSet<Pair<Integer, Integer>>();
|
||||||
|
while (webUrlMatcher.find()) {
|
||||||
|
webUrls.add(Pair.create(webUrlMatcher.start(), webUrlMatcher.end()));
|
||||||
|
}
|
||||||
|
|
||||||
Map<Pattern, Integer> emoticons = ANDROID_EMOTICONS;
|
Map<Pattern, Integer> emoticons = ANDROID_EMOTICONS;
|
||||||
for (Map.Entry<Pattern, Integer> entry : emoticons.entrySet()) {
|
for (Map.Entry<Pattern, Integer> entry : emoticons.entrySet()) {
|
||||||
Matcher matcher = entry.getKey().matcher(spannable);
|
Matcher matcher = entry.getKey().matcher(spannable);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
boolean set = true;
|
boolean set = true;
|
||||||
for (EmojiconImageSpan span : spannable.getSpans(matcher.start(),
|
for (EmojiconImageSpan span : spannable.getSpans(matcher.start(),
|
||||||
matcher.end(), EmojiconImageSpan.class))
|
matcher.end(), EmojiconImageSpan.class)) {
|
||||||
if (spannable.getSpanStart(span) >= matcher.start()
|
if (spannable.getSpanStart(span) >= matcher.start()
|
||||||
&& spannable.getSpanEnd(span) <= matcher.end())
|
&& spannable.getSpanEnd(span) <= matcher.end())
|
||||||
spannable.removeSpan(span);
|
spannable.removeSpan(span);
|
||||||
|
@ -1454,6 +1467,17 @@ public final class EmojiconHandler {
|
||||||
set = false;
|
set = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (set) {
|
||||||
|
// check that found emojicon is not in an web url
|
||||||
|
for (Pair<Integer, Integer> webUrl : webUrls) {
|
||||||
|
if ((matcher.start() >= webUrl.first && matcher.start() <= webUrl.second)
|
||||||
|
|| (matcher.end() >= webUrl.first && matcher.end() <= webUrl.second)) {
|
||||||
|
set = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (set) {
|
if (set) {
|
||||||
spannable.setSpan(new EmojiconImageSpan(context, entry.getValue()),
|
spannable.setSpan(new EmojiconImageSpan(context, entry.getValue()),
|
||||||
matcher.start(), matcher.end(),
|
matcher.start(), matcher.end(),
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class HttpDownloadConnection implements Transferable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
file.setExpectedSize(size);
|
file.setExpectedSize(size);
|
||||||
if (size <= mHttpConnectionManager.getAutoAcceptFileSize()) {
|
if (size != -1 && size <= mHttpConnectionManager.getAutoAcceptFileSize()) {
|
||||||
HttpDownloadConnection.this.acceptedAutomatically = true;
|
HttpDownloadConnection.this.acceptedAutomatically = true;
|
||||||
new Thread(new FileDownloader(interactive)).start();
|
new Thread(new FileDownloader(interactive)).start();
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,12 +171,12 @@ public class HttpDownloadConnection implements Transferable {
|
||||||
connection.connect();
|
connection.connect();
|
||||||
String contentLength = connection.getHeaderField("Content-Length");
|
String contentLength = connection.getHeaderField("Content-Length");
|
||||||
if (contentLength == null) {
|
if (contentLength == null) {
|
||||||
throw new IOException();
|
return -1;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return Long.parseLong(contentLength, 10);
|
return Long.parseLong(contentLength, 10);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IOException();
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue