Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit b84b919

Browse files
committed
Fix: Use unicode to locate emojis.
1 parent 68e3463 commit b84b919

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ dependencies {
7272
compile 'com.android.support:recyclerview-v7:24.1.1'
7373
compile 'com.google.android.gms:play-services-gcm:8.4.0'
7474
compile 'com.google.android.gms:play-services-auth:8.4.0'
75-
compile 'com.squareup.retrofit2:retrofit:2.2.0'
75+
compile 'com.squareup.retrofit2:retrofit:2+'
7676
compile 'com.squareup.okhttp3:logging-interceptor:3+'
77-
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
77+
compile 'com.squareup.retrofit2:converter-gson:2+'
7878
compile 'com.squareup.okhttp3:okhttp:3+'
7979
compile 'com.j256.ormlite:ormlite-core:5.0'
8080
compile 'com.j256.ormlite:ormlite-android:5.0'

app/src/main/java/com/zulip/android/models/Message.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,15 @@ public static Spanned formatContent(String source, final ZulipApp app) {
340340
Html.ImageGetter emojiGetter = new Html.ImageGetter() {
341341
@Override
342342
public Drawable getDrawable(String source) {
343-
String filename = "emoji/" + source.replace(":", "") + ".png";
343+
int imagesIndex;
344+
String filename;
345+
if (source != null) {
346+
imagesIndex = source.indexOf("images/");
347+
if (imagesIndex != -1) {
348+
filename = source.substring(imagesIndex + "images/".length());
349+
} else {
350+
filename = "emoji/unicode/" + source + ".png";
351+
}
344352
try {
345353
Drawable drawable = Drawable.createFromStream(context
346354
.getAssets().open(filename), filename);
@@ -361,6 +369,7 @@ public Drawable getDrawable(String source) {
361369
} catch (IOException e) {
362370
Log.e("RecyclerMessageAdapter", e.getMessage());
363371
}
372+
}
364373
return null;
365374
}
366375
};

app/src/main/java/com/zulip/android/networking/AsyncGetEvents.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ private void processMessages(final List<Message> messages) {
412412
// In task thread
413413
int lastMessageId = messages.get(messages.size() - 1).getID();
414414
MessageRange.updateNewMessagesRange(app, lastMessageId);
415-
416415
if (mActivity != null) {
417416
mActivity.runOnUiThread(new Runnable() {
418417
@Override

app/src/main/java/com/zulip/android/util/CustomHtmlToSpannedConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private static void end(SpannableStringBuilder text, Class kind, Object repl) {
176176
private static void startImg(SpannableStringBuilder text,
177177
Attributes attributes, Html.ImageGetter img) {
178178
String cssClass = attributes.getValue("class");
179-
String src = cssClass != null && cssClass.startsWith("emoji") ? attributes.getValue("title") : attributes.getValue("", "src");
179+
String src = cssClass != null && attributes.getValue("", "src") == null ? cssClass.substring(cssClass.indexOf("-") + 1) : attributes.getValue("", "src");
180180
Drawable d = null;
181181

182182
if (img != null) {

0 commit comments

Comments
 (0)