diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 235ad19bf..f776b919a 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -80,7 +80,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 19 - versionCode 358 + versionCode 359 versionName "1.9.5" } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java index b4e1a6f42..722277b21 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java @@ -67,6 +67,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter private long updatesStartWaitTime = 0; public ArrayList delayedEncryptedChatUpdates = new ArrayList(); private boolean startingSecretChat = false; + private ArrayList loadingFullUsers = new ArrayList(); + private ArrayList loadedFullUsers = new ArrayList(); private boolean gettingNewDeleteTask = false; private int currentDeletingTaskTime = 0; @@ -318,6 +320,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter delayedEncryptedChatUpdates.clear(); blockedUsers.clear(); sendingTypings.clear(); + loadingFullUsers.clear(); + loadedFullUsers.clear(); updatesStartWaitTime = 0; currentDeletingTaskTime = 0; @@ -389,6 +393,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter users.put(user.id, user); if (user.id == UserConfig.getClientUserId()) { UserConfig.setCurrentUser(user); + UserConfig.saveConfig(true); } if (oldUser != null && user.status != null && oldUser.status != null && user.status.expires != oldUser.status.expires) { return true; @@ -459,10 +464,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } + public void cancelLoadFullUser(int uid) { + loadingFullUsers.remove((Integer) uid); + } + public void loadFullUser(final TLRPC.User user, final int classGuid) { - if (user == null) { + if (user == null || loadingFullUsers.contains(user.id) || loadedFullUsers.contains(user.id)) { return; } + loadingFullUsers.add(user.id); TLRPC.TL_users_getFullUser req = new TLRPC.TL_users_getFullUser(); req.id = getInputUser(user); long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { @@ -472,10 +482,24 @@ public class MessagesController implements NotificationCenter.NotificationCenter AndroidUtilities.RunOnUIThread(new Runnable() { @Override public void run() { + loadingFullUsers.remove((Integer)user.id); + loadedFullUsers.add(user.id); + String names = user.first_name + user.last_name + user.username; TLRPC.TL_userFull userFull = (TLRPC.TL_userFull)response; ArrayList users = new ArrayList(); users.add(userFull.user); putUsers(users, false); + MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); + if (!names.equals(userFull.user.first_name + userFull.user.last_name + userFull.user.username)) { + NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_NAME); + } + } + }); + } else { + AndroidUtilities.RunOnUIThread(new Runnable() { + @Override + public void run() { + loadingFullUsers.remove((Integer)user.id); } }); } @@ -3153,6 +3177,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter newChat.user_id = exist.user_id; newChat.auth_key = exist.auth_key; newChat.ttl = exist.ttl; + newChat.seq_in = exist.seq_in; + newChat.seq_out = exist.seq_out; putEncryptedChat(newChat, false); } MessagesStorage.getInstance().updateEncryptedChat(newChat); @@ -3189,6 +3215,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter }); } else if (update instanceof TLRPC.TL_updateNotifySettings) { updatesOnMainThread.add(update); + } else if (update instanceof TLRPC.TL_updateServiceNotification) { + //TODO } } if (!messages.isEmpty()) { @@ -3257,9 +3285,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (currentUser != null) { currentUser.first_name = update.first_name; currentUser.last_name = update.last_name; + currentUser.username = update.username; } toDbUser.first_name = update.first_name; toDbUser.last_name = update.last_name; + toDbUser.username = update.username; dbUsers.add(toDbUser); } else if (update instanceof TLRPC.TL_updateUserPhoto) { if (currentUser != null) { @@ -3786,6 +3816,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } }); + } else if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionResend) { + } else { return null; } @@ -3832,12 +3864,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter long fingerprint = Utilities.bytesToLong(authKeyId); if (encryptedChat.key_fingerprint == fingerprint) { encryptedChat.auth_key = authKey; + encryptedChat.seq_in = 0; + encryptedChat.seq_out = 1; MessagesStorage.getInstance().updateEncryptedChat(encryptedChat); AndroidUtilities.RunOnUIThread(new Runnable() { @Override public void run() { putEncryptedChat(encryptedChat, false); NotificationCenter.getInstance().postNotificationName(NotificationCenter.encryptedChatUpdated, encryptedChat); + SendMessagesHelper.getInstance().sendNotifyLayerMessage(encryptedChat); } }); } else { @@ -3845,6 +3880,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter newChat.id = encryptedChat.id; newChat.user_id = encryptedChat.user_id; newChat.auth_key = encryptedChat.auth_key; + newChat.seq_in = encryptedChat.seq_in; + newChat.seq_out = encryptedChat.seq_out; MessagesStorage.getInstance().updateEncryptedChat(newChat); AndroidUtilities.RunOnUIThread(new Runnable() { @Override @@ -3952,12 +3989,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter final TLRPC.EncryptedChat newChat = (TLRPC.EncryptedChat) response; newChat.auth_key = encryptedChat.auth_key; newChat.user_id = encryptedChat.user_id; + newChat.seq_in = encryptedChat.seq_in; + newChat.seq_out = encryptedChat.seq_out; MessagesStorage.getInstance().updateEncryptedChat(newChat); AndroidUtilities.RunOnUIThread(new Runnable() { @Override public void run() { putEncryptedChat(newChat, false); NotificationCenter.getInstance().postNotificationName(NotificationCenter.encryptedChatUpdated, newChat); + SendMessagesHelper.getInstance().sendNotifyLayerMessage(newChat); } }); } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java index 09dffff17..9260ba4ac 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java @@ -109,6 +109,7 @@ public class MessagesStorage { database.executeFast("CREATE TABLE blocked_users(uid INTEGER PRIMARY KEY)").stepThis().dispose(); database.executeFast("CREATE TABLE download_queue(uid INTEGER, type INTEGER, date INTEGER, data BLOB, PRIMARY KEY (uid, type));").stepThis().dispose(); database.executeFast("CREATE TABLE dialog_settings(did INTEGER PRIMARY KEY, flags INTEGER);").stepThis().dispose(); + database.executeFast("CREATE TABLE messages_seq(mid INTEGER PRIMARY KEY, seq_in INTEGER, seq_out INTEGER);").stepThis().dispose(); //database.executeFast("CREATE TABLE attach_data(uid INTEGER, id INTEGER, data BLOB, PRIMARY KEY (uid, id))").stepThis().dispose(); database.executeFast("CREATE TABLE user_contacts_v6(uid INTEGER PRIMARY KEY, fname TEXT, sname TEXT)").stepThis().dispose(); @@ -290,6 +291,7 @@ public class MessagesStorage { version = 6; } if (version == 6 && version < 7) { + database.executeFast("CREATE TABLE IF NOT EXISTS messages_seq(mid INTEGER PRIMARY KEY, seq_in INTEGER, seq_out INTEGER);").stepThis().dispose(); database.executeFast("ALTER TABLE enc_chats ADD COLUMN layer INTEGER default 0").stepThis().dispose(); database.executeFast("ALTER TABLE enc_chats ADD COLUMN seq_in INTEGER default 0").stepThis().dispose(); database.executeFast("ALTER TABLE enc_chats ADD COLUMN seq_out INTEGER default 0").stepThis().dispose(); @@ -2956,6 +2958,7 @@ public class MessagesStorage { if (updateUser.first_name != null && updateUser.last_name != null) { user.first_name = updateUser.first_name; user.last_name = updateUser.last_name; + user.username = updateUser.username; } else if (updateUser.photo != null) { user.photo = updateUser.photo; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index 755deabc8..a0946ca60 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -833,7 +833,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } object = invoke; } - TLRPC.invokeWithLayer17 invoke = new TLRPC.invokeWithLayer17(); + TLRPC.invokeWithLayer18 invoke = new TLRPC.invokeWithLayer18(); invoke.query = object; FileLog.d("wrap in layer", "" + object); return invoke; @@ -1386,7 +1386,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (rawRequest != null && (rawRequest instanceof TLRPC.TL_messages_sendMessage || rawRequest instanceof TLRPC.TL_messages_sendMedia || rawRequest instanceof TLRPC.TL_messages_forwardMessages || - rawRequest instanceof TLRPC.TL_messages_sendEncrypted)) { + rawRequest instanceof TLRPC.TL_messages_sendEncrypted || + rawRequest instanceof TLRPC.TL_messages_sendEncryptedFile || + rawRequest instanceof TLRPC.TL_messages_sendEncryptedService)) { if (rawRequest instanceof TLRPC.TL_messages_sendMessage) { hasSendMessage = true; @@ -1404,7 +1406,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (currentRawRequest instanceof TLRPC.TL_messages_sendMessage || currentRawRequest instanceof TLRPC.TL_messages_sendMedia || currentRawRequest instanceof TLRPC.TL_messages_forwardMessages || - currentRawRequest instanceof TLRPC.TL_messages_sendEncrypted) { + currentRawRequest instanceof TLRPC.TL_messages_sendEncrypted || + currentRawRequest instanceof TLRPC.TL_messages_sendEncryptedFile || + currentRawRequest instanceof TLRPC.TL_messages_sendEncryptedService) { currentRequests.add(currentMessage.msg_id); } } @@ -1414,7 +1418,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (request.rawRequest instanceof TLRPC.TL_messages_sendMessage || request.rawRequest instanceof TLRPC.TL_messages_sendMedia || request.rawRequest instanceof TLRPC.TL_messages_forwardMessages || - request.rawRequest instanceof TLRPC.TL_messages_sendEncrypted) { + request.rawRequest instanceof TLRPC.TL_messages_sendEncrypted || + request.rawRequest instanceof TLRPC.TL_messages_sendEncryptedFile || + request.rawRequest instanceof TLRPC.TL_messages_sendEncryptedService) { if (!currentRequests.contains(request.runningMessageId)) { maxRequestId = Math.max(maxRequestId, request.runningMessageId); } @@ -1608,12 +1614,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. TLRPC.TL_protoMessage message = networkMessage.protoMessage; if (BuildVars.DEBUG_VERSION) { - if (message.body instanceof TLRPC.invokeWithLayer17) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)message.body).query); + if (message.body instanceof TLRPC.invokeWithLayer18) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer18)message.body).query); } else if (message.body instanceof TLRPC.initConnection) { TLRPC.initConnection r = (TLRPC.initConnection)message.body; - if (r.query instanceof TLRPC.invokeWithLayer17) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)r.query).query); + if (r.query instanceof TLRPC.invokeWithLayer18) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer18)r.query).query); } else { FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); } @@ -1648,12 +1654,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. TLRPC.TL_protoMessage message = networkMessage.protoMessage; containerMessages.add(message); if (BuildVars.DEBUG_VERSION) { - if (message.body instanceof TLRPC.invokeWithLayer17) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)message.body).query); + if (message.body instanceof TLRPC.invokeWithLayer18) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer18)message.body).query); } else if (message.body instanceof TLRPC.initConnection) { TLRPC.initConnection r = (TLRPC.initConnection)message.body; - if (r.query instanceof TLRPC.invokeWithLayer17) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)r.query).query); + if (r.query instanceof TLRPC.invokeWithLayer18) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer18)r.query).query); } else { FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); } @@ -2070,12 +2076,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. int errorCode = ((TLRPC.RpcError) resultContainer.result).error_code; if (errorCode == 500 || errorCode < 0) { - if ((request.flags & RPCRequest.RPCRequestClassFailOnServerErrors) != 0) { - if (request.serverFailureCount < 1) { - discardResponse = true; - request.runningMinStartTime = request.runningStartTime + 1; - } - } else { + if ((request.flags & RPCRequest.RPCRequestClassFailOnServerErrors) == 0) { discardResponse = true; int delay = Math.min(1, request.serverFailureCount * 2); request.runningMinStartTime = request.runningStartTime + delay; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index f67e955f9..be06766b1 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -176,7 +176,7 @@ public class FileLoader { } if (small) { currentUploadSmallOperationsCount--; - if (currentUploadSmallOperationsCount < 2) { + if (currentUploadSmallOperationsCount < 1) { FileUploadOperation operation = uploadSmallOperationQueue.poll(); if (operation != null) { currentUploadSmallOperationsCount++; @@ -185,7 +185,7 @@ public class FileLoader { } } else { currentUploadOperationsCount--; - if (currentUploadOperationsCount < 2) { + if (currentUploadOperationsCount < 1) { FileUploadOperation operation = uploadOperationQueue.poll(); if (operation != null) { currentUploadOperationsCount++; @@ -227,7 +227,7 @@ public class FileLoader { }); if (small) { currentUploadSmallOperationsCount--; - if (currentUploadSmallOperationsCount < 2) { + if (currentUploadSmallOperationsCount < 1) { FileUploadOperation operation = uploadSmallOperationQueue.poll(); if (operation != null) { currentUploadSmallOperationsCount++; @@ -236,7 +236,7 @@ public class FileLoader { } } else { currentUploadOperationsCount--; - if (currentUploadOperationsCount < 2) { + if (currentUploadOperationsCount < 1) { FileUploadOperation operation = uploadOperationQueue.poll(); if (operation != null) { currentUploadOperationsCount++; @@ -259,14 +259,14 @@ public class FileLoader { } }; if (small) { - if (currentUploadSmallOperationsCount < 2) { + if (currentUploadSmallOperationsCount < 1) { currentUploadSmallOperationsCount++; operation.start(); } else { uploadSmallOperationQueue.add(operation); } } else { - if (currentUploadOperationsCount < 2) { + if (currentUploadOperationsCount < 1) { currentUploadOperationsCount++; operation.start(); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java index 2e2f94524..6b0303725 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java @@ -198,6 +198,7 @@ public class TLClassStore { classStore.put(TLRPC.TL_updateReadMessages.constructor, TLRPC.TL_updateReadMessages.class); classStore.put(TLRPC.TL_updateChatParticipantDelete.constructor, TLRPC.TL_updateChatParticipantDelete.class); classStore.put(TLRPC.TL_updateRestoreMessages.constructor, TLRPC.TL_updateRestoreMessages.class); + classStore.put(TLRPC.TL_updateServiceNotification.constructor, TLRPC.TL_updateServiceNotification.class); classStore.put(TLRPC.TL_updateNotifySettings.constructor, TLRPC.TL_updateNotifySettings.class); classStore.put(TLRPC.TL_updateUserTyping.constructor, TLRPC.TL_updateUserTyping.class); classStore.put(TLRPC.TL_updateChatUserTyping.constructor, TLRPC.TL_updateChatUserTyping.class); @@ -226,6 +227,7 @@ public class TLClassStore { classStore.put(TLRPC.TL_inputEncryptedFileEmpty.constructor, TLRPC.TL_inputEncryptedFileEmpty.class); classStore.put(TLRPC.TL_inputEncryptedFileUploaded.constructor, TLRPC.TL_inputEncryptedFileUploaded.class); classStore.put(TLRPC.TL_decryptedMessageActionFlushHistory.constructor, TLRPC.TL_decryptedMessageActionFlushHistory.class); + classStore.put(TLRPC.TL_decryptedMessageActionResend.constructor, TLRPC.TL_decryptedMessageActionResend.class); classStore.put(TLRPC.TL_decryptedMessageActionNotifyLayer.constructor, TLRPC.TL_decryptedMessageActionNotifyLayer.class); classStore.put(TLRPC.TL_decryptedMessageActionSetMessageTTL.constructor, TLRPC.TL_decryptedMessageActionSetMessageTTL.class); classStore.put(TLRPC.TL_decryptedMessageActionDeleteMessages.constructor, TLRPC.TL_decryptedMessageActionDeleteMessages.class); @@ -363,6 +365,11 @@ public class TLClassStore { classStore.put(TLRPC.TL_decryptedMessageService_old.constructor, TLRPC.TL_decryptedMessageService_old.class); classStore.put(TLRPC.TL_decryptedMessage_old.constructor, TLRPC.TL_decryptedMessage_old.class); classStore.put(TLRPC.TL_message_secret.constructor, TLRPC.TL_message_secret.class); + classStore.put(TLRPC.TL_userSelf_old.constructor, TLRPC.TL_userSelf_old.class); + classStore.put(TLRPC.TL_userContact_old.constructor, TLRPC.TL_userContact_old.class); + classStore.put(TLRPC.TL_userRequest_old.constructor, TLRPC.TL_userRequest_old.class); + classStore.put(TLRPC.TL_userForeign_old.constructor, TLRPC.TL_userForeign_old.class); + classStore.put(TLRPC.TL_userDeleted_old.constructor, TLRPC.TL_userDeleted_old.class); } static TLClassStore store = null; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java index f985df2ce..b358aca16 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java @@ -2084,13 +2084,14 @@ public class TLRPC { } public static class TL_userContact extends User { - public static int constructor = 0xf2fb8319; + public static int constructor = 0xcab35e18; public void readParams(AbsSerializedData stream) { id = stream.readInt32(); first_name = stream.readString(); last_name = stream.readString(); + username = stream.readString(); access_hash = stream.readInt64(); phone = stream.readString(); photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); @@ -2102,6 +2103,7 @@ public class TLRPC { stream.writeInt32(id); stream.writeString(first_name); stream.writeString(last_name); + stream.writeString(username); stream.writeInt64(access_hash); stream.writeString(phone); photo.serializeToStream(stream); @@ -2110,13 +2112,14 @@ public class TLRPC { } public static class TL_userRequest extends User { - public static int constructor = 0x22e8ceb0; + public static int constructor = 0xd9ccc4ef; public void readParams(AbsSerializedData stream) { id = stream.readInt32(); first_name = stream.readString(); last_name = stream.readString(); + username = stream.readString(); access_hash = stream.readInt64(); phone = stream.readString(); photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); @@ -2128,6 +2131,7 @@ public class TLRPC { stream.writeInt32(id); stream.writeString(first_name); stream.writeString(last_name); + stream.writeString(username); stream.writeInt64(access_hash); stream.writeString(phone); photo.serializeToStream(stream); @@ -2136,13 +2140,14 @@ public class TLRPC { } public static class TL_userForeign extends User { - public static int constructor = 0x5214c89d; + public static int constructor = 0x75cf7a8; public void readParams(AbsSerializedData stream) { id = stream.readInt32(); first_name = stream.readString(); last_name = stream.readString(); + username = stream.readString(); access_hash = stream.readInt64(); photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); @@ -2153,6 +2158,7 @@ public class TLRPC { stream.writeInt32(id); stream.writeString(first_name); stream.writeString(last_name); + stream.writeString(username); stream.writeInt64(access_hash); photo.serializeToStream(stream); status.serializeToStream(stream); @@ -2160,13 +2166,14 @@ public class TLRPC { } public static class TL_userDeleted extends User { - public static int constructor = 0xb29ad7cc; + public static int constructor = 0xd6016d7a; public void readParams(AbsSerializedData stream) { id = stream.readInt32(); first_name = stream.readString(); last_name = stream.readString(); + username = stream.readString(); } public void serializeToStream(AbsSerializedData stream) { @@ -2174,17 +2181,19 @@ public class TLRPC { stream.writeInt32(id); stream.writeString(first_name); stream.writeString(last_name); + stream.writeString(username); } } public static class TL_userSelf extends User { - public static int constructor = 0x720535ec; + public static int constructor = 0x7007b451; public void readParams(AbsSerializedData stream) { id = stream.readInt32(); first_name = stream.readString(); last_name = stream.readString(); + username = stream.readString(); phone = stream.readString(); photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); @@ -2196,6 +2205,7 @@ public class TLRPC { stream.writeInt32(id); stream.writeString(first_name); stream.writeString(last_name); + stream.writeString(username); stream.writeString(phone); photo.serializeToStream(stream); status.serializeToStream(stream); @@ -3425,11 +3435,15 @@ public class TLRPC { public ArrayList messages = new ArrayList(); public int pts; public int version; + public String type; + public MessageMedia media; + public boolean popup; public NotifyPeer peer; public PeerNotifySettings notify_settings; public SendMessageAction action; public String first_name; public String last_name; + public String username; public int qts; public int id; public long random_id; @@ -3550,6 +3564,27 @@ public class TLRPC { } } + public static class TL_updateServiceNotification extends Update { + public static int constructor = 0x382dd3e4; + + public String message; + + public void readParams(AbsSerializedData stream) { + type = stream.readString(); + message = stream.readString(); + media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + popup = stream.readBool(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(type); + stream.writeString(message); + media.serializeToStream(stream); + stream.writeBool(popup); + } + } + public static class TL_updateNotifySettings extends Update { public static int constructor = 0xbec268ef; @@ -3601,13 +3636,14 @@ public class TLRPC { } public static class TL_updateUserName extends Update { - public static int constructor = 0xda22d9ad; + public static int constructor = 0xa7332b73; public void readParams(AbsSerializedData stream) { user_id = stream.readInt32(); first_name = stream.readString(); last_name = stream.readString(); + username = stream.readString(); } public void serializeToStream(AbsSerializedData stream) { @@ -3615,6 +3651,7 @@ public class TLRPC { stream.writeInt32(user_id); stream.writeString(first_name); stream.writeString(last_name); + stream.writeString(username); } } @@ -4037,6 +4074,8 @@ public class TLRPC { } public static class DecryptedMessageAction extends TLObject { + public int start_seq_no; + public int end_seq_no; public int layer; public int ttl_seconds; public ArrayList random_ids = new ArrayList(); @@ -4064,6 +4103,22 @@ public class TLRPC { } } + public static class TL_decryptedMessageActionResend extends DecryptedMessageAction { + public static int constructor = 0x511110b0; + + + public void readParams(AbsSerializedData stream) { + start_seq_no = stream.readInt32(); + end_seq_no = stream.readInt32(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(start_seq_no); + stream.writeInt32(end_seq_no); + } + } + public static class TL_decryptedMessageActionNotifyLayer extends DecryptedMessageAction { public static int constructor = 0xf3048883; @@ -4572,6 +4627,44 @@ public class TLRPC { } } + public static class TL_account_checkUsername extends TLObject { + public static int constructor = 0x2714d86c; + + public String username; + + public Class responseClass () { + return Bool.class; + } + + public void readParams(AbsSerializedData stream) { + username = stream.readString(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(username); + } + } + + public static class TL_account_updateUsername extends TLObject { + public static int constructor = 0x3e0bdd7c; + + public String username; + + public Class responseClass () { + return User.class; + } + + public void readParams(AbsSerializedData stream) { + username = stream.readString(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(username); + } + } + public static class InputAudio extends TLObject { public long id; public long access_hash; @@ -8363,6 +8456,126 @@ public class TLRPC { //manually created + public static class TL_userDeleted_old extends TL_userDeleted { + public static int constructor = 0xb29ad7cc; + + + public void readParams(AbsSerializedData stream) { + id = stream.readInt32(); + first_name = stream.readString(); + last_name = stream.readString(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + } + } + + public static class TL_userForeign_old extends TL_userForeign { + public static int constructor = 0x5214c89d; + + + public void readParams(AbsSerializedData stream) { + id = stream.readInt32(); + first_name = stream.readString(); + last_name = stream.readString(); + access_hash = stream.readInt64(); + photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt64(access_hash); + photo.serializeToStream(stream); + status.serializeToStream(stream); + } + } + + public static class TL_userRequest_old extends TL_userRequest { + public static int constructor = 0x22e8ceb0; + + + public void readParams(AbsSerializedData stream) { + id = stream.readInt32(); + first_name = stream.readString(); + last_name = stream.readString(); + access_hash = stream.readInt64(); + phone = stream.readString(); + photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt64(access_hash); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); + } + } + + public static class TL_userContact_old extends TL_userContact { + public static int constructor = 0xf2fb8319; + + + public void readParams(AbsSerializedData stream) { + id = stream.readInt32(); + first_name = stream.readString(); + last_name = stream.readString(); + access_hash = stream.readInt64(); + phone = stream.readString(); + photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt64(access_hash); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); + } + } + + public static class TL_userSelf_old extends TL_userSelf { + public static int constructor = 0x720535ec; + + + public void readParams(AbsSerializedData stream) { + id = stream.readInt32(); + first_name = stream.readString(); + last_name = stream.readString(); + phone = stream.readString(); + photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + inactive = stream.readBool(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); + stream.writeBool(inactive); + } + } + public static class TL_set_client_DH_params extends TLObject { public static int constructor = 0xf5045f1f; @@ -9129,6 +9342,7 @@ public class TLRPC { public int id; public String first_name; public String last_name; + public String username; public long access_hash; public String phone; public UserProfilePhoto photo; @@ -9629,8 +9843,8 @@ public class TLRPC { } } - public static class invokeWithLayer17 extends TLObject { - public static int constructor = 0x50858a19; + public static class invokeWithLayer18 extends TLObject { + public static int constructor = 0x1c900537; public TLObject query; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java index c6fc1baf0..ec2e602bd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java @@ -9,10 +9,17 @@ package org.telegram.ui.Adapters; import android.content.Context; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.LocaleController; +import org.telegram.messenger.ConnectionsManager; +import org.telegram.messenger.R; +import org.telegram.messenger.RPCRequest; +import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; import org.telegram.android.ContactsController; import org.telegram.messenger.FileLog; @@ -32,6 +39,9 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { private ArrayList searchResult; private ArrayList searchResultNames; private Timer searchTimer; + private ArrayList globalSearch; + private long reqId = 0; + private int lastReqId; public ContactsActivitySearchAdapter(Context context, HashMap arg1) { mContext = context; @@ -42,6 +52,8 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { if (query == null) { searchResult = null; searchResultNames = null; + globalSearch = null; + queryServerSearch(null); notifyDataSetChanged(); } else { try { @@ -63,14 +75,50 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { } processSearch(query); } - }, 100, 300); + }, 200, 300); } } + private void queryServerSearch(String query) { + if (query == null || query.length() < 5) { + if (reqId != 0) { + ConnectionsManager.getInstance().cancelRpc(reqId, true); + reqId = 0; + } + globalSearch = null; + lastReqId = 0; + notifyDataSetChanged(); + return; + } + TLRPC.TL_contacts_search req = new TLRPC.TL_contacts_search(); + req.q = query; + req.limit = 50; + final int currentReqId = ++lastReqId; + reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(final TLObject response, final TLRPC.TL_error error) { + AndroidUtilities.RunOnUIThread(new Runnable() { + @Override + public void run() { + if (currentReqId == lastReqId) { + if (error == null) { + TLRPC.TL_contacts_found res = (TLRPC.TL_contacts_found) response; + globalSearch = res.users; + notifyDataSetChanged(); + } + } + reqId = 0; + } + }); + } + }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); + } + private void processSearch(final String query) { AndroidUtilities.RunOnUIThread(new Runnable() { @Override public void run() { + queryServerSearch(query); final ArrayList contactsCopy = new ArrayList(); contactsCopy.addAll(ContactsController.getInstance().contacts); Utilities.searchQueue.postRunnable(new Runnable() { @@ -117,28 +165,43 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { @Override public boolean areAllItemsEnabled() { - return true; + return false; } @Override public boolean isEnabled(int i) { - return true; + return i != (searchResult == null ? 0 : searchResult.size()); } @Override public int getCount() { - if (searchResult == null) { - return 0; + int count = searchResult == null ? 0 : searchResult.size(); + int globalCount = globalSearch == null ? 0 : globalSearch.size(); + if (globalCount != 0) { + count += globalCount + 1; } - return searchResult.size(); + return count; + } + + public boolean isGlobalSearch(int i) { + int localCount = searchResult == null ? 0 : searchResult.size(); + int globalCount = globalSearch == null ? 0 : globalSearch.size(); + if (i >= 0 && i < localCount) { + return false; + } else if (i > localCount && i <= globalCount + localCount) { + return true; + } + return false; } @Override public TLRPC.User getItem(int i) { - if (searchResult != null) { - if (i >= 0 && i < searchResult.size()) { - return searchResult.get(i); - } + int localCount = searchResult == null ? 0 : searchResult.size(); + int globalCount = globalSearch == null ? 0 : globalSearch.size(); + if (i >= 0 && i < localCount) { + return searchResult.get(i); + } else if (i > localCount && i <= globalCount + localCount) { + return globalSearch.get(i - localCount - 1); } return null; } @@ -155,24 +218,30 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { @Override public View getView(int i, View view, ViewGroup viewGroup) { - if (view == null) { - view = new ChatOrUserCell(mContext); - ((ChatOrUserCell)view).usePadding = false; - } + if (i == (searchResult == null ? 0 : searchResult.size())) { + if (view == null) { + LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + view = li.inflate(R.layout.settings_section_layout, viewGroup, false); + TextView textView = (TextView)view.findViewById(R.id.settings_section_text); + textView.setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch)); + } + } else { + if (view == null) { + view = new ChatOrUserCell(mContext); + ((ChatOrUserCell) view).usePadding = false; + } - ((ChatOrUserCell) view).useSeparator = i != searchResult.size() - 1; + ((ChatOrUserCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1); + TLRPC.User user = getItem(i); + if (user != null) { + ((ChatOrUserCell) view).setData(user, null, null, i < searchResult.size() ? searchResultNames.get(i) : null, i > searchResult.size() ? "@" + user.username : null); - Object obj = searchResult.get(i); - TLRPC.User user = MessagesController.getInstance().getUser(((TLRPC.User)obj).id); - - if (user != null) { - ((ChatOrUserCell)view).setData(user, null, null, searchResultNames.get(i), null); - - if (ignoreUsers != null) { - if (ignoreUsers.containsKey(user.id)) { - ((ChatOrUserCell)view).drawAlpha = 0.5f; - } else { - ((ChatOrUserCell)view).drawAlpha = 1.0f; + if (ignoreUsers != null) { + if (ignoreUsers.containsKey(user.id)) { + ((ChatOrUserCell) view).drawAlpha = 0.5f; + } else { + ((ChatOrUserCell) view).drawAlpha = 1.0f; + } } } } @@ -181,16 +250,19 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { @Override public int getItemViewType(int i) { + if (i == (searchResult == null ? 0 : searchResult.size())) { + return 1; + } return 0; } @Override public int getViewTypeCount() { - return 1; + return 2; } @Override public boolean isEmpty() { - return searchResult == null || searchResult.size() == 0; + return (searchResult == null || searchResult.size() == 0) && (globalSearch == null || globalSearch.isEmpty()); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java index b6041c688..34e8e74a7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java @@ -36,6 +36,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega private static TextPaint timePaint; private ImageReceiver avatarImage; + private boolean needAvatarImage = false; private SeekBar seekBar; private ProgressView progressView; private int seekBarX; @@ -117,7 +118,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega buttonPressed = true; invalidate(); result = true; - } else if (avatarImage.isInsideImage(x, y)) { + } else if (needAvatarImage && avatarImage.isInsideImage(x, y)) { avatarPressed = true; result = true; } @@ -317,11 +318,19 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega timeX = AndroidUtilities.dp(80); } } - avatarImage.setImageCoords(x, AndroidUtilities.dp(9), AndroidUtilities.dp(50), AndroidUtilities.dp(50)); + int diff = 0; + if (needAvatarImage) { + avatarImage.setImageCoords(x, AndroidUtilities.dp(9), AndroidUtilities.dp(50), AndroidUtilities.dp(50)); + } else { + diff = AndroidUtilities.dp(56); + seekBarX -= diff; + buttonX -= diff; + timeX -= diff; + } - seekBar.width = backgroundWidth - AndroidUtilities.dp(112); + seekBar.width = backgroundWidth - AndroidUtilities.dp(112) + diff; seekBar.height = AndroidUtilities.dp(30); - progressView.width = backgroundWidth - AndroidUtilities.dp(136); + progressView.width = backgroundWidth - AndroidUtilities.dp(136) + diff; progressView.height = AndroidUtilities.dp(30); seekBarY = AndroidUtilities.dp(13); buttonY = AndroidUtilities.dp(10); @@ -348,14 +357,18 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega if (uid == 0) { uid = messageObject.messageOwner.from_id; } + needAvatarImage = !(messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.chat_id != 0 && !messageObject.isOut() && messageObject.messageOwner.media.audio.user_id == messageObject.messageOwner.from_id); audioUser = MessagesController.getInstance().getUser(uid); - if (audioUser != null) { - if (audioUser.photo != null) { - currentPhoto = audioUser.photo.photo_small; + + if (needAvatarImage) { + if (audioUser != null) { + if (audioUser.photo != null) { + currentPhoto = audioUser.photo.photo_small; + } + avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false); + } else { + avatarImage.setImage(null, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false); } - avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false); - } else { - avatarImage.setImage(null, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false); } if (messageObject.isOut()) { @@ -379,7 +392,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega return; } - avatarImage.draw(canvas, avatarImage.getImageX(), avatarImage.getImageY(), avatarImage.getImageHeight(), avatarImage.getImageHeight()); + if (needAvatarImage) { + avatarImage.draw(canvas, avatarImage.getImageX(), avatarImage.getImageY(), avatarImage.getImageHeight(), avatarImage.getImageHeight()); + } canvas.save(); if (buttonState == 0 || buttonState == 1) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java index 7b0f14d2d..1621d812e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java @@ -10,7 +10,6 @@ package org.telegram.ui.Cells; import android.content.Context; import android.graphics.Canvas; -import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.text.Layout; import android.text.StaticLayout; @@ -39,8 +38,8 @@ public class ChatContactCell extends ChatBaseCell { private static TextPaint namePaint; private static TextPaint phonePaint; - private static Drawable addContactDrawable; - private static Paint linePaint; + private static Drawable addContactDrawableIn; + private static Drawable addContactDrawableOut; private ImageReceiver avatarImage; @@ -67,10 +66,8 @@ public class ChatContactCell extends ChatBaseCell { phonePaint.setTextSize(AndroidUtilities.dp(15)); phonePaint.setColor(0xff000000); - addContactDrawable = getResources().getDrawable(R.drawable.ic_ab_add_member); - - linePaint = new Paint(); - linePaint.setStrokeWidth(AndroidUtilities.dp(1)); + addContactDrawableIn = getResources().getDrawable(R.drawable.addcontact_blue); + addContactDrawableOut = getResources().getDrawable(R.drawable.addcontact_green); } avatarImage = new ImageReceiver(this); } @@ -85,6 +82,12 @@ public class ChatContactCell extends ChatBaseCell { return false; } + int uid = currentMessageObject.messageOwner.media.user_id; + boolean newDrawAdd = contactUser != null && uid != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(uid) == null; + if (newDrawAdd != drawAddButton) { + return true; + } + contactUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id); TLRPC.FileLocation newPhoto = null; @@ -103,10 +106,10 @@ public class ChatContactCell extends ChatBaseCell { boolean result = false; int side = AndroidUtilities.dp(36); if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (x >= avatarImage.getImageX() && x <= avatarImage.getImageX() + namesWidth && y >= avatarImage.getImageY() && y <= avatarImage.getImageY() + avatarImage.getImageHeight()) { + if (x >= avatarImage.getImageX() && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(42) && y >= avatarImage.getImageY() && y <= avatarImage.getImageY() + avatarImage.getImageHeight()) { avatarPressed = true; result = true; - } else if (x >= avatarImage.getImageX() - AndroidUtilities.dp(44) && y >= AndroidUtilities.dp(20) && x <= avatarImage.getImageX() - AndroidUtilities.dp(10) && y <= AndroidUtilities.dp(52)) { + } else if (x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52)) { buttonPressed = true; result = true; } @@ -133,7 +136,7 @@ public class ChatContactCell extends ChatBaseCell { } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { avatarPressed = false; } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!avatarImage.isInsideImage(x, y)) { + if (!(x >= avatarImage.getImageX() && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(42) && y >= avatarImage.getImageY() && y <= avatarImage.getImageY() + avatarImage.getImageHeight())) { avatarPressed = false; } } @@ -147,7 +150,7 @@ public class ChatContactCell extends ChatBaseCell { } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { buttonPressed = false; } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!(x >= avatarImage.getImageX() - AndroidUtilities.dp(44) && y >= AndroidUtilities.dp(20) && x <= avatarImage.getImageX() - AndroidUtilities.dp(10) && y <= AndroidUtilities.dp(52))) { + if (!(x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52))) { buttonPressed = false; } } @@ -175,7 +178,7 @@ public class ChatContactCell extends ChatBaseCell { } else { maxWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); } - maxWidth -= AndroidUtilities.dp(58 + (drawAddButton ? 52 : 0)); + maxWidth -= AndroidUtilities.dp(58 + (drawAddButton ? 42 : 0)); if (contactUser != null) { if (contactUser.photo != null) { @@ -216,7 +219,7 @@ public class ChatContactCell extends ChatBaseCell { } namesWidth = Math.max(nameWidth, phoneWidth); - backgroundWidth = AndroidUtilities.dp(75 + (drawAddButton ? 52 : 0)) + namesWidth; + backgroundWidth = AndroidUtilities.dp(77 + (drawAddButton ? 42 : 0)) + namesWidth; super.setMessageObject(messageObject); } @@ -238,15 +241,15 @@ public class ChatContactCell extends ChatBaseCell { int x; if (currentMessageObject.isOut()) { - x = layoutWidth - backgroundWidth + AndroidUtilities.dp(6); + x = layoutWidth - backgroundWidth + AndroidUtilities.dp(8); } else { if (isChat) { - x = AndroidUtilities.dp(67); + x = AndroidUtilities.dp(69); } else { - x = AndroidUtilities.dp(14); + x = AndroidUtilities.dp(16); } } - avatarImage.setImageCoords(x + (drawAddButton ? AndroidUtilities.dp(52) : 0), AndroidUtilities.dp(7), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); + avatarImage.setImageCoords(x, AndroidUtilities.dp(9), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); } @Override @@ -261,27 +264,26 @@ public class ChatContactCell extends ChatBaseCell { if (nameLayout != null) { canvas.save(); - canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(8)); + canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(10)); namePaint.setColor(AndroidUtilities.getColorForId(currentMessageObject.messageOwner.media.user_id)); nameLayout.draw(canvas); canvas.restore(); } if (phoneLayout != null) { canvas.save(); - canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(29)); + canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(31)); phoneLayout.draw(canvas); canvas.restore(); } if (drawAddButton) { + Drawable addContactDrawable; if (currentMessageObject.isOut()) { - linePaint.setColor(0x9670b15c); + addContactDrawable = addContactDrawableOut; } else { - linePaint.setColor(0xffe8e8e8); + addContactDrawable = addContactDrawableIn; } - canvas.drawLine(avatarImage.getImageX() - AndroidUtilities.dp(4), avatarImage.getImageY(), avatarImage.getImageX() - AndroidUtilities.dp(4), AndroidUtilities.dp(62), linePaint); - - setDrawableBounds(addContactDrawable, avatarImage.getImageX() - AndroidUtilities.dp(44), AndroidUtilities.dp(20)); + setDrawableBounds(addContactDrawable, avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(78), AndroidUtilities.dp(13)); addContactDrawable.draw(canvas); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index d530fdc83..9bfd611b9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -30,6 +30,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.android.MessagesStorage; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; import org.telegram.messenger.ConnectionsManager; @@ -221,6 +222,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter if (user == null || user.id == UserConfig.getClientUserId()) { return; } + if (searchListViewAdapter.isGlobalSearch(i)) { + ArrayList users = new ArrayList(); + users.add(user); + MessagesController.getInstance().putUsers(users, false); + MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); + } if (returnAsResult) { if (ignoreUsers != null && ignoreUsers.containsKey(user.id)) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index ce0c21d93..daa9f6de9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -73,6 +73,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter private int profileRow; private int numberSectionRow; private int numberRow; + private int usernameRow; private int settingsSectionRow; private int textSizeRow; private int enableAnimationsRow; @@ -179,6 +180,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter profileRow = rowCount++; numberSectionRow = rowCount++; numberRow = rowCount++; + usernameRow = rowCount++; settingsSectionRow = rowCount++; enableAnimationsRow = rowCount++; languageRow = rowCount++; @@ -208,12 +210,15 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter logoutRow = rowCount++; versionRow = rowCount++; + MessagesController.getInstance().loadFullUser(UserConfig.getCurrentUser(), classGuid); + return true; } @Override public void onFragmentDestroy() { super.onFragmentDestroy(); + MessagesController.getInstance().cancelLoadFullUser(UserConfig.getClientUserId()); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces); avatarUpdater.clear(); } @@ -477,6 +482,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter }); builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null); showAlertDialog(builder); + } else if (i == usernameRow) { + presentFragment(new SettingsChangeUsernameActivity()); } } }); @@ -709,7 +716,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter public boolean isEnabled(int i) { return i == textSizeRow || i == enableAnimationsRow || i == blockedRow || i == notificationRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == wifiDownloadRow || - i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || + i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow; } @@ -829,7 +836,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } TextView textView = (TextView)view.findViewById(R.id.settings_section_text); if (i == numberSectionRow) { - textView.setText(LocaleController.getString("YourPhoneNumber", R.string.YourPhoneNumber)); + textView.setText(LocaleController.getString("Info", R.string.Info)); } else if (i == settingsSectionRow) { textView.setText(LocaleController.getString("SETTINGS", R.string.SETTINGS)); } else if (i == supportSectionRow) { @@ -848,15 +855,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } TextView textView = (TextView)view.findViewById(R.id.settings_row_text); View divider = view.findViewById(R.id.settings_row_divider); - if (i == numberRow) { - TLRPC.User user = UserConfig.getCurrentUser(); - if (user != null && user.phone != null && user.phone.length() != 0) { - textView.setText(PhoneFormat.getInstance().format("+" + user.phone)); - } else { - textView.setText(LocaleController.getString("Unknown", R.string.Unknown)); - } - divider.setVisibility(View.INVISIBLE); - } else if (i == notificationRow) { + if (i == notificationRow) { textView.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); divider.setVisibility(View.VISIBLE); } else if (i == blockedRow) { @@ -966,7 +965,16 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter TextView textView = (TextView)view.findViewById(R.id.settings_row_text); TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail); View divider = view.findViewById(R.id.settings_row_divider); - if (i == textSizeRow) { + if (i == numberRow) { + TLRPC.User user = UserConfig.getCurrentUser(); + textView.setText(LocaleController.getString("Phone", R.string.Phone)); + if (user != null && user.phone != null && user.phone.length() != 0) { + detailTextView.setText(PhoneFormat.getInstance().format("+" + user.phone)); + } else { + detailTextView.setText(LocaleController.getString("Unknown", R.string.Unknown)); + } + divider.setVisibility(View.VISIBLE); + } else if (i == textSizeRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int size = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16); detailTextView.setText(String.format("%d", size)); @@ -988,6 +996,15 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } else if (sort == 2) { detailTextView.setText(LocaleController.getString("LastName", R.string.SortLastName)); } + } else if (i == usernameRow) { + TLRPC.User user = UserConfig.getCurrentUser(); + textView.setText(LocaleController.getString("Username", R.string.Username)); + if (user != null && user.username != null && user.username.length() != 0) { + detailTextView.setText("@" + user.username); + } else { + detailTextView.setText("-"); + } + divider.setVisibility(View.INVISIBLE); } } else if (type == 6) { if (view == null) { @@ -1061,11 +1078,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter return 0; } else if (i == numberSectionRow || i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow) { return 1; - } else if (i == textSizeRow || i == languageRow || i == contactsSortRow) { + } else if (i == textSizeRow || i == languageRow || i == contactsSortRow || i == numberRow || i == usernameRow) { return 5; } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow) { return 3; - } else if (i == numberRow || i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow) { + } else if (i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow) { return 2; } else if (i == logoutRow) { return 4; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java index 2806c0500..86557b088 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeNameActivity.java @@ -125,12 +125,13 @@ public class SettingsChangeNameActivity extends BaseFragment { } private void saveName() { - TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile(); - if (UserConfig.getCurrentUser() == null || lastNameField.getText() == null || firstNameField.getText() == null) { + TLRPC.User currentUser = UserConfig.getCurrentUser(); + if (currentUser == null || lastNameField.getText() == null || firstNameField.getText() == null) { return; } - UserConfig.getCurrentUser().first_name = req.first_name = firstNameField.getText().toString(); - UserConfig.getCurrentUser().last_name = req.last_name = lastNameField.getText().toString(); + TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile(); + currentUser.first_name = req.first_name = firstNameField.getText().toString(); + currentUser.last_name = req.last_name = lastNameField.getText().toString(); TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); if (user != null) { user.first_name = req.first_name; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java new file mode 100644 index 000000000..ca1e855bf --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java @@ -0,0 +1,216 @@ +/* + * This is the source code of Telegram for Android v. 1.7.x. + * It is licensed under GNU GPL v. 2 or later. + * You should have received a copy of the license in this archive (see LICENSE). + * + * Copyright Nikolai Kudashov, 2013-2014. + */ + +package org.telegram.ui; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.EditorInfo; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; + +import org.telegram.android.AndroidUtilities; +import org.telegram.android.LocaleController; +import org.telegram.android.MessagesController; +import org.telegram.android.MessagesStorage; +import org.telegram.android.NotificationCenter; +import org.telegram.messenger.ConnectionsManager; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.R; +import org.telegram.messenger.RPCRequest; +import org.telegram.messenger.TLObject; +import org.telegram.messenger.TLRPC; +import org.telegram.messenger.UserConfig; +import org.telegram.ui.Views.ActionBar.BaseFragment; + +import java.util.ArrayList; + +public class SettingsChangeUsernameActivity extends BaseFragment { + private EditText firstNameField; + private View headerLabelView; + private View doneButton; + + @Override + public View createView(LayoutInflater inflater, ViewGroup container) { + if (fragmentView == null) { + actionBarLayer.setCustomView(R.layout.settings_do_action_layout); + Button cancelButton = (Button)actionBarLayer.findViewById(R.id.cancel_button); + cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finishFragment(); + } + }); + doneButton = actionBarLayer.findViewById(R.id.done_button); + doneButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (firstNameField.getText().length() != 0) { + saveName(); + } + } + }); + + cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase()); + TextView textView = (TextView)doneButton.findViewById(R.id.done_button_text); + textView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase()); + + fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false); + + TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); + if (user == null) { + user = UserConfig.getCurrentUser(); + } + + firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field); + firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { + if (i == EditorInfo.IME_ACTION_DONE) { + doneButton.performClick(); + return true; + } + return false; + } + }); + + if (user != null && user.username != null && user.username.length() > 0) { + firstNameField.setText(user.username); + firstNameField.setSelection(firstNameField.length()); + } + + TextView headerLabel = (TextView)fragmentView.findViewById(R.id.settings_section_text); + headerLabel.setText(LocaleController.getString("Username", R.string.Username).toUpperCase()); + } else { + ViewGroup parent = (ViewGroup)fragmentView.getParent(); + if (parent != null) { + parent.removeView(fragmentView); + } + } + return fragmentView; + } + + @Override + public void onResume() { + super.onResume(); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + boolean animations = preferences.getBoolean("view_animations", true); + if (!animations) { + firstNameField.requestFocus(); + AndroidUtilities.showKeyboard(firstNameField); + } + } + + private void showErrorAlert(String error) { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + if (error.equals("USERNAME_INVALID")) { + builder.setMessage(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid)); + } else if (error.equals("USERNAME_OCCUPIED")) { + builder.setMessage(LocaleController.getString("UsernameInUse", R.string.UsernameInUse)); + } else { + builder.setMessage(error); + } + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + showAlertDialog(builder); + } + + private void saveName() { + TLRPC.User user = UserConfig.getCurrentUser(); + if (getParentActivity() == null || user == null) { + return; + } + String currentName = user.username; + if (currentName == null) { + currentName = ""; + } + String newName = firstNameField.getText().toString(); + if (currentName.equals(newName)) { + finishFragment(); + return; + } + if (newName.length() > 32 || newName.length() > 0 && newName.length() < 5) { + showErrorAlert("USERNAME_INVALID"); + return; + } + + final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); + progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); + progressDialog.setCanceledOnTouchOutside(false); + progressDialog.setCancelable(false); + + TLRPC.TL_account_updateUsername req = new TLRPC.TL_account_updateUsername(); + req.username = newName; + + NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME); + final long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(TLObject response, final TLRPC.TL_error error) { + if (error == null) { + final TLRPC.User user = (TLRPC.User)response; + AndroidUtilities.RunOnUIThread(new Runnable() { + @Override + public void run() { + try { + progressDialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + ArrayList users = new ArrayList(); + users.add(user); + MessagesController.getInstance().putUsers(users, false); + MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); + UserConfig.saveConfig(true); + finishFragment(); + } + }); + } else { + AndroidUtilities.RunOnUIThread(new Runnable() { + @Override + public void run() { + try { + progressDialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + showErrorAlert(error.text); + } + }); + } + } + }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); + ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); + + progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + ConnectionsManager.getInstance().cancelRpc(reqId, true); + try { + dialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + progressDialog.show(); + } + + @Override + public void onOpenAnimationEnd() { + firstNameField.requestFocus(); + AndroidUtilities.showKeyboard(firstNameField); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java index 0d41355fd..84c53c1a8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java @@ -63,6 +63,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen private int avatarRow; private int phoneSectionRow; private int phoneRow; + private int usernameRow; private int settingsSectionRow; private int settingsTimerRow; private int settingsKeyRow; @@ -93,6 +94,9 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated); NotificationCenter.getInstance().addObserver(this, NotificationCenter.blockedUsersDidLoaded); userBlocked = MessagesController.getInstance().blockedUsers.contains(user_id); + + MessagesController.getInstance().loadFullUser(MessagesController.getInstance().getUser(user_id), classGuid); + return true; } @@ -105,6 +109,8 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatCreated); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.blockedUsersDidLoaded); + + MessagesController.getInstance().cancelLoadFullUser(user_id); } private void updateRowsIds() { @@ -112,6 +118,12 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen avatarRow = rowCount++; phoneSectionRow = rowCount++; phoneRow = rowCount++; + TLRPC.User user = MessagesController.getInstance().getUser(user_id); + if (user != null && user.username != null && user.username.length() > 0) { + usernameRow = rowCount++; + } else { + usernameRow = -1; + } settingsSectionRow = rowCount++; if (currentEncryptedChat instanceof TLRPC.TL_encryptedChat) { settingsTimerRow = rowCount++; @@ -281,6 +293,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen if (id == NotificationCenter.updateInterfaces) { int mask = (Integer)args[0]; if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) { + updateRowsIds(); if (listView != null) { listView.invalidateViews(); } @@ -531,7 +544,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen } TextView textView = (TextView)view.findViewById(R.id.settings_section_text); if (i == phoneSectionRow) { - textView.setText(LocaleController.getString("PHONE", R.string.PHONE)); + textView.setText(LocaleController.getString("Info", R.string.Info)); } else if (i == settingsSectionRow) { textView.setText(LocaleController.getString("SETTINGS", R.string.SETTINGS)); } else if (i == sharedMediaSectionRow) { @@ -610,7 +623,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen } else { textView.setText(LocaleController.getString("Unknown", R.string.Unknown)); } - divider.setVisibility(View.INVISIBLE); + divider.setVisibility(usernameRow != -1 ? View.VISIBLE : View.INVISIBLE); detailTextView.setText(LocaleController.getString("PhoneMobile", R.string.PhoneMobile)); } } else if (type == 3) { @@ -639,6 +652,15 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen } else { detailTextView.setText(AndroidUtilities.formatTTLString(encryptedChat.ttl)); } + } else if (i == usernameRow) { + TLRPC.User user = MessagesController.getInstance().getUser(user_id); + textView.setText(LocaleController.getString("Username", R.string.Username)); + if (user != null && user.username != null && user.username.length() != 0) { + detailTextView.setText("@" + user.username); + } else { + detailTextView.setText("-"); + } + divider.setVisibility(View.INVISIBLE); } } else if (type == 4) { if (view == null) { @@ -675,7 +697,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen return 1; } else if (i == phoneRow) { return 2; - } else if (i == sharedMediaRow || i == settingsTimerRow) { + } else if (i == sharedMediaRow || i == settingsTimerRow || i == usernameRow) { return 3; } else if (i == settingsKeyRow) { return 4; diff --git a/TMessagesProj/src/main/res/drawable-hdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/addcontact_blue.png new file mode 100755 index 000000000..a90b6ce9c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/addcontact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-hdpi/addcontact_green.png new file mode 100755 index 000000000..a553f495f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/addcontact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_add_member.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_add_member.png deleted file mode 100644 index cd5eaa0af..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_add_member.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/addcontact_blue.png new file mode 100755 index 000000000..fd1dd7433 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/addcontact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-ldpi/addcontact_green.png new file mode 100755 index 000000000..cfa9e2b03 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/addcontact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_add_member.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_add_member.png deleted file mode 100644 index a97cc796b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_add_member.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/addcontact_blue.png new file mode 100755 index 000000000..ec9b9c028 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/addcontact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-mdpi/addcontact_green.png new file mode 100755 index 000000000..45d6ac2b4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/addcontact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_add_member.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_add_member.png deleted file mode 100644 index b36768f14..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_add_member.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_blue.png new file mode 100755 index 000000000..3ba0c9c35 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_green.png new file mode 100755 index 000000000..5beefa1c3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_add_member.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_add_member.png deleted file mode 100644 index 36803948a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_add_member.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_blue.png new file mode 100755 index 000000000..a592549b2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_green.png new file mode 100755 index 000000000..fd4bada3d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_add_member.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_add_member.png deleted file mode 100644 index 3f064c690..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_add_member.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/layout/chat_profile_change_name_layout.xml b/TMessagesProj/src/main/res/layout/chat_profile_change_name_layout.xml index 81e5e34ea..27a533665 100644 --- a/TMessagesProj/src/main/res/layout/chat_profile_change_name_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_profile_change_name_layout.xml @@ -1,6 +1,6 @@ - @@ -35,4 +35,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/settings_change_name_layout.xml b/TMessagesProj/src/main/res/layout/settings_change_name_layout.xml index f85588786..6bdd8e59e 100644 --- a/TMessagesProj/src/main/res/layout/settings_change_name_layout.xml +++ b/TMessagesProj/src/main/res/layout/settings_change_name_layout.xml @@ -1,6 +1,6 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-ar/strings.xml b/TMessagesProj/src/main/res/values-ar/strings.xml index f0367e4e4..b6bdf5658 100644 --- a/TMessagesProj/src/main/res/values-ar/strings.xml +++ b/TMessagesProj/src/main/res/values-ar/strings.xml @@ -160,6 +160,7 @@ آخر ظهور آخر ظهور قم بدعوة صديق + GLOBAL SEARCH إرسال الرسالة إلى... أدخل اسم للمجموعة @@ -198,6 +199,11 @@ إيقاف هذه الصورة هي تصور لمفتاح التشفير لهذه المحادثة السرية مع ]]>%1$s]]>.
]]>إذا كانت مطابقة للصورة التي في جهاز ]]>%2$s]]>, فمحادثتكم آمنة ٢٠٠٪.
]]>للمزيد نرجو الذهاب إلى telegram.org
Unknown + INFO + الهاتف + Username + Username already in use + Username invalid تم تعيين كافة الإشعارات افتراضيا حجم نص الرسائل @@ -206,7 +212,6 @@ إلغاء الحظر إضغط بإستمرار على المستخدم لإلغاء الحظر لا توجد جهات اتصال محظورة - رقم هاتفك إشعارات الرسائل التنبيه معاينة الرسالة diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index 478d7458f..8db89f19f 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -160,6 +160,7 @@ zul. online zul. online Freunde einladen + GLOBAL SEARCH Sende Nachricht an… Gruppenname @@ -198,6 +199,11 @@ Aus Das ist eine Darstellung des Schlüssels für den Geheimen Chat mit ]]>%1$s]]>.
]]>Wenn dieses Bild auf ]]>%2$s\s]]>s Telefon genau so aussieht, ist euer Chat zu 200%% sicher.
]]>Erfahre mehr auf telegram.org
Unknown + INFO + Telefon + Username + Username already in use + Username invalid Alle Einstellungen für Mitteilungen zurücksetzen Textgröße für Nachrichten @@ -206,7 +212,6 @@ Freigeben Gedrückt halten um freizugeben. Keine blockierten Benutzer - DEINE TELEFONNUMMER NACHRICHTEN Benachrichtigung Vorschau diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index 920f5533a..98c9d5fd6 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -160,6 +160,7 @@ últ. vez últ. vez el Invitar a amigos + GLOBAL SEARCH Enviar mensaje a... Nombre del grupo @@ -198,6 +199,11 @@ Apagada Esta imagen es una visualización de la clave de cifrado para el chat secreto con ]]>%1$s]]>.
]]>Si esta imagen se ve igual en el teléfono de ]]>%2$s]]>, tu chat es seguro en un 200%%.
]]>Aprende más en telegram.org
Unknown + INFO + Teléfono + Username + Username already in use + Username invalid Restablecer las notificaciones Tamaño del texto @@ -206,7 +212,6 @@ Desbloquear Para desbloquear, mantén pulsado sobre un usuario. Sin usuarios bloqueados - TU NÚMERO DE TELÉFONO NOTIFICACIONES DE MENSAJES Alerta Vista previa del mensaje diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index 581b0807d..cdab3e61d 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -160,6 +160,7 @@ ultimo accesso ultimo accesso Invita amici + GLOBAL SEARCH Invia messaggio a... Immetti il nome del gruppo @@ -198,6 +199,11 @@ Spento Questa immagine è una visualizzazione della chiave di cifratura per questa chat segreta con ]]>%1$s]]>.
]]>Se questa immagine è uguale sul telefono di ]]>%2$s]]>, la chat è sicura al 200%%.
]]>Per saperne di più, visita Telegram.org
Unknown + INFO + Telefono + Username + Username already in use + Username invalid Ripristina tutte le impostazioni di notifica predefinite Dimensione testo messaggi @@ -206,7 +212,6 @@ Sblocca Tieni premuto sull’utente per sbloccarlo. Ancora nessun utente bloccato - IL TUO NUMERO DI TELEFONO NOTIFICHE MESSAGGI Avviso Anteprima messaggio diff --git a/TMessagesProj/src/main/res/values-ko/strings.xml b/TMessagesProj/src/main/res/values-ko/strings.xml index e44c83b9a..a61a43b31 100644 --- a/TMessagesProj/src/main/res/values-ko/strings.xml +++ b/TMessagesProj/src/main/res/values-ko/strings.xml @@ -160,6 +160,7 @@ 마지막 접속: 마지막 접속: 친구 초대 + GLOBAL SEARCH 메시지 보내기... 그룹 이름 입력 @@ -198,6 +199,11 @@ 해제 이 이미지는 ]]>%1$s]]>님과의 비밀대화에 사용 중인 암호화 키의 모습입니다.
]]>이 이미지가 ]]>%2$s]]>님의 암호화 키와 똑같다면 대화는 200%% 안전합니다.
]]>더 자세한 사항은 telegram.org 를 참고해 주세요.
Unknown + INFO + 전화번호 + Username + Username already in use + Username invalid 모든 알림 설정이 초기화되었습니다 채팅 글자 크기 @@ -206,7 +212,6 @@ 차단 해제 차단을 해제하려면 대화상대를 길게 누르세요. 차단한 친구가 없습니다 - 전화번호 메시지 알림 알림 사용 메시지 미리보기 diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index eb9299974..c05fab203 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -160,6 +160,7 @@ gezien gezien Vrienden uitnodigen + GLOBAL SEARCH Bericht verzenden naar… Groepsnaam... @@ -198,6 +199,11 @@ Uit Dit is een weergave van de encryptiesleutel voor deze geheime chat met ]]>%1$s]]>.
]]>Als deze afbeelding er bij ]]>%2$s]]> hetzelfde uitziet, is jullie gesprek 200%% beveiligd.
]]>Lees meer op telegram.org.
Unknown + INFO + Telefoon + Username + Username already in use + Username invalid Alle meldingsinstellingen herstellen Tekstgrootte berichten @@ -206,7 +212,6 @@ Deblokkeren Houd een gebruiker ingedrukt om hem/haar te deblokkeren. Geen geblokkeerde gebruikers - JE TELEFOONNUMMER BERICHTMELDINGEN Waarschuwing Voorvertoning diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 8a04e1e61..e4a8dadf2 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -160,6 +160,7 @@ visto visto Convidar Amigos + GLOBAL SEARCH Enviar mensagem para... Digite o nome do grupo @@ -198,6 +199,11 @@ Desativado Esta imagem é uma visualização da chave criptográfica para esta conversa secreta com ]]>%1$s]]>.
]]>Se esta imagem aparecer da mesma forma no telefone de ]]>%2$s\'s]]>, sua conversa é 200%% segura.
]]>Saiba mais em telegram.org
Unknown + INFO + Telefone + Username + Username already in use + Username invalid Restaurar todas as configurações de notificação Tamanho do texto nas mensagens @@ -206,7 +212,6 @@ Desbloquear Toque e segure no usuário para desbloquear Nenhum usuário bloqueado - SEU NÚMERO DE TELEFONE NOTIFICAÇÕES DE MENSAGENS Alerta Visualização de Mensagem diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index 844c59259..894430297 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -160,6 +160,7 @@ visto visto Convidar Amigos + GLOBAL SEARCH Enviar mensagem para... Digite o nome do grupo @@ -198,6 +199,11 @@ Desativado Esta imagem é uma visualização da chave criptográfica para esta conversa secreta com ]]>%1$s]]>.
]]>Se esta imagem aparecer da mesma forma no telefone de ]]>%2$s\'s]]>, sua conversa é 200%% segura.
]]>Saiba mais em telegram.org
Unknown + INFO + Telefone + Username + Username already in use + Username invalid Restaurar todas as configurações de notificação Tamanho do texto nas mensagens @@ -206,7 +212,6 @@ Desbloquear Toque e segure no usuário para desbloquear Nenhum usuário bloqueado - SEU NÚMERO DE TELEFONE NOTIFICAÇÕES DE MENSAGENS Alerta Visualização de Mensagem diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 67d833a25..af9433480 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -160,6 +160,7 @@ last seen last seen Invite Friends + GLOBAL SEARCH Send message to... Enter group name @@ -198,6 +199,11 @@ Off This image is a visualization of the encryption key for this secret chat with ]]>%1$s]]>.
]]>If this image looks the same on ]]>%2$s\'s]]> phone, your chat is 200%% secure.
]]>Learn more at telegram.org
Unknown + INFO + Phone + Username + Username already in use + Username invalid Reset all notification settings to default Messages Text Size @@ -206,7 +212,6 @@ Unblock Tap and hold on user to unblock. No blocked users yet - YOUR PHONE NUMBER MESSAGE NOTIFICATIONS Alert Message Preview