Skip to content

Commit

Permalink
Update to 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Jul 22, 2015
1 parent a93d299 commit 82f9be2
Show file tree
Hide file tree
Showing 422 changed files with 10,934 additions and 1,584 deletions.
4 changes: 2 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 572
versionName "3.0.1"
versionCode 580
versionName "3.1.1"
}
}
14 changes: 13 additions & 1 deletion TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,20 @@

<service android:name="org.telegram.android.NotificationsService" android:enabled="true"/>
<service android:name="org.telegram.android.NotificationRepeat" android:exported="false"/>
<service android:name="org.telegram.android.NotificationDelay" android:exported="false"/>
<service android:name="org.telegram.android.VideoEncodingService" android:enabled="true"/>
<service android:name="org.telegram.android.MusicPlayerService" android:exported="true" android:enabled="true"/>

<receiver android:name="org.telegram.android.MusicPlayerReceiver" >
<intent-filter>
<action android:name="org.telegram.android.musicplayer.close" />
<action android:name="org.telegram.android.musicplayer.pause" />
<action android:name="org.telegram.android.musicplayer.next" />
<action android:name="org.telegram.android.musicplayer.play" />
<action android:name="org.telegram.android.musicplayer.previous" />
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.media.AUDIO_BECOMING_NOISY" />
</intent-filter>
</receiver>

<receiver android:name="org.telegram.android.AppStartReceiver" android:enabled="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.telegram.SQLite;

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

import java.nio.ByteBuffer;
Expand All @@ -30,15 +29,15 @@ public int getStatementHandle() {
public SQLitePreparedStatement(SQLiteDatabase db, String sql, boolean finalize) throws SQLiteException {
finalizeAfterQuery = finalize;
sqliteStatementHandle = prepare(db.getSQLiteHandle(), sql);
if (BuildVars.DEBUG_VERSION) {
/*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 @@ -101,9 +100,9 @@ public void finalizeQuery() {
return;
}
try {
if (BuildVars.DEBUG_VERSION) {
/*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 @@ -542,16 +542,6 @@ public static int getViewInset(View view) {
return 0;
}

public static int getCurrentActionBarHeight() {
if (isTablet()) {
return dp(64);
} else if (ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
return dp(48);
} else {
return dp(56);
}
}

public static Point getRealScreenSize() {
Point size = new Point();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public void playTogether(Object... items) {

public void playTogether(ArrayList<Object> items) {
if (View10.NEED_PROXY) {
ArrayList<Animator10> animators = new ArrayList<Animator10>();
ArrayList<Animator10> animators = new ArrayList<>();
for (Object obj : items) {
animators.add((Animator10)obj);
}
((AnimatorSet10) animatorSet).playTogether(animators);
} else {
ArrayList<Animator> animators = new ArrayList<Animator>();
ArrayList<Animator> animators = new ArrayList<>();
for (Object obj : items) {
animators.add((Animator)obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.net.Uri;
import android.provider.BaseColumns;
import android.provider.ContactsContract;
import android.text.TextUtils;
import android.util.SparseArray;

import org.telegram.PhoneFormat.PhoneFormat;
Expand Down Expand Up @@ -330,7 +331,7 @@ private HashMap<Integer, Contact> readContactsFromPhoneBook() {
ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();

HashMap<String, Contact> shortContacts = new HashMap<>();
StringBuilder ids = new StringBuilder();
ArrayList<Integer> idsArr = new ArrayList<>();
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projectionPhones, null, null, null);
if (pCur != null) {
if (pCur.getCount() > 0) {
Expand All @@ -355,10 +356,9 @@ private HashMap<Integer, Contact> readContactsFromPhoneBook() {
}

Integer id = pCur.getInt(0);
if (ids.length() != 0) {
ids.append(",");
if (!idsArr.contains(id)) {
idsArr.add(id);
}
ids.append(id);

int type = pCur.getInt(2);
Contact contact = contactsMap.get(id);
Expand Down Expand Up @@ -392,8 +392,9 @@ private HashMap<Integer, Contact> readContactsFromPhoneBook() {
}
pCur.close();
}
String ids = TextUtils.join(",", idsArr);

pCur = cr.query(ContactsContract.Data.CONTENT_URI, projectionNames, ContactsContract.CommonDataKinds.StructuredName.CONTACT_ID + " IN (" + ids.toString() + ") AND " + ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, null);
pCur = cr.query(ContactsContract.Data.CONTENT_URI, projectionNames, ContactsContract.CommonDataKinds.StructuredName.CONTACT_ID + " IN (" + ids + ") AND " + ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, null);
if (pCur != null && pCur.getCount() > 0) {
while (pCur.moveToNext()) {
int id = pCur.getInt(0);
Expand Down Expand Up @@ -474,6 +475,23 @@ private HashMap<Integer, Contact> readContactsFromPhoneBook() {
FileLog.e("tmessages", e);
contactsMap.clear();
}
if (BuildVars.DEBUG_VERSION) {
for (HashMap.Entry<Integer, Contact> entry : contactsMap.entrySet()) {
Contact contact = entry.getValue();
FileLog.e("tmessages", "contact = " + contact.first_name + " " + contact.last_name);
if (contact.first_name.length() == 0 && contact.last_name.length() == 0 && contact.phones.size() > 0) {
FileLog.e("tmessages", "warning, empty name for contact = " + contact.id);
}
FileLog.e("tmessages", "phones:");
for (String s : contact.phones) {
FileLog.e("tmessages", "phone = " + s);
}
FileLog.e("tmessages", "short phones:");
for (String s : contact.shortPhones) {
FileLog.e("tmessages", "short phone = " + s);
}
}
}
return contactsMap;
}

Expand Down Expand Up @@ -569,7 +587,7 @@ public void run() {
}
}

boolean nameChanged = existing != null && (!existing.first_name.equals(value.first_name) || !existing.last_name.equals(value.last_name));
boolean nameChanged = existing != null && (value.first_name.length() != 0 && !existing.first_name.equals(value.first_name) || value.last_name != null && !existing.last_name.equals(value.last_name));
if (existing == null || nameChanged) {
for (int a = 0; a < value.phones.size(); a++) {
String sphone = value.shortPhones.get(a);
Expand Down Expand Up @@ -607,8 +625,12 @@ public void run() {
int index = existing.shortPhones.indexOf(sphone);
if (index == -1) {
if (request) {
if (contactsByPhone.containsKey(sphone)) {
continue;
TLRPC.TL_contact contact = contactsByPhone.get(sphone);
if (contact != null) {
TLRPC.User user = MessagesController.getInstance().getUser(contact.user_id);
if (user == null || user.first_name != null && user.first_name.length() != 0 || user.last_name != null && user.last_name.length() != 0) {
continue;
}
}

TLRPC.TL_inputPhoneContact imp = new TLRPC.TL_inputPhoneContact();
Expand Down Expand Up @@ -702,8 +724,12 @@ public void run() {
int id = pair.getKey();
for (int a = 0; a < value.phones.size(); a++) {
String phone = value.shortPhones.get(a);
if (contactsByPhone.containsKey(phone)) {
continue;
TLRPC.TL_contact contact = contactsByPhone.get(phone);
if (contact != null) {
TLRPC.User user = MessagesController.getInstance().getUser(contact.user_id);
if (user == null || user.first_name != null && user.first_name.length() != 0 || user.last_name != null && user.last_name.length() != 0) {
continue;
}
}
TLRPC.TL_inputPhoneContact imp = new TLRPC.TL_inputPhoneContact();
imp.client_id = id;
Expand All @@ -721,9 +747,9 @@ public void run() {
if (!toImport.isEmpty()) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "start import contacts");
// for (TLRPC.TL_inputPhoneContact contact : toImport) {
// FileLog.e("tmessages", "add contact " + contact.first_name + " " + contact.last_name + " " + contact.phone);
// }
for (TLRPC.TL_inputPhoneContact contact : toImport) {
FileLog.e("tmessages", "add contact " + contact.first_name + " " + contact.last_name + " " + contact.phone);
}
}
final int count = (int)Math.ceil(toImport.size() / 500.0f);
for (int a = 0; a < count; a++) {
Expand All @@ -743,9 +769,9 @@ public void run(TLObject response, TLRPC.TL_error error) {
}
TLRPC.TL_contacts_importedContacts res = (TLRPC.TL_contacts_importedContacts)response;
if (BuildVars.DEBUG_VERSION) {
// for (TLRPC.User user : res.users) {
// FileLog.e("tmessages", "received user " + user.first_name + " " + user.last_name + " " + user.phone);
// }
for (TLRPC.User user : res.users) {
FileLog.e("tmessages", "received user " + user.first_name + " " + user.last_name + " " + user.phone);
}
}
MessagesStorage.getInstance().putUsersAndChats(res.users, null, true, true);
ArrayList<TLRPC.TL_contact> cArr = new ArrayList<>();
Expand Down Expand Up @@ -903,9 +929,9 @@ public void run() {
if (user != null) {
usersDict.put(user.id, user);

// if (BuildVars.DEBUG_VERSION) {
// FileLog.e("tmessages", "loaded user contact " + user.first_name + " " + user.last_name + " " + user.phone);
// }
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "loaded user contact " + user.first_name + " " + user.last_name + " " + user.phone);
}
}
}

Expand Down Expand Up @@ -1524,9 +1550,9 @@ public void addContact(TLRPC.User user) {
contactsParams.add(c);
req.contacts = contactsParams;
req.replace = false;
// if (BuildVars.DEBUG_VERSION) {
// FileLog.e("tmessages", "add contact " + user.first_name + " " + user.last_name + " " + user.phone);
// }
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "add contact " + user.first_name + " " + user.last_name + " " + user.phone);
}
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
Expand All @@ -1536,11 +1562,11 @@ public void run(TLObject response, TLRPC.TL_error error) {
final TLRPC.TL_contacts_importedContacts res = (TLRPC.TL_contacts_importedContacts)response;
MessagesStorage.getInstance().putUsersAndChats(res.users, null, true, true);

// if (BuildVars.DEBUG_VERSION) {
// for (TLRPC.User user : res.users) {
// FileLog.e("tmessages", "received user " + user.first_name + " " + user.last_name + " " + user.phone);
// }
// }
if (BuildVars.DEBUG_VERSION) {
for (TLRPC.User user : res.users) {
FileLog.e("tmessages", "received user " + user.first_name + " " + user.last_name + " " + user.phone);
}
}

for (final TLRPC.User u : res.users) {
Utilities.phoneBookQueue.postRunnable(new Runnable() {
Expand Down
Loading

0 comments on commit 82f9be2

Please sign in to comment.