mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Bug fixes
This commit is contained in:
parent
87612e006b
commit
5d042955cd
4 changed files with 18 additions and 76 deletions
|
@ -83,7 +83,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 302
|
||||
versionCode 303
|
||||
versionName "1.7.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,10 +47,7 @@ public class ContactsController {
|
|||
private final Integer observerLock = 1;
|
||||
public boolean contactsLoaded = false;
|
||||
private boolean contactsBookLoaded = false;
|
||||
private int lastContactsPhonesCount = -1;
|
||||
private int lastContactsPhonesMaxId = -1;
|
||||
private int lastContactsNamesCount = -1;
|
||||
private int lastContactsNamesMaxId = -1;
|
||||
private String lastContactsVersions = "";
|
||||
private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
|
||||
|
||||
public static class Contact {
|
||||
|
@ -119,10 +116,7 @@ public class ContactsController {
|
|||
contactsSyncInProgress = false;
|
||||
contactsLoaded = false;
|
||||
contactsBookLoaded = false;
|
||||
lastContactsPhonesCount = -1;
|
||||
lastContactsPhonesMaxId = -1;
|
||||
lastContactsNamesCount = -1;
|
||||
lastContactsNamesMaxId = -1;
|
||||
lastContactsVersions = "";
|
||||
}
|
||||
|
||||
public void checkAppAccount() {
|
||||
|
@ -191,70 +185,17 @@ public class ContactsController {
|
|||
ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();
|
||||
Cursor pCur = null;
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._ID}, null, null, ContactsContract.CommonDataKinds.Phone._ID + " desc LIMIT 1");
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsPhonesMaxId != -1 && value != lastContactsPhonesMaxId) {
|
||||
pCur = cr.query(ContactsContract.RawContacts.CONTENT_URI, new String[]{ContactsContract.RawContacts.VERSION}, null, null, null);
|
||||
StringBuilder currentVersion = new StringBuilder();
|
||||
while (pCur.moveToNext()) {
|
||||
int col = pCur.getColumnIndex(ContactsContract.RawContacts.VERSION);
|
||||
currentVersion.append(pCur.getString(col));
|
||||
}
|
||||
String newContactsVersion = currentVersion.toString();
|
||||
if (lastContactsVersions.length() != 0 && !lastContactsVersions.equals(newContactsVersion)) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsPhonesMaxId = value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
} finally {
|
||||
if (pCur != null) {
|
||||
pCur.close();
|
||||
}
|
||||
}
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._COUNT}, null, null, null);
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsPhonesCount != -1 && value != lastContactsPhonesCount) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsPhonesCount = value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
} finally {
|
||||
if (pCur != null) {
|
||||
pCur.close();
|
||||
}
|
||||
}
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._COUNT}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, null);
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsNamesCount != -1 && value != lastContactsNamesCount) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsNamesCount = value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
} finally {
|
||||
if (pCur != null) {
|
||||
pCur.close();
|
||||
}
|
||||
}
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._ID}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, ContactsContract.Data._ID + " desc LIMIT 1");
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsNamesMaxId != -1 && value != lastContactsNamesMaxId) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsNamesMaxId = value;
|
||||
}
|
||||
}
|
||||
lastContactsVersions = newContactsVersion;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
} finally {
|
||||
|
@ -368,7 +309,7 @@ public class ContactsController {
|
|||
String sname2 = pCur.getString(3);
|
||||
String mname = pCur.getString(4);
|
||||
Contact contact = contactsMap.get(id);
|
||||
if (contact != null) {
|
||||
if (contact != null && contact.first_name.length() == 0 && contact.last_name.length() == 0) {
|
||||
contact.first_name = fname;
|
||||
contact.last_name = sname;
|
||||
if (contact.first_name == null) {
|
||||
|
@ -535,7 +476,8 @@ public class ContactsController {
|
|||
}
|
||||
}
|
||||
|
||||
if (existing == null || existing != null && (!existing.first_name.equals(value.first_name) || !existing.last_name.equals(value.last_name))) {
|
||||
boolean nameChanged = existing != null && (!existing.first_name.equals(value.first_name) || !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);
|
||||
contactsBookShort.put(sphone, value);
|
||||
|
@ -550,7 +492,7 @@ public class ContactsController {
|
|||
}
|
||||
}
|
||||
if (request) {
|
||||
if (contactsByPhone.containsKey(sphone)) {
|
||||
if (!nameChanged && contactsByPhone.containsKey(sphone)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -2009,7 +2009,7 @@ public class MessagesStorage {
|
|||
} else {
|
||||
state.bindInteger(2, dialog_date != 0 ? dialog_date : value.date);
|
||||
}
|
||||
state.bindInteger(3, unread_count);
|
||||
state.bindInteger(3, old_unread_count + unread_count);
|
||||
state.bindInteger(4, messageId);
|
||||
state.step();
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ public class MessageObject {
|
|||
photoThumbs.add(obj);
|
||||
} else if (photoThumbs != null && !photoThumbs.isEmpty() && messageOwner.media.document.thumb != null) {
|
||||
PhotoObject photoObject = photoThumbs.get(0);
|
||||
photoObject.photoOwner.location = messageOwner.media.video.thumb.location;
|
||||
photoObject.photoOwner.location = messageOwner.media.document.thumb.location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue