Skip to content

Commit

Permalink
Update to 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Jun 29, 2015
1 parent 1634618 commit a93d299
Show file tree
Hide file tree
Showing 207 changed files with 7,574 additions and 2,830 deletions.
14 changes: 3 additions & 11 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'

repositories {
mavenCentral()
}

dependencies {
compile 'com.android.support:support-v4:22.1.+'
compile 'com.android.support:support-v4:22.2.+'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.5.+'
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
Expand Down Expand Up @@ -81,7 +73,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 542
versionName "2.9.1"
versionCode 572
versionName "3.0.1"
}
}
6 changes: 3 additions & 3 deletions TMessagesProj/jni/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jcl

AndroidBitmapInfo info;
int i;

if ((i = AndroidBitmap_getInfo(env, bitmap, &info)) >= 0) {
char *fileName = (*env)->GetStringUTFChars(env, path, NULL);
FILE *infile;

if ((infile = fopen(fileName, "rb"))) {
struct my_error_mgr jerr;
struct jpeg_decompress_struct cinfo;

cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;

Expand Down Expand Up @@ -557,7 +557,7 @@ JNIEXPORT jobject Java_org_telegram_messenger_Utilities_loadWebpImage(JNIEnv *en
if (!WebPDecodeRGBAInto((uint8_t*)inputBuffer, len, (uint8_t*)bitmapPixels, bitmapInfo.height * bitmapInfo.stride, bitmapInfo.stride)) {
AndroidBitmap_unlockPixels(env, outputBitmap);
(*env)->DeleteLocalRef(env, outputBitmap);
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to unlock Bitmap pixels");
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to decode webp image");
return 0;
}

Expand Down
Binary file modified TMessagesProj/libs/armeabi-v7a/libtmessages.8.so
Binary file not shown.
Binary file modified TMessagesProj/libs/armeabi/libtmessages.8.so
Binary file not shown.
Binary file modified TMessagesProj/libs/x86/libtmessages.8.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

package org.telegram.SQLite;

import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;

import java.nio.ByteBuffer;
import java.util.HashMap;

public class SQLitePreparedStatement {
private boolean isFinalized = false;
Expand All @@ -19,13 +21,24 @@ public class SQLitePreparedStatement {
private int queryArgsCount;
private boolean finalizeAfterQuery = false;

private static HashMap<SQLitePreparedStatement, String> hashMap;

public int getStatementHandle() {
return sqliteStatementHandle;
}

public SQLitePreparedStatement(SQLiteDatabase db, String sql, boolean finalize) throws SQLiteException {
finalizeAfterQuery = finalize;
sqliteStatementHandle = prepare(db.getSQLiteHandle(), sql);
if (BuildVars.DEBUG_VERSION) {
if (hashMap == null) {
hashMap = new HashMap<>();
}
hashMap.put(this, sql);
for (HashMap.Entry<SQLitePreparedStatement, String> entry : hashMap.entrySet()) {
FileLog.d("tmessages", "exist entry = " + entry.getValue());
}
}
}


Expand Down Expand Up @@ -88,6 +101,9 @@ public void finalizeQuery() {
return;
}
try {
if (BuildVars.DEBUG_VERSION) {
hashMap.remove(this);
}
isFinalized = true;
finalize(sqliteStatementHandle);
} catch (SQLiteException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,22 +616,31 @@ public static void clearDrawableAnimation(View view) {
}
}

public static final int FLAG_TAG_BR = 1;
public static final int FLAG_TAG_BOLD = 2;
public static final int FLAG_TAG_COLOR = 4;
public static final int FLAG_TAG_ALL = FLAG_TAG_BR | FLAG_TAG_BOLD | FLAG_TAG_COLOR;

public static Spannable replaceTags(String str) {
return replaceTags(str, FLAG_TAG_ALL);
}

public static Spannable replaceTags(String str, int flag) {
try {
int start;
int startColor = -1;
int end;
StringBuilder stringBuilder = new StringBuilder(str);
while ((start = stringBuilder.indexOf("<br>")) != -1) {
stringBuilder.replace(start, start + 4, "\n");
}
while ((start = stringBuilder.indexOf("<br/>")) != -1) {
stringBuilder.replace(start, start + 5, "\n");
if ((flag & FLAG_TAG_BR) != 0) {
while ((start = stringBuilder.indexOf("<br>")) != -1) {
stringBuilder.replace(start, start + 4, "\n");
}
while ((start = stringBuilder.indexOf("<br/>")) != -1) {
stringBuilder.replace(start, start + 5, "\n");
}
}
ArrayList<Integer> bolds = new ArrayList<>();
ArrayList<Integer> colors = new ArrayList<>();
while ((start = stringBuilder.indexOf("<b>")) != -1 || (startColor = stringBuilder.indexOf("<c#")) != -1) {
if (start != -1) {
if ((flag & FLAG_TAG_BOLD) != 0) {
while ((start = stringBuilder.indexOf("<b>")) != -1) {
stringBuilder.replace(start, start + 3, "");
end = stringBuilder.indexOf("</b>");
if (end == -1) {
Expand All @@ -640,17 +649,20 @@ public static Spannable replaceTags(String str) {
stringBuilder.replace(end, end + 4, "");
bolds.add(start);
bolds.add(end);
} else if (startColor != -1) {
stringBuilder.replace(startColor, startColor + 2, "");
end = stringBuilder.indexOf(">", startColor);
int color = Color.parseColor(stringBuilder.substring(startColor, end));
stringBuilder.replace(startColor, end + 1, "");
}
}
ArrayList<Integer> colors = new ArrayList<>();
if ((flag & FLAG_TAG_COLOR) != 0) {
while ((start = stringBuilder.indexOf("<c#")) != -1) {
stringBuilder.replace(start, start + 2, "");
end = stringBuilder.indexOf(">", start);
int color = Color.parseColor(stringBuilder.substring(start, end));
stringBuilder.replace(start, end + 1, "");
end = stringBuilder.indexOf("</c>");
stringBuilder.replace(end, end + 4, "");
colors.add(startColor);
colors.add(start);
colors.add(end);
colors.add(color);
startColor = -1;
}
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(stringBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ public AnimatorSetProxy setDuration(long duration) {
return this;
}

public AnimatorSetProxy setStartDelay(long delay) {
if (View10.NEED_PROXY) {
((AnimatorSet10) animatorSet).setStartDelay(delay);
} else {
((AnimatorSet) animatorSet).setStartDelay(delay);
}
return this;
}

public void start() {
if (View10.NEED_PROXY) {
((AnimatorSet10) animatorSet).start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,14 +956,8 @@ public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) {
public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) {
TLRPC.User user1 = usersDict.get(tl_contact.user_id);
TLRPC.User user2 = usersDict.get(tl_contact2.user_id);
String name1 = user1.first_name;
if (name1 == null || name1.length() == 0) {
name1 = user1.last_name;
}
String name2 = user2.first_name;
if (name2 == null || name2.length() == 0) {
name2 = user2.last_name;
}
String name1 = UserObject.getFirstName(user1);
String name2 = UserObject.getFirstName(user2);
return name1.compareTo(name2);
}
});
Expand All @@ -989,10 +983,7 @@ public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) {
contactsByPhonesDict.put(user.phone, value);
}

String key = user.first_name;
if (key == null || key.length() == 0) {
key = user.last_name;
}
String key = UserObject.getFirstName(user);
if (key.length() > 1) {
key = key.substring(0, 1);
}
Expand Down Expand Up @@ -1160,14 +1151,8 @@ private void buildContactsSectionsArrays(boolean sort) {
public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) {
TLRPC.User user1 = MessagesController.getInstance().getUser(tl_contact.user_id);
TLRPC.User user2 = MessagesController.getInstance().getUser(tl_contact2.user_id);
String name1 = user1.first_name;
if (name1 == null || name1.length() == 0) {
name1 = user1.last_name;
}
String name2 = user2.first_name;
if (name2 == null || name2.length() == 0) {
name2 = user2.last_name;
}
String name1 = UserObject.getFirstName(user1);
String name2 = UserObject.getFirstName(user2);
return name1.compareTo(name2);
}
});
Expand All @@ -1183,10 +1168,7 @@ public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) {
continue;
}

String key = user.first_name;
if (key == null || key.length() == 0) {
key = user.last_name;
}
String key = UserObject.getFirstName(user);
if (key.length() > 1) {
key = key.substring(0, 1);
}
Expand Down Expand Up @@ -1638,7 +1620,7 @@ public void run() {

for (TLRPC.User user : users) {
if (user.phone != null && user.phone.length() > 0) {
CharSequence name = ContactsController.formatName(user.first_name, user.last_name);
CharSequence name = UserObject.getUserName(user);
MessagesStorage.getInstance().applyPhoneBookUpdates(user.phone, "");
Contact contact = contactsBookSPhones.get(user.phone);
if (contact != null) {
Expand Down
29 changes: 25 additions & 4 deletions TMessagesProj/src/main/java/org/telegram/android/Emoji.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.Spanned;
import android.text.style.DynamicDrawableSpan;
import android.text.style.ImageSpan;
import android.view.View;
Expand Down Expand Up @@ -416,6 +417,14 @@ private static boolean inArray(char c, char[] a) {
return false;
}

private static boolean isNextCharIsColor(CharSequence cs, int i) {
if (i + 2 >= cs.length()) {
return false;
}
int value = cs.charAt(i + 1) << 16 | cs.charAt(i + 2);
return value == 0xd83cdffb || value == 0xd83cdffc || value == 0xd83cdffd || value == 0xd83cdffe || value == 0xd83cdfff;
}

public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, int size) {
if (cs == null || cs.length() == 0) {
return cs;
Expand All @@ -439,12 +448,16 @@ public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fo
buf |= c;
EmojiDrawable d = Emoji.getEmojiDrawable(buf);
if (d != null) {
boolean nextIsSkinTone = isNextCharIsColor(cs, i);
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
emojiCount++;
if (c >= 0xDDE6 && c <= 0xDDFA) {
s.setSpan(span, i - 3, i + 1, 0);
s.setSpan(span, i - 3, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
s.setSpan(span, i - 1, i + 1, 0);
s.setSpan(span, i - 1, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (nextIsSkinTone) {
i += 2;
}
}
buf = 0;
Expand All @@ -457,19 +470,27 @@ public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fo
buf |= c;
EmojiDrawable d = Emoji.getEmojiDrawable(buf);
if (d != null) {
boolean nextIsSkinTone = isNextCharIsColor(cs, i);
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
emojiCount++;
s.setSpan(span, i - 1, i + 1, 0);
s.setSpan(span, i - 1, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if (nextIsSkinTone) {
i += 2;
}
}
buf = 0;
}
}
} else if (inArray(c, emojiChars)) {
EmojiDrawable d = Emoji.getEmojiDrawable(c);
if (d != null) {
boolean nextIsSkinTone = isNextCharIsColor(cs, i);
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
emojiCount++;
s.setSpan(span, i, i + 1, 0);
s.setSpan(span, i, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if (nextIsSkinTone) {
i += 2;
}
}
}
if (emojiCount >= 50) {
Expand Down
Loading

0 comments on commit a93d299

Please sign in to comment.