From 934408c73f7447260b05cf5a1e754309c1dca85e Mon Sep 17 00:00:00 2001 From: DrKLO Date: Fri, 14 Nov 2014 18:40:15 +0300 Subject: [PATCH] More Android L design --- TMessagesProj/build.gradle | 2 +- .../messenger/ConnectionsManager.java | 25 +- .../org/telegram/messenger/TLClassStore.java | 24 +- .../java/org/telegram/messenger/TLRPC.java | 402 +++- .../org/telegram/ui/ActionBar/ActionBar.java | 3 +- .../telegram/ui/ActionBar/ActionBarMenu.java | 6 +- .../ui/ActionBar/ActionBarMenuItem.java | 38 +- .../telegram/ui/Adapters/ContactsAdapter.java | 8 + .../ui/Adapters/ContactsSearchAdapter.java | 8 + .../telegram/ui/Adapters/DialogsAdapter.java | 2 +- .../org/telegram/ui/Cells/DialogCell.java | 1 + .../java/org/telegram/ui/Cells/UserCell.java | 21 +- .../telegram/ui/ChangeChatNameActivity.java | 2 +- .../org/telegram/ui/ChangeNameActivity.java | 2 +- .../telegram/ui/ChangeUsernameActivity.java | 2 +- .../java/org/telegram/ui/ChatActivity.java | 173 +- .../org/telegram/ui/ContactAddActivity.java | 3 +- .../org/telegram/ui/GroupCreateActivity.java | 65 +- .../telegram/ui/GroupCreateFinalActivity.java | 129 +- .../java/org/telegram/ui/LaunchActivity.java | 3 +- .../java/org/telegram/ui/LoginActivity.java | 1654 +++++++++++++---- .../telegram/ui/LoginActivityPhoneView.java | 437 ----- .../ui/LoginActivityRegisterView.java | 221 --- .../org/telegram/ui/LoginActivitySmsView.java | 426 ----- .../org/telegram/ui/MessagesActivity.java | 23 +- .../org/telegram/ui/PhotoCropActivity.java | 2 +- .../telegram/ui/PrivacySettingsActivity.java | 14 + .../org/telegram/ui/VideoEditorActivity.java | 5 +- .../org/telegram/ui/Views/AvatarDrawable.java | 14 + .../ui/Views/ChatActivityEnterView.java | 140 +- .../java/org/telegram/ui/Views/CheckBox.java | 58 + .../java/org/telegram/ui/Views/SlideView.java | 71 - .../org/telegram/ui/WallpapersActivity.java | 2 +- .../src/main/res/drawable-hdpi/photo_w.png | Bin 0 -> 1376 bytes .../main/res/drawable-hdpi/round_check2.png | Bin 0 -> 1048 bytes .../src/main/res/drawable-hdpi/shadow.png | Bin 131 -> 0 bytes .../src/main/res/drawable-hdpi/spinner.9.png | Bin 339 -> 0 bytes .../res/drawable-hdpi/spinner_pressed.9.png | Bin 328 -> 0 bytes .../src/main/res/drawable-mdpi/photo_w.png | Bin 0 -> 1177 bytes .../main/res/drawable-mdpi/round_check2.png | Bin 0 -> 1136 bytes .../src/main/res/drawable-mdpi/shadow.png | Bin 131 -> 0 bytes .../src/main/res/drawable-mdpi/spinner.9.png | Bin 269 -> 0 bytes .../res/drawable-mdpi/spinner_pressed.9.png | Bin 276 -> 0 bytes .../src/main/res/drawable-xhdpi/photo_w.png | Bin 0 -> 1493 bytes .../main/res/drawable-xhdpi/round_check2.png | Bin 0 -> 1123 bytes .../src/main/res/drawable-xhdpi/shadow.png | Bin 134 -> 0 bytes .../src/main/res/drawable-xhdpi/spinner.9.png | Bin 389 -> 0 bytes .../res/drawable-xhdpi/spinner_pressed.9.png | Bin 370 -> 0 bytes .../src/main/res/drawable-xxhdpi/photo_w.png | Bin 0 -> 1921 bytes .../main/res/drawable-xxhdpi/round_check2.png | Bin 0 -> 1194 bytes .../src/main/res/drawable-xxhdpi/shadow.png | Bin 144 -> 0 bytes .../main/res/drawable-xxhdpi/spinner.9.png | Bin 1112 -> 0 bytes .../res/drawable-xxhdpi/spinner_pressed.9.png | Bin 473 -> 0 bytes .../src/main/res/drawable/edit_text.xml | 1 - .../src/main/res/drawable/spinner_states.xml | 48 +- .../main/res/layout-ar/country_row_layout.xml | 36 - .../layout-ar/group_create_final_layout.xml | 69 - .../src/main/res/layout/chat_layout.xml | 238 +-- .../main/res/layout/country_row_layout.xml | 36 - .../res/layout/group_create_done_layout.xml | 24 - .../src/main/res/layout/login_layout.xml | 276 --- .../src/main/res/layout/media_layout.xml | 12 +- .../main/res/layout/media_loading_layout.xml | 5 +- .../res/layout/popup_notification_layout.xml | 6 +- .../res/layout/settings_wallpapers_layout.xml | 1 - .../src/main/res/values-v21/styles.xml | 3 +- TMessagesProj/src/main/res/values/strings.xml | 40 +- 67 files changed, 2532 insertions(+), 2249 deletions(-) delete mode 100644 TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java delete mode 100644 TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java delete mode 100644 TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java create mode 100644 TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java create mode 100644 TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java delete mode 100644 TMessagesProj/src/main/java/org/telegram/ui/Views/SlideView.java create mode 100755 TMessagesProj/src/main/res/drawable-hdpi/photo_w.png create mode 100755 TMessagesProj/src/main/res/drawable-hdpi/round_check2.png delete mode 100755 TMessagesProj/src/main/res/drawable-hdpi/shadow.png delete mode 100755 TMessagesProj/src/main/res/drawable-hdpi/spinner.9.png delete mode 100755 TMessagesProj/src/main/res/drawable-hdpi/spinner_pressed.9.png create mode 100755 TMessagesProj/src/main/res/drawable-mdpi/photo_w.png create mode 100755 TMessagesProj/src/main/res/drawable-mdpi/round_check2.png delete mode 100755 TMessagesProj/src/main/res/drawable-mdpi/shadow.png delete mode 100755 TMessagesProj/src/main/res/drawable-mdpi/spinner.9.png delete mode 100755 TMessagesProj/src/main/res/drawable-mdpi/spinner_pressed.9.png create mode 100755 TMessagesProj/src/main/res/drawable-xhdpi/photo_w.png create mode 100755 TMessagesProj/src/main/res/drawable-xhdpi/round_check2.png delete mode 100755 TMessagesProj/src/main/res/drawable-xhdpi/shadow.png delete mode 100755 TMessagesProj/src/main/res/drawable-xhdpi/spinner.9.png delete mode 100755 TMessagesProj/src/main/res/drawable-xhdpi/spinner_pressed.9.png create mode 100755 TMessagesProj/src/main/res/drawable-xxhdpi/photo_w.png create mode 100755 TMessagesProj/src/main/res/drawable-xxhdpi/round_check2.png delete mode 100755 TMessagesProj/src/main/res/drawable-xxhdpi/shadow.png delete mode 100755 TMessagesProj/src/main/res/drawable-xxhdpi/spinner.9.png delete mode 100755 TMessagesProj/src/main/res/drawable-xxhdpi/spinner_pressed.9.png delete mode 100644 TMessagesProj/src/main/res/layout-ar/country_row_layout.xml delete mode 100644 TMessagesProj/src/main/res/layout-ar/group_create_final_layout.xml delete mode 100644 TMessagesProj/src/main/res/layout/country_row_layout.xml delete mode 100644 TMessagesProj/src/main/res/layout/group_create_done_layout.xml delete mode 100644 TMessagesProj/src/main/res/layout/login_layout.xml diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index c70fe9ca0..8eccd89dd 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -80,7 +80,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 21 - versionCode 380 + versionCode 382 versionName "2.0.0" } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index 995e6f2f6..06570717a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -824,12 +824,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (invoke.system_version == null || invoke.system_version.length() == 0) { invoke.system_version = "SDK Unknown"; } - object = invoke; + TLRPC.invokeWithLayer invoke2 = new TLRPC.invokeWithLayer(); + invoke2.query = invoke; + FileLog.d("wrap in layer", "" + object); + object = invoke2; } - TLRPC.invokeWithLayer18 invoke = new TLRPC.invokeWithLayer18(); - invoke.query = object; - FileLog.d("wrap in layer", "" + object); - return invoke; } return object; } @@ -1607,12 +1606,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. TLRPC.TL_protoMessage message = networkMessage.protoMessage; if (BuildVars.DEBUG_VERSION) { - 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); + if (message.body instanceof TLRPC.invokeWithLayer) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)message.body).query); } else if (message.body instanceof TLRPC.initConnection) { TLRPC.initConnection r = (TLRPC.initConnection)message.body; - 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); + if (r.query instanceof TLRPC.invokeWithLayer) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)r.query).query); } else { FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); } @@ -1647,12 +1646,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.invokeWithLayer18) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer18)message.body).query); + if (message.body instanceof TLRPC.invokeWithLayer) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)message.body).query); } else if (message.body instanceof TLRPC.initConnection) { TLRPC.initConnection r = (TLRPC.initConnection)message.body; - 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); + if (r.query instanceof TLRPC.invokeWithLayer) { + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)r.query).query); } else { FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java index c81e30045..9a5bfdc68 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java @@ -51,6 +51,8 @@ public class TLClassStore { classStore.put(TLRPC.TL_updates_difference.constructor, TLRPC.TL_updates_difference.class); classStore.put(TLRPC.TL_geoPointEmpty.constructor, TLRPC.TL_geoPointEmpty.class); classStore.put(TLRPC.TL_geoPoint.constructor, TLRPC.TL_geoPoint.class); + classStore.put(TLRPC.TL_privacyKeyStatusTimestamp.constructor, TLRPC.TL_privacyKeyStatusTimestamp.class); + classStore.put(TLRPC.TL_account_privacyRules.constructor, TLRPC.TL_account_privacyRules.class); classStore.put(TLRPC.TL_help_appUpdate.constructor, TLRPC.TL_help_appUpdate.class); classStore.put(TLRPC.TL_help_noAppUpdate.constructor, TLRPC.TL_help_noAppUpdate.class); classStore.put(TLRPC.TL_messageForwarded.constructor, TLRPC.TL_messageForwarded.class); @@ -93,8 +95,15 @@ public class TLClassStore { classStore.put(TLRPC.TL_audioEmpty.constructor, TLRPC.TL_audioEmpty.class); classStore.put(TLRPC.TL_audio.constructor, TLRPC.TL_audio.class); classStore.put(TLRPC.TL_destroy_sessions_res.constructor, TLRPC.TL_destroy_sessions_res.class); + classStore.put(TLRPC.TL_privacyValueAllowUsers.constructor, TLRPC.TL_privacyValueAllowUsers.class); + classStore.put(TLRPC.TL_privacyValueDisallowAll.constructor, TLRPC.TL_privacyValueDisallowAll.class); + classStore.put(TLRPC.TL_privacyValueAllowContacts.constructor, TLRPC.TL_privacyValueAllowContacts.class); + classStore.put(TLRPC.TL_privacyValueDisallowContacts.constructor, TLRPC.TL_privacyValueDisallowContacts.class); + classStore.put(TLRPC.TL_privacyValueAllowAll.constructor, TLRPC.TL_privacyValueAllowAll.class); + classStore.put(TLRPC.TL_privacyValueDisallowUsers.constructor, TLRPC.TL_privacyValueDisallowUsers.class); classStore.put(TLRPC.TL_contacts_contacts.constructor, TLRPC.TL_contacts_contacts.class); classStore.put(TLRPC.TL_contacts_contactsNotModified.constructor, TLRPC.TL_contacts_contactsNotModified.class); + classStore.put(TLRPC.TL_inputPrivacyKeyStatusTimestamp.constructor, TLRPC.TL_inputPrivacyKeyStatusTimestamp.class); classStore.put(TLRPC.TL_photos_photos.constructor, TLRPC.TL_photos_photos.class); classStore.put(TLRPC.TL_photos_photosSlice.constructor, TLRPC.TL_photos_photosSlice.class); classStore.put(TLRPC.TL_chatFull.constructor, TLRPC.TL_chatFull.class); @@ -165,6 +174,12 @@ public class TLClassStore { classStore.put(TLRPC.TL_messages_affectedHistory.constructor, TLRPC.TL_messages_affectedHistory.class); classStore.put(TLRPC.TL_documentEmpty.constructor, TLRPC.TL_documentEmpty.class); classStore.put(TLRPC.TL_document.constructor, TLRPC.TL_document.class); + classStore.put(TLRPC.TL_inputPrivacyValueDisallowUsers.constructor, TLRPC.TL_inputPrivacyValueDisallowUsers.class); + classStore.put(TLRPC.TL_inputPrivacyValueDisallowAll.constructor, TLRPC.TL_inputPrivacyValueDisallowAll.class); + classStore.put(TLRPC.TL_inputPrivacyValueDisallowContacts.constructor, TLRPC.TL_inputPrivacyValueDisallowContacts.class); + classStore.put(TLRPC.TL_inputPrivacyValueAllowAll.constructor, TLRPC.TL_inputPrivacyValueAllowAll.class); + classStore.put(TLRPC.TL_inputPrivacyValueAllowContacts.constructor, TLRPC.TL_inputPrivacyValueAllowContacts.class); + classStore.put(TLRPC.TL_inputPrivacyValueAllowUsers.constructor, TLRPC.TL_inputPrivacyValueAllowUsers.class); classStore.put(TLRPC.TL_inputMediaContact.constructor, TLRPC.TL_inputMediaContact.class); classStore.put(TLRPC.TL_inputMediaUploadedThumbDocument.constructor, TLRPC.TL_inputMediaUploadedThumbDocument.class); classStore.put(TLRPC.TL_inputMediaAudio.constructor, TLRPC.TL_inputMediaAudio.class); @@ -187,9 +202,12 @@ public class TLClassStore { classStore.put(TLRPC.TL_contactSuggested.constructor, TLRPC.TL_contactSuggested.class); classStore.put(TLRPC.TL_server_DH_params_fail.constructor, TLRPC.TL_server_DH_params_fail.class); classStore.put(TLRPC.TL_server_DH_params_ok.constructor, TLRPC.TL_server_DH_params_ok.class); - classStore.put(TLRPC.TL_userStatusEmpty.constructor, TLRPC.TL_userStatusEmpty.class); - classStore.put(TLRPC.TL_userStatusOnline.constructor, TLRPC.TL_userStatusOnline.class); classStore.put(TLRPC.TL_userStatusOffline.constructor, TLRPC.TL_userStatusOffline.class); + classStore.put(TLRPC.TL_userStatusLastWeek.constructor, TLRPC.TL_userStatusLastWeek.class); + classStore.put(TLRPC.TL_userStatusEmpty.constructor, TLRPC.TL_userStatusEmpty.class); + classStore.put(TLRPC.TL_userStatusLastMonth.constructor, TLRPC.TL_userStatusLastMonth.class); + classStore.put(TLRPC.TL_userStatusOnline.constructor, TLRPC.TL_userStatusOnline.class); + classStore.put(TLRPC.TL_userStatusRecently.constructor, TLRPC.TL_userStatusRecently.class); classStore.put(TLRPC.TL_msg_copy.constructor, TLRPC.TL_msg_copy.class); classStore.put(TLRPC.TL_contacts_importedContacts.constructor, TLRPC.TL_contacts_importedContacts.class); classStore.put(TLRPC.TL_futureSalt.constructor, TLRPC.TL_futureSalt.class); @@ -210,6 +228,7 @@ public class TLClassStore { classStore.put(TLRPC.TL_updateEncryptedChatTyping.constructor, TLRPC.TL_updateEncryptedChatTyping.class); classStore.put(TLRPC.TL_updateDcOptions.constructor, TLRPC.TL_updateDcOptions.class); classStore.put(TLRPC.TL_updateChatParticipants.constructor, TLRPC.TL_updateChatParticipants.class); + classStore.put(TLRPC.TL_updatePrivacy.constructor, TLRPC.TL_updatePrivacy.class); classStore.put(TLRPC.TL_updateEncryption.constructor, TLRPC.TL_updateEncryption.class); classStore.put(TLRPC.TL_updateUserBlocked.constructor, TLRPC.TL_updateUserBlocked.class); classStore.put(TLRPC.TL_updateActivation.constructor, TLRPC.TL_updateActivation.class); @@ -328,6 +347,7 @@ public class TLClassStore { classStore.put(TLRPC.TL_inputPhotoEmpty.constructor, TLRPC.TL_inputPhotoEmpty.class); classStore.put(TLRPC.TL_inputPhoto.constructor, TLRPC.TL_inputPhoto.class); classStore.put(TLRPC.TL_importedContact.constructor, TLRPC.TL_importedContact.class); + classStore.put(TLRPC.TL_accountDaysTTL.constructor, TLRPC.TL_accountDaysTTL.class); classStore.put(TLRPC.TL_inputPeerContact.constructor, TLRPC.TL_inputPeerContact.class); classStore.put(TLRPC.TL_inputPeerChat.constructor, TLRPC.TL_inputPeerChat.class); classStore.put(TLRPC.TL_inputPeerEmpty.constructor, TLRPC.TL_inputPeerEmpty.class); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java index e5f5c11a3..2a9a055d1 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java @@ -769,6 +769,51 @@ public class TLRPC { } } + public static class TL_privacyKeyStatusTimestamp extends TLObject { + public static int constructor = 0xbc2eab30; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_account_privacyRules extends TLObject { + public static int constructor = 0x554abb6f; + + public ArrayList rules = new ArrayList(); + public ArrayList users = new ArrayList(); + + public void readParams(AbsSerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + rules.add((PrivacyRule)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + stream.readInt32(); + count = stream.readInt32(); + for (int a = 0; a < count; a++) { + users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = rules.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + rules.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = users.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + users.get(a).serializeToStream(stream); + } + } + } + public static class help_AppUpdate extends TLObject { public int id; public boolean critical; @@ -1434,6 +1479,92 @@ public class TLRPC { } } + public static class PrivacyRule extends TLObject { + public ArrayList users = new ArrayList(); + } + + public static class TL_privacyValueAllowUsers extends PrivacyRule { + public static int constructor = 0x4d5bbe0c; + + + public void readParams(AbsSerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + users.add(stream.readInt32()); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = users.size(); + stream.writeInt32(count); + for (Integer user : users) { + stream.writeInt32(user); + } + } + } + + public static class TL_privacyValueDisallowAll extends PrivacyRule { + public static int constructor = 0x8b73e763; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueAllowContacts extends PrivacyRule { + public static int constructor = 0xfffe1bac; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueDisallowContacts extends PrivacyRule { + public static int constructor = 0xf888fa1a; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueAllowAll extends PrivacyRule { + public static int constructor = 0x65427b82; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueDisallowUsers extends PrivacyRule { + public static int constructor = 0xc7f49b7; + + + public void readParams(AbsSerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + users.add(stream.readInt32()); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = users.size(); + stream.writeInt32(count); + for (Integer user : users) { + stream.writeInt32(user); + } + } + } + public static class contacts_Contacts extends TLObject { public ArrayList contacts = new ArrayList(); public ArrayList users = new ArrayList(); @@ -1482,6 +1613,15 @@ public class TLRPC { } } + public static class TL_inputPrivacyKeyStatusTimestamp extends TLObject { + public static int constructor = 0x4f96cb18; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class photos_Photos extends TLObject { public ArrayList photos = new ArrayList(); public ArrayList users = new ArrayList(); @@ -2841,6 +2981,92 @@ public class TLRPC { } } + public static class InputPrivacyRule extends TLObject { + public ArrayList users = new ArrayList(); + } + + public static class TL_inputPrivacyValueDisallowUsers extends InputPrivacyRule { + public static int constructor = 0x90110467; + + + public void readParams(AbsSerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + users.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = users.size(); + stream.writeInt32(count); + for (InputUser user : users) { + user.serializeToStream(stream); + } + } + } + + public static class TL_inputPrivacyValueDisallowAll extends InputPrivacyRule { + public static int constructor = 0xd66b66c9; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPrivacyValueDisallowContacts extends InputPrivacyRule { + public static int constructor = 0xba52007; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPrivacyValueAllowAll extends InputPrivacyRule { + public static int constructor = 0x184b35ce; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPrivacyValueAllowContacts extends InputPrivacyRule { + public static int constructor = 0xd09e07b; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPrivacyValueAllowUsers extends InputPrivacyRule { + public static int constructor = 0x131cc67f; + + + public void readParams(AbsSerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + users.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = users.size(); + stream.writeInt32(count); + for (InputUser user : users) { + user.serializeToStream(stream); + } + } + } + public static class InputMedia extends TLObject { public String phone_number; public String first_name; @@ -3449,6 +3675,8 @@ public class TLRPC { public long random_id; public ArrayList dc_options = new ArrayList(); public ChatParticipants participants; + public TL_privacyKeyStatusTimestamp key; + public ArrayList rules = new ArrayList(); public EncryptedChat chat; public boolean blocked; public long auth_key_id; @@ -3781,6 +4009,31 @@ public class TLRPC { } } + public static class TL_updatePrivacy extends Update { + public static int constructor = 0xee3b272a; + + + public void readParams(AbsSerializedData stream) { + key = (TL_privacyKeyStatusTimestamp)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + rules.add((PrivacyRule)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + key.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = rules.size(); + stream.writeInt32(count); + for (PrivacyRule rule : rules) { + rule.serializeToStream(stream); + } + } + } + public static class TL_updateEncryption extends Update { public static int constructor = 0xb4a2e88d; @@ -4627,6 +4880,107 @@ public class TLRPC { } } + public static class TL_account_getPrivacy extends TLObject { + public static int constructor = 0xdadbc950; + + public TL_inputPrivacyKeyStatusTimestamp key; + + public Class responseClass () { + return TL_account_privacyRules.class; + } + + public void readParams(AbsSerializedData stream) { + key = (TL_inputPrivacyKeyStatusTimestamp)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + key.serializeToStream(stream); + } + } + + public static class TL_account_setPrivacy extends TLObject { + public static int constructor = 0xc9f81ce8; + + public TL_inputPrivacyKeyStatusTimestamp key; + public ArrayList rules = new ArrayList(); + + public Class responseClass () { + return TL_account_privacyRules.class; + } + + public void readParams(AbsSerializedData stream) { + key = (TL_inputPrivacyKeyStatusTimestamp)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + rules.add((InputPrivacyRule)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + key.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = rules.size(); + stream.writeInt32(count); + for (InputPrivacyRule rule : rules) { + rule.serializeToStream(stream); + } + } + } + + public static class TL_account_deleteAccount extends TLObject { + public static int constructor = 0x418d4e0b; + + public String reason; + + public Class responseClass () { + return Bool.class; + } + + public void readParams(AbsSerializedData stream) { + reason = stream.readString(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(reason); + } + } + + public static class TL_account_getAccountTTL extends TLObject { + public static int constructor = 0x8fc711d; + + + public Class responseClass () { + return TL_accountDaysTTL.class; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_account_setAccountTTL extends TLObject { + public static int constructor = 0x2442485e; + + public TL_accountDaysTTL ttl; + + public Class responseClass () { + return Bool.class; + } + + public void readParams(AbsSerializedData stream) { + ttl = (TL_accountDaysTTL)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + ttl.serializeToStream(stream); + } + } + public static class TL_account_checkUsername extends TLObject { public static int constructor = 0x2714d86c; @@ -6267,6 +6621,21 @@ public class TLRPC { } } + public static class TL_accountDaysTTL extends TLObject { + public static int constructor = 0xb8d0afdf; + + public int days; + + public void readParams(AbsSerializedData stream) { + days = stream.readInt32(); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(days); + } + } + public static class InputPeer extends TLObject { public int user_id; public int chat_id; @@ -8744,6 +9113,15 @@ public class TLRPC { public int expires; } + public static class TL_userStatusLastWeek extends UserStatus { + public static int constructor = 0x7bf09fc; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_userStatusEmpty extends UserStatus { public static int constructor = 0x9d05049; @@ -8753,6 +9131,15 @@ public class TLRPC { } } + public static class TL_userStatusLastMonth extends UserStatus { + public static int constructor = 0x77ebc742; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_userStatusOnline extends UserStatus { public static int constructor = 0xedb93949; @@ -8767,6 +9154,15 @@ public class TLRPC { } } + public static class TL_userStatusRecently extends UserStatus { + public static int constructor = 0xe26f42f1; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_userStatusOffline extends UserStatus { public static int constructor = 0x8c703f; @@ -9879,13 +10275,15 @@ public class TLRPC { } } - public static class invokeWithLayer18 extends TLObject { - public static int constructor = 0x1c900537; + public static class invokeWithLayer extends TLObject { + public static int constructor = 0xda9b0d0d; + public int layer = 19; public TLObject query; public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); + stream.writeInt32(layer); query.serializeToStream(stream); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index 8e510f045..2c0c69e97 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -190,6 +190,7 @@ public class ActionBar extends FrameLayout { titleFrameLayout.addView(backButtonImageView); backButtonImageView.setVisibility(VISIBLE); backButtonImageView.setScaleType(ImageView.ScaleType.CENTER); + backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); backButtonImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -505,7 +506,7 @@ public class ActionBar extends FrameLayout { public void setItemsBackground(int resourceId) { itemsBackgroundResourceId = resourceId; if (backButtonImageView != null) { - backButtonImageView.setBackgroundResource(resourceId); + backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java index 52ab4e381..fe6781241 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java @@ -63,6 +63,10 @@ public class ActionBarMenu extends LinearLayout { } public ActionBarMenuItem addItem(int id, int icon, int backgroundResource) { + return addItem(id, icon, parentActionBar.itemsBackgroundResourceId, AndroidUtilities.dp(48)); + } + + public ActionBarMenuItem addItem(int id, int icon, int backgroundResource, int width) { ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundResource); menuItem.setTag(id); menuItem.setScaleType(ImageView.ScaleType.CENTER); @@ -70,7 +74,7 @@ public class ActionBarMenu extends LinearLayout { addView(menuItem); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams(); layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.width = AndroidUtilities.dp(48); + layoutParams.width = width; menuItem.setLayoutParams(layoutParams); menuItem.setOnClickListener(new OnClickListener() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java index e1fe066fd..92d0a1434 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java @@ -53,6 +53,8 @@ public class ActionBarMenuItem extends ImageView { private int[] location; private View selectedMenuView; private Runnable showMenuRunnable; + private boolean showFromBottom; + private int height; public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) { super(context); @@ -129,6 +131,10 @@ public class ActionBarMenuItem extends ImageView { return super.onTouchEvent(event); } + public void setShowFromBottom(boolean value) { + showFromBottom = value; + } + public void addSubItem(int id, String text, int icon) { if (popupLayout == null) { rect = new Rect(); @@ -238,10 +244,23 @@ public class ActionBarMenuItem extends ImageView { } popupWindow.setFocusable(true); if (popupLayout.getMeasuredWidth() == 0) { - popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); - popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); + if (showFromBottom) { + popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -popupLayout.getMeasuredHeight() + AndroidUtilities.dp(12)); + popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -popupLayout.getMeasuredHeight() + AndroidUtilities.dp(12), -1, -1); + height = popupLayout.getMeasuredHeight(); + } else { + popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); + popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); + } } else { - popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); + if (showFromBottom) { + if (height == 0) { + height = popupLayout.getMeasuredHeight(); + } + popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -height + AndroidUtilities.dp(12)); + } else { + popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight()); + } } } @@ -287,7 +306,7 @@ public class ActionBarMenuItem extends ImageView { searchField.setTextColor(0xffffffff); searchField.setSingleLine(true); searchField.setBackgroundResource(R.drawable.search_light_states); - searchField.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), 0); + searchField.setPadding(0, 0, 0, 0); searchField.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS); if (android.os.Build.VERSION.SDK_INT < 11) { searchField.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @@ -366,7 +385,8 @@ public class ActionBarMenuItem extends ImageView { layoutParams.width = 0; layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.height = AndroidUtilities.dp(36); - layoutParams.rightMargin = AndroidUtilities.dp(16); + layoutParams.rightMargin = AndroidUtilities.dp(22); + layoutParams.leftMargin = AndroidUtilities.dp(6); searchField.setLayoutParams(layoutParams); searchField.setVisibility(GONE); } @@ -386,9 +406,11 @@ public class ActionBarMenuItem extends ImageView { protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (popupWindow != null && popupWindow.isShowing()) { - int x = parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(); - int y = -getMeasuredHeight(); - popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); + if (showFromBottom) { + popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(12), -height + AndroidUtilities.dp(12), -1, -1); + } else { + popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java index 5a6995070..ed57814ce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java @@ -34,6 +34,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { private boolean onlyUsers; private boolean needPhonebook; private HashMap ignoreUsers; + private HashMap checkedMap; public ContactsAdapter(Context context, boolean arg1, boolean arg2, HashMap arg3) { mContext = context; @@ -42,6 +43,10 @@ public class ContactsAdapter extends BaseSectionsAdapter { ignoreUsers = arg3; } + public void setCheckedMap(HashMap map) { + checkedMap = map; + } + @Override public Object getItem(int section, int position) { if (onlyUsers) { @@ -212,6 +217,9 @@ public class ContactsAdapter extends BaseSectionsAdapter { ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers ? 0 : 1))); TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id); ((UserCell)convertView).setData(user, null, null, 0); + if (checkedMap != null) { + ((UserCell) convertView).setChecked(checkedMap.containsKey(user.id)); + } if (ignoreUsers != null) { if (ignoreUsers.containsKey(user.id)) { ViewProxy.setAlpha(convertView, 0.5f); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsSearchAdapter.java index ab1b45f60..aa68e3572 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsSearchAdapter.java @@ -36,6 +36,7 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter { private HashMap ignoreUsers; private ArrayList searchResult = new ArrayList(); private ArrayList searchResultNames = new ArrayList(); + private HashMap checkedMap; private Timer searchTimer; private boolean allowUsernameSearch; private boolean useUserCell; @@ -46,6 +47,10 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter { allowUsernameSearch = usernameSearch; } + public void setCheckedMap(HashMap map) { + checkedMap = map; + } + public void setUseUserCell(boolean value) { useUserCell = value; } @@ -238,6 +243,9 @@ public class ContactsSearchAdapter extends BaseContactsSearchAdapter { if (useUserCell) { ((UserCell) view).setData(user, name, username, 0); + if (checkedMap != null) { + ((UserCell) view).setChecked(checkedMap.containsKey(user.id)); + } } else { ((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1); if (ignoreUsers != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java index afa3db16b..6b660b8bf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -136,7 +136,7 @@ public class DialogsAdapter extends BaseFragmentAdapter { @Override public boolean isEmpty() { if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) { - return false; + return true; } int count; if (serverOnly) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 3f04768af..4810729b3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -33,6 +33,7 @@ import org.telegram.android.ImageReceiver; import org.telegram.ui.Views.AvatarDrawable; public class DialogCell extends BaseCell { + private static TextPaint namePaint; private static TextPaint nameEncryptedPaint; private static TextPaint nameUnknownPaint; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java index e17397a8c..1492ccf90 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java @@ -12,7 +12,6 @@ import android.content.Context; import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; -import android.widget.CheckBox; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -27,6 +26,7 @@ import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.ui.Views.AvatarDrawable; import org.telegram.ui.Views.BackupImageView; +import org.telegram.ui.Views.CheckBox; public class UserCell extends FrameLayout { @@ -111,6 +111,18 @@ public class UserCell extends FrameLayout { layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL; imageView.setLayoutParams(layoutParams); + + checkBox = new CheckBox(context); + checkBox.setVisibility(GONE); + addView(checkBox); + layoutParams = (LayoutParams) checkBox.getLayoutParams(); + layoutParams.width = AndroidUtilities.dp(22); + layoutParams.height = AndroidUtilities.dp(22); + layoutParams.topMargin = AndroidUtilities.dp(38); + layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(37 + padding); + layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(37 + padding) : 0; + layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + checkBox.setLayoutParams(layoutParams); } public void setData(TLRPC.User user, CharSequence name, CharSequence status, int resId) { @@ -130,6 +142,13 @@ public class UserCell extends FrameLayout { update(0); } + public void setChecked(boolean checked) { + if (checkBox.getVisibility() != VISIBLE) { + checkBox.setVisibility(VISIBLE); + } + checkBox.setChecked(checked); + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java index 210dbf57c..89a82c3e6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java @@ -74,7 +74,7 @@ public class ChangeChatNameActivity extends BaseFragment { }); ActionBarMenu menu = actionBar.createMenu(); - doneButton = menu.addItem(done_button, R.drawable.ic_done); + doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java index 90967404e..b063700d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java @@ -67,7 +67,7 @@ public class ChangeNameActivity extends BaseFragment { }); ActionBarMenu menu = actionBar.createMenu(); - doneButton = menu.addItem(done_button, R.drawable.ic_done); + doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java index 3f78310a1..82cee7a35 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java @@ -77,7 +77,7 @@ public class ChangeUsernameActivity extends BaseFragment { }); ActionBarMenu menu = actionBar.createMenu(); - doneButton = menu.addItem(done_button, R.drawable.ic_done); + doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); if (user == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 527d3cb80..120fb8dc7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -29,6 +29,7 @@ import android.provider.MediaStore; import android.text.Html; import android.text.TextUtils; import android.util.SparseArray; +import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -42,7 +43,6 @@ import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -112,7 +112,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private TypingDotsDrawable typingDotsDrawable; private View emptyViewContainer; private ArrayList actionModeViews = new ArrayList(); - + private TextView nameTextView; + private TextView onlineTextView; + private FrameLayout avatarContainer; private TextView bottomOverlayText; private MessageObject selectedObject; @@ -186,7 +188,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private final static int attach_video = 8; private final static int attach_document = 9; private final static int attach_location = 10; - private final static int chat_menu_avatar = 11; AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener() { @Override @@ -549,31 +550,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); presentFragment(fragment); - } else if (id == chat_menu_avatar) { - if (currentUser != null) { - Bundle args = new Bundle(); - args.putInt("user_id", currentUser.id); - if (currentEncryptedChat != null) { - args.putLong("dialog_id", dialog_id); - } - presentFragment(new ProfileActivity(args)); - } else if (currentChat != null) { - if (info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) { - return; - } - int count = currentChat.participants_count; - if (info != null) { - count = info.participants.size(); - } - if (count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) { - return; - } - Bundle args = new Bundle(); - args.putInt("chat_id", currentChat.id); - ProfileActivity fragment = new ProfileActivity(args); - fragment.setChatInfo(info); - presentFragment(fragment); - } } else if (id == copy) { String str = ""; ArrayList ids = new ArrayList(selectedMessagesCanCopyIds.keySet()); @@ -634,13 +610,99 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); + avatarContainer = new FrameLayout(getParentActivity()); + actionBar.addView(avatarContainer); + FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams(); + layoutParams2.height = AndroidUtilities.dp(48); + layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.rightMargin = AndroidUtilities.dp(48 + (currentEncryptedChat != null ? 48 : 0)); + layoutParams2.leftMargin = AndroidUtilities.dp(64); + layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; + avatarContainer.setLayoutParams(layoutParams2); + avatarContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (currentUser != null) { + Bundle args = new Bundle(); + args.putInt("user_id", currentUser.id); + if (currentEncryptedChat != null) { + args.putLong("dialog_id", dialog_id); + } + presentFragment(new ProfileActivity(args)); + } else if (currentChat != null) { + if (info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) { + return; + } + int count = currentChat.participants_count; + if (info != null) { + count = info.participants.size(); + } + if (count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) { + return; + } + Bundle args = new Bundle(); + args.putInt("chat_id", currentChat.id); + ProfileActivity fragment = new ProfileActivity(args); + fragment.setChatInfo(info); + presentFragment(fragment); + } + } + }); + + avatarImageView = new BackupImageView(getParentActivity()); + avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(21)); + avatarImageView.processDetach = false; + avatarContainer.addView(avatarImageView); + layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams(); + layoutParams2.width = AndroidUtilities.dp(42); + layoutParams2.height = AndroidUtilities.dp(42); + layoutParams2.topMargin = AndroidUtilities.dp(3); + avatarImageView.setLayoutParams(layoutParams2); + + nameTextView = new TextView(getParentActivity()); + nameTextView.setTextColor(0xffffffff); + nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); + nameTextView.setLines(1); + nameTextView.setMaxLines(1); + nameTextView.setSingleLine(true); + nameTextView.setEllipsize(TextUtils.TruncateAt.END); + nameTextView.setGravity(Gravity.LEFT); + nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + avatarContainer.addView(nameTextView); + layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); + layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.leftMargin = AndroidUtilities.dp(54); + layoutParams2.bottomMargin = AndroidUtilities.dp(22); + layoutParams2.gravity = Gravity.BOTTOM; + nameTextView.setLayoutParams(layoutParams2); + + onlineTextView = new TextView(getParentActivity()); + onlineTextView.setTextColor(0xffd7e8f7); + onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + onlineTextView.setLines(1); + onlineTextView.setMaxLines(1); + onlineTextView.setSingleLine(true); + onlineTextView.setEllipsize(TextUtils.TruncateAt.END); + onlineTextView.setGravity(Gravity.LEFT); + avatarContainer.addView(onlineTextView); + layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); + layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.leftMargin = AndroidUtilities.dp(54); + layoutParams2.bottomMargin = AndroidUtilities.dp(4); + layoutParams2.gravity = Gravity.BOTTOM; + onlineTextView.setLayoutParams(layoutParams2); + updateTitle(); updateSubtitle(); if (currentEncryptedChat != null) { - actionBar.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); + nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0); + nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); } else if (currentChat != null && currentChat.id < 0) { - actionBar.setTitleIcon(R.drawable.broadcast2, AndroidUtilities.dp(4)); + nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.broadcast2, 0, 0, 0); + nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); } ActionBarMenu menu = actionBar.createMenu(); @@ -656,6 +718,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not item.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc); item.addSubItem(attach_location, LocaleController.getString("ChatLocation", R.string.ChatLocation), R.drawable.ic_attach_location); menuItem = item; + item.setShowFromBottom(true); + item.setBackground(null); actionModeViews.clear(); @@ -704,10 +768,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode)); } actionMode.getItem(copy).setVisibility(selectedMessagesCanCopyIds.size() != 0 ? View.VISIBLE : View.GONE); - - View avatarLayout = menu.addItemResource(chat_menu_avatar, R.layout.chat_header_layout); - avatarImageView = (BackupImageView)avatarLayout.findViewById(R.id.chat_avatar_image); - avatarImageView.processDetach = false; checkActionBarMenu(); fragmentView = inflater.inflate(R.layout.chat_layout, container, false); @@ -1038,6 +1098,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateBottomOverlay(); chatActivityEnterView.setContainerView(getParentActivity(), fragmentView); + chatActivityEnterView.addToAttachLayout(menuItem); } else { ViewGroup parent = (ViewGroup)fragmentView.getParent(); if (parent != null) { @@ -1371,16 +1432,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private void updateTitle() { if (currentChat != null) { - actionBar.setTitle(currentChat.title); + nameTextView.setText(currentChat.title); } else if (currentUser != null) { if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) { if (currentUser.phone != null && currentUser.phone.length() != 0) { - actionBar.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); + nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone)); } else { - actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } } else { - actionBar.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } } } @@ -1394,18 +1455,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not setTypingAnimation(false); if (currentChat != null) { if (currentChat instanceof TLRPC.TL_chatForbidden) { - actionBar.setSubtitle(LocaleController.getString("YouWereKicked", R.string.YouWereKicked)); + onlineTextView.setText(LocaleController.getString("YouWereKicked", R.string.YouWereKicked)); } else if (currentChat.left) { - actionBar.setSubtitle(LocaleController.getString("YouLeft", R.string.YouLeft)); + onlineTextView.setText(LocaleController.getString("YouLeft", R.string.YouLeft)); } else { int count = currentChat.participants_count; if (info != null) { count = info.participants.size(); } if (onlineCount > 1 && count != 0) { - actionBar.setSubtitle(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))); + onlineTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))); } else { - actionBar.setSubtitle(LocaleController.formatPluralString("Members", count)); + onlineTextView.setText(LocaleController.formatPluralString("Members", count)); } } } else if (currentUser != null) { @@ -1415,13 +1476,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (lastPrintString != null || lastStatus != user.status || lastStatus != null && user.status != null && lastStatus.expires != user.status.expires) { lastStatus = user.status; - actionBar.setSubtitle(LocaleController.formatUserStatus(currentUser)); + onlineTextView.setText(LocaleController.formatUserStatus(currentUser)); } } lastPrintString = null; } else { lastPrintString = printString; - actionBar.setSubtitle(printString); + onlineTextView.setText(printString); setTypingAnimation(true); } } @@ -1432,13 +1493,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (start) { try { - actionBar.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4)); + onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null); + onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); typingDotsDrawable.start(); } catch (Exception e) { FileLog.e("tmessages", e); } } else { - actionBar.setSubTitleIcon(0, null, 0); + onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); + onlineTextView.setCompoundDrawablePadding(0); if (typingDotsDrawable != null) { typingDotsDrawable.stop(); } @@ -2531,28 +2594,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void fixLayout(final boolean resume) { - if (avatarImageView != null) { - avatarImageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + if (avatarContainer != null) { + avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { - if (avatarImageView != null) { - avatarImageView.getViewTreeObserver().removeOnPreDrawListener(this); + if (avatarContainer != null) { + avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this); } if (getParentActivity() == null) { return false; } - int height = AndroidUtilities.getCurrentActionBarHeight(); if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { selectedMessagesCountTextView.setTextSize(16); } else { selectedMessagesCountTextView.setTextSize(18); } - if (avatarImageView != null) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) avatarImageView.getLayoutParams(); - params.width = height; - params.height = height; - avatarImageView.setLayoutParams(params); - } + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)avatarContainer.getLayoutParams(); + layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2; + avatarContainer.setLayoutParams(layoutParams); return false; } }); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java index 670eee6c1..67dc13c19 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java @@ -98,7 +98,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent }); ActionBarMenu menu = actionBar.createMenu(); - doneButton = menu.addItem(done_button, R.drawable.ic_done); + doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); fragmentView = inflater.inflate(R.layout.contact_add_layout, container, false); @@ -112,6 +112,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent onlineText = (TextView)fragmentView.findViewById(R.id.settings_online); avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image); avatarImage.processDetach = false; + avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(32)); phoneText = (TextView)fragmentView.findViewById(R.id.settings_name); Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf"); phoneText.setTypeface(typeface); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index 32c49b260..0f6d65d70 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -47,7 +47,6 @@ import org.telegram.messenger.FileLog; import org.telegram.android.MessagesController; import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; -import org.telegram.ui.Adapters.BaseSectionsAdapter; import org.telegram.ui.Adapters.ContactsAdapter; import org.telegram.ui.Adapters.ContactsSearchAdapter; import org.telegram.ui.ActionBar.ActionBar; @@ -85,7 +84,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen } } - private BaseSectionsAdapter listViewAdapter; + private ContactsAdapter listViewAdapter; private TextView emptyTextView; private EditText userSelectEditText; private SectionsListView listView; @@ -98,7 +97,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen private boolean searchWas; private boolean searching; private CharSequence changeString; - private HashMap selectedContacts = new HashMap(); + private HashMap selectedContacts = new HashMap(); private ArrayList allSpans = new ArrayList(); private final static int done_button = 1; @@ -158,13 +157,13 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen } }); ActionBarMenu menu = actionBar.createMenu(); - View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout); - TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button); - doneTextView.setText(LocaleController.getString("Next", R.string.Next)); + menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false); - listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null); + searchListViewAdapter.setCheckedMap(selectedContacts); searchListViewAdapter.setUseUserCell(true); + listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null); + listViewAdapter.setCheckedMap(selectedContacts); fragmentView = new LinearLayout(getParentActivity()); LinearLayout linearLayout = (LinearLayout) fragmentView; @@ -182,19 +181,23 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); userSelectEditText.setHintTextColor(0xffa6a6a6); userSelectEditText.setTextColor(0xff000000); - userSelectEditText.setMinimumHeight(AndroidUtilities.dp(52)); - userSelectEditText.setMaxLines(2); - userSelectEditText.setPadding(userSelectEditText.getPaddingLeft(), AndroidUtilities.dp(3), userSelectEditText.getPaddingRight(), userSelectEditText.getPaddingBottom()); userSelectEditText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE); - userSelectEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); + userSelectEditText.setMinimumHeight(AndroidUtilities.dp(54)); + userSelectEditText.setSingleLine(false); + userSelectEditText.setLines(2); + userSelectEditText.setMaxLines(2); + userSelectEditText.setVerticalScrollBarEnabled(true); + userSelectEditText.setHorizontalScrollBarEnabled(false); + userSelectEditText.setPadding(0, 0, 0, 0); + userSelectEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); userSelectEditText.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); AndroidUtilities.clearCursorDrawable(userSelectEditText); frameLayout.addView(userSelectEditText); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) userSelectEditText.getLayoutParams(); layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.leftMargin = AndroidUtilities.dp(5); - layoutParams1.rightMargin = AndroidUtilities.dp(5); + layoutParams1.leftMargin = AndroidUtilities.dp(10); + layoutParams1.rightMargin = AndroidUtilities.dp(10); layoutParams1.gravity = Gravity.TOP; userSelectEditText.setLayoutParams(layoutParams1); @@ -324,16 +327,21 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { - /*TLRPC.User user; - int section = listViewAdapter.getSectionForPosition(i); - int row = listViewAdapter.getPositionInSectionForPosition(i); + TLRPC.User user = null; if (searching && searchWas) { - user = searchResult.get(row); + user = searchListViewAdapter.getItem(i); } else { - ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); - user = MessagesController.getInstance().getUser(arr.get(row).user_id); - listView.invalidateViews(); + int section = listViewAdapter.getSectionForPosition(i); + int row = listViewAdapter.getPositionInSectionForPosition(i); + if (row < 0 || section < 0) { + return; + } + user = (TLRPC.User) listViewAdapter.getItem(section, row); } + if (user == null) { + return; + } + if (selectedContacts.containsKey(user.id)) { XImageSpan span = selectedContacts.get(user.id); selectedContacts.remove(user.id); @@ -355,10 +363,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen } actionBar.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount)); if (searching || searchWas) { - searching = false; - searchWas = false; - emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); - ignoreChange = true; SpannableStringBuilder ssb = new SpannableStringBuilder(""); for (ImageSpan sp : allSpans) { @@ -369,10 +373,21 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen userSelectEditText.setSelection(ssb.length()); ignoreChange = false; + searchListViewAdapter.searchDialogs(null); + searching = false; + searchWas = false; + ViewGroup group = (ViewGroup) listView.getParent(); + listView.setAdapter(listViewAdapter); listViewAdapter.notifyDataSetChanged(); + if (android.os.Build.VERSION.SDK_INT >= 11) { + listView.setFastScrollAlwaysVisible(true); + } + listView.setFastScrollEnabled(true); + listView.setVerticalScrollBarEnabled(false); + emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); } else { listView.invalidateViews(); - }*/ + } } }); listView.setOnScrollListener(new AbsListView.OnScrollListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java index 336dbadf4..bef7552a4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java @@ -8,17 +8,25 @@ package org.telegram.ui; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.text.Editable; +import android.text.InputType; +import android.text.TextWatcher; +import android.util.TypedValue; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.inputmethod.EditorInfo; import android.widget.EditText; +import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.ListView; -import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.messenger.ConnectionsManager; @@ -30,6 +38,7 @@ import org.telegram.android.MessagesController; import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; import org.telegram.ui.Adapters.BaseFragmentAdapter; +import org.telegram.ui.Cells.GreySectionCell; import org.telegram.ui.Cells.UserCell; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; @@ -175,15 +184,33 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati }); ActionBarMenu menu = actionBar.createMenu(); - View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout); + menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); - TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button); - doneTextView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase()); + fragmentView = new LinearLayout(getParentActivity()); + LinearLayout linearLayout = (LinearLayout) fragmentView; + linearLayout.setOrientation(LinearLayout.VERTICAL); - fragmentView = inflater.inflate(R.layout.group_create_final_layout, container, false); + FrameLayout frameLayout = new FrameLayout(getParentActivity()); + linearLayout.addView(frameLayout); + LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); + layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; + frameLayout.setLayoutParams(layoutParams); + avatarImage = new BackupImageView(getParentActivity()); + avatarDrawable.setInfo(5, null, null, isBroadcast); + avatarImage.setImageDrawable(avatarDrawable); + frameLayout.addView(avatarImage); + FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); + layoutParams1.width = AndroidUtilities.dp(64); + layoutParams1.height = AndroidUtilities.dp(64); + layoutParams1.topMargin = AndroidUtilities.dp(12); + layoutParams1.bottomMargin = AndroidUtilities.dp(12); + layoutParams1.leftMargin = AndroidUtilities.dp(16); + avatarImage.setLayoutParams(layoutParams1); if (!isBroadcast) { - /*button2.setOnClickListener(new View.OnClickListener() { + avatarDrawable.setDrawPhoto(true); + avatarImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (getParentActivity() == null) { @@ -215,25 +242,66 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati }); showAlertDialog(builder); } - });*/ + }); } - avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image); - avatarDrawable.setInfo(3, null, null, isBroadcast); - avatarImage.setImageDrawable(avatarDrawable); - - nameTextView = (EditText)fragmentView.findViewById(R.id.bubble_input_text); - if (isBroadcast) { - nameTextView.setHint(LocaleController.getString("EnterListName", R.string.EnterListName)); - } else { - nameTextView.setHint(LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder)); - } + nameTextView = new EditText(getParentActivity()); + nameTextView.setHint(isBroadcast ? LocaleController.getString("EnterListName", R.string.EnterListName) : LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder)); if (nameToSet != null) { nameTextView.setText(nameToSet); nameToSet = null; } - listView = (ListView)fragmentView.findViewById(R.id.listView); + nameTextView.setMaxLines(4); + nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); + nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + nameTextView.setHintTextColor(0xffa6a6a6); + nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); + nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); + nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8)); + AndroidUtilities.clearCursorDrawable(nameTextView); + nameTextView.setTextColor(0xff000000); + frameLayout.addView(nameTextView); + layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); + layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.leftMargin = AndroidUtilities.dp(96); + layoutParams1.rightMargin = AndroidUtilities.dp(16); + layoutParams1.gravity = Gravity.CENTER_VERTICAL; + nameTextView.setLayoutParams(layoutParams1); + if (!isBroadcast) { + nameTextView.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable s) { + avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null, null, isBroadcast); + avatarImage.invalidate(); + } + }); + } + + GreySectionCell sectionCell = new GreySectionCell(getParentActivity()); + sectionCell.setText(LocaleController.formatPluralString("Members", selectedContacts.size())); + linearLayout.addView(sectionCell); + + listView = new ListView(getParentActivity()); + listView.setDivider(null); + listView.setDividerHeight(0); + listView.setVerticalScrollBarEnabled(false); listView.setAdapter(new ListAdapter(getParentActivity())); + linearLayout.addView(listView); + layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams(); + layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + listView.setLayoutParams(layoutParams); } else { ViewGroup parent = (ViewGroup)fragmentView.getParent(); if (parent != null) { @@ -359,21 +427,28 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati @Override public View getView(int i, View view, ViewGroup viewGroup) { - TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(i)); if (view == null) { view = new UserCell(mContext, 1); } + + TLRPC.User user = MessagesController.getInstance().getUser(selectedContacts.get(i)); ((UserCell) view).setData(user, null, null, 0); return view; + } - /* - if (convertView == null) { - convertView = new SettingsSectionLayout(mContext); - convertView.setBackgroundColor(0xffffffff); - } - ((SettingsSectionLayout) convertView).setText(LocaleController.formatPluralString("Members", selectedContacts.size()).toUpperCase()); - return convertView; - */ + @Override + public int getItemViewType(int position) { + return 0; + } + + @Override + public int getViewTypeCount() { + return 1; + } + + @Override + public int getCount() { + return selectedContacts.size(); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 4b00db4ef..f3690f321 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -305,7 +305,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); drawerLayoutContainer.setParentActionBarLayout(actionBarLayout); - drawerLayoutContainer.setAllowOpenDrawer(true); actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer); } actionBarLayout.init(mainFragmentsStack); @@ -1119,6 +1118,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) { + drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity)); if (AndroidUtilities.isTablet()) { if (fragment instanceof MessagesActivity) { MessagesActivity messagesActivity = (MessagesActivity)fragment; @@ -1196,6 +1196,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) { + drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity)); if (AndroidUtilities.isTablet()) { if (fragment instanceof MessagesActivity) { MessagesActivity messagesActivity = (MessagesActivity)fragment; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index a9cf6b42a..8f4093716 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -12,315 +12,78 @@ import android.animation.Animator; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageInfo; +import android.graphics.Paint; +import android.graphics.Typeface; +import android.os.Build; import android.os.Bundle; +import android.telephony.TelephonyManager; +import android.text.Editable; +import android.text.InputFilter; +import android.text.InputType; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.text.TextPaint; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.text.style.MetricAffectingSpan; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.inputmethod.EditorInfo; +import android.widget.AdapterView; +import android.widget.EditText; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; +import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.android.AndroidUtilities; +import org.telegram.android.ContactsController; +import org.telegram.android.MessagesController; +import org.telegram.android.MessagesStorage; +import org.telegram.android.NotificationCenter; +import org.telegram.messenger.BuildVars; +import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.android.LocaleController; 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.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.Views.SlideView; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; -public class LoginActivity extends BaseFragment implements SlideView.SlideViewDelegate { +public class LoginActivity extends BaseFragment { private int currentViewNum = 0; private SlideView[] views = new SlideView[3]; private ProgressDialog progressDialog; private final static int done_button = 1; - /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - @Override public void onFragmentDestroy() { super.onFragmentDestroy(); @@ -348,21 +111,61 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe @Override public void onItemClick(int id) { if (id == done_button) { - onNextAction(); + views[currentViewNum].onNextPressed(); } } }); ActionBarMenu menu = actionBar.createMenu(); - View doneItem = menu.addItemResource(done_button, R.layout.group_create_done_layout); - TextView doneTextView = (TextView)doneItem.findViewById(R.id.done_button); - doneTextView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase()); + menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); - fragmentView = inflater.inflate(R.layout.login_layout, container, false); + fragmentView = new ScrollView(getParentActivity()); + ScrollView scrollView = (ScrollView) fragmentView; + scrollView.setFillViewport(true); - views[0] = (SlideView)fragmentView.findViewById(R.id.login_page1); - views[1] = (SlideView)fragmentView.findViewById(R.id.login_page2); - views[2] = (SlideView)fragmentView.findViewById(R.id.login_page3); + FrameLayout frameLayout = new FrameLayout(getParentActivity()); + scrollView.addView(frameLayout); + ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) frameLayout.getLayoutParams(); + layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT; + layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + frameLayout.setLayoutParams(layoutParams); + + views[0] = new PhoneView(getParentActivity()); + views[0].setVisibility(View.VISIBLE); + frameLayout.addView(views[0]); + FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) views[0].getLayoutParams(); + layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.leftMargin = AndroidUtilities.dp(16); + layoutParams1.rightMargin = AndroidUtilities.dp(16); + layoutParams1.topMargin = AndroidUtilities.dp(30); + layoutParams1.gravity = Gravity.TOP | Gravity.LEFT; + views[0].setLayoutParams(layoutParams1); + + views[1] = new LoginActivitySmsView(getParentActivity()); + views[1].setVisibility(View.GONE); + frameLayout.addView(views[1]); + layoutParams1 = (FrameLayout.LayoutParams) views[1].getLayoutParams(); + layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.leftMargin = AndroidUtilities.dp(16); + layoutParams1.rightMargin = AndroidUtilities.dp(16); + layoutParams1.topMargin = AndroidUtilities.dp(30); + layoutParams1.gravity = Gravity.TOP | Gravity.LEFT; + views[1].setLayoutParams(layoutParams1); + + views[2] = new RegisterView(getParentActivity()); + views[2].setVisibility(View.GONE); + frameLayout.addView(views[2]); + layoutParams1 = (FrameLayout.LayoutParams) views[2].getLayoutParams(); + layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.leftMargin = AndroidUtilities.dp(16); + layoutParams1.rightMargin = AndroidUtilities.dp(16); + layoutParams1.topMargin = AndroidUtilities.dp(30); + layoutParams1.gravity = Gravity.TOP | Gravity.LEFT; + views[2].setLayoutParams(layoutParams1); try { if (views[0] == null || views[1] == null || views[2] == null) { @@ -389,7 +192,6 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe if (savedInstanceState != null) { v.restoreStateParams(savedInstanceState); } - v.delegate = this; v.setVisibility(currentViewNum == a ? View.VISIBLE : View.GONE); } } @@ -414,26 +216,6 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); } - private void saveCurrentState() { - try { - Bundle bundle = new Bundle(); - bundle.putInt("currentViewNum", currentViewNum); - for (int a = 0; a <= currentViewNum; a++) { - SlideView v = views[a]; - if (v != null) { - v.saveStateParams(bundle); - } - } - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", Context.MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - editor.clear(); - putBundleToEditor(bundle, editor, null); - editor.commit(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - private Bundle loadCurrentState() { try { Bundle bundle = new Bundle(); @@ -506,6 +288,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe v.onDestroyActivity(); } } + clearCurrentState(); return true; } else if (currentViewNum != 1 && currentViewNum != 2) { setPage(0, true, null, true); @@ -513,7 +296,6 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe return false; } - @Override public void needShowAlert(final String text) { if (text == null || getParentActivity() == null) { return; @@ -525,7 +307,6 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe showAlertDialog(builder); } - @Override public void needShowProgress() { if (getParentActivity() == null || getParentActivity().isFinishing() || progressDialog != null) { return; @@ -537,7 +318,6 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe progressDialog.show(); } - @Override public void needHideProgress() { if (progressDialog == null) { return; @@ -607,19 +387,1253 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe } } - @Override - public void onNextAction() { - views[currentViewNum].onNextPressed(); - } - @Override public void saveSelfArgs(Bundle outState) { - saveCurrentState(); + try { + Bundle bundle = new Bundle(); + bundle.putInt("currentViewNum", currentViewNum); + for (int a = 0; a <= currentViewNum; a++) { + SlideView v = views[a]; + if (v != null) { + v.saveStateParams(bundle); + } + } + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.clear(); + putBundleToEditor(bundle, editor, null); + editor.commit(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } } - @Override public void needFinishActivity() { clearCurrentState(); presentFragment(new MessagesActivity(null), true); } + + public class SlideView extends LinearLayout { + + public SlideView(Context context) { + super(context); + } + + public String getHeaderName() { + return ""; + } + + public void setParams(Bundle params) { + + } + + public void onBackPressed() { + + } + + public void onShow() { + + } + + public void onDestroyActivity() { + + } + + public void onNextPressed() { + + } + + public void saveStateParams(Bundle bundle) { + + } + + public void restoreStateParams(Bundle bundle) { + + } + } + + public class PhoneView extends SlideView implements AdapterView.OnItemSelectedListener { + + private EditText codeField; + private EditText phoneField; + private TextView countryButton; + + private int countryState = 0; + + private ArrayList countriesArray = new ArrayList(); + private HashMap countriesMap = new HashMap(); + private HashMap codesMap = new HashMap(); + + private boolean ignoreSelection = false; + private boolean ignoreOnTextChange = false; + private boolean ignoreOnPhoneChange = false; + private boolean nextPressed = false; + + public PhoneView(Context context) { + super(context); + + setOrientation(VERTICAL); + + countryButton = new TextView(context); + countryButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + countryButton.setPadding(AndroidUtilities.dp(12), AndroidUtilities.dp(10), AndroidUtilities.dp(12), 0); + countryButton.setTextColor(0xff212121); + countryButton.setMaxLines(1); + countryButton.setSingleLine(true); + countryButton.setEllipsize(TextUtils.TruncateAt.END); + countryButton.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL); + countryButton.setBackgroundResource(R.drawable.spinner_states); + addView(countryButton); + LayoutParams layoutParams = (LayoutParams) countryButton.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = AndroidUtilities.dp(36); + layoutParams.leftMargin = AndroidUtilities.dp(20); + layoutParams.rightMargin = AndroidUtilities.dp(20); + layoutParams.bottomMargin = AndroidUtilities.dp(14); + countryButton.setLayoutParams(layoutParams); + countryButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + CountrySelectActivity fragment = new CountrySelectActivity(); + fragment.setCountrySelectActivityDelegate(new CountrySelectActivity.CountrySelectActivityDelegate() { + @Override + public void didSelectCountry(String name) { + selectCountry(name); + phoneField.requestFocus(); + } + }); + presentFragment(fragment); + } + }); + + View view = new View(context); + view.setPadding(AndroidUtilities.dp(12), 0, AndroidUtilities.dp(12), 0); + view.setBackgroundColor(0xffdbdbdb); + addView(view); + layoutParams = (LayoutParams) view.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = 1; + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + layoutParams.topMargin = AndroidUtilities.dp(-17.5f); + view.setLayoutParams(layoutParams); + + LinearLayout linearLayout = new LinearLayout(context); + linearLayout.setOrientation(HORIZONTAL); + addView(linearLayout); + layoutParams = (LayoutParams) linearLayout.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.topMargin = AndroidUtilities.dp(20); + linearLayout.setLayoutParams(layoutParams); + + TextView textView = new TextView(context); + textView.setText("+"); + textView.setTextColor(0xff212121); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + linearLayout.addView(textView); + layoutParams = (LayoutParams) textView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(24); + textView.setLayoutParams(layoutParams); + + codeField = new EditText(context); + codeField.setInputType(InputType.TYPE_CLASS_PHONE); + codeField.setTextColor(0xff212121); + AndroidUtilities.clearCursorDrawable(codeField); + codeField.setPadding(AndroidUtilities.dp(10), 0, 0, 0); + codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + codeField.setMaxLines(1); + codeField.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); + codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); + InputFilter[] inputFilters = new InputFilter[1]; + inputFilters[0] = new InputFilter.LengthFilter(4); + codeField.setFilters(inputFilters); + linearLayout.addView(codeField); + layoutParams = (LayoutParams) codeField.getLayoutParams(); + layoutParams.width = AndroidUtilities.dp(55); + layoutParams.height = AndroidUtilities.dp(36); + layoutParams.rightMargin = AndroidUtilities.dp(16); + layoutParams.leftMargin = AndroidUtilities.dp(-9); + codeField.setLayoutParams(layoutParams); + codeField.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + + } + + @Override + public void afterTextChanged(Editable editable) { + if (ignoreOnTextChange) { + ignoreOnTextChange = false; + return; + } + ignoreOnTextChange = true; + String text = PhoneFormat.stripExceptNumbers(codeField.getText().toString()); + codeField.setText(text); + if (text.length() == 0) { + countryButton.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); + countryState = 1; + } else { + String country = codesMap.get(text); + if (country != null) { + int index = countriesArray.indexOf(country); + if (index != -1) { + ignoreSelection = true; + countryButton.setText(countriesArray.get(index)); + + updatePhoneField(); + countryState = 0; + } else { + countryButton.setText(LocaleController.getString("WrongCountry", R.string.WrongCountry)); + countryState = 2; + } + } else { + countryButton.setText(LocaleController.getString("WrongCountry", R.string.WrongCountry)); + countryState = 2; + } + codeField.setSelection(codeField.getText().length()); + } + } + }); + codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { + if (i == EditorInfo.IME_ACTION_NEXT) { + phoneField.requestFocus(); + return true; + } + return false; + } + }); + + phoneField = new EditText(context); + phoneField.setInputType(InputType.TYPE_CLASS_PHONE); + phoneField.setTextColor(0xff212121); + phoneField.setHintTextColor(0xff979797); + phoneField.setPadding(0, 0, 0, 0); + AndroidUtilities.clearCursorDrawable(phoneField); + phoneField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + phoneField.setMaxLines(1); + phoneField.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); + phoneField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); + linearLayout.addView(phoneField); + layoutParams = (LayoutParams) phoneField.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = AndroidUtilities.dp(36); + layoutParams.rightMargin = AndroidUtilities.dp(24); + phoneField.setLayoutParams(layoutParams); + phoneField.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + if (ignoreOnPhoneChange) { + return; + } + if (count == 1 && after == 0 && s.length() > 1) { + String phoneChars = "0123456789"; + String str = s.toString(); + String substr = str.substring(start, start + 1); + if (!phoneChars.contains(substr)) { + ignoreOnPhoneChange = true; + StringBuilder builder = new StringBuilder(str); + int toDelete = 0; + for (int a = start; a >= 0; a--) { + substr = str.substring(a, a + 1); + if(phoneChars.contains(substr)) { + break; + } + toDelete++; + } + builder.delete(Math.max(0, start - toDelete), start + 1); + str = builder.toString(); + if (PhoneFormat.strip(str).length() == 0) { + phoneField.setText(""); + } else { + phoneField.setText(str); + updatePhoneField(); + } + ignoreOnPhoneChange = false; + } + } + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable s) { + if (ignoreOnPhoneChange) { + return; + } + updatePhoneField(); + } + }); + phoneField.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { + if (i == EditorInfo.IME_ACTION_NEXT) { + onNextPressed(); + return true; + } + return false; + } + }); + + textView = new TextView(context); + textView.setText(LocaleController.getString("StartText", R.string.StartText)); + textView.setTextColor(0xff757575); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + textView.setGravity(Gravity.LEFT); + textView.setLineSpacing(AndroidUtilities.dp(2), 1.0f); + addView(textView); + layoutParams = (LayoutParams) textView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + layoutParams.topMargin = AndroidUtilities.dp(28); + layoutParams.bottomMargin = AndroidUtilities.dp(10); + layoutParams.gravity = Gravity.LEFT; + textView.setLayoutParams(layoutParams); + + HashMap languageMap = new HashMap(); + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().getAssets().open("countries.txt"))); + String line; + while ((line = reader.readLine()) != null) { + String[] args = line.split(";"); + countriesArray.add(0, args[2]); + countriesMap.put(args[2], args[0]); + codesMap.put(args[0], args[2]); + languageMap.put(args[1], args[2]); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + Collections.sort(countriesArray, new Comparator() { + @Override + public int compare(String lhs, String rhs) { + return lhs.compareTo(rhs); + } + }); + + String country = null; + + try { + TelephonyManager telephonyManager = (TelephonyManager)ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE); + if (telephonyManager != null) { + country = telephonyManager.getSimCountryIso().toUpperCase(); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + if (country != null) { + String countryName = languageMap.get(country); + if (countryName != null) { + int index = countriesArray.indexOf(countryName); + if (index != -1) { + codeField.setText(countriesMap.get(countryName)); + countryState = 0; + } + } + } + if (codeField.length() == 0) { + countryButton.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); + countryState = 1; + } + + if (codeField.length() != 0) { + AndroidUtilities.showKeyboard(phoneField); + phoneField.requestFocus(); + } else { + AndroidUtilities.showKeyboard(codeField); + codeField.requestFocus(); + } + } + + public void selectCountry(String name) { + int index = countriesArray.indexOf(name); + if (index != -1) { + ignoreOnTextChange = true; + codeField.setText(countriesMap.get(name)); + countryButton.setText(name); + countryState = 0; + } + } + + private void updatePhoneField() { + ignoreOnPhoneChange = true; + String codeText = codeField.getText().toString(); + String phone = PhoneFormat.getInstance().format("+" + codeText + phoneField.getText().toString()); + int idx = phone.indexOf(" "); + if (idx != -1) { + String resultCode = PhoneFormat.stripExceptNumbers(phone.substring(0, idx)); + if (!codeText.equals(resultCode)) { + phone = PhoneFormat.getInstance().format(phoneField.getText().toString()).trim(); + phoneField.setText(phone); + int len = phoneField.length(); + phoneField.setSelection(phoneField.length()); + } else { + phoneField.setText(phone.substring(idx).trim()); + int len = phoneField.length(); + phoneField.setSelection(phoneField.length()); + } + } else { + phoneField.setSelection(phoneField.length()); + } + ignoreOnPhoneChange = false; + } + + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + if (ignoreSelection) { + ignoreSelection = false; + return; + } + ignoreOnTextChange = true; + String str = countriesArray.get(i); + codeField.setText(countriesMap.get(str)); + updatePhoneField(); + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + + } + + @Override + public void onNextPressed() { + if (nextPressed) { + return; + } + if (countryState == 1) { + needShowAlert(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); + return; + } else if (countryState == 2) { + needShowAlert(LocaleController.getString("WrongCountry", R.string.WrongCountry)); + return; + } + if (codeField.length() == 0) { + needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); + return; + } + TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode(); + String phone = PhoneFormat.stripExceptNumbers("" + codeField.getText() + phoneField.getText()); + ConnectionsManager.getInstance().applyCountryPortNumber(phone); + req.api_hash = BuildVars.APP_HASH; + req.api_id = BuildVars.APP_ID; + req.sms_type = 0; + req.phone_number = phone; + req.lang_code = LocaleController.getLocaleString(Locale.getDefault()); + if (req.lang_code == null || req.lang_code.length() == 0) { + req.lang_code = "en"; + } + + final Bundle params = new Bundle(); + params.putString("phone", "+" + codeField.getText() + phoneField.getText()); + params.putString("phoneFormated", phone); + nextPressed = true; + needShowProgress(); + 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() { + nextPressed = false; + if (error == null) { + final TLRPC.TL_auth_sentCode res = (TLRPC.TL_auth_sentCode)response; + params.putString("phoneHash", res.phone_code_hash); + params.putInt("calltime", res.send_call_timeout * 1000); + if (res.phone_registered) { + params.putString("registered", "true"); + } + setPage(1, true, params, false); + } else { + if (error.text != null) { + if (error.text.contains("PHONE_NUMBER_INVALID")) { + needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); + } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { + needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode)); + } else if (error.text.contains("PHONE_CODE_EXPIRED")) { + needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired)); + } else if (error.text.startsWith("FLOOD_WAIT")) { + needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait)); + } else { + needShowAlert(error.text); + } + } + } + needHideProgress(); + } + }); + } + }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin | RPCRequest.RPCRequestClassTryDifferentDc | RPCRequest.RPCRequestClassEnableUnauthorized); + } + + @Override + public void onShow() { + super.onShow(); + if (phoneField != null) { + phoneField.requestFocus(); + phoneField.setSelection(phoneField.length()); + } + } + + @Override + public String getHeaderName() { + return LocaleController.getString("YourPhone", R.string.YourPhone); + } + + @Override + public void saveStateParams(Bundle bundle) { + String code = codeField.getText().toString(); + if (code != null && code.length() != 0) { + bundle.putString("phoneview_code", code); + } + String phone = phoneField.getText().toString(); + if (phone != null && phone.length() != 0) { + bundle.putString("phoneview_phone", phone); + } + } + + @Override + public void restoreStateParams(Bundle bundle) { + String code = bundle.getString("phoneview_code"); + if (code != null) { + codeField.setText(code); + } + String phone = bundle.getString("phoneview_phone"); + if (phone != null) { + phoneField.setText(phone); + } + } + } + + public class LoginActivitySmsView extends SlideView implements NotificationCenter.NotificationCenterDelegate { + + private String phoneHash; + private String requestPhone; + private String registered; + private EditText codeField; + private TextView confirmTextView; + private TextView timeText; + private TextView problemText; + private Bundle currentParams; + + private Timer timeTimer; + private Timer codeTimer; + private final Object timerSync = new Object(); + private volatile int time = 60000; + private volatile int codeTime = 15000; + private double lastCurrentTime; + private double lastCodeTime; + private boolean waitingForSms = false; + private boolean nextPressed = false; + private String lastError = ""; + + public class TypefaceSpan extends MetricAffectingSpan { + + private Typeface mTypeface; + + public TypefaceSpan(Typeface typeface) { + mTypeface = typeface; + } + + @Override + public void updateMeasureState(TextPaint p) { + p.setTypeface(mTypeface); + p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); + } + + @Override + public void updateDrawState(TextPaint tp) { + tp.setTypeface(mTypeface); + tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); + } + } + + public LoginActivitySmsView(Context context) { + super(context); + + setOrientation(VERTICAL); + + confirmTextView = new TextView(context); + confirmTextView.setTextColor(0xff757575); + confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + confirmTextView.setGravity(Gravity.LEFT); + confirmTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f); + addView(confirmTextView); + LayoutParams layoutParams = (LayoutParams) confirmTextView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.LEFT; + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + confirmTextView.setLayoutParams(layoutParams); + + codeField = new EditText(context); + codeField.setTextColor(0xff212121); + codeField.setHint(LocaleController.getString("Code", R.string.Code)); + AndroidUtilities.clearCursorDrawable(codeField); + codeField.setHintTextColor(0xff979797); + codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); + codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + codeField.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); + codeField.setMaxLines(1); + codeField.setPadding(0, 0, 0, 0); + addView(codeField); + layoutParams = (LayoutParams) codeField.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = AndroidUtilities.dp(36); + layoutParams.gravity = Gravity.CENTER_HORIZONTAL; + layoutParams.topMargin = AndroidUtilities.dp(20); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + codeField.setLayoutParams(layoutParams); + codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { + if (i == EditorInfo.IME_ACTION_NEXT) { + onNextPressed(); + return true; + } + return false; + } + }); + + timeText = new TextView(context); + timeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + timeText.setTextColor(0xff757575); + timeText.setLineSpacing(AndroidUtilities.dp(2), 1.0f); + timeText.setGravity(Gravity.LEFT); + addView(timeText); + layoutParams = (LayoutParams) timeText.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.LEFT; + layoutParams.topMargin = AndroidUtilities.dp(30); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + timeText.setLayoutParams(layoutParams); + + problemText = new TextView(context); + problemText.setText(LocaleController.getString("DidNotGetTheCode", R.string.DidNotGetTheCode)); + problemText.setVisibility(time < 1000 ? VISIBLE : GONE); + problemText.setGravity(Gravity.LEFT); + problemText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + problemText.setTextColor(0xff548ab6); + problemText.setLineSpacing(AndroidUtilities.dp(2), 1.0f); + problemText.setPadding(0, AndroidUtilities.dp(2), 0, AndroidUtilities.dp(12)); + addView(problemText); + layoutParams = (LayoutParams) problemText.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.LEFT; + layoutParams.topMargin = AndroidUtilities.dp(20); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + problemText.setLayoutParams(layoutParams); + problemText.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + try { + PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); + String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode); + + Intent mailer = new Intent(Intent.ACTION_SEND); + mailer.setType("message/rfc822"); + mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@telegram.org"}); + mailer.putExtra(Intent.EXTRA_SUBJECT, "Android registration/login issue " + version + " " + requestPhone); + mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError); + getContext().startActivity(Intent.createChooser(mailer, "Send email...")); + } catch (Exception e) { + needShowAlert(LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled)); + } + } + }); + + LinearLayout linearLayout = new LinearLayout(context); + linearLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL); + addView(linearLayout); + layoutParams = (LayoutParams) linearLayout.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + linearLayout.setLayoutParams(layoutParams); + + TextView wrongNumber = new TextView(context); + wrongNumber.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL); + wrongNumber.setTextColor(0xff548ab6); + wrongNumber.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + wrongNumber.setLineSpacing(AndroidUtilities.dp(2), 1.0f); + wrongNumber.setPadding(0, AndroidUtilities.dp(24), 0, 0); + linearLayout.addView(wrongNumber); + layoutParams = (LayoutParams) wrongNumber.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; + layoutParams.bottomMargin = AndroidUtilities.dp(10); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + wrongNumber.setLayoutParams(layoutParams); + wrongNumber.setText(LocaleController.getString("WrongNumber", R.string.WrongNumber)); + wrongNumber.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + onBackPressed(); + setPage(0, true, null, true); + } + }); + } + + @Override + public String getHeaderName() { + return LocaleController.getString("YourCode", R.string.YourCode); + } + + @Override + public void setParams(Bundle params) { + if (params == null) { + return; + } + codeField.setText(""); + AndroidUtilities.setWaitingForSms(true); + NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceiveSmsCode); + currentParams = params; + waitingForSms = true; + String phone = params.getString("phone"); + requestPhone = params.getString("phoneFormated"); + phoneHash = params.getString("phoneHash"); + registered = params.getString("registered"); + time = params.getInt("calltime"); + + if (phone == null) { + return; + } + + String number = PhoneFormat.getInstance().format(phone); + String str = String.format(Locale.US, LocaleController.getString("SentSmsCode", R.string.SentSmsCode) + " %s", number); + try { + SpannableStringBuilder stringBuilder = new SpannableStringBuilder(str); + TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + int idx = str.indexOf(number); + stringBuilder.setSpan(span, idx, idx + number.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); + confirmTextView.setText(stringBuilder); + } catch (Exception e) { + FileLog.e("tmessages", e); + confirmTextView.setText(str); + } + + AndroidUtilities.showKeyboard(codeField); + codeField.requestFocus(); + + destroyTimer(); + destroyCodeTimer(); + timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 1, 0)); + lastCurrentTime = System.currentTimeMillis(); + problemText.setVisibility(time < 1000 ? VISIBLE : GONE); + + createTimer(); + } + + private void createCodeTimer() { + if (codeTimer != null) { + return; + } + codeTime = 15000; + codeTimer = new Timer(); + lastCodeTime = System.currentTimeMillis(); + codeTimer.schedule(new TimerTask() { + @Override + public void run() { + double currentTime = System.currentTimeMillis(); + double diff = currentTime - lastCodeTime; + codeTime -= diff; + lastCodeTime = currentTime; + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (codeTime <= 1000) { + problemText.setVisibility(VISIBLE); + destroyCodeTimer(); + } + } + }); + } + }, 0, 1000); + } + + private void destroyCodeTimer() { + try { + synchronized(timerSync) { + if (codeTimer != null) { + codeTimer.cancel(); + codeTimer = null; + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + + private void createTimer() { + if (timeTimer != null) { + return; + } + timeTimer = new Timer(); + timeTimer.schedule(new TimerTask() { + @Override + public void run() { + double currentTime = System.currentTimeMillis(); + double diff = currentTime - lastCurrentTime; + time -= diff; + lastCurrentTime = currentTime; + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (time >= 1000) { + int minutes = time / 1000 / 60; + int seconds = time / 1000 - minutes * 60; + timeText.setText(LocaleController.formatString("CallText", R.string.CallText, minutes, seconds)); + } else { + timeText.setText(LocaleController.getString("Calling", R.string.Calling)); + destroyTimer(); + createCodeTimer(); + TLRPC.TL_auth_sendCall req = new TLRPC.TL_auth_sendCall(); + req.phone_number = requestPhone; + req.phone_code_hash = phoneHash; + ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(TLObject response, final TLRPC.TL_error error) { + if (error != null && error.text != null) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + lastError = error.text; + } + }); + } + } + }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin); + } + } + }); + } + }, 0, 1000); + } + + private void destroyTimer() { + try { + synchronized(timerSync) { + if (timeTimer != null) { + timeTimer.cancel(); + timeTimer = null; + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + + @Override + public void onNextPressed() { + if (nextPressed) { + return; + } + nextPressed = true; + waitingForSms = false; + AndroidUtilities.setWaitingForSms(false); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); + final TLRPC.TL_auth_signIn req = new TLRPC.TL_auth_signIn(); + req.phone_number = requestPhone; + req.phone_code = codeField.getText().toString(); + req.phone_code_hash = phoneHash; + destroyTimer(); + needShowProgress(); + 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() { + needHideProgress(); + nextPressed = false; + if (error == null) { + TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response; + destroyTimer(); + destroyCodeTimer(); + UserConfig.clearConfig(); + MessagesController.getInstance().cleanUp(); + UserConfig.setCurrentUser(res.user); + UserConfig.saveConfig(true); + MessagesStorage.getInstance().cleanUp(true); + ArrayList users = new ArrayList(); + users.add(res.user); + MessagesStorage.getInstance().putUsersAndChats(users, null, true, true); + MessagesController.getInstance().putUser(res.user, false); + ContactsController.getInstance().checkAppAccount(); + MessagesController.getInstance().getBlockedUsers(true); + needFinishActivity(); + ConnectionsManager.getInstance().initPushConnection(); + } else { + lastError = error.text; + + if (error.text.contains("PHONE_NUMBER_UNOCCUPIED") && registered == null) { + Bundle params = new Bundle(); + params.putString("phoneFormated", requestPhone); + params.putString("phoneHash", phoneHash); + params.putString("code", req.phone_code); + setPage(2, true, params, false); + destroyTimer(); + destroyCodeTimer(); + } else { + createTimer(); + if (error.text.contains("PHONE_NUMBER_INVALID")) { + needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); + } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { + needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode)); + } else if (error.text.contains("PHONE_CODE_EXPIRED")) { + needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired)); + } else if (error.text.startsWith("FLOOD_WAIT")) { + needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait)); + } else { + needShowAlert(error.text); + } + } + } + } + }); + } + }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin); + } + + @Override + public void onBackPressed() { + destroyTimer(); + destroyCodeTimer(); + currentParams = null; + AndroidUtilities.setWaitingForSms(false); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); + waitingForSms = false; + } + + @Override + public void onDestroyActivity() { + super.onDestroyActivity(); + AndroidUtilities.setWaitingForSms(false); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); + destroyTimer(); + destroyCodeTimer(); + waitingForSms = false; + } + + @Override + public void onShow() { + super.onShow(); + if (codeField != null) { + codeField.requestFocus(); + codeField.setSelection(codeField.length()); + } + } + + @Override + public void didReceivedNotification(int id, final Object... args) { + if (id == NotificationCenter.didReceiveSmsCode) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (!waitingForSms) { + return; + } + if (codeField != null) { + codeField.setText("" + args[0]); + onNextPressed(); + } + } + }); + } + } + + @Override + public void saveStateParams(Bundle bundle) { + String code = codeField.getText().toString(); + if (code != null && code.length() != 0) { + bundle.putString("smsview_code", code); + } + if (currentParams != null) { + bundle.putBundle("smsview_params", currentParams); + } + if (time != 0) { + bundle.putInt("time", time); + } + } + + @Override + public void restoreStateParams(Bundle bundle) { + currentParams = bundle.getBundle("smsview_params"); + if (currentParams != null) { + setParams(currentParams); + } + String code = bundle.getString("smsview_code"); + if (code != null) { + codeField.setText(code); + } + Integer t = bundle.getInt("time"); + if (t != 0) { + time = t; + } + } + } + + public class RegisterView extends SlideView { + + private EditText firstNameField; + private EditText lastNameField; + private String requestPhone; + private String phoneHash; + private String phoneCode; + private Bundle currentParams; + private boolean nextPressed = false; + + public RegisterView(Context context) { + super(context); + + setOrientation(VERTICAL); + + TextView textView = new TextView(context); + textView.setText(LocaleController.getString("RegisterText", R.string.RegisterText)); + textView.setTextColor(0xff757575); + textView.setGravity(Gravity.LEFT); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + addView(textView); + LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.topMargin = AndroidUtilities.dp(8); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + layoutParams.gravity = Gravity.LEFT; + textView.setLayoutParams(layoutParams); + + firstNameField = new EditText(context); + firstNameField.setHintTextColor(0xff979797); + firstNameField.setTextColor(0xff212121); + AndroidUtilities.clearCursorDrawable(firstNameField); + firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName)); + firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); + firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + firstNameField.setMaxLines(1); + firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS); + addView(firstNameField); + layoutParams = (LayoutParams) firstNameField.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = AndroidUtilities.dp(36); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + layoutParams.topMargin = AndroidUtilities.dp(26); + firstNameField.setLayoutParams(layoutParams); + firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { + if (i == EditorInfo.IME_ACTION_NEXT) { + lastNameField.requestFocus(); + return true; + } + return false; + } + }); + + lastNameField = new EditText(context); + lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName)); + lastNameField.setHintTextColor(0xff979797); + lastNameField.setTextColor(0xff212121); + AndroidUtilities.clearCursorDrawable(lastNameField); + lastNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); + lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + lastNameField.setMaxLines(1); + lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS); + addView(lastNameField); + layoutParams = (LayoutParams) lastNameField.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = AndroidUtilities.dp(36); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + layoutParams.topMargin = AndroidUtilities.dp(10); + lastNameField.setLayoutParams(layoutParams); + + LinearLayout linearLayout = new LinearLayout(context); + linearLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL); + addView(linearLayout); + layoutParams = (LayoutParams) linearLayout.getLayoutParams(); + layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutParams.MATCH_PARENT; + linearLayout.setLayoutParams(layoutParams); + + TextView wrongNumber = new TextView(context); + wrongNumber.setText(LocaleController.getString("CancelRegistration", R.string.CancelRegistration)); + wrongNumber.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL); + wrongNumber.setTextColor(0xff548ab6); + wrongNumber.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + wrongNumber.setLineSpacing(AndroidUtilities.dp(2), 1.0f); + wrongNumber.setPadding(0, AndroidUtilities.dp(24), 0, 0); + linearLayout.addView(wrongNumber); + layoutParams = (LayoutParams) wrongNumber.getLayoutParams(); + layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; + layoutParams.bottomMargin = AndroidUtilities.dp(10); + layoutParams.leftMargin = AndroidUtilities.dp(24); + layoutParams.rightMargin = AndroidUtilities.dp(24); + wrongNumber.setLayoutParams(layoutParams); + wrongNumber.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setMessage(LocaleController.getString("AreYouSureRegistration", R.string.AreYouSureRegistration)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + onBackPressed(); + setPage(0, true, null, true); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showAlertDialog(builder); + } + }); + } + + @Override + public void onBackPressed() { + currentParams = null; + } + + @Override + public String getHeaderName() { + return LocaleController.getString("YourName", R.string.YourName); + } + + @Override + public void onShow() { + super.onShow(); + if (firstNameField != null) { + firstNameField.requestFocus(); + firstNameField.setSelection(firstNameField.length()); + } + } + + @Override + public void setParams(Bundle params) { + if (params == null) { + return; + } + firstNameField.setText(""); + lastNameField.setText(""); + requestPhone = params.getString("phoneFormated"); + phoneHash = params.getString("phoneHash"); + phoneCode = params.getString("code"); + currentParams = params; + } + + @Override + public void onNextPressed() { + if (nextPressed) { + return; + } + nextPressed = true; + TLRPC.TL_auth_signUp req = new TLRPC.TL_auth_signUp(); + req.phone_code = phoneCode; + req.phone_code_hash = phoneHash; + req.phone_number = requestPhone; + req.first_name = firstNameField.getText().toString(); + req.last_name = lastNameField.getText().toString(); + needShowProgress(); + 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() { + nextPressed = false; + needHideProgress(); + if (error == null) { + final TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization) response; + TLRPC.TL_userSelf user = (TLRPC.TL_userSelf) res.user; + UserConfig.clearConfig(); + MessagesController.getInstance().cleanUp(); + UserConfig.setCurrentUser(user); + UserConfig.saveConfig(true); + MessagesStorage.getInstance().cleanUp(true); + ArrayList users = new ArrayList(); + users.add(user); + MessagesStorage.getInstance().putUsersAndChats(users, null, true, true); + //MessagesController.getInstance().uploadAndApplyUserAvatar(avatarPhotoBig); + MessagesController.getInstance().putUser(res.user, false); + ContactsController.getInstance().checkAppAccount(); + MessagesController.getInstance().getBlockedUsers(true); + needFinishActivity(); + ConnectionsManager.getInstance().initPushConnection(); + } else { + if (error.text.contains("PHONE_NUMBER_INVALID")) { + needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); + } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { + needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode)); + } else if (error.text.contains("PHONE_CODE_EXPIRED")) { + needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired)); + } else if (error.text.contains("FIRSTNAME_INVALID")) { + needShowAlert(LocaleController.getString("InvalidFirstName", R.string.InvalidFirstName)); + } else if (error.text.contains("LASTNAME_INVALID")) { + needShowAlert(LocaleController.getString("InvalidLastName", R.string.InvalidLastName)); + } else { + needShowAlert(error.text); + } + } + } + }); + } + }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin); + } + + @Override + public void saveStateParams(Bundle bundle) { + String first = firstNameField.getText().toString(); + if (first != null && first.length() != 0) { + bundle.putString("registerview_first", first); + } + String last = lastNameField.getText().toString(); + if (last != null && last.length() != 0) { + bundle.putString("registerview_last", last); + } + if (currentParams != null) { + bundle.putBundle("registerview_params", currentParams); + } + } + + @Override + public void restoreStateParams(Bundle bundle) { + currentParams = bundle.getBundle("registerview_params"); + if (currentParams != null) { + setParams(currentParams); + } + String first = bundle.getString("registerview_first"); + if (first != null) { + firstNameField.setText(first); + } + String last = bundle.getString("registerview_last"); + if (last != null) { + lastNameField.setText(last); + } + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java deleted file mode 100644 index 2c504e4b4..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java +++ /dev/null @@ -1,437 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.3.2. - * 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. - */ - -package org.telegram.ui; - -import android.content.Context; -import android.os.Bundle; -import android.telephony.TelephonyManager; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.view.View; -import android.view.inputmethod.EditorInfo; -import android.widget.AdapterView; -import android.widget.EditText; -import android.widget.TextView; - -import org.telegram.android.AndroidUtilities; -import org.telegram.PhoneFormat.PhoneFormat; -import org.telegram.messenger.BuildVars; -import org.telegram.android.LocaleController; -import org.telegram.messenger.TLObject; -import org.telegram.messenger.TLRPC; -import org.telegram.messenger.ConnectionsManager; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.R; -import org.telegram.messenger.RPCRequest; -import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.Views.SlideView; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Locale; - -public class LoginActivityPhoneView extends SlideView implements AdapterView.OnItemSelectedListener { - private EditText codeField; - private EditText phoneField; - private TextView countryButton; - - private int countryState = 0; - - private ArrayList countriesArray = new ArrayList(); - private HashMap countriesMap = new HashMap(); - private HashMap codesMap = new HashMap(); - private HashMap languageMap = new HashMap(); - - private boolean ignoreSelection = false; - private boolean ignoreOnTextChange = false; - private boolean ignoreOnPhoneChange = false; - private boolean nextPressed = false; - - public LoginActivityPhoneView(Context context) { - super(context); - } - - public LoginActivityPhoneView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LoginActivityPhoneView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - - TextView textView = (TextView)findViewById(R.id.login_confirm_text); - textView.setText(LocaleController.getString("StartText", R.string.StartText)); - - countryButton = (TextView)findViewById(R.id.login_coutry_textview); - countryButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - if (delegate == null) { - return; - } - BaseFragment activity = (BaseFragment)delegate; - CountrySelectActivity fragment = new CountrySelectActivity(); - fragment.setCountrySelectActivityDelegate(new CountrySelectActivity.CountrySelectActivityDelegate() { - @Override - public void didSelectCountry(String name) { - selectCountry(name); - phoneField.requestFocus(); - } - }); - activity.presentFragment(fragment); - } - }); - - codeField = (EditText)findViewById(R.id.login_county_code_field); - codeField.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { - - } - - @Override - public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { - - } - - @Override - public void afterTextChanged(Editable editable) { - if (ignoreOnTextChange) { - ignoreOnTextChange = false; - return; - } - ignoreOnTextChange = true; - String text = PhoneFormat.stripExceptNumbers(codeField.getText().toString()); - codeField.setText(text); - if (text.length() == 0) { - countryButton.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); - countryState = 1; - } else { - String country = codesMap.get(text); - if (country != null) { - int index = countriesArray.indexOf(country); - if (index != -1) { - ignoreSelection = true; - countryButton.setText(countriesArray.get(index)); - - updatePhoneField(); - countryState = 0; - } else { - countryButton.setText(LocaleController.getString("WrongCountry", R.string.WrongCountry)); - countryState = 2; - } - } else { - countryButton.setText(LocaleController.getString("WrongCountry", R.string.WrongCountry)); - countryState = 2; - } - codeField.setSelection(codeField.getText().length()); - } - } - }); - codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { - if (i == EditorInfo.IME_ACTION_NEXT) { - phoneField.requestFocus(); - return true; - } - return false; - } - }); - phoneField = (EditText)findViewById(R.id.login_phone_field); - phoneField.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - if (ignoreOnPhoneChange) { - return; - } - if (count == 1 && after == 0 && s.length() > 1) { - String phoneChars = "0123456789"; - String str = s.toString(); - String substr = str.substring(start, start + 1); - if (!phoneChars.contains(substr)) { - ignoreOnPhoneChange = true; - StringBuilder builder = new StringBuilder(str); - int toDelete = 0; - for (int a = start; a >= 0; a--) { - substr = str.substring(a, a + 1); - if(phoneChars.contains(substr)) { - break; - } - toDelete++; - } - builder.delete(Math.max(0, start - toDelete), start + 1); - str = builder.toString(); - if (PhoneFormat.strip(str).length() == 0) { - phoneField.setText(""); - } else { - phoneField.setText(str); - updatePhoneField(); - } - ignoreOnPhoneChange = false; - } - } - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - - } - - @Override - public void afterTextChanged(Editable s) { - if (ignoreOnPhoneChange) { - return; - } - updatePhoneField(); - } - }); - - if(!isInEditMode()) { - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().getAssets().open("countries.txt"))); - String line; - while ((line = reader.readLine()) != null) { - String[] args = line.split(";"); - countriesArray.add(0, args[2]); - countriesMap.put(args[2], args[0]); - codesMap.put(args[0], args[2]); - languageMap.put(args[1], args[2]); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - - Collections.sort(countriesArray, new Comparator() { - @Override - public int compare(String lhs, String rhs) { - return lhs.compareTo(rhs); - } - }); - - String country = null; - - try { - TelephonyManager telephonyManager = (TelephonyManager)ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE); - if (telephonyManager != null) { - country = telephonyManager.getSimCountryIso().toUpperCase(); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - - if (country != null) { - String countryName = languageMap.get(country); - if (countryName != null) { - int index = countriesArray.indexOf(countryName); - if (index != -1) { - codeField.setText(countriesMap.get(countryName)); - countryState = 0; - } - } - } - if (codeField.length() == 0) { - countryButton.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); - countryState = 1; - } - } - - if (codeField.length() != 0) { - AndroidUtilities.showKeyboard(phoneField); - phoneField.requestFocus(); - } else { - AndroidUtilities.showKeyboard(codeField); - codeField.requestFocus(); - } - phoneField.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { - if (i == EditorInfo.IME_ACTION_NEXT) { - delegate.onNextAction(); - return true; - } - return false; - } - }); - } - - public void selectCountry(String name) { - int index = countriesArray.indexOf(name); - if (index != -1) { - ignoreOnTextChange = true; - codeField.setText(countriesMap.get(name)); - countryButton.setText(name); - countryState = 0; - } - } - - private void updatePhoneField() { - ignoreOnPhoneChange = true; - String codeText = codeField.getText().toString(); - String phone = PhoneFormat.getInstance().format("+" + codeText + phoneField.getText().toString()); - int idx = phone.indexOf(" "); - if (idx != -1) { - String resultCode = PhoneFormat.stripExceptNumbers(phone.substring(0, idx)); - if (!codeText.equals(resultCode)) { - phone = PhoneFormat.getInstance().format(phoneField.getText().toString()).trim(); - phoneField.setText(phone); - int len = phoneField.length(); - phoneField.setSelection(phoneField.length()); - } else { - phoneField.setText(phone.substring(idx).trim()); - int len = phoneField.length(); - phoneField.setSelection(phoneField.length()); - } - } else { - phoneField.setSelection(phoneField.length()); - } - ignoreOnPhoneChange = false; - } - - @Override - public void onItemSelected(AdapterView adapterView, View view, int i, long l) { - if (ignoreSelection) { - ignoreSelection = false; - return; - } - ignoreOnTextChange = true; - String str = countriesArray.get(i); - codeField.setText(countriesMap.get(str)); - updatePhoneField(); - } - - @Override - public void onNothingSelected(AdapterView adapterView) { - - } - - @Override - public void onNextPressed() { - if (nextPressed) { - return; - } - if (countryState == 1) { - delegate.needShowAlert(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); - return; - } else if (countryState == 2) { - delegate.needShowAlert(LocaleController.getString("WrongCountry", R.string.WrongCountry)); - return; - } - if (codeField.length() == 0) { - delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); - return; - } - TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode(); - String phone = PhoneFormat.stripExceptNumbers("" + codeField.getText() + phoneField.getText()); - ConnectionsManager.getInstance().applyCountryPortNumber(phone); - req.api_hash = BuildVars.APP_HASH; - req.api_id = BuildVars.APP_ID; - req.sms_type = 0; - req.phone_number = phone; - req.lang_code = LocaleController.getLocaleString(Locale.getDefault()); - if (req.lang_code == null || req.lang_code.length() == 0) { - req.lang_code = "en"; - } - - final Bundle params = new Bundle(); - params.putString("phone", "+" + codeField.getText() + phoneField.getText()); - params.putString("phoneFormated", phone); - nextPressed = true; - if (delegate != null) { - delegate.needShowProgress(); - } - 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() { - nextPressed = false; - if (error == null) { - final TLRPC.TL_auth_sentCode res = (TLRPC.TL_auth_sentCode)response; - params.putString("phoneHash", res.phone_code_hash); - params.putInt("calltime", res.send_call_timeout * 1000); - if (res.phone_registered) { - params.putString("registered", "true"); - } - if (delegate != null) { - delegate.setPage(1, true, params, false); - } - } else { - if (delegate != null && error.text != null) { - if (error.text.contains("PHONE_NUMBER_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); - } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode)); - } else if (error.text.contains("PHONE_CODE_EXPIRED")) { - delegate.needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired)); - } else if (error.text.startsWith("FLOOD_WAIT")) { - delegate.needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait)); - } else { - delegate.needShowAlert(error.text); - } - } - } - if (delegate != null) { - delegate.needHideProgress(); - } - } - }); - } - }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin | RPCRequest.RPCRequestClassTryDifferentDc | RPCRequest.RPCRequestClassEnableUnauthorized); - } - - @Override - public void onShow() { - super.onShow(); - if (phoneField != null) { - phoneField.requestFocus(); - phoneField.setSelection(phoneField.length()); - } - } - - @Override - public String getHeaderName() { - return LocaleController.getString("YourPhone", R.string.YourPhone); - } - - @Override - public void saveStateParams(Bundle bundle) { - String code = codeField.getText().toString(); - if (code != null && code.length() != 0) { - bundle.putString("phoneview_code", code); - } - String phone = phoneField.getText().toString(); - if (phone != null && phone.length() != 0) { - bundle.putString("phoneview_phone", phone); - } - } - - @Override - public void restoreStateParams(Bundle bundle) { - String code = bundle.getString("phoneview_code"); - if (code != null) { - codeField.setText(code); - } - String phone = bundle.getString("phoneview_phone"); - if (phone != null) { - phoneField.setText(phone); - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java deleted file mode 100644 index fab0b4d07..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.3.2. - * 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. - */ - -package org.telegram.ui; - -import android.content.Context; -import android.os.Bundle; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.view.View; -import android.view.inputmethod.EditorInfo; -import android.widget.EditText; -import android.widget.TextView; - -import org.telegram.android.AndroidUtilities; -import org.telegram.android.LocaleController; -import org.telegram.messenger.TLObject; -import org.telegram.messenger.TLRPC; -import org.telegram.messenger.ConnectionsManager; -import org.telegram.android.ContactsController; -import org.telegram.android.MessagesController; -import org.telegram.android.MessagesStorage; -import org.telegram.messenger.R; -import org.telegram.messenger.RPCRequest; -import org.telegram.messenger.UserConfig; -import org.telegram.ui.Views.SlideView; - -import java.util.ArrayList; - -public class LoginActivityRegisterView extends SlideView { - private EditText firstNameField; - private EditText lastNameField; - private String requestPhone; - private String phoneHash; - private String phoneCode; - private Bundle currentParams; - private boolean nextPressed = false; - - public LoginActivityRegisterView(Context context) { - super(context); - } - - public LoginActivityRegisterView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LoginActivityRegisterView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - - firstNameField = (EditText)findViewById(R.id.login_first_name_field); - firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName)); - lastNameField = (EditText)findViewById(R.id.login_last_name_field); - lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName)); - - TextView textView = (TextView)findViewById(R.id.login_register_info); - textView.setText(LocaleController.getString("RegisterText", R.string.RegisterText)); - - TextView wrongNumber = (TextView) findViewById(R.id.changed_mind); - wrongNumber.setText(LocaleController.getString("CancelRegistration", R.string.CancelRegistration)); - - wrongNumber.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - onBackPressed(); - delegate.setPage(0, true, null, true); - } - }); - - firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { - if (i == EditorInfo.IME_ACTION_NEXT) { - lastNameField.requestFocus(); - return true; - } - return false; - } - }); - - } - - @Override - public void onBackPressed() { - currentParams = null; - } - - @Override - public String getHeaderName() { - return LocaleController.getString("YourName", R.string.YourName); - } - - @Override - public void onShow() { - super.onShow(); - if (firstNameField != null) { - firstNameField.requestFocus(); - firstNameField.setSelection(firstNameField.length()); - } - } - - @Override - public void setParams(Bundle params) { - if (params == null) { - return; - } - firstNameField.setText(""); - lastNameField.setText(""); - requestPhone = params.getString("phoneFormated"); - phoneHash = params.getString("phoneHash"); - phoneCode = params.getString("code"); - currentParams = params; - } - - @Override - public void onNextPressed() { - if (nextPressed) { - return; - } - nextPressed = true; - TLRPC.TL_auth_signUp req = new TLRPC.TL_auth_signUp(); - req.phone_code = phoneCode; - req.phone_code_hash = phoneHash; - req.phone_number = requestPhone; - req.first_name = firstNameField.getText().toString(); - req.last_name = lastNameField.getText().toString(); - if (delegate != null) { - delegate.needShowProgress(); - } - 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() { - nextPressed = false; - if (delegate != null) { - delegate.needHideProgress(); - } - if (error == null) { - final TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization) response; - TLRPC.TL_userSelf user = (TLRPC.TL_userSelf) res.user; - UserConfig.clearConfig(); - MessagesController.getInstance().cleanUp(); - UserConfig.setCurrentUser(user); - UserConfig.saveConfig(true); - MessagesStorage.getInstance().cleanUp(true); - ArrayList users = new ArrayList(); - users.add(user); - MessagesStorage.getInstance().putUsersAndChats(users, null, true, true); - //MessagesController.getInstance().uploadAndApplyUserAvatar(avatarPhotoBig); - MessagesController.getInstance().putUser(res.user, false); - ContactsController.getInstance().checkAppAccount(); - MessagesController.getInstance().getBlockedUsers(true); - if (delegate != null) { - delegate.needFinishActivity(); - } - ConnectionsManager.getInstance().initPushConnection(); - } else { - if (delegate != null) { - if (error.text.contains("PHONE_NUMBER_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); - } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode)); - } else if (error.text.contains("PHONE_CODE_EXPIRED")) { - delegate.needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired)); - } else if (error.text.contains("FIRSTNAME_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidFirstName", R.string.InvalidFirstName)); - } else if (error.text.contains("LASTNAME_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidLastName", R.string.InvalidLastName)); - } else { - delegate.needShowAlert(error.text); - } - } - } - } - }); - } - }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin); - } - - @Override - public void saveStateParams(Bundle bundle) { - String first = firstNameField.getText().toString(); - if (first != null && first.length() != 0) { - bundle.putString("registerview_first", first); - } - String last = lastNameField.getText().toString(); - if (last != null && last.length() != 0) { - bundle.putString("registerview_last", last); - } - if (currentParams != null) { - bundle.putBundle("registerview_params", currentParams); - } - } - - @Override - public void restoreStateParams(Bundle bundle) { - currentParams = bundle.getBundle("registerview_params"); - if (currentParams != null) { - setParams(currentParams); - } - String first = bundle.getString("registerview_first"); - if (first != null) { - firstNameField.setText(first); - } - String last = bundle.getString("registerview_last"); - if (last != null) { - lastNameField.setText(last); - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java deleted file mode 100644 index 9f8eb75b6..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java +++ /dev/null @@ -1,426 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.3.2. - * 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. - */ - -package org.telegram.ui; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.os.Build; -import android.os.Bundle; -import android.text.Html; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.view.View; -import android.view.inputmethod.EditorInfo; -import android.widget.EditText; -import android.widget.TextView; - -import org.telegram.android.AndroidUtilities; -import org.telegram.PhoneFormat.PhoneFormat; -import org.telegram.android.LocaleController; -import org.telegram.messenger.TLObject; -import org.telegram.messenger.TLRPC; -import org.telegram.messenger.ConnectionsManager; -import org.telegram.android.ContactsController; -import org.telegram.messenger.FileLog; -import org.telegram.android.MessagesController; -import org.telegram.android.MessagesStorage; -import org.telegram.android.NotificationCenter; -import org.telegram.messenger.R; -import org.telegram.messenger.RPCRequest; -import org.telegram.messenger.UserConfig; -import org.telegram.ui.Views.SlideView; - -import java.util.ArrayList; -import java.util.Locale; -import java.util.Timer; -import java.util.TimerTask; - -public class LoginActivitySmsView extends SlideView implements NotificationCenter.NotificationCenterDelegate { - private String phoneHash; - private String requestPhone; - private String registered; - private EditText codeField; - private TextView confirmTextView; - private TextView timeText; - private TextView problemText; - private Bundle currentParams; - - private Timer timeTimer; - private Timer codeTimer; - private static final Object timerSync = new Object(); - private volatile int time = 60000; - private volatile int codeTime = 15000; - private double lastCurrentTime; - private double lastCodeTime; - private boolean waitingForSms = false; - private boolean nextPressed = false; - private String lastError = ""; - - public LoginActivitySmsView(Context context) { - super(context); - } - - public LoginActivitySmsView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LoginActivitySmsView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - - confirmTextView = (TextView)findViewById(R.id.login_sms_confirm_text); - codeField = (EditText)findViewById(R.id.login_sms_code_field); - codeField.setHint(LocaleController.getString("Code", R.string.Code)); - timeText = (TextView)findViewById(R.id.login_time_text); - problemText = (TextView)findViewById(R.id.login_problem); - TextView wrongNumber = (TextView) findViewById(R.id.wrong_number); - wrongNumber.setText(LocaleController.getString("WrongNumber", R.string.WrongNumber)); - problemText.setText(LocaleController.getString("DidNotGetTheCode", R.string.DidNotGetTheCode)); - problemText.setVisibility(time < 1000 ? VISIBLE : GONE); - - wrongNumber.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - onBackPressed(); - delegate.setPage(0, true, null, true); - } - }); - - problemText.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - try { - PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); - String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode); - - Intent mailer = new Intent(Intent.ACTION_SEND); - mailer.setType("message/rfc822"); - mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@telegram.org"}); - mailer.putExtra(Intent.EXTRA_SUBJECT, "Android registration/login issue " + version + " " + requestPhone); - mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError); - getContext().startActivity(Intent.createChooser(mailer, "Send email...")); - } catch (Exception e) { - if (delegate != null) { - delegate.needShowAlert(LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled)); - } - } - } - }); - - codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { - if (i == EditorInfo.IME_ACTION_NEXT) { - if (delegate != null) { - delegate.onNextAction(); - } - return true; - } - return false; - } - }); - } - - @Override - public String getHeaderName() { - return LocaleController.getString("YourCode", R.string.YourCode); - } - - @Override - public void setParams(Bundle params) { - if (params == null) { - return; - } - codeField.setText(""); - AndroidUtilities.setWaitingForSms(true); - NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceiveSmsCode); - currentParams = params; - waitingForSms = true; - String phone = params.getString("phone"); - requestPhone = params.getString("phoneFormated"); - phoneHash = params.getString("phoneHash"); - registered = params.getString("registered"); - time = params.getInt("calltime"); - - if (phone == null) { - return; - } - - String number = PhoneFormat.getInstance().format(phone); - confirmTextView.setText(Html.fromHtml(String.format(LocaleController.getString("SentSmsCode", R.string.SentSmsCode) + " %s", number))); - - AndroidUtilities.showKeyboard(codeField); - codeField.requestFocus(); - - destroyTimer(); - destroyCodeTimer(); - timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 1, 0)); - lastCurrentTime = System.currentTimeMillis(); - problemText.setVisibility(time < 1000 ? VISIBLE : GONE); - - createTimer(); - } - - private void createCodeTimer() { - if (codeTimer != null) { - return; - } - codeTime = 15000; - codeTimer = new Timer(); - lastCodeTime = System.currentTimeMillis(); - codeTimer.schedule(new TimerTask() { - @Override - public void run() { - double currentTime = System.currentTimeMillis(); - double diff = currentTime - lastCodeTime; - codeTime -= diff; - lastCodeTime = currentTime; - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (codeTime <= 1000) { - problemText.setVisibility(VISIBLE); - destroyCodeTimer(); - } - } - }); - } - }, 0, 1000); - } - - private void destroyCodeTimer() { - try { - synchronized(timerSync) { - if (codeTimer != null) { - codeTimer.cancel(); - codeTimer = null; - } - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - - private void createTimer() { - if (timeTimer != null) { - return; - } - timeTimer = new Timer(); - timeTimer.schedule(new TimerTask() { - @Override - public void run() { - double currentTime = System.currentTimeMillis(); - double diff = currentTime - lastCurrentTime; - time -= diff; - lastCurrentTime = currentTime; - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (time >= 1000) { - int minutes = time / 1000 / 60; - int seconds = time / 1000 - minutes * 60; - timeText.setText(LocaleController.formatString("CallText", R.string.CallText, minutes, seconds)); - } else { - timeText.setText(LocaleController.getString("Calling", R.string.Calling)); - destroyTimer(); - createCodeTimer(); - TLRPC.TL_auth_sendCall req = new TLRPC.TL_auth_sendCall(); - req.phone_number = requestPhone; - req.phone_code_hash = phoneHash; - ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { - @Override - public void run(TLObject response, final TLRPC.TL_error error) { - if (error != null && error.text != null) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - lastError = error.text; - } - }); - } - } - }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin); - } - } - }); - } - }, 0, 1000); - } - - private void destroyTimer() { - try { - synchronized(timerSync) { - if (timeTimer != null) { - timeTimer.cancel(); - timeTimer = null; - } - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - - @Override - public void onNextPressed() { - if (nextPressed) { - return; - } - nextPressed = true; - waitingForSms = false; - AndroidUtilities.setWaitingForSms(false); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); - final TLRPC.TL_auth_signIn req = new TLRPC.TL_auth_signIn(); - req.phone_number = requestPhone; - req.phone_code = codeField.getText().toString(); - req.phone_code_hash = phoneHash; - destroyTimer(); - if (delegate != null) { - delegate.needShowProgress(); - } - 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 (delegate == null) { - return; - } - delegate.needHideProgress(); - nextPressed = false; - if (error == null) { - TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response; - destroyTimer(); - destroyCodeTimer(); - UserConfig.clearConfig(); - MessagesController.getInstance().cleanUp(); - UserConfig.setCurrentUser(res.user); - UserConfig.saveConfig(true); - MessagesStorage.getInstance().cleanUp(true); - ArrayList users = new ArrayList(); - users.add(res.user); - MessagesStorage.getInstance().putUsersAndChats(users, null, true, true); - MessagesController.getInstance().putUser(res.user, false); - ContactsController.getInstance().checkAppAccount(); - MessagesController.getInstance().getBlockedUsers(true); - delegate.needFinishActivity(); - ConnectionsManager.getInstance().initPushConnection(); - } else { - lastError = error.text; - if (error.text.contains("PHONE_NUMBER_UNOCCUPIED") && registered == null) { - Bundle params = new Bundle(); - params.putString("phoneFormated", requestPhone); - params.putString("phoneHash", phoneHash); - params.putString("code", req.phone_code); - delegate.setPage(2, true, params, false); - destroyTimer(); - destroyCodeTimer(); - } else { - createTimer(); - if (error.text.contains("PHONE_NUMBER_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); - } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { - delegate.needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode)); - } else if (error.text.contains("PHONE_CODE_EXPIRED")) { - delegate.needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired)); - } else if (error.text.startsWith("FLOOD_WAIT")) { - delegate.needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait)); - } else { - delegate.needShowAlert(error.text); - } - } - } - } - }); - } - }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin); - } - - @Override - public void onBackPressed() { - destroyTimer(); - destroyCodeTimer(); - currentParams = null; - AndroidUtilities.setWaitingForSms(false); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); - waitingForSms = false; - } - - @Override - public void onDestroyActivity() { - super.onDestroyActivity(); - AndroidUtilities.setWaitingForSms(false); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); - destroyTimer(); - destroyCodeTimer(); - waitingForSms = false; - } - - @Override - public void onShow() { - super.onShow(); - if (codeField != null) { - codeField.requestFocus(); - codeField.setSelection(codeField.length()); - } - } - - @Override - public void didReceivedNotification(int id, final Object... args) { - if (id == NotificationCenter.didReceiveSmsCode) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (!waitingForSms) { - return; - } - if (codeField != null) { - codeField.setText("" + args[0]); - onNextPressed(); - } - } - }); - } - } - - @Override - public void saveStateParams(Bundle bundle) { - String code = codeField.getText().toString(); - if (code != null && code.length() != 0) { - bundle.putString("smsview_code", code); - } - if (currentParams != null) { - bundle.putBundle("smsview_params", currentParams); - } - if (time != 0) { - bundle.putInt("time", time); - } - } - - @Override - public void restoreStateParams(Bundle bundle) { - currentParams = bundle.getBundle("smsview_params"); - if (currentParams != null) { - setParams(currentParams); - } - String code = bundle.getString("smsview_code"); - if (code != null) { - codeField.setText(code); - } - Integer t = bundle.getInt("time"); - if (t != 0) { - time = t; - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java index 96536d39a..9d503d07a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java @@ -149,9 +149,16 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter searching = false; searchWas = false; if (messagesListView != null) { - messagesListView.setEmptyView(emptyView); - searchEmptyView.setVisibility(View.GONE); - progressView.setVisibility(View.GONE); + if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) { + searchEmptyView.setVisibility(View.GONE); + emptyView.setVisibility(View.GONE); + progressView.setVisibility(View.VISIBLE); + messagesListView.setEmptyView(progressView); + } else { + messagesListView.setEmptyView(emptyView); + searchEmptyView.setVisibility(View.GONE); + progressView.setVisibility(View.GONE); + } if (!onlySelect) { floatingButton.setVisibility(View.VISIBLE); floatingHidden = true; @@ -274,15 +281,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) { searchEmptyView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); + progressView.setVisibility(View.VISIBLE); messagesListView.setEmptyView(progressView); } else { - if (searching && searchWas) { - messagesListView.setEmptyView(searchEmptyView); - emptyView.setVisibility(View.GONE); - } else { - messagesListView.setEmptyView(emptyView); - searchEmptyView.setVisibility(View.GONE); - } + messagesListView.setEmptyView(emptyView); + searchEmptyView.setVisibility(View.GONE); progressView.setVisibility(View.GONE); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java index 6fcad48ac..8d5ea20b2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java @@ -353,7 +353,7 @@ public class PhotoCropActivity extends BaseFragment { }); ActionBarMenu menu = actionBar.createMenu(); - menu.addItem(done_button, R.drawable.ic_done); + menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); fragmentView = view = new PhotoCropView(getParentActivity()); fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java new file mode 100644 index 000000000..19deb7507 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java @@ -0,0 +1,14 @@ +/* + * 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 org.telegram.ui.ActionBar.BaseFragment; + +public class PrivacySettingsActivity extends BaseFragment { +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java index 35a5cd43b..c96a0f59d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java @@ -254,10 +254,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur }); ActionBarMenu menu = actionBar.createMenu(); - View doneItem = menu.addItemResource(1, R.layout.group_create_done_layout); - - TextView doneTextView = (TextView) doneItem.findViewById(R.id.done_button); - doneTextView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase()); + menu.addItem(1, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); fragmentView = inflater.inflate(R.layout.video_editor_layout, container, false); originalSizeTextView = (TextView) fragmentView.findViewById(R.id.original_size); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java index 6f4a76d2b..6abea8e89 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java @@ -35,6 +35,7 @@ public class AvatarDrawable extends Drawable { R.drawable.bar_selector_green, R.drawable.bar_selector_cyan, R.drawable.bar_selector_blue, R.drawable.bar_selector_violet, R.drawable.bar_selector_pink}; private static Drawable broadcastDrawable; + private static Drawable photoDrawable; private int color; private StaticLayout textLayout; @@ -42,6 +43,7 @@ public class AvatarDrawable extends Drawable { private float textHeight; private boolean isProfile; private boolean drawBrodcast; + private boolean drawPhoto; public AvatarDrawable() { super(); @@ -147,6 +149,13 @@ public class AvatarDrawable extends Drawable { } } + public void setDrawPhoto(boolean value) { + if (value && photoDrawable == null) { + photoDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_w); + } + drawPhoto = value; + } + @Override public void draw(Canvas canvas) { Rect bounds = getBounds(); @@ -168,6 +177,11 @@ public class AvatarDrawable extends Drawable { if (textLayout != null) { canvas.translate((size - textWidth) / 2, (size - textHeight) / 2); textLayout.draw(canvas); + } else if (drawPhoto && photoDrawable != null) { + int x = (size - photoDrawable.getIntrinsicWidth()) / 2; + int y = (size - photoDrawable.getIntrinsicHeight()) / 2; + photoDrawable.setBounds(x, y, x + photoDrawable.getIntrinsicWidth(), y + photoDrawable.getIntrinsicHeight()); + photoDrawable.draw(canvas); } } canvas.restore(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java index 5c174a2ad..1652118ad 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java @@ -26,6 +26,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.Surface; import android.view.View; +import android.view.ViewGroup; import android.view.WindowManager; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.inputmethod.EditorInfo; @@ -49,6 +50,8 @@ import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.ui.ApplicationLoader; +import java.util.ArrayList; + public class ChatActivityEnterView implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate { public static interface ChatActivityEnterViewDelegate { @@ -65,24 +68,25 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen private ImageButton audioSendButton; private View recordPanel; private View slideText; - private PowerManager.WakeLock mWakeLock = null; + private PowerManager.WakeLock mWakeLock; private SizeNotifierRelativeLayout sizeNotifierRelativeLayout; - private Object runningAnimation = null; - private int runningAnimationType = 0; + private FrameLayout attachButton; + private Object runningAnimation; + private int runningAnimationType; - private int keyboardHeight = 0; - private int keyboardHeightLand = 0; + private int keyboardHeight; + private int keyboardHeightLand; private boolean keyboardVisible; - private boolean sendByEnter = false; - private long lastTypingTimeSend = 0; - private String lastTimeString = null; + private boolean sendByEnter; + private long lastTypingTimeSend; + private String lastTimeString; private float startedDraggingX = -1; private float distCanMove = AndroidUtilities.dp(80); - private boolean recordingAudio = false; + private boolean recordingAudio; private Activity parentActivity; private long dialog_id; - private boolean ignoreTextChange = false; + private boolean ignoreTextChange; private ChatActivityEnterViewDelegate delegate; public ChatActivityEnterView() { @@ -123,20 +127,22 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen public void setContainerView(Activity activity, View containerView) { parentActivity = activity; - sizeNotifierRelativeLayout = (SizeNotifierRelativeLayout)containerView.findViewById(R.id.chat_layout); + sizeNotifierRelativeLayout = (SizeNotifierRelativeLayout) containerView.findViewById(R.id.chat_layout); sizeNotifierRelativeLayout.delegate = this; - messsageEditText = (EditText)containerView.findViewById(R.id.chat_text_edit); + messsageEditText = (EditText) containerView.findViewById(R.id.chat_text_edit); messsageEditText.setHint(LocaleController.getString("TypeMessage", R.string.TypeMessage)); - sendButton = (ImageButton)containerView.findViewById(R.id.chat_send_button); + attachButton = (FrameLayout) containerView.findViewById(R.id.chat_attach_button); + + sendButton = (ImageButton) containerView.findViewById(R.id.chat_send_button); sendButton.setVisibility(View.INVISIBLE); - emojiButton = (ImageView)containerView.findViewById(R.id.chat_smile_button); - audioSendButton = (ImageButton)containerView.findViewById(R.id.chat_audio_send_button); + emojiButton = (ImageView) containerView.findViewById(R.id.chat_smile_button); + audioSendButton = (ImageButton) containerView.findViewById(R.id.chat_audio_send_button); recordPanel = containerView.findViewById(R.id.record_panel); - recordTimeText = (TextView)containerView.findViewById(R.id.recording_time_text); + recordTimeText = (TextView) containerView.findViewById(R.id.recording_time_text); slideText = containerView.findViewById(R.id.slideText); - TextView textView = (TextView)containerView.findViewById(R.id.slideToCancelTextView); + TextView textView = (TextView) containerView.findViewById(R.id.slideToCancelTextView); textView.setText(LocaleController.getString("SlideToCancel", R.string.SlideToCancel)); emojiButton.setOnClickListener(new View.OnClickListener() { @@ -218,12 +224,12 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen recordingAudio = false; updateAudioRecordIntefrace(); } - if(android.os.Build.VERSION.SDK_INT > 13) { + if (android.os.Build.VERSION.SDK_INT > 13) { x = x + audioSendButton.getX(); - FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)slideText.getLayoutParams(); + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); if (startedDraggingX != -1) { float dist = (x - startedDraggingX); - params.leftMargin = AndroidUtilities.dp(30) + (int)dist; + params.leftMargin = AndroidUtilities.dp(30) + (int) dist; slideText.setLayoutParams(params); float alpha = 1.0f + dist / distCanMove; if (alpha > 1) { @@ -271,8 +277,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen if (message.length() != 0 && lastTypingTimeSend < System.currentTimeMillis() - 5000 && !ignoreTextChange) { int currentTime = ConnectionsManager.getInstance().getCurrentTime(); TLRPC.User currentUser = null; - if ((int)dialog_id > 0) { - currentUser = MessagesController.getInstance().getUser((int)dialog_id); + if ((int) dialog_id > 0) { + currentUser = MessagesController.getInstance().getUser((int) dialog_id); } if (currentUser != null && currentUser.status != null && currentUser.status.expires < currentTime) { return; @@ -319,7 +325,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen public boolean processSendingText(String text) { text = getTrimmedString(text); if (text.length() != 0) { - int count = (int)Math.ceil(text.length() / 4096.0f); + int count = (int) Math.ceil(text.length() / 4096.0f); for (int a = 0; a < count; a++) { String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length())); SendMessagesHelper.getInstance().sendMessage(mess, dialog_id); @@ -352,7 +358,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen return; } if (runningAnimation != null) { - ((AnimatorSet)runningAnimation).cancel(); + ((AnimatorSet) runningAnimation).cancel(); runningAnimation = null; } @@ -360,14 +366,23 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen AnimatorSet animatorSet = new AnimatorSet(); runningAnimation = animatorSet; runningAnimationType = 1; - animatorSet.playTogether( - ObjectAnimator.ofFloat(audioSendButton, "scaleX", 0.1f), - ObjectAnimator.ofFloat(audioSendButton, "scaleY", 0.1f), - ObjectAnimator.ofFloat(audioSendButton, "alpha", 0.0f), - ObjectAnimator.ofFloat(sendButton, "scaleX", 1.0f), - ObjectAnimator.ofFloat(sendButton, "scaleY", 1.0f), - ObjectAnimator.ofFloat(sendButton, "alpha", 1.0f) - ); + + ArrayList animators = new ArrayList(); + animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleX", 0.1f)); + animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleY", 0.1f)); + animators.add(ObjectAnimator.ofFloat(audioSendButton, "alpha", 0.0f)); + animators.add(ObjectAnimator.ofFloat(sendButton, "scaleX", 1.0f)); + animators.add(ObjectAnimator.ofFloat(sendButton, "scaleY", 1.0f)); + animators.add(ObjectAnimator.ofFloat(sendButton, "alpha", 1.0f)); + if (attachButton != null) { + animators.add(ObjectAnimator.ofFloat(attachButton, "alpha", 0.0f)); + animators.add(ObjectAnimator.ofFloat(attachButton, "translationX", AndroidUtilities.dp(48))); + + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams(); + layoutParams.rightMargin = AndroidUtilities.dp(6); + messsageEditText.setLayoutParams(layoutParams); + } + animatorSet.playTogether(animators); animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapter() { @@ -393,6 +408,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen } sendButton.setVisibility(View.VISIBLE); audioSendButton.setVisibility(View.INVISIBLE); + if (attachButton != null) { + attachButton.setVisibility(View.GONE); + } } } } else if (sendButton.getVisibility() == View.VISIBLE) { @@ -402,7 +420,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen } if (runningAnimation != null) { - ((AnimatorSet)runningAnimation).cancel(); + ((AnimatorSet) runningAnimation).cancel(); runningAnimation = null; } @@ -410,14 +428,23 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen AnimatorSet animatorSet = new AnimatorSet(); runningAnimation = animatorSet; runningAnimationType = 2; - animatorSet.playTogether( - ObjectAnimator.ofFloat(sendButton, "scaleX", 0.1f), - ObjectAnimator.ofFloat(sendButton, "scaleY", 0.1f), - ObjectAnimator.ofFloat(sendButton, "alpha", 0.0f), - ObjectAnimator.ofFloat(audioSendButton, "scaleX", 1.0f), - ObjectAnimator.ofFloat(audioSendButton, "scaleY", 1.0f), - ObjectAnimator.ofFloat(audioSendButton, "alpha", 1.0f) - ); + + ArrayList animators = new ArrayList(); + animators.add(ObjectAnimator.ofFloat(sendButton, "scaleX", 0.1f)); + animators.add(ObjectAnimator.ofFloat(sendButton, "scaleY", 0.1f)); + animators.add(ObjectAnimator.ofFloat(sendButton, "alpha", 0.0f)); + animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleX", 1.0f)); + animators.add(ObjectAnimator.ofFloat(audioSendButton, "scaleY", 1.0f)); + animators.add(ObjectAnimator.ofFloat(audioSendButton, "alpha", 1.0f)); + if (attachButton != null) { + animators.add(ObjectAnimator.ofFloat(attachButton, "alpha", 1.0f)); + animators.add(ObjectAnimator.ofFloat(attachButton, "translationX", 0.0f)); + + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams(); + layoutParams.rightMargin = AndroidUtilities.dp(54); + messsageEditText.setLayoutParams(layoutParams); + } + animatorSet.playTogether(animators); animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapter() { @@ -443,6 +470,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen } sendButton.setVisibility(View.INVISIBLE); audioSendButton.setVisibility(View.VISIBLE); + if (attachButton != null) { + attachButton.setVisibility(View.VISIBLE); + } } } } @@ -463,8 +493,8 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen recordPanel.setVisibility(View.VISIBLE); recordTimeText.setText("00:00"); lastTimeString = null; - if(android.os.Build.VERSION.SDK_INT > 13) { - FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)slideText.getLayoutParams(); + if (android.os.Build.VERSION.SDK_INT > 13) { + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); params.leftMargin = AndroidUtilities.dp(30); slideText.setLayoutParams(params); slideText.setAlpha(1); @@ -498,7 +528,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen } } AndroidUtilities.unlockOrientation(parentActivity); - if(android.os.Build.VERSION.SDK_INT > 13) { + if (android.os.Build.VERSION.SDK_INT > 13) { recordPanel.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { @@ -507,7 +537,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen @Override public void onAnimationEnd(Animator animator) { - FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)slideText.getLayoutParams(); + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); params.leftMargin = AndroidUtilities.dp(30); slideText.setLayoutParams(params); slideText.setAlpha(1); @@ -670,6 +700,22 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen return emojiPopup != null && emojiPopup.isShowing(); } + public void addToAttachLayout(View view) { + if (attachButton == null) { + return; + } + if (view.getParent() != null) { + ViewGroup viewGroup = (ViewGroup) view.getParent(); + viewGroup.removeView(view); + } + attachButton.addView(view); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); + layoutParams.gravity = Gravity.CENTER; + layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + view.setLayoutParams(layoutParams); + } + @Override public void onSizeChanged(int height) { Rect localRect = new Rect(); @@ -698,7 +744,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen } else { newHeight = keyboardHeight; } - final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams)emojiPopup.getContentView().getLayoutParams(); + final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) emojiPopup.getContentView().getLayoutParams(); if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) { WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); layoutParams.width = AndroidUtilities.displaySize.x; @@ -734,7 +780,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen emojiView.invalidateViews(); } } else if (id == NotificationCenter.recordProgressChanged) { - Long time = (Long)args[0] / 1000; + Long time = (Long) args[0] / 1000; String str = String.format("%02d:%02d", time / 60, time % 60); if (lastTimeString == null || !lastTimeString.equals(str)) { if (recordTimeText != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java new file mode 100644 index 000000000..c407daac5 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/CheckBox.java @@ -0,0 +1,58 @@ +/* + * 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.Views; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.drawable.Drawable; +import android.widget.CompoundButton; + +import org.telegram.messenger.R; + +public class CheckBox extends CompoundButton { + + private Paint paint; + private Drawable checkDrawable; + + public CheckBox(Context context) { + super(context); + + paint = new Paint(Paint.ANTI_ALIAS_FLAG); + paint.setColor(0xff5ec245); + + checkDrawable = context.getResources().getDrawable(R.drawable.round_check2); + } + + @Override + public void setChecked(boolean checked) { + super.setChecked(checked); + + checked = isChecked(); + invalidate(); + + /*if (attachedToWindow && wasLayout) { + animateThumbToCheckedState(checked); + } else { + cancelPositionAnimator(); + setThumbPosition(checked ? 1 : 0); + }*/ + } + + @Override + protected void onDraw(Canvas canvas) { + if (isChecked()) { + canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, getMeasuredWidth() / 2, paint); + int x = (getMeasuredWidth() - checkDrawable.getIntrinsicWidth()) / 2; + int y = (getMeasuredHeight() - checkDrawable.getIntrinsicHeight()) / 2; + checkDrawable.setBounds(x, y, x + checkDrawable.getIntrinsicWidth(), y + checkDrawable.getIntrinsicHeight()); + checkDrawable.draw(canvas); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/SlideView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/SlideView.java deleted file mode 100644 index 3462651ed..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/SlideView.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.3.2. - * 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. - */ - -package org.telegram.ui.Views; - -import android.content.Context; -import android.os.Bundle; -import android.util.AttributeSet; -import android.widget.LinearLayout; - -public class SlideView extends LinearLayout { - public static interface SlideViewDelegate { - public abstract void onNextAction(); - public abstract void needShowAlert(String text); - public abstract void needShowProgress(); - public abstract void needHideProgress(); - public abstract void setPage(int page, boolean animated, Bundle params, boolean back); - public abstract void needFinishActivity(); - } - - public SlideView(Context context) { - super(context); - } - - public SlideView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public SlideView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public SlideViewDelegate delegate; - - public String getHeaderName() { - return ""; - } - - public void onNextPressed() { - - } - - public void setParams(Bundle params) { - - } - - public void onBackPressed() { - - } - - public void onShow() { - - } - - public void onDestroyActivity() { - delegate = null; - } - - public void saveStateParams(Bundle bundle) { - - } - - public void restoreStateParams(Bundle bundle) { - - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java index eae6cd107..b3cfd5f33 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java @@ -155,7 +155,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent }); ActionBarMenu menu = actionBar.createMenu(); - doneButton = menu.addItem(done_button, R.drawable.ic_done); + doneButton = menu.addItem(done_button, R.drawable.ic_done, 0, AndroidUtilities.dp(56)); fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false); listAdapter = new ListAdapter(getParentActivity()); diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photo_w.png b/TMessagesProj/src/main/res/drawable-hdpi/photo_w.png new file mode 100755 index 0000000000000000000000000000000000000000..2aae32939feb7d2aa0e13b1e883837ff8009c91f GIT binary patch literal 1376 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBBuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFe_z-M3hAM`dB6B=jtVb)aX^@765fKFxc2v6eK2Rr0UTq__OB&@Hb09I0xZL0)vRD^GUf^&XRs)DJWv2L<~p`n7AnVzAE zshOFfj)IYap^?4;5Si&3npl~dSs9rtK!Fm_wxX0Ys~{IQs9ivwtx`rwNr9EVetCJh zUb(Seeo?xx^|#0uTKVr7^KE~&-IMVSR9nfZANAQKal@=Hr> zm4GgVcpgi&u1T;Y}Gc(1?(Ztxo)YZ($%-O)%(9qSy!ot+i)zQGx+0?+< z%-Pfwrq?AuximL5uLPzy1)2BVcf4LpK7qA`CKQY7g zc2n8`)e~7q(lpC%z2GxiY3kXKotP(Tu(DeIYlF>39;-w9_FmfisIKXhQjK;oZ{MYM zs|2$rhh8;VmM`S$TIFrE&RFii`rS;W7nYy8#dOj>KJcVsY<82-42b~EPd5}R40p^+ z4|;vWHsY$r!_$8_5r z-n!%>5A)2_Ra;lSy!v9}>8x8OCnZZyx4mQaUAt*J$B~l1Qjc9(n$G=|O13$2UZJvI p_^a^=$-lo1g-nD}Zq~6#Fnpc;y6K{_L^{M~> literal 0 HcmV?d00001 diff --git a/TMessagesProj/src/main/res/drawable-hdpi/round_check2.png b/TMessagesProj/src/main/res/drawable-hdpi/round_check2.png new file mode 100755 index 0000000000000000000000000000000000000000..f00b4ffd27e807f6ab0c3d3c064bd6508abce3fb GIT binary patch literal 1048 zcmaJ=Pe>F|9G)o6ge~-vb;x0i$Z%(NX8*B+>$dKwyWyCuOKy13aptL$&b)Ev>COs4 zNl2oXK%pYM6cIsDkq7ILW(ak(C`tmMh=M?mQ3SnN-L*s8Ff;GHAK&-={=UifwiZ|U z;c|i?T#2}l#A_A)D$7doKl=U199|BgrZnn+eJCTDfQTxv7mx`}>IX?6DcRwdpq?Oh zQ)()W(qbzwLyeXk3~g%$W)nnx#5N>(5FoM_^s9Q9+IaemB2^_!b^1k*XvDyP8Xq%3 z$5>lR9vhTH3KeM}>unwjXaGs1tqtiGZ-=RzE|2$)nW4xW1Pz9%t)S9kI~ju}ApNx0 zEqhp&3G}6Cxzy1U-%TJ1`slMhRI|y zbjC|Vv!7u@p^&4&ac+!oTUi}Rwp+Jq@(Kd5WK%Ve3U$&^lzQO^3R5`JtrRq)Agf#3 zWx@qxY{_6)+T)~@2a4kVp_*1eTPO*3;{B(vmC71`NdgOwm@;l$Uyb9+;A19`5HwQ| z4&|%ZJ^&H42B1O4Is)YJPE}W6#;VQXMUhYF7Ls%sB!n=96=+pec+TTtz0pQC(CCY? zY?CkK_i|Ce%QXhEDHi1NTmi}>8qiUmtL$*OqFiSbGy{7UfT@lGrP+iUnM;{hi^dXd zE~>Z9Rf@;rDavJVFpSgKzZ#u4;puU-b7cCxmFq{_uEq z&9z9D5mO&ex12jT{Ahp7KR@}fr{c<`>gr5I_l3)AuZ)Sh__xTtY)R?9+M0&pH|O7O z2FGU?D>l=&UXOSGm_E7ZUHJ>6ZGB%iKaH;eq+!0AAS>9 Au>b%7 literal 0 HcmV?d00001 diff --git a/TMessagesProj/src/main/res/drawable-hdpi/shadow.png b/TMessagesProj/src/main/res/drawable-hdpi/shadow.png deleted file mode 100755 index 30e6eec6ac020be81a57ad067f7c2be4697260b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 131 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i=adb&7C3<00004XF*Lt006JZ zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUyjYo$SColCLmmlD1?I% zht$?ghFnuSSZ^WJAf*^pNGV1Y@|dhv2QRBb9P-s`)5lxO3+iTiCU=3~kUOSp4CqzN l+cVb(E}002ovPDHLkV1mr-hf@Fm diff --git a/TMessagesProj/src/main/res/drawable-hdpi/spinner_pressed.9.png b/TMessagesProj/src/main/res/drawable-hdpi/spinner_pressed.9.png deleted file mode 100755 index dccf010ae965b41df21303acb42893ac8f780f77..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^%0O(y!3HF+1t+BgDVB6cUq=Rp^(V|(yIunMk|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XZh5*mhE&{obF-1FSwVp9!RHT} zW^S)dZ+-jczv;O_ESvQ0Ltn0N|7&h;I-|eE`O1Z|9ow^=rzXFB;4=4c{nyJoTv>Pw z+K)tR{zA{asknltR<5Wv^vM0~H|OrEXRQ!RU})8G WnDhPZJ8z&b89ZJ6T-G@yGywqe;(e(A diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photo_w.png b/TMessagesProj/src/main/res/drawable-mdpi/photo_w.png new file mode 100755 index 0000000000000000000000000000000000000000..0f44275cd172d28b2bb14991e6e1b697473ad0d7 GIT binary patch literal 1177 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxSU1_g&``n5OwZ87 z)XdCKN5ROz&`93^h|F{iO{`4Ktc=VRpg;*|TTx1yRgjAt)Gi>;Rw<*Tq`*pFzr4I$ zuiRKKzbIYb(9+TpWQLKEE>MMTab;dfVufyAu`f(~1RD^r68eAMwS&*t9 zlvv ztM~P_^2{qPNz6-5^>ndS0-B(gnVDkcWawyYU~J}W=4{|>Xy|I<=;&nXW@Kq@Xk=<& zVPv4~Pj*wm=R%;iu*SQ+p9GSsQ-Ha$#U#&L$N80AM0gyOj(c@An@?u$^Rdl>mBAaoaagLQxMqy$KSGo^~gVi zV#$e0KUD>~12td7Gj6o#Xv|^UI$2m*b7h9Ez-=Z&b&=bQAFCFXC>>?g3t*Yb{xgiZ z{?{BhBwAi>b?uInKte^j@HOySaHU71*+ lbw^rxk)PZhF$NY1hD928mq&iuIule_c)I$ztaD0e0st1DfY<;4 literal 0 HcmV?d00001 diff --git a/TMessagesProj/src/main/res/drawable-mdpi/round_check2.png b/TMessagesProj/src/main/res/drawable-mdpi/round_check2.png new file mode 100755 index 0000000000000000000000000000000000000000..6ff1a82afcb92cf01875c451a204791dd3040c81 GIT binary patch literal 1136 zcmeAS@N?(olHy`uVBq!ia0vp^qChOb!3HFM-ZD`IQj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS=07?_nZLn2Bde0{8v^Kf6`()~Xj@TAnpKdC8`Lf!&sHg;q@=(~U%$M( zT(8_%FTW^V-_X+15@d#vkuFe$ZgFK^Nn(X=Ua>OF1ees}+T7#d8#0MoBXEYLU9GXQxBrqI_HztY@Xxa#7Ppj3o=u^L<)Qdy9y zACy|0Us{w5jJPyqkW~d%&PAz-CHX}m`T04pPz=b(FUc>?$S+WE4mMNJ2+zz*$uBR~ z1grP;werj>E=kNwPW5!LRRWrzmzkMjWn|)H>gMQdYUX6(Y-s3e;%H)QWZ`7)Y+_*m z6t=L0>2=9ZF3nBND}m`vLFhHZsTY(KatnYqyQCInmZhe+73JqDfW2&$iQ6s4IL(9V zO~LIJ6P$YWfsWA!MJ!T8!-RmT2gHOYTObFX@Kf`Esl5o8tcz5hM+39O6Hgb%kcwML zfByfsXWq)FEXuQ$JxNUA9=AB7q!;5h#z*=Ne?&XpCO+~J*>QoZV>_dvxj-@FM((A0 zrtFXS{|hb*T-G@yGywpe32(Uo literal 0 HcmV?d00001 diff --git a/TMessagesProj/src/main/res/drawable-mdpi/shadow.png b/TMessagesProj/src/main/res/drawable-mdpi/shadow.png deleted file mode 100755 index cbdc938e2b5e236ef0824f6bd085e81bdede96db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 131 zcmeAS@N?(olHy`uVBq!ia0vp^Od!m`1|*BN@u~nRmUKs7M+S!VC(K#9UIO`&C9V-A z!TD(=<%vb942~)JNvR5+xryniL8*x;m4zo$ZGehIJzX3_DsCmEBqRthC9$coX)tgY ZFfbZ1h?_hA2$F1 diff --git a/TMessagesProj/src/main/res/drawable-mdpi/spinner.9.png b/TMessagesProj/src/main/res/drawable-mdpi/spinner.9.png deleted file mode 100755 index 2d3ce5e748d48a2da21cdc12d084de28d4aeb022..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^5X$@$gtufgCS5V`T)f(Rrr4HaM_OZ!GWk1;hPCiz_@@3n%#eNX;YyYZZFhKP zH6C-noV_;b!HF*sE7D4vt#<^6bCl=Kyppcany#Ag!_9Qn{6!%ZK}<=}d8b#@@fST@ z#KLobCEM58F$;l$iY!{cXkNRF1*-(Zq;H}ETT{x9 Q1D(p?>FVdQ&MBb@0GNGeFaQ7m diff --git a/TMessagesProj/src/main/res/drawable-mdpi/spinner_pressed.9.png b/TMessagesProj/src/main/res/drawable-mdpi/spinner_pressed.9.png deleted file mode 100755 index 5cfa70795b5903fc8820ecf2a391f18d06fc9612..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 276 zcmeAS@N?(olHy`uVBq!ia0vp^5^lJIjFE%PQJmI`9R3Md5YLxBL5O|o0 zgTe~DWM4f`8;Qo diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photo_w.png b/TMessagesProj/src/main/res/drawable-xhdpi/photo_w.png new file mode 100755 index 0000000000000000000000000000000000000000..99dadead68170c8ec638a340c06a0646ba1c3469 GIT binary patch literal 1493 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%u1Od5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|81#=KlDb#X~hD#E>34K5C;EJ)Q4 zN-fSWElLJPT$(b-ssbzLqSVBa{GyQj{2W*)24v)yj>2=9ZF3nBND}m`vLFhHbsTY(KatnYqyQCInmZhe+73JqDfW2&$iQ6qe2jOxH zL~jaiw;1Eps}FRHJ}6?5A{r(HOg$hbJlO&{@Pwb52Tbinz+_#pdmS)SFnM~qIEGZ* zdNae&gV|7|EqdyrW{c>pM^~P6y>RxduM5l3g$rf}TwM7=&q-E>g*Dt&K-=l<69uIg z3PA-qf}$mbB1@B2Z+k9(LLh0~Uhky$tG+*2{Bq*-J?{7RelMy!Y*5py0XYM)Dbw;8ni1G5O->aqUx%Tl?{$x?sGW#KV>4ks=+uAP24}5J0ThEm* z;9qhud#Z%pT0S$eIqtj0sS=y9r~lTLtfwp< zH@56Hc`IIV+l6n(UdvC_Q+IStIlw2uo+z-O<>lsBEBE;vUCnFWG%jd;beT1X>-Uv4 zN6MD+q^YjTnDa`@^1`Br0*@2AtFQ5}Ikfy!-}#$s%1q1IU&;@k6u9-c#51hB(f!~Z zb_3NL`cFeRM0d_mKej&df_KsH(&kCRd^yEchSIx)=e%3DhFL4~OGo!lQR!WtdacXn zu3(N#^NG75C%tR0Le{3RyD}9?#{@b5+D+cN$9r$+%ami4oPTAE`K%r~*c+?4zPi}< zPIiY`e6I#OXON^qRU(MwPBU;(BYw#$BG=Rj23pomlDQmJ+|fp7R}RasI&_ z3I7&)X)k>2W_H{pEhocmX2{INhVc)dooz0iDm`;unU&r}Km8XO%S+=jg0>j0POb1z z%BeGLiTKIDzGeGKBT+Mt;HMIMqu5GfU+rBll$WD=FD57dU>Eapy|M>OCfdKVyWGFq ze5;>=zj~UB`?G)>OI(l5o_k>bzb!8;AAsS9^D;lg5*Tv0PETL9oVOfQ(0aQ1xvX6oj<1!HWCY|}Fmnd^pX&PQBf~-*OXDt-!3EiZl%S$+2;#cj1Cvlzd$-?* zVT!7uwNx6X6B~F1=^oj^c#677*c26REt;~DgBWzf9?gi*A8y{Jfu=_2P5uO%Fh!Wv z)|M>TRq9A7rJNE{>DJXCT;z#>4zUc1`ZmMnixGNKmnU;)o1wuZ1m`03@1)X+P9P!+ z0>7u(t*{&i0s#-_^9KT46Y#Q}mtn~paC1K1AK<+~F!j(Rnx$s=q|`nYi>xAa7GslV zm_ni8DKvYK)x&V1P{`5ndff!!wtEdM7u|;4P*ISetyr3gHDmxsQSL^09HB|3zmK4s z)3Sy=RVGp}rYM^X=V6^ARe*`a|Dn1*jka+T{>k^B!gi|HgiI3JC~qmGahV1ul*x-0 zlrgeW2yLrWu``P>va`qpVpjmH+@u*QD%g#a_(Xz_8#a~=1;(WaO%yzurt+L$40<_M z47B+~j*IyOk&6kF1>Gc(C1`0opxSOB9ZVjX z*Q)0tRMnf}s?~F8tIB0aGK|yMzZzZHBJOdf)3zmxY2!nKxZNVQ4reY8kSp;lE(xjP z^K$>IS$EiZ?T7Mn-wfBcL>pW7Hnbebel=ae$90RNr7fdvzJ(>Tq@7lc( zz4>YQ!C-hO6TN$Spby*rzVBo2_vFqj`%%xHmmhuJ`Q??}|4BGHK6o`Bz4C$v>krQv z>u;#p|N7$Y?veS!GN0>hIt!ORJoe5#ksMuqrlZM4pK#r{e*E~%f$*2w(hAqAXRGg| z%dw;5>n3jR5*uBsHV)QoE{}hDDlCshUx$vd2Y27M*L>_Bp(mD}7^(ZV#JV(6cjWDb bk1Iy0v0JU@hU?#9=i0|(9nw(S);+%f6Igzk literal 0 HcmV?d00001 diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/shadow.png b/TMessagesProj/src/main/res/drawable-xhdpi/shadow.png deleted file mode 100755 index c9898d4a16570ea9de77de61902b02023b0c9fc5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2|pq&xaLGBB(^Vb0q163CY%X8O-xS>N=;0uEIgTN15_m8>EaktaVse$AweL?fysv_qhSMs cLjxlN>lFs6E7#@L1Jy8iy85}Sb4q9e0E*otbpQYW diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/spinner.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/spinner.9.png deleted file mode 100755 index 3815d221141cd8c694f237d8a89ac13706407b7d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 389 zcmV;00eb$4P)}kFboFZW(>D$6@4ak;QK#KY{yX0;SNoj2L3=UHW+-AG(9j1>w>?YDHz8HVCLW| zh`4b^en%4k2OMy~Md9?jxYXaqQ7V9MgA+y^aKHfvyq!N8*>=b^M@f_l;D7@TIN*|T zi23vePv~3B>+U7r2z`%v@l-0C(KWz#p{+|Lp@*1fPhBMoZ3WLpTfjxorE9#4`H(=D z9C1-}DY!Vg1Y8BJ4Oc^JPR?%X9w$%RT6MGrya-ylRQjo=)zOk8UKA|_FOHUgo1k;y zX6T&B*-zc$=U=fHex9)9b5@I>1s^o;wfh(v z3p{9G=G&oRQ~Q5s$^4cu#u`bRhesIMWeN_!iF31Fi}A)?P+#YK_Vnt$3+d}>mxM+3 zykq<)ertCq*RNAsyG=r8U5NXTwuL>0CHL-Qm*(;Y{y*NoduWMSziBXUhwZ0|Sl0 M)78&qol`;+03PR+7XSbN diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_w.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photo_w.png new file mode 100755 index 0000000000000000000000000000000000000000..75073d1c6bec5ef8514be4907c1a835bc1fb219a GIT binary patch literal 1921 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxSU1_g&``n5OwZ87 z)XdCKN5ROz&`93^h|F{iO{`4Ktc=VRpg;*|TTx1yRgjAt)Gi>;Rw<*Tq`*pFzr4I$ zuiRKKzbIYb(9+TpWQLKEE>MMTab;dfVufyAu`f(~1RD^r68eAMwS&*t9 zlvv ztM~P_^2{qPNz6-5^>ndS0-B(gnVDi`;bQ3GWNBh<=4{|>Xy|I<=xl6mX>Q@@VqxTB z;bvkE)9aF-T$-DjR|3v4~Pj*wm=R%;iu*SQ+p9GS*I-f=LF0xUp-wMLn>~) znSI(jG*IN&`Ll6eiY`KB?P`r*q-Hp}noL^cs2C#Rmv!lIkoFSC3-toiY}*7y++1B< z68dCr9Jrz}S)t~N%UK^UsToV}>^mAeJ#W+Zk9Uf{+nwM0puJ#S`rOCQ?`5yw`fXol zh*qlPjJ0I$_yjSFHI7`sgSFUbGtuaH-3Jas^O!?DE?R&3jv&)2O< z@;(@Ofwj&mCY8-rq{f&qw`&s((9i@W%EZoI=$z!B3mu{*#}}XN-EB01+bsXT=Q1QQQ(DL z27|EP`{kdOvdVNtO_;~5e(<8r5k+bC_Jfk&Bs(?Dj{pCt-gW=4LjMV-xymQH6=JtH zScC+=XA6y)ntn_CitURDS3NekFJQTI<<~cpCY2Q%!leJZJ}{cGWoJE83{$IFot#Eh z_`>?R!98KCzfPLre0}~$fAw#SG7QX<4*U%~`082ZguHEn%Z=F!PiXy^S32oHt!|Fv ztVhS99OpT+KAbIc^yIcWKe=?4%1asZPA*xlyux=9OWX-(nN7TN+|O>$pEI$2nOOGp zHDSG6HS?#h*|$(=MR-B)v`?X2HNgS*UVfO_D4O9>u-0o~{lxW+2An3UJHl37sK4~k z*w@};`%58@DO-9qzt}$lsaxSwu+|%-?vnv$h~|!K2Y-6)`*zgp{cr2av;@{w(^9U7 zi~iV`wDdfiWo6m|@7^T|M?|7tHZzOr{oVIiwXTkPNsD)H%`NkJ)1 zt3&FnKczhDSKPaF<@TkU?`AyOl^ydzGW4nc&TU0jMILh!J?mWG_DxO9F2Atpw$jg> z3C*uuI~#5??(AHCb;FbLJPm>4(*>s(W^K5=)pe!o#%5QKw5OJ_d!o+Xy5k+}9jbp~ zd#-%eE%}X?Y*VJX?Ur84mEM?t+iuHihu!?kMSrac*XdgytaDrLlf3!6Pyd4YEKRMp za5Op0yxRNd*jE{&*Fs|39FraRdK@HwCokRIF!L}s^R@r&;-}Wuw~MdR{aanpD6El@ z#uvc4GNQND!PxLp;;mkXzlK69?)N%;Pg1!MYu>4p`=zwGS5W-9?v1paKeU*RD*RgH z9)INM&GeJ!6?AuW^%hL^jXq{uc2FmUap!E~VkyhTdD(`^YW$!)*5lx&pgaMR<er{{GxPyLrY6bkQqisxQ#zd*q`*i1nqJTosPzr0uz ztlrnx$}_LHBrz{J)zigR321^|W@d_&fwQZnlbNZZnUjgLp`ojZqltl=larHyxsj2% zv!SaQOs`9Ra%paAUI|QZ3PP_DPQ9R{kXrz>*(J3ovn(~mttdZN0qkX~Oq^~pal>gI zRBsAyw;15ms}FRHJ}6?5A{r(HOg$hbJlO&{@Pwb52Tbinz+|m-xqk-(1EZX$i(^Q| ztt&I*`3@=Yw13xs>`}#ff6s&>Rr#KIXWLnKr*w7)MrmwWdh&hmlKa~a9&?j-dJ(m5 zVfLQ3Yd6<$ota>LWU=yf(*zykCxUiQlOL}=yjV#0fV(Q2bMZemOV?vEij$9;HpKqi zI!_?IkZa?Et*kdb%wlqVu$86jU^a(H>vS;1D$v-^`NJdG$BF0P`~zD|IV6P^eb{LIz)0oD!;PjBlom4iS8@fa zhCEpLp0TTitLD^fi||ESHLv0{LKj)poJ;H56mj%HarxpIEfO~A)_?t-MCSdr{h+JJ zw|`msJpP^u+)o%Ro#QUmAKAfFJ#p#N&y7dFC^kK<;x=Gdo8TI8zUQtvsPyo3^>bP0 Hl+XkK#HpJt literal 0 HcmV?d00001 diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/shadow.png b/TMessagesProj/src/main/res/drawable-xxhdpi/shadow.png deleted file mode 100755 index 9c8b9f09791095f73a9f2c5778543a070047ebc7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$61|)m))t&+=mUKs7M+S!VC(K#9UIO`&C9V-A z!TD(=<%vb942~)JNvR5+xryniL8*x;m4zo$ZGeiDJY5_^DsCkuCL{PiWIn7!Q>VH#P;CjLm~@nc#Fbf7&Kn5BF+&@6dd! zC@_UEgPd8Gk4B@uMko{{h@e}vu<8XZx4Wt!LsxSQ8ym<1zM?vf7I2Ivk?y5n+BI3r ztsE0MFxFFTmS;FWr7BQS{tq?H8rsDfxF7GK!fv)`LpB3lwBTr@a5LS$D_e>?P{qi} zA~at;#dIEFvCBV4C|NnK&h)sques@S?e|_41f_xP3Q}S@u+x+>Z z>)0KxW$4ob`)}{VhP9>*Fj~C!4SZi+>gs$HJ)d~({J3@Heq-X~in*hmZu`7EbT`n@ z+}4vO#>R12*!;6w{5ZCHdwHmMYUKkf_f|Ip4fhUWebVqg^^j@LVokVgEC#kxO>f2y vaJJ4q{{4d6F7-X%b+xJ9owera@ocD)4hB}-f* zN`mv#O3D+9QW+dm@{>{(JaZG%Q-e|yQz{EjrrIztFlKwYIEGZ*dUMB9sL4Q}^`XjB z&4^tE+YWqWxc6Ub93X7N+imEjIG?MmVi zmY;qn&aGybXk%m*32=ZDr<^6LZ^ahbXt#c2WSz1z(96;(WoZKwm&O7J;e=2MWi7oC zvf#_+iB*l4*efsD88?+gin45)TD9S#8-pfmYS;v!fHd}v`yfu5TOb66WDi~Ce-vR-)*tHp8PrL lYH#6Oqy5qA9x5MT@cy7v@qg1*5n$Xfc)I$ztaD0e0st^yvYr3{ diff --git a/TMessagesProj/src/main/res/drawable/edit_text.xml b/TMessagesProj/src/main/res/drawable/edit_text.xml index 287901e71..b9d7fc543 100644 --- a/TMessagesProj/src/main/res/drawable/edit_text.xml +++ b/TMessagesProj/src/main/res/drawable/edit_text.xml @@ -1,7 +1,6 @@ - diff --git a/TMessagesProj/src/main/res/drawable/spinner_states.xml b/TMessagesProj/src/main/res/drawable/spinner_states.xml index 92fb773c1..5cce57b08 100644 --- a/TMessagesProj/src/main/res/drawable/spinner_states.xml +++ b/TMessagesProj/src/main/res/drawable/spinner_states.xml @@ -1,7 +1,47 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout-ar/country_row_layout.xml b/TMessagesProj/src/main/res/layout-ar/country_row_layout.xml deleted file mode 100644 index 5c2499c98..000000000 --- a/TMessagesProj/src/main/res/layout-ar/country_row_layout.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout-ar/group_create_final_layout.xml b/TMessagesProj/src/main/res/layout-ar/group_create_final_layout.xml deleted file mode 100644 index c4e674df2..000000000 --- a/TMessagesProj/src/main/res/layout-ar/group_create_final_layout.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/TMessagesProj/src/main/res/layout/chat_layout.xml b/TMessagesProj/src/main/res/layout/chat_layout.xml index 11e46e8fc..57c147fb7 100644 --- a/TMessagesProj/src/main/res/layout/chat_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_layout.xml @@ -103,137 +103,155 @@ - + android:id="@+id/chat_compose_panel" + android:background="@drawable/compose_panel" + android:orientation="horizontal"> - - - - - + android:layout_width="0dp" + android:layout_weight="1"> - + - + android:layout_gravity="bottom" + android:id="@+id/chat_text_edit" + android:layout_marginTop="2dp" + android:maxLines="4" + android:textSize="18dp" + android:textColorHint="#909090" + android:ems="10" + android:imeOptions="flagNoExtractUi" + android:inputType="textCapSentences|textMultiLine" + android:maxLength="16384" + android:layout_marginLeft="54dp" + android:layout_marginRight="54dp" + android:layout_marginBottom="4dp" + android:paddingBottom="10dp" + android:paddingTop="4dp" + android:textCursorDrawable="@null" + android:textColor="#000000"/> - + + + + + + + + + + + + + android:paddingLeft="13dp" + android:orientation="horizontal" + android:background="#ffffffff"> - + - + - + - + - + - - - - - + android:layout_gravity="bottom" + android:layout_marginTop="2dp"> - + + + + + + + - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/group_create_done_layout.xml b/TMessagesProj/src/main/res/layout/group_create_done_layout.xml deleted file mode 100644 index 7de70f823..000000000 --- a/TMessagesProj/src/main/res/layout/group_create_done_layout.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/login_layout.xml b/TMessagesProj/src/main/res/layout/login_layout.xml deleted file mode 100644 index 5404684d4..000000000 --- a/TMessagesProj/src/main/res/layout/login_layout.xml +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/TMessagesProj/src/main/res/layout/media_layout.xml b/TMessagesProj/src/main/res/layout/media_layout.xml index 405fbcce8..e29bce34d 100644 --- a/TMessagesProj/src/main/res/layout/media_layout.xml +++ b/TMessagesProj/src/main/res/layout/media_layout.xml @@ -3,7 +3,8 @@ android:layout_height="match_parent" android:layout_gravity="top"> - - + android:visibility="gone"> - + android:layout_height="wrap_content"/> + diff --git a/TMessagesProj/src/main/res/layout/media_loading_layout.xml b/TMessagesProj/src/main/res/layout/media_loading_layout.xml index 85a059b04..435491b6d 100644 --- a/TMessagesProj/src/main/res/layout/media_loading_layout.xml +++ b/TMessagesProj/src/main/res/layout/media_loading_layout.xml @@ -1,11 +1,12 @@ + - + android:paddingBottom="6dp"/> + diff --git a/TMessagesProj/src/main/res/layout/popup_notification_layout.xml b/TMessagesProj/src/main/res/layout/popup_notification_layout.xml index c00e824f6..6a5a3ab6f 100644 --- a/TMessagesProj/src/main/res/layout/popup_notification_layout.xml +++ b/TMessagesProj/src/main/res/layout/popup_notification_layout.xml @@ -66,7 +66,11 @@ android:ems="10" android:inputType="textCapSentences|textMultiLine" android:layout_alignParentTop="true" - android:paddingBottom="12dp" + android:layout_marginLeft="6dp" + android:layout_marginRight="6dp" + android:layout_marginBottom="4dp" + android:paddingBottom="10dp" + android:paddingTop="4dp" android:maxLength="16384" android:textCursorDrawable="@null" android:textColor="#000000"/> diff --git a/TMessagesProj/src/main/res/layout/settings_wallpapers_layout.xml b/TMessagesProj/src/main/res/layout/settings_wallpapers_layout.xml index 120b2bd32..257543b17 100644 --- a/TMessagesProj/src/main/res/layout/settings_wallpapers_layout.xml +++ b/TMessagesProj/src/main/res/layout/settings_wallpapers_layout.xml @@ -10,7 +10,6 @@ android:id="@+id/background_image"/> #33000000 #54759e @style/Theme.TMessages.Dialog.Alert + #678cb9 diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 5d96c2f10..07152d993 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -9,7 +9,7 @@ en Your phone - Please confirm your country code\nand enter your phone number. + Please confirm your country code and enter your phone number. Choose a country Wrong country code @@ -306,6 +306,37 @@ Gallery All Photos No photos yet + + Privacy and Security + Privacy + Last Seen + Everybody + My Contacts + Nobody + Everybody (-%1$d) + My Contacts (+%1$d) + My Contacts (-%1$d) + My Contacts (-%1$d, +%2$d) + Nobody (+%1$d) + Security + Delete my account + If Away For + If you do not log in at least once within this period, your account will be deleted along with all groups, messages and contacts. + Delete your account? + Never + Change who can see your Last Seen time. + Important: you won\'t be able to see Last Seen times for people with whom you don\'t share your Last Seen time. Approximate last seen will be shown instead (recently, within a week, witin a month). + Always Share With + Never Share With + These settings will override the values above. + Always Share + Always share with users... + Never Share + Never share with users... + Add Users + Add %1$s to this list? + Sorry, too many requests. Unable to change privacy settings now, please wait. + Edit Video Original Video @@ -386,6 +417,7 @@ Are you sure you want to unblock this contact? Are you sure you want to delete this contact? Are you sure you want to start a secret chat? + Are you sure you want to cancel registration? forward from my name Send messages to %1$s? Forward messages to %1$s? @@ -473,6 +505,12 @@ %1$d weeks %1$d weeks %1$d weeks + %1$d users + %1$d user + %1$d users + %1$d users + %1$d users + %1$d users MMM dd dd.MM.yy