diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index 22ddb19d6..4a4be47de 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="129" + android:versionName="1.3.6"> new_messages = new ArrayList(); public ArrayList new_encrypted_messages = new ArrayList(); public ArrayList other_updates = new ArrayList(); public ArrayList chats = new ArrayList(); public ArrayList users = new ArrayList(); - public TL_updates_state state; - public int pts; - public int date; - public int qts; public TL_updates_state intermediate_state; - public int seq; + public TL_updates_state state; } - public static class TL_updates_difference extends updates_Difference { - public static int constructor = 0xf49ca0; + public static class TL_updates_differenceEmpty extends updates_Difference { + public static int constructor = 0x5d75a138; public void readParams(SerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - new_messages.add((Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - new_encrypted_messages.add((EncryptedMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - other_updates.add((Update)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - chats.add((Chat)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())); - } - state = (TL_updates_state)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + date = stream.readInt32(); + seq = stream.readInt32(); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = new_messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - new_messages.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = new_encrypted_messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - new_encrypted_messages.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = other_updates.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - other_updates.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = chats.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - chats.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); - } - state.serializeToStream(stream); + stream.writeInt32(date); + stream.writeInt32(seq); } } @@ -678,19 +623,72 @@ public class TLRPC { } } - public static class TL_updates_differenceEmpty extends updates_Difference { - public static int constructor = 0x5d75a138; + public static class TL_updates_difference extends updates_Difference { + public static int constructor = 0xf49ca0; public void readParams(SerializedData stream) { - date = stream.readInt32(); - seq = stream.readInt32(); + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + new_messages.add((Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + stream.readInt32(); + count = stream.readInt32(); + for (int a = 0; a < count; a++) { + new_encrypted_messages.add((EncryptedMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + stream.readInt32(); + count = stream.readInt32(); + for (int a = 0; a < count; a++) { + other_updates.add((Update)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + stream.readInt32(); + count = stream.readInt32(); + for (int a = 0; a < count; a++) { + chats.add((Chat)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())); + } + state = (TL_updates_state)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(date); - stream.writeInt32(seq); + stream.writeInt32(0x1cb5c415); + int count = new_messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + new_messages.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = new_encrypted_messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + new_encrypted_messages.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = other_updates.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + other_updates.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = chats.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + chats.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); + } + state.serializeToStream(stream); } } @@ -724,6 +722,42 @@ public class TLRPC { } } + public static class help_AppUpdate extends TLObject { + public int id; + public boolean critical; + public String url; + public String text; + } + + public static class TL_help_appUpdate extends help_AppUpdate { + public static int constructor = 0x8987f311; + + + public void readParams(SerializedData stream) { + id = stream.readInt32(); + critical = stream.readBool(); + url = stream.readString(); + text = stream.readString(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeBool(critical); + stream.writeString(url); + stream.writeString(text); + } + } + + public static class TL_help_noAppUpdate extends help_AppUpdate { + public static int constructor = 0xc45a6536; + + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_messageEmpty extends Message { public static int constructor = 0x83e5de54; @@ -808,13 +842,15 @@ public class TLRPC { public static class MessageMedia extends TLObject { public Video video; - public GeoPoint geo; public Photo photo; + public Document document; + public GeoPoint geo; + public Audio audio; public String phone_number; public String first_name; public String last_name; - public byte[] bytes; public int user_id; + public byte[] bytes; } public static class TL_messageMediaVideo extends MessageMedia { @@ -831,20 +867,6 @@ public class TLRPC { } } - public static class TL_messageMediaGeo extends MessageMedia { - public static int constructor = 0x56e0d474; - - - public void readParams(SerializedData stream) { - geo = (GeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - geo.serializeToStream(stream); - } - } - public static class TL_messageMediaPhoto extends MessageMedia { public static int constructor = 0xc8c45a2a; @@ -859,6 +881,34 @@ public class TLRPC { } } + public static class TL_messageMediaDocument extends MessageMedia { + public static int constructor = 0x2fda2204; + + + public void readParams(SerializedData stream) { + document = (Document)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + document.serializeToStream(stream); + } + } + + public static class TL_messageMediaGeo extends MessageMedia { + public static int constructor = 0x56e0d474; + + + public void readParams(SerializedData stream) { + geo = (GeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + geo.serializeToStream(stream); + } + } + public static class TL_messageMediaEmpty extends MessageMedia { public static int constructor = 0x3ded6320; @@ -868,6 +918,20 @@ public class TLRPC { } } + public static class TL_messageMediaAudio extends MessageMedia { + public static int constructor = 0xc6b68300; + + + public void readParams(SerializedData stream) { + audio = (Audio)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + audio.serializeToStream(stream); + } + } + public static class TL_messageMediaContact extends MessageMedia { public static int constructor = 0x5e7d2f39; @@ -891,6 +955,7 @@ public class TLRPC { public static class TL_messageMediaUnsupported extends MessageMedia { public static int constructor = 0x29632a36; + public void readParams(SerializedData stream) { bytes = stream.readByteArray(); } @@ -1162,6 +1227,56 @@ public class TLRPC { } } + public static class Audio extends TLObject { + public long id; + public long access_hash; + public int user_id; + public int date; + public int duration; + public int size; + public int dc_id; + } + + public static class TL_audioEmpty extends Audio { + public static int constructor = 0x586988d8; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + } + } + + public static class TL_audio extends Audio { + public static int constructor = 0x427425e7; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + user_id = stream.readInt32(); + date = stream.readInt32(); + duration = stream.readInt32(); + size = stream.readInt32(); + dc_id = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeInt32(duration); + stream.writeInt32(size); + stream.writeInt32(dc_id); + } + } + public static class TL_destroy_sessions_res extends TLObject { public static int constructor = 0xfb95abcd; @@ -1724,6 +1839,22 @@ public class TLRPC { public long secret; } + public static class TL_inputAudioFileLocation extends InputFileLocation { + public static int constructor = 0x74dc404d; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + public static class TL_inputEncryptedFileLocation extends InputFileLocation { public static int constructor = 0xf5235d55; @@ -1740,6 +1871,38 @@ public class TLRPC { } } + public static class TL_inputVideoFileLocation extends InputFileLocation { + public static int constructor = 0x3d0364ec; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + + public static class TL_inputDocumentFileLocation extends InputFileLocation { + public static int constructor = 0x4e45abe9; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + public static class TL_inputFileLocation extends InputFileLocation { public static int constructor = 0x14637196; @@ -1758,22 +1921,6 @@ public class TLRPC { } } - public static class TL_inputVideoFileLocation extends InputFileLocation { - public static int constructor = 0x3d0364ec; - - - public void readParams(SerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - } - } - public static class TL_photos_photo extends TLObject { public static int constructor = 0x20212ca8; @@ -2025,6 +2172,7 @@ public class TLRPC { public static class TL_messageActionChatEditPhoto extends MessageAction { public static int constructor = 0x7fcb13a8; + public void readParams(SerializedData stream) { photo = (Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); } @@ -2243,7 +2391,19 @@ public class TLRPC { } } - public static class TL_peerNotifyEventsAll extends TLObject { + public static class PeerNotifyEvents extends TLObject { + } + + public static class TL_peerNotifyEventsEmpty extends PeerNotifyEvents { + public static int constructor = 0xadd53cb3; + + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_peerNotifyEventsAll extends PeerNotifyEvents { public static int constructor = 0x6d1ded88; @@ -2296,21 +2456,6 @@ public class TLRPC { } } - public static class TL_decryptedMessageActionSetMessageTTL extends TLObject { - public static int constructor = 0xa1733aec; - - public int ttl_seconds; - - public void readParams(SerializedData stream) { - ttl_seconds = stream.readInt32(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(ttl_seconds); - } - } - public static class TL_decryptedMessage extends DecryptedMessage { public static int constructor = 0x1f814f1f; @@ -2331,7 +2476,10 @@ public class TLRPC { } } - public static class TL_inputPeerNotifyEventsAll extends TLObject { + public static class InputPeerNotifyEvents extends TLObject { + } + + public static class TL_inputPeerNotifyEventsAll extends InputPeerNotifyEvents { public static int constructor = 0xe86a2c74; @@ -2340,6 +2488,15 @@ public class TLRPC { } } + public static class TL_inputPeerNotifyEventsEmpty extends InputPeerNotifyEvents { + public static int constructor = 0xf03064d8; + + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_client_DH_inner_data extends TLObject { public static int constructor = 0x6643b654; @@ -2430,6 +2587,36 @@ public class TLRPC { } } + public static class InputDocument extends TLObject { + public long id; + public long access_hash; + } + + public static class TL_inputDocumentEmpty extends InputDocument { + public static int constructor = 0x72f0eaae; + + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputDocument extends InputDocument { + public static int constructor = 0x18798952; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + public static class TL_inputAppEvent extends TLObject { public static int constructor = 0x770656a8; @@ -2475,29 +2662,129 @@ public class TLRPC { } } + public static class TL_documentEmpty extends Document { + public static int constructor = 0x36f8c871; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + } + } + + public static class TL_document extends Document { + public static int constructor = 0x9efc6326; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + user_id = stream.readInt32(); + date = stream.readInt32(); + file_name = stream.readString(); + mime_type = stream.readString(); + size = stream.readInt32(); + thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + dc_id = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeString(file_name); + stream.writeString(mime_type); + stream.writeInt32(size); + thumb.serializeToStream(stream); + stream.writeInt32(dc_id); + } + } + public static class InputMedia extends TLObject { - public InputFile file; - public InputGeoPoint geo_point; public String phone_number; public String first_name; public String last_name; + public InputFile file; public InputFile thumb; + public String file_name; + public String mime_type; + public InputGeoPoint geo_point; public int duration; public int w; public int h; } - public static class TL_inputMediaUploadedPhoto extends InputMedia { - public static int constructor = 0x2dc53a7d; + public static class TL_inputMediaContact extends InputMedia { + public static int constructor = 0xa6e45987; + + + public void readParams(SerializedData stream) { + phone_number = stream.readString(); + first_name = stream.readString(); + last_name = stream.readString(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_number); + stream.writeString(first_name); + stream.writeString(last_name); + } + } + + public static class TL_inputMediaUploadedThumbDocument extends InputMedia { + public static int constructor = 0x3e46de5d; public void readParams(SerializedData stream) { file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + thumb = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + file_name = stream.readString(); + mime_type = stream.readString(); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); file.serializeToStream(stream); + thumb.serializeToStream(stream); + stream.writeString(file_name); + stream.writeString(mime_type); + } + } + + public static class TL_inputMediaAudio extends InputMedia { + public static int constructor = 0x89938781; + + public InputAudio id; + + public void readParams(SerializedData stream) { + id = (InputAudio)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + id.serializeToStream(stream); + } + } + + public static class TL_inputMediaDocument extends InputMedia { + public static int constructor = 0xd184e841; + + public InputDocument id; + + public void readParams(SerializedData stream) { + id = (InputDocument)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + id.serializeToStream(stream); } } @@ -2530,21 +2817,12 @@ public class TLRPC { } } - public static class TL_inputMediaContact extends InputMedia { - public static int constructor = 0xa6e45987; + public static class TL_inputMediaEmpty extends InputMedia { + public static int constructor = 0x9664f57f; - public void readParams(SerializedData stream) { - phone_number = stream.readString(); - first_name = stream.readString(); - last_name = stream.readString(); - } - public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeString(phone_number); - stream.writeString(first_name); - stream.writeString(last_name); } } @@ -2570,6 +2848,36 @@ public class TLRPC { } } + public static class TL_inputMediaUploadedPhoto extends InputMedia { + public static int constructor = 0x2dc53a7d; + + + public void readParams(SerializedData stream) { + file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + file.serializeToStream(stream); + } + } + + public static class TL_inputMediaUploadedAudio extends InputMedia { + public static int constructor = 0x61a6d436; + + + public void readParams(SerializedData stream) { + file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + duration = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + file.serializeToStream(stream); + stream.writeInt32(duration); + } + } + public static class TL_inputMediaUploadedVideo extends InputMedia { public static int constructor = 0x4847d92a; @@ -2590,6 +2898,24 @@ public class TLRPC { } } + public static class TL_inputMediaUploadedDocument extends InputMedia { + public static int constructor = 0x34e794bd; + + + public void readParams(SerializedData stream) { + file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + file_name = stream.readString(); + mime_type = stream.readString(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + file.serializeToStream(stream); + stream.writeString(file_name); + stream.writeString(mime_type); + } + } + public static class TL_inputMediaPhoto extends InputMedia { public static int constructor = 0x8f2ab2ec; @@ -2605,15 +2931,6 @@ public class TLRPC { } } - public static class TL_inputMediaEmpty extends InputMedia { - public static int constructor = 0x9664f57f; - - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - } - } - public static class geochats_Messages extends TLObject { public int count; public ArrayList messages = new ArrayList(); @@ -2822,6 +3139,24 @@ public class TLRPC { } } + public static class TL_contactSuggested extends TLObject { + public static int constructor = 0x3de191a1; + + public int user_id; + public int mutual_contacts; + + public void readParams(SerializedData stream) { + user_id = stream.readInt32(); + mutual_contacts = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt32(mutual_contacts); + } + } + public static class Server_DH_Params extends TLObject { public byte[] nonce; public byte[] server_nonce; @@ -2982,24 +3317,27 @@ public class TLRPC { public static class Update extends TLObject { public int chat_id; public int max_date; + public int date; public int user_id; public contacts_MyLink my_link; public contacts_ForeignLink foreign_link; public ArrayList messages = new ArrayList(); public int pts; + public int version; public String first_name; public String last_name; public int qts; public int id; public long random_id; + public ArrayList dc_options = new ArrayList(); public ChatParticipants participants; public EncryptedChat chat; - public int date; public long auth_key_id; public String device; public String location; public UserProfilePhoto photo; public boolean previous; + public int inviter_id; public UserStatus status; } @@ -3064,6 +3402,24 @@ public class TLRPC { } } + public static class TL_updateChatParticipantDelete extends Update { + public static int constructor = 0x6e5f8c22; + + + public void readParams(SerializedData stream) { + chat_id = stream.readInt32(); + user_id = stream.readInt32(); + version = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(user_id); + stream.writeInt32(version); + } + } + public static class TL_updateRestoreMessages extends Update { public static int constructor = 0xd15de04d; @@ -3226,6 +3582,29 @@ public class TLRPC { } } + public static class TL_updateDcOptions extends Update { + public static int constructor = 0x8e5e9873; + + + public void readParams(SerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + dc_options.add((TL_dcOption)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + } + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = dc_options.size(); + stream.writeInt32(count); + for (TL_dcOption dc_option : dc_options) { + dc_option.serializeToStream(stream); + } + } + } + public static class TL_updateChatParticipants extends Update { public static int constructor = 0x7761198; @@ -3341,6 +3720,26 @@ public class TLRPC { } } + public static class TL_updateChatParticipantAdd extends Update { + public static int constructor = 0x3a0eeb22; + + + public void readParams(SerializedData stream) { + chat_id = stream.readInt32(); + user_id = stream.readInt32(); + inviter_id = stream.readInt32(); + version = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(user_id); + stream.writeInt32(inviter_id); + stream.writeInt32(version); + } + } + public static class TL_updateUserStatus extends Update { public static int constructor = 0x1bfbd823; @@ -3357,6 +3756,42 @@ public class TLRPC { } } + public static class TL_contacts_suggested extends TLObject { + public static int constructor = 0x5649dcc5; + + public ArrayList results = new ArrayList(); + public ArrayList users = new ArrayList(); + + public void readParams(SerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + results.add((TL_contactSuggested)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(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = results.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + results.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 RpcError extends TLObject { public int error_code; public String error_message; @@ -3401,8 +3836,8 @@ public class TLRPC { public long id; public long access_hash; public int parts; - public String md5_checksum; public int key_fingerprint; + public String md5_checksum; } public static class TL_inputEncryptedFile extends InputEncryptedFile { @@ -3468,31 +3903,18 @@ public class TLRPC { } } - public static class TL_upload_saveBigFilePart extends TLObject { - public static int constructor = 0xde7b673d; + public static class TL_decryptedMessageActionSetMessageTTL extends TLObject { + public static int constructor = 0xa1733aec; - public long file_id; - public int file_part; - public int file_total_parts; - public byte[] bytes; - - public Class responseClass () { - return Bool.class; - } + public int ttl_seconds; public void readParams(SerializedData stream) { - file_id = stream.readInt64(); - file_part = stream.readInt32(); - file_total_parts = stream.readInt32(); - bytes = stream.readByteArray(); + ttl_seconds = stream.readInt32(); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(file_id); - stream.writeInt32(file_part); - stream.writeInt32(file_total_parts); - stream.writeByteArray(bytes); + stream.writeInt32(ttl_seconds); } } @@ -3726,7 +4148,7 @@ public class TLRPC { } public static class TL_encryptedChat extends EncryptedChat { - public static int constructor = 0x6601d14f; + public static int constructor = 0xfa56ce36; public void readParams(SerializedData stream) { @@ -3736,7 +4158,6 @@ public class TLRPC { admin_id = stream.readInt32(); participant_id = stream.readInt32(); g_a_or_b = stream.readByteArray(); - nonce = stream.readByteArray(); key_fingerprint = stream.readInt64(); } @@ -3748,13 +4169,12 @@ public class TLRPC { stream.writeInt32(admin_id); stream.writeInt32(participant_id); stream.writeByteArray(g_a_or_b); - stream.writeByteArray(nonce); stream.writeInt64(key_fingerprint); } } public static class TL_encryptedChatRequested extends EncryptedChat { - public static int constructor = 0xfda9a7b7; + public static int constructor = 0xc878527e; public void readParams(SerializedData stream) { @@ -3764,7 +4184,6 @@ public class TLRPC { admin_id = stream.readInt32(); participant_id = stream.readInt32(); g_a = stream.readByteArray(); - nonce = stream.readByteArray(); } public void serializeToStream(SerializedData stream) { @@ -3775,7 +4194,6 @@ public class TLRPC { stream.writeInt32(admin_id); stream.writeInt32(participant_id); stream.writeByteArray(g_a); - stream.writeByteArray(nonce); } } @@ -3875,6 +4293,36 @@ public class TLRPC { } } + public static class InputAudio extends TLObject { + public long id; + public long access_hash; + } + + public static class TL_inputAudio extends InputAudio { + public static int constructor = 0x77d440ff; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + + public static class TL_inputAudioEmpty extends InputAudio { + public static int constructor = 0xd95adc84; + + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_messages_chats extends TLObject { public static int constructor = 0x8150cbd8; @@ -3911,6 +4359,42 @@ public class TLRPC { } } + public static class TL_contacts_found extends TLObject { + public static int constructor = 0x566000e; + + public ArrayList results = new ArrayList(); + public ArrayList users = new ArrayList(); + + public void readParams(SerializedData stream) { + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + results.add((TL_contactFound)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(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = results.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + results.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 ChatParticipants extends TLObject { public int chat_id; public int admin_id; @@ -3962,41 +4446,86 @@ public class TLRPC { } public static class DecryptedMessageMedia extends TLObject { - public String phone_number; - public String first_name; - public String last_name; - public int user_id; public byte[] thumb; public int thumb_w; public int thumb_h; - public int duration; - public int w; - public int h; + public String file_name; + public String mime_type; public int size; public byte[] key; public byte[] iv; public double lat; public double _long; - public String filename; + public int duration; + public int w; + public int h; + public String phone_number; + public String first_name; + public String last_name; + public int user_id; } - public static class TL_decryptedMessageMediaContact extends DecryptedMessageMedia { - public static int constructor = 0x588a0a97; + public static class TL_decryptedMessageMediaDocument extends DecryptedMessageMedia { + public static int constructor = 0xb095434b; public void readParams(SerializedData stream) { - phone_number = stream.readString(); - first_name = stream.readString(); - last_name = stream.readString(); - user_id = stream.readInt32(); + thumb = stream.readByteArray(); + thumb_w = stream.readInt32(); + thumb_h = stream.readInt32(); + file_name = stream.readString(); + mime_type = stream.readString(); + size = stream.readInt32(); + key = stream.readByteArray(); + iv = stream.readByteArray(); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeString(phone_number); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeInt32(user_id); + stream.writeByteArray(thumb); + stream.writeInt32(thumb_w); + stream.writeInt32(thumb_h); + stream.writeString(file_name); + stream.writeString(mime_type); + stream.writeInt32(size); + stream.writeByteArray(key); + stream.writeByteArray(iv); + } + } + + public static class TL_decryptedMessageMediaGeoPoint extends DecryptedMessageMedia { + public static int constructor = 0x35480a59; + + + public void readParams(SerializedData stream) { + lat = stream.readDouble(); + _long = stream.readDouble(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeDouble(lat); + stream.writeDouble(_long); + } + } + + public static class TL_decryptedMessageMediaAudio extends DecryptedMessageMedia { + public static int constructor = 0x6080758f; + + + public void readParams(SerializedData stream) { + duration = stream.readInt32(); + size = stream.readInt32(); + key = stream.readByteArray(); + iv = stream.readByteArray(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(duration); + stream.writeInt32(size); + stream.writeByteArray(key); + stream.writeByteArray(iv); } } @@ -4030,43 +4559,23 @@ public class TLRPC { } } - public static class TL_decryptedMessageMediaGeoPoint extends DecryptedMessageMedia { - public static int constructor = 0x35480a59; + public static class TL_decryptedMessageMediaContact extends DecryptedMessageMedia { + public static int constructor = 0x588a0a97; public void readParams(SerializedData stream) { - lat = stream.readDouble(); - _long = stream.readDouble(); + phone_number = stream.readString(); + first_name = stream.readString(); + last_name = stream.readString(); + user_id = stream.readInt32(); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeDouble(lat); - stream.writeDouble(_long); - } - } - - public static class TL_decryptedMessageMediaFile extends DecryptedMessageMedia { - public static int constructor = 0xc0bb4455; - - - public void readParams(SerializedData stream) { - filename = stream.readString(); - thumb = stream.readByteArray(); - thumb_w = stream.readInt32(); - thumb_h = stream.readInt32(); - key = stream.readByteArray(); - iv = stream.readByteArray(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(filename); - stream.writeByteArray(thumb); - stream.writeInt32(thumb_w); - stream.writeInt32(thumb_h); - stream.writeByteArray(key); - stream.writeByteArray(iv); + stream.writeString(phone_number); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt32(user_id); } } @@ -4194,7 +4703,6 @@ public class TLRPC { stream.writeInt32(version); } } - public static class TL_chat extends Chat { public static int constructor = 0x6e9c9bc7; @@ -4344,6 +4852,134 @@ public class TLRPC { } } + public static class TL_msgs_state_info extends TLObject { + public static int constructor = 0x04deb57d; + + public long req_msg_id; + public String info; + + public void readParams(SerializedData stream) { + req_msg_id = stream.readInt64(); + info = stream.readString(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(req_msg_id); + stream.writeString(info); + } + } + + public static class TL_upload_file extends TLObject { + public static int constructor = 0x96a18d5; + + public storage_FileType type; + public int mtime; + public byte[] bytes; + + public void readParams(SerializedData stream) { + type = (storage_FileType)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + mtime = stream.readInt32(); + bytes = stream.readByteArray(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + type.serializeToStream(stream); + stream.writeInt32(mtime); + stream.writeByteArray(bytes); + } + } + + public static class TL_fileLocation extends FileLocation { + public static int constructor = 0x53d69076; + + + public void readParams(SerializedData stream) { + dc_id = stream.readInt32(); + volume_id = stream.readInt64(); + local_id = stream.readInt32(); + secret = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(dc_id); + stream.writeInt64(volume_id); + stream.writeInt32(local_id); + stream.writeInt64(secret); + } + } + + public static class TL_fileLocationUnavailable extends FileLocation { + public static int constructor = 0x7c596b46; + + + public void readParams(SerializedData stream) { + volume_id = stream.readInt64(); + local_id = stream.readInt32(); + secret = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(volume_id); + stream.writeInt32(local_id); + stream.writeInt64(secret); + } + } + + public static class messages_Message extends TLObject { + public Message message; + public ArrayList chats = new ArrayList(); + public ArrayList users = new ArrayList(); + } + + public static class TL_messages_messageEmpty extends messages_Message { + public static int constructor = 0x3f4e0648; + + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messages_message extends messages_Message { + public static int constructor = 0xff90c417; + + + public void readParams(SerializedData stream) { + message = (Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + stream.readInt32(); + int count = stream.readInt32(); + for (int a = 0; a < count; a++) { + chats.add((Chat)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(SerializedData stream) { + stream.writeInt32(constructor); + message.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = chats.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + chats.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 TL_geochats_located extends TLObject { public static int constructor = 0x48feb267; @@ -4404,134 +5040,6 @@ public class TLRPC { } } - public static class TL_msgs_state_info extends TLObject { - public static int constructor = 0x04deb57d; - - public long req_msg_id; - public String info; - - public void readParams(SerializedData stream) { - req_msg_id = stream.readInt64(); - info = stream.readString(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(req_msg_id); - stream.writeString(info); - } - } - - public static class TL_upload_file extends TLObject { - public static int constructor = 0x96a18d5; - - public storage_FileType type; - public int mtime; - public byte[] bytes; - - public void readParams(SerializedData stream) { - type = (storage_FileType)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - mtime = stream.readInt32(); - bytes = stream.readByteArray(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - type.serializeToStream(stream); - stream.writeInt32(mtime); - stream.writeByteArray(bytes); - } - } - - public static class messages_Message extends TLObject { - public Message message; - public ArrayList chats = new ArrayList(); - public ArrayList users = new ArrayList(); - } - - public static class TL_messages_messageEmpty extends messages_Message { - public static int constructor = 0x3f4e0648; - - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messages_message extends messages_Message { - public static int constructor = 0xff90c417; - - - public void readParams(SerializedData stream) { - message = (Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - chats.add((Chat)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(SerializedData stream) { - stream.writeInt32(constructor); - message.serializeToStream(stream); - stream.writeInt32(0x1cb5c415); - int count = chats.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - chats.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 TL_fileLocation extends FileLocation { - public static int constructor = 0x53d69076; - - - public void readParams(SerializedData stream) { - dc_id = stream.readInt32(); - volume_id = stream.readInt64(); - local_id = stream.readInt32(); - secret = stream.readInt64(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(dc_id); - stream.writeInt64(volume_id); - stream.writeInt32(local_id); - stream.writeInt64(secret); - } - } - - public static class TL_fileLocationUnavailable extends FileLocation { - public static int constructor = 0x7c596b46; - - - public void readParams(SerializedData stream) { - volume_id = stream.readInt64(); - local_id = stream.readInt32(); - secret = stream.readInt64(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(volume_id); - stream.writeInt32(local_id); - stream.writeInt64(secret); - } - } - public static class TL_inputGeoChat extends TLObject { public static int constructor = 0x74d456fa; @@ -4641,6 +5149,21 @@ public class TLRPC { } } + public static class TL_contactFound extends TLObject { + public static int constructor = 0xea879f95; + + public int user_id; + + public void readParams(SerializedData stream) { + user_id = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + } + } + public static class InputFile extends TLObject { public long id; public int parts; @@ -4648,25 +5171,6 @@ public class TLRPC { public String md5_checksum; } - public static class TL_inputFile extends InputFile { - public static int constructor = 0xf52ff27f; - - public void readParams(SerializedData stream) { - id = stream.readInt64(); - parts = stream.readInt32(); - name = stream.readString(); - md5_checksum = stream.readString(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt32(parts); - stream.writeString(name); - stream.writeString(md5_checksum); - } - } - public static class TL_inputFileBig extends InputFile { public static int constructor = 0xfa4f0bb5; @@ -4685,6 +5189,26 @@ public class TLRPC { } } + public static class TL_inputFile extends InputFile { + public static int constructor = 0xf52ff27f; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + parts = stream.readInt32(); + name = stream.readString(); + md5_checksum = stream.readString(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt32(parts); + stream.writeString(name); + stream.writeString(md5_checksum); + } + } + public static class messages_StatedMessage extends TLObject { public Message message; public ArrayList chats = new ArrayList(); @@ -4818,48 +5342,30 @@ public class TLRPC { } } - public static class MsgDetailedInfo extends TLObject { - public long answer_msg_id; - public int bytes; - public int status; - public long msg_id; - } - - public static class TL_msg_new_detailed_info extends MsgDetailedInfo { - public static int constructor = 0x809db6df; + public static class TL_updates_state extends TLObject { + public static int constructor = 0xa56c2a3e; + public int pts; + public int qts; + public int date; + public int seq; + public int unread_count; public void readParams(SerializedData stream) { - answer_msg_id = stream.readInt64(); - bytes = stream.readInt32(); - status = stream.readInt32(); + pts = stream.readInt32(); + qts = stream.readInt32(); + date = stream.readInt32(); + seq = stream.readInt32(); + unread_count = stream.readInt32(); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(answer_msg_id); - stream.writeInt32(bytes); - stream.writeInt32(status); - } - } - - public static class TL_msg_detailed_info extends MsgDetailedInfo { - public static int constructor = 0x276d3ec6; - - - public void readParams(SerializedData stream) { - msg_id = stream.readInt64(); - answer_msg_id = stream.readInt64(); - bytes = stream.readInt32(); - status = stream.readInt32(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(msg_id); - stream.writeInt64(answer_msg_id); - stream.writeInt32(bytes); - stream.writeInt32(status); + stream.writeInt32(pts); + stream.writeInt32(qts); + stream.writeInt32(date); + stream.writeInt32(seq); + stream.writeInt32(unread_count); } } @@ -5170,30 +5676,48 @@ public class TLRPC { } } - public static class TL_updates_state extends TLObject { - public static int constructor = 0xa56c2a3e; + public static class MsgDetailedInfo extends TLObject { + public long answer_msg_id; + public int bytes; + public int status; + public long msg_id; + } + + public static class TL_msg_new_detailed_info extends MsgDetailedInfo { + public static int constructor = 0x809db6df; - public int pts; - public int qts; - public int date; - public int seq; - public int unread_count; public void readParams(SerializedData stream) { - pts = stream.readInt32(); - qts = stream.readInt32(); - date = stream.readInt32(); - seq = stream.readInt32(); - unread_count = stream.readInt32(); + answer_msg_id = stream.readInt64(); + bytes = stream.readInt32(); + status = stream.readInt32(); } public void serializeToStream(SerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(pts); - stream.writeInt32(qts); - stream.writeInt32(date); - stream.writeInt32(seq); - stream.writeInt32(unread_count); + stream.writeInt64(answer_msg_id); + stream.writeInt32(bytes); + stream.writeInt32(status); + } + } + + public static class TL_msg_detailed_info extends MsgDetailedInfo { + public static int constructor = 0x276d3ec6; + + + public void readParams(SerializedData stream) { + msg_id = stream.readInt64(); + answer_msg_id = stream.readInt64(); + bytes = stream.readInt32(); + status = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(msg_id); + stream.writeInt64(answer_msg_id); + stream.writeInt32(bytes); + stream.writeInt32(status); } } @@ -5453,6 +5977,24 @@ public class TLRPC { } } + public static class TL_decryptedMessageLayer extends TLObject { + public static int constructor = 0x99a438cf; + + public int layer; + public DecryptedMessage message; + + public void readParams(SerializedData stream) { + layer = stream.readInt32(); + message = (DecryptedMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(layer); + message.serializeToStream(stream); + } + } + public static class InputPhotoCrop extends TLObject { public double crop_left; public double crop_top; @@ -5827,6 +6369,19 @@ public class TLRPC { } } + public static class TL_auth_resetAuthorizations extends TLObject { + public static int constructor = 0x9fab0d1a; + + + public Class responseClass () { + return Bool.class; + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_auth_sendInvites extends TLObject { public static int constructor = 0x771c1d97; @@ -6155,6 +6710,47 @@ public class TLRPC { } } + public static class TL_contacts_search extends TLObject { + public static int constructor = 0x11f812d8; + + public String q; + public int limit; + + public Class responseClass () { + return TL_contacts_found.class; + } + + public void readParams(SerializedData stream) { + q = stream.readString(); + limit = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(q); + stream.writeInt32(limit); + } + } + + public static class TL_contacts_getSuggested extends TLObject { + public static int constructor = 0xcd773428; + + public int limit; + + public Class responseClass () { + return TL_contacts_suggested.class; + } + + public void readParams(SerializedData stream) { + limit = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(limit); + } + } + public static class TL_contacts_deleteContact extends TLObject { public static int constructor = 0x8e953744; @@ -6715,6 +7311,31 @@ public class TLRPC { } } + public static class TL_updates_getDifference extends TLObject { + public static int constructor = 0xa041495; + + public int pts; + public int date; + public int qts; + + public Class responseClass () { + return updates_Difference.class; + } + + public void readParams(SerializedData stream) { + pts = stream.readInt32(); + date = stream.readInt32(); + qts = stream.readInt32(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(pts); + stream.writeInt32(date); + stream.writeInt32(qts); + } + } + public static class TL_photos_updateProfilePhoto extends TLObject { public static int constructor = 0xeef579a0; @@ -6841,6 +7462,34 @@ public class TLRPC { } } + public static class TL_help_getAppUpdate extends TLObject { + public static int constructor = 0xc812ac7e; + + public String device_model; + public String system_version; + public String app_version; + public String lang_code; + + public Class responseClass () { + return help_AppUpdate.class; + } + + public void readParams(SerializedData stream) { + device_model = stream.readString(); + system_version = stream.readString(); + app_version = stream.readString(); + lang_code = stream.readString(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(device_model); + stream.writeString(system_version); + stream.writeString(app_version); + stream.writeString(lang_code); + } + } + public static class TL_help_saveAppLog extends TLObject { public static int constructor = 0x6f02f748; @@ -7275,31 +7924,6 @@ public class TLRPC { } } - public static class TL_updates_getDifference extends TLObject { - public static int constructor = 0xa041495; - - public int pts; - public int date; - public int qts; - - public Class responseClass () { - return updates_Difference.class; - } - - public void readParams(SerializedData stream) { - pts = stream.readInt32(); - date = stream.readInt32(); - qts = stream.readInt32(); - } - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(pts); - stream.writeInt32(date); - stream.writeInt32(qts); - } - } - public static class TL_messages_getDhConfig extends TLObject { public static int constructor = 0x26cf8950; @@ -7513,6 +8137,34 @@ public class TLRPC { } } + public static class TL_upload_saveBigFilePart extends TLObject { + public static int constructor = 0xde7b673d; + + public long file_id; + public int file_part; + public int file_total_parts; + public byte[] bytes; + + public Class responseClass () { + return Bool.class; + } + + public void readParams(SerializedData stream) { + file_id = stream.readInt64(); + file_part = stream.readInt32(); + file_total_parts = stream.readInt32(); + bytes = stream.readByteArray(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(file_id); + stream.writeInt32(file_part); + stream.writeInt32(file_total_parts); + stream.writeByteArray(bytes); + } + } + //manually created public static class TL_messages_receivedQueue extends TLObject { @@ -8051,7 +8703,6 @@ public class TLRPC { public int admin_id; public int participant_id; public byte[] g_a_or_b; - public byte[] nonce; public long key_fingerprint; public byte[] g_a; public byte[] a_or_b; @@ -8110,6 +8761,21 @@ public class TLRPC { public byte[] iv; } + public static class Document extends TLObject { + public long id; + public long access_hash; + public int user_id; + public int date; + public String file_name; + public String mime_type; + public int size; + public PhotoSize thumb; + public int dc_id; + public String path; + public byte[] key; + public byte[] iv; + } + public static class MessageAction extends TLObject { public Photo photo; public UserProfilePhoto newUserPhoto; @@ -8133,6 +8799,40 @@ public class TLRPC { } } + public static class TL_documentEncrypted extends Document { + public static int constructor = 0x55555556; + + + public void readParams(SerializedData stream) { + id = stream.readInt64(); + access_hash = stream.readInt64(); + user_id = stream.readInt32(); + date = stream.readInt32(); + file_name = stream.readString(); + mime_type = stream.readString(); + size = stream.readInt32(); + thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + dc_id = stream.readInt32(); + key = stream.readByteArray(); + iv = stream.readByteArray(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeString(file_name); + stream.writeString(mime_type); + stream.writeInt32(size); + thumb.serializeToStream(stream); + stream.writeInt32(dc_id); + stream.writeByteArray(key); + stream.writeByteArray(iv); + } + } + public static class TL_videoEncrypted extends Video { public static int constructor = 0x55555553; @@ -8211,19 +8911,8 @@ public class TLRPC { } } - public static class invokeWithLayer8 extends TLObject { - public static int constructor = 0xe9abd9fd; - - public TLObject query; - - public void serializeToStream(SerializedData stream) { - stream.writeInt32(constructor); - query.serializeToStream(stream); - } - } - - public static class invokeWithLayer9 extends TLObject { - public static int constructor = 0x76715a63; + public static class invokeWithLayer11 extends TLObject { + public static int constructor = 0xa6b88fdf; public TLObject query; @@ -8271,4 +8960,56 @@ public class TLRPC { message.serializeToStream(stream); } } + + public static class TL_encryptedChat_old extends EncryptedChat { + public static int constructor = 0x6601d14f; + + + public void readParams(SerializedData stream) { + id = stream.readInt32(); + access_hash = stream.readInt64(); + date = stream.readInt32(); + admin_id = stream.readInt32(); + participant_id = stream.readInt32(); + g_a_or_b = stream.readByteArray(); + stream.readByteArray(); + key_fingerprint = stream.readInt64(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(TL_encryptedChat.constructor); + stream.writeInt32(id); + stream.writeInt64(access_hash); + stream.writeInt32(date); + stream.writeInt32(admin_id); + stream.writeInt32(participant_id); + stream.writeByteArray(g_a_or_b); + stream.writeInt64(key_fingerprint); + } + } + + public static class TL_encryptedChatRequested_old extends EncryptedChat { + public static int constructor = 0xfda9a7b7; + + + public void readParams(SerializedData stream) { + id = stream.readInt32(); + access_hash = stream.readInt64(); + date = stream.readInt32(); + admin_id = stream.readInt32(); + participant_id = stream.readInt32(); + g_a = stream.readByteArray(); + stream.readByteArray(); + } + + public void serializeToStream(SerializedData stream) { + stream.writeInt32(TL_encryptedChatRequested.constructor); + stream.writeInt32(id); + stream.writeInt64(access_hash); + stream.writeInt32(date); + stream.writeInt32(admin_id); + stream.writeInt32(participant_id); + stream.writeByteArray(g_a); + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index 753613987..4e8f42181 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -10,8 +10,10 @@ package org.telegram.messenger; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.PackageInfo; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Build; import android.util.Base64; import org.telegram.TL.TLClassStore; @@ -23,6 +25,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Locale; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; @@ -30,6 +33,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.TcpConnectionDelegate { + public static boolean DEBUG_VERSION = false; + public static int APP_ID = 2458; + public static String APP_HASH = "5bce48dc7d331e62c955669eb7233217"; + public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here"; + private HashMap datacenters = new HashMap(); private HashMap> processedMessageIdsSet = new HashMap>(); private HashMap nextSeqNoInSession = new HashMap(); @@ -62,6 +70,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. private boolean updatingDcSettings = false; private int updatingDcStartTime = 0; private int lastDcUpdateTime = 0; + private int currentAppVersion = 0; public static ConnectionsManager Instance = new ConnectionsManager(); @@ -73,6 +82,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. private int nextSleepTimeout = 60000; public ConnectionsManager() { + currentAppVersion = ApplicationLoader.getAppVersion(); lastOutgoingMessageId = 0; movingToDatacenterId = DEFAULT_DATACENTER_ID; loadSession(); @@ -622,9 +632,36 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. return performRpc(rpc, completionBlock, progressBlock, null, requiresCompletion, requestClass, datacenterId); } - TLObject wrapInLayer(TLObject object) { + TLObject wrapInLayer(TLObject object, int datacenterId, RPCRequest request) { if (object.layer() > 0) { - TLRPC.invokeWithLayer8 invoke = new TLRPC.invokeWithLayer8(); + Datacenter datacenter = datacenterWithId(datacenterId); + if (datacenter.lastInitVersion != currentAppVersion) { + request.initRequest = true; + TLRPC.initConnection invoke = new TLRPC.initConnection(); + invoke.query = object; + invoke.api_id = APP_ID; + try { + invoke.lang_code = Locale.getDefault().getCountry(); + invoke.device_model = Build.MANUFACTURER + Build.MODEL; + if (invoke.device_model == null) { + invoke.device_model = "Android unknown"; + } + PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); + invoke.app_version = pInfo.versionName; + if (invoke.app_version == null) { + invoke.app_version = "App version unknown"; + } + invoke.system_version = "SDK " + Build.VERSION.SDK_INT; + } catch (Exception e) { + FileLog.e("tmessages", e); + invoke.lang_code = "en"; + invoke.device_model = "Android unknown"; + invoke.app_version = "App version unknown"; + invoke.system_version = "SDK " + Build.VERSION.SDK_INT; + } + object = invoke; + } + TLRPC.invokeWithLayer11 invoke = new TLRPC.invokeWithLayer11(); invoke.query = object; FileLog.d("wrap in layer", "" + object); return invoke; @@ -647,7 +684,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. request.runningDatacenterId = datacenterId; request.rawRequest = rpc; - request.rpcRequest = wrapInLayer(rpc); + request.rpcRequest = wrapInLayer(rpc, datacenterId, request); request.completionBlock = completionBlock; request.progressBlock = progressBlock; request.quickAckBlock = quickAckBlock; @@ -1791,12 +1828,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. found = true; boolean discardResponse = false; + boolean isError = false; if (request.completionBlock != null) { TLRPC.TL_error implicitError = null; if (resultContainer.result instanceof TLRPC.TL_gzip_packed) { TLRPC.TL_gzip_packed packet = (TLRPC.TL_gzip_packed)resultContainer.result; TLObject uncomressed = Utilities.decompress(packet.packed_data, request.rawRequest); if (uncomressed == null) { + System.gc(); uncomressed = Utilities.decompress(packet.packed_data, request.rawRequest); } if (uncomressed == null) { @@ -1871,6 +1910,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (!discardResponse) { if (implicitError != null || resultContainer.result instanceof TLRPC.TL_error) { + isError = true; request.completionBlock.run(null, implicitError != null ? implicitError : (TLRPC.TL_error) resultContainer.result); } else { request.completionBlock.run(resultContainer.result, null); @@ -1878,6 +1918,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } if (implicitError != null && implicitError.code == 401) { + isError = true; if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) { if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) { Utilities.RunOnUIThread(new Runnable() { @@ -1901,6 +1942,15 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } if (!discardResponse) { + if (request.initRequest && !isError) { + if (datacenter.lastInitVersion != currentAppVersion) { + datacenter.lastInitVersion = currentAppVersion; + saveSession(); + FileLog.e("tmessages", "init connection completed"); + } else { + FileLog.e("tmessages", "rpc is init, but init connection already completed"); + } + } rpcCompleted(resultMid); } else { request.runningMessageId = 0; @@ -2309,6 +2359,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. MessageKeyData keyData = Utilities.generateMessageKeyData(datacenter.authKey, messageKey, true); byte[] messageData = is.readData(data.length - 24); + messageData = Utilities.aesIgeEncryption(messageData, keyData.aesKey, keyData.aesIv, false, false); if (messageData == null) { FileLog.e("tmessages", "Error: can't decrypt message data " + connection); @@ -2329,6 +2380,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. long messageId = messageIs.readInt64(); int messageSeqNo = messageIs.readInt32(); + int messageLength = messageIs.readInt32(); if (isMessageIdProcessed(messageSessionId, messageId)) { doNotProcess = true; @@ -2342,22 +2394,20 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } set.add(messageId); } - + byte[] realMessageKeyFull = Utilities.computeSHA1(messageData, 0, Math.min(messageLength + 32, messageData.length)); if (realMessageKeyFull == null) { return; } byte[] realMessageKey = new byte[16]; System.arraycopy(realMessageKeyFull, realMessageKeyFull.length - 16, realMessageKey, 0, 16); - + if (!Arrays.equals(messageKey, realMessageKey)) { FileLog.e("tmessages", "***** Error: invalid message key"); return; } if (!doNotProcess) { - int messageLength = messageIs.readInt32(); - int constructor = messageIs.readInt32(); TLObject message = TLClassStore.Instance().TLdeserialize(messageIs, constructor, getRequestWithMessageId(messageId)); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java b/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java index 89a25bd63..3953b7e59 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java @@ -20,18 +20,19 @@ import java.util.Comparator; import java.util.HashMap; public class Datacenter { - private final int DATA_VERSION = 2; + private final int DATA_VERSION = 3; public int datacenterId; public ArrayList addresses = new ArrayList(); public HashMap ports = new HashMap(); - public int[] defaultPorts = new int[] {-1, 80, -1, 88, -1, 443, -1, 80, -1, 443, -1}; + public int[] defaultPorts = new int[] {-1, 80, -1, 443, -1, 443, -1, 80, -1, 443, -1}; public boolean authorized; public long authSessionId; public long authDownloadSessionId; public long authUploadSessionId; public byte[] authKey; public byte[] authKeyId; + public int lastInitVersion = 0; private volatile int currentPortNum = 0; private volatile int currentAddressNum = 0; @@ -74,8 +75,11 @@ public class Datacenter { } } else if (version == 1) { int currentVersion = data.readInt32(); - if (currentVersion == 2) { + if (currentVersion == 2 || currentVersion == 3) { datacenterId = data.readInt32(); + if (currentVersion == 3) { + lastInitVersion = data.readInt32(); + } int len = data.readInt32(); for (int a = 0; a < len; a++) { String address = data.readString(); @@ -182,6 +186,7 @@ public class Datacenter { public void SerializeToStream(SerializedData stream) { stream.writeInt32(DATA_VERSION); stream.writeInt32(datacenterId); + stream.writeInt32(lastInitVersion); stream.writeInt32(addresses.size()); for (String address : addresses) { stream.writeString(address); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java b/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java index 4a26ebeaf..ae1dcc2a4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java @@ -19,7 +19,6 @@ import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.text.Spannable; -import android.text.Spanned; import android.text.style.DynamicDrawableSpan; import android.text.style.ImageSpan; import android.view.View; @@ -510,9 +509,9 @@ public class Emoji { EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM); emojiCount++; if (c>= 0xDDE6 && c <= 0xDDFA) { - s.setSpan(span, i - 3, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + s.setSpan(span, i - 3, i + 1, 0); } else { - s.setSpan(span, i - 1, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + s.setSpan(span, i - 1, i + 1, 0); } } buf = 0; @@ -527,7 +526,7 @@ public class Emoji { if(d != null) { EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM); emojiCount++; - s.setSpan(span, i - 1, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + s.setSpan(span, i - 1, i + 1, 0); } buf = 0; } @@ -537,7 +536,7 @@ public class Emoji { if(d != null){ EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM); emojiCount++; - s.setSpan(span, i, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + s.setSpan(span, i, i + 1, 0); } } if (emojiCount >= 50) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java index df09bfffc..8b4f6015e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -42,6 +42,7 @@ public class FileLoadOperation { private File cacheFileFinal; private File cacheIvTemp; + private String ext; private String httpUrl; private URLConnection httpConnection; public boolean needBitmapCreate = true; @@ -90,6 +91,34 @@ public class FileLoadOperation { System.arraycopy(videoLocation.iv, 0, iv, 0, iv.length); key = videoLocation.key; } + ext = ".mp4"; + } + + public FileLoadOperation(TLRPC.Document documentLocation) { + if (documentLocation instanceof TLRPC.TL_document) { + location = new TLRPC.TL_inputDocumentFileLocation(); + datacenter_id = documentLocation.dc_id; + location.id = documentLocation.id; + location.access_hash = documentLocation.access_hash; + } else if (documentLocation instanceof TLRPC.TL_documentEncrypted) { + location = new TLRPC.TL_inputEncryptedFileLocation(); + location.id = documentLocation.id; + location.access_hash = documentLocation.access_hash; + datacenter_id = documentLocation.dc_id; + iv = new byte[32]; + System.arraycopy(documentLocation.iv, 0, iv, 0, iv.length); + key = documentLocation.key; + } + ext = documentLocation.file_name; + int idx = -1; + if (ext == null || (idx = ext.lastIndexOf(".")) == -1) { + ext = ""; + } else { + ext = ext.substring(idx); + if (ext.length() <= 1) { + ext = ""; + } + } } public FileLoadOperation(String url) { @@ -112,13 +141,20 @@ public class FileLoadOperation { } boolean ignoreCache = false; boolean onlyCache = false; + boolean isLocalFile = false; String fileNameFinal = null; String fileNameTemp = null; String fileNameIv = null; if (httpUrl != null) { - fileNameFinal = Utilities.MD5(httpUrl); - fileNameTemp = fileNameFinal + "_temp.jpg"; - fileNameFinal += ".jpg"; + if (!httpUrl.startsWith("http")) { + onlyCache = true; + isLocalFile = true; + fileNameFinal = httpUrl; + } else { + fileNameFinal = Utilities.MD5(httpUrl); + fileNameTemp = fileNameFinal + "_temp.jpg"; + fileNameFinal += ".jpg"; + } } else if (location.volume_id != 0 && location.local_id != 0) { fileNameTemp = location.volume_id + "_" + location.local_id + "_temp.jpg"; fileNameFinal = location.volume_id + "_" + location.local_id + ".jpg"; @@ -131,15 +167,20 @@ public class FileLoadOperation { } else { ignoreCache = true; needBitmapCreate = false; - fileNameTemp = datacenter_id + "_" + location.id + "_temp.mp4"; - fileNameFinal = datacenter_id + "_" + location.id + ".mp4"; + fileNameTemp = datacenter_id + "_" + location.id + "_temp" + ext; + fileNameFinal = datacenter_id + "_" + location.id + ext; if (key != null) { fileNameIv = datacenter_id + "_" + location.id + ".iv"; } } boolean exist; - cacheFileFinal = new File(Utilities.getCacheDir(), fileNameFinal); + if (isLocalFile) { + cacheFileFinal = new File(fileNameFinal); + } else { + cacheFileFinal = new File(Utilities.getCacheDir(), fileNameFinal); + } + final boolean dontDelete = isLocalFile; if ((exist = cacheFileFinal.exists()) && !ignoreCache) { Utilities.cacheOutQueue.postRunnable(new Runnable() { @Override @@ -184,7 +225,9 @@ public class FileLoadOperation { image = BitmapFactory.decodeStream(is, null, opts); is.close(); if (image == null) { - cacheFileFinal.delete(); + if (!dontDelete) { + cacheFileFinal.delete(); + } } else { if (filter != null && image != null) { float bitmapW = image.getWidth(); @@ -213,7 +256,9 @@ public class FileLoadOperation { } }); } catch (Exception e) { - cacheFileFinal.delete(); + if (!dontDelete) { + cacheFileFinal.delete(); + } FileLog.e("tmessages", e); } } @@ -293,7 +338,9 @@ public class FileLoadOperation { private void cleanup() { if (httpUrl != null) { try { - httpConnectionStream.close(); + if (httpConnectionStream != null) { + httpConnectionStream.close(); + } httpConnection = null; httpConnectionStream = null; } catch (Exception e) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index 9d3cbddcf..40e839a57 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -19,6 +19,7 @@ import android.view.View; import android.widget.ImageView; import org.telegram.TL.TLRPC; +import org.telegram.objects.MessageObject; import org.telegram.ui.ApplicationLoader; import org.telegram.ui.Views.BackupImageView; @@ -388,8 +389,8 @@ public class FileLoader { }); } - public void cancelLoadFile(final TLRPC.Video video, final TLRPC.PhotoSize photo) { - if (video == null && photo == null) { + public void cancelLoadFile(final TLRPC.Video video, final TLRPC.PhotoSize photo, final TLRPC.Document document) { + if (video == null && photo == null && document == null) { return; } Utilities.fileUploadQueue.postRunnable(new Runnable() { @@ -397,9 +398,14 @@ public class FileLoader { public void run() { String fileName = null; if (video != null) { - fileName = video.dc_id + "_" + video.id + ".mp4"; + fileName = MessageObject.getAttachFileName(video); } else if (photo != null) { - fileName = photo.location.volume_id + "_" + photo.location.local_id + ".jpg"; + fileName = MessageObject.getAttachFileName(photo); + } else if (document != null) { + fileName = MessageObject.getAttachFileName(document); + } + if (fileName == null) { + return; } FileLoadOperation operation = loadOperationPaths.get(fileName); if (operation != null) { @@ -414,15 +420,20 @@ public class FileLoader { return loadOperationPaths.containsKey(fileName); } - public void loadFile(final TLRPC.Video video, final TLRPC.PhotoSize photo) { + public void loadFile(final TLRPC.Video video, final TLRPC.PhotoSize photo, final TLRPC.Document document) { Utilities.fileUploadQueue.postRunnable(new Runnable() { @Override public void run() { String fileName = null; if (video != null) { - fileName = video.dc_id + "_" + video.id + ".mp4"; + fileName = MessageObject.getAttachFileName(video); } else if (photo != null) { - fileName = photo.location.volume_id + "_" + photo.location.local_id + ".jpg"; + fileName = MessageObject.getAttachFileName(photo); + } else if (document != null) { + fileName = MessageObject.getAttachFileName(document); + } + if (fileName == null) { + return; } if (loadOperationPaths.containsKey(fileName)) { return; @@ -435,6 +446,9 @@ public class FileLoader { operation = new FileLoadOperation(photo.location); operation.totalBytesCount = photo.size; operation.needBitmapCreate = false; + } else if (document != null) { + operation = new FileLoadOperation(document); + operation.totalBytesCount = document.size; } final String arg1 = fileName; @@ -536,24 +550,6 @@ public class FileLoader { memCache.evictAll(); } - public void cleanDisk(boolean all) { - /*if (all) { - [cacheInQueue cancelAllOperations]; - [[NSFileManager defaultManager] removeItemAtPath:diskCachePath error:nil]; - [[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL]; - } else { - NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-cacheMaxCacheAge]; - NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:diskCachePath]; - for (NSString *fileName in fileEnumerator) { - NSString *filePath = [diskCachePath stringByAppendingPathComponent:fileName]; - NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; - if ([[[attrs fileModificationDate] laterDate:expirationDate] isEqualToDate:expirationDate]) { - [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; - } - } - }*/ - } - public void cancelLoadingForImageView(final View imageView) { if (imageView == null) { return; @@ -598,10 +594,11 @@ public class FileLoader { String key; if (httpUrl != null) { key = Utilities.MD5(httpUrl); - } else if (filter == null) { - key = url.volume_id + "_" + url.local_id; } else { - key = url.volume_id + "_" + url.local_id + "@" + filter; + key = url.volume_id + "_" + url.local_id; + } + if (filter != null) { + key += "@" + filter; } Bitmap img = imageFromKey(key); @@ -664,10 +661,11 @@ public class FileLoader { String key; if (httpUrl != null) { key = Utilities.MD5(httpUrl); - } else if (filter == null) { - key = url.volume_id + "_" + url.local_id; } else { - key = url.volume_id + "_" + url.local_id + "@" + filter; + key = url.volume_id + "_" + url.local_id; + } + if (filter != null) { + key += "@" + filter; } Integer num = (Integer)imageView.getTag(R.string.CacheTag); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java index 557ade92c..00ce841ef 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java @@ -20,8 +20,6 @@ import java.util.ArrayList; import java.util.Locale; public class FileLog { - public static boolean DEBUG_VERSION = true; - public static FileLog Instance = new FileLog(); private OutputStreamWriter streamWriter = null; private FastDateFormat dateFormat = null; @@ -29,7 +27,7 @@ public class FileLog { private File currentFile = null; public FileLog() { - if (!DEBUG_VERSION) { + if (!ConnectionsManager.DEBUG_VERSION) { return; } dateFormat = FastDateFormat.getInstance("dd_MM_yyyy_HH_mm_ss", Locale.US); @@ -59,7 +57,7 @@ public class FileLog { } public static void e(final String tag, final String message, final Throwable exception) { - if (!DEBUG_VERSION) { + if (!ConnectionsManager.DEBUG_VERSION) { return; } Log.e(tag, message, exception); @@ -80,7 +78,7 @@ public class FileLog { } public static void e(final String tag, final String message) { - if (!DEBUG_VERSION) { + if (!ConnectionsManager.DEBUG_VERSION) { return; } Log.e(tag, message); @@ -100,7 +98,7 @@ public class FileLog { } public static void e(final String tag, final Exception e) { - if (!DEBUG_VERSION) { + if (!ConnectionsManager.DEBUG_VERSION) { return; } e.printStackTrace(); @@ -124,7 +122,7 @@ public class FileLog { } public static void d(final String tag, final String message) { - if (!DEBUG_VERSION) { + if (!ConnectionsManager.DEBUG_VERSION) { return; } Log.d(tag, message); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java b/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java index a0673e421..46a401137 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java @@ -77,9 +77,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti TLRPC.TL_req_pq reqPq = new TLRPC.TL_req_pq(); byte[] nonceBytes = new byte[16]; - for (int a = 0; a < 16; a++) { - nonceBytes[a] = (byte)(MessagesController.random.nextDouble() * 255); - } + MessagesController.random.nextBytes(nonceBytes); authNonce = reqPq.nonce = nonceBytes; reqPQMsgData = sendMessageData(reqPq, generateMessageId()); } @@ -104,6 +102,45 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti new BigInteger("010001", 16)}); map.put("fingerprint", 0xc3b42b026ce86b21L); serverPublicKeys.add(map); + + map = new HashMap(); + map.put("key", new BigInteger[]{ + new BigInteger("c6aeda78b02a251db4b6441031f467fa871faed32526c436524b1fb3b5dc" + + "a28efb8c089dd1b46d92c895993d87108254951c5f001a0f055f3063dcd14d431a300eb9e29" + + "517e359a1c9537e5e87ab1b116faecf5d17546ebc21db234d9d336a693efcb2b6fbcca1e7d1" + + "a0be414dca408a11609b9c4269a920b09fed1f9a1597be02761430f09e4bc48fcafbe289054" + + "c99dba51b6b5eb7d9c3a2ab4e490545b4676bd620e93804bcac93bf94f73f92c729ca899477" + + "ff17625ef14a934d51dc11d5f8650a3364586b3a52fcff2fedec8a8406cac4e751705a472e5" + + "5707e3c8cd5594342b119c6c3293532d85dbe9271ed54a2fd18b4dc79c04a30951107d5639397", 16), + new BigInteger("010001", 16)}); + map.put("fingerprint", 0x9a996a1db11c729bL); + serverPublicKeys.add(map); + + map = new HashMap(); + map.put("key", new BigInteger[]{ + new BigInteger("b1066749655935f0a5936f517034c943bea7f3365a8931ae52c8bcb14856" + + "f004b83d26cf2839be0f22607470d67481771c1ce5ec31de16b20bbaa4ecd2f7d2ecf6b6356" + + "f27501c226984263edc046b89fb6d3981546b01d7bd34fedcfcc1058e2d494bda732ff813e5" + + "0e1c6ae249890b225f82b22b1e55fcb063dc3c0e18e91c28d0c4aa627dec8353eee6038a95a" + + "4fd1ca984eb09f94aeb7a2220635a8ceb450ea7e61d915cdb4eecedaa083aa3801daf071855" + + "ec1fb38516cb6c2996d2d60c0ecbcfa57e4cf1fb0ed39b2f37e94ab4202ecf595e167b3ca62" + + "669a6da520859fb6d6c6203dfdfc79c75ec3ee97da8774b2da903e3435f2cd294670a75a526c1", 16), + new BigInteger("010001", 16)}); + map.put("fingerprint", 0xb05b2a6f70cdea78L); + serverPublicKeys.add(map); + + map = new HashMap(); + map.put("key", new BigInteger[]{ + new BigInteger("c2a8c55b4a62e2b78a19b91cf692bcdc4ba7c23fe4d06f194e2a0c30f6d9" + + "996f7d1a2bcc89bc1ac4333d44359a6c433252d1a8402d9970378b5912b75bc8cc3fa76710a" + + "025bcb9032df0b87d7607cc53b928712a174ea2a80a8176623588119d42ffce40205c6d7216" + + "0860d8d80b22a8b8651907cf388effbef29cd7cf2b4eb8a872052da1351cfe7fec214ce4830" + + "4ea472bd66329d60115b3420d08f6894b0410b6ab9450249967617670c932f7cbdb5d6fbcce" + + "1e492c595f483109999b2661fcdeec31b196429b7834c7211a93c6789d9ee601c18c39e521f" + + "da9d7264e61e518add6f0712d2d5228204b851e13c4f322e5c5431c3b7f31089668486aadc59f", 16), + new BigInteger("010001", 16)}); + map.put("fingerprint", 0x71e025b6c76033e3L); + serverPublicKeys.add(map); } } @@ -209,9 +246,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti innerData.q = reqDH.q; byte[] nonceBytes = new byte[32]; - for (int a = 0; a < 32; a++) { - nonceBytes[a] = (byte)(MessagesController.random.nextDouble() * 255); - } + MessagesController.random.nextBytes(nonceBytes); innerData.new_nonce = authNewNonce = nonceBytes; innerData.serializeToStream(os); @@ -340,9 +375,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti } byte[] b = new byte[256]; - for (int a = 0; a < 256; a++) { - b[a] = (byte)(MessagesController.random.nextDouble() * 255); - } + MessagesController.random.nextBytes(b); BigInteger p = new BigInteger(1, dhInnerData.dh_prime); BigInteger g_a = new BigInteger(1, dhInnerData.g_a); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 42350fd35..e39e47315 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -133,6 +133,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter public int type; public TLRPC.FileLocation location; public TLRPC.TL_video videoLocation; + public TLRPC.TL_document documentLocation; public MessageObject obj; public TLRPC.EncryptedChat encryptedChat; } @@ -1960,31 +1961,35 @@ public class MessagesController implements NotificationCenter.NotificationCenter } public void sendMessage(TLRPC.User user, long peer) { - sendMessage(null, 0, 0, null, null, null, null, user, peer); + sendMessage(null, 0, 0, null, null, null, null, user, null, peer); } public void sendMessage(MessageObject message, long peer) { - sendMessage(null, 0, 0, null, null, message, null, null, peer); + sendMessage(null, 0, 0, null, null, message, null, null, null, peer); + } + + public void sendMessage(TLRPC.TL_document document, long peer) { + sendMessage(null, 0, 0, null, null, null, null, null, document, peer); } public void sendMessage(String message, long peer) { - sendMessage(message, 0, 0, null, null, null, null, null, peer); + sendMessage(message, 0, 0, null, null, null, null, null, null, peer); } public void sendMessage(TLRPC.FileLocation location, long peer) { - sendMessage(null, 0, 0, null, null, null, location, null, peer); + sendMessage(null, 0, 0, null, null, null, location, null, null, peer); } public void sendMessage(double lat, double lon, long peer) { - sendMessage(null, lat, lon, null, null, null, null, null, peer); + sendMessage(null, lat, lon, null, null, null, null, null, null, peer); } public void sendMessage(TLRPC.TL_photo photo, long peer) { - sendMessage(null, 0, 0, photo, null, null, null, null, peer); + sendMessage(null, 0, 0, photo, null, null, null, null, null, peer); } public void sendMessage(TLRPC.TL_video video, long peer) { - sendMessage(null, 0, 0, null, video, null, null, null, peer); + sendMessage(null, 0, 0, null, video, null, null, null, null, peer); } public void sendTTLMessage(TLRPC.EncryptedChat encryptedChat) { @@ -2028,7 +2033,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null); } - private void sendMessage(String message, double lat, double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.FileLocation location, TLRPC.User user, long peer) { + private void sendMessage(String message, double lat, double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.FileLocation location, TLRPC.User user, TLRPC.TL_document document, long peer) { TLRPC.Message newMsg = null; int type = -1; if (message != null) { @@ -2095,6 +2100,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter newMsg.media.user_id = user.id; newMsg.message = ""; type = 6; + } else if (document != null) { + newMsg = new TLRPC.TL_message(); + newMsg.media = new TLRPC.TL_messageMediaDocument(); + newMsg.media.document = document; + type = 7; + newMsg.message = "-1"; + newMsg.attachPath = document.path; } if (newMsg == null) { return; @@ -2172,7 +2184,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter reqSend.media = new TLRPC.TL_decryptedMessageMediaEmpty(); performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null); } - } else if (type == 1 || type == 2 || type == 3 || type == 5 || type == 6) { + } else if (type == 1 || type == 2 || type == 3 || type == 5 || type == 6 || type == 7) { if (encryptedChat == null) { TLRPC.TL_messages_sendMedia reqSend = new TLRPC.TL_messages_sendMedia(); reqSend.peer = sendToPeer; @@ -2216,6 +2228,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter reqSend.media.first_name = user.first_name; reqSend.media.last_name = user.last_name; performSendMessageRequest(reqSend, newMsgObj); + } else if (type == 7) { + reqSend.media = new TLRPC.TL_inputMediaUploadedDocument(); + reqSend.media.mime_type = document.mime_type; + reqSend.media.file_name = document.file_name; + DelayedMessage delayedMessage = new DelayedMessage(); + delayedMessage.sendRequest = reqSend; + delayedMessage.type = 2; + delayedMessage.obj = newMsgObj; + delayedMessage.documentLocation = document; + performSendDelayedMessage(delayedMessage); } } else { TLRPC.TL_decryptedMessage reqSend = new TLRPC.TL_decryptedMessage(); @@ -2280,6 +2302,26 @@ public class MessagesController implements NotificationCenter.NotificationCenter reqSend.media.last_name = user.last_name; reqSend.media.user_id = user.id; performSendEncryptedRequest(reqSend, newMsgObj, encryptedChat, null); + } else if (type == 7) { + reqSend.media = new TLRPC.TL_decryptedMessageMediaDocument(); + reqSend.media.iv = new byte[32]; + reqSend.media.key = new byte[32]; + random.nextBytes(reqSend.media.iv); + random.nextBytes(reqSend.media.key); + reqSend.media.size = document.size; + reqSend.media.thumb = new byte[0]; + reqSend.media.thumb_h = 0; + reqSend.media.thumb_w = 0; + reqSend.media.file_name = document.file_name; + reqSend.media.mime_type = document.mime_type; + + DelayedMessage delayedMessage = new DelayedMessage(); + delayedMessage.sendEncryptedRequest = reqSend; + delayedMessage.type = 2; + delayedMessage.obj = newMsgObj; + delayedMessage.encryptedChat = encryptedChat; + delayedMessage.documentLocation = document; + performSendDelayedMessage(delayedMessage); } } } else if (type == 4) { @@ -2337,6 +2379,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter sendedMessage.message = newMsg.message; sendedMessage.attachPath = newMsg.attachPath; } + } else if (sendedMessage.media instanceof TLRPC.TL_messageMediaDocument && sendedMessage.media.document != null && newMsg.media instanceof TLRPC.TL_messageMediaDocument && newMsg.media.document != null) { + sendedMessage.message = newMsg.message; + sendedMessage.attachPath = newMsg.attachPath; } } else if (file != null) { if (newMsg.media instanceof TLRPC.TL_messageMediaPhoto && newMsg.media.photo != null) { @@ -2378,6 +2423,24 @@ public class MessagesController implements NotificationCenter.NotificationCenter ArrayList arr = new ArrayList(); arr.add(newMsg); MessagesStorage.Instance.putMessages(arr, false, true); + } else if (newMsg.media instanceof TLRPC.TL_messageMediaDocument && newMsg.media.document != null) { + TLRPC.Document document = newMsg.media.document; + newMsg.media.document = new TLRPC.TL_documentEncrypted(); + newMsg.media.document.id = file.id; + newMsg.media.document.access_hash = file.access_hash; + newMsg.media.document.user_id = document.user_id; + newMsg.media.document.date = document.date; + newMsg.media.document.file_name = document.file_name; + newMsg.media.document.mime_type = document.mime_type; + newMsg.media.document.size = file.size; + newMsg.media.document.key = decryptedMessage.media.key; + newMsg.media.document.iv = decryptedMessage.media.iv; + newMsg.media.document.path = document.path; + newMsg.media.document.thumb = document.thumb; + newMsg.media.document.dc_id = file.dc_id; + ArrayList arr = new ArrayList(); + arr.add(newMsg); + MessagesStorage.Instance.putMessages(arr, false, true); } } } @@ -2591,6 +2654,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter delayedMessages.put(location, message); FileLoader.Instance.uploadFile(location, message.sendEncryptedRequest.media.key, message.sendEncryptedRequest.media.iv); } + } else if (message.type == 2) { + String location = message.documentLocation.path; + delayedMessages.put(location, message); + if (message.sendRequest != null) { + FileLoader.Instance.uploadFile(location, null, null); + } else { + FileLoader.Instance.uploadFile(location, message.sendEncryptedRequest.media.key, message.sendEncryptedRequest.media.iv); + } } } }); @@ -2903,12 +2974,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter message.sendRequest.media.file = file; performSendMessageRequest(message.sendRequest, message.obj); } + } else if (message.type == 2) { + message.sendRequest.media.file = file; + performSendMessageRequest(message.sendRequest, message.obj); } } else if (encryptedFile != null) { if (message.type == 0) { performSendEncryptedRequest(message.sendEncryptedRequest, message.obj, message.encryptedChat, encryptedFile); } else if (message.type == 1) { performSendEncryptedRequest(message.sendEncryptedRequest, message.obj, message.encryptedChat, encryptedFile); + } else if (message.type == 2) { + performSendEncryptedRequest(message.sendEncryptedRequest, message.obj, message.encryptedChat, encryptedFile); } } delayedMessages.remove(location); @@ -4473,6 +4549,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageContact, Utilities.formatName(u.first_name, u.last_name)); } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) { msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageMap, Utilities.formatName(u.first_name, u.last_name)); + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { + msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageDocument, Utilities.formatName(u.first_name, u.last_name)); + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaAudio) { + msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageAudio, Utilities.formatName(u.first_name, u.last_name)); } } } else if (chat_id != 0 && user_id == 0) { @@ -4527,6 +4607,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageGroupContact, Utilities.formatName(u.first_name, u.last_name), chat.title); } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) { msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageGroupMap, Utilities.formatName(u.first_name, u.last_name), chat.title); + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { + msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageGroupDocument, Utilities.formatName(u.first_name, u.last_name), chat.title); + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaAudio) { + msg = ApplicationLoader.applicationContext.getString(R.string.NotificationMessageGroupAudio, Utilities.formatName(u.first_name, u.last_name), chat.title); } } } @@ -4737,13 +4821,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter newMessage.media.photo.date = newMessage.date; newMessage.media.photo.caption = ""; newMessage.media.photo.geo = new TLRPC.TL_geoPointEmpty(); - TLRPC.TL_photoCachedSize small = new TLRPC.TL_photoCachedSize(); - small.w = decryptedMessage.media.thumb_w; - small.h = decryptedMessage.media.thumb_h; - small.bytes = decryptedMessage.media.thumb; - small.type = "s"; - small.location = new TLRPC.TL_fileLocationUnavailable(); - newMessage.media.photo.sizes.add(small); + if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 5000 && decryptedMessage.media.thumb_w < 100 && decryptedMessage.media.thumb_h < 100) { + TLRPC.TL_photoCachedSize small = new TLRPC.TL_photoCachedSize(); + small.w = decryptedMessage.media.thumb_w; + small.h = decryptedMessage.media.thumb_h; + small.bytes = decryptedMessage.media.thumb; + small.type = "s"; + small.location = new TLRPC.TL_fileLocationUnavailable(); + newMessage.media.photo.sizes.add(small); + } TLRPC.TL_photoSize big = new TLRPC.TL_photoSize(); big.w = decryptedMessage.media.w; @@ -4764,12 +4850,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter } newMessage.media = new TLRPC.TL_messageMediaVideo(); newMessage.media.video = new TLRPC.TL_videoEncrypted(); - newMessage.media.video.thumb = new TLRPC.TL_photoCachedSize(); - newMessage.media.video.thumb.bytes = decryptedMessage.media.thumb; - newMessage.media.video.thumb.w = decryptedMessage.media.thumb_w; - newMessage.media.video.thumb.h = decryptedMessage.media.thumb_h; - newMessage.media.video.thumb.type = "s"; - newMessage.media.video.thumb.location = new TLRPC.TL_fileLocationUnavailable(); + if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 5000 && decryptedMessage.media.thumb_w < 100 && decryptedMessage.media.thumb_h < 100) { + newMessage.media.video.thumb = new TLRPC.TL_photoCachedSize(); + newMessage.media.video.thumb.bytes = decryptedMessage.media.thumb; + newMessage.media.video.thumb.w = decryptedMessage.media.thumb_w; + newMessage.media.video.thumb.h = decryptedMessage.media.thumb_h; + newMessage.media.video.thumb.type = "s"; + newMessage.media.video.thumb.location = new TLRPC.TL_fileLocationUnavailable(); + } else { + newMessage.media.video.thumb = new TLRPC.TL_photoSizeEmpty(); + newMessage.media.video.thumb.type = "s"; + } newMessage.media.video.duration = decryptedMessage.media.duration; newMessage.media.video.dc_id = message.file.dc_id; newMessage.media.video.w = decryptedMessage.media.w; @@ -4782,6 +4873,33 @@ public class MessagesController implements NotificationCenter.NotificationCenter newMessage.media.video.access_hash = message.file.access_hash; newMessage.media.video.key = decryptedMessage.media.key; newMessage.media.video.iv = decryptedMessage.media.iv; + } else if (decryptedMessage.media instanceof TLRPC.TL_decryptedMessageMediaDocument) { + if (decryptedMessage.media.key.length != 32 || decryptedMessage.media.iv.length != 32) { + return null; + } + newMessage.media = new TLRPC.TL_messageMediaDocument(); + newMessage.media.document = new TLRPC.TL_documentEncrypted(); + newMessage.media.document.id = message.file.id; + newMessage.media.document.access_hash = message.file.access_hash; + newMessage.media.document.user_id = decryptedMessage.media.user_id; + newMessage.media.document.date = message.date; + newMessage.media.document.file_name = decryptedMessage.media.file_name; + newMessage.media.document.mime_type = decryptedMessage.media.mime_type; + newMessage.media.document.size = message.file.size; + newMessage.media.document.key = decryptedMessage.media.key; + newMessage.media.document.iv = decryptedMessage.media.iv; + if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 5000 && decryptedMessage.media.thumb_w < 100 && decryptedMessage.media.thumb_h < 100) { + newMessage.media.document.thumb = new TLRPC.TL_photoCachedSize(); + newMessage.media.document.thumb.bytes = decryptedMessage.media.thumb; + newMessage.media.document.thumb.w = decryptedMessage.media.thumb_w; + newMessage.media.document.thumb.h = decryptedMessage.media.thumb_h; + newMessage.media.document.thumb.type = "s"; + newMessage.media.document.thumb.location = new TLRPC.TL_fileLocationUnavailable(); + } else { + newMessage.media.document.thumb = new TLRPC.TL_photoSizeEmpty(); + newMessage.media.document.thumb.type = "s"; + } + newMessage.media.document.dc_id = message.file.dc_id; } else { return null; } @@ -4903,7 +5021,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } byte[] salt = new byte[256]; for (int a = 0; a < 256; a++) { - salt[a] = (byte)((byte)(random.nextDouble() * 255) ^ res.random[a]); + salt[a] = (byte)((byte)(random.nextDouble() * 256) ^ res.random[a]); } encryptedChat.a_or_b = salt; BigInteger p = new BigInteger(1, MessagesStorage.secretPBytes); @@ -5009,7 +5127,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } final byte[] salt = new byte[256]; for (int a = 0; a < 256; a++) { - salt[a] = (byte)((byte)(random.nextDouble() * 255) ^ res.random[a]); + salt[a] = (byte)((byte)(random.nextDouble() * 256) ^ res.random[a]); } BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.secretG); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java b/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java index 818f41bba..fb3626386 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java @@ -58,6 +58,8 @@ public class RPCRequest { boolean confirmed; + boolean initRequest = false; + ArrayList respondsToMessageIds = new ArrayList(); public void addRespondMessageId(long messageId) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java index af042bf88..311d7ff22 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java @@ -753,6 +753,18 @@ public class Utilities { return result; } + public static String formatFileSize(long size) { + if (size < 1024) { + return String.format("%d B", size); + } else if (size < 1024 * 1024) { + return String.format("%.1f KB", size / 1024.0f); + } else if (size < 1024 * 1024 * 1024) { + return String.format("%.1f MB", size / 1024.0f / 1024.0f); + } else { + return String.format("%.1f GB", size / 1024.0f / 1024.0f / 1024.0f); + } + } + public static String stringForMessageListDate(long date) { Calendar rightNow = Calendar.getInstance(); int day = rightNow.get(Calendar.DAY_OF_YEAR); diff --git a/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java index eaf5b3fa3..cb949b30f 100644 --- a/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java @@ -10,6 +10,7 @@ package org.telegram.objects; import android.graphics.Bitmap; +import org.telegram.TL.TLObject; import org.telegram.TL.TLRPC; import org.telegram.messenger.Emoji; import org.telegram.messenger.MessagesController; @@ -211,6 +212,10 @@ public class MessageObject { messageText = ApplicationLoader.applicationContext.getString(R.string.AttachContact); } else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) { messageText = ApplicationLoader.applicationContext.getString(R.string.UnsuppotedMedia); + } else if (message.media instanceof TLRPC.TL_messageMediaDocument) { + messageText = ApplicationLoader.applicationContext.getString(R.string.AttachDocument); + } else if (message.media instanceof TLRPC.TL_messageMediaAudio) { + messageText = ApplicationLoader.applicationContext.getString(R.string.AttachAudio); } } else { messageText = message.message; @@ -255,6 +260,12 @@ public class MessageObject { } else { type = 1; } + } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaDocument) { + if (message.from_id == UserConfig.clientUserId) { + type = 16; + } else { + type = 17; + } } } else if (message instanceof TLRPC.TL_messageService) { if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto || message.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) { @@ -277,4 +288,38 @@ public class MessageObject { int dateMonth = rightNow.get(Calendar.MONTH); dateKey = String.format("%d_%02d_%02d", dateYear, dateMonth, dateDay); } + + public String getFileName() { + if (messageOwner.media instanceof TLRPC.TL_messageMediaVideo) { + return getAttachFileName(messageOwner.media.video); + } else if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { + return getAttachFileName(messageOwner.media.document); + } + return ""; + } + + public static String getAttachFileName(TLObject attach) { + if (attach instanceof TLRPC.Video) { + TLRPC.Video video = (TLRPC.Video)attach; + return video.dc_id + "_" + video.id + ".mp4"; + } else if (attach instanceof TLRPC.Document) { + TLRPC.Document document = (TLRPC.Document)attach; + String ext = document.file_name; + int idx = -1; + if (ext == null || (idx = ext.lastIndexOf(".")) == -1) { + ext = ""; + } else { + ext = ext.substring(idx); + } + if (ext.length() > 1) { + return document.dc_id + "_" + document.id + ext; + } else { + return document.dc_id + "_" + document.id; + } + } else if (attach instanceof TLRPC.PhotoSize) { + TLRPC.PhotoSize photo = (TLRPC.PhotoSize)attach; + return photo.location.volume_id + "_" + photo.location.local_id + ".jpg"; + } + return ""; + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ApplicationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ApplicationActivity.java index 06a1cdf88..1353c3207 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ApplicationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ApplicationActivity.java @@ -317,12 +317,12 @@ public class ApplicationActivity extends ActionBarActivity implements Notificati } private void checkForCrashes() { - CrashManager.register(this, "your-hockeyapp-api-key-here"); + CrashManager.register(this, ConnectionsManager.HOCKEY_APP_HASH); } private void checkForUpdates() { - if (FileLog.DEBUG_VERSION) { - UpdateManager.register(this, "your-hockeyapp-api-key-here"); + if (ConnectionsManager.DEBUG_VERSION) { + UpdateManager.register(this, ConnectionsManager.HOCKEY_APP_HASH); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java index 5b9c339f1..5da7a87b2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java @@ -150,7 +150,7 @@ public class ApplicationLoader extends Application { return ""; } int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE); - int currentVersion = getAppVersion(context); + int currentVersion = getAppVersion(); if (registeredVersion != currentVersion) { FileLog.d("tmessages", "App version changed."); return ""; @@ -162,9 +162,9 @@ public class ApplicationLoader extends Application { return getSharedPreferences(ApplicationLoader.class.getSimpleName(), Context.MODE_PRIVATE); } - private static int getAppVersion(Context context) { + public static int getAppVersion() { try { - PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); + PackageInfo packageInfo = applicationContext.getPackageManager().getPackageInfo(applicationContext.getPackageName(), 0); return packageInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException("Could not get package name: " + e); @@ -223,7 +223,7 @@ public class ApplicationLoader extends Application { private void storeRegistrationId(Context context, String regId) { final SharedPreferences prefs = getGCMPreferences(context); - int appVersion = getAppVersion(context); + int appVersion = getAppVersion(); FileLog.e("tmessages", "Saving regId on app version " + appVersion); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PROPERTY_REG_ID, regId); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 09964bc38..96fc843fd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -53,6 +53,7 @@ import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; +import android.webkit.MimeTypeMap; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.BaseAdapter; @@ -95,7 +96,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Locale; -public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate { +public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, DocumentSelectActivity.DocumentSelectActivityDelegate { private LayoutListView chatListView; private BackupImageView avatarImageView; private TLRPC.Chat currentChat; @@ -164,7 +165,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa private MessageObject unreadMessageObject = null; //private boolean reloadAfterAnimation = false; - private int videoLocalId; private String currentPicturePath; private TLRPC.ChatParticipants info = null; @@ -421,9 +421,17 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa v.setVisibility(View.VISIBLE); if (currentEncryptedChat.admin_id == UserConfig.clientUserId) { - secretViewStatusTextView.setText(String.format(getStringEntry(R.string.EncryptedPlaceholderTitleOutgoing), currentUser.first_name)); + if (currentUser.first_name.length() > 0) { + secretViewStatusTextView.setText(String.format(getStringEntry(R.string.EncryptedPlaceholderTitleOutgoing), currentUser.first_name)); + } else { + secretViewStatusTextView.setText(String.format(getStringEntry(R.string.EncryptedPlaceholderTitleOutgoing), currentUser.last_name)); + } } else { - secretViewStatusTextView.setText(String.format(getStringEntry(R.string.EncryptedPlaceholderTitleIncoming), currentUser.first_name)); + if (currentUser.first_name.length() > 0) { + secretViewStatusTextView.setText(String.format(getStringEntry(R.string.EncryptedPlaceholderTitleIncoming), currentUser.first_name)); + } else { + secretViewStatusTextView.setText(String.format(getStringEntry(R.string.EncryptedPlaceholderTitleIncoming), currentUser.last_name)); + } } updateSecretStatus(); @@ -1192,7 +1200,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa TLRPC.TL_video video = new TLRPC.TL_video(); video.thumb = size; video.caption = ""; - video.id = videoLocalId; + video.id = 0; video.path = videoPath; File temp = new File(videoPath); if (temp != null && temp.exists()) { @@ -2360,6 +2368,10 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } else if (selectedObject.type == 12 || selectedObject.type == 13) { TLRPC.User user = MessagesController.Instance.users.get(selectedObject.messageOwner.media.user_id); MessagesController.Instance.sendMessage(user, dialog_id); + } else if (selectedObject.type == 16 || selectedObject.type == 17) { + TLRPC.TL_document document = (TLRPC.TL_document)selectedObject.messageOwner.media.document; + document.path = selectedObject.messageOwner.attachPath; + MessagesController.Instance.sendMessage(document, dialog_id); } ArrayList arr = new ArrayList(); arr.add(selectedObject.messageOwner.id); @@ -2404,6 +2416,33 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } } + @Override + public void didSelectFile(DocumentSelectActivity activity, String path, String name, String ext, long size) { + activity.finishFragment(); + TLRPC.TL_document document = new TLRPC.TL_document(); + document.thumb = new TLRPC.TL_photoSizeEmpty(); + document.thumb.type = "s"; + document.id = 0; + document.user_id = UserConfig.clientUserId; + document.date = ConnectionsManager.Instance.getCurrentTime(); + document.file_name = name; + document.size = (int)size; + document.dc_id = 0; + document.path = path; + if (ext.length() != 0) { + MimeTypeMap myMime = MimeTypeMap.getSingleton(); + String mimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); + if (mimeType != null) { + document.mime_type = mimeType; + } else { + document.mime_type = "application/octet-stream"; + } + } else { + document.mime_type = "application/octet-stream"; + } + MessagesController.Instance.sendMessage(document, dialog_id); + } + @Override public void didSelectDialog(MessagesActivity activity, long did) { if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) { @@ -2537,6 +2576,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ((ApplicationActivity)parentActivity).presentFragment(fragment, "location", false); break; } + case R.id.attach_document: { + DocumentSelectActivity fragment = new DocumentSelectActivity(); + fragment.delegate = this; + ((ApplicationActivity)parentActivity).presentFragment(fragment, "document", false); + break; + } } return true; } @@ -2656,6 +2701,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } else if (messageType == 13) { holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states); holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0); + } else if (messageType == 16) { + holder.chatBubbleView.setBackgroundResource(R.drawable.chat_outgoing_text_states); + holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0); + } else if (messageType == 17) { + holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states); + holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0); } } else { if (messageType == 2 || messageType == 4 || messageType == 6) { @@ -2698,6 +2749,20 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in); } holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0); + } else if (messageType == 16) { + if (selected) { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out_selected); + } else { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out); + } + holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0); + } else if (messageType == 17) { + if (selected) { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in_selected); + } else { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in); + } + holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0); } } } @@ -2830,6 +2895,14 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } } else if (type == 15) { view = li.inflate(R.layout.chat_unread_layout, viewGroup, false); + } else if (type == 16) { + view = li.inflate(R.layout.chat_outgoing_document_layout, viewGroup, false); + } else if (type == 17) { + if (currentChat != null) { + view = li.inflate(R.layout.chat_group_incoming_document_layout, viewGroup, false); + } else { + view = li.inflate(R.layout.chat_incoming_document_layout, viewGroup, false); + } } } @@ -2871,6 +2944,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } else if (messageType == 13) { holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states); holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0); + } else if (messageType == 16) { + holder.chatBubbleView.setBackgroundResource(R.drawable.chat_outgoing_text_states); + holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0); + } else if (messageType == 17) { + holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states); + holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0); } } else { if (messageType == 2 || messageType == 4 || messageType == 6) { @@ -2913,6 +2992,20 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in); } holder.chatBubbleView.setPadding((int)(15 * displayDensity), (int)(6 * displayDensity), (int)(9 * displayDensity), 0); + } else if (messageType == 16) { + if (selected) { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out_selected); + } else { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out); + } + holder.chatBubbleView.setPadding((int)(9 * displayDensity), (int)(9 * displayDensity), (int)(18 * displayDensity), 0); + } else if (messageType == 17) { + if (selected) { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in_selected); + } else { + holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in); + } + holder.chatBubbleView.setPadding((int)(18 * displayDensity), (int)(9 * displayDensity), (int)(9 * displayDensity), 0); } } @@ -2939,7 +3032,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa @Override public int getViewTypeCount() { - return 16; + return 18; } @Override @@ -3014,7 +3107,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa avatarImageView.setImage(photo, "50_50", placeHolderId); } - if (type != 12 && type != 13 && nameTextView != null && fromUser != null) { + if (type != 12 && type != 13 && nameTextView != null && fromUser != null && type != 16 && type != 17) { nameTextView.setText(Utilities.formatName(fromUser.first_name, fromUser.last_name)); nameTextView.setTextColor(Utilities.getColorForId(message.messageOwner.from_id)); } @@ -3026,7 +3119,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } } else if (type == 2 || type == 3 || type == 6 || type == 7) { int width = (int)(Math.min(displaySize.x, displaySize.y) / 2.5f); - /*PhotoObject photo = PhotoObject.getClosestImageWithSize(message.photoThumbs, width, width + 100);*/ PhotoObject photo = PhotoObject.getClosestImageWithSize(message.photoThumbs, width, width + 100); if (photo != null) { @@ -3141,6 +3233,48 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } else { messageTextView.setText(String.format(getStringEntry(R.string.FewNewMessages), unread_to_load)); } + } else if (type == 16 || type == 17) { + TLRPC.Document document = message.messageOwner.media.document; + if (document instanceof TLRPC.TL_document || document instanceof TLRPC.TL_documentEncrypted) { + nameTextView.setText(message.messageOwner.media.document.file_name); + + String fileName = message.getFileName(); + int idx = fileName.lastIndexOf("."); + String ext = null; + if (idx != -1) { + ext = fileName.substring(idx + 1); + } + if (ext == null || ext.length() == 0) { + ext = message.messageOwner.media.document.mime_type; + } + ext = ext.toUpperCase(); + if (document.size < 1024) { + phoneTextView.setText(String.format("%d B %s", document.size, ext)); + } else if (document.size < 1024 * 1024) { + phoneTextView.setText(String.format("%.1f KB %s", document.size / 1024.0f, ext)); + } else { + phoneTextView.setText(String.format("%.1f MB %s", document.size / 1024.0f / 1024.0f, ext)); + } + if (document.thumb instanceof TLRPC.TL_photoSize) { + + } else if (document.thumb instanceof TLRPC.TL_photoCachedSize) { + + } else { + if (type == 16) { + contactAvatar.setImageResource(R.drawable.doc_green); + } else { + contactAvatar.setImageResource(R.drawable.doc_blue); + } + } + } else { + nameTextView.setText("Error"); + phoneTextView.setText("Error"); + if (type == 16) { + contactAvatar.setImageResource(R.drawable.doc_green); + } else { + contactAvatar.setImageResource(R.drawable.doc_blue); + } + } } if (message.messageOwner.id < 0 && message.messageOwner.send_state != MessagesController.MESSAGE_SEND_STATE_SENT) { @@ -3212,7 +3346,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } } } - if (message.type == 6 || message.type == 7) { + if (message.type == 6 || message.type == 7 || message.type == 16 || message.type == 17) { Integer tag = (Integer)actionProgress.getTag(); String file = progressByTag.get(tag); if (file != null) { @@ -3222,14 +3356,18 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa if (file != null) { progressBarMap.remove(file); } - String fileName = message.messageOwner.media.video.dc_id + "_" + message.messageOwner.media.video.id + ".mp4"; + String fileName = message.getFileName(); boolean load = false; if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) { File f = new File(message.messageOwner.attachPath); if (f.exists()) { actionAttachButton.setVisibility(View.VISIBLE); actionView.setVisibility(View.GONE); - actionAttachButton.setText(getStringEntry(R.string.ViewVideo)); + if (message.type == 6 || message.type == 7) { + actionAttachButton.setText(getStringEntry(R.string.ViewVideo)); + } else if (message.type == 16 || message.type == 17) { + actionAttachButton.setText(getStringEntry(R.string.Open)); + } } else { load = true; } @@ -3238,7 +3376,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa if (cacheFile.exists()) { actionAttachButton.setVisibility(View.VISIBLE); actionView.setVisibility(View.GONE); - actionAttachButton.setText(getStringEntry(R.string.ViewVideo)); + if (message.type == 6 || message.type == 7) { + actionAttachButton.setText(getStringEntry(R.string.ViewVideo)); + } else if (message.type == 16 || message.type == 17) { + actionAttachButton.setText(getStringEntry(R.string.Open)); + } } else { load = true; } @@ -3258,11 +3400,33 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } else { actionView.setVisibility(View.GONE); actionAttachButton.setVisibility(View.VISIBLE); - actionAttachButton.setText(String.format("%s %.1f MB", getStringEntry(R.string.DOWNLOAD), message.messageOwner.media.video.size / 1024.0f / 1024.0f)); + if (message.type == 6 || message.type == 7) { + actionAttachButton.setText(String.format("%s %.1f MB", getStringEntry(R.string.DOWNLOAD), message.messageOwner.media.video.size / 1024.0f / 1024.0f)); + } else if (message.type == 16 || message.type == 17) { + actionAttachButton.setText(getStringEntry(R.string.DOWNLOAD)); + } } } } } + if (message.type == 16 || message.type == 17) { + int width; + if (currentChat != null && type != 16) { + if (actionView.getVisibility() == View.VISIBLE) { + width = displaySize.x - (int)(290 * displayDensity); + } else { + width = displaySize.x - (int)(270 * displayDensity); + } + } else { + if (actionView.getVisibility() == View.VISIBLE) { + width = displaySize.x - (int)(240 * displayDensity); + } else { + width = displaySize.x - (int)(220 * displayDensity); + } + } + nameTextView.setMaxWidth(width); + phoneTextView.setMaxWidth(width); + } } public ChatListRowHolderEx(View view) { @@ -3343,16 +3507,20 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa contactView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (mActionMode != null) { - processRowSelect(view); - return; - } - if (message.messageOwner.media.user_id != UserConfig.clientUserId) { - UserProfileActivity fragment = new UserProfileActivity(); - Bundle args = new Bundle(); - args.putInt("user_id", message.messageOwner.media.user_id); - fragment.setArguments(args); - ((ApplicationActivity)parentActivity).presentFragment(fragment, "user_" + message.messageOwner.media.user_id, false); + if (message.type == 16 || message.type == 17) { + processOnClick(view); + } else if (message.type == 12 || message.type == 13) { + if (mActionMode != null) { + processRowSelect(view); + return; + } + if (message.messageOwner.media.user_id != UserConfig.clientUserId) { + UserProfileActivity fragment = new UserProfileActivity(); + Bundle args = new Bundle(); + args.putInt("user_id", message.messageOwner.media.user_id); + fragment.setArguments(args); + ((ApplicationActivity)parentActivity).presentFragment(fragment, "user_" + message.messageOwner.media.user_id, false); + } } } }); @@ -3370,83 +3538,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa actionAttachButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (mActionMode != null) { - processRowSelect(view); - return; - } - if (message != null) { - if (message.type == 4 || message.type == 5) { - if (!isGoogleMapsInstalled()) { - return; - } - NotificationCenter.Instance.addToMemCache(0, message); - LocationActivity fragment = new LocationActivity(); - ((ApplicationActivity)parentActivity).presentFragment(fragment, "location_view", false); - } else if (message.type == 2 || message.type == 3) { - NotificationCenter.Instance.addToMemCache(51, message); - Intent intent = new Intent(parentActivity, GalleryImageViewer.class); - startActivity(intent); - } else if (message.type == 6 || message.type == 7) { - boolean loadFile = false; - String fileName = message.messageOwner.media.video.dc_id + "_" + message.messageOwner.media.video.id + ".mp4"; - if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) { - File f = new File(message.messageOwner.attachPath); - if (f.exists()) { - try { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(f), "video/mp4"); - startActivity(intent); - } catch (Exception e) { - AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); - builder.setTitle(R.string.AppName); - builder.setMessage(R.string.NoPlayerInstalled); - visibleDialog = builder.show(); - visibleDialog.setCanceledOnTouchOutside(true); - visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - visibleDialog = null; - } - }); - } - } else { - loadFile = true; - } - } else { - File cacheFile = new File(Utilities.getCacheDir(), fileName); - if (cacheFile.exists()) { - try { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(cacheFile), "video/mp4"); - startActivity(intent); - } catch (Exception e) { - AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); - builder.setTitle(R.string.AppName); - builder.setMessage(R.string.NoPlayerInstalled); - visibleDialog = builder.show(); - visibleDialog.setCanceledOnTouchOutside(true); - - visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - visibleDialog = null; - } - }); - } - } else { - loadFile = true; - } - } - if (loadFile) { - if (!loadingFile.containsKey(fileName)) { - progressByTag.put((Integer)actionProgress.getTag(), fileName); - addToLoadingFile(fileName, actionProgress); - FileLoader.Instance.loadFile(message.messageOwner.media.video, null); - updateVisibleRows(); - } - } - } - } + processOnClick(view); } }); } @@ -3482,11 +3574,15 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa if (file != null) { progressBarMap.remove(file); } - } else if (message.type == 6 || message.type == 7) { + } else if (message.type == 6 || message.type == 7 || message.type == 16 || message.type == 17) { String file = progressByTag.get(tag); if (file != null) { loadingFile.remove(file); - FileLoader.Instance.cancelLoadFile(message.messageOwner.media.video, null); + if (message.type == 6 || message.type == 7) { + FileLoader.Instance.cancelLoadFile(message.messageOwner.media.video, null, null); + } else if (message.type == 16 || message.type == 17) { + FileLoader.Instance.cancelLoadFile(null, null, message.messageOwner.media.document); + } updateVisibleRows(); } } @@ -3499,88 +3595,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa photoImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (mActionMode != null) { - processRowSelect(view); - return; - } - if (message != null) { - if (message.type == 4 || message.type == 5) { - if (!isGoogleMapsInstalled()) { - return; - } - NotificationCenter.Instance.addToMemCache(0, message); - LocationActivity fragment = new LocationActivity(); - ((ApplicationActivity)parentActivity).presentFragment(fragment, "location_view", false); - } else if (message.type == 2 || message.type == 3) { - NotificationCenter.Instance.addToMemCache(51, message); - Intent intent = new Intent(parentActivity, GalleryImageViewer.class); - startActivity(intent); - } else if (message.type == 11) { - NotificationCenter.Instance.addToMemCache(51, message); - Intent intent = new Intent(parentActivity, GalleryImageViewer.class); - startActivity(intent); - } else if (message.type == 6 || message.type == 7) { - boolean loadFile = false; - String fileName = message.messageOwner.media.video.dc_id + "_" + message.messageOwner.media.video.id + ".mp4"; - if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) { - File f = new File(message.messageOwner.attachPath); - if (f.exists()) { - try { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(f), "video/mp4"); - startActivity(intent); - } catch (Exception e) { - AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); - builder.setTitle(R.string.AppName); - builder.setMessage(R.string.NoPlayerInstalled); - visibleDialog = builder.show(); - visibleDialog.setCanceledOnTouchOutside(true); - - visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - visibleDialog = null; - } - }); - } - } else { - loadFile = true; - } - } else { - File cacheFile = new File(Utilities.getCacheDir(), fileName); - if (cacheFile.exists()) { - try { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(cacheFile), "video/*"); - startActivity(intent); - } catch (Exception e) { - AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); - builder.setTitle(R.string.AppName); - builder.setMessage(R.string.NoPlayerInstalled); - visibleDialog = builder.show(); - visibleDialog.setCanceledOnTouchOutside(true); - - visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - visibleDialog = null; - } - }); - } - } else { - loadFile = true; - } - } - if (loadFile) { - if (!loadingFile.containsKey(fileName)) { - progressByTag.put((Integer)actionProgress.getTag(), fileName); - addToLoadingFile(fileName, actionProgress); - FileLoader.Instance.loadFile(message.messageOwner.media.video, null); - updateVisibleRows(); - } - } - } - } + processOnClick(view); } }); @@ -3609,5 +3624,96 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa }); } } + + private void processOnClick(View view) { + if (mActionMode != null) { + processRowSelect(view); + return; + } + if (message != null) { + if (message.type == 4 || message.type == 5) { + if (!isGoogleMapsInstalled()) { + return; + } + NotificationCenter.Instance.addToMemCache(0, message); + LocationActivity fragment = new LocationActivity(); + ((ApplicationActivity)parentActivity).presentFragment(fragment, "location_view", false); + } else if (message.type == 2 || message.type == 3) { + NotificationCenter.Instance.addToMemCache(51, message); + Intent intent = new Intent(parentActivity, GalleryImageViewer.class); + startActivity(intent); + } else if (message.type == 11) { + NotificationCenter.Instance.addToMemCache(51, message); + Intent intent = new Intent(parentActivity, GalleryImageViewer.class); + startActivity(intent); + } else if (message.type == 6 || message.type == 7 || message.type == 16 || message.type == 17) { + File f = null; + String fileName = message.getFileName(); + if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) { + f = new File(message.messageOwner.attachPath); + } else { + f = new File(Utilities.getCacheDir(), fileName); + } + if (f != null && f.exists()) { + try { + Intent intent = new Intent(Intent.ACTION_VIEW); + if (message.type == 6 || message.type == 7) { + intent.setDataAndType(Uri.fromFile(f), "video/mp4"); + } else if (message.type == 16 || message.type == 17) { + MimeTypeMap myMime = MimeTypeMap.getSingleton(); + int idx = fileName.lastIndexOf("."); + if (idx != -1) { + String ext = fileName.substring(idx + 1); + String mimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); + if (mimeType != null) { + intent.setDataAndType(Uri.fromFile(f), mimeType); + } else { + intent.setDataAndType(Uri.fromFile(f), "text/plain"); + } + } else { + intent.setDataAndType(Uri.fromFile(f), "text/plain"); + } + } + startActivity(intent); + } catch (Exception e) { + AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); + builder.setTitle(R.string.AppName); + builder.setPositiveButton(R.string.OK, null); + if (message.type == 6 || message.type == 7) { + builder.setMessage(R.string.NoPlayerInstalled); + } else { + builder.setMessage(String.format(getStringEntry(R.string.NoHandleAppInstalled), message.messageOwner.media.document.mime_type)); + } + visibleDialog = builder.show(); + visibleDialog.setCanceledOnTouchOutside(true); + + visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + visibleDialog = null; + } + }); + } + } else { + if (message.messageOwner.send_state != MessagesController.MESSAGE_SEND_STATE_SEND_ERROR && message.messageOwner.send_state != MessagesController.MESSAGE_SEND_STATE_SENDING || !message.messageOwner.out) { + if (!loadingFile.containsKey(fileName)) { + progressByTag.put((Integer)actionProgress.getTag(), fileName); + addToLoadingFile(fileName, actionProgress); + if (message.type == 6 || message.type == 7) { + FileLoader.Instance.loadFile(message.messageOwner.media.video, null, null); + } else if (message.type == 16 || message.type == 17) { + FileLoader.Instance.loadFile(null, null, message.messageOwner.media.document); + } + updateVisibleRows(); + } + } else { + if (message.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) { + createMenu(view, false); + } + } + } + } + } + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java new file mode 100644 index 000000000..5d9937219 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -0,0 +1,475 @@ +/* + * 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.app.AlertDialog; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.os.StatFs; +import android.support.v7.app.ActionBar; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.TextView; + +import org.telegram.messenger.FileLog; +import org.telegram.messenger.R; +import org.telegram.messenger.Utilities; +import org.telegram.ui.Views.BackupImageView; +import org.telegram.ui.Views.BaseFragment; +import org.telegram.ui.Views.OnSwipeTouchListener; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; + +public class DocumentSelectActivity extends BaseFragment { + + public static abstract interface DocumentSelectActivityDelegate { + public void didSelectFile(DocumentSelectActivity activity, String path, String name, String ext, long size); + } + + private ListView listView; + private ListAdapter listAdapter; + private File currentDir; + private TextView emptyView; + private ArrayList items = new ArrayList(); + private boolean receiverRegistered = false; + private ArrayList history = new ArrayList(); + private long sizeLimit = 1024 * 1024 * 1024; + public DocumentSelectActivityDelegate delegate; + + private class ListItem { + int icon; + String title; + String subtitle = ""; + String ext = ""; + String thumb; + File file; + } + + private class HistoryEntry { + int scrollItem, scrollOffset; + File dir; + String title; + } + + private BroadcastReceiver receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context arg0, Intent intent) { + Runnable r = new Runnable() { + public void run() { + if (currentDir == null){ + listRoots(); + } else { + listFiles(currentDir); + } + } + }; + if (Intent.ACTION_MEDIA_UNMOUNTED.equals(intent.getAction())) { + listView.postDelayed(r, 1000); + } else { + r.run(); + } + } + }; + + @Override + public boolean onFragmentCreate() { + super.onFragmentCreate(); + return true; + } + + @Override + public void onFragmentDestroy() { + if (receiverRegistered) { + parentActivity.unregisterReceiver(receiver); + } + super.onFragmentDestroy(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setHasOptionsMenu(true); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + if (!receiverRegistered) { + receiverRegistered = true; + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL); + filter.addAction(Intent.ACTION_MEDIA_CHECKING); + filter.addAction(Intent.ACTION_MEDIA_EJECT); + filter.addAction(Intent.ACTION_MEDIA_MOUNTED); + filter.addAction(Intent.ACTION_MEDIA_NOFS); + filter.addAction(Intent.ACTION_MEDIA_REMOVED); + filter.addAction(Intent.ACTION_MEDIA_SHARED); + filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE); + filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); + filter.addDataScheme("file"); + parentActivity.registerReceiver(receiver, filter); + } + + if (fragmentView == null) { + fragmentView = inflater.inflate(R.layout.document_select_layout, container, false); + listAdapter = new ListAdapter(parentActivity); + emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); + listView = (ListView)fragmentView.findViewById(R.id.listView); + listView.setEmptyView(emptyView); + listView.setAdapter(listAdapter); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + ListItem item = items.get(i); + File file = item.file; + if (file.isDirectory()) { + HistoryEntry he = new HistoryEntry(); + he.scrollItem = listView.getFirstVisiblePosition(); + he.scrollOffset = listView.getChildAt(0).getTop(); + he.dir = currentDir; + ActionBar actionBar = parentActivity.getSupportActionBar(); + he.title = actionBar.getTitle().toString(); + if (!listFiles(file)){ + return; + } + history.add(he); + actionBar.setTitle(item.title); + listView.setSelection(0); + } else { + if (!file.canRead()) { + showErrorBox(getString(R.string.AccessError)); + return; + } + if (sizeLimit != 0) { + if (file.length() > sizeLimit) { + showErrorBox(getString(R.string.FileUploadLimit, Utilities.formatFileSize(sizeLimit))); + return; + } + } + if (file.length() == 0) { + return; + } + if (delegate != null) { + delegate.didSelectFile(DocumentSelectActivity.this, file.getAbsolutePath(), item.title, item.ext, file.length()); + } + } + } + }); + + listView.setOnTouchListener(new OnSwipeTouchListener() { + public void onSwipeRight() { + finishFragment(true); + } + }); + listRoots(); + } else { + ViewGroup parent = (ViewGroup)fragmentView.getParent(); + if (parent != null) { + parent.removeView(fragmentView); + } + } + return fragmentView; + } + + @Override + public void applySelfActionBar() { + if (parentActivity == null) { + return; + } + ActionBar actionBar = parentActivity.getSupportActionBar(); + actionBar.setDisplayShowTitleEnabled(true); + actionBar.setDisplayShowHomeEnabled(false); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayUseLogoEnabled(false); + actionBar.setDisplayShowCustomEnabled(false); + actionBar.setSubtitle(null); + actionBar.setCustomView(null); + actionBar.setTitle(getStringEntry(R.string.SelectFile)); + + TextView title = (TextView)parentActivity.findViewById(R.id.action_bar_title); + if (title == null) { + final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); + title = (TextView)parentActivity.findViewById(subtitleId); + } + if (title != null) { + title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + title.setCompoundDrawablePadding(0); + } + } + + @Override + public void onResume() { + super.onResume(); + if (isFinish) { + return; + } + if (getActivity() == null) { + return; + } + if (!firstStart && listAdapter != null) { + listAdapter.notifyDataSetChanged(); + } + firstStart = false; + ((ApplicationActivity)parentActivity).showActionBar(); + ((ApplicationActivity)parentActivity).updateActionBar(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int itemId = item.getItemId(); + switch (itemId) { + case android.R.id.home: + finishFragment(); + break; + } + return true; + } + + @Override + public boolean onBackPressed() { + if (history.size() > 0){ + HistoryEntry he = history.remove(history.size() - 1); + ActionBar actionBar = parentActivity.getSupportActionBar(); + actionBar.setTitle(he.title); + if (he.dir != null) { + listFiles(he.dir); + } else { + listRoots(); + } + listView.setSelectionFromTop(he.scrollItem, he.scrollOffset); + return false; + } + return super.onBackPressed(); + } + + private boolean listFiles(File dir) { + if (!dir.canRead()) { + if (dir.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().toString()) + || dir.getAbsolutePath().startsWith("/sdcard") + || dir.getAbsolutePath().startsWith("/mnt/sdcard")) { + if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) + && !Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { + currentDir = dir; + items.clear(); + String state = Environment.getExternalStorageState(); + if (Environment.MEDIA_SHARED.equals(state)){ + emptyView.setText(R.string.UsbActive); + } else { + emptyView.setText(R.string.NotMounted); + } + listAdapter.notifyDataSetChanged(); + return true; + } + } + showErrorBox(getString(R.string.AccessError)); + return false; + } + emptyView.setText(R.string.NoFiles); + File[] files = null; + try { + files = dir.listFiles(); + } catch(Exception e) { + showErrorBox(e.getLocalizedMessage()); + return false; + } + if (files == null) { + showErrorBox(getString(R.string.UnknownError)); + return false; + } + currentDir = dir; + items.clear(); + Arrays.sort(files, new Comparator() { + @Override + public int compare(File lhs, File rhs) { + if (lhs.isDirectory() != rhs.isDirectory()) { + return lhs.isDirectory() ? -1 : 1; + } + return lhs.getName().compareToIgnoreCase(rhs.getName()); + } + }); + for (File file : files) { + if (file.getName().startsWith(".")) { + continue; + } + ListItem item = new ListItem(); + item.title = file.getName(); + item.file = file; + if (file.isDirectory()) { + item.icon = R.drawable.ic_directory; + } else { + String fname = file.getName(); + String[] sp = fname.split("\\."); + item.ext = sp.length > 1 ? sp[sp.length - 1] : "?"; + item.subtitle = Utilities.formatFileSize(file.length()); + fname = fname.toLowerCase(); + if (fname.endsWith(".jpg") || fname.endsWith(".png") || fname.endsWith(".gif") || fname.endsWith(".jpeg")) { + item.thumb = file.getAbsolutePath(); + } + } + items.add(item); + } + listAdapter.notifyDataSetChanged(); + return true; + } + + private void showErrorBox(String error){ + new AlertDialog.Builder(parentActivity) + .setTitle(R.string.AppName) + .setMessage(error) + .setPositiveButton(R.string.OK, null) + .show(); + } + + private void listRoots() { + currentDir = null; + items.clear(); + String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath(); + ListItem ext = new ListItem(); + ext.title = getString(Build.VERSION.SDK_INT < 9 || Environment.isExternalStorageRemovable() ? R.string.SdCard : R.string.InternalStorage); + ext.icon = Build.VERSION.SDK_INT < 9 || Environment.isExternalStorageRemovable() ? R.drawable.ic_external_storage : R.drawable.ic_storage; + ext.subtitle = getRootSubtitle(extStorage); + ext.file = Environment.getExternalStorageDirectory(); + items.add(ext); + try { + BufferedReader reader = new BufferedReader(new FileReader("/proc/mounts")); + String line; + HashMap> aliases = new HashMap>(); + ArrayList result = new ArrayList(); + String extDevice = null; + while ((line = reader.readLine()) != null) { + if ((!line.contains("/mnt") && !line.contains("/storage") && !line.contains("/sdcard")) || line.contains("asec") || line.contains("tmpfs") || line.contains("none")) { + continue; + } + String[] info = line.split(" "); + if (!aliases.containsKey(info[0])) { + aliases.put(info[0], new ArrayList()); + } + aliases.get(info[0]).add(info[1]); + if (info[1].equals(extStorage)) { + extDevice=info[0]; + } + result.add(info[1]); + } + reader.close(); + if (extDevice != null) { + result.removeAll(aliases.get(extDevice)); + for (String path : result) { + boolean isSd = path.toLowerCase().contains("sd"); + ListItem item = new ListItem(); + item.title = getString(isSd ? R.string.SdCard : R.string.ExternalStorage); + item.icon = R.drawable.ic_external_storage; + item.subtitle = getRootSubtitle(path); + item.file = new File(path); + items.add(item); + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + ListItem fs = new ListItem(); + fs.title = "/"; + fs.subtitle = getString(R.string.SystemRoot); + fs.icon = R.drawable.ic_directory; + fs.file = new File("/"); + items.add(fs); + listAdapter.notifyDataSetChanged(); + } + + private String getRootSubtitle(String path){ + StatFs stat = new StatFs(path); + long total = (long)stat.getBlockCount() * (long)stat.getBlockSize(); + long free = (long)stat.getAvailableBlocks() * (long)stat.getBlockSize(); + if (total == 0) { + return ""; + } + return getString(R.string.FreeOfTotal, Utilities.formatFileSize(free), Utilities.formatFileSize(total)); + } + + private class ListAdapter extends BaseAdapter { + private Context mContext; + + public ListAdapter(Context context) { + mContext = context; + } + + @Override + public int getCount() { + return items.size(); + } + + @Override + public Object getItem(int position) { + return items.get(position); + } + + @Override + public long getItemId(int position) { + return 0; + } + + public int getViewTypeCount(){ + return 2; + } + + public int getItemViewType(int pos){ + return items.get(pos).subtitle.length() > 0 ? 0 : 1; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + View v = convertView; + ListItem item = items.get(position); + if (v == null) { + v = View.inflate(mContext, R.layout.document_item, null); + if (item.subtitle.length() == 0) { + v.findViewById(R.id.docs_item_info).setVisibility(View.GONE); + } + } + TextView typeTextView = (TextView)v.findViewById(R.id.docs_item_type); + ((TextView)v.findViewById(R.id.docs_item_title)).setText(item.title); + + ((TextView)v.findViewById(R.id.docs_item_info)).setText(item.subtitle); + BackupImageView imageView = (BackupImageView)v.findViewById(R.id.docs_item_thumb); + if (item.thumb != null) { + imageView.setImageBitmap(null); + typeTextView.setText(item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4))); + imageView.setImage(item.thumb, "55_42", 0); + imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + imageView.setVisibility(View.VISIBLE); + typeTextView.setVisibility(View.VISIBLE); + } else if (item.icon != 0) { + imageView.setImageResource(item.icon); + imageView.setScaleType(ImageView.ScaleType.CENTER); + imageView.setVisibility(View.VISIBLE); + typeTextView.setVisibility(View.GONE); + } else { + typeTextView.setText(item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4))); + imageView.setVisibility(View.GONE); + typeTextView.setVisibility(View.VISIBLE); + } + return v; + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GalleryImageViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/GalleryImageViewer.java index 6356db688..cc30936b3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GalleryImageViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GalleryImageViewer.java @@ -924,9 +924,9 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif } if (loadFile) { if (!FileLoader.Instance.isLoadingFile(fileName)) { - FileLoader.Instance.loadFile(message.messageOwner.media.video, null); + FileLoader.Instance.loadFile(message.messageOwner.media.video, null, null); } else { - FileLoader.Instance.cancelLoadFile(message.messageOwner.media.video, null); + FileLoader.Instance.cancelLoadFile(message.messageOwner.media.video, null, null); } checkCurrentFile(); processViews(playButton, message); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java index 47d948b2c..6cffca0e9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java @@ -292,8 +292,6 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI updatePhoneField(); } - - @Override public void onNothingSelected(AdapterView adapterView) { @@ -303,8 +301,8 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI public void onNextPressed() { TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode(); String phone = PhoneFormat.stripExceptNumbers("" + codeField.getText() + phoneField.getText()); - req.api_hash = "5bce48dc7d331e62c955669eb7233217"; - req.api_id = 2458; + req.api_hash = ConnectionsManager.APP_HASH; + req.api_id = ConnectionsManager.APP_ID; req.sms_type = 0; req.phone_number = phone; req.lang_code = Locale.getDefault().getCountry(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index a2bb05447..44debb60f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -382,7 +382,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No BackupImageView imageView = (BackupImageView)view.findViewById(R.id.media_photo_image); - if (message.messageOwner.media.photo != null && !message.messageOwner.media.photo.sizes.isEmpty()) { + if (message.messageOwner.media != null && message.messageOwner.media.photo != null && !message.messageOwner.media.photo.sizes.isEmpty()) { ArrayList sizes = message.messageOwner.media.photo.sizes; boolean set = false; // for (TLRPC.PhotoSize size : sizes) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index 0f5b2845c..de8a6c29e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -102,7 +102,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter blockedRow = rowCount++; backgroundRow = rowCount++; supportSectionRow = rowCount++; - if (FileLog.DEBUG_VERSION) { + if (ConnectionsManager.DEBUG_VERSION) { sendLogsRow = rowCount++; } askQuestionRow = rowCount++; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java index d789666ff..d719b5739 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java @@ -248,11 +248,11 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica progressBar.setVisibility(View.VISIBLE); loadingSize = size; selectedColor = 0; - FileLoader.Instance.loadFile(null, size); + FileLoader.Instance.loadFile(null, size, null); backgroundImage.setBackgroundColor(0); } else { if (loadingFile != null) { - FileLoader.Instance.cancelLoadFile(null, loadingSize); + FileLoader.Instance.cancelLoadFile(null, loadingSize, null); } loadingFileObject = null; loadingFile = null; @@ -265,7 +265,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica } } else { if (loadingFile != null) { - FileLoader.Instance.cancelLoadFile(null, loadingSize); + FileLoader.Instance.cancelLoadFile(null, loadingSize, null); } if (selectedBackground == 1000001) { backgroundImage.setImageResource(R.drawable.background_hd); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/FrameLayoutFixed.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/FrameLayoutFixed.java index fc676acff..73bcd9dcd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/FrameLayoutFixed.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/FrameLayoutFixed.java @@ -150,6 +150,7 @@ public class FrameLayoutFixed extends FrameLayout { } } catch (Exception e) { FileLog.e("tmessages", e); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/NiceSupportMapFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/NiceSupportMapFragment.java deleted file mode 100644 index 59a0608a6..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/NiceSupportMapFragment.java +++ /dev/null @@ -1,155 +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.annotation.SuppressLint; -import android.graphics.PixelFormat; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.TextureView; -import android.view.View; -import android.view.View.OnTouchListener; -import android.view.ViewGroup; - -import com.google.android.gms.maps.SupportMapFragment; - -public class NiceSupportMapFragment extends SupportMapFragment { - - private View drawingView; - private boolean hasTextureViewSupport = false; - private boolean preventParentScrolling = true; - - private boolean textureViewSupport() { - boolean exist = true; - try { - Class.forName("android.view.TextureView"); - } catch (ClassNotFoundException e) { - exist = false; - } - return exist; - } - - private View searchAndFindDrawingView(ViewGroup group) { - int childCount = group.getChildCount(); - for (int i = 0; i < childCount; i++) { - View child = group.getChildAt(i); - if (child instanceof ViewGroup) { - View view = searchAndFindDrawingView((ViewGroup) child); - - if (view != null) { - return view; - } - } - - if (child instanceof SurfaceView) { - return (View) child; - } - - if (hasTextureViewSupport) { // if we have support for texture view - if (child instanceof TextureView) { - return (View) child; - } - } - } - return null; - } - - @SuppressLint("NewApi") - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - ViewGroup view = (ViewGroup) super.onCreateView(inflater, container, - savedInstanceState); - view.setBackgroundColor(0x00000000); // Set Root View to be transparent - // to prevent black screen on - // load - - hasTextureViewSupport = textureViewSupport(); // Find out if we support - // texture view on this - // device - drawingView = searchAndFindDrawingView(view); // Find the view the map - // is using for Open GL - - if (drawingView == null) - return view; // If we didn't get anything then abort - - drawingView.setBackgroundColor(0x00000000); // Stop black artifact from - // being left behind on - // scroll - - // Create On Touch Listener for MapView Parent Scrolling Fix - Many thanks to Gemerson Ribas (gmribas) for help with this fix. - OnTouchListener touchListener = new OnTouchListener() { - public boolean onTouch(View view, MotionEvent event) { - - int action = event.getAction(); - - switch (action) { - - case MotionEvent.ACTION_DOWN: - // Disallow Parent to intercept touch events. - view.getParent().requestDisallowInterceptTouchEvent(preventParentScrolling); - break; - - case MotionEvent.ACTION_UP: - // Allow Parent to intercept touch events. - view.getParent().requestDisallowInterceptTouchEvent(!preventParentScrolling); - break; - - } - - // Handle View touch events. - view.onTouchEvent(event); - return false; - } - }; - - // texture view - if (hasTextureViewSupport) { // If we support texture view and the - // drawing view is a TextureView then - // tweak it and return the fragment view - - if (drawingView instanceof TextureView) { - - TextureView textureView = (TextureView) drawingView; - - // Stop Containing Views from moving when a user is interacting - // with Map View Directly - textureView.setOnTouchListener(touchListener); - - return view; - } - - } - - // Otherwise continue onto legacy surface view hack - final SurfaceView surfaceView = (SurfaceView) drawingView; - - // Fix for reducing black view flash issues - SurfaceHolder holder = surfaceView.getHolder(); - holder.setFormat(PixelFormat.RGB_888); - - // Stop Containing Views from moving when a user is interacting with - // Map View Directly - surfaceView.setOnTouchListener(touchListener); - - return view; - } - - public boolean getPreventParentScrolling() { - return preventParentScrolling; - } - - public void setPreventParentScrolling(boolean value) { - preventParentScrolling = value; - } - -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/TightTextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/TightTextView.java index 59d45b81b..f4ed8c2df 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/TightTextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/TightTextView.java @@ -87,6 +87,8 @@ public class TightTextView extends TextView { if (w < getMeasuredWidth()) { super.onMeasure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.AT_MOST), heightMeasureSpec); } + } else { + super.onMeasure(MeasureSpec.makeMeasureSpec(Math.min(maxWidth, linesMaxWidth), MeasureSpec.AT_MOST), heightMeasureSpec); } } } @@ -99,6 +101,7 @@ public class TightTextView extends TextView { public void setMaxWidth(int maxpixels) { super.setMaxWidth(maxpixels); hasMaxWidth = true; + maxWidth = maxpixels; } @Override diff --git a/TMessagesProj/src/main/res/drawable-hdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/doc_blue.png new file mode 100755 index 000000000..c9cd69113 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-hdpi/doc_green.png new file mode 100755 index 000000000..890cc33fb Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_doc.png new file mode 100644 index 000000000..30ff62d19 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_doc.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png new file mode 100644 index 000000000..0d999eeab Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/ic_directory.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png new file mode 100644 index 000000000..6b6f61138 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/ic_external_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png new file mode 100644 index 000000000..696acc689 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/ic_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/doc_blue.png new file mode 100755 index 000000000..d39e47fe4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doc_green.png b/TMessagesProj/src/main/res/drawable-ldpi/doc_green.png new file mode 100755 index 000000000..d279bca65 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_doc.png new file mode 100644 index 000000000..6f5029f42 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_doc.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/doc_blue.png new file mode 100755 index 000000000..69b5351ea Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-mdpi/doc_green.png new file mode 100755 index 000000000..ebb8cbf7a Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_doc.png new file mode 100644 index 000000000..da7ea4e34 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_doc.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png new file mode 100644 index 000000000..d3359460d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/ic_directory.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png new file mode 100644 index 000000000..d66145888 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/ic_external_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png new file mode 100644 index 000000000..7bc0ddab5 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/ic_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue.png new file mode 100755 index 000000000..f8cfa704a Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/doc_green.png new file mode 100755 index 000000000..ff5df25e4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_doc.png new file mode 100644 index 000000000..aaa8b4178 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_doc.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png new file mode 100644 index 000000000..4c99f9877 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_directory.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png new file mode 100644 index 000000000..3280482f6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_external_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png new file mode 100644 index 000000000..6aba104d9 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue.png new file mode 100755 index 000000000..f9e72f34d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_green.png new file mode 100755 index 000000000..e7d32c22e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_doc.png new file mode 100644 index 000000000..7a1992659 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_doc.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png new file mode 100644 index 000000000..91b4d6cb6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_directory.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png new file mode 100644 index 000000000..44304c6ce Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_external_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png new file mode 100644 index 000000000..a19c0aa88 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_storage.png differ diff --git a/TMessagesProj/src/main/res/drawable/photo_progress_chat.xml b/TMessagesProj/src/main/res/drawable/photo_progress_chat.xml new file mode 100644 index 000000000..e0d1896b5 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/photo_progress_chat.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout-ar/document_item.xml b/TMessagesProj/src/main/res/layout-ar/document_item.xml new file mode 100644 index 000000000..d83e00d30 --- /dev/null +++ b/TMessagesProj/src/main/res/layout-ar/document_item.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/chat_group_incoming_contact_layout.xml b/TMessagesProj/src/main/res/layout/chat_group_incoming_contact_layout.xml index e626c8c71..f86882572 100644 --- a/TMessagesProj/src/main/res/layout/chat_group_incoming_contact_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_group_incoming_contact_layout.xml @@ -16,6 +16,7 @@ android:id="@+id/chat_group_avatar_image" android:scaleType="fitCenter" android:layout_marginBottom="2dp" + android:layout_marginRight="4dp" android:layout_gravity="bottom"/> - diff --git a/TMessagesProj/src/main/res/layout/chat_group_incoming_document_layout.xml b/TMessagesProj/src/main/res/layout/chat_group_incoming_document_layout.xml new file mode 100644 index 000000000..92c29c4db --- /dev/null +++ b/TMessagesProj/src/main/res/layout/chat_group_incoming_document_layout.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/chat_group_incoming_video_layout.xml b/TMessagesProj/src/main/res/layout/chat_group_incoming_video_layout.xml index 80a33fc42..ac594232d 100644 --- a/TMessagesProj/src/main/res/layout/chat_group_incoming_video_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_group_incoming_video_layout.xml @@ -130,12 +130,13 @@ diff --git a/TMessagesProj/src/main/res/layout/chat_incoming_contact_layout.xml b/TMessagesProj/src/main/res/layout/chat_incoming_contact_layout.xml index b38a36681..946a2649c 100644 --- a/TMessagesProj/src/main/res/layout/chat_incoming_contact_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_incoming_contact_layout.xml @@ -2,7 +2,6 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/chat_incoming_forward_layout.xml b/TMessagesProj/src/main/res/layout/chat_incoming_forward_layout.xml index a4d518a4b..7ef566b04 100644 --- a/TMessagesProj/src/main/res/layout/chat_incoming_forward_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_incoming_forward_layout.xml @@ -16,15 +16,16 @@ android:id="@+id/message_layout" android:layout_gravity="top|left"> - + - diff --git a/TMessagesProj/src/main/res/layout/chat_layout.xml b/TMessagesProj/src/main/res/layout/chat_layout.xml index fd58fb826..3098d1a7d 100644 --- a/TMessagesProj/src/main/res/layout/chat_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_layout.xml @@ -28,7 +28,7 @@ android:textSize="14dp" android:id="@+id/searchEmptyView" android:visibility="gone" - android:layout_centerInParent="true"/> + android:layout_gravity="center"/> + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/chat_outgoing_document_layout.xml b/TMessagesProj/src/main/res/layout/chat_outgoing_document_layout.xml new file mode 100644 index 000000000..1845e7a8f --- /dev/null +++ b/TMessagesProj/src/main/res/layout/chat_outgoing_document_layout.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/chat_outgoing_photo_layout.xml b/TMessagesProj/src/main/res/layout/chat_outgoing_photo_layout.xml index 5416e6d16..cb6b899b7 100644 --- a/TMessagesProj/src/main/res/layout/chat_outgoing_photo_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_outgoing_photo_layout.xml @@ -15,7 +15,7 @@ android:layout_marginRight="10dp" android:id="@+id/chat_view_action_layout" android:layout_gravity="center" - android:visibility="visible"> + android:visibility="gone"> @@ -55,7 +56,8 @@ android:clickable="true" android:gravity="center" android:textStyle="bold" - android:layout_gravity="center"/> + android:layout_gravity="center" + android:visibility="gone"/> diff --git a/TMessagesProj/src/main/res/layout/document_item.xml b/TMessagesProj/src/main/res/layout/document_item.xml new file mode 100644 index 000000000..aa20aba2b --- /dev/null +++ b/TMessagesProj/src/main/res/layout/document_item.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/document_select_layout.xml b/TMessagesProj/src/main/res/layout/document_select_layout.xml new file mode 100644 index 000000000..bb2811e8a --- /dev/null +++ b/TMessagesProj/src/main/res/layout/document_select_layout.xml @@ -0,0 +1,28 @@ + + + + + + + diff --git a/TMessagesProj/src/main/res/menu/chat_menu.xml b/TMessagesProj/src/main/res/menu/chat_menu.xml index 3a17931b7..f817aaadb 100644 --- a/TMessagesProj/src/main/res/menu/chat_menu.xml +++ b/TMessagesProj/src/main/res/menu/chat_menu.xml @@ -24,6 +24,11 @@ android:title="@string/ChatVideo" android:id="@+id/attach_video"/> + + لقد قمت بالدخول للمحادثة السرية. مسح سجل التاريخ حذف وخروج + + + اختر ملف + متاح %1$s من %2$s + حدث خطأ غير معروف + خطأ في الوصول + لا يوجد ملفات بعد... + حجم الملف لا يمكن أن يكون أكبر من %1$s + الذاكرة غير مثبتة + نقل اليو إس بي مفعل + الذاكرة الداخلية + الذاكرة الخارجية + جذر النظام + بطاقة الذاكرة مخفي @@ -59,6 +73,7 @@ صورة موقع مقطع مرئي + مستند ...لا توجد رسائل بعد عرض الصورة عرض الموقع @@ -105,12 +120,16 @@ %1$s قام بإرسال مقطع مرئي لك %1$s قام بإرسال جهة اتصال لك %1$s قام بإرسال خريطة لك + %1$s قام بإرسال مستند لك + %1$s قام بإرسال مقطع صوتي لك %1$s @ %2$s: %3$s %1$s قام بإرسال رسالة للمجموعة %2$s %1$s قام بإرسال صورة للمجموعة %2$s %1$s قام بإرسال مقطع مرئي للمجموعة %2$s %1$s قام بإرسال جهة اتصال للمجموعة %2$s %1$s قام بإرسال خريطة للمجموعة %2$s + %1$s قام بإرسال مستند للمجموعة %2$s + %1$s قام بإرسال مقطع صوتي للمجموعة %2$s %1$s قام بدعوتك للمجموعة %2$s %1$s قام بتعديل اسم المجموعة %2$s %1$s قام بتغيير صورة المجموعة %2$s @@ -235,6 +254,7 @@ التالي رجوع تم + فتح إلغاء إضافة تعديل @@ -264,6 +284,8 @@ مقطع مرئي موقع جهة اتصال + مستند + مقطع صوتي أنت @@ -275,6 +297,7 @@ اسم العائلة غير صحيح جاري التحميل ... ليس لديك أي مشغل مقاطع مرئية، يرجى تنزيل أية مشغل + لا يوجد لديك تطبيق يمكنه فته هذا المستند، يرجى تنزيل تطبيق يمكنه للإستمرار هذا المستخدم ليس لديه تيليجرام بعد ، هل ترغب في دعوته الآن؟ هل أنت متأكد؟ هل تريد حذف هذه الدردشة؟ diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 90385a1b9..c271755d9 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -47,6 +47,20 @@ Clear History Delete and Exit + + Select File + Free %1$s of %2$s + Unknown error + Access error + No files yet... + File size shouldn\'t be greater than %1$s + Storage not mounted + Usb transfer active + Internal Storage + External Storage + System Root + SD Card + invisible typing... @@ -59,6 +73,7 @@ Gallery Location Video + Document No messages here yet... View Photo View Location @@ -105,12 +120,16 @@ %1$s sent you a video %1$s shared a contact with you %1$s sent you a map + %1$s sent you a document + %1$s sent you an audio %1$s @ %2$s: %3$s %1$s sent a message to the group %2$s %1$s sent a photo to the group %2$s %1$s sent a video to the group %2$s %1$s shared a contact in the group %2$s %1$s sent a map to the group %2$s + %1$s sent a document to the group %2$s + %1$s sent an audio to the group %2$s %1$s invited you to the group %2$s %1$s edited the group\'s %2$s name %1$s edited the group\'s %2$s photo @@ -235,6 +254,7 @@ Next Back Done + Open Cancel Add Edit @@ -264,6 +284,8 @@ Video Location Contact + Document + Audio You @@ -275,6 +297,7 @@ Invalid last name Loading... You don\'t have a video player, please install one to continue + You don\'t have any application that can handle with mime type \'%1$s\', please install one to continue This user does not have Telegram yet, send an invitation? Are you sure? Add contact?