Commit c6b1a343 authored by DrKLO's avatar DrKLO

Updated database structure, updated sqlite (don't use this source code, it may be changed)

parent 43674c48
This diff is collapsed.
This diff is collapsed.
......@@ -236,7 +236,7 @@ public class ContactsController {
ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();
HashMap<String, Contact> shortContacts = new HashMap<String, Contact>();
String ids = "";
StringBuilder ids = new StringBuilder();
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projectionPhones, null, null, null);
if (pCur != null) {
if (pCur.getCount() > 0) {
......@@ -262,9 +262,9 @@ public class ContactsController {
Integer id = pCur.getInt(0);
if (ids.length() != 0) {
ids += ",";
ids.append(",");
}
ids += id;
ids.append(id);
int type = pCur.getInt(2);
Contact contact = contactsMap.get(id);
......@@ -299,7 +299,7 @@ public class ContactsController {
pCur.close();
}
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);
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);
if (pCur != null && pCur.getCount() > 0) {
while (pCur.moveToNext()) {
int id = pCur.getInt(0);
......@@ -844,14 +844,14 @@ public class ContactsController {
return 0;
}
});
String ids = "";
StringBuilder ids = new StringBuilder();
for (TLRPC.TL_contact aContactsArr : contactsArr) {
if (ids.length() != 0) {
ids += ",";
ids.append(",");
}
ids += aContactsArr.user_id;
ids.append(aContactsArr.user_id);
}
UserConfig.contactsHash = Utilities.MD5(ids);
UserConfig.contactsHash = Utilities.MD5(ids.toString());
UserConfig.saveConfig(false);
}
......@@ -1084,7 +1084,7 @@ public class ContactsController {
});
}
String ids = "";
StringBuilder ids = new StringBuilder();
final HashMap<String, ArrayList<TLRPC.TL_contact>> sectionsDict = new HashMap<String, ArrayList<TLRPC.TL_contact>>();
final ArrayList<String> sortedSectionsArray = new ArrayList<String>();
......@@ -1114,11 +1114,11 @@ public class ContactsController {
}
arr.add(value);
if (ids.length() != 0) {
ids += ",";
ids.append(",");
}
ids += value.user_id;
ids.append(value.user_id);
}
UserConfig.contactsHash = Utilities.MD5(ids);
UserConfig.contactsHash = Utilities.MD5(ids.toString());
UserConfig.saveConfig(false);
Collections.sort(sortedSectionsArray, new Comparator<String>() {
......@@ -1189,8 +1189,8 @@ public class ContactsController {
}
FileLog.e("tmessages", "process update - contacts add = " + newC.size() + " delete = " + contactsTD.size());
String toAdd = "";
String toDelete = "";
StringBuilder toAdd = new StringBuilder();
StringBuilder toDelete = new StringBuilder();
boolean reloadContacts = false;
for (TLRPC.TL_contact newContact : newC) {
......@@ -1216,9 +1216,9 @@ public class ContactsController {
}
}
if (toAdd.length() != 0) {
toAdd += ",";
toAdd.append(",");
}
toAdd += user.phone;
toAdd.append(user.phone);
}
for (final Integer uid : contactsTD) {
......@@ -1252,14 +1252,14 @@ public class ContactsController {
}
}
if (toDelete.length() != 0) {
toDelete += ",";
toDelete.append(",");
}
toDelete += user.phone;
toDelete.append(user.phone);
}
}
if (toAdd.length() != 0 || toDelete.length() != 0) {
MessagesStorage.getInstance().applyPhoneBookUpdates(toAdd, toDelete);
MessagesStorage.getInstance().applyPhoneBookUpdates(toAdd.toString(), toDelete.toString());
}
if (reloadContacts) {
......
......@@ -69,7 +69,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
private boolean gettingNewDeleteTask = false;
private int currentDeletingTaskTime = 0;
private Long currentDeletingTask = null;
private ArrayList<Integer> currentDeletingTaskMids = null;
public int totalDialogsCount = 0;
......@@ -322,7 +321,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
currentDeletingTaskTime = 0;
currentDeletingTaskMids = null;
gettingNewDeleteTask = false;
currentDeletingTask = null;
loadingDialogs = false;
dialogsEndReached = false;
gettingDifference = false;
......@@ -508,14 +506,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
if (currentDeletingTask == null && !gettingNewDeleteTask || currentDeletingTaskTime != 0 && minDate < currentDeletingTaskTime) {
if (currentDeletingTaskMids == null && !gettingNewDeleteTask || currentDeletingTaskTime != 0 && minDate < currentDeletingTaskTime) {
getNewDeleteTask(null);
}
}
});
}
public void getNewDeleteTask(final Long oldTask) {
public void getNewDeleteTask(final ArrayList<Integer> oldTask) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
......@@ -528,7 +526,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
private void checkDeletingTask() {
int currentServerTime = ConnectionsManager.getInstance().getCurrentTime();
if (currentDeletingTask != null && currentDeletingTaskTime != 0 && currentDeletingTaskTime <= currentServerTime) {
if (currentDeletingTaskMids != null && currentDeletingTaskTime != 0 && currentDeletingTaskTime <= currentServerTime) {
currentDeletingTaskTime = 0;
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
......@@ -538,9 +536,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
getNewDeleteTask(currentDeletingTask);
getNewDeleteTask(currentDeletingTaskMids);
currentDeletingTaskTime = 0;
currentDeletingTask = null;
currentDeletingTaskMids = null;
}
});
}
......@@ -548,20 +546,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
public void processLoadedDeleteTask(final Long taskId, final int taskTime, final ArrayList<Integer> messages) {
public void processLoadedDeleteTask(final int taskTime, final ArrayList<Integer> messages) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
gettingNewDeleteTask = false;
if (taskId != null) {
if (messages != null) {
currentDeletingTaskTime = taskTime;
currentDeletingTask = taskId;
currentDeletingTaskMids = messages;
checkDeletingTask();
} else {
currentDeletingTaskTime = 0;
currentDeletingTask = null;
currentDeletingTaskMids = null;
}
}
......@@ -1275,10 +1271,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
public void loadMessages(final long dialog_id, final int count, final int max_id, boolean fromCache, int midDate, final int classGuid, boolean from_unread, boolean forward) {
public void loadMessages(final long dialog_id, final int count, final int max_id, boolean fromCache, int midDate, final int classGuid, boolean from_unread, boolean forward, final Semaphore semaphore) {
int lower_part = (int)dialog_id;
if (fromCache || lower_part == 0) {
MessagesStorage.getInstance().getMessages(dialog_id, count, max_id, midDate, classGuid, from_unread, forward);
MessagesStorage.getInstance().getMessages(dialog_id, count, max_id, midDate, classGuid, from_unread, forward, semaphore);
} else {
TLRPC.TL_messages_getHistory req = new TLRPC.TL_messages_getHistory();
if (lower_part < 0) {
......@@ -1303,7 +1299,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
final TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
processLoadedMessages(res, dialog_id, count, max_id, false, classGuid, 0, 0, 0, 0, false);
processLoadedMessages(res, dialog_id, count, max_id, false, classGuid, 0, 0, 0, 0, false, semaphore);
}
}
});
......@@ -1311,7 +1307,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
public void processLoadedMessages(final TLRPC.messages_Messages messagesRes, final long dialog_id, final int count, final int max_id, final boolean isCache, final int classGuid, final int first_unread, final int last_unread, final int unread_count, final int last_date, final boolean isForward) {
public void processLoadedMessages(final TLRPC.messages_Messages messagesRes, final long dialog_id, final int count, final int max_id, final boolean isCache, final int classGuid, final int first_unread, final int last_unread, final int unread_count, final int last_date, final boolean isForward, final Semaphore semaphore) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
......@@ -1320,10 +1316,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
}
if (lower_id != 0 && isCache && messagesRes.messages.size() == 0 && !isForward) {
if (semaphore != null) {
semaphore.release();
}
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
loadMessages(dialog_id, count, max_id, false, 0, classGuid, false, false);
loadMessages(dialog_id, count, max_id, false, 0, classGuid, false, false, null);
}
});
return;
......@@ -1337,14 +1336,21 @@ public class MessagesController implements NotificationCenter.NotificationCenter
message.dialog_id = dialog_id;
objects.add(new MessageObject(message, usersLocal, 2));
}
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
putUsers(messagesRes.users, isCache);
putChats(messagesRes.chats, isCache);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDidLoaded, dialog_id, count, objects, isCache, first_unread, last_unread, unread_count, last_date, isForward);
}
});
if (semaphore != null) {
putUsers(messagesRes.users, isCache);
putChats(messagesRes.chats, isCache);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDidLoaded, dialog_id, count, objects, isCache, first_unread, last_unread, unread_count, last_date, isForward);
semaphore.release();
} else {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
putUsers(messagesRes.users, isCache);
putChats(messagesRes.chats, isCache);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDidLoaded, dialog_id, count, objects, isCache, first_unread, last_unread, unread_count, last_date, isForward);
}
});
}
}
});
}
......
......@@ -24,9 +24,9 @@ import java.util.zip.ZipFile;
public class NativeLoader {
private static final long sizes[] = new long[] {
946908, //armeabi
1028848, //armeabi-v7a
1603780, //x86
951052, //armeabi
1032992, //armeabi-v7a
1612020, //x86
0, //mips
};
......
......@@ -9000,6 +9000,41 @@ public class TLRPC {
}
}
public static class TL_message_secret extends TL_message {
public static int constructor = 0x555555F8;
public void readParams(AbsSerializedData stream) {
id = stream.readInt32();
from_id = stream.readInt32();
to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
out = stream.readBool();
unread = stream.readBool();
date = stream.readInt32();
message = stream.readString();
media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) {
attachPath = stream.readString();
}
if (id < 0 && message.length() > 6 && media instanceof TL_messageMediaVideo) {
videoEditedInfo = new VideoEditedInfo();
videoEditedInfo.parseString(message);
}
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(id);
stream.writeInt32(from_id);
to_id.serializeToStream(stream);
stream.writeBool(out);
stream.writeBool(unread);
stream.writeInt32(date);
stream.writeString(message);
media.serializeToStream(stream);
stream.writeString(attachPath);
}
}
public static class TL_messages_deleteMessages extends TLObject {
public static int constructor = 0x14f2dd0a;
......
......@@ -117,6 +117,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private TypingDotsDrawable typingDotsDrawable;
private View emptyViewContainer;
private ArrayList<View> actionModeViews = new ArrayList<View>();
private Semaphore testSemaphore = new Semaphore(0);
private TextView bottomOverlayText;
......@@ -352,7 +353,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
super.onFragmentCreate();
loading = true;
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false);
MessagesController.getInstance().loadMessages(dialog_id, AndroidUtilities.isTablet() ? 30 : 20, 0, true, 0, classGuid, true, false, testSemaphore);
try {
testSemaphore.acquire();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (currentUser != null) {
userBlocked = MessagesController.getInstance().blockedUsers.contains(currentUser.id);
}
......@@ -766,16 +774,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (firstVisibleItem <= 4) {
if (!endReached && !loading) {
if (messagesByDays.size() != 0) {
MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced, minDate, classGuid, false, false);
MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced, minDate, classGuid, false, false, null);
} else {
MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReaced, minDate, classGuid, false, false);
MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReaced, minDate, classGuid, false, false, null);
}
loading = true;
}
}
if (firstVisibleItem + visibleItemCount >= totalItemCount - 6) {
if (!unread_end_reached && !loadingForward) {
MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, true, maxDate, classGuid, false, true);
MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, true, maxDate, classGuid, false, true, null);
loadingForward = true;
}
}
......@@ -896,7 +904,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
unread_end_reached = true;
loading = true;
chatAdapter.notifyDataSetChanged();
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false);
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false, null);
}
}
......@@ -2249,7 +2257,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
maxDate = Integer.MIN_VALUE;
minDate = 0;
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, !cacheEndReaced, minDate, classGuid, false, false);
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, !cacheEndReaced, minDate, classGuid, false, false, null);
loading = true;
}
}
......
......@@ -2138,7 +2138,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
float ai = -1;
if (System.currentTimeMillis() - animationStartTime < animationDuration) {
ai = interpolator.getInterpolation((float)(System.currentTimeMillis() - animationStartTime) / animationDuration);
if (ai >= 0.95) {
if (ai >= 0.999f) {
ai = -1;
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<decelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:factor="1.5" />
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="0.9"
android:fromYScale="0.9"
android:toXScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="150"/>
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="150" />
<!--<scale-->
<!--android:fromXScale="0.9"-->
<!--android:fromYScale="0.9"-->
<!--android:toXScale="1.0"-->
<!--android:toYScale="1.0"-->
<!--android:pivotX="50%"-->
<!--android:pivotY="50%"-->
<!--android:interpolator="@android:anim/decelerate_interpolator"-->
<!--android:duration="220"/>-->
<!--<alpha android:fromAlpha="0.0"-->
<!--android:toAlpha="1.0"-->
<!--android:interpolator="@android:anim/decelerate_interpolator"-->
<!--android:duration="@android:integer/config_mediumAnimTime" />-->
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@anim/decelerate_cubic"
android:duration="220"/>
<scale
android:fromXScale=".8" android:toXScale="1.0"
android:fromYScale=".8" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:interpolator="@anim/decelerate_cubic"
android:duration="220"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="0.9"
android:toYScale="0.9"
android:pivotX="50%"
android:pivotY="50%"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:duration="150"/>
<!--<scale-->
<!--android:fromXScale="1.0"-->
<!--android:fromYScale="1.0"-->
<!--android:toXScale="0.9"-->
<!--android:toYScale="0.9"-->
<!--android:pivotX="50%"-->
<!--android:pivotY="50%"-->
<!--android:interpolator="@android:anim/decelerate_interpolator"-->
<!--android:duration="220"/>-->
<!--<alpha-->
<!--android:fromAlpha="1.0"-->
<!--android:toAlpha="0.0"-->
<!--android:interpolator="@android:anim/decelerate_interpolator"-->
<!--android:duration="220" />-->
<alpha android:fromAlpha="1.0"
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:duration="150" />
android:interpolator="@anim/decelerate_cubic"
android:duration="220"/>
<scale
android:fromXScale="1.0"
android:toXScale=".8"
android:fromYScale="1.0"
android:toYScale=".8"
android:pivotX="50%p"
android:pivotY="50%p"
android:interpolator="@anim/decelerate_cubic"
android:duration="220"/>
</set>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment