Bug fixes

This commit is contained in:
DrKLO 2014-08-07 01:27:24 +04:00
parent 87612e006b
commit 5d042955cd
4 changed files with 18 additions and 76 deletions

View file

@ -83,7 +83,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 302 versionCode 303
versionName "1.7.0" versionName "1.7.0"
} }
} }

View file

@ -47,10 +47,7 @@ public class ContactsController {
private final Integer observerLock = 1; private final Integer observerLock = 1;
public boolean contactsLoaded = false; public boolean contactsLoaded = false;
private boolean contactsBookLoaded = false; private boolean contactsBookLoaded = false;
private int lastContactsPhonesCount = -1; private String lastContactsVersions = "";
private int lastContactsPhonesMaxId = -1;
private int lastContactsNamesCount = -1;
private int lastContactsNamesMaxId = -1;
private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>(); private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
public static class Contact { public static class Contact {
@ -119,10 +116,7 @@ public class ContactsController {
contactsSyncInProgress = false; contactsSyncInProgress = false;
contactsLoaded = false; contactsLoaded = false;
contactsBookLoaded = false; contactsBookLoaded = false;
lastContactsPhonesCount = -1; lastContactsVersions = "";
lastContactsPhonesMaxId = -1;
lastContactsNamesCount = -1;
lastContactsNamesMaxId = -1;
} }
public void checkAppAccount() { public void checkAppAccount() {
@ -191,70 +185,17 @@ public class ContactsController {
ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver(); ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();
Cursor pCur = null; Cursor pCur = null;
try { try {
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._ID}, null, null, ContactsContract.CommonDataKinds.Phone._ID + " desc LIMIT 1"); pCur = cr.query(ContactsContract.RawContacts.CONTENT_URI, new String[]{ContactsContract.RawContacts.VERSION}, null, null, null);
if (pCur != null) { StringBuilder currentVersion = new StringBuilder();
if (pCur.getCount() > 0 && pCur.moveToFirst()) { while (pCur.moveToNext()) {
int value = pCur.getInt(0); int col = pCur.getColumnIndex(ContactsContract.RawContacts.VERSION);
if (lastContactsPhonesMaxId != -1 && value != lastContactsPhonesMaxId) { currentVersion.append(pCur.getString(col));
reload = true;
}
lastContactsPhonesMaxId = value;
}
} }
} catch (Exception e) { String newContactsVersion = currentVersion.toString();
FileLog.e("tmessages", e); if (lastContactsVersions.length() != 0 && !lastContactsVersions.equals(newContactsVersion)) {
} finally { reload = true;
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) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} finally { } finally {
@ -368,7 +309,7 @@ public class ContactsController {
String sname2 = pCur.getString(3); String sname2 = pCur.getString(3);
String mname = pCur.getString(4); String mname = pCur.getString(4);
Contact contact = contactsMap.get(id); 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.first_name = fname;
contact.last_name = sname; contact.last_name = sname;
if (contact.first_name == null) { 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++) { for (int a = 0; a < value.phones.size(); a++) {
String sphone = value.shortPhones.get(a); String sphone = value.shortPhones.get(a);
contactsBookShort.put(sphone, value); contactsBookShort.put(sphone, value);
@ -550,7 +492,7 @@ public class ContactsController {
} }
} }
if (request) { if (request) {
if (contactsByPhone.containsKey(sphone)) { if (!nameChanged && contactsByPhone.containsKey(sphone)) {
continue; continue;
} }

View file

@ -2009,7 +2009,7 @@ public class MessagesStorage {
} else { } else {
state.bindInteger(2, dialog_date != 0 ? dialog_date : value.date); 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.bindInteger(4, messageId);
state.step(); state.step();
} }

View file

@ -380,7 +380,7 @@ public class MessageObject {
photoThumbs.add(obj); photoThumbs.add(obj);
} else if (photoThumbs != null && !photoThumbs.isEmpty() && messageOwner.media.document.thumb != null) { } else if (photoThumbs != null && !photoThumbs.isEmpty() && messageOwner.media.document.thumb != null) {
PhotoObject photoObject = photoThumbs.get(0); PhotoObject photoObject = photoThumbs.get(0);
photoObject.photoOwner.location = messageOwner.media.video.thumb.location; photoObject.photoOwner.location = messageOwner.media.document.thumb.location;
} }
} }
} }