diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 3b892e53..f2af8c94 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -13,11 +13,10 @@ repositories { } dependencies { - compile 'com.android.support:support-v4:22.0.+' + compile 'com.android.support:support-v4:22.1.+' compile 'com.google.android.gms:play-services:3.2.+' compile 'net.hockeyapp.android:HockeySDK:3.5.+' compile 'com.googlecode.mp4parser:isoparser:1.0.+' - compile 'com.android.support:recyclerview-v7:+' } android { @@ -89,7 +88,7 @@ android { applicationId "org.telegram.plus" minSdkVersion 8 targetSdkVersion 22 - versionCode 492 - versionName "2.7.0.1" + versionCode 524 + versionName "2.8.1.4" } } diff --git a/TMessagesProj/config/debug/AndroidManifest.xml b/TMessagesProj/config/debug/AndroidManifest.xml index 7c386826..8c5a54fe 100644 --- a/TMessagesProj/config/debug/AndroidManifest.xml +++ b/TMessagesProj/config/debug/AndroidManifest.xml @@ -15,13 +15,11 @@ - - + + + + diff --git a/TMessagesProj/config/release/AndroidManifest.xml b/TMessagesProj/config/release/AndroidManifest.xml index bce6ffd5..e4f770bb 100644 --- a/TMessagesProj/config/release/AndroidManifest.xml +++ b/TMessagesProj/config/release/AndroidManifest.xml @@ -14,11 +14,11 @@ - + + + + diff --git a/TMessagesProj/jni/Android.mk b/TMessagesProj/jni/Android.mk index f9b84ba9..19183707 100755 --- a/TMessagesProj/jni/Android.mk +++ b/TMessagesProj/jni/Android.mk @@ -104,7 +104,7 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_PRELINK_MODULE := false LOCAL_STATIC_LIBRARIES := webp sqlite -LOCAL_MODULE := tmessages.7 +LOCAL_MODULE := tmessages.8 LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math diff --git a/TMessagesProj/jni/image.c b/TMessagesProj/jni/image.c index 85a85900..a3a0fb86 100644 --- a/TMessagesProj/jni/image.c +++ b/TMessagesProj/jni/image.c @@ -288,7 +288,7 @@ METHODDEF(void) my_error_exit(j_common_ptr cinfo) { longjmp(myerr->setjmp_buffer, 1); } -JNIEXPORT void Java_org_telegram_messenger_Utilities_blurBitmap(JNIEnv *env, jclass class, jobject bitmap, int radius) { +JNIEXPORT void Java_org_telegram_messenger_Utilities_blurBitmap(JNIEnv *env, jclass class, jobject bitmap, int radius, int unpin) { if (!bitmap) { return; } @@ -312,7 +312,9 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_blurBitmap(JNIEnv *env, jcl } else { fastBlurMore(info.width, info.height, info.stride, pixels, radius); } - AndroidBitmap_unlockPixels(env, bitmap); + if (unpin) { + AndroidBitmap_unlockPixels(env, bitmap); + } } JNIEXPORT void Java_org_telegram_messenger_Utilities_calcCDT(JNIEnv *env, jclass class, jobject hsvBuffer, int width, int height, jobject buffer) { diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_0.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_0.jpg deleted file mode 100644 index 1cf58511..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_1.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_1.jpg deleted file mode 100644 index f5a3bd8a..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_2.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_2.jpg deleted file mode 100644 index d0db3e17..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_3.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_3.jpg deleted file mode 100644 index 225f2b8c..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_4.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_4.jpg deleted file mode 100644 index 453875c0..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_0.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_0.jpg deleted file mode 100644 index 53416f24..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_1.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_1.jpg deleted file mode 100644 index 8b7a562e..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_2.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_2.jpg deleted file mode 100644 index 48424203..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_3.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_3.jpg deleted file mode 100644 index 98cef882..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_4.jpg b/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_4.jpg deleted file mode 100644 index 0f8980a8..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji2.0x_a_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_0.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_0.jpg deleted file mode 100644 index e09c30c5..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_1.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_1.jpg deleted file mode 100644 index e0b0752e..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_2.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_2.jpg deleted file mode 100644 index ffd3c848..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_3.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_3.jpg deleted file mode 100644 index dd229d2a..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_4.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_4.jpg deleted file mode 100644 index 9127912f..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_0.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_0.jpg deleted file mode 100644 index e0e9339e..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_1.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_1.jpg deleted file mode 100644 index f5e831ae..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_2.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_2.jpg deleted file mode 100644 index d04659d6..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_3.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_3.jpg deleted file mode 100644 index 1a337239..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_4.jpg b/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_4.jpg deleted file mode 100644 index 7ce611f7..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/emoji3.0x_a_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java index e250ae56..50721491 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java @@ -42,16 +42,16 @@ import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Components.ForegroundDetector; import org.telegram.ui.Components.NumberPicker; import org.telegram.ui.Components.TypefaceSpan; @@ -75,10 +75,11 @@ public class AndroidUtilities { public static Integer photoSize = null; public static DisplayMetrics displayMetrics = new DisplayMetrics(); public static int leftBaseline; + public static boolean usingHardwareInput; private static Boolean isTablet = null; public static final String THEME_PREFS = "theme"; - public static final int THEME_PREFS_MODE = Activity.MODE_WORLD_READABLE; + public static final int THEME_PREFS_MODE = Activity.MODE_PRIVATE; public static final int defColor = 0xff009688;//0xff58BCD5;//0xff43C3DB;//0xff2f8cc9;58BCD5//0xff55abd2 public static int themeColor = getIntColor("themeColor"); @@ -238,21 +239,38 @@ public class AndroidUtilities { } public static int dp(float value) { + if (value == 0) { + return 0; + } return (int)Math.ceil(density * value); } + public static int compare(int lhs, int rhs) { + if (lhs == rhs) { + return 0; + } else if (lhs > rhs) { + return 1; + } + return -1; + } + public static float dpf2(float value) { + if (value == 0) { + return 0; + } return density * value; } public static void checkDisplaySize() { try { - WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); + Configuration configuration = ApplicationLoader.applicationContext.getResources().getConfiguration(); + usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS && configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO; + WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); if (manager != null) { Display display = manager.getDefaultDisplay(); if (display != null) { display.getMetrics(displayMetrics); - if(android.os.Build.VERSION.SDK_INT < 13) { + if (android.os.Build.VERSION.SDK_INT < 13) { displaySize.set(display.getWidth(), display.getHeight()); } else { display.getSize(displaySize); @@ -263,6 +281,38 @@ public class AndroidUtilities { } catch (Exception e) { FileLog.e("tmessages", e); } + + /* + keyboardHidden + public static final int KEYBOARDHIDDEN_NO = 1 + Constant for keyboardHidden, value corresponding to the keysexposed resource qualifier. + + public static final int KEYBOARDHIDDEN_UNDEFINED = 0 + Constant for keyboardHidden: a value indicating that no value has been set. + + public static final int KEYBOARDHIDDEN_YES = 2 + Constant for keyboardHidden, value corresponding to the keyshidden resource qualifier. + + hardKeyboardHidden + public static final int HARDKEYBOARDHIDDEN_NO = 1 + Constant for hardKeyboardHidden, value corresponding to the physical keyboard being exposed. + + public static final int HARDKEYBOARDHIDDEN_UNDEFINED = 0 + Constant for hardKeyboardHidden: a value indicating that no value has been set. + + public static final int HARDKEYBOARDHIDDEN_YES = 2 + Constant for hardKeyboardHidden, value corresponding to the physical keyboard being hidden. + + keyboard + public static final int KEYBOARD_12KEY = 3 + Constant for keyboard, value corresponding to the 12key resource qualifier. + + public static final int KEYBOARD_NOKEYS = 1 + Constant for keyboard, value corresponding to the nokeys resource qualifier. + + public static final int KEYBOARD_QWERTY = 2 + Constant for keyboard, value corresponding to the qwerty resource qualifier. + */ } public static float getPixelsInCM(float cm, boolean isX) { @@ -573,6 +623,9 @@ public class AndroidUtilities { if (start != -1) { stringBuilder.replace(start, start + 3, ""); end = stringBuilder.indexOf(""); + if (end == -1) { + end = stringBuilder.indexOf(""); + } stringBuilder.replace(end, end + 4, ""); bolds.add(start); bolds.add(end); diff --git a/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java index 4c116e37..cf701444 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java @@ -14,6 +14,7 @@ import android.app.Activity; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; import android.content.ContentResolver; +import android.content.ContentValues; import android.content.SharedPreferences; import android.database.Cursor; import android.net.Uri; @@ -37,7 +38,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.Locale; import java.util.concurrent.ConcurrentHashMap; public class ContactsController { @@ -168,7 +168,7 @@ public class ContactsController { if (!updatingInviteText && (inviteText == null || time + 86400 < (int)(System.currentTimeMillis() / 1000))) { updatingInviteText = true; TLRPC.TL_help_getInviteText req = new TLRPC.TL_help_getInviteText(); - req.lang_code = LocaleController.getLocaleString(Locale.getDefault()); + req.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); if (req.lang_code == null || req.lang_code.length() == 0) { req.lang_code = "en"; } @@ -203,7 +203,19 @@ public class ContactsController { public void checkAppAccount() { AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); - Account[] accounts = am.getAccountsByType("org.telegram.account"); + Account[] accounts; + try { + accounts = am.getAccountsByType("org.telegram.account"); + if (accounts != null && accounts.length > 0) { + for (Account c : accounts) { + am.removeAccount(c, null, null); + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + accounts = am.getAccountsByType("org.telegram.messenger"); boolean recreateAccount = false; if (UserConfig.isClientActivated()) { if (accounts.length == 1) { @@ -228,7 +240,7 @@ public class ContactsController { } if (UserConfig.isClientActivated()) { try { - currentAccount = new Account(UserConfig.getCurrentUser().phone, "org.telegram.account"); + currentAccount = new Account(UserConfig.getCurrentUser().phone, "org.telegram.messenger"); am.addAccountExplicitly(currentAccount, "", null); } catch (Exception e) { FileLog.e("tmessages", e); @@ -240,7 +252,7 @@ public class ContactsController { public void deleteAllAppAccounts() { try { AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); - Account[] accounts = am.getAccountsByType("org.telegram.account"); + Account[] accounts = am.getAccountsByType("org.telegram.messenger"); for (Account c : accounts) { am.removeAccount(c, null, null); } @@ -1247,7 +1259,7 @@ public class ContactsController { private void performWriteContactsToPhoneBook() { final ArrayList contactsArray = new ArrayList<>(); contactsArray.addAll(contacts); - Utilities.photoBookQueue.postRunnable(new Runnable() { + Utilities.phoneBookQueue.postRunnable(new Runnable() { @Override public void run() { performWriteContactsToPhoneBookInternal(contactsArray); @@ -1304,7 +1316,7 @@ public class ContactsController { } for (final Integer uid : contactsTD) { - Utilities.photoBookQueue.postRunnable(new Runnable() { + Utilities.phoneBookQueue.postRunnable(new Runnable() { @Override public void run() { deleteContactFromPhoneBook(uid); @@ -1464,7 +1476,7 @@ public class ContactsController { builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI); builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0); builder.withValue(ContactsContract.Data.MIMETYPE, "vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile"); - builder.withValue(ContactsContract.Data.DATA1, "+" + user.phone); + builder.withValue(ContactsContract.Data.DATA1, user.id); builder.withValue(ContactsContract.Data.DATA2, "Telegram Profile"); builder.withValue(ContactsContract.Data.DATA3, "+" + user.phone); builder.withValue(ContactsContract.Data.DATA4, user.id); @@ -1497,6 +1509,22 @@ public class ContactsController { } } + protected void markAsContacted(final String contactId) { + if (contactId == null) { + return; + } + Utilities.phoneBookQueue.postRunnable(new Runnable() { + @Override + public void run() { + Uri uri = Uri.parse(contactId); + ContentValues values = new ContentValues(); + values.put(ContactsContract.Contacts.LAST_TIME_CONTACTED, System.currentTimeMillis()); + ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver(); + cr.update(uri, values, null, null); + } + }); + } + public void addContact(TLRPC.User user) { if (user == null || user.phone == null) { return; @@ -1534,7 +1562,7 @@ public class ContactsController { // } for (final TLRPC.User u : res.users) { - Utilities.photoBookQueue.postRunnable(new Runnable() { + Utilities.phoneBookQueue.postRunnable(new Runnable() { @Override public void run() { addContactToPhoneBook(u, true); @@ -1547,7 +1575,7 @@ public class ContactsController { MessagesStorage.getInstance().putContacts(arrayList, false); if (u.phone != null && u.phone.length() > 0) { - String name = formatName(u.first_name, u.last_name); + CharSequence name = formatName(u.first_name, u.last_name); MessagesStorage.getInstance().applyPhoneBookUpdates(u.phone, ""); Contact contact = contactsBookSPhones.get(u.phone); if (contact != null) { @@ -1600,7 +1628,7 @@ public class ContactsController { return; } MessagesStorage.getInstance().deleteContacts(uids); - Utilities.photoBookQueue.postRunnable(new Runnable() { + Utilities.phoneBookQueue.postRunnable(new Runnable() { @Override public void run() { for (TLRPC.User user : users) { @@ -1611,7 +1639,7 @@ public class ContactsController { for (TLRPC.User user : users) { if (user.phone != null && user.phone.length() > 0) { - String name = ContactsController.formatName(user.first_name, user.last_name); + CharSequence name = ContactsController.formatName(user.first_name, user.last_name); MessagesStorage.getInstance().applyPhoneBookUpdates(user.phone, ""); Contact contact = contactsBookSPhones.get(user.phone); if (contact != null) { @@ -1773,22 +1801,37 @@ public class ContactsController { } public static String formatName(String firstName, String lastName) { - String result = ""; + /*if ((firstName == null || firstName.length() == 0) && (lastName == null || lastName.length() == 0)) { + return LocaleController.getString("HiddenName", R.string.HiddenName); + }*/ + if (firstName != null) { + firstName = firstName.trim(); + } + if (lastName != null) { + lastName = lastName.trim(); + } + StringBuilder result = new StringBuilder((firstName != null ? firstName.length() : 0) + (lastName != null ? lastName.length() : 0) + 1); if (LocaleController.nameDisplayOrder == 1) { - result = firstName; - if (result == null || result.length() == 0) { - result = lastName; - } else if (result.length() != 0 && lastName != null && lastName.length() != 0) { - result += " " + lastName; + if (firstName != null && firstName.length() > 0) { + result.append(firstName); + if (lastName != null && lastName.length() > 0) { + result.append(" "); + result.append(lastName); + } + } else if (lastName != null && lastName.length() > 0) { + result.append(lastName); } } else { - result = lastName; - if (result == null || result.length() == 0) { - result = firstName; - } else if (result.length() != 0 && firstName != null && firstName.length() != 0) { - result += " " + firstName; + if (lastName != null && lastName.length() > 0) { + result.append(lastName); + if (firstName != null && firstName.length() > 0) { + result.append(" "); + result.append(firstName); + } + } else if (firstName != null && firstName.length() > 0) { + result.append(firstName); } } - return result.trim(); + return result.toString(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/Emoji.java b/TMessagesProj/src/main/java/org/telegram/android/Emoji.java index 1549263d..2e29e24a 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/Emoji.java +++ b/TMessagesProj/src/main/java/org/telegram/android/Emoji.java @@ -33,7 +33,8 @@ import java.util.Locale; public class Emoji { private static HashMap rects = new HashMap<>(); - private static int drawImgSize, bigImgSize; + private static int drawImgSize; + private static int bigImgSize; private static boolean inited = false; private static Paint placeholderPaint; private static Bitmap emojiBmp[] = new Bitmap[5]; @@ -193,19 +194,19 @@ public class Emoji { static { int emojiFullSize; if (AndroidUtilities.density <= 1.0f) { - emojiFullSize = 30; + emojiFullSize = 32; } else if (AndroidUtilities.density <= 1.5f) { - emojiFullSize = 45; + emojiFullSize = 48; } else if (AndroidUtilities.density <= 2.0f) { - emojiFullSize = 60; + emojiFullSize = 64; } else { - emojiFullSize = 90; + emojiFullSize = 96; } drawImgSize = AndroidUtilities.dp(20); if (AndroidUtilities.isTablet()) { bigImgSize = AndroidUtilities.dp(40); } else { - bigImgSize = AndroidUtilities.dp(30); + bigImgSize = AndroidUtilities.dp(32); } for (int j = 1; j < data.length; j++) { @@ -234,8 +235,26 @@ public class Emoji { scale = 3.0f; } - String imageName = String.format(Locale.US, "emoji%.01fx_%d.jpg", scale, page); - File imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName); + String imageName; + File imageFile; + + try { + imageName = String.format(Locale.US, "emoji%.01fx_%d.jpg", scale, page); + imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName); + if (imageFile.exists()) { + imageFile.delete(); + } + imageName = String.format(Locale.US, "emoji%.01fx_a_%d.jpg", scale, page); + imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName); + if (imageFile.exists()) { + imageFile.delete(); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + imageName = String.format(Locale.US, "v4_emoji%.01fx_%d.jpg", scale, page); + imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName); if (!imageFile.exists()) { InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName); Utilities.copyFile(is, imageFile); @@ -253,7 +272,7 @@ public class Emoji { final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, width, height, stride); - imageName = String.format(Locale.US, "emoji%.01fx_a_%d.jpg", scale, page); + imageName = String.format(Locale.US, "v4_emoji%.01fx_a_%d.jpg", scale, page); imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName); if (!imageFile.exists()) { InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName); @@ -401,7 +420,6 @@ public class Emoji { if (cs == null || cs.length() == 0) { return cs; } - Spannable s; if (cs instanceof Spannable) { s = (Spannable)cs; diff --git a/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java index 37c0267a..0ff5997b 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java @@ -70,6 +70,8 @@ public class ImageLoader { private DispatchQueue recycleQueue = new DispatchQueue("recycleQueue"); private ConcurrentHashMap fileProgresses = new ConcurrentHashMap<>(); private HashMap thumbGenerateTasks = new HashMap<>(); + private static byte[] bytes; + private static byte[] bytesThumb; private int currentHttpTasksCount = 0; private LinkedList httpFileLoadTasks = new LinkedList<>(); @@ -507,6 +509,7 @@ public class ImageLoader { } Long mediaId = null; + boolean mediaIsVideo = false; Bitmap image = null; File cacheFileFinal = cacheImage.finalFilePath; boolean canDeleteFile = true; @@ -537,18 +540,35 @@ public class ImageLoader { } } - if (image == null) { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inSampleSize = 1; + + if (!isWebp && Build.VERSION.SDK_INT > 10 && Build.VERSION.SDK_INT < 21) { + opts.inPurgeable = true; + } + if (isWebp) { RandomAccessFile file = new RandomAccessFile(cacheFileFinal, "r"); ByteBuffer buffer = file.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, cacheFileFinal.length()); image = Utilities.loadWebpImage(buffer, buffer.limit(), null); file.close(); + } else { + if (opts.inPurgeable) { + RandomAccessFile f = new RandomAccessFile(cacheFileFinal, "r"); + int len = (int) f.length(); + byte[] data = bytesThumb != null && bytesThumb.length >= len ? bytesThumb : null; + if (data == null) { + bytesThumb = data = new byte[len]; + } + f.readFully(data, 0, len); + image = BitmapFactory.decodeByteArray(data, 0, len, opts); } else { FileInputStream is = new FileInputStream(cacheFileFinal); - image = BitmapFactory.decodeStream(is, null, null); + image = BitmapFactory.decodeStream(is, null, opts); is.close(); } } + if (image == null) { if (canDeleteFile && (cacheFileFinal.length() == 0 || cacheImage.filter == null)) { cacheFileFinal.delete(); @@ -556,15 +576,18 @@ public class ImageLoader { } else { if (image != null) { if (blurType == 1) { - Utilities.blurBitmap(image, 3); + Utilities.blurBitmap(image, 3, opts.inPurgeable ? 0 : 1); } else if (blurType == 2) { - Utilities.blurBitmap(image, 1); + Utilities.blurBitmap(image, 1, opts.inPurgeable ? 0 : 1); } else if (blurType == 3) { - Utilities.blurBitmap(image, 7); - Utilities.blurBitmap(image, 7); - Utilities.blurBitmap(image, 7); + Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1); + Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1); + Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1); } } + if (blurType == 0 && opts.inPurgeable) { + Utilities.pinBitmap(image); + } if (runtimeHack != null) { runtimeHack.trackFree(image.getRowBytes() * image.getHeight()); } @@ -579,6 +602,14 @@ public class ImageLoader { int idx = cacheImage.httpUrl.indexOf(":", 8); if (idx >= 0) { mediaId = Long.parseLong(cacheImage.httpUrl.substring(8, idx)); + mediaIsVideo = false; + } + canDeleteFile = false; + } else if (cacheImage.httpUrl.startsWith("vthumb://")) { + int idx = cacheImage.httpUrl.indexOf(":", 9); + if (idx >= 0) { + mediaId = Long.parseLong(cacheImage.httpUrl.substring(9, idx)); + mediaIsVideo = true; } canDeleteFile = false; } else if (!cacheImage.httpUrl.startsWith("http")) { @@ -604,21 +635,29 @@ public class ImageLoader { } BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inSampleSize = 1; float w_filter = 0; float h_filter = 0; boolean blur = false; if (cacheImage.filter != null) { String args[] = cacheImage.filter.split("_"); + if (args.length >= 2) { w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density; h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density; - if (args.length > 2) { + } + if (cacheImage.filter.contains("b")) { blur = true; } + if (w_filter != 0 && h_filter != 0) { opts.inJustDecodeBounds = true; if (mediaId != null) { + if (mediaIsVideo) { + MediaStore.Video.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Video.Thumbnails.MINI_KIND, opts); + } else { MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts); + } } else { FileInputStream is = new FileInputStream(cacheFileFinal); image = BitmapFactory.decodeStream(is, null, opts); @@ -632,7 +671,8 @@ public class ImageLoader { scaleFactor = 1; } opts.inJustDecodeBounds = false; - opts.inSampleSize = (int)scaleFactor; + opts.inSampleSize = (int) scaleFactor; + } } synchronized (sync) { if (isCancelled) { @@ -645,14 +685,18 @@ public class ImageLoader { } else { opts.inPreferredConfig = Bitmap.Config.RGB_565; } - //if (Build.VERSION.SDK_INT < 21) { - // opts.inPurgeable = true; - //} + if (!isWebp && Build.VERSION.SDK_INT > 10 && Build.VERSION.SDK_INT < 21) { + opts.inPurgeable = true; + } opts.inDither = false; if (mediaId != null) { + if (mediaIsVideo) { + image = MediaStore.Video.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Video.Thumbnails.MINI_KIND, opts); + } else { image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts); } + } if (image == null) { if (isWebp) { RandomAccessFile file = new RandomAccessFile(cacheFileFinal, "r"); @@ -660,9 +704,20 @@ public class ImageLoader { image = Utilities.loadWebpImage(buffer, buffer.limit(), null); file.close(); } else { - FileInputStream is = new FileInputStream(cacheFileFinal); - image = BitmapFactory.decodeStream(is, null, opts); - is.close(); + if (opts.inPurgeable) { + RandomAccessFile f = new RandomAccessFile(cacheFileFinal, "r"); + int len = (int) f.length(); + byte[] data = bytes != null && bytes.length >= len ? bytes : null; + if (data == null) { + bytes = data = new byte[len]; + } + f.readFully(data, 0, len); + image = BitmapFactory.decodeByteArray(data, 0, len, opts); + } else { + FileInputStream is = new FileInputStream(cacheFileFinal); + image = BitmapFactory.decodeStream(is, null, opts); + is.close(); + } } } if (image == null) { @@ -670,12 +725,13 @@ public class ImageLoader { cacheFileFinal.delete(); } } else { + boolean blured = false; if (cacheImage.filter != null) { float bitmapW = image.getWidth(); float bitmapH = image.getHeight(); - if (bitmapW != w_filter && bitmapW > w_filter) { + if (!opts.inPurgeable && w_filter != 0 && bitmapW != w_filter && bitmapW > w_filter + 20) { float scaleFactor = bitmapW / w_filter; - Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, (int)w_filter, (int)(bitmapH / scaleFactor), true); + Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, (int) w_filter, (int) (bitmapH / scaleFactor), true); if (image != scaledBitmap) { image.recycle(); callGC(); @@ -683,9 +739,13 @@ public class ImageLoader { } } if (image != null && blur && bitmapH < 100 && bitmapW < 100) { - Utilities.blurBitmap(image, 3); + Utilities.blurBitmap(image, 3, opts.inPurgeable ? 0 : 1); + blured = true; } } + if (!blured && opts.inPurgeable) { + Utilities.pinBitmap(image); + } if (runtimeHack != null) { runtimeHack.trackFree(image.getRowBytes() * image.getHeight()); } @@ -753,7 +813,7 @@ public class ImageLoader { } try { Object res = trackAllocation.invoke(runtime, size); - return (res instanceof Boolean) ? (Boolean)res : true; + return (res instanceof Boolean) ? (Boolean) res : true; } catch (Exception e) { return false; } @@ -765,7 +825,7 @@ public class ImageLoader { } try { Object res = trackFree.invoke(runtime, size); - return (res instanceof Boolean) ? (Boolean)res : true; + return (res instanceof Boolean) ? (Boolean) res : true; } catch (Exception e) { return false; } @@ -778,8 +838,8 @@ public class ImageLoader { Method getRt = cl.getMethod("getRuntime", new Class[0]); Object[] objects = new Object[0]; runtime = getRt.invoke(null, objects); - trackAllocation = cl.getMethod("trackExternalAllocation", new Class[] {long.class}); - trackFree = cl.getMethod("trackExternalFree", new Class[] {long.class}); + trackAllocation = cl.getMethod("trackExternalAllocation", new Class[]{long.class}); + trackFree = cl.getMethod("trackExternalFree", new Class[]{long.class}); } catch (Exception e) { FileLog.e("tmessages", e); runtime = null; @@ -872,7 +932,7 @@ public class ImageLoader { @Override public void run() { for (ImageReceiver imgView : finalImageReceiverArray) { - imgView.setImageBitmapByKey(image, key, thumb); + imgView.setImageBitmapByKey(image, key, thumb, false); } } }); @@ -891,6 +951,7 @@ public class ImageLoader { } private static volatile ImageLoader Instance = null; + public static ImageLoader getInstance() { ImageLoader localInstance = Instance; if (localInstance == null) { @@ -915,12 +976,13 @@ public class ImageLoader { @Override protected int sizeOf(String key, BitmapDrawable bitmap) { Bitmap b = bitmap.getBitmap(); - if(Build.VERSION.SDK_INT < 12) { + if (Build.VERSION.SDK_INT < 12) { return b.getRowBytes() * b.getHeight(); } else { return b.getByteCount(); } } + @Override protected void entryRemoved(boolean evicted, String key, final BitmapDrawable oldBitmap, BitmapDrawable newBitmap) { if (ignoreRemoval != null && key != null && ignoreRemoval.equals(key)) { @@ -1206,7 +1268,7 @@ public class ImageLoader { recycleQueue.postRunnable(new Runnable() { @Override public void run() { - System.gc(); + //System.gc(); } }); } @@ -1309,17 +1371,21 @@ public class ImageLoader { return memCache.get(key); } - public void replaceImageInCache(final String oldKey, final String newKey) { + public void replaceImageInCache(final String oldKey, final String newKey, final TLRPC.FileLocation newLocation) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { ArrayList arr = memCache.getFilterKeys(oldKey); if (arr != null) { for (String filter : arr) { - performReplace(oldKey + "@" + filter, newKey + "@" + filter); + String oldK = oldKey + "@" + filter; + String newK = newKey + "@" + filter; + performReplace(oldK, newK); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldK, newK, newLocation); } } else { performReplace(oldKey, newKey); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldKey, newKey, newLocation); } } }); @@ -1397,6 +1463,11 @@ public class ImageLoader { if (idx >= 0) { cacheFile = new File(httpLocation.substring(idx + 1)); } + } else if (httpLocation.startsWith("vthumb://")) { + int idx = httpLocation.indexOf(":", 9); + if (idx >= 0) { + cacheFile = new File(httpLocation.substring(idx + 1)); + } } else { cacheFile = new File(httpLocation); } @@ -1500,7 +1571,7 @@ public class ImageLoader { if (bitmapDrawable != null) { cancelLoadingForImageReceiver(imageReceiver, 0); if (!imageReceiver.isForcePreview()) { - imageReceiver.setImageBitmapByKey(bitmapDrawable, key, false); + imageReceiver.setImageBitmapByKey(bitmapDrawable, key, false, true); return; } } @@ -1510,7 +1581,7 @@ public class ImageLoader { if (thumbKey != null) { BitmapDrawable bitmapDrawable = memCache.get(thumbKey); if (bitmapDrawable != null) { - imageReceiver.setImageBitmapByKey(bitmapDrawable, thumbKey, true); + imageReceiver.setImageBitmapByKey(bitmapDrawable, thumbKey, true, true); cancelLoadingForImageReceiver(imageReceiver, 1); thumbSet = true; } @@ -1797,7 +1868,7 @@ public class ImageLoader { scaleFactor = 1; } bmOptions.inJustDecodeBounds = false; - bmOptions.inSampleSize = (int)scaleFactor; + bmOptions.inSampleSize = (int) scaleFactor; String exifPath = null; if (path != null) { @@ -1913,7 +1984,7 @@ public class ImageLoader { size.size = size.bytes.length; stream2.close(); } else { - size.size = (int)stream.getChannel().size(); + size.size = (int) stream.getChannel().size(); } stream.close(); if (scaledBitmap != bitmap) { @@ -1939,11 +2010,17 @@ public class ImageLoader { boolean scaleAnyway = false; float scaleFactor = Math.max(photoW / maxWidth, photoH / maxHeight); if (minWidth != 0 && minHeight != 0 && (photoW < minWidth || photoH < minHeight)) { + if (photoW < minWidth && photoH > minHeight) { + scaleFactor = photoW / minWidth; + } else if (photoW > minWidth && photoH < minHeight) { + scaleFactor = photoH / minHeight; + } else { scaleFactor = Math.max(photoW / minWidth, photoH / minHeight); + } scaleAnyway = true; } - int w = (int)(photoW / scaleFactor); - int h = (int)(photoH / scaleFactor); + int w = (int) (photoW / scaleFactor); + int h = (int) (photoH / scaleFactor); if (h == 0 || w == 0) { return null; } diff --git a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java index 1f75dd4b..eb9b2d2c 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java @@ -11,6 +11,7 @@ package org.telegram.android; import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; +import android.graphics.ColorFilter; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PorterDuff; @@ -33,12 +34,25 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb); } + private class SetImageBackup { + public TLObject fileLocation; + public String httpUrl; + public String filter; + public Drawable thumb; + public TLRPC.FileLocation thumbLocation; + public String thumbFilter; + public int size; + public boolean cacheOnly; + } + private View parentView; private Integer tag; private Integer thumbTag; private MessageObject parentMessageObject; private boolean canceledLoading; + private SetImageBackup setImageBackup; + private TLObject currentImageLocation; private String currentKey; private String currentThumbKey; @@ -66,12 +80,16 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg private RectF roundRect; private RectF bitmapRect; private Matrix shaderMatrix; - private int alpha = 255; + private float overrideAlpha = 1.0f; private boolean isPressed; - private boolean disableRecycle; private int orientation; private boolean centerRotation; private ImageReceiverDelegate delegate; + private float currentAlpha; + private long lastUpdateAlphaTime; + private byte crossfadeAlpha = 1; + private boolean crossfadeWithThumb; + private ColorFilter colorFilter; public ImageReceiver() { @@ -107,6 +125,13 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } public void setImage(TLObject fileLocation, String httpUrl, String filter, Drawable thumb, TLRPC.FileLocation thumbLocation, String thumbFilter, int size, boolean cacheOnly) { + if (setImageBackup != null) { + setImageBackup.fileLocation = null; + setImageBackup.httpUrl = null; + setImageBackup.thumbLocation = null; + setImageBackup.thumb = null; + } + if ((fileLocation == null && httpUrl == null && thumbLocation == null) || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation) @@ -121,13 +146,14 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg currentFilter = null; currentCacheOnly = false; staticThumb = thumb; + currentAlpha = 1; currentThumbLocation = null; currentSize = 0; currentImage = null; bitmapShader = null; ImageLoader.getInstance().cancelLoadingForImageReceiver(this, 0); if (parentView != null) { - parentView.invalidate(); + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); } if (delegate != null) { delegate.didSetImage(this, currentImage != null || currentThumb != null || staticThumb != null, currentImage == null); @@ -135,6 +161,8 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg return; } + + if (!(thumbLocation instanceof TLRPC.TL_fileLocation)) { thumbLocation = null; } @@ -188,6 +216,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg currentThumbLocation = thumbLocation; staticThumb = thumb; bitmapShader = null; + currentAlpha = 1.0f; if (delegate != null) { delegate.didSetImage(this, currentImage != null || currentThumb != null || staticThumb != null, currentImage == null); @@ -195,10 +224,14 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg ImageLoader.getInstance().loadImageForImageReceiver(this); if (parentView != null) { - parentView.invalidate(); + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); } } + public void setColorFilter(ColorFilter filter) { + colorFilter = filter; + } + public void setDelegate(ImageReceiverDelegate delegate) { this.delegate = delegate; } @@ -240,11 +273,18 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg currentSize = 0; currentCacheOnly = false; bitmapShader = null; + if (setImageBackup != null) { + setImageBackup.fileLocation = null; + setImageBackup.httpUrl = null; + setImageBackup.thumbLocation = null; + setImageBackup.thumb = null; + } + currentAlpha = 1; if (delegate != null) { delegate.didSetImage(this, currentImage != null || currentThumb != null || staticThumb != null, currentImage == null); } if (parentView != null) { - parentView.invalidate(); + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); } } @@ -257,17 +297,37 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } } - public boolean draw(Canvas canvas) { - try { - BitmapDrawable bitmapDrawable = null; - if (!forcePreview && currentImage != null) { - bitmapDrawable = currentImage; - } else if (staticThumb instanceof BitmapDrawable) { - bitmapDrawable = (BitmapDrawable) staticThumb; - } else if (currentThumb != null) { - bitmapDrawable = currentThumb; + public void onDetachedFromWindow() { + if (currentImageLocation != null || currentHttpUrl != null || currentThumbLocation != null || staticThumb != null) { + if (setImageBackup == null) { + setImageBackup = new SetImageBackup(); } - if (bitmapDrawable != null) { + setImageBackup.fileLocation = currentImageLocation; + setImageBackup.httpUrl = currentHttpUrl; + setImageBackup.filter = currentFilter; + setImageBackup.thumb = staticThumb; + setImageBackup.thumbLocation = currentThumbLocation; + setImageBackup.thumbFilter = currentThumbFilter; + setImageBackup.size = currentSize; + setImageBackup.cacheOnly = currentCacheOnly; + } + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReplacedPhotoInMemCache); + clearImage(); + } + + public boolean onAttachedToWindow() { + NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReplacedPhotoInMemCache); + if (setImageBackup != null && (setImageBackup.fileLocation != null || setImageBackup.httpUrl != null || setImageBackup.thumbLocation != null || setImageBackup.thumb != null)) { + setImage(setImageBackup.fileLocation, setImageBackup.httpUrl, setImageBackup.filter, setImageBackup.thumb, setImageBackup.thumbLocation, setImageBackup.thumbFilter, setImageBackup.size, setImageBackup.cacheOnly); + return true; + } + return false; + } + + private void drawDrawable(Canvas canvas, Drawable drawable, int alpha) { + if (drawable instanceof BitmapDrawable) { + BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; + Paint paint = bitmapDrawable.getPaint(); boolean hasFilter = paint != null && paint.getColorFilter() != null; if (hasFilter && !isPressed) { @@ -277,6 +337,9 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg bitmapDrawable.setColorFilter(new PorterDuffColorFilter(0xffdddddd, PorterDuff.Mode.MULTIPLY)); hasFilter = true; } + if (colorFilter != null) { + bitmapDrawable.setColorFilter(colorFilter); + } if (bitmapShader != null) { drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); if (isVisible) { @@ -284,6 +347,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg shaderMatrix.reset(); shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL); bitmapShader.setLocalMatrix(shaderMatrix); + roundPaint.setAlpha(alpha); canvas.drawRoundRect(roundRect, roundRadius, roundRadius, roundPaint); } } else { @@ -411,18 +475,73 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } } } - return true; - } else if (staticThumb != null) { - drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); - staticThumb.setBounds(drawRegion); - if (isVisible) { - try { - staticThumb.setAlpha(alpha); - staticThumb.draw(canvas); - } catch (Exception e) { - FileLog.e("tmessages", e); + } else { + drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); + drawable.setBounds(drawRegion); + if (isVisible) { + try { + drawable.setAlpha(alpha); + drawable.draw(canvas); + } catch (Exception e) { + FileLog.e("tmessages", e); + } } } + } + + private void checkAlphaAnimation() { + if (currentAlpha != 1) { + long currentTime = System.currentTimeMillis(); + currentAlpha += (currentTime - lastUpdateAlphaTime) / 150.0f; + if (currentAlpha > 1) { + currentAlpha = 1; + } + lastUpdateAlphaTime = System.currentTimeMillis(); + if (parentView != null) { + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); + } + } + } + + public boolean draw(Canvas canvas) { + try { + BitmapDrawable bitmapDrawable = null; + if (!forcePreview && currentImage != null) { + bitmapDrawable = currentImage; + } else if (staticThumb instanceof BitmapDrawable) { + bitmapDrawable = (BitmapDrawable) staticThumb; + } else if (currentThumb != null) { + bitmapDrawable = currentThumb; + } + if (bitmapDrawable != null) { + if (crossfadeAlpha != 0) { + if (crossfadeWithThumb && currentAlpha != 1.0f) { + Drawable thumbDrawable = null; + if (bitmapDrawable == currentImage) { + if (staticThumb != null) { + thumbDrawable = staticThumb; + } else if (currentThumb != null) { + thumbDrawable = currentThumb; + } + } else if (bitmapDrawable == currentThumb) { + if (staticThumb != null) { + thumbDrawable = staticThumb; + } + } + if (thumbDrawable != null) { + drawDrawable(canvas, thumbDrawable, (int) (overrideAlpha * 255)); + } + } + drawDrawable(canvas, bitmapDrawable, (int) (overrideAlpha * currentAlpha * 255)); + } else { + drawDrawable(canvas, bitmapDrawable, (int) (overrideAlpha * 255)); + } + + checkAlphaAnimation(); + return true; + } else if (staticThumb != null) { + drawDrawable(canvas, staticThumb, 255); + checkAlphaAnimation(); return true; } } catch (Exception e) { @@ -458,7 +577,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } isVisible = value; if (invalidate && parentView != null) { - parentView.invalidate(); + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); } } @@ -467,7 +586,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } public void setAlpha(float value) { - alpha = (int)(value * 255.0f); + overrideAlpha = value; + } + + public void setCrossfadeAlpha(byte value) { + crossfadeAlpha = value; } public boolean hasImage() { @@ -631,7 +754,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } } - protected void setImageBitmapByKey(BitmapDrawable bitmap, String key, boolean thumb) { + protected void setImageBitmapByKey(BitmapDrawable bitmap, String key, boolean thumb, boolean memCache) { if (bitmap == null || key == null) { return; } @@ -647,17 +770,38 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg roundPaint.setShader(bitmapShader); bitmapRect.set(0, 0, object.getWidth(), object.getHeight()); } + + if (!memCache && !forcePreview) { + if (currentThumb == null && staticThumb == null || currentAlpha == 1.0f) { + currentAlpha = 0.0f; + lastUpdateAlphaTime = System.currentTimeMillis(); + crossfadeWithThumb = currentThumb != null || staticThumb != null; + } + } else { + currentAlpha = 1.0f; + } + if (parentView != null) { - parentView.invalidate(); + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); } } else if (currentThumb == null && (currentImage == null || forcePreview)) { if (currentThumbKey == null || !key.equals(currentThumbKey)) { return; } ImageLoader.getInstance().incrementUseCount(currentThumbKey); + currentThumb = bitmap; + + if (!memCache && crossfadeAlpha != 2) { + currentAlpha = 0.0f; + lastUpdateAlphaTime = System.currentTimeMillis(); + crossfadeWithThumb = staticThumb != null && currentKey == null; + } else { + currentAlpha = 1.0f; + } + if (!(staticThumb instanceof BitmapDrawable) && parentView != null) { - parentView.invalidate(); + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); } } @@ -722,7 +866,27 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg staticThumb = null; } if (parentView != null) { - parentView.invalidate(); + parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH); + } + } + } else if (id == NotificationCenter.didReplacedPhotoInMemCache) { + String oldKey = (String) args[0]; + if (currentKey != null && currentKey.equals(oldKey)) { + currentKey = (String) args[1]; + currentImageLocation = (TLRPC.FileLocation) args[2]; + } + if (currentThumbKey != null && currentThumbKey.equals(oldKey)) { + currentThumbKey = (String) args[1]; + currentThumbLocation = (TLRPC.FileLocation) args[2]; + } + if (setImageBackup != null) { + if (currentKey != null && currentKey.equals(oldKey)) { + currentKey = (String) args[1]; + currentImageLocation = (TLRPC.FileLocation) args[2]; + } + if (currentThumbKey != null && currentThumbKey.equals(oldKey)) { + currentThumbKey = (String) args[1]; + currentThumbLocation = (TLRPC.FileLocation) args[2]; } } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java index cd58ef94..d2d559b1 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java @@ -378,6 +378,10 @@ public class LocaleController { } } + public Locale getSystemDefaultLocale() { + return systemDefaultLocale; + } + public static String getLocaleString(Locale locale) { if (locale == null) { return "en"; @@ -676,11 +680,12 @@ public class LocaleController { } public static String formatString(String key, int res, Object... args) { + try { String value = getInstance().localeValues.get(key); if (value == null) { value = ApplicationLoader.applicationContext.getString(res); } - try { + if (getInstance().currentLocale != null) { return String.format(getInstance().currentLocale, value, args); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java index 800b396c..8d80b2b4 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java @@ -87,6 +87,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel public static int[] readArgs = new int[3]; + public static String iFilter = "*"; + public interface FileDownloadProgressListener { void onFailedDownload(String fileName); void onSuccessDownload(String fileName); @@ -117,17 +119,27 @@ public class MediaController implements NotificationCenter.NotificationCenterDel MediaStore.Images.Media.ORIENTATION }; + private static final String[] projectionVideo = { + MediaStore.Video.Media._ID, + MediaStore.Video.Media.BUCKET_ID, + MediaStore.Video.Media.BUCKET_DISPLAY_NAME, + MediaStore.Video.Media.DATA, + MediaStore.Video.Media.DATE_TAKEN + }; + public static class AlbumEntry { public int bucketId; public String bucketName; public PhotoEntry coverPhoto; public ArrayList photos = new ArrayList<>(); public HashMap photosByIds = new HashMap<>(); + public boolean isVideo; - public AlbumEntry(int bucketId, String bucketName, PhotoEntry coverPhoto) { + public AlbumEntry(int bucketId, String bucketName, PhotoEntry coverPhoto, boolean isVideo) { this.bucketId = bucketId; this.bucketName = bucketName; this.coverPhoto = coverPhoto; + this.isVideo = isVideo; } public void addPhoto(PhotoEntry photoEntry) { @@ -144,13 +156,16 @@ public class MediaController implements NotificationCenter.NotificationCenterDel public int orientation; public String thumbPath; public String imagePath; + public boolean isVideo; + public CharSequence caption; - public PhotoEntry(int bucketId, int imageId, long dateTaken, String path, int orientation) { + public PhotoEntry(int bucketId, int imageId, long dateTaken, String path, int orientation, boolean isVideo) { this.bucketId = bucketId; this.imageId = imageId; this.dateTaken = dateTaken; this.path = path; this.orientation = orientation; + this.isVideo = isVideo; } } @@ -167,6 +182,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel public int date; public String thumbPath; public String imagePath; + public CharSequence caption; } public final static String MIME_TYPE = "video/avc"; @@ -178,6 +194,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel private final static int PROCESSOR_TYPE_TI = 5; private final Object videoConvertSync = new Object(); + private HashMap typingTimes = new HashMap<>(); + private SensorManager sensorManager; private Sensor proximitySensor; private boolean ignoreProximity; @@ -550,6 +568,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel videoDownloadQueue.clear(); downloadQueueKeys.clear(); videoConvertQueue.clear(); + typingTimes.clear(); cancelVideoConvert(null); } @@ -975,6 +994,29 @@ public class MediaController implements NotificationCenter.NotificationCenterDel } listenerInProgress = false; processLaterArrays(); + try { + ArrayList delayedMessages = SendMessagesHelper.getInstance().getDelayedMessages(fileName); + if (delayedMessages != null) { + for (SendMessagesHelper.DelayedMessage delayedMessage : delayedMessages) { + if (delayedMessage.encryptedChat == null) { + long dialog_id = delayedMessage.obj.getDialogId(); + Long lastTime = typingTimes.get(dialog_id); + if (lastTime == null || lastTime + 4000 < System.currentTimeMillis()) { + if (delayedMessage.videoLocation != null) { + MessagesController.getInstance().sendTyping(dialog_id, 5, 0); + } else if (delayedMessage.documentLocation != null) { + MessagesController.getInstance().sendTyping(dialog_id, 3, 0); + } else if (delayedMessage.location != null) { + MessagesController.getInstance().sendTyping(dialog_id, 4, 0); + } + typingTimes.put(dialog_id, System.currentTimeMillis()); + } + } + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } } else if (id == NotificationCenter.messagesDeleted) { if (playingMessageObject != null) { ArrayList markAsDeletedMessages = (ArrayList)args[0]; @@ -1970,10 +2012,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel @Override public void run() { final ArrayList albumsSorted = new ArrayList<>(); + final ArrayList videoAlbumsSorted = new ArrayList<>(); HashMap albums = new HashMap<>(); AlbumEntry allPhotosAlbum = null; String cameraFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() + "/" + "Camera/"; Integer cameraAlbumId = null; + Integer cameraAlbumVideoId = null; Cursor cursor = null; try { @@ -1993,15 +2037,15 @@ public class MediaController implements NotificationCenter.NotificationCenterDel String path = cursor.getString(dataColumn); long dateTaken = cursor.getLong(dateColumn); int orientation = cursor.getInt(orientationColumn); - - if (path == null || path.length() == 0) { + //Plus + if (path == null || path.length() == 0 || !iFilter.equals("*") && !path.toLowerCase().endsWith(iFilter)) {//|| !path.contains(".webp") continue; } - PhotoEntry photoEntry = new PhotoEntry(bucketId, imageId, dateTaken, path, orientation); + PhotoEntry photoEntry = new PhotoEntry(bucketId, imageId, dateTaken, path, orientation, false); if (allPhotosAlbum == null) { - allPhotosAlbum = new AlbumEntry(0, LocaleController.getString("AllPhotos", R.string.AllPhotos), photoEntry); + allPhotosAlbum = new AlbumEntry(0, LocaleController.getString("AllPhotos", R.string.AllPhotos), photoEntry, false); albumsSorted.add(0, allPhotosAlbum); } if (allPhotosAlbum != null) { @@ -2010,7 +2054,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel AlbumEntry albumEntry = albums.get(bucketId); if (albumEntry == null) { - albumEntry = new AlbumEntry(bucketId, bucketName, photoEntry); + albumEntry = new AlbumEntry(bucketId, bucketName, photoEntry, false); albums.put(bucketId, albumEntry); if (cameraAlbumId == null && cameraFolder != null && path != null && path.startsWith(cameraFolder)) { albumsSorted.add(0, albumEntry); @@ -2034,11 +2078,72 @@ public class MediaController implements NotificationCenter.NotificationCenterDel } } } + + try { + albums.clear(); + allPhotosAlbum = null; + cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projectionVideo, "", null, MediaStore.Video.Media.DATE_TAKEN + " DESC"); + if (cursor != null) { + int imageIdColumn = cursor.getColumnIndex(MediaStore.Video.Media._ID); + int bucketIdColumn = cursor.getColumnIndex(MediaStore.Video.Media.BUCKET_ID); + int bucketNameColumn = cursor.getColumnIndex(MediaStore.Video.Media.BUCKET_DISPLAY_NAME); + int dataColumn = cursor.getColumnIndex(MediaStore.Video.Media.DATA); + int dateColumn = cursor.getColumnIndex(MediaStore.Video.Media.DATE_TAKEN); + + while (cursor.moveToNext()) { + int imageId = cursor.getInt(imageIdColumn); + int bucketId = cursor.getInt(bucketIdColumn); + String bucketName = cursor.getString(bucketNameColumn); + String path = cursor.getString(dataColumn); + long dateTaken = cursor.getLong(dateColumn); + + if (path == null || path.length() == 0) { + continue; + } + + PhotoEntry photoEntry = new PhotoEntry(bucketId, imageId, dateTaken, path, 0, true); + + if (allPhotosAlbum == null) { + allPhotosAlbum = new AlbumEntry(0, LocaleController.getString("AllVideo", R.string.AllVideo), photoEntry, true); + videoAlbumsSorted.add(0, allPhotosAlbum); + } + if (allPhotosAlbum != null) { + allPhotosAlbum.addPhoto(photoEntry); + } + + AlbumEntry albumEntry = albums.get(bucketId); + if (albumEntry == null) { + albumEntry = new AlbumEntry(bucketId, bucketName, photoEntry, true); + albums.put(bucketId, albumEntry); + if (cameraAlbumVideoId == null && cameraFolder != null && path != null && path.startsWith(cameraFolder)) { + videoAlbumsSorted.add(0, albumEntry); + cameraAlbumVideoId = bucketId; + } else { + videoAlbumsSorted.add(albumEntry); + } + } + + albumEntry.addPhoto(photoEntry); + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } finally { + if (cursor != null) { + try { + cursor.close(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } + final Integer cameraAlbumIdFinal = cameraAlbumId; + final Integer cameraAlbumVideoIdFinal = cameraAlbumVideoId; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - NotificationCenter.getInstance().postNotificationName(NotificationCenter.albumsDidLoaded, guid, albumsSorted, cameraAlbumIdFinal); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.albumsDidLoaded, guid, albumsSorted, cameraAlbumIdFinal, videoAlbumsSorted, cameraAlbumVideoIdFinal); } }); } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java index 774235e6..c8a33d07 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java @@ -44,6 +44,7 @@ public class MessageObject { public TLRPC.Message messageOwner; public CharSequence messageText; public CharSequence linkDescription; + public CharSequence caption; public MessageObject replyMessageObject; public int type; public int contentType; @@ -54,7 +55,7 @@ public class MessageObject { public int audioProgressSec; public ArrayList photoThumbs; - private static TextPaint textPaint; + public static TextPaint textPaint; private static TextPaint textPaintRight = new TextPaint(Paint.ANTI_ALIAS_FLAG); private static TextPaint textPaintLeft = new TextPaint(Paint.ANTI_ALIAS_FLAG); public int lastLineWidth; @@ -163,6 +164,13 @@ public class MessageObject { whoUser = MessagesController.getInstance().getUser(message.action.user_id); } if (whoUser != null && fromUser != null) { + if (whoUser.id == fromUser.id) { + if (isOut()) { + messageText = LocaleController.getString("ActionAddUserSelf", R.string.ActionAddUserSelf).replace("un1", LocaleController.getString("FromYou", R.string.FromYou)); + } else { + messageText = replaceWithLink(LocaleController.getString("ActionAddUserSelf", R.string.ActionAddUserSelf), "un1", fromUser); + } + } else { if (isOut()) { messageText = replaceWithLink(LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser), "un2", whoUser); } else if (message.action.user_id == UserConfig.getClientUserId()) { @@ -171,9 +179,20 @@ public class MessageObject { messageText = replaceWithLink(LocaleController.getString("ActionAddUser", R.string.ActionAddUser), "un2", whoUser); messageText = replaceWithLink(messageText, "un1", fromUser); } + } } else { messageText = LocaleController.getString("ActionAddUser", R.string.ActionAddUser).replace("un2", "").replace("un1", ""); } + } else if (message.action instanceof TLRPC.TL_messageActionChatJoinedByLink) { + if (fromUser != null) { + if (isOut()) { + messageText = LocaleController.getString("ActionInviteYou", R.string.ActionInviteYou); + } else { + messageText = replaceWithLink(LocaleController.getString("ActionInviteUser", R.string.ActionInviteUser), "un1", fromUser); + } + } else { + messageText = LocaleController.getString("ActionInviteUser", R.string.ActionInviteUser).replace("un1", ""); + } } else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto) { if (isOut()) { messageText = LocaleController.getString("ActionYouChangedPhoto", R.string.ActionYouChangedPhoto); @@ -298,7 +317,7 @@ public class MessageObject { messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto); } else if (message.media instanceof TLRPC.TL_messageMediaVideo) { messageText = LocaleController.getString("AttachVideo", R.string.AttachVideo); - } else if (message.media instanceof TLRPC.TL_messageMediaGeo) { + } else if (message.media instanceof TLRPC.TL_messageMediaGeo || message.media instanceof TLRPC.TL_messageMediaVenue) { messageText = LocaleController.getString("AttachLocation", R.string.AttachLocation); } else if (message.media instanceof TLRPC.TL_messageMediaContact) { messageText = LocaleController.getString("AttachContact", R.string.AttachContact); @@ -333,7 +352,7 @@ public class MessageObject { contentType = type = 0; } else if (message.media instanceof TLRPC.TL_messageMediaPhoto) { contentType = type = 1; - } else if (message.media instanceof TLRPC.TL_messageMediaGeo) { + } else if (message.media instanceof TLRPC.TL_messageMediaGeo || message.media instanceof TLRPC.TL_messageMediaVenue) { contentType = 1; type = 4; } else if (message.media instanceof TLRPC.TL_messageMediaVideo) { @@ -393,6 +412,7 @@ public class MessageObject { monthKey = String.format("%d_%02d", dateYear, dateMonth); } + generateCaption(); if (generateLayout) { generateLayout(); } @@ -588,6 +608,41 @@ public class MessageObject { } } + public void generateCaption() { + if (caption != null) { + return; + } + if (messageOwner.media != null && messageOwner.media.caption != null && messageOwner.media.caption.length() > 0) { + caption = Emoji.replaceEmoji(messageOwner.media.caption, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + if (containsUrls(caption)) { + try { + Linkify.addLinks((Spannable) caption, Linkify.WEB_URLS); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + addUsernamesAndHashtags(caption); + } + } + } + + private void addUsernamesAndHashtags(CharSequence charSequence) { + try { + Pattern pattern = Pattern.compile("(^|\\s)@[a-zA-Z\\d_]{5,32}|(^|\\s)#[\\w\\.]+"); + Matcher matcher = pattern.matcher(charSequence); + while (matcher.find()) { + int start = matcher.start(); + int end = matcher.end(); + if (charSequence.charAt(start) != '@' && charSequence.charAt(start) != '#') { + start++; + } + URLSpanNoUnderline url = new URLSpanNoUnderline(charSequence.subSequence(start, end).toString()); + ((Spannable) charSequence).setSpan(url, start, end, 0); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + private void generateLayout() { if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) { return; @@ -598,26 +653,19 @@ public class MessageObject { if (messageText instanceof Spannable && containsUrls(messageText)) { if (messageText.length() < 100) { - Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS | Linkify.PHONE_NUMBERS); - } else { - Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS); - } - - try { - Pattern pattern = Pattern.compile("(^|\\s)@[a-zA-Z\\d_]{5,32}|(^|\\s)#[\\w\\.]+"); - Matcher matcher = pattern.matcher(messageText); - while (matcher.find()) { - int start = matcher.start(); - int end = matcher.end(); - if (messageText.charAt(start) != '@' && messageText.charAt(start) != '#') { - start++; - } - URLSpanNoUnderline url = new URLSpanNoUnderline(messageText.subSequence(start, end).toString()); - ((Spannable) messageText).setSpan(url, start, end, 0); + try { + Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS | Linkify.PHONE_NUMBERS); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } else { + try { + Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS); + } catch (Exception e) { + FileLog.e("tmessages", e); } - } catch (Exception e) { - FileLog.e("tmessages", e); } + addUsernamesAndHashtags(messageText); } int maxWidth; @@ -782,10 +830,33 @@ public class MessageObject { return (messageOwner.flags & TLRPC.MESSAGE_FLAG_UNREAD) != 0; } + public boolean isContentUnread() { + return (messageOwner.flags & TLRPC.MESSAGE_FLAG_CONTENT_UNREAD) != 0; + } + public void setIsRead() { messageOwner.flags &= ~TLRPC.MESSAGE_FLAG_UNREAD; } + public int getUnradFlags() { + return getUnreadFlags(messageOwner); + } + + public static int getUnreadFlags(TLRPC.Message message) { + int flags = 0; + if ((message.flags & TLRPC.MESSAGE_FLAG_UNREAD) == 0) { + flags |= 1; + } + if ((message.flags & TLRPC.MESSAGE_FLAG_CONTENT_UNREAD) == 0) { + flags |= 2; + } + return flags; + } + + public void setContentIsRead() { + messageOwner.flags &= ~TLRPC.MESSAGE_FLAG_CONTENT_UNREAD; + } + public int getId() { return messageOwner.id; } @@ -801,18 +872,27 @@ public class MessageObject { messageOwner.media instanceof TLRPC.TL_messageMediaVideo); } - public static void setIsUnread(TLRPC.Message message, boolean unread) { - if (unread) { + public static void setUnreadFlags(TLRPC.Message message, int flag) { + if ((flag & 1) == 0) { message.flags |= TLRPC.MESSAGE_FLAG_UNREAD; } else { message.flags &= ~TLRPC.MESSAGE_FLAG_UNREAD; } + if ((flag & 2) == 0) { + message.flags |= TLRPC.MESSAGE_FLAG_CONTENT_UNREAD; + } else { + message.flags &= ~TLRPC.MESSAGE_FLAG_CONTENT_UNREAD; + } } public static boolean isUnread(TLRPC.Message message) { return (message.flags & TLRPC.MESSAGE_FLAG_UNREAD) != 0; } + public static boolean isContentUnread(TLRPC.Message message) { + return (message.flags & TLRPC.MESSAGE_FLAG_CONTENT_UNREAD) != 0; + } + public static boolean isOut(TLRPC.Message message) { return (message.flags & TLRPC.MESSAGE_FLAG_OUT) != 0; } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java index 5773daf1..711e2ad6 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java @@ -23,7 +23,6 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.RPCRequest; import org.telegram.messenger.SerializedData; -import org.telegram.messenger.TLClassStore; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; @@ -34,7 +33,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.Locale; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Semaphore; @@ -45,13 +43,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter private ConcurrentHashMap users = new ConcurrentHashMap<>(100, 1.0f, 2); private ConcurrentHashMap usersByUsernames = new ConcurrentHashMap<>(100, 1.0f, 2); + private HashMap exportedChats = new HashMap<>(); + public ArrayList dialogs = new ArrayList<>(); public ArrayList dialogsServerOnly = new ArrayList<>(); public ConcurrentHashMap dialogs_dict = new ConcurrentHashMap<>(100, 1.0f, 2); public HashMap dialogMessage = new HashMap<>(); public ConcurrentHashMap> printingUsers = new ConcurrentHashMap<>(20, 1.0f, 2); public HashMap printingStrings = new HashMap<>(); - public HashMap sendingTypings = new HashMap<>(); + public HashMap printingStringsTypes = new HashMap<>(); + public HashMap> sendingTypings = new HashMap<>(); public ConcurrentHashMap onlinePrivacy = new ConcurrentHashMap<>(20, 1.0f, 2); private int lastPrintingStringCount = 0; @@ -124,6 +125,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter public static class PrintingUser { public long lastTime; public int userId; + public TLRPC.SendMessageAction action; } private static volatile MessagesController Instance = null; @@ -163,9 +165,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter byte[] bytes = Base64.decode(disabledFeaturesString, Base64.DEFAULT); if (bytes != null) { SerializedData data = new SerializedData(bytes); - int count = data.readInt32(); + int count = data.readInt32(false); for (int a = 0; a < count; a++) { - TLRPC.TL_disabledFeature feature = (TLRPC.TL_disabledFeature) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.TL_disabledFeature feature = TLRPC.TL_disabledFeature.TLdeserialize(data, data.readInt32(false), false); if (feature != null && feature.feature != null && feature.description != null) { disabledFeatures.add(feature); } @@ -372,6 +374,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter SecretChatHelper.getInstance().cleanUp(); dialogs_dict.clear(); + exportedChats.clear(); dialogs.clear(); dialogsServerOnly.clear(); users.clear(); @@ -380,6 +383,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter dialogMessage.clear(); printingUsers.clear(); printingStrings.clear(); + printingStringsTypes.clear(); onlinePrivacy.clear(); totalDialogsCount = 0; lastPrintingStringCount = 0; @@ -463,6 +467,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter return chat; } + public TLRPC.ExportedChatInvite getExportedInvite(int chat_id) { + return exportedChats.get(chat_id); + } + + public void putExportedInvite(int chat_id, TLRPC.TL_chatInviteExported invite) { + exportedChats.put(chat_id, invite); + } + public boolean putUser(TLRPC.User user, boolean fromCache) { if (user == null) { return false; @@ -564,7 +576,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter } public void loadFullChat(final int chat_id, final int classGuid) { - if (loadingFullChats.contains(chat_id) || loadedFullChats.contains(chat_id)) { + loadFullChat(chat_id, classGuid, false); + } + + public void loadFullChat(final int chat_id, final int classGuid, boolean force) { + if (loadingFullChats.contains(chat_id) || !force && loadedFullChats.contains(chat_id)) { return; } loadingFullChats.add(chat_id); @@ -580,12 +596,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - loadingFullChats.remove((Integer)chat_id); + exportedChats.put(chat_id, res.full_chat.exported_invite); + loadingFullChats.remove((Integer) chat_id); loadedFullChats.add(chat_id); putUsers(res.users, false); putChats(res.chats, false); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, chat_id, res.full_chat.participants); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, chat_id, res.full_chat.participants, classGuid); } }); } else { @@ -617,7 +634,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - loadingFullUsers.remove((Integer)user.id); + loadingFullUsers.remove((Integer) user.id); loadedFullUsers.add(user.id); String names = user.first_name + user.last_name + user.username; TLRPC.TL_userFull userFull = (TLRPC.TL_userFull)response; @@ -1275,15 +1292,72 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } - public void updatePrintingStrings() { + private String getUserNameForTyping(TLRPC.User user) { + if (user == null) { + return ""; + } + if (user.first_name != null && user.first_name.length() > 0) { + return user.first_name; + } else if (user.last_name != null && user.last_name.length() > 0) { + return user.last_name; + } + return ""; + } + + private void updatePrintingStrings() { final HashMap newPrintingStrings = new HashMap<>(); + final HashMap newPrintingStringsTypes = new HashMap<>(); ArrayList keys = new ArrayList<>(printingUsers.keySet()); - for (Long key : keys) { - if (key > 0 || key.intValue() == 0) { - newPrintingStrings.put(key, LocaleController.getString("Typing", R.string.Typing)); + for (HashMap.Entry> entry : printingUsers.entrySet()) { + long key = entry.getKey(); + ArrayList arr = entry.getValue(); + + int lower_id = (int) key; + + if (lower_id > 0 || lower_id == 0 || arr.size() == 1) { + PrintingUser pu = arr.get(0); + TLRPC.User user = getUser(pu.userId); + if (user == null) { + return; + } + if (pu.action instanceof TLRPC.TL_sendMessageUploadAudioAction || pu.action instanceof TLRPC.TL_sendMessageRecordAudioAction) { + if (lower_id < 0) { + newPrintingStrings.put(key, LocaleController.formatString("IsRecordingAudio", R.string.IsRecordingAudio, getUserNameForTyping(user))); + } else { + newPrintingStrings.put(key, LocaleController.getString("RecordingAudio", R.string.RecordingAudio)); + } + newPrintingStringsTypes.put(key, 1); + } else if (pu.action instanceof TLRPC.TL_sendMessageUploadVideoAction || pu.action instanceof TLRPC.TL_sendMessageRecordVideoAction) { + if (lower_id < 0) { + newPrintingStrings.put(key, LocaleController.formatString("IsSendingVideo", R.string.IsSendingVideo, getUserNameForTyping(user))); + } else { + newPrintingStrings.put(key, LocaleController.getString("SendingVideoStatus", R.string.SendingVideoStatus)); + } + newPrintingStringsTypes.put(key, 2); + } else if (pu.action instanceof TLRPC.TL_sendMessageUploadDocumentAction) { + if (lower_id < 0) { + newPrintingStrings.put(key, LocaleController.formatString("IsSendingFile", R.string.IsSendingFile, getUserNameForTyping(user))); + } else { + newPrintingStrings.put(key, LocaleController.getString("SendingFile", R.string.SendingFile)); + } + newPrintingStringsTypes.put(key, 2); + } else if (pu.action instanceof TLRPC.TL_sendMessageUploadPhotoAction) { + if (lower_id < 0) { + newPrintingStrings.put(key, LocaleController.formatString("IsSendingPhoto", R.string.IsSendingPhoto, getUserNameForTyping(user))); + } else { + newPrintingStrings.put(key, LocaleController.getString("SendingPhoto", R.string.SendingPhoto)); + } + newPrintingStringsTypes.put(key, 2); + } else { + if (lower_id < 0) { + newPrintingStrings.put(key, String.format("%s %s", getUserNameForTyping(user), LocaleController.getString("IsTyping", R.string.IsTyping))); + } else { + newPrintingStrings.put(key, LocaleController.getString("Typing", R.string.Typing)); + } + newPrintingStringsTypes.put(key, 0); + } } else { - ArrayList arr = printingUsers.get(key); int count = 0; String label = ""; for (PrintingUser pu : arr) { @@ -1292,11 +1366,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (label.length() != 0) { label += ", "; } - if (user.first_name != null && user.first_name.length() > 0) { - label += user.first_name; - } else if (user.last_name != null && user.last_name.length() > 0) { - label += user.last_name; - } + label += getUserNameForTyping(user); count++; } if (count == 2) { @@ -1304,15 +1374,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } if (label.length() != 0) { - if (count > 1) { if (arr.size() > 2) { newPrintingStrings.put(key, String.format("%s %s", label, LocaleController.formatPluralString("AndMoreTyping", arr.size() - 2))); } else { newPrintingStrings.put(key, String.format("%s %s", label, LocaleController.getString("AreTyping", R.string.AreTyping))); } - } else { - newPrintingStrings.put(key, String.format("%s %s", label, LocaleController.getString("IsTyping", R.string.IsTyping))); - } + newPrintingStringsTypes.put(key, 0); } } } @@ -1323,21 +1390,30 @@ public class MessagesController implements NotificationCenter.NotificationCenter @Override public void run() { printingStrings = newPrintingStrings; + printingStringsTypes = newPrintingStringsTypes; } }); } - public void cancelTyping(long dialog_id) { - sendingTypings.remove(dialog_id); + public void cancelTyping(int action, long dialog_id) { + HashMap typings = sendingTypings.get(action); + if (typings != null) { + typings.remove(dialog_id); + } } - public void sendTyping(final long dialog_id, int classGuid) { + public void sendTyping(final long dialog_id, final int action, int classGuid) { if (dialog_id == 0) { return; } - if (sendingTypings.get(dialog_id) != null) { + HashMap typings = sendingTypings.get(action); + if (typings != null && typings.get(dialog_id) != null) { return; } + if (typings == null) { + typings = new HashMap<>(); + sendingTypings.put(action, typings); + } int lower_part = (int)dialog_id; int high_id = (int)(dialog_id >> 32); if (lower_part != 0) { @@ -1364,21 +1440,41 @@ public class MessagesController implements NotificationCenter.NotificationCenter return; } } + if (action == 0) { req.action = new TLRPC.TL_sendMessageTypingAction(); - sendingTypings.put(dialog_id, true); + } else if (action == 1) { + req.action = new TLRPC.TL_sendMessageRecordAudioAction(); + } else if (action == 2) { + req.action = new TLRPC.TL_sendMessageCancelAction(); + } else if (action == 3) { + req.action = new TLRPC.TL_sendMessageUploadDocumentAction(); + } else if (action == 4) { + req.action = new TLRPC.TL_sendMessageUploadPhotoAction(); + } else if (action == 5) { + req.action = new TLRPC.TL_sendMessageUploadVideoAction(); + } + typings.put(dialog_id, true); long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - sendingTypings.remove(dialog_id); + HashMap typings = sendingTypings.get(action); + if (typings != null) { + typings.remove(dialog_id); + } } }); } }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); - ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); + if (classGuid != 0) { + ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); + } } else { + if (action != 0) { + return; + } TLRPC.EncryptedChat chat = getEncryptedChat(high_id); if (chat.auth_key != null && chat.auth_key.length > 1 && chat instanceof TLRPC.TL_encryptedChat) { TLRPC.TL_messages_setEncryptedTyping req = new TLRPC.TL_messages_setEncryptedTyping(); @@ -1386,14 +1482,24 @@ public class MessagesController implements NotificationCenter.NotificationCenter req.peer.chat_id = chat.id; req.peer.access_hash = chat.access_hash; req.typing = true; - sendingTypings.put(dialog_id, true); + typings.put(dialog_id, true); long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { - sendingTypings.remove(dialog_id); + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + HashMap typings = sendingTypings.get(action); + if (typings != null) { + typings.remove(dialog_id); + } + } + }); } }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); - ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); + if (classGuid != 0) { + ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); + } } } } @@ -1567,7 +1673,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter currentDialog.unread_count = entry.getValue(); } } - NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_READ_DIALOG_MESSAGE); NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate); } }); @@ -1803,12 +1909,29 @@ public class MessagesController implements NotificationCenter.NotificationCenter dialogsEndReached = (dialogsRes.dialogs.size() == 0 || dialogsRes.dialogs.size() != count) && !isCache; NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); + generateUpdateMessage(); } }); } }); } + public void markMessageContentAsRead(int mid) { + TLRPC.TL_messages_readMessageContents req = new TLRPC.TL_messages_readMessageContents(); + req.id.add(mid); + MessagesStorage.getInstance().markMessagesContentAsRead(req.id); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesReadContent, req.id); + ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(TLObject response, TLRPC.TL_error error) { + if (error == null) { + TLRPC.TL_messages_affectedMessages res = (TLRPC.TL_messages_affectedMessages) response; + processNewDifferenceParams(-1, res.pts, -1, res.pts_count); + } + } + }); + } + public void markMessageAsRead(final long dialog_id, final long random_id, int ttl) { if (random_id == 0 || dialog_id == 0 || ttl <= 0) { return; @@ -2030,7 +2153,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter public void run() { putUsers(updates.users, false); putChats(updates.chats, false); - TLRPC.Chat chat = null; if (updates.chats != null && !updates.chats.isEmpty()) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidCreated, updates.chats.get(0).id); } else { @@ -2213,6 +2335,35 @@ public class MessagesController implements NotificationCenter.NotificationCenter }); } + public void generateUpdateMessage() { + Utilities.stageQueue.postRunnable(new Runnable() { + @Override + public void run() { + try { + String build = LocaleController.getString("updateBuild", R.string.updateBuild); + if (build != null) { + int version = Utilities.parseInt(build); + if (version <= UserConfig.lastUpdateVersion) { + return; + } + UserConfig.lastUpdateVersion = version; + UserConfig.saveConfig(false); + } + TLRPC.TL_updateServiceNotification update = new TLRPC.TL_updateServiceNotification(); + update.message = LocaleController.getString("updateText", R.string.updateText) + LocaleController.getString("updatePlusText", R.string.updatePlusText); + update.media = new TLRPC.TL_messageMediaEmpty(); + update.type = "update"; + update.popup = false; + ArrayList updates = new ArrayList<>(); + updates.add(update); + processUpdateArray(updates, null, null); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + } + public void registerForPush(final String regid) { if (regid == null || regid.length() == 0 || registeringForPush || UserConfig.getClientUserId() == 0) { return; @@ -2226,7 +2377,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter req.token = regid; req.app_sandbox = false; try { - req.lang_code = LocaleController.getLocaleString(Locale.getDefault()); + req.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + if (req.lang_code == null || req.lang_code.length() == 0) { + req.lang_code = "en"; + } req.device_model = Build.MANUFACTURER + Build.MODEL; if (req.device_model == null) { req.device_model = "Android unknown"; @@ -2359,7 +2513,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } else if (type == 2) { if (updates.qts <= MessagesStorage.lastQtsValue) { return 2; - } else if (MessagesStorage.lastQtsValue + 1 == updates.qts) { + } else if (MessagesStorage.lastQtsValue + updates.updates.size() == updates.qts) { return 0; } else { return 1; @@ -2375,14 +2529,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter Collections.sort(updatesQueue, new Comparator() { @Override public int compare(TLRPC.Updates updates, TLRPC.Updates updates2) { - int seq1 = getUpdateSeq(updates); - int seq2 = getUpdateSeq(updates2); - if (seq1 == seq2) { - return 0; - } else if (seq1 > seq2) { - return 1; - } - return -1; + return AndroidUtilities.compare(getUpdateSeq(updates), getUpdateSeq(updates2)); } }); } else if (type == 1) { @@ -2390,12 +2537,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter Collections.sort(updatesQueue, new Comparator() { @Override public int compare(TLRPC.Updates updates, TLRPC.Updates updates2) { - if (updates.pts == updates2.pts) { - return 0; - } else if (updates.pts > updates2.pts) { - return 1; - } - return -1; + return AndroidUtilities.compare(updates.pts, updates2.pts); } }); } else if (type == 2) { @@ -2403,12 +2545,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter Collections.sort(updatesQueue, new Comparator() { @Override public int compare(TLRPC.Updates updates, TLRPC.Updates updates2) { - if (updates.qts == updates2.qts) { - return 0; - } else if (updates.qts > updates2.qts) { - return 1; - } - return -1; + return AndroidUtilities.compare(updates.qts, updates2.qts); } }); } @@ -2710,6 +2847,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter }); } + private int getUpdateType(TLRPC.Update update) { + if (update instanceof TLRPC.TL_updateNewMessage || update instanceof TLRPC.TL_updateReadMessagesContents || update instanceof TLRPC.TL_updateReadHistoryInbox || + update instanceof TLRPC.TL_updateReadHistoryOutbox || update instanceof TLRPC.TL_updateDeleteMessages) { + return 0; + } else if (update instanceof TLRPC.TL_updateNewEncryptedMessage) { + return 1; + } else { + return 2; + } + } + public void processUpdates(final TLRPC.Updates updates, boolean fromQueue) { boolean needGetDiff = false; boolean needReceivedQueue = false; @@ -2719,11 +2867,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter arr.add(updates.update); processUpdateArray(arr, null, null); } else if (updates instanceof TLRPC.TL_updateShortChatMessage || updates instanceof TLRPC.TL_updateShortMessage) { - TLRPC.User user = getUser(updates.user_id); + final int user_id = updates instanceof TLRPC.TL_updateShortChatMessage ? updates.from_id : updates.user_id; + TLRPC.User user = getUser(user_id); TLRPC.User user2 = null; if (user == null) { - user = MessagesStorage.getInstance().getUserSync(updates.user_id); + user = MessagesStorage.getInstance().getUserSync(user_id); putUser(user, true); } @@ -2763,13 +2912,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter if ((updates.flags & TLRPC.MESSAGE_FLAG_OUT) != 0) { message.from_id = UserConfig.getClientUserId(); } else { - message.from_id = updates.user_id; + message.from_id = user_id; } message.to_id = new TLRPC.TL_peerUser(); - message.to_id.user_id = updates.user_id; - message.dialog_id = updates.user_id; + message.to_id.user_id = user_id; + message.dialog_id = user_id; } else { - message.from_id = updates.user_id; + message.from_id = user_id; message.to_id = new TLRPC.TL_peerChat(); message.to_id.chat_id = updates.chat_id; message.dialog_id = -updates.chat_id; @@ -2798,7 +2947,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (printUpdate) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_USER_PRINT); } - updateInterfaceWithMessages(updates.user_id, objArr); + updateInterfaceWithMessages(user_id, objArr); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); } }); @@ -2840,7 +2989,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (updatesStartWaitTimePts == 0) { updatesStartWaitTimePts = System.currentTimeMillis(); } - FileLog.e("tmessages", "add short message to queue"); + FileLog.e("tmessages", "add to queue"); updatesQueuePts.add(updates); } else { needGetDiff = true; @@ -2849,56 +2998,92 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } else if (updates instanceof TLRPC.TL_updatesCombined || updates instanceof TLRPC.TL_updates) { MessagesStorage.getInstance().putUsersAndChats(updates.users, updates.chats, true, true); - int lastQtsValue = MessagesStorage.lastQtsValue; + Collections.sort(updates.updates, new Comparator() { + @Override + public int compare(TLRPC.Update lhs, TLRPC.Update rhs) { + int ltype = getUpdateType(lhs); + int rtype = getUpdateType(rhs); + if (ltype != rtype) { + return AndroidUtilities.compare(ltype, rtype); + } else if (ltype == 0) { + return AndroidUtilities.compare(lhs.pts, rhs.pts); + } else if (ltype == 1) { + return AndroidUtilities.compare(lhs.qts, rhs.qts); + } + return 0; + } + }); for (int a = 0; a < updates.updates.size(); a++) { TLRPC.Update update = updates.updates.get(a); - if (update instanceof TLRPC.TL_updateNewMessage || update instanceof TLRPC.TL_updateReadMessages || update instanceof TLRPC.TL_updateReadHistoryInbox || - update instanceof TLRPC.TL_updateReadHistoryOutbox || update instanceof TLRPC.TL_updateDeleteMessages) { + if (getUpdateType(update) == 0) { TLRPC.TL_updates updatesNew = new TLRPC.TL_updates(); updatesNew.updates.add(update); updatesNew.pts = update.pts; updatesNew.pts_count = update.pts_count; - if (MessagesStorage.lastPtsValue + update.pts_count == update.pts) { + for (int b = a + 1; b < updates.updates.size(); b++) { + TLRPC.Update update2 = updates.updates.get(b); + if (getUpdateType(update2) == 0 && updatesNew.pts + update2.pts_count == update2.pts) { + updatesNew.updates.add(update2); + updatesNew.pts = update2.pts; + updatesNew.pts_count += update2.pts_count; + updates.updates.remove(b); + b--; + } else { + break; + } + } + if (MessagesStorage.lastPtsValue + updatesNew.pts_count == updatesNew.pts) { if (!processUpdateArray(updatesNew.updates, updates.users, updates.chats)) { FileLog.e("tmessages", "need get diff inner TL_updates, seq: " + MessagesStorage.lastSeqValue + " " + updates.seq); needGetDiff = true; } else { - MessagesStorage.lastPtsValue = update.pts; + MessagesStorage.lastPtsValue = updatesNew.pts; } - } else if (MessagesStorage.lastPtsValue != update.pts) { - FileLog.e("tmessages", update + " need get diff, pts: " + MessagesStorage.lastPtsValue + " " + update.pts + " count = " + update.pts_count); + } else if (MessagesStorage.lastPtsValue != updatesNew.pts) { + FileLog.e("tmessages", update + " need get diff, pts: " + MessagesStorage.lastPtsValue + " " + updatesNew.pts + " count = " + updatesNew.pts_count); if (gettingDifference || updatesStartWaitTimePts == 0 || updatesStartWaitTimePts != 0 && updatesStartWaitTimePts + 1500 > System.currentTimeMillis()) { if (updatesStartWaitTimePts == 0) { updatesStartWaitTimePts = System.currentTimeMillis(); } - FileLog.e("tmessages", "add short message to queue"); + FileLog.e("tmessages", "add to queue"); updatesQueuePts.add(updatesNew); } else { needGetDiff = true; } } - } else if (update instanceof TLRPC.TL_updateNewEncryptedMessage) { + } else if (getUpdateType(update) == 1) { TLRPC.TL_updates updatesNew = new TLRPC.TL_updates(); updatesNew.updates.add(update); updatesNew.qts = update.qts; - if (MessagesStorage.lastQtsValue == 0 || MessagesStorage.lastQtsValue + 1 == update.qts) { + for (int b = a + 1; b < updates.updates.size(); b++) { + TLRPC.Update update2 = updates.updates.get(b); + if (getUpdateType(update2) == 1 && updatesNew.qts + 1 == update2.qts) { + updatesNew.updates.add(update2); + updatesNew.qts = update2.qts; + updates.updates.remove(b); + b--; + } else { + break; + } + } + if (MessagesStorage.lastQtsValue == 0 || MessagesStorage.lastQtsValue + updatesNew.updates.size() == updatesNew.qts) { processUpdateArray(updatesNew.updates, updates.users, updates.chats); - MessagesStorage.lastQtsValue = update.qts; + MessagesStorage.lastQtsValue = updatesNew.qts; needReceivedQueue = true; - } else if (MessagesStorage.lastPtsValue != update.qts) { - FileLog.e("tmessages", update + " need get diff, qts: " + MessagesStorage.lastQtsValue + " " + update.qts); + } else if (MessagesStorage.lastPtsValue != updatesNew.qts) { + FileLog.e("tmessages", update + " need get diff, qts: " + MessagesStorage.lastQtsValue + " " + updatesNew.qts); if (gettingDifference || updatesStartWaitTimeQts == 0 || updatesStartWaitTimeQts != 0 && updatesStartWaitTimeQts + 1500 > System.currentTimeMillis()) { if (updatesStartWaitTimeQts == 0) { updatesStartWaitTimeQts = System.currentTimeMillis(); } - FileLog.e("tmessages", "add short message to queue"); + FileLog.e("tmessages", "add to queue"); updatesQueueQts.add(updatesNew); } else { needGetDiff = true; } } } else { - continue; + break; } updates.updates.remove(a); a--; @@ -2996,6 +3181,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter final ArrayList messagesArr = new ArrayList<>(); final HashMap markAsReadMessagesInbox = new HashMap<>(); final HashMap markAsReadMessagesOutbox = new HashMap<>(); + final ArrayList markAsReadMessages = new ArrayList<>(); final HashMap markAsReadEncrypted = new HashMap<>(); final ArrayList deletedMessages = new ArrayList<>(); boolean printChanged = false; @@ -3078,8 +3264,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (!obj.isOut() && obj.isUnread()) { pushMessages.add(obj); } - } else if (update instanceof TLRPC.TL_updateReadMessages) { - //markAsReadMessages.addAll(update.messages); disabled for now + } else if (update instanceof TLRPC.TL_updateReadMessagesContents) { + markAsReadMessages.addAll(update.messages); } else if (update instanceof TLRPC.TL_updateReadHistoryInbox) { TLRPC.Peer peer = ((TLRPC.TL_updateReadHistoryInbox) update).peer; if (peer.chat_id != 0) { @@ -3097,12 +3283,27 @@ public class MessagesController implements NotificationCenter.NotificationCenter } else if (update instanceof TLRPC.TL_updateDeleteMessages) { deletedMessages.addAll(update.messages); } else if (update instanceof TLRPC.TL_updateUserTyping || update instanceof TLRPC.TL_updateChatUserTyping) { - if (update.action instanceof TLRPC.TL_sendMessageTypingAction && update.user_id != UserConfig.getClientUserId()) { + if (update.user_id != UserConfig.getClientUserId()) { long uid = -update.chat_id; if (uid == 0) { uid = update.user_id; } ArrayList arr = printingUsers.get(uid); + if (update.action instanceof TLRPC.TL_sendMessageCancelAction) { + if (arr != null) { + for (int a = 0; a < arr.size(); a++) { + PrintingUser pu = arr.get(a); + if (pu.userId == update.user_id) { + arr.remove(a); + printChanged = true; + break; + } + } + if (arr.isEmpty()) { + printingUsers.remove(uid); + } + } + } else { if (arr == null) { arr = new ArrayList<>(); printingUsers.put(uid, arr); @@ -3112,6 +3313,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (u.userId == update.user_id) { exist = true; u.lastTime = currentTime; + u.action = update.action; break; } } @@ -3119,9 +3321,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter PrintingUser newUser = new PrintingUser(); newUser.userId = update.user_id; newUser.lastTime = currentTime; + newUser.action = update.action; arr.add(newUser); printChanged = true; } + } onlinePrivacy.put(update.user_id, ConnectionsManager.getInstance().getCurrentTime()); } } else if (update instanceof TLRPC.TL_updateChatParticipants) { @@ -3181,8 +3385,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter contactsIds.add(-update.user_id); } } - } else if (update instanceof TLRPC.TL_updateActivation) { - //DEPRECATED } else if (update instanceof TLRPC.TL_updateNewAuthorization) { AndroidUtilities.runOnUIThread(new Runnable() { @Override @@ -3247,6 +3449,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (u.userId == update.user_id) { exist = true; u.lastTime = currentTime; + u.action = new TLRPC.TL_sendMessageTypingAction(); break; } } @@ -3254,6 +3457,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter PrintingUser newUser = new PrintingUser(); newUser.userId = update.user_id; newUser.lastTime = currentTime; + newUser.action = new TLRPC.TL_sendMessageTypingAction(); arr.add(newUser); printChanged = true; } @@ -3304,7 +3508,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter newMessage.local_id = newMessage.id = UserConfig.getNewMessageId(); UserConfig.saveConfig(false); newMessage.flags = TLRPC.MESSAGE_FLAG_UNREAD; - newMessage.date = update.date; + newMessage.date = ConnectionsManager.getInstance().getCurrentTime(); newMessage.from_id = 777000; newMessage.to_id = new TLRPC.TL_peerUser(); newMessage.to_id.user_id = UserConfig.getClientUserId(); @@ -3403,14 +3607,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } else if (update instanceof TLRPC.TL_updateUserName) { if (currentUser != null) { + if (!(currentUser instanceof TLRPC.TL_userContact)) { + currentUser.first_name = update.first_name; + currentUser.last_name = update.last_name; + } if (currentUser.username != null && currentUser.username.length() > 0) { usersByUsernames.remove(currentUser.username); } if (update.username != null && update.username.length() > 0) { usersByUsernames.put(update.username, currentUser); } - currentUser.first_name = update.first_name; - currentUser.last_name = update.last_name; currentUser.username = update.username; } toDbUser.first_name = update.first_name; @@ -3427,7 +3633,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } else if (update instanceof TLRPC.TL_updateUserPhone) { if (currentUser != null) { currentUser.phone = update.phone; - Utilities.photoBookQueue.postRunnable(new Runnable() { + Utilities.phoneBookQueue.postRunnable(new Runnable() { @Override public void run() { ContactsController.getInstance().addContactToPhoneBook(currentUser, true); @@ -3470,13 +3676,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (dialog != null) { dialog.notify_settings.mute_until = 0; } - //editor.remove("notify2_" + dialog_id); - //Smart Notifications - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - if (preferences.getInt("notify2_" + dialog_id, 0) != 4) { editor.remove("notify2_" + dialog_id); - } - // MessagesStorage.getInstance().setDialogFlags(dialog_id, 0); } @@ -3569,7 +3769,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } if (!markAsReadEncrypted.isEmpty()) { for (HashMap.Entry entry : markAsReadEncrypted.entrySet()) { - NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesReadedEncrypted, entry.getKey(), entry.getValue()); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesReadEncrypted, entry.getKey(), entry.getValue()); long dialog_id = (long) (entry.getKey()) << 32; TLRPC.TL_dialog dialog = dialogs_dict.get(dialog_id); if (dialog != null) { @@ -3581,6 +3781,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } } + if (!markAsReadMessages.isEmpty()) { + NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesReadContent, markAsReadMessages); + } if (!deletedMessages.isEmpty()) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDeleted, deletedMessages); for (Integer id : deletedMessages) { @@ -3607,6 +3810,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter } MessagesStorage.getInstance().markMessagesAsRead(markAsReadMessagesInbox, markAsReadMessagesOutbox, markAsReadEncrypted, true); } + if (!markAsReadMessages.isEmpty()) { + MessagesStorage.getInstance().markMessagesContentAsRead(markAsReadMessages); + } if (!deletedMessages.isEmpty()) { MessagesStorage.getInstance().markMessagesAsDeleted(deletedMessages, true); } @@ -3690,7 +3896,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceivedNewMessages, uid, messages); for (MessageObject message : messages) { - if (lastMessage == null || (!isEncryptedChat && message.getId() > lastMessage.getId() || isEncryptedChat && message.getId() < lastMessage.getId()) || message.messageOwner.date > lastMessage.messageOwner.date) { + if (lastMessage == null || (!isEncryptedChat && message.getId() > lastMessage.getId() || (isEncryptedChat || message.getId() < 0 && lastMessage.getId() < 0) && message.getId() < lastMessage.getId()) || message.messageOwner.date > lastMessage.messageOwner.date) { lastMessage = message; } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java index 04fe7b66..8ce15a22 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java @@ -106,7 +106,7 @@ public class MessagesStorage { database.executeFast("CREATE TABLE messages(mid INTEGER PRIMARY KEY, uid INTEGER, read_state INTEGER, send_state INTEGER, date INTEGER, data BLOB, out INTEGER, ttl INTEGER, media INTEGER, replydata BLOB)").stepThis().dispose(); database.executeFast("CREATE TABLE chats(uid INTEGER PRIMARY KEY, name TEXT, data BLOB)").stepThis().dispose(); database.executeFast("CREATE TABLE enc_chats(uid INTEGER PRIMARY KEY, user INTEGER, name TEXT, data BLOB, g BLOB, authkey BLOB, ttl INTEGER, layer INTEGER, seq_in INTEGER, seq_out INTEGER, use_count INTEGER, exchange_id INTEGER, key_date INTEGER, fprint INTEGER, fauthkey BLOB, khash BLOB)").stepThis().dispose(); - database.executeFast("CREATE TABLE dialogs(did INTEGER PRIMARY KEY, date INTEGER, unread_count INTEGER, last_mid INTEGER)").stepThis().dispose(); + database.executeFast("CREATE TABLE dialogs(did INTEGER PRIMARY KEY, date INTEGER, unread_count INTEGER, last_mid INTEGER, inbox_max INTEGER, outbox_max INTEGER)").stepThis().dispose(); database.executeFast("CREATE TABLE chat_settings(uid INTEGER PRIMARY KEY, participants BLOB)").stepThis().dispose(); database.executeFast("CREATE TABLE contacts(uid INTEGER PRIMARY KEY, mutual INTEGER)").stepThis().dispose(); database.executeFast("CREATE TABLE pending_read(uid INTEGER PRIMARY KEY, max_id INTEGER)").stepThis().dispose(); @@ -164,7 +164,7 @@ public class MessagesStorage { database.executeFast("CREATE TABLE keyvalue(id TEXT PRIMARY KEY, value TEXT)").stepThis().dispose(); //version - database.executeFast("PRAGMA user_version = 16").stepThis().dispose(); + database.executeFast("PRAGMA user_version = 17").stepThis().dispose(); } else { try { SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1"); @@ -195,7 +195,7 @@ public class MessagesStorage { } } int version = database.executeInt("PRAGMA user_version"); - if (version < 16) { + if (version < 17) { updateDbToLastVersion(version); } } @@ -295,7 +295,7 @@ public class MessagesStorage { if ((length = cursor.byteBufferValue(1, data.buffer)) != 0) { for (int a = 0; a < length / 4; a++) { state.requery(); - state.bindInteger(1, data.readInt32()); + state.bindInteger(1, data.readInt32(false)); state.bindInteger(2, date); state.step(); } @@ -385,6 +385,12 @@ public class MessagesStorage { database.executeFast("PRAGMA user_version = 16").stepThis().dispose(); version = 16; } + if (version == 16 && version < 17) { + database.executeFast("ALTER TABLE dialogs ADD COLUMN inbox_max INTEGER default 0").stepThis().dispose(); + database.executeFast("ALTER TABLE dialogs ADD COLUMN outbox_max INTEGER default 0").stepThis().dispose(); + database.executeFast("PRAGMA user_version = 17").stepThis().dispose(); + version = 17; + } } catch (Exception e) { FileLog.e("tmessages", e); } @@ -523,12 +529,12 @@ public class MessagesStorage { ArrayList chatIds = new ArrayList<>(); ArrayList encryptedChatIds = new ArrayList<>(); - cursor = database.queryFinalized("SELECT read_state, data, send_state, mid, date, uid FROM messages WHERE uid IN (" + ids.toString() + ") AND out = 0 AND read_state = 0 ORDER BY date DESC LIMIT 50"); + cursor = database.queryFinalized("SELECT read_state, data, send_state, mid, date, uid FROM messages WHERE uid IN (" + ids.toString() + ") AND out = 0 AND read_state IN(0,2) ORDER BY date DESC LIMIT 50"); while (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(1)); if (data != null && cursor.byteBufferValue(1, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); - MessageObject.setIsUnread(message, cursor.intValue(0) != 1); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); + MessageObject.setUnreadFlags(message, cursor.intValue(0)); message.id = cursor.intValue(3); message.date = cursor.intValue(4); message.dialog_id = cursor.longValue(5); @@ -762,7 +768,7 @@ public class MessagesStorage { while (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.WallPaper wallPaper = (TLRPC.WallPaper) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.WallPaper wallPaper = TLRPC.WallPaper.TLdeserialize(data, data.readInt32(false), false); wallPapers.add(wallPaper); } buffersStorage.reuseFreeBuffer(data); @@ -876,7 +882,7 @@ public class MessagesStorage { while (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message == null || message.media == null) { continue; } @@ -950,7 +956,7 @@ public class MessagesStorage { while (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.Photo photo = (TLRPC.Photo)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Photo photo = TLRPC.Photo.TLdeserialize(data, data.readInt32(false), false); res.photos.add(photo); } buffersStorage.reuseFreeBuffer(data); @@ -1065,7 +1071,7 @@ public class MessagesStorage { StringBuilder mids = new StringBuilder(); SQLiteCursor cursor = null; if (random_ids == null) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT mid, ttl FROM messages WHERE uid = %d AND out = %d AND read_state = 1 AND ttl > 0 AND date <= %d AND send_state = 0 AND media != 1", ((long) chat_id) << 32, isOut, time)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT mid, ttl FROM messages WHERE uid = %d AND out = %d AND read_state != 0 AND ttl > 0 AND date <= %d AND send_state = 0 AND media != 1", ((long) chat_id) << 32, isOut, time)); } else { String ids = TextUtils.join(",", random_ids); cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.mid, m.ttl FROM messages as m INNER JOIN randoms as r ON m.mid = r.mid WHERE r.random_id IN (%s)", ids)); @@ -1147,7 +1153,7 @@ public class MessagesStorage { cursor.dispose(); } else if (inbox != null && !inbox.isEmpty()) { for (HashMap.Entry entry : inbox.entrySet()) { - SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(mid) FROM messages WHERE uid = %d AND mid <= %d AND read_state = 0 AND out = 0", entry.getKey(), entry.getValue())); + SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(mid) FROM messages WHERE uid = %d AND mid <= %d AND read_state IN(0,2) AND out = 0", entry.getKey(), entry.getValue())); if (cursor.next()) { int count = cursor.intValue(0); if (count == 0) { @@ -1255,7 +1261,7 @@ public class MessagesStorage { if (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - info = (TLRPC.ChatParticipants)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + info = TLRPC.ChatParticipants.TLdeserialize(data, data.readInt32(false), false); } buffersStorage.reuseFreeBuffer(data); } @@ -1318,7 +1324,7 @@ public class MessagesStorage { if (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - info = (TLRPC.ChatParticipants)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + info = TLRPC.ChatParticipants.TLdeserialize(data, data.readInt32(false), false); } buffersStorage.reuseFreeBuffer(data); } @@ -1383,14 +1389,14 @@ public class MessagesStorage { int lower_id = (int)dialog_id; if (lower_id != 0) { - state = database.executeFast("UPDATE messages SET read_state = 1 WHERE uid = ? AND mid <= ? AND read_state = 0 AND out = 0"); + state = database.executeFast("UPDATE messages SET read_state = read_state | 1 WHERE uid = ? AND mid <= ? AND read_state IN(0,2) AND out = 0"); state.requery(); state.bindLong(1, dialog_id); state.bindInteger(2, max_id); state.step(); state.dispose(); } else { - state = database.executeFast("UPDATE messages SET read_state = 1 WHERE uid = ? AND date <= ? AND read_state = 0 AND out = 0"); + state = database.executeFast("UPDATE messages SET read_state = read_state | 1 WHERE uid = ? AND date <= ? AND read_state IN(0,2) AND out = 0"); state.requery(); state.bindLong(1, dialog_id); state.bindInteger(2, max_date); @@ -1613,9 +1619,9 @@ public class MessagesStorage { while (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(1)); if (data != null && cursor.byteBufferValue(1, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (!messageHashMap.containsKey(message.id)) { - MessageObject.setIsUnread(message, cursor.intValue(0) != 1); + MessageObject.setUnreadFlags(message, cursor.intValue(0)); message.id = cursor.intValue(3); message.date = cursor.intValue(4); if (!cursor.isNull(5)) { @@ -1798,14 +1804,14 @@ public class MessagesStorage { } cursor.dispose(); - cursor = database.queryFinalized(String.format(Locale.US, "SELECT min(mid), max(date) FROM messages WHERE uid = %d AND out = 0 AND read_state = 0 AND mid > 0", dialog_id)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT min(mid), max(date) FROM messages WHERE uid = %d AND out = 0 AND read_state IN(0,2) AND mid > 0", dialog_id)); if (cursor.next()) { min_unread_id = cursor.intValue(0); max_unread_date = cursor.intValue(1); } cursor.dispose(); if (min_unread_id != 0) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(*) FROM messages WHERE uid = %d AND mid >= %d AND out = 0 AND read_state = 0", dialog_id, min_unread_id)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(*) FROM messages WHERE uid = %d AND mid >= %d AND out = 0 AND read_state IN(0,2)", dialog_id, min_unread_id)); if (cursor.next()) { count_unread = cursor.intValue(0); } @@ -1843,14 +1849,14 @@ public class MessagesStorage { } cursor.dispose(); - cursor = database.queryFinalized(String.format(Locale.US, "SELECT max(mid), max(date) FROM messages WHERE uid = %d AND out = 0 AND read_state = 0 AND mid < 0", dialog_id)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT max(mid), max(date) FROM messages WHERE uid = %d AND out = 0 AND read_state IN(0,2) AND mid < 0", dialog_id)); if (cursor.next()) { min_unread_id = cursor.intValue(0); max_unread_date = cursor.intValue(1); } cursor.dispose(); if (min_unread_id != 0) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(*) FROM messages WHERE uid = %d AND mid <= %d AND out = 0 AND read_state = 0", dialog_id, min_unread_id)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(*) FROM messages WHERE uid = %d AND mid <= %d AND out = 0 AND read_state IN(0,2)", dialog_id, min_unread_id)); if (cursor.next()) { count_unread = cursor.intValue(0); } @@ -1876,8 +1882,8 @@ public class MessagesStorage { while (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(1)); if (data != null && cursor.byteBufferValue(1, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); - MessageObject.setIsUnread(message, cursor.intValue(0) != 1); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); + MessageObject.setUnreadFlags(message, cursor.intValue(0)); message.id = cursor.intValue(3); message.date = cursor.intValue(4); message.dialog_id = dialog_id; @@ -1900,7 +1906,7 @@ public class MessagesStorage { if (!cursor.isNull(6)) { ByteBufferDesc data2 = buffersStorage.getFreeBuffer(cursor.byteArrayLength(6)); if (data2 != null && cursor.byteBufferValue(6, data2.buffer) != 0) { - message.replyMessage = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data2, data2.readInt32()); + message.replyMessage = TLRPC.Message.TLdeserialize(data2, data2.readInt32(false), false); if (message.replyMessage != null) { fromUser.add(message.replyMessage.from_id); if (message.replyMessage.action != null && message.replyMessage.action.user_id != 0) { @@ -1987,7 +1993,7 @@ public class MessagesStorage { while (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); message.id = cursor.intValue(1); message.date = cursor.intValue(2); message.dialog_id = dialog_id; @@ -2091,7 +2097,7 @@ public class MessagesStorage { if (cursor.next()) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLObject file = TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLObject file = TLClassStore.Instance().TLdeserialize(data, data.readInt32(false), false); if (file != null) { result.add(file); } @@ -2374,11 +2380,13 @@ public class MessagesStorage { buffersStorage.reuseFreeBuffer(data5); if (dialog != null) { - state = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)"); + state = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid, inbox_max, outbox_max) VALUES(?, ?, ?, ?, ?, ?)"); state.bindLong(1, dialog.id); state.bindInteger(2, dialog.last_message_date); state.bindInteger(3, dialog.unread_count); state.bindInteger(4, dialog.top_message); + state.bindInteger(5, dialog.read_inbox_max_id); + state.bindInteger(6, 0); state.step(); state.dispose(); } @@ -2469,7 +2477,7 @@ public class MessagesStorage { try { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.User user = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.User user = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); if (user != null) { if (user.status != null) { user.status.expires = cursor.intValue(1); @@ -2494,7 +2502,7 @@ public class MessagesStorage { try { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.Chat chat = (TLRPC.Chat)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Chat chat = TLRPC.Chat.TLdeserialize(data, data.readInt32(false), false); if (chat != null) { result.add(chat); } @@ -2511,13 +2519,12 @@ public class MessagesStorage { if (chatsToLoad == null || chatsToLoad.length() == 0 || result == null) { return; } - //use_count INTEGER, exchange_id INTEGER, key_date INTEGER, fprint INTEGER, fauthkey BLOB SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT data, user, g, authkey, ttl, layer, seq_in, seq_out, use_count, exchange_id, key_date, fprint, fauthkey, khash FROM enc_chats WHERE uid IN(%s)", chatsToLoad)); while (cursor.next()) { try { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.EncryptedChat chat = TLRPC.EncryptedChat.TLdeserialize(data, data.readInt32(false), false); if (chat != null) { chat.user_id = cursor.intValue(1); if (usersToLoad != null && !usersToLoad.contains(chat.user_id)) { @@ -2634,7 +2641,7 @@ public class MessagesStorage { downloadObject.id = cursor.longValue(0); ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(2)); if (data != null && cursor.byteBufferValue(2, data.buffer) != 0) { - downloadObject.object = TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + downloadObject.object = TLClassStore.Instance().TLdeserialize(data, data.readInt32(false), false); } buffersStorage.reuseFreeBuffer(data); objects.add(downloadObject); @@ -2691,7 +2698,7 @@ public class MessagesStorage { int mid = cursor.intValue(0); ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(1)); if (data != null && cursor.byteBufferValue(1, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message.media instanceof TLRPC.TL_messageMediaWebPage) { message.id = mid; message.media.webpage = webPages.get(message.media.webpage.id); @@ -2865,7 +2872,7 @@ public class MessagesStorage { state.bindInteger(1, messageId); state.bindLong(2, dialog_id); - state.bindInteger(3, (MessageObject.isUnread(message) ? 0 : 1)); + state.bindInteger(3, MessageObject.getUnreadFlags(message)); state.bindInteger(4, message.send_state); state.bindInteger(5, message.date); state.bindByteBuffer(6, data.buffer); @@ -2954,7 +2961,7 @@ public class MessagesStorage { state4.dispose(); state5.dispose(); - state = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)"); + state = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid, inbox_max, outbox_max) VALUES(?, ?, ?, ?, ?, ?)"); for (HashMap.Entry pair : messagesMap.entrySet()) { Long key = pair.getKey(); @@ -2987,6 +2994,8 @@ public class MessagesStorage { } state.bindInteger(3, old_unread_count + unread_count); state.bindInteger(4, messageId); + state.bindInteger(5, 0); + state.bindInteger(6, 0); state.step(); } state.dispose(); @@ -3294,8 +3303,10 @@ public class MessagesStorage { TLRPC.User updateUser = usersDict.get(user.id); if (updateUser != null) { if (updateUser.first_name != null && updateUser.last_name != null) { + if (!(user instanceof TLRPC.TL_userContact)) { user.first_name = updateUser.first_name; user.last_name = updateUser.last_name; + } user.username = updateUser.username; } else if (updateUser.photo != null) { user.photo = updateUser.photo; @@ -3337,25 +3348,22 @@ public class MessagesStorage { } private void markMessagesAsReadInternal(HashMap inbox, HashMap outbox, HashMap encryptedMessages) { - if (Thread.currentThread().getId() != storageQueue.getId()) { - throw new RuntimeException("wrong db thread"); - } try { if (inbox != null) { for (HashMap.Entry entry : inbox.entrySet()) { - database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = 1 WHERE uid = %d AND mid <= %d AND read_state = 0 AND out = 0", entry.getKey(), entry.getValue())).stepThis().dispose(); + database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = read_state | 1 WHERE uid = %d AND mid <= %d AND read_state IN(0,2) AND out = 0", entry.getKey(), entry.getValue())).stepThis().dispose(); } } if (outbox != null) { for (HashMap.Entry entry : outbox.entrySet()) { - database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = 1 WHERE uid = %d AND mid <= %d AND read_state = 0 AND out = 1", entry.getKey(), entry.getValue())).stepThis().dispose(); + database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = read_state | 1 WHERE uid = %d AND mid <= %d AND read_state IN(0,2) AND out = 1", entry.getKey(), entry.getValue())).stepThis().dispose(); } } if (encryptedMessages != null && !encryptedMessages.isEmpty()) { for (HashMap.Entry entry : encryptedMessages.entrySet()) { long dialog_id = ((long)entry.getKey()) << 32; int max_date = entry.getValue(); - SQLitePreparedStatement state = database.executeFast("UPDATE messages SET read_state = 1 WHERE uid = ? AND date <= ? AND read_state = 0 AND out = 1"); + SQLitePreparedStatement state = database.executeFast("UPDATE messages SET read_state = read_state | 1 WHERE uid = ? AND date <= ? AND read_state IN(0,2) AND out = 1"); state.requery(); state.bindLong(1, dialog_id); state.bindInteger(2, max_date); @@ -3368,6 +3376,22 @@ public class MessagesStorage { } } + public void markMessagesContentAsRead(final ArrayList mids) { + if (mids == null || mids.isEmpty()) { + return; + } + storageQueue.postRunnable(new Runnable() { + @Override + public void run() { + try { + database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = read_state | 2 WHERE mid IN (%s)", TextUtils.join(",", mids))).stepThis().dispose(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + } + public void markMessagesAsRead(final HashMap inbox, final HashMap outbox, final HashMap encryptedMessages, boolean useQueue) { if (useQueue) { storageQueue.postRunnable(new Runnable() { @@ -3433,7 +3457,7 @@ public class MessagesStorage { } ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(1)); if (data != null && cursor.byteBufferValue(1, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message == null || message.media == null) { continue; } @@ -3527,8 +3551,8 @@ public class MessagesStorage { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(4)); if (data != null && cursor.byteBufferValue(4, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); - MessageObject.setIsUnread(message, cursor.intValue(5) != 1); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); + MessageObject.setUnreadFlags(message, cursor.intValue(5)); message.id = cursor.intValue(6); message.send_state = cursor.intValue(7); int date = cursor.intValue(8); @@ -3667,7 +3691,7 @@ public class MessagesStorage { message.serializeToStream(data); state.bindInteger(1, message.id); state.bindLong(2, dialog_id); - state.bindInteger(3, (MessageObject.isUnread(message) ? 0 : 1)); + state.bindInteger(3, MessageObject.getUnreadFlags(message)); state.bindInteger(4, message.send_state); state.bindInteger(5, message.date); state.bindByteBuffer(6, data.buffer); @@ -3732,9 +3756,9 @@ public class MessagesStorage { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(4)); if (data != null && cursor.byteBufferValue(4, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message != null) { - MessageObject.setIsUnread(message, cursor.intValue(5) != 1); + MessageObject.setUnreadFlags(message, cursor.intValue(5)); message.id = cursor.intValue(6); int date = cursor.intValue(9); if (date != 0) { @@ -3831,7 +3855,7 @@ public class MessagesStorage { if (!dialogs.dialogs.isEmpty()) { SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)"); - SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)"); + SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid, inbox_max, outbox_max) VALUES(?, ?, ?, ?, ?, ?)"); SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)"); SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO dialog_settings VALUES(?, ?)"); @@ -3850,7 +3874,7 @@ public class MessagesStorage { state.bindInteger(1, message.id); state.bindInteger(2, uid); - state.bindInteger(3, (MessageObject.isUnread(message) ? 0 : 1)); + state.bindInteger(3, MessageObject.getUnreadFlags(message)); state.bindInteger(4, message.send_state); state.bindInteger(5, message.date); state.bindByteBuffer(6, data.buffer); @@ -3863,6 +3887,8 @@ public class MessagesStorage { state2.bindInteger(2, message.date); state2.bindInteger(3, dialog.unread_count); state2.bindInteger(4, dialog.top_message); + state2.bindInteger(5, dialog.read_inbox_max_id); + state2.bindInteger(6, 0); state2.step(); state4.bindLong(1, uid); diff --git a/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java b/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java index 6eab0a11..7ea11323 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java @@ -23,7 +23,7 @@ import java.util.zip.ZipFile; public class NativeLoader { - private final static int LIB_VERSION = 7; + private final static int LIB_VERSION = 8; private final static String LIB_NAME = "tmessages." + LIB_VERSION; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so"; private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so"; diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java index 962de697..a75a4f64 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java +++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java @@ -32,7 +32,7 @@ public class NotificationCenter { public static final int mediaDidLoaded = totalEvents++; public static final int mediaCountDidLoaded = totalEvents++; public static final int encryptedChatUpdated = totalEvents++; - public static final int messagesReadedEncrypted = totalEvents++; + public static final int messagesReadEncrypted = totalEvents++; public static final int encryptedChatCreated = totalEvents++; public static final int userPhotosLoaded = totalEvents++; public static final int removeAllMessagesFromDialog = totalEvents++; @@ -56,6 +56,9 @@ public class NotificationCenter { public static final int newSessionReceived = totalEvents++; public static final int didReceivedWebpages = totalEvents++; public static final int didReceivedWebpagesInUpdates = totalEvents++; + public static final int stickersDidLoaded = totalEvents++; + public static final int didReplacedPhotoInMemCache = totalEvents++; + public static final int messagesReadContent = totalEvents++; public static final int httpFileDidLoaded = totalEvents++; public static final int httpFileDidFailedLoad = totalEvents++; diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java index b31839cb..6785b8aa 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java @@ -17,10 +17,10 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.res.AssetFileDescriptor; +import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.media.AudioManager; -import android.media.MediaPlayer; +import android.media.SoundPool; import android.net.Uri; import android.os.Build; import android.os.SystemClock; @@ -45,9 +45,7 @@ import org.telegram.ui.PopupNotificationActivity; import java.util.ArrayList; import java.util.Calendar; -import java.util.Date; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; public class NotificationsController { @@ -56,7 +54,9 @@ public class NotificationsController { private DispatchQueue notificationsQueue = new DispatchQueue("notificationsQueue"); private ArrayList pushMessages = new ArrayList<>(); + private ArrayList delayedPushMessages = new ArrayList<>(); private HashMap pushMessagesDict = new HashMap<>(); + private HashMap smartNotificationsDialogs = new HashMap<>(); private NotificationManagerCompat notificationManager = null; private HashMap pushDialogs = new HashMap<>(); private HashMap wearNoticationsIds = new HashMap<>(); @@ -69,10 +69,14 @@ public class NotificationsController { private boolean notifyCheck = false; private int lastOnlineFromOtherDevice = 0; private boolean inChatSoundEnabled = true; + private int lastBadgeCount; private long lastSoundPlay; - private MediaPlayer mediaPlayerIn; - private MediaPlayer mediaPlayerOut; + //private MediaPlayer mediaPlayerIn; + //private MediaPlayer mediaPlayerOut; + private SoundPool soundPool; + private int soundIn; + private int soundOut; protected AudioManager audioManager; private static volatile NotificationsController Instance = null; @@ -112,6 +116,7 @@ public class NotificationsController { popupMessages.clear(); wearNoticationsIds.clear(); notifyCheck = false; + lastBadgeCount = 0; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear(); @@ -189,7 +194,7 @@ public class NotificationsController { msg = LocaleController.formatString("NotificationMessageVideo", R.string.NotificationMessageVideo, ContactsController.formatName(user.first_name, user.last_name)); } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) { msg = LocaleController.formatString("NotificationMessageContact", R.string.NotificationMessageContact, ContactsController.formatName(user.first_name, user.last_name)); - } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) { + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) { msg = LocaleController.formatString("NotificationMessageMap", R.string.NotificationMessageMap, ContactsController.formatName(user.first_name, user.last_name)); } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { if (messageObject.isSticker()) { @@ -216,8 +221,14 @@ public class NotificationsController { if (u2 == null) { return null; } + if (user.id == u2.id) { + msg = LocaleController.formatString("NotificationGroupAddSelf", R.string.NotificationGroupAddSelf, ContactsController.formatName(user.first_name, user.last_name), chat.title); + } else { msg = LocaleController.formatString("NotificationGroupAddMember", R.string.NotificationGroupAddMember, ContactsController.formatName(user.first_name, user.last_name), chat.title, ContactsController.formatName(u2.first_name, u2.last_name)); } + } + } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink) { + msg = LocaleController.formatString("NotificationInvitedToGroupByLink", R.string.NotificationInvitedToGroupByLink, ContactsController.formatName(user.first_name, user.last_name), chat.title); } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditTitle) { msg = LocaleController.formatString("NotificationEditedGroupName", R.string.NotificationEditedGroupName, ContactsController.formatName(user.first_name, user.last_name), messageObject.messageOwner.action.title); } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeletePhoto) { @@ -250,7 +261,7 @@ public class NotificationsController { msg = LocaleController.formatString("NotificationMessageGroupVideo", R.string.NotificationMessageGroupVideo, ContactsController.formatName(user.first_name, user.last_name), chat.title); } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) { msg = LocaleController.formatString("NotificationMessageGroupContact", R.string.NotificationMessageGroupContact, ContactsController.formatName(user.first_name, user.last_name), chat.title); - } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) { + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) { msg = LocaleController.formatString("NotificationMessageGroupMap", R.string.NotificationMessageGroupMap, ContactsController.formatName(user.first_name, user.last_name), chat.title); } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { if (messageObject.isSticker()) { @@ -288,14 +299,14 @@ public class NotificationsController { private void scheduleNotificationDelay(boolean onlineReason) { try { - FileLog.e("tmessages", "delay notification start"); + FileLog.e("tmessages", "delay notification start, onlineReason = " + onlineReason); AlarmManager alarm = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE); PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, NotificationDelay.class), 0); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); if (onlineReason) { alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 3 * 1000, pintent); } else { - alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 500, pintent); + alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pintent); } } catch (Exception e) { FileLog.e("tmessages", e); @@ -304,7 +315,10 @@ public class NotificationsController { protected void notificationDelayReached() { FileLog.e("tmessages", "delay reached"); + if (!delayedPushMessages.isEmpty()) { showOrUpdateNotification(true); + delayedPushMessages.clear(); + } } protected void repeatNotificationMaybe() { @@ -321,6 +335,7 @@ public class NotificationsController { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { + FileLog.e("tmessages", "set last online from other device = " + time); lastOnlineFromOtherDevice = time; } }); @@ -366,54 +381,47 @@ public class NotificationsController { boolean inAppPreview = false; boolean inAppPriority = false; int priority = 0; - int priority_override = 0; - int vibrate_override = 0; + int priorityOverride = 0; + int vibrateOverride = 0; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); - int notify_override = preferences.getInt("notify2_" + override_dialog_id, 0); - if (notify_override == 3) { - int mute_until = preferences.getInt("notifyuntil_" + override_dialog_id, 0); - if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { - notify_override = 2; - } - } - if (!notifyAboutLast || notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || chat_id != 0 && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0) { + int notifyOverride = getNotifyOverride(preferences, override_dialog_id); + if (!notifyAboutLast || notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || chat_id != 0 && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0) { notifyDisabled = true; } - //Smart notifications - boolean use_smart_notify = preferences.getBoolean("smart_notify_" + dialog_id, false); - Long smart_notify_timeframe = preferences.getLong("smart_notify_timeframe_" + dialog_id, 1); - int smart_notify_max_count = preferences.getInt("smart_notify_max_count_" + dialog_id, 1); - if (chat_id != 0 && use_smart_notify) - { - if (chat.sound_timestamps == null) - chat.sound_timestamps = new LinkedList<>(); - boolean shouldAdd = true; - Date firstNotification = chat.sound_timestamps.peek(); - Date currentDate = new Date(); - if (firstNotification != null) { - if (currentDate.getTime() - firstNotification.getTime() < smart_notify_timeframe * 1000 && chat.sound_timestamps.size () >= smart_notify_max_count) { - shouldAdd = false; - } - } - if (!shouldAdd) { + + if (!notifyDisabled && dialog_id == override_dialog_id && chat != null) { + int notifyMaxCount = preferences.getInt("smart_max_count_" + dialog_id, 2); + int notifyDelay = preferences.getInt("smart_delay_" + dialog_id, 3 * 60); + if (notifyMaxCount != 0) { + Point dialogInfo = smartNotificationsDialogs.get(dialog_id); + if (dialogInfo == null) { + dialogInfo = new Point(1, (int) (System.currentTimeMillis() / 1000)); + smartNotificationsDialogs.put(dialog_id, dialogInfo); + } else { + int lastTime = dialogInfo.y; + if (lastTime + notifyDelay < System.currentTimeMillis() / 1000) { + dialogInfo.set(1, (int) (System.currentTimeMillis() / 1000)); + } else { + int count = dialogInfo.x; + if (count < notifyMaxCount) { + dialogInfo.set(count + 1, (int) (System.currentTimeMillis() / 1000)); + } else { notifyDisabled = true; } - else { - if (chat.sound_timestamps.size() >= smart_notify_max_count) - chat.sound_timestamps.poll(); - chat.sound_timestamps.add(currentDate); + } + } } } - // + String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath(); if (!notifyDisabled) { inAppSounds = preferences.getBoolean("EnableInAppSounds", true); inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true); inAppPreview = preferences.getBoolean("EnableInAppPreview", true); inAppPriority = preferences.getBoolean("EnableInAppPriority", false); - vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0); - priority_override = preferences.getInt("priority_" + dialog_id, 3); + vibrateOverride = preferences.getInt("vibrate_" + dialog_id, 0); + priorityOverride = preferences.getInt("priority_" + dialog_id, 3); boolean vibrateOnlyIfSilent = false; choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null); @@ -440,16 +448,16 @@ public class NotificationsController { ledColor = preferences.getInt("color_" + dialog_id, 0); } - if (priority_override != 3) { - priority = priority_override; + if (priorityOverride != 3) { + priority = priorityOverride; } if (needVibrate == 4) { vibrateOnlyIfSilent = true; needVibrate = 0; } - if (needVibrate == 2 && (vibrate_override == 1 || vibrate_override == 3 || vibrate_override == 5) || needVibrate != 2 && vibrate_override == 2 || vibrate_override != 0) { - needVibrate = vibrate_override; + if (needVibrate == 2 && (vibrateOverride == 1 || vibrateOverride == 3 || vibrateOverride == 5) || needVibrate != 2 && vibrateOverride == 2 || vibrateOverride != 0) { + needVibrate = vibrateOverride; } if (!ApplicationLoader.mainInterfacePaused) { if (!inAppSounds) { @@ -538,7 +546,7 @@ public class NotificationsController { .setGroup("messages") .setGroupSummary(true) //.setColor(0xff2ca5e0); - .setColor(AndroidUtilities.getIntColor("themeColor")); + .setColor(AndroidUtilities.getIntColor("themeColor")); //Plus if (priority == 0) { mBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT); @@ -552,9 +560,6 @@ public class NotificationsController { if (chat == null && user != null && user.phone != null && user.phone.length() > 0) { mBuilder.addPerson("tel:+" + user.phone); } - /*Bundle bundle = new Bundle(); - bundle.putString(NotificationCompat.EXTRA_PEOPLE, ); - mBuilder.setExtras()*/ String lastMessage = null; String lastMessageFull = null; @@ -586,7 +591,6 @@ public class NotificationsController { } if (i == 0) { lastMessageFull = message; - //lastMessage = getStringForMessage(pushMessages.get(i), true); lastMessage = lastMessageFull; } if (pushDialogs.size() == 1) { @@ -818,6 +822,7 @@ public class NotificationsController { } popupMessages.remove(messageObject); pushMessagesDict.remove(messageObject.getId()); + delayedPushMessages.remove(messageObject); pushMessages.remove(a); a--; } @@ -849,6 +854,7 @@ public class NotificationsController { personal_count--; } pushMessages.remove(a); + delayedPushMessages.remove(messageObject); popupMessages.remove(messageObject); pushMessagesDict.remove(messageObject.getId()); a--; @@ -875,14 +881,8 @@ public class NotificationsController { try { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); - int notify_override = preferences.getInt("notify2_" + openned_dialog_id, 0); - if (notify_override == 3) { - int mute_until = preferences.getInt("notifyuntil_" + openned_dialog_id, 0); - if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { - notify_override = 2; - } - } - if (notify_override == 2) { + int notifyOverride = getNotifyOverride(preferences, openned_dialog_id); + if (notifyOverride == 2) { return; } notificationsQueue.postRunnable(new Runnable() { @@ -892,7 +892,14 @@ public class NotificationsController { return; } try { - if (mediaPlayerIn == null) { + if (soundPool == null) { + soundPool = new SoundPool(4, AudioManager.STREAM_SYSTEM, 0); + } + if (soundIn == 0) { + soundIn = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1); + } + soundPool.play(soundIn, 1.0f, 1.0f, 1, 0, 1.0f); + /*if (mediaPlayerIn == null) { AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_in); if (assetFileDescriptor != null) { mediaPlayerIn = new MediaPlayer(); @@ -903,45 +910,18 @@ public class NotificationsController { mediaPlayerIn.prepare(); } } - mediaPlayerIn.start(); + try { + mediaPlayerIn.pause(); + mediaPlayerIn.seekTo(0); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + mediaPlayerIn.start();*/ } catch (Exception e) { FileLog.e("tmessages", e); } } }); - /*String choosenSoundPath = null; - String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath(); - - choosenSoundPath = preferences.getString("sound_path_" + openned_dialog_id, null); - boolean isChat = (int)(openned_dialog_id) < 0; - if (isChat) { - if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) { - choosenSoundPath = null; - } else if (choosenSoundPath == null) { - choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath); - } - } else { - if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) { - choosenSoundPath = null; - } else if (choosenSoundPath == null) { - choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath); - } - } - - if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) { - if (lastMediaPlayerUri == null || !choosenSoundPath.equals(lastMediaPlayerUri)) { - lastMediaPlayerUri = choosenSoundPath; - mediaPlayer.reset(); - mediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); - if (choosenSoundPath.equals(defaultPath)) { - mediaPlayer.setDataSource(ApplicationLoader.applicationContext, Settings.System.DEFAULT_NOTIFICATION_URI); - } else { - mediaPlayer.setDataSource(ApplicationLoader.applicationContext, Uri.parse(choosenSoundPath)); - } - mediaPlayer.prepare(); - } - mediaPlayer.start(); - }*/ } catch (Exception e) { FileLog.e("tmessages", e); } @@ -962,7 +942,14 @@ public class NotificationsController { @Override public void run() { try { - if (mediaPlayerOut == null) { + if (soundPool == null) { + soundPool = new SoundPool(4, AudioManager.STREAM_SYSTEM, 0); + } + if (soundOut == 0) { + soundOut = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1); + } + soundPool.play(soundOut, 1.0f, 1.0f, 1, 0, 1.0f); + /*if (mediaPlayerOut == null) { AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_out); if (assetFileDescriptor != null) { mediaPlayerOut = new MediaPlayer(); @@ -973,7 +960,13 @@ public class NotificationsController { mediaPlayerOut.prepare(); } } - mediaPlayerOut.start(); + try { + mediaPlayerOut.pause(); + mediaPlayerOut.seekTo(0); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + mediaPlayerOut.start();*/ } catch (Exception e) { FileLog.e("tmessages", e); } @@ -981,6 +974,17 @@ public class NotificationsController { }); } + private int getNotifyOverride(SharedPreferences preferences, long dialog_id) { + int notifyOverride = preferences.getInt("notify2_" + dialog_id, 0); + if (notifyOverride == 3) { + int muteUntil = preferences.getInt("notifyuntil_" + dialog_id, 0); + if (muteUntil >= ConnectionsManager.getInstance().getCurrentTime()) { + notifyOverride = 2; + } + } + return notifyOverride; + } + public void processNewMessages(ArrayList messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return; @@ -1014,20 +1018,15 @@ public class NotificationsController { boolean isChat = (int)dialog_id < 0; popup = (int)dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { - int notify_override = preferences.getInt("notify2_" + dialog_id, 0); - if (notify_override == 3) { - int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); - if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { - notify_override = 2; - } - } - value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); + int notifyOverride = getNotifyOverride(preferences, dialog_id); + value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupMessages.add(0, messageObject); } + delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(messageObject.getId(), messageObject); if (original_dialog_id != dialog_id) { @@ -1058,24 +1057,22 @@ public class NotificationsController { for (HashMap.Entry entry : dialogsToUpdate.entrySet()) { long dialog_id = entry.getKey(); - int notify_override = preferences.getInt("notify2_" + dialog_id, 0); - if (notify_override == 3) { - int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); - if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { - notify_override = 2; - } - } + int notifyOverride = getNotifyOverride(preferences, dialog_id); if (notifyCheck) { Integer override = pushDialogsOverrideMention.get(dialog_id); if (override != null && override == 1) { pushDialogsOverrideMention.put(dialog_id, 0); - notify_override = 1; + notifyOverride = 1; } } - boolean canAddValue = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int)dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); + boolean canAddValue = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || ((int)dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); Integer currentCount = pushDialogs.get(dialog_id); Integer newCount = entry.getValue(); + if (newCount == 0) { + smartNotificationsDialogs.remove(dialog_id); + } + if (newCount < 0) { if (currentCount == null) { continue; @@ -1098,6 +1095,7 @@ public class NotificationsController { } pushMessages.remove(a); a--; + delayedPushMessages.remove(messageObject); pushMessagesDict.remove(messageObject.getId()); popupMessages.remove(messageObject); } @@ -1107,17 +1105,18 @@ public class NotificationsController { pushDialogs.put(dialog_id, newCount); } } - /*if (old_unread_count != total_unread_count) { TODO - if (lastOnlineFromOtherDevice > ConnectionsManager.getInstance().getCurrentTime()) { - showOrUpdateNotification(false); - scheduleNotificationDelay(true); - } else { - showOrUpdateNotification(notifyCheck); - } - }*/ if (old_unread_count != total_unread_count) { - showOrUpdateNotification(notifyCheck); + if (!notifyCheck) { + delayedPushMessages.clear(); + showOrUpdateNotification(notifyCheck); + } else { + showOrUpdateNotification(false); + scheduleNotificationDelay(lastOnlineFromOtherDevice > ConnectionsManager.getInstance().getCurrentTime()); + } } + /*if (old_unread_count != total_unread_count) { + showOrUpdateNotification(notifyCheck); + }*/ notifyCheck = false; if (preferences.getBoolean("badgeNumber", true)) { setBadge(ApplicationLoader.applicationContext, total_unread_count); @@ -1153,14 +1152,8 @@ public class NotificationsController { } Boolean value = settingsCache.get(dialog_id); if (value == null) { - int notify_override = preferences.getInt("notify2_" + dialog_id, 0); - if (notify_override == 3) { - int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); - if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { - notify_override = 2; - } - } - value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); + int notifyOverride = getNotifyOverride(preferences, dialog_id); + value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { @@ -1177,19 +1170,13 @@ public class NotificationsController { long dialog_id = entry.getKey(); Boolean value = settingsCache.get(dialog_id); if (value == null) { - int notify_override = preferences.getInt("notify2_" + dialog_id, 0); - if (notify_override == 3) { - int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); - if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { - notify_override = 2; - } - } + int notifyOverride = getNotifyOverride(preferences, dialog_id); Integer override = pushDialogsOverrideMention.get(dialog_id); if (override != null && override == 1) { pushDialogsOverrideMention.put(dialog_id, 0); - notify_override = 1; + notifyOverride = 1; } - value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); + value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (!value) { @@ -1218,10 +1205,14 @@ public class NotificationsController { notificationsQueue.postRunnable(new Runnable() { @Override public void run() { + if (lastBadgeCount == count) { + return; + } + lastBadgeCount = count; try { ContentValues cv = new ContentValues(); //cv.put("tag", "org.telegram.messenger/org.telegram.ui.LaunchActivity"); - cv.put("tag", context.getPackageName() + "/org.telegram.ui.LaunchActivity"); + cv.put("tag", context.getPackageName() + "/org.telegram.ui.LaunchActivity"); //Plus cv.put("count", count); context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); } catch (Throwable e) { diff --git a/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java b/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java index 6a34ea26..2866763a 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java @@ -542,7 +542,7 @@ public class SecretChatHelper { File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg"); File cacheFile2 = FileLoader.getPathToAttach(size); cacheFile.renameTo(cacheFile2); - ImageLoader.getInstance().replaceImageInCache(fileName, fileName2); + ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location); ArrayList arr = new ArrayList<>(); arr.add(newMsg); MessagesStorage.getInstance().putMessages(arr, false, true, false, 0); @@ -557,7 +557,7 @@ public class SecretChatHelper { newMsg.media.video.w = video.w; newMsg.media.video.h = video.h; newMsg.media.video.date = video.date; - newMsg.media.video.caption = ""; + newMsg.media.caption = video.caption != null ? video.caption : ""; newMsg.media.video.user_id = video.user_id; newMsg.media.video.size = file.size; newMsg.media.video.id = file.id; @@ -565,6 +565,7 @@ public class SecretChatHelper { newMsg.media.video.key = decryptedMessage.media.key; newMsg.media.video.iv = decryptedMessage.media.iv; newMsg.media.video.mime_type = video.mime_type; + newMsg.media.video.caption = video.caption != null ? video.caption : ""; if (newMsg.attachPath != null && newMsg.attachPath.startsWith(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE).getAbsolutePath())) { File cacheFile = new File(newMsg.attachPath); @@ -893,10 +894,10 @@ public class SecretChatHelper { return null; } newMessage.media = new TLRPC.TL_messageMediaPhoto(); + newMessage.media.caption = ""; newMessage.media.photo = new TLRPC.TL_photo(); newMessage.media.photo.user_id = newMessage.from_id; newMessage.media.photo.date = newMessage.date; - newMessage.media.photo.caption = ""; newMessage.media.photo.geo = new TLRPC.TL_geoPointEmpty(); if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 6000 && decryptedMessage.media.thumb_w <= 100 && decryptedMessage.media.thumb_h <= 100) { TLRPC.TL_photoCachedSize small = new TLRPC.TL_photoCachedSize(); @@ -926,6 +927,7 @@ public class SecretChatHelper { return null; } newMessage.media = new TLRPC.TL_messageMediaVideo(); + newMessage.media.caption = ""; newMessage.media.video = new TLRPC.TL_videoEncrypted(); if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 6000 && decryptedMessage.media.thumb_w <= 100 && decryptedMessage.media.thumb_h <= 100) { newMessage.media.video.thumb = new TLRPC.TL_photoCachedSize(); @@ -943,7 +945,6 @@ public class SecretChatHelper { newMessage.media.video.w = decryptedMessage.media.w; newMessage.media.video.h = decryptedMessage.media.h; newMessage.media.video.date = date; - newMessage.media.video.caption = ""; newMessage.media.video.user_id = from_id; newMessage.media.video.size = file.size; newMessage.media.video.id = file.id; @@ -951,6 +952,7 @@ public class SecretChatHelper { newMessage.media.video.key = decryptedMessage.media.key; newMessage.media.video.iv = decryptedMessage.media.iv; newMessage.media.video.mime_type = decryptedMessage.media.mime_type; + newMessage.media.video.caption = ""; if (newMessage.ttl != 0) { newMessage.ttl = Math.max(newMessage.media.video.duration + 1, newMessage.ttl); } @@ -1300,7 +1302,7 @@ public class SecretChatHelper { ByteBufferDesc is = BuffersStorage.getInstance().getFreeBuffer(message.bytes.length); is.writeRaw(message.bytes); is.position(0); - long fingerprint = is.readInt64(); + long fingerprint = is.readInt64(false); byte[] keyToDecrypt = null; boolean new_key_used = false; if (chat.key_fingerprint == fingerprint) { @@ -1311,12 +1313,12 @@ public class SecretChatHelper { } if (keyToDecrypt != null) { - byte[] messageKey = is.readData(16); + byte[] messageKey = is.readData(16, false); MessageKeyData keyData = Utilities.generateMessageKeyData(keyToDecrypt, messageKey, false); Utilities.aesIgeEncryption(is.buffer, keyData.aesKey, keyData.aesIv, false, false, 24, is.limit() - 24); - int len = is.readInt32(); + int len = is.readInt32(false); if (len < 0 || len > is.limit() - 28) { return null; } @@ -1325,7 +1327,13 @@ public class SecretChatHelper { return null; } - TLObject object = TLClassStore.Instance().TLdeserialize(is, is.readInt32()); + TLObject object = null; + try { + object = TLClassStore.Instance().TLdeserialize(is, is.readInt32(true), true); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + BuffersStorage.getInstance().reuseFreeBuffer(is); if (!new_key_used && AndroidUtilities.getPeerLayerVersion(chat.layer) >= 20) { chat.key_use_count_in++; diff --git a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java index 5b961c34..8a0d4ae5 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java @@ -44,7 +44,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter private HashMap unsentMessages = new HashMap<>(); private HashMap sendingMessages = new HashMap<>(); - private class DelayedMessage { + protected class DelayedMessage { public TLObject sendRequest; public TLRPC.TL_decryptedMessage sendEncryptedRequest; public int type; @@ -458,8 +458,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter sendMessage(video, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject); } else if (messageObject.messageOwner.media.document instanceof TLRPC.TL_document) { sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject); - } else if (messageObject.messageOwner.media.geo instanceof TLRPC.TL_geoPoint) { - sendMessage(messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long, did, messageObject.replyMessageObject); + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) { + sendMessage(messageObject.messageOwner.media, did, messageObject.replyMessageObject); } else if (messageObject.messageOwner.media.phone_number != null) { TLRPC.User user = new TLRPC.TL_userContact(); user.phone = messageObject.messageOwner.media.phone_number; @@ -481,8 +481,53 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } } + public void sendSticker(TLRPC.Document document, long peer, MessageObject replyingMessageObject) { + if (document == null) { + return; + } + if (((int) peer) == 0 && document.thumb instanceof TLRPC.TL_photoSize) { + File file = FileLoader.getPathToAttach(document.thumb, true); + if (file.exists()) { + try { + int len = (int) file.length(); + byte[] arr = new byte[(int) file.length()]; + RandomAccessFile reader = new RandomAccessFile(file, "r"); + reader.readFully(arr); + TLRPC.TL_document newDocument = new TLRPC.TL_document(); + newDocument.thumb = new TLRPC.TL_photoCachedSize(); + newDocument.thumb.location = document.thumb.location; + newDocument.thumb.size = document.thumb.size; + newDocument.thumb.w = document.thumb.w; + newDocument.thumb.h = document.thumb.h; + newDocument.thumb.type = document.thumb.type; + newDocument.thumb.bytes = arr; + + newDocument.id = document.id; + newDocument.access_hash = document.access_hash; + newDocument.date = document.date; + newDocument.mime_type = document.mime_type; + newDocument.size = document.size; + newDocument.dc_id = document.dc_id; + newDocument.attributes = document.attributes; + document = newDocument; + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeSticker) { + document.attributes.remove(a); + document.attributes.add(new TLRPC.TL_documentAttributeSticker_old()); + break; + } + } + SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, peer, replyingMessageObject); + } + public void sendMessage(TLRPC.User user, long peer, MessageObject reply_to_msg) { - sendMessage(null, null, null, null, null, null, user, null, null, null, peer, false, null, reply_to_msg, null, true); + sendMessage(null, null, null, null, null, user, null, null, null, peer, false, null, reply_to_msg, null, true); } public void sendMessage(ArrayList messages, long peer) { @@ -550,6 +595,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ids.add(newMsg.fwd_msg_id); newMsg.date = ConnectionsManager.getInstance().getCurrentTime(); newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD; + if (newMsg.media instanceof TLRPC.TL_messageMediaAudio) { + newMsg.flags |= TLRPC.MESSAGE_FLAG_CONTENT_UNREAD; + } newMsg.dialog_id = peer; newMsg.to_id = to_id; MessageObject newMsgObj = new MessageObject(newMsg, null, true); @@ -560,7 +608,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter putToSendingMessages(newMsg); if (arr.size() == 100 || a == messages.size() - 1) { - MessagesStorage.getInstance().putMessages(arr, false, true, false, 0); + MessagesStorage.getInstance().putMessages(new ArrayList<>(arr), false, true, false, 0); MessagesController.getInstance().updateInterfaceWithMessages(peer, objArr); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); UserConfig.saveConfig(false); @@ -655,38 +703,38 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } public void sendMessage(MessageObject message) { - sendMessage(null, null, null, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath, null, null, true); + sendMessage(null, null, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath, null, null, true); } public void sendMessage(MessageObject message, long peer) { - sendMessage(null, null, null, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath, null, null, true); + sendMessage(null, null, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath, null, null, true); } public void sendMessage(TLRPC.TL_document document, String originalPath, String path, long peer, MessageObject reply_to_msg) { - sendMessage(null, null, null, null, null, null, null, document, null, originalPath, peer, false, path, reply_to_msg, null, true); + sendMessage(null, null, null, null, null, null, document, null, originalPath, peer, false, path, reply_to_msg, null, true); } public void sendMessage(String message, long peer, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks) { - sendMessage(message, null, null, null, null, null, null, null, null, null, peer, false, null, reply_to_msg, webPage, searchLinks); + sendMessage(message, null, null, null, null, null, null, null, null, peer, false, null, reply_to_msg, webPage, searchLinks); } - public void sendMessage(double lat, double lon, long peer, MessageObject reply_to_msg) { - sendMessage(null, lat, lon, null, null, null, null, null, null, null, peer, false, null, reply_to_msg, null, true); + public void sendMessage(TLRPC.MessageMedia location, long peer, MessageObject reply_to_msg) { + sendMessage(null, location, null, null, null, null, null, null, null, peer, false, null, reply_to_msg, null, true); } public void sendMessage(TLRPC.TL_photo photo, String originalPath, String path, long peer, MessageObject reply_to_msg) { - sendMessage(null, null, null, photo, null, null, null, null, null, originalPath, peer, false, path, reply_to_msg, null, true); + sendMessage(null, null, photo, null, null, null, null, null, originalPath, peer, false, path, reply_to_msg, null, true); } public void sendMessage(TLRPC.TL_video video, String originalPath, String path, long peer, MessageObject reply_to_msg) { - sendMessage(null, null, null, null, video, null, null, null, null, originalPath, peer, false, path, reply_to_msg, null, true); + sendMessage(null, null, null, video, null, null, null, null, originalPath, peer, false, path, reply_to_msg, null, true); } public void sendMessage(TLRPC.TL_audio audio, String path, long peer, MessageObject reply_to_msg) { - sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path, reply_to_msg, null, true); + sendMessage(null, null, null, null, null, null, null, audio, null, peer, false, path, reply_to_msg, null, true); } - private void sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks) { + private void sendMessage(String message, TLRPC.MessageMedia location, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks) { if (peer == 0) { return; } @@ -713,8 +761,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter type = 0; } } else if (msgObj.type == 4) { - lat = newMsg.media.geo.lat; - lon = newMsg.media.geo._long; + location = newMsg.media; type = 1; } else if (msgObj.type == 1) { if (msgObj.isForwarded()) { @@ -760,16 +807,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } type = 0; newMsg.message = message; - } else if (lat != null && lon != null) { + } else if (location != null) { if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { newMsg = new TLRPC.TL_message_secret(); } else { newMsg = new TLRPC.TL_message(); } - newMsg.media = new TLRPC.TL_messageMediaGeo(); - newMsg.media.geo = new TLRPC.TL_geoPoint(); - newMsg.media.geo.lat = lat; - newMsg.media.geo._long = lon; + newMsg.media = location; newMsg.message = ""; type = 1; } else if (photo != null) { @@ -779,6 +823,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter newMsg = new TLRPC.TL_message(); } newMsg.media = new TLRPC.TL_messageMediaPhoto(); + newMsg.media.caption = photo.caption != null ? photo.caption : ""; newMsg.media.photo = photo; type = 2; newMsg.message = "-1"; @@ -795,6 +840,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter newMsg = new TLRPC.TL_message(); } newMsg.media = new TLRPC.TL_messageMediaVideo(); + newMsg.media.caption = video.caption != null ? video.caption : ""; newMsg.media.video = video; newMsg.videoEditedInfo = video.videoEditedInfo; type = 3; @@ -868,6 +914,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } newMsg.date = ConnectionsManager.getInstance().getCurrentTime(); newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD; + if (encryptedChat == null && high_id != 1 && newMsg.media instanceof TLRPC.TL_messageMediaAudio) { + newMsg.flags |= TLRPC.MESSAGE_FLAG_CONTENT_UNREAD; + } newMsg.dialog_id = peer; if (reply_to_msg != null) { newMsg.flags |= TLRPC.MESSAGE_FLAG_REPLY; @@ -993,13 +1042,22 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter TLRPC.InputMedia inputMedia = null; DelayedMessage delayedMessage = null; if (type == 1) { - inputMedia = new TLRPC.TL_inputMediaGeoPoint(); + if (location instanceof TLRPC.TL_messageMediaVenue) { + inputMedia = new TLRPC.TL_inputMediaVenue(); + inputMedia.address = location.address; + inputMedia.title = location.title; + inputMedia.provider = location.provider; + inputMedia.venue_id = location.venue_id; + } else { + inputMedia = new TLRPC.TL_inputMediaGeoPoint(); + } inputMedia.geo_point = new TLRPC.TL_inputGeoPoint(); - inputMedia.geo_point.lat = lat; - inputMedia.geo_point._long = lon; + inputMedia.geo_point.lat = location.geo.lat; + inputMedia.geo_point._long = location.geo._long; } else if (type == 2) { if (photo.access_hash == 0) { inputMedia = new TLRPC.TL_inputMediaUploadedPhoto(); + inputMedia.caption = photo.caption != null ? photo.caption : ""; delayedMessage = new DelayedMessage(); delayedMessage.originalPath = originalPath; delayedMessage.type = 0; @@ -1012,6 +1070,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } else { TLRPC.TL_inputMediaPhoto media = new TLRPC.TL_inputMediaPhoto(); media.id = new TLRPC.TL_inputPhoto(); + media.caption = photo.caption != null ? photo.caption : ""; media.id.id = photo.id; media.id.access_hash = photo.access_hash; inputMedia = media; @@ -1023,6 +1082,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } else { inputMedia = new TLRPC.TL_inputMediaUploadedVideo(); } + inputMedia.caption = video.caption != null ? video.caption : ""; inputMedia.duration = video.duration; inputMedia.w = video.w; inputMedia.h = video.h; @@ -1036,6 +1096,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } else { TLRPC.TL_inputMediaVideo media = new TLRPC.TL_inputMediaVideo(); media.id = new TLRPC.TL_inputVideo(); + media.caption = video.caption != null ? video.caption : ""; media.id.id = video.id; media.id.access_hash = video.access_hash; inputMedia = media; @@ -1161,8 +1222,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter reqSend.message = ""; if (type == 1) { reqSend.media = new TLRPC.TL_decryptedMessageMediaGeoPoint(); - reqSend.media.lat = lat; - reqSend.media._long = lon; + reqSend.media.lat = location.geo.lat; + reqSend.media._long = location.geo._long; SecretChatHelper.getInstance().performSendEncryptedRequest(reqSend, newMsgObj.messageOwner, encryptedChat, null, null); } else if (type == 2) { TLRPC.PhotoSize small = photo.sizes.get(0); @@ -1589,7 +1650,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg"); } cacheFile.renameTo(cacheFile2); - ImageLoader.getInstance().replaceImageInCache(fileName, fileName2); + ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location); size2.location = size.location; break; } @@ -1611,7 +1672,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg"); File cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg"); cacheFile.renameTo(cacheFile2); - ImageLoader.getInstance().replaceImageInCache(fileName, fileName2); + ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location); size2.location = size.location; } } @@ -1642,7 +1703,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg"); File cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg"); cacheFile.renameTo(cacheFile2); - ImageLoader.getInstance().replaceImageInCache(fileName, fileName2); + ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location); size2.location = size.location; } } else if (MessageObject.isStickerMessage(sentMessage) && size2.location != null) { @@ -1697,6 +1758,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter arrayList.add(message); } + protected ArrayList getDelayedMessages(String location) { + return delayedMessages.get(location); + } + protected long getNextRandomId() { long val = 0; while (val == 0) { @@ -1749,7 +1814,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter photo.user_id = UserConfig.getClientUserId(); photo.date = ConnectionsManager.getInstance().getCurrentTime(); photo.sizes = sizes; - photo.caption = ""; photo.geo = new TLRPC.TL_geoPointEmpty(); return photo; } @@ -1811,11 +1875,15 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter document.size = (int)f.length(); document.dc_id = 0; if (ext.length() != 0) { - String mimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); - if (mimeType != null) { - document.mime_type = mimeType; + if (ext.toLowerCase().equals("webp")) { + document.mime_type = "image/webp"; } else { - document.mime_type = "application/octet-stream"; + 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"; @@ -1929,9 +1997,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter }).start(); } - public static void prepareSendingPhoto(String imageFilePath, Uri imageUri, long dialog_id, MessageObject reply_to_msg) { + public static void prepareSendingPhoto(String imageFilePath, Uri imageUri, long dialog_id, MessageObject reply_to_msg, CharSequence caption) { ArrayList paths = null; ArrayList uris = null; + ArrayList captions = null; if (imageFilePath != null && imageFilePath.length() != 0) { paths = new ArrayList<>(); paths.add(imageFilePath); @@ -1940,7 +2009,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter uris = new ArrayList<>(); uris.add(imageUri); } - prepareSendingPhotos(paths, uris, dialog_id, reply_to_msg); + if (caption != null) { + captions = new ArrayList<>(); + captions.add(caption.toString()); + } + prepareSendingPhotos(paths, uris, dialog_id, reply_to_msg, captions); } public static void prepareSendingPhotosSearch(final ArrayList photos, final long dialog_id, final MessageObject reply_to_msg) { @@ -1951,7 +2024,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter @Override public void run() { boolean isEncrypted = (int)dialog_id == 0; - for (final MediaController.SearchImage searchImage : photos) { + for (int a = 0; a < photos.size(); a++) { + final MediaController.SearchImage searchImage = photos.get(a); if (searchImage.type == 1) { TLRPC.TL_document document = null; if (!isEncrypted) { @@ -2029,7 +2103,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter photo = new TLRPC.TL_photo(); photo.user_id = UserConfig.getClientUserId(); photo.date = ConnectionsManager.getInstance().getCurrentTime(); - photo.caption = ""; photo.geo = new TLRPC.TL_geoPointEmpty(); TLRPC.TL_photoSize photoSize = new TLRPC.TL_photoSize(); photoSize.w = searchImage.width; @@ -2042,6 +2115,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } } if (photo != null) { + if (searchImage.caption != null) { + photo.caption = searchImage.caption.toString(); + } final String originalPathFinal = searchImage.imageUrl; final TLRPC.TL_photo photoFinal = photo; final boolean needDownloadHttpFinal = needDownloadHttp; @@ -2058,7 +2134,32 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter }).start(); } - public static void prepareSendingPhotos(ArrayList paths, ArrayList uris, final long dialog_id, final MessageObject reply_to_msg) { + private static String getTrimmedString(String src) { + String result = src.trim(); + if (result.length() == 0) { + return result; + } + while (src.startsWith("\n")) { + src = src.substring(1); + } + while (src.endsWith("\n")) { + src = src.substring(0, src.length() - 1); + } + return src; + } + + public static void prepareSendingText(String text, long dialog_id) { + text = getTrimmedString(text); + if (text.length() != 0) { + int count = (int) Math.ceil(text.length() / 4096.0f); + for (int a = 0; a < count; a++) { + String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length())); + SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, null, null, true); + } + } + } + + public static void prepareSendingPhotos(ArrayList paths, ArrayList uris, final long dialog_id, final MessageObject reply_to_msg, final ArrayList captions) { if (paths == null && uris == null || paths != null && paths.isEmpty() || uris != null && uris.isEmpty()) { return; } @@ -2080,6 +2181,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter int count = !pathsCopy.isEmpty() ? pathsCopy.size() : urisCopy.size(); String path = null; Uri uri = null; + String extension = null; for (int a = 0; a < count; a++) { if (!pathsCopy.isEmpty()) { path = pathsCopy.get(a); @@ -2096,16 +2198,23 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter boolean isDocument = false; if (tempPath != null && (tempPath.endsWith(".gif") || tempPath.endsWith(".webp"))) { + if (tempPath.endsWith(".gif")) { + extension = "gif"; + } else { + extension = "webp"; + } isDocument = true; } else if (tempPath == null && uri != null) { if (MediaController.isGif(uri)) { isDocument = true; originalPath = uri.toString(); tempPath = MediaController.copyDocumentToCache(uri, "gif"); + extension = "gif"; } else if (MediaController.isWebp(uri)) { isDocument = true; originalPath = uri.toString(); tempPath = MediaController.copyDocumentToCache(uri, "webp"); + extension = "webp"; } } @@ -2134,6 +2243,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter photo = SendMessagesHelper.getInstance().generatePhotoSizes(path, uri); } if (photo != null) { + if (captions != null) { + photo.caption = captions.get(a); + } final String originalPathFinal = originalPath; final TLRPC.TL_photo photoFinal = photo; AndroidUtilities.runOnUIThread(new Runnable() { @@ -2147,7 +2259,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } if (sendAsDocuments != null && !sendAsDocuments.isEmpty()) { for (int a = 0; a < sendAsDocuments.size(); a++) { - prepareSendingDocumentInternal(sendAsDocuments.get(a), sendAsDocumentsOriginal.get(a), null, "gif", dialog_id, reply_to_msg); + prepareSendingDocumentInternal(sendAsDocuments.get(a), sendAsDocumentsOriginal.get(a), null, extension, dialog_id, reply_to_msg); } } } @@ -2190,7 +2302,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } else { video.thumb.type = "s"; } - video.caption = ""; video.mime_type = "video/mp4"; video.id = 0; UserConfig.saveConfig(false); diff --git a/TMessagesProj/src/main/java/org/telegram/android/query/SharedMediaQuery.java b/TMessagesProj/src/main/java/org/telegram/android/query/SharedMediaQuery.java index aab9255e..345b0e49 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/query/SharedMediaQuery.java +++ b/TMessagesProj/src/main/java/org/telegram/android/query/SharedMediaQuery.java @@ -20,7 +20,6 @@ import org.telegram.messenger.ByteBufferDesc; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.messenger.RPCRequest; -import org.telegram.messenger.TLClassStore; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; @@ -178,7 +177,7 @@ public class SharedMediaQuery { } final ArrayList objects = new ArrayList<>(); for (TLRPC.Message message : res.messages) { - objects.add(new MessageObject(message, usersLocal, false)); + objects.add(new MessageObject(message, usersLocal, true)); } AndroidUtilities.runOnUIThread(new Runnable() { @@ -324,7 +323,7 @@ public class SharedMediaQuery { while (cursor.next()) { ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); message.id = cursor.intValue(1); message.dialog_id = uid; if ((int)uid == 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AbsSerializedData.java b/TMessagesProj/src/main/java/org/telegram/messenger/AbsSerializedData.java index 0f0bb480..1e24cd4e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AbsSerializedData.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AbsSerializedData.java @@ -20,17 +20,19 @@ public abstract class AbsSerializedData { public abstract void writeByteArray(byte[] b, int offset, int count); public abstract void writeByteArray(byte[] b); public abstract void writeDouble(double d); - public abstract int readInt32(); - public abstract int readInt32(boolean[] error); - public abstract boolean readBool(); - public abstract long readInt64(); - public abstract long readInt64(boolean[] error); - public abstract void readRaw(byte[] b); - public abstract byte[] readData(int count); - public abstract String readString(); - public abstract byte[] readByteArray(); - public abstract ByteBufferDesc readByteBuffer(); public abstract void writeByteBuffer(ByteBufferDesc buffer); - public abstract double readDouble(); + + public abstract int readInt32(boolean exception); + public abstract boolean readBool(boolean exception); + public abstract long readInt64(boolean exception); + public abstract void readRaw(byte[] b, boolean exception); + public abstract byte[] readData(int count, boolean exception); + public abstract String readString(boolean exception); + public abstract byte[] readByteArray(boolean exception); + public abstract ByteBufferDesc readByteBuffer(boolean exception); + public abstract double readDouble(boolean exception); + public abstract int length(); + public abstract void skip(int count); + public abstract int getPosition(); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index 0525ac4d..2dcace50 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -17,8 +17,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -67,6 +65,7 @@ public class ApplicationLoader extends Application { public static volatile boolean mainInterfacePaused = true; public static boolean SHOW_ANDROID_EMOJI; + public static boolean KEEP_ORIGINAL_FILENAME; public static boolean isCustomTheme() { return isCustomTheme; @@ -197,7 +196,7 @@ public class ApplicationLoader extends Application { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SHOW_ANDROID_EMOJI = preferences.getBoolean("showAndroidEmoji", false); - + KEEP_ORIGINAL_FILENAME = preferences.getBoolean("keepOriginalFilename", false); startPushService(); } @@ -278,8 +277,7 @@ public class ApplicationLoader extends Application { return ""; } int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE); - int currentVersion = getAppVersion(); - if (registeredVersion != currentVersion) { + if (registeredVersion != BuildVars.BUILD_VERSION) { FileLog.d("tmessages", "App version changed."); return ""; } @@ -290,15 +288,6 @@ public class ApplicationLoader extends Application { return getSharedPreferences(ApplicationLoader.class.getSimpleName(), Context.MODE_PRIVATE); } - public static int getAppVersion() { - try { - PackageInfo packageInfo = applicationContext.getPackageManager().getPackageInfo(applicationContext.getPackageName(), 0); - return packageInfo.versionCode; - } catch (PackageManager.NameNotFoundException e) { - throw new RuntimeException("Could not get package name: " + e); - } - } - private void registerInBackground() { AsyncTask task = new AsyncTask() { @Override @@ -359,7 +348,7 @@ public class ApplicationLoader extends Application { private void storeRegistrationId(Context context, String regId) { final SharedPreferences prefs = getGCMPreferences(context); - int appVersion = getAppVersion(); + int appVersion = BuildVars.BUILD_VERSION; 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/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index d2b91b67..3ccd1a78 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -10,10 +10,14 @@ package org.telegram.messenger; public class BuildVars { public static boolean DEBUG_VERSION = false; - public static int APP_ID = 0; //obtain your own APP_ID at https://core.telegram.org/api/obtaining_api_id - public static String APP_HASH = ""; //obtain your own APP_HASH at https://core.telegram.org/api/obtaining_api_id - public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here"; - public static String GCM_SENDER_ID = "760348033672"; - public static String SEND_LOGS_EMAIL = "email@gmail.com"; - public static String BING_SEARCH_KEY = ""; //obtain your own KEY at https://www.bing.com/dev/en-us/dev-center + public static int BUILD_VERSION = 521; + public static int APP_ID = 16623; //obtain your own APP_ID at https://core.telegram.org/api/obtaining_api_id + public static String APP_HASH = "8c9dbfe58437d1739540f5d53c72ae4b"; //obtain your own APP_HASH at https://core.telegram.org/api/obtaining_api_id + public static String HOCKEY_APP_HASH = "9602f502a85552c90543497e91a071f0";//"a5b5c4f551dadedc9918d9766a22ca7c"; + public static String GCM_SENDER_ID = "326898382893"; + public static String SEND_LOGS_EMAIL = "androiddeveloperplus@gmail.com"; + public static String BING_SEARCH_KEY = "dKYt6BjhkmFnJABZI/nWs++mx7owYEKZLcdA3DTOO1s"; //obtain your own KEY at https://www.bing.com/dev/en-us/dev-center + public static String FOURSQUARE_API_KEY = "AYVLOEUWYPLCHN113NI41GHUE2NVHO4NHA5XLZWJU152N3ZP"; //obtain your own KEY at https://developer.foursquare.com/ + public static String FOURSQUARE_API_ID = "CRY3VMYDJYBKQQDCZ4YY3ZAACTIITLVMBUUEDSPRXNZVZZA1"; //obtain your own API_ID at https://developer.foursquare.com/ + public static String FOURSQUARE_API_VERSION = "20150326"; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ByteBufferDesc.java b/TMessagesProj/src/main/java/org/telegram/messenger/ByteBufferDesc.java index f36049bc..ca366b0b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ByteBufferDesc.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ByteBufferDesc.java @@ -109,7 +109,7 @@ public class ByteBufferDesc extends AbsSerializedData { } else { len += b.length; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write raw error"); } } @@ -121,7 +121,7 @@ public class ByteBufferDesc extends AbsSerializedData { } else { len += count; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write raw error"); } } @@ -145,7 +145,7 @@ public class ByteBufferDesc extends AbsSerializedData { public void writeString(String s) { try { writeByteArray(s.getBytes("UTF-8")); - } catch(Exception x) { + } catch(Exception e) { FileLog.e("tmessages", "write string error"); } } @@ -182,7 +182,7 @@ public class ByteBufferDesc extends AbsSerializedData { } i++; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write byte array error"); } } @@ -219,7 +219,7 @@ public class ByteBufferDesc extends AbsSerializedData { } i++; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write byte array error"); } } @@ -227,7 +227,7 @@ public class ByteBufferDesc extends AbsSerializedData { public void writeDouble(double d) { try { writeInt64(Double.doubleToRawLongBits(d)); - } catch(Exception x) { + } catch(Exception e) { FileLog.e("tmessages", "write double error"); } } @@ -280,72 +280,92 @@ public class ByteBufferDesc extends AbsSerializedData { } } - public int readInt32() { - return readInt32(null); + public int getIntFromByte(byte b) { + return b >= 0 ? b : ((int)b) + 256; } - public int readInt32(boolean[] error) { + public int length() { + if (!justCalc) { + return buffer.position(); + } + return len; + } + + public void skip(int count) { + if (count == 0) { + return; + } + if (!justCalc) { + buffer.position(buffer.position() + count); + } else { + len += count; + } + } + + public int getPosition() { + return buffer.position(); + } + + public int readInt32(boolean exception) { try { - int i = buffer.getInt(); - if (error != null) { - error[0] = false; + return buffer.getInt(); + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read int32 error", e); + } else { + FileLog.e("tmessages", "read int32 error"); } - return i; - } catch (Exception x) { - if (error != null) { - error[0] = true; - } - FileLog.e("tmessages", "read int32 error"); } return 0; } - public boolean readBool() { - int consructor = readInt32(); + public boolean readBool(boolean exception) { + int consructor = readInt32(exception); if (consructor == 0x997275b5) { return true; } else if (consructor == 0xbc799737) { return false; } - FileLog.e("tmessages", "Not bool value!"); + if (exception) { + throw new RuntimeException("Not bool value!"); + } else { + FileLog.e("tmessages", "Not bool value!"); + } return false; } - public long readInt64() { - return readInt64(null); - } - - public long readInt64(boolean[] error) { + public long readInt64(boolean exception) { try { - long i = buffer.getLong(); - if (error != null) { - error[0] = false; + return buffer.getLong(); + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read int64 error", e); + } else { + FileLog.e("tmessages", "read int64 error"); } - return i; - } catch (Exception x) { - if (error != null) { - error[0] = true; - } - FileLog.e("tmessages", "read int64 error"); } return 0; } - public void readRaw(byte[] b) { + public void readRaw(byte[] b, boolean exception) { try { buffer.get(b); - } catch (Exception x) { - FileLog.e("tmessages", "read raw error"); + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read raw error", e); + } else { + FileLog.e("tmessages", "read raw error"); + } } } - public byte[] readData(int count) { + public byte[] readData(int count, boolean exception) { byte[] arr = new byte[count]; - readRaw(arr); + readRaw(arr, exception); return arr; } - public String readString() { + public String readString(boolean exception) { try { int sl = 1; int l = getIntFromByte(buffer.get()); @@ -361,17 +381,17 @@ public class ByteBufferDesc extends AbsSerializedData { i++; } return new String(b, "UTF-8"); - } catch (Exception x) { - FileLog.e("tmessages", "read string error"); + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read string error", e); + } else { + FileLog.e("tmessages", "read string error"); + } } return null; } - public int getIntFromByte(byte b) { - return b >= 0 ? b : ((int)b) + 256; - } - - public byte[] readByteArray() { + public byte[] readByteArray(boolean exception) { try { int sl = 1; int l = getIntFromByte(buffer.get()); @@ -387,13 +407,17 @@ public class ByteBufferDesc extends AbsSerializedData { i++; } return b; - } catch (Exception x) { - FileLog.e("tmessages", "read byte array error"); + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read byte array error", e); + } else { + FileLog.e("tmessages", "read byte array error"); + } } return null; } - public ByteBufferDesc readByteBuffer() { + public ByteBufferDesc readByteBuffer(boolean exception) { try { int sl = 1; int l = getIntFromByte(buffer.get()); @@ -415,25 +439,26 @@ public class ByteBufferDesc extends AbsSerializedData { i++; } return b; - } catch (Exception x) { - FileLog.e("tmessages", "read byte array error"); + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read byte array error", e); + } else { + FileLog.e("tmessages", "read byte array error"); + } } return null; } - public double readDouble() { + public double readDouble(boolean exception) { try { - return Double.longBitsToDouble(readInt64()); - } catch(Exception x) { - FileLog.e("tmessages", "read double error"); + return Double.longBitsToDouble(readInt64(exception)); + } catch(Exception e) { + if (exception) { + throw new RuntimeException("read double error", e); + } else { + FileLog.e("tmessages", "read double error"); + } } return 0; } - - public int length() { - if (!justCalc) { - return buffer.position(); - } - return len; - } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index 3d8fa2a1..b0a32b64 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -65,7 +65,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. private boolean updatingDcSettings = false; private int updatingDcStartTime = 0; private int lastDcUpdateTime = 0; - private int currentAppVersion = 0; private long pushSessionId; private boolean registeringForPush = false; @@ -85,6 +84,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. private PowerManager.WakeLock wakeLock = null; private static volatile ConnectionsManager Instance = null; + public static ConnectionsManager getInstance() { ConnectionsManager localInstance = Instance; if (localInstance == null) { @@ -185,7 +185,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. boolean notFound = true; for (Action actor : actionQueue) { if (actor instanceof HandshakeAction) { - HandshakeAction eactor = (HandshakeAction)actor; + HandshakeAction eactor = (HandshakeAction) actor; if (eactor.datacenter.datacenterId == datacenter.datacenterId) { notFound = false; break; @@ -206,7 +206,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. }; public ConnectionsManager() { - currentAppVersion = ApplicationLoader.getAppVersion(); lastOutgoingMessageId = 0; movingToDatacenterId = DEFAULT_DATACENTER_ID; loadSession(); @@ -218,7 +217,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. Utilities.stageQueue.postRunnable(stageRunnable, 1000); try { - PowerManager pm = (PowerManager)ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE); + PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock"); wakeLock.setReferenceCounted(false); } catch (Exception e) { @@ -352,20 +351,20 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (configFile.exists()) { try { SerializedData data = new SerializedData(configFile); - isTestBackend = data.readInt32(); - int version = data.readInt32(); + isTestBackend = data.readInt32(false); + int version = data.readInt32(false); sessionsToDestroy.clear(); - int count = data.readInt32(); + int count = data.readInt32(false); for (int a = 0; a < count; a++) { - sessionsToDestroy.add(data.readInt64()); + sessionsToDestroy.add(data.readInt64(false)); } - timeDifference = data.readInt32(); - count = data.readInt32(); + timeDifference = data.readInt32(false); + count = data.readInt32(false); for (int a = 0; a < count; a++) { Datacenter datacenter = new Datacenter(data, 0); datacenters.put(datacenter.datacenterId, datacenter); } - currentDatacenterId = data.readInt32(); + currentDatacenterId = data.readInt32(false); data.cleanup(); } catch (Exception e) { UserConfig.clearConfig(); @@ -385,9 +384,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. byte[] sessionsBytes = Base64.decode(sessionsString, Base64.DEFAULT); if (sessionsBytes != null) { SerializedData data = new SerializedData(sessionsBytes); - int count = data.readInt32(); + int count = data.readInt32(false); for (int a = 0; a < count; a++) { - sessionsToDestroy.add(data.readInt64()); + sessionsToDestroy.add(data.readInt64(false)); } data.cleanup(); } @@ -402,7 +401,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. byte[] datacentersBytes = Base64.decode(datacentersString, Base64.DEFAULT); if (datacentersBytes != null) { SerializedData data = new SerializedData(datacentersBytes); - int count = data.readInt32(); + int count = data.readInt32(false); for (int a = 0; a < count; a++) { Datacenter datacenter = new Datacenter(data, 1); datacenters.put(datacenter.datacenterId, datacenter); @@ -625,7 +624,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } long generateMessageId() { - long messageId = (long)((((double)System.currentTimeMillis() + ((double)timeDifference) * 1000) * 4294967296.0) / 1000.0); + long messageId = (long) ((((double) System.currentTimeMillis() + ((double) timeDifference) * 1000) * 4294967296.0) / 1000.0); if (messageId <= lastOutgoingMessageId) { messageId = lastOutgoingMessageId + 1; } @@ -637,13 +636,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } long getTimeFromMsgId(long messageId) { - return (long)(messageId / 4294967296.0 * 1000); + return (long) (messageId / 4294967296.0 * 1000); } //================================================================================ // Requests manage //================================================================================ int lastClassGuid = 1; + public int generateClassGuid() { int guid = lastClassGuid++; requestsByGuids.put(guid, new ArrayList()); @@ -756,7 +756,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (updatingDcSettings) { return; } - updatingDcStartTime = (int)(System.currentTimeMillis() / 1000); + updatingDcStartTime = (int) (System.currentTimeMillis() / 1000); updatingDcSettings = true; TLRPC.TL_help_getConfig getConfig = new TLRPC.TL_help_getConfig(); @@ -767,12 +767,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. return; } if (error == null) { - TLRPC.TL_config config = (TLRPC.TL_config)response; + TLRPC.TL_config config = (TLRPC.TL_config) response; int updateIn = config.expires - getCurrentTime(); if (updateIn <= 0) { updateIn = 120; } - lastDcUpdateTime = (int)(System.currentTimeMillis() / 1000) - DC_UPDATE_TIME + updateIn; + lastDcUpdateTime = (int) (System.currentTimeMillis() / 1000) - DC_UPDATE_TIME + updateIn; ArrayList datacentersArr = new ArrayList<>(); HashMap datacenterMap = new HashMap<>(); for (TLRPC.TL_dcOption datacenterDesc : config.dc_options) { @@ -813,14 +813,17 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. private TLObject wrapInLayer(TLObject object, int datacenterId, RPCRequest request) { if (object.layer() > 0) { Datacenter datacenter = datacenterWithId(datacenterId); - if (datacenter == null || datacenter.lastInitVersion != currentAppVersion) { + if (datacenter == null || datacenter.lastInitVersion != BuildVars.BUILD_VERSION) { registerForPush(); request.initRequest = true; TLRPC.initConnection invoke = new TLRPC.initConnection(); invoke.query = object; invoke.api_id = BuildVars.APP_ID; try { - invoke.lang_code = LocaleController.getLocaleString(Locale.getDefault()); + invoke.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + if (invoke.lang_code == null || invoke.lang_code.length() == 0) { + invoke.lang_code = "en"; + } invoke.device_model = Build.MANUFACTURER + Build.MODEL; if (invoke.device_model == null) { invoke.device_model = "Android unknown"; @@ -962,7 +965,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. public static boolean isNetworkOnline() { try { - ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && (netInfo.isConnectedOrConnecting() || netInfo.isAvailable())) { return true; @@ -974,11 +977,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. return true; } else { netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); - if(netInfo != null && netInfo.isConnectedOrConnecting()) { + if (netInfo != null && netInfo.isConnectedOrConnecting()) { return true; } } - } catch(Exception e) { + } catch (Exception e) { FileLog.e("tmessages", e); return true; } @@ -987,12 +990,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. public static boolean isRoaming() { try { - ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null) { return netInfo.isRoaming(); } - } catch(Exception e) { + } catch (Exception e) { FileLog.e("tmessages", e); } return false; @@ -1000,19 +1003,19 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. public static boolean isConnectedToWiFi() { try { - ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) { return true; } - } catch(Exception e) { + } catch (Exception e) { FileLog.e("tmessages", e); } return false; } public int getCurrentTime() { - return (int)(System.currentTimeMillis() / 1000) + timeDifference; + return (int) (System.currentTimeMillis() / 1000) + timeDifference; } public int getTimeDifference() { @@ -1033,7 +1036,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. genericConnection = defaultDatacenter.getGenericConnection(this); } - int currentTime = (int)(System.currentTimeMillis() / 1000); + int currentTime = (int) (System.currentTimeMillis() / 1000); for (int i = 0; i < runningRequests.size(); i++) { RPCRequest request = runningRequests.get(i); @@ -1062,7 +1065,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } Datacenter requestDatacenter = datacenterWithId(datacenterId); - if (!request.initRequest && requestDatacenter.lastInitVersion != currentAppVersion) { + if (!request.initRequest && requestDatacenter.lastInitVersion != BuildVars.BUILD_VERSION) { request.rpcRequest = wrapInLayer(request.rawRequest, requestDatacenter.datacenterId, request); ByteBufferDesc os = new ByteBufferDesc(true); request.rpcRequest.serializeToStream(os); @@ -1093,7 +1096,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. connection = requestDatacenter.getGenericConnection(this); } else if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0) { connection = requestDatacenter.getDownloadConnection(this); - } else if ((request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0 ) { + } else if ((request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) { connection = requestDatacenter.getUploadConnection(this); } @@ -1203,7 +1206,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. continue; } if (System.currentTimeMillis() / 1000 - lastDestroySessionRequestTime > 2.0) { - lastDestroySessionRequestTime = (int)(System.currentTimeMillis() / 1000); + lastDestroySessionRequestTime = (int) (System.currentTimeMillis() / 1000); TLRPC.TL_destroy_session destroySession = new TLRPC.TL_destroy_session(); destroySession.session_id = it; destroyingSessions.add(it); @@ -1277,7 +1280,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } Datacenter requestDatacenter = datacenterWithId(datacenterId); - if (!request.initRequest && requestDatacenter.lastInitVersion != currentAppVersion) { + if (!request.initRequest && requestDatacenter.lastInitVersion != BuildVars.BUILD_VERSION) { request.rpcRequest = wrapInLayer(request.rawRequest, requestDatacenter.datacenterId, request); } @@ -1363,7 +1366,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. request.runningMessageId = messageId; request.runningMessageSeqNo = networkMessage.protoMessage.seqno; request.serializedLength = requestLength; - request.runningStartTime = (int)(System.currentTimeMillis() / 1000); + request.runningStartTime = (int) (System.currentTimeMillis() / 1000); request.transportChannelToken = connection.channelToken; if (request.requiresCompletion) { runningRequests.add(request); @@ -1486,7 +1489,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. boolean notFound = true; for (Action actor : actionQueue) { if (actor instanceof HandshakeAction) { - HandshakeAction eactor = (HandshakeAction)actor; + HandshakeAction eactor = (HandshakeAction) actor; if (eactor.datacenter.datacenterId == num) { notFound = false; break; @@ -1506,7 +1509,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. boolean notFound = true; for (Action actor : actionQueue) { if (actor instanceof ExportAuthorizationAction) { - ExportAuthorizationAction eactor = (ExportAuthorizationAction)actor; + ExportAuthorizationAction eactor = (ExportAuthorizationAction) actor; if (eactor.datacenter.datacenterId == num) { notFound = false; break; @@ -1554,7 +1557,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } ArrayList messages = new ArrayList<>(); - if(messageList != null) { + if (messageList != null) { messages.addAll(messageList); } @@ -1638,11 +1641,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (BuildVars.DEBUG_VERSION) { if (message.body instanceof TLRPC.invokeWithLayer) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)message.body).query); + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer) message.body).query); } else if (message.body instanceof TLRPC.initConnection) { - TLRPC.initConnection r = (TLRPC.initConnection)message.body; + TLRPC.initConnection r = (TLRPC.initConnection) message.body; if (r.query instanceof TLRPC.invokeWithLayer) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)r.query).query); + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer) r.query).query); } else { FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); } @@ -1652,7 +1655,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } long msg_time = getTimeFromMsgId(message.msg_id); - long currentTime = System.currentTimeMillis() + ((long)timeDifference) * 1000; + long currentTime = System.currentTimeMillis() + ((long) timeDifference) * 1000; if (msg_time < currentTime - 30000 || msg_time > currentTime + 25000) { FileLog.d("tmessages", "wrap in messages continaer"); @@ -1678,11 +1681,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. containerMessages.add(message); if (BuildVars.DEBUG_VERSION) { if (message.body instanceof TLRPC.invokeWithLayer) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)message.body).query); + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer) message.body).query); } else if (message.body instanceof TLRPC.initConnection) { - TLRPC.initConnection r = (TLRPC.initConnection)message.body; + TLRPC.initConnection r = (TLRPC.initConnection) message.body; if (r.query instanceof TLRPC.invokeWithLayer) { - FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer)r.query).query); + FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer) r.query).query); } else { FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); } @@ -1722,7 +1725,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (quickAckId != null) { SerializedData data = new SerializedData(messageKeyFull); - quickAckId.add(data.readInt32() & 0x7fffffff); + quickAckId.add(data.readInt32(false) & 0x7fffffff); data.cleanup(); } @@ -1782,7 +1785,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. performRpc(getFutureSalts, new RPCRequest.RPCRequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { - TLRPC.TL_futuresalts res = (TLRPC.TL_futuresalts)response; + TLRPC.TL_futuresalts res = (TLRPC.TL_futuresalts) response; if (error == null) { int currentTime = getCurrentTime(); datacenter.mergeServerSalts(currentTime, res.salts); @@ -1837,7 +1840,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. req.token = "" + pushSessionId; req.app_sandbox = false; try { - req.lang_code = LocaleController.getLocaleString(Locale.getDefault()); + req.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + if (req.lang_code == null || req.lang_code.length() == 0) { + req.lang_code = "en"; + } req.device_model = Build.MANUFACTURER + Build.MODEL; if (req.device_model == null) { req.device_model = "Android unknown"; @@ -1896,7 +1902,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. Datacenter datacenter = datacenterWithId(connection.getDatacenterId()); if (message instanceof TLRPC.TL_new_session_created) { - TLRPC.TL_new_session_created newSession = (TLRPC.TL_new_session_created)message; + TLRPC.TL_new_session_created newSession = (TLRPC.TL_new_session_created) message; if (!connection.isSessionProcessed(newSession.unique_id)) { FileLog.d("tmessages", "New session:"); @@ -1941,7 +1947,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. timeDifference = (int)((time - currentTime) / 1000 - currentPingTime / 2.0); }*/ - TLRPC.TL_msg_container messageContainer = (TLRPC.TL_msg_container)message; + TLRPC.TL_msg_container messageContainer = (TLRPC.TL_msg_container) message; for (TLRPC.TL_protoMessage innerMessage : messageContainer.messages) { long innerMessageId = innerMessage.msg_id; if (innerMessage.seqno % 2 != 0) { @@ -1989,7 +1995,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. sendingPushPing = false; } } else if (message instanceof TLRPC.TL_futuresalts) { - TLRPC.TL_futuresalts futureSalts = (TLRPC.TL_futuresalts)message; + TLRPC.TL_futuresalts futureSalts = (TLRPC.TL_futuresalts) message; long requestMid = futureSalts.req_msg_id; for (RPCRequest request : runningRequests) { if (request.respondsToMessageId(requestMid)) { @@ -2007,7 +2013,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } } } else if (message instanceof TLRPC.DestroySessionRes) { - TLRPC.DestroySessionRes res = (TLRPC.DestroySessionRes)message; + TLRPC.DestroySessionRes res = (TLRPC.DestroySessionRes) message; ArrayList lst = new ArrayList<>(); lst.addAll(sessionsToDestroy); destroyingSessions.remove(res.session_id); @@ -2019,18 +2025,18 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } } } else if (message instanceof TLRPC.TL_rpc_result) { - TLRPC.TL_rpc_result resultContainer = (TLRPC.TL_rpc_result)message; + TLRPC.TL_rpc_result resultContainer = (TLRPC.TL_rpc_result) message; long resultMid = resultContainer.req_msg_id; boolean ignoreResult = false; FileLog.d("tmessages", "object in rpc_result is " + resultContainer.result); if (resultContainer.result instanceof TLRPC.RpcError) { - String errorMessage = ((TLRPC.RpcError)resultContainer.result).error_message; - FileLog.e("tmessages", String.format("***** RPC error %d: %s", ((TLRPC.RpcError)resultContainer.result).error_code, errorMessage)); + String errorMessage = ((TLRPC.RpcError) resultContainer.result).error_message; + FileLog.e("tmessages", String.format("***** RPC error %d: %s", ((TLRPC.RpcError) resultContainer.result).error_code, errorMessage)); int migrateToDatacenterId = DEFAULT_DATACENTER_ID; - if (((TLRPC.RpcError)resultContainer.result).error_code == 303) { + if (((TLRPC.RpcError) resultContainer.result).error_code == 303) { ArrayList migrateErrors = new ArrayList<>(); migrateErrors.add("NETWORK_MIGRATE_"); migrateErrors.add("PHONE_MIGRATE_"); @@ -2079,21 +2085,16 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. boolean discardResponse = false; boolean isError = false; + boolean allowInitConnection = true; + 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) { - throw new RuntimeException("failed to decomress responce for " + request.rawRequest); - } - resultContainer.result = uncomressed; + TLRPC.TL_gzip_packed packet = (TLRPC.TL_gzip_packed) resultContainer.result; + resultContainer.result = Utilities.decompress(packet.packed_data, request.rawRequest, true); } if (resultContainer.result instanceof TLRPC.RpcError) { + allowInitConnection = false; String errorMessage = ((TLRPC.RpcError) resultContainer.result).error_message; FileLog.e("tmessages", String.format("***** RPC error %d: %s", ((TLRPC.RpcError) resultContainer.result).error_code, errorMessage)); @@ -2106,6 +2107,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. request.runningMinStartTime = request.runningStartTime + delay; request.confirmed = false; } + request.serverFailureCount++; } else if (errorCode == 420) { if ((request.flags & RPCRequest.RPCRequestClassFailOnServerErrors) == 0) { @@ -2135,20 +2137,21 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. discardResponse = true; request.wait = true; - request.runningMinStartTime = (int)(System.currentTimeMillis() / 1000 + waitTime); + request.runningMinStartTime = (int) (System.currentTimeMillis() / 1000 + waitTime); request.confirmed = false; } } implicitError = new TLRPC.TL_error(); - implicitError.code = ((TLRPC.RpcError)resultContainer.result).error_code; - implicitError.text = ((TLRPC.RpcError)resultContainer.result).error_message; + implicitError.code = ((TLRPC.RpcError) resultContainer.result).error_code; + implicitError.text = ((TLRPC.RpcError) resultContainer.result).error_message; } else if (!(resultContainer.result instanceof TLRPC.TL_error)) { - if (request.rawRequest == null || resultContainer.result == null || !request.rawRequest.responseClass().isAssignableFrom(resultContainer.result.getClass())) { + if (request.rawRequest == null || resultContainer.result == null) { + allowInitConnection = false; if (request.rawRequest == null) { FileLog.e("tmessages", "rawRequest is null"); } else { - FileLog.e("tmessages", "***** RPC error: invalid response class " + resultContainer.result + " (" + request.rawRequest.responseClass() + " expected)"); + FileLog.e("tmessages", "***** RPC error: invalid response class " + resultContainer.result + " (for request " + request.rawRequest + ")"); } implicitError = new TLRPC.TL_error(); implicitError.code = -1000; @@ -2161,6 +2164,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. isError = true; request.completionBlock.run(null, implicitError != null ? implicitError : (TLRPC.TL_error) resultContainer.result); } else { + request.completionBlock.run(resultContainer.result, null); if (resultContainer.result instanceof TLRPC.updates_Difference) { pushMessagesReceived = true; AndroidUtilities.runOnUIThread(new Runnable() { @@ -2173,24 +2177,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } }); } - request.completionBlock.run(resultContainer.result, null); } } if (implicitError != null && implicitError.code == 401) { + allowInitConnection = false; isError = true; if (implicitError.text != null && implicitError.text.contains("SESSION_PASSWORD_NEEDED")) { - /*UserConfig.setWaitingForPasswordEnter(true); TODO - UserConfig.saveConfig(false); - if (UserConfig.isClientActivated()) { - discardResponse = true; - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - NotificationCenter.getInstance().postNotificationName(NotificationCenter.needPasswordEnter); - } - }); - }*/ + //ignore this error } else if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) { if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0 && UserConfig.isClientActivated()) { UserConfig.clearConfig(); @@ -2214,9 +2208,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } if (!discardResponse) { - if (request.initRequest && !isError) { - if (datacenter.lastInitVersion != currentAppVersion) { - datacenter.lastInitVersion = currentAppVersion; + if (allowInitConnection && request.initRequest && !isError) { + if (datacenter.lastInitVersion != BuildVars.BUILD_VERSION) { + datacenter.lastInitVersion = BuildVars.BUILD_VERSION; saveSession(); FileLog.e("tmessages", "init connection completed"); } else { @@ -2254,7 +2248,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } else if (message instanceof TLRPC.TL_ping) { } else if (message instanceof TLRPC.TL_bad_msg_notification) { - TLRPC.TL_bad_msg_notification badMsgNotification = (TLRPC.TL_bad_msg_notification)message; + TLRPC.TL_bad_msg_notification badMsgNotification = (TLRPC.TL_bad_msg_notification) message; FileLog.e("tmessages", String.format("***** Bad message: %d", badMsgNotification.error_code)); @@ -2267,7 +2261,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (realId != 0) { long time = getTimeFromMsgId(messageId); long currentTime = System.currentTimeMillis(); - timeDifference = (int)((time - currentTime) / 1000 - currentPingTime / 2.0); + timeDifference = (int) ((time - currentTime) / 1000 - currentPingTime / 2.0); } datacenter.recreateSessions(); @@ -2283,7 +2277,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (messageId != 0) { long time = getTimeFromMsgId(messageId); long currentTime = System.currentTimeMillis(); - timeDifference = (int)((time - currentTime) / 1000 - currentPingTime / 2.0); + timeDifference = (int) ((time - currentTime) / 1000 - currentPingTime / 2.0); lastOutgoingMessageId = Math.max(messageId, lastOutgoingMessageId); } @@ -2316,7 +2310,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. processRequestQueue(RPCRequest.RPCRequestClassTransportMask, datacenter.datacenterId); } } else if (message instanceof TLRPC.MsgDetailedInfo) { - TLRPC.MsgDetailedInfo detailedInfo = (TLRPC.MsgDetailedInfo)message; + TLRPC.MsgDetailedInfo detailedInfo = (TLRPC.MsgDetailedInfo) message; boolean requestResend = false; boolean confirm = true; @@ -2327,8 +2321,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (request.completed) { break; } - if (request.lastResendTime == 0 || request.lastResendTime + 60 < (int)(System.currentTimeMillis() / 1000)) { - request.lastResendTime = (int)(System.currentTimeMillis() / 1000); + if (request.lastResendTime == 0 || request.lastResendTime + 60 < (int) (System.currentTimeMillis() / 1000)) { + request.lastResendTime = (int) (System.currentTimeMillis() / 1000); requestResend = true; } else { confirm = false; @@ -2356,9 +2350,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. connection.addMessageToConfirm(detailedInfo.answer_msg_id); } } else if (message instanceof TLRPC.TL_gzip_packed) { - TLRPC.TL_gzip_packed packet = (TLRPC.TL_gzip_packed)message; - TLObject result = Utilities.decompress(packet.packed_data, getRequestWithMessageId(messageId)); - processMessage(result, messageId, messageSeqNo, messageSalt, connection, innerMsgId, containerMessageId); + TLRPC.TL_gzip_packed packet = (TLRPC.TL_gzip_packed) message; + TLObject result = Utilities.decompress(packet.packed_data, getRequestWithMessageId(messageId), true); + if (result != null) { + processMessage(result, messageId, messageSeqNo, messageSalt, connection, innerMsgId, containerMessageId); + } } else if (message instanceof TLRPC.Updates) { if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) { FileLog.e("tmessages", "received internal push"); @@ -2375,6 +2371,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. resumeNetworkInternal(); } else { pushMessagesReceived = true; + MessagesController.getInstance().processUpdates((TLRPC.Updates) message, false); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { @@ -2384,7 +2381,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } } }); - MessagesController.getInstance().processUpdates((TLRPC.Updates) message, false); } } else { FileLog.e("tmessages", "***** Error: unknown message class " + message); @@ -2464,7 +2460,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } if (BuildVars.DEBUG_VERSION) { try { - ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] networkInfos = cm.getAllNetworkInfo(); for (int a = 0; a < 2; a++) { if (a >= networkInfos.length) { @@ -2491,7 +2487,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. FileLog.e("tmessages", "push connection closed"); if (BuildVars.DEBUG_VERSION) { try { - ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager cm = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] networkInfos = cm.getAllNetworkInfo(); for (int a = 0; a < 2; a++) { if (a >= networkInfos.length) { @@ -2577,7 +2573,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } } if (length == 4) { - int error = data.readInt32(); + int error = data.readInt32(false); FileLog.e("tmessages", "mtproto error = " + error); connection.suspendConnection(true); connection.connect(); @@ -2585,22 +2581,20 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } Datacenter datacenter = datacenterWithId(connection.getDatacenterId()); - long keyId = data.readInt64(); + long keyId = data.readInt64(false); if (keyId == 0) { - long messageId = data.readInt64(); + long messageId = data.readInt64(false); if (connection.isMessageIdProcessed(messageId)) { finishUpdatingState(connection); return; } - int messageLength = data.readInt32(); - int constructor = data.readInt32(); + int messageLength = data.readInt32(false); - TLObject object = TLClassStore.Instance().TLdeserialize(data, constructor, getRequestWithMessageId(messageId)); + TLObject message = deserialize(getRequestWithMessageId(messageId), data, true); - processMessage(object, messageId, 0, 0, connection, 0, 0); - - if (object != null) { + if (message != null) { + processMessage(message, messageId, 0, 0, connection, 0, 0); connection.addProcessedMessageId(messageId); } } else { @@ -2612,13 +2606,13 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. return; } - byte[] messageKey = data.readData(16); + byte[] messageKey = data.readData(16, false); MessageKeyData keyData = Utilities.generateMessageKeyData(datacenter.authKey, messageKey, true); Utilities.aesIgeEncryption(data.buffer, keyData.aesKey, keyData.aesIv, false, false, data.position(), length - 24); - long messageServerSalt = data.readInt64(); - long messageSessionId = data.readInt64(); + long messageServerSalt = data.readInt64(false); + long messageSessionId = data.readInt64(false); if (messageSessionId != connection.getSissionId()) { FileLog.e("tmessages", String.format("***** Error: invalid message session ID (%d instead of %d)", messageSessionId, connection.getSissionId())); @@ -2628,9 +2622,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. boolean doNotProcess = false; - long messageId = data.readInt64(); - int messageSeqNo = data.readInt32(); - int messageLength = data.readInt32(); + long messageId = data.readInt64(false); + int messageSeqNo = data.readInt32(false); + int messageLength = data.readInt32(false); if (connection.isMessageIdProcessed(messageId)) { doNotProcess = true; @@ -2654,12 +2648,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } if (!doNotProcess) { - int constructor = data.readInt32(); - TLObject message = TLClassStore.Instance().TLdeserialize(data, constructor, getRequestWithMessageId(messageId)); - - if (message == null) { - FileLog.e("tmessages", "***** Error parsing message: " + constructor); - } else { + TLObject message = deserialize(getRequestWithMessageId(messageId), data, true); + if (message != null) { FileLog.d("tmessages", "received object " + message); processMessage(message, messageId, messageSeqNo, messageServerSalt, connection, 0, 0); connection.addProcessedMessageId(messageId); @@ -2680,6 +2670,33 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } } + protected TLObject deserialize(TLObject request, AbsSerializedData data, boolean exception) { + int constructor = data.readInt32(exception); + TLObject message = null; + try { + message = TLClassStore.Instance().TLdeserialize(data, constructor, request, exception); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + if (message == null) { + if (request != null) { + try { + message = request.deserializeResponse(data, constructor, exception); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + if (message == null) { + FileLog.e("tmessages", String.format(Locale.US, "***** Error parsing message: %x", constructor)); + } + } else { + FileLog.d("tmessages", String.format(Locale.US, "***** Not found request to parse message: %x", constructor)); + } + } else if (message instanceof TLRPC.TL_rpc_result && ((TLRPC.TL_rpc_result) message).result == null) { + message = null; + } + return message; + } + public TLObject getRequestWithMessageId(long msgId) { for (RPCRequest request : runningRequests) { if (msgId == request.runningMessageId) { @@ -2712,7 +2729,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. @Override public void run(TLObject response, TLRPC.TL_error error) { if (error == null) { - movingAuthorization = (TLRPC.TL_auth_exportedAuthorization)response; + movingAuthorization = (TLRPC.TL_auth_exportedAuthorization) response; authorizeOnMovingDatacenter(); } else { Utilities.stageQueue.postRunnable(new Runnable() { @@ -2797,12 +2814,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. @Override public void ActionDidFinishExecution(final Action action, HashMap params) { if (action instanceof HandshakeAction) { - HandshakeAction eactor = (HandshakeAction)action; + HandshakeAction eactor = (HandshakeAction) action; eactor.datacenter.connection.delegate = this; saveSession(); if (eactor.datacenter.datacenterId == currentDatacenterId || eactor.datacenter.datacenterId == movingToDatacenterId) { - timeDifference = (Integer)params.get("timeDifference"); + timeDifference = (Integer) params.get("timeDifference"); eactor.datacenter.recreateSessions(); clearRequestsForRequestClass(RPCRequest.RPCRequestClassGeneric, eactor.datacenter); @@ -2811,7 +2828,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } processRequestQueue(RPCRequest.RPCRequestClassTransportMask, eactor.datacenter.datacenterId); } else if (action instanceof ExportAuthorizationAction) { - ExportAuthorizationAction eactor = (ExportAuthorizationAction)action; + ExportAuthorizationAction eactor = (ExportAuthorizationAction) action; Datacenter datacenter = eactor.datacenter; datacenter.authorized = true; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java b/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java index 61c63d2a..04ffccfa 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Datacenter.java @@ -45,64 +45,64 @@ public class Datacenter { public Datacenter(SerializedData data, int version) { if (version == 0) { - datacenterId = data.readInt32(); - String address = data.readString(); + datacenterId = data.readInt32(false); + String address = data.readString(false); addresses.add(address); - int port = data.readInt32(); + int port = data.readInt32(false); ports.put(address, port); - int len = data.readInt32(); + int len = data.readInt32(false); if (len != 0) { - authKey = data.readData(len); + authKey = data.readData(len, false); } - len = data.readInt32(); + len = data.readInt32(false); if (len != 0) { - authKeyId = data.readInt64(); + authKeyId = data.readInt64(false); } - authorized = data.readInt32() != 0; - len = data.readInt32(); + authorized = data.readInt32(false) != 0; + len = data.readInt32(false); for (int a = 0; a < len; a++) { ServerSalt salt = new ServerSalt(); - salt.validSince = data.readInt32(); - salt.validUntil = data.readInt32(); - salt.value = data.readInt64(); + salt.validSince = data.readInt32(false); + salt.validUntil = data.readInt32(false); + salt.value = data.readInt64(false); if (authServerSaltSet == null) { authServerSaltSet = new ArrayList<>(); } authServerSaltSet.add(salt); } } else if (version == 1) { - int currentVersion = data.readInt32(); + int currentVersion = data.readInt32(false); if (currentVersion == 2 || currentVersion == 3 || currentVersion == 4) { - datacenterId = data.readInt32(); + datacenterId = data.readInt32(false); if (currentVersion >= 3) { - lastInitVersion = data.readInt32(); + lastInitVersion = data.readInt32(false); } - int len = data.readInt32(); + int len = data.readInt32(false); for (int a = 0; a < len; a++) { - String address = data.readString(); + String address = data.readString(false); addresses.add(address); - ports.put(address, data.readInt32()); + ports.put(address, data.readInt32(false)); } - len = data.readInt32(); + len = data.readInt32(false); if (len != 0) { - authKey = data.readData(len); + authKey = data.readData(len, false); } if (currentVersion == 4) { - authKeyId = data.readInt64(); + authKeyId = data.readInt64(false); } else { - len = data.readInt32(); + len = data.readInt32(false); if (len != 0) { - authKeyId = data.readInt64(); + authKeyId = data.readInt64(false); } } - authorized = data.readInt32() != 0; - len = data.readInt32(); + authorized = data.readInt32(false) != 0; + len = data.readInt32(false); for (int a = 0; a < len; a++) { ServerSalt salt = new ServerSalt(); - salt.validSince = data.readInt32(); - salt.validUntil = data.readInt32(); - salt.value = data.readInt64(); + salt.validSince = data.readInt32(false); + salt.validUntil = data.readInt32(false); + salt.value = data.readInt64(false); if (authServerSaltSet == null) { authServerSaltSet = new ArrayList<>(); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java index 62f21744..bd61dd05 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -8,8 +8,8 @@ package org.telegram.messenger; -import java.io.RandomAccessFile; import java.io.File; +import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.Scanner; @@ -54,6 +54,8 @@ public class FileLoadOperation { private File tempPath = null; private boolean isForceRequest = false; + private static String orgName = null; + public interface FileLoadOperationDelegate { void didFinishLoadingFile(FileLoadOperation operation, File finalFile); void didFailedLoadingFile(FileLoadOperation operation, int state); @@ -83,6 +85,7 @@ public class FileLoadOperation { if (ext == null) { ext = "jpg"; } + orgName = null; } public FileLoadOperation(TLRPC.Video videoLocation) { @@ -149,6 +152,9 @@ public class FileLoadOperation { ext = ""; } } + if(ApplicationLoader.KEEP_ORIGINAL_FILENAME && !ext.contains("webp")){ + orgName = FileLoader.getDocName(documentLocation); + } } public void setForceRequest(boolean forceRequest) { @@ -215,9 +221,19 @@ public class FileLoadOperation { return; } } - + // + if(ApplicationLoader.KEEP_ORIGINAL_FILENAME && orgName != null){ + fileNameFinal = orgName; + } + // cacheFileFinal = new File(storePath, fileNameFinal); boolean exist = cacheFileFinal.exists(); + // + if(exist && orgName != null && ApplicationLoader.KEEP_ORIGINAL_FILENAME){ + exist = false; + cacheFileFinal.delete(); + } + // if (exist && totalBytesCount != 0 && totalBytesCount != cacheFileFinal.length()) { exist = false; cacheFileFinal.delete(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index dad1b9bf..42177106 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -11,9 +11,12 @@ package org.telegram.messenger; import org.telegram.android.AndroidUtilities; import java.io.File; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.HashMap; import java.util.LinkedList; +import java.util.Locale; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Semaphore; @@ -632,6 +635,10 @@ public class FileLoader { } public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList sizes, int side) { + return getClosestPhotoSizeWithSize(sizes, side, false); + } + + public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList sizes, int side, boolean byMinSide) { if (sizes == null || sizes.isEmpty()) { return null; } @@ -641,11 +648,19 @@ public class FileLoader { if (obj == null) { continue; } - int currentSide = obj.w >= obj.h ? obj.w : obj.h; - if (closestObject == null || side > 100 && closestObject.location != null && closestObject.location.dc_id == Integer.MIN_VALUE || obj instanceof TLRPC.TL_photoCachedSize || currentSide <= side && lastSide < currentSide) { + if (byMinSide) { + int currentSide = obj.h >= obj.w ? obj.w : obj.h; + if (closestObject == null || side > 100 && closestObject.location != null && closestObject.location.dc_id == Integer.MIN_VALUE || obj instanceof TLRPC.TL_photoCachedSize || side > lastSide && lastSide < currentSide) { closestObject = obj; lastSide = currentSide; } + } else { + int currentSide = obj.w >= obj.h ? obj.w : obj.h; + if (closestObject == null || side > 100 && closestObject.location != null && closestObject.location.dc_id == Integer.MIN_VALUE || obj instanceof TLRPC.TL_photoCachedSize || currentSide <= side && lastSide < currentSide) { + closestObject = obj; + lastSide = currentSide; + } + } } return closestObject; } @@ -675,6 +690,7 @@ public class FileLoader { ext = ext.substring(idx); } if (ext.length() > 1) { + if(ApplicationLoader.KEEP_ORIGINAL_FILENAME && !ext.contains("webp"))return getDocName(document); //Plus return document.dc_id + "_" + document.id + ext; } else { return document.dc_id + "_" + document.id; @@ -694,6 +710,64 @@ public class FileLoader { } return ""; } + //Plus + public static String getAttachFileName(TLObject attach, boolean out) { + 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 = getDocumentFileName(document); + int idx = -1; + if (ext == null || (idx = ext.lastIndexOf(".")) == -1) { + ext = ""; + } else { + ext = ext.substring(idx); + } + if (ext.length() > 1) { + if(!out && ApplicationLoader.KEEP_ORIGINAL_FILENAME && !ext.contains("webp"))return getDocName(document); + 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; + if (photo.location == null) { + return ""; + } + return photo.location.volume_id + "_" + photo.location.local_id + "." + (photo.location.ext != null ? photo.location.ext : "jpg"); + } else if (attach instanceof TLRPC.Audio) { + TLRPC.Audio audio = (TLRPC.Audio)attach; + return audio.dc_id + "_" + audio.id + ".ogg"; + } else if (attach instanceof TLRPC.FileLocation) { + TLRPC.FileLocation location = (TLRPC.FileLocation)attach; + return location.volume_id + "_" + location.local_id + "." + (location.ext != null ? location.ext : "jpg"); + } + return ""; + } + //Plus + public static String getDocName(TLRPC.Document document) { + String name = getDocumentFileName(document); + //boolean org = false; + //if(org)return name; + String date = document.date +""; + String ext = name; + int idx = -1; + if (ext == null || (idx = ext.lastIndexOf(".")) == -1) { + ext = ""; + } else { + ext = ext.substring(idx); + } + int pos = name.lastIndexOf("."); + SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyHHmmss", Locale.US); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(document.date * 1000L); + date = formatter.format(calendar.getTime()); + if (pos > 0) { + name = name.substring(0, pos) + "_" + date + ext; + } + return name; + } public void deleteFiles(final ArrayList files) { if (files == null || files.isEmpty()) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java b/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java index dc5f426d..cf64c98e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java @@ -340,7 +340,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti Utilities.aesIgeEncryption(answerWithHash.buffer, tmpAesKey.toByteArray(), tmpAesIv.toByteArray(), false, false, 0, serverDhParams.encrypted_answer.length); byte[] answerHash = new byte[20]; - answerWithHash.readRaw(answerHash); + answerWithHash.readRaw(answerHash, false); boolean hashVerified = false; for (int i = 0; i < 16; i++) { @@ -358,8 +358,8 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti return; } - int constructor = answerWithHash.readInt32(); - TLRPC.TL_server_DH_inner_data dhInnerData = (TLRPC.TL_server_DH_inner_data)TLClassStore.Instance().TLdeserialize(answerWithHash, constructor); + int constructor = answerWithHash.readInt32(false); + TLRPC.TL_server_DH_inner_data dhInnerData = TLRPC.TL_server_DH_inner_data.TLdeserialize(answerWithHash, constructor, false); BuffersStorage.getInstance().reuseFreeBuffer(answerWithHash); if (!(dhInnerData instanceof TLRPC.TL_server_DH_inner_data)) { @@ -627,17 +627,17 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti @Override public void tcpConnectionReceivedData(TcpConnection connection, ByteBufferDesc data, int length) { - long keyId = data.readInt64(); + long keyId = data.readInt64(false); if (keyId == 0) { - long messageId = data.readInt64(); + long messageId = data.readInt64(false); if (processedMessageIds.contains(messageId)) { FileLog.d("tmessages", String.format("===== Duplicate message id %d received, ignoring", messageId)); return; } - int messageLength = data.readInt32(); + int messageLength = data.readInt32(false); - int constructor = data.readInt32(); - TLObject object = TLClassStore.Instance().TLdeserialize(data, constructor); + int constructor = data.readInt32(false); + TLObject object = TLClassStore.Instance().TLdeserialize(data, constructor, false); if (object != null) { processedMessageIds.add(messageId); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SerializedData.java b/TMessagesProj/src/main/java/org/telegram/messenger/SerializedData.java index 40847dab..f0130942 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SerializedData.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SerializedData.java @@ -47,6 +47,7 @@ public class SerializedData extends AbsSerializedData { isOut = false; inbuf = new ByteArrayInputStream(data); in = new DataInputStream(inbuf); + len = 0; } public void cleanup() { @@ -131,17 +132,6 @@ public class SerializedData extends AbsSerializedData { } } - public boolean readBool() { - int consructor = readInt32(); - if (consructor == 0x997275b5) { - return true; - } else if (consructor == 0xbc799737) { - return false; - } - FileLog.e("tmessages", "Not bool value!"); - return false; - } - public void writeBool(boolean value) { if (!justCalc) { if (value) { @@ -173,52 +163,6 @@ public class SerializedData extends AbsSerializedData { } } - public int readInt32() { - return readInt32(null); - } - - public int readInt32(boolean[] error) { - try { - int i = 0; - for(int j = 0; j < 4; j++) { - i |= (in.read() << (j * 8)); - } - if (error != null) { - error[0] = false; - } - return i; - } catch(Exception x) { - if (error != null) { - error[0] = true; - } - FileLog.e("tmessages", "read int32 error"); - } - return 0; - } - - public long readInt64() { - return readInt64(null); - } - - public long readInt64(boolean[] error) { - try { - long i = 0; - for(int j = 0; j < 8; j++) { - i |= ((long)in.read() << (j * 8)); - } - if (error != null) { - error[0] = false; - } - return i; - } catch (Exception x) { - if (error != null) { - error[0] = true; - } - FileLog.e("tmessages", "read int64 error"); - } - return 0; - } - public void writeRaw(byte[] b) { try { if (!justCalc) { @@ -226,7 +170,7 @@ public class SerializedData extends AbsSerializedData { } else { len += b.length; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write raw error"); } } @@ -238,7 +182,7 @@ public class SerializedData extends AbsSerializedData { } else { len += count; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write raw error"); } } @@ -246,7 +190,7 @@ public class SerializedData extends AbsSerializedData { public void writeByte(int i) { try { if (!justCalc) { - out.writeByte((byte)i); + out.writeByte((byte) i); } else { len += 1; } @@ -267,68 +211,6 @@ public class SerializedData extends AbsSerializedData { } } - public void readRaw(byte[] b) { - try { - in.read(b); - } catch (Exception x) { - FileLog.e("tmessages", "read raw error"); - } - } - - public byte[] readData(int count) { - byte[] arr = new byte[count]; - readRaw(arr); - return arr; - } - - public String readString() { - try { - int sl = 1; - int l = in.read(); - if(l >= 254) { - l = in.read() | (in.read() << 8) | (in.read() << 16); - sl = 4; - } - byte[] b = new byte[l]; - in.read(b); - int i=sl; - while((l + i) % 4 != 0) { - in.read(); - i++; - } - return new String(b, "UTF-8"); - } catch (Exception x) { - FileLog.e("tmessages", "read string error"); - } - return null; - } - - public byte[] readByteArray() { - try { - int sl = 1; - int l = in.read(); - if (l >= 254) { - l = in.read() | (in.read() << 8) | (in.read() << 16); - sl = 4; - } - byte[] b = new byte[l]; - in.read(b); - int i = sl; - while((l + i) % 4 != 0) { - in.read(); - i++; - } - return b; - } catch (Exception x) { - FileLog.e("tmessages", "read byte array error"); - } - return null; - } - - public ByteBufferDesc readByteBuffer() { - throw new RuntimeException("SerializedData don't support readByteBuffer"); - } - public void writeByteArray(byte[] b) { try { if (b.length <= 253) { @@ -361,7 +243,7 @@ public class SerializedData extends AbsSerializedData { } i++; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write byte array error"); } } @@ -369,7 +251,7 @@ public class SerializedData extends AbsSerializedData { public void writeString(String s) { try { writeByteArray(s.getBytes("UTF-8")); - } catch(Exception x) { + } catch(Exception e) { FileLog.e("tmessages", "write string error"); } } @@ -406,24 +288,15 @@ public class SerializedData extends AbsSerializedData { } i++; } - } catch (Exception x) { + } catch (Exception e) { FileLog.e("tmessages", "write byte array error"); } } - public double readDouble() { - try { - return Double.longBitsToDouble(readInt64()); - } catch(Exception x) { - FileLog.e("tmessages", "read double error"); - } - return 0; - } - public void writeDouble(double d) { try { writeInt64(Double.doubleToRawLongBits(d)); - } catch(Exception x) { + } catch(Exception e) { FileLog.e("tmessages", "write double error"); } } @@ -444,4 +317,172 @@ public class SerializedData extends AbsSerializedData { public byte[] toByteArray() { return outbuf.toByteArray(); } + + public void skip(int count) { + if (count == 0) { + return; + } + if (!justCalc) { + if (in != null) { + try { + in.skipBytes(count); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } else { + len += count; + } + } + + public int getPosition() { + return len; + } + + public boolean readBool(boolean exception) { + int consructor = readInt32(exception); + if (consructor == 0x997275b5) { + return true; + } else if (consructor == 0xbc799737) { + return false; + } + if (exception) { + throw new RuntimeException("Not bool value!"); + } else { + FileLog.e("tmessages", "Not bool value!"); + } + return false; + } + + public void readRaw(byte[] b, boolean exception) { + try { + in.read(b); + len += b.length; + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read raw error", e); + } else { + FileLog.e("tmessages", "read raw error"); + } + } + } + + public byte[] readData(int count, boolean exception) { + byte[] arr = new byte[count]; + readRaw(arr, exception); + return arr; + } + + public String readString(boolean exception) { + try { + int sl = 1; + int l = in.read(); + len++; + if(l >= 254) { + l = in.read() | (in.read() << 8) | (in.read() << 16); + len += 3; + sl = 4; + } + byte[] b = new byte[l]; + in.read(b); + len++; + int i=sl; + while((l + i) % 4 != 0) { + in.read(); + len++; + i++; + } + return new String(b, "UTF-8"); + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read string error", e); + } else { + FileLog.e("tmessages", "read string error"); + } + } + return null; + } + + public byte[] readByteArray(boolean exception) { + try { + int sl = 1; + int l = in.read(); + len++; + if (l >= 254) { + l = in.read() | (in.read() << 8) | (in.read() << 16); + len += 3; + sl = 4; + } + byte[] b = new byte[l]; + in.read(b); + len++; + int i = sl; + while((l + i) % 4 != 0) { + in.read(); + len++; + i++; + } + return b; + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read byte array error", e); + } else { + FileLog.e("tmessages", "read byte array error"); + } + } + return null; + } + + public ByteBufferDesc readByteBuffer(boolean exception) { + throw new RuntimeException("SerializedData don't support readByteBuffer"); + } + + public double readDouble(boolean exception) { + try { + return Double.longBitsToDouble(readInt64(exception)); + } catch(Exception e) { + if (exception) { + throw new RuntimeException("read double error", e); + } else { + FileLog.e("tmessages", "read double error"); + } + } + return 0; + } + + public int readInt32(boolean exception) { + try { + int i = 0; + for(int j = 0; j < 4; j++) { + i |= (in.read() << (j * 8)); + len++; + } + return i; + } catch(Exception e) { + if (exception) { + throw new RuntimeException("read int32 error", e); + } else { + FileLog.e("tmessages", "read int32 error"); + } + } + return 0; + } + + public long readInt64(boolean exception) { + try { + long i = 0; + for(int j = 0; j < 8; j++) { + i |= ((long)in.read() << (j * 8)); + len++; + } + return i; + } catch (Exception e) { + if (exception) { + throw new RuntimeException("read int64 error", e); + } else { + FileLog.e("tmessages", "read int64 error"); + } + } + return 0; + } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java index c3e862ad..8b433f28 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java @@ -16,415 +16,86 @@ public class TLClassStore { public TLClassStore () { classStore = new HashMap<>(); - classStore.put(TLRPC.TL_chatPhotoEmpty.constructor, TLRPC.TL_chatPhotoEmpty.class); - classStore.put(TLRPC.TL_chatPhoto.constructor, TLRPC.TL_chatPhoto.class); classStore.put(TLRPC.TL_futuresalts.constructor, TLRPC.TL_futuresalts.class); - classStore.put(TLRPC.TL_bad_msg_notification.constructor, TLRPC.TL_bad_msg_notification.class); - classStore.put(TLRPC.TL_bad_server_salt.constructor, TLRPC.TL_bad_server_salt.class); + classStore.put(TLRPC.TL_msg_new_detailed_info.constructor, TLRPC.TL_msg_new_detailed_info.class); + classStore.put(TLRPC.TL_msg_detailed_info.constructor, TLRPC.TL_msg_detailed_info.class); classStore.put(TLRPC.TL_error.constructor, TLRPC.TL_error.class); - classStore.put(TLRPC.TL_messages_sentEncryptedMessage.constructor, TLRPC.TL_messages_sentEncryptedMessage.class); - classStore.put(TLRPC.TL_messages_sentEncryptedFile.constructor, TLRPC.TL_messages_sentEncryptedFile.class); - classStore.put(TLRPC.TL_notifyAll.constructor, TLRPC.TL_notifyAll.class); - classStore.put(TLRPC.TL_notifyChats.constructor, TLRPC.TL_notifyChats.class); - classStore.put(TLRPC.TL_notifyUsers.constructor, TLRPC.TL_notifyUsers.class); - classStore.put(TLRPC.TL_notifyPeer.constructor, TLRPC.TL_notifyPeer.class); - classStore.put(TLRPC.TL_auth_checkedPhone.constructor, TLRPC.TL_auth_checkedPhone.class); - classStore.put(TLRPC.TL_msgs_ack.constructor, TLRPC.TL_msgs_ack.class); - classStore.put(TLRPC.TL_messages_chatFull.constructor, TLRPC.TL_messages_chatFull.class); - classStore.put(TLRPC.TL_documentAttributeAnimated.constructor, TLRPC.TL_documentAttributeAnimated.class); - classStore.put(TLRPC.TL_documentAttributeAudio.constructor, TLRPC.TL_documentAttributeAudio.class); - classStore.put(TLRPC.TL_documentAttributeFilename.constructor, TLRPC.TL_documentAttributeFilename.class); - classStore.put(TLRPC.TL_documentAttributeVideo.constructor, TLRPC.TL_documentAttributeVideo.class); - classStore.put(TLRPC.TL_documentAttributeSticker.constructor, TLRPC.TL_documentAttributeSticker.class); - classStore.put(TLRPC.TL_documentAttributeImageSize.constructor, TLRPC.TL_documentAttributeImageSize.class); - classStore.put(TLRPC.TL_rpc_result.constructor, TLRPC.TL_rpc_result.class); - classStore.put(TLRPC.TL_contactStatus.constructor, TLRPC.TL_contactStatus.class); classStore.put(TLRPC.TL_auth_authorization.constructor, TLRPC.TL_auth_authorization.class); - classStore.put(TLRPC.TL_messages_messages.constructor, TLRPC.TL_messages_messages.class); - classStore.put(TLRPC.TL_messages_messagesSlice.constructor, TLRPC.TL_messages_messagesSlice.class); - classStore.put(TLRPC.TL_rpc_answer_unknown.constructor, TLRPC.TL_rpc_answer_unknown.class); - classStore.put(TLRPC.TL_rpc_answer_dropped.constructor, TLRPC.TL_rpc_answer_dropped.class); - classStore.put(TLRPC.TL_rpc_answer_dropped_running.constructor, TLRPC.TL_rpc_answer_dropped_running.class); - classStore.put(TLRPC.TL_contacts_link.constructor, TLRPC.TL_contacts_link.class); - classStore.put(TLRPC.TL_peerUser.constructor, TLRPC.TL_peerUser.class); - classStore.put(TLRPC.TL_peerChat.constructor, TLRPC.TL_peerChat.class); - classStore.put(TLRPC.TL_encryptedFile.constructor, TLRPC.TL_encryptedFile.class); - classStore.put(TLRPC.TL_encryptedFileEmpty.constructor, TLRPC.TL_encryptedFileEmpty.class); - classStore.put(TLRPC.TL_destroy_session_ok.constructor, TLRPC.TL_destroy_session_ok.class); - classStore.put(TLRPC.TL_destroy_session_none.constructor, TLRPC.TL_destroy_session_none.class); - classStore.put(TLRPC.TL_updates_differenceEmpty.constructor, TLRPC.TL_updates_differenceEmpty.class); - classStore.put(TLRPC.TL_updates_differenceSlice.constructor, TLRPC.TL_updates_differenceSlice.class); - classStore.put(TLRPC.TL_updates_difference.constructor, TLRPC.TL_updates_difference.class); - classStore.put(TLRPC.TL_geoPointEmpty.constructor, TLRPC.TL_geoPointEmpty.class); - classStore.put(TLRPC.TL_geoPoint.constructor, TLRPC.TL_geoPoint.class); - classStore.put(TLRPC.TL_privacyKeyStatusTimestamp.constructor, TLRPC.TL_privacyKeyStatusTimestamp.class); - classStore.put(TLRPC.TL_account_privacyRules.constructor, TLRPC.TL_account_privacyRules.class); - classStore.put(TLRPC.TL_help_appUpdate.constructor, TLRPC.TL_help_appUpdate.class); - classStore.put(TLRPC.TL_help_noAppUpdate.constructor, TLRPC.TL_help_noAppUpdate.class); - classStore.put(TLRPC.TL_messageEmpty.constructor, TLRPC.TL_messageEmpty.class); - classStore.put(TLRPC.TL_message.constructor, TLRPC.TL_message.class); - classStore.put(TLRPC.TL_messageService.constructor, TLRPC.TL_messageService.class); - classStore.put(TLRPC.TL_inputPhoneContact.constructor, TLRPC.TL_inputPhoneContact.class); - classStore.put(TLRPC.TL_sendMessageGeoLocationAction.constructor, TLRPC.TL_sendMessageGeoLocationAction.class); - classStore.put(TLRPC.TL_sendMessageChooseContactAction.constructor, TLRPC.TL_sendMessageChooseContactAction.class); - classStore.put(TLRPC.TL_sendMessageTypingAction.constructor, TLRPC.TL_sendMessageTypingAction.class); - classStore.put(TLRPC.TL_sendMessageUploadDocumentAction.constructor, TLRPC.TL_sendMessageUploadDocumentAction.class); - classStore.put(TLRPC.TL_sendMessageRecordVideoAction.constructor, TLRPC.TL_sendMessageRecordVideoAction.class); - classStore.put(TLRPC.TL_sendMessageUploadPhotoAction.constructor, TLRPC.TL_sendMessageUploadPhotoAction.class); - classStore.put(TLRPC.TL_sendMessageUploadVideoAction.constructor, TLRPC.TL_sendMessageUploadVideoAction.class); - classStore.put(TLRPC.TL_sendMessageUploadAudioAction.constructor, TLRPC.TL_sendMessageUploadAudioAction.class); - classStore.put(TLRPC.TL_sendMessageCancelAction.constructor, TLRPC.TL_sendMessageCancelAction.class); - classStore.put(TLRPC.TL_sendMessageRecordAudioAction.constructor, TLRPC.TL_sendMessageRecordAudioAction.class); - classStore.put(TLRPC.TL_invokeAfterMsg.constructor, TLRPC.TL_invokeAfterMsg.class); - classStore.put(TLRPC.TL_messageMediaVideo.constructor, TLRPC.TL_messageMediaVideo.class); - classStore.put(TLRPC.TL_messageMediaPhoto.constructor, TLRPC.TL_messageMediaPhoto.class); - classStore.put(TLRPC.TL_messageMediaDocument.constructor, TLRPC.TL_messageMediaDocument.class); - classStore.put(TLRPC.TL_messageMediaGeo.constructor, TLRPC.TL_messageMediaGeo.class); - classStore.put(TLRPC.TL_messageMediaEmpty.constructor, TLRPC.TL_messageMediaEmpty.class); - classStore.put(TLRPC.TL_messageMediaAudio.constructor, TLRPC.TL_messageMediaAudio.class); - classStore.put(TLRPC.TL_messageMediaContact.constructor, TLRPC.TL_messageMediaContact.class); - classStore.put(TLRPC.TL_messageMediaUnsupported.constructor, TLRPC.TL_messageMediaUnsupported.class); - classStore.put(TLRPC.TL_auth_sentAppCode.constructor, TLRPC.TL_auth_sentAppCode.class); - classStore.put(TLRPC.TL_auth_sentCode.constructor, TLRPC.TL_auth_sentCode.class); - classStore.put(TLRPC.TL_peerNotifySettingsEmpty.constructor, TLRPC.TL_peerNotifySettingsEmpty.class); - classStore.put(TLRPC.TL_peerNotifySettings.constructor, TLRPC.TL_peerNotifySettings.class); - classStore.put(TLRPC.TL_msg_resend_req.constructor, TLRPC.TL_msg_resend_req.class); - classStore.put(TLRPC.TL_http_wait.constructor, TLRPC.TL_http_wait.class); - classStore.put(TLRPC.TL_contacts_blocked.constructor, TLRPC.TL_contacts_blocked.class); - classStore.put(TLRPC.TL_contacts_blockedSlice.constructor, TLRPC.TL_contacts_blockedSlice.class); - classStore.put(TLRPC.TL_inputGeoPoint.constructor, TLRPC.TL_inputGeoPoint.class); - classStore.put(TLRPC.TL_inputGeoPointEmpty.constructor, TLRPC.TL_inputGeoPointEmpty.class); - classStore.put(TLRPC.TL_help_inviteText.constructor, TLRPC.TL_help_inviteText.class); - classStore.put(TLRPC.TL_messages_dhConfigNotModified.constructor, TLRPC.TL_messages_dhConfigNotModified.class); - classStore.put(TLRPC.TL_messages_dhConfig.constructor, TLRPC.TL_messages_dhConfig.class); - classStore.put(TLRPC.TL_audioEmpty.constructor, TLRPC.TL_audioEmpty.class); - classStore.put(TLRPC.TL_audio.constructor, TLRPC.TL_audio.class); - classStore.put(TLRPC.TL_destroy_sessions_res.constructor, TLRPC.TL_destroy_sessions_res.class); - classStore.put(TLRPC.TL_privacyValueAllowUsers.constructor, TLRPC.TL_privacyValueAllowUsers.class); - classStore.put(TLRPC.TL_privacyValueDisallowAll.constructor, TLRPC.TL_privacyValueDisallowAll.class); - classStore.put(TLRPC.TL_privacyValueAllowContacts.constructor, TLRPC.TL_privacyValueAllowContacts.class); - classStore.put(TLRPC.TL_privacyValueDisallowContacts.constructor, TLRPC.TL_privacyValueDisallowContacts.class); - classStore.put(TLRPC.TL_privacyValueAllowAll.constructor, TLRPC.TL_privacyValueAllowAll.class); - classStore.put(TLRPC.TL_privacyValueDisallowUsers.constructor, TLRPC.TL_privacyValueDisallowUsers.class); - classStore.put(TLRPC.TL_contacts_contacts.constructor, TLRPC.TL_contacts_contacts.class); - classStore.put(TLRPC.TL_contacts_contactsNotModified.constructor, TLRPC.TL_contacts_contactsNotModified.class); - classStore.put(TLRPC.TL_inputPrivacyKeyStatusTimestamp.constructor, TLRPC.TL_inputPrivacyKeyStatusTimestamp.class); - classStore.put(TLRPC.TL_photos_photos.constructor, TLRPC.TL_photos_photos.class); - classStore.put(TLRPC.TL_photos_photosSlice.constructor, TLRPC.TL_photos_photosSlice.class); - classStore.put(TLRPC.TL_chatFull.constructor, TLRPC.TL_chatFull.class); - classStore.put(TLRPC.TL_msgs_all_info.constructor, TLRPC.TL_msgs_all_info.class); - classStore.put(TLRPC.TL_inputPeerNotifySettings.constructor, TLRPC.TL_inputPeerNotifySettings.class); - classStore.put(TLRPC.TL_null.constructor, TLRPC.TL_null.class); - classStore.put(TLRPC.TL_inputUserSelf.constructor, TLRPC.TL_inputUserSelf.class); - classStore.put(TLRPC.TL_inputUserForeign.constructor, TLRPC.TL_inputUserForeign.class); - classStore.put(TLRPC.TL_inputUserEmpty.constructor, TLRPC.TL_inputUserEmpty.class); - classStore.put(TLRPC.TL_inputUserContact.constructor, TLRPC.TL_inputUserContact.class); - classStore.put(TLRPC.TL_p_q_inner_data.constructor, TLRPC.TL_p_q_inner_data.class); - classStore.put(TLRPC.TL_msgs_state_req.constructor, TLRPC.TL_msgs_state_req.class); - classStore.put(TLRPC.TL_boolTrue.constructor, TLRPC.TL_boolTrue.class); - classStore.put(TLRPC.TL_boolFalse.constructor, TLRPC.TL_boolFalse.class); - classStore.put(TLRPC.TL_auth_exportedAuthorization.constructor, TLRPC.TL_auth_exportedAuthorization.class); - classStore.put(TLRPC.TL_inputNotifyChats.constructor, TLRPC.TL_inputNotifyChats.class); - classStore.put(TLRPC.TL_inputNotifyPeer.constructor, TLRPC.TL_inputNotifyPeer.class); - classStore.put(TLRPC.TL_inputNotifyUsers.constructor, TLRPC.TL_inputNotifyUsers.class); - classStore.put(TLRPC.TL_inputNotifyGeoChatPeer.constructor, TLRPC.TL_inputNotifyGeoChatPeer.class); - classStore.put(TLRPC.TL_inputNotifyAll.constructor, TLRPC.TL_inputNotifyAll.class); - classStore.put(TLRPC.TL_inputAudioFileLocation.constructor, TLRPC.TL_inputAudioFileLocation.class); - classStore.put(TLRPC.TL_inputEncryptedFileLocation.constructor, TLRPC.TL_inputEncryptedFileLocation.class); - classStore.put(TLRPC.TL_inputVideoFileLocation.constructor, TLRPC.TL_inputVideoFileLocation.class); - classStore.put(TLRPC.TL_inputDocumentFileLocation.constructor, TLRPC.TL_inputDocumentFileLocation.class); - classStore.put(TLRPC.TL_inputFileLocation.constructor, TLRPC.TL_inputFileLocation.class); - classStore.put(TLRPC.TL_photos_photo.constructor, TLRPC.TL_photos_photo.class); - classStore.put(TLRPC.TL_userContact.constructor, TLRPC.TL_userContact.class); - classStore.put(TLRPC.TL_userRequest.constructor, TLRPC.TL_userRequest.class); - classStore.put(TLRPC.TL_userForeign.constructor, TLRPC.TL_userForeign.class); - classStore.put(TLRPC.TL_userDeleted.constructor, TLRPC.TL_userDeleted.class); - classStore.put(TLRPC.TL_userSelf.constructor, TLRPC.TL_userSelf.class); - classStore.put(TLRPC.TL_userEmpty.constructor, TLRPC.TL_userEmpty.class); - classStore.put(TLRPC.TL_geoChatMessage.constructor, TLRPC.TL_geoChatMessage.class); - classStore.put(TLRPC.TL_geoChatMessageService.constructor, TLRPC.TL_geoChatMessageService.class); - classStore.put(TLRPC.TL_geoChatMessageEmpty.constructor, TLRPC.TL_geoChatMessageEmpty.class); - classStore.put(TLRPC.TL_pong.constructor, TLRPC.TL_pong.class); - classStore.put(TLRPC.TL_messageActionChatEditPhoto.constructor, TLRPC.TL_messageActionChatEditPhoto.class); - classStore.put(TLRPC.TL_messageActionChatDeleteUser.constructor, TLRPC.TL_messageActionChatDeleteUser.class); - classStore.put(TLRPC.TL_messageActionChatDeletePhoto.constructor, TLRPC.TL_messageActionChatDeletePhoto.class); - classStore.put(TLRPC.TL_messageActionChatAddUser.constructor, TLRPC.TL_messageActionChatAddUser.class); - classStore.put(TLRPC.TL_messageActionChatCreate.constructor, TLRPC.TL_messageActionChatCreate.class); - classStore.put(TLRPC.TL_messageActionEmpty.constructor, TLRPC.TL_messageActionEmpty.class); - classStore.put(TLRPC.TL_messageActionChatEditTitle.constructor, TLRPC.TL_messageActionChatEditTitle.class); - classStore.put(TLRPC.TL_messageActionGeoChatCreate.constructor, TLRPC.TL_messageActionGeoChatCreate.class); - classStore.put(TLRPC.TL_messageActionGeoChatCheckin.constructor, TLRPC.TL_messageActionGeoChatCheckin.class); classStore.put(TLRPC.TL_dh_gen_retry.constructor, TLRPC.TL_dh_gen_retry.class); classStore.put(TLRPC.TL_dh_gen_fail.constructor, TLRPC.TL_dh_gen_fail.class); classStore.put(TLRPC.TL_dh_gen_ok.constructor, TLRPC.TL_dh_gen_ok.class); - classStore.put(TLRPC.TL_peerNotifyEventsEmpty.constructor, TLRPC.TL_peerNotifyEventsEmpty.class); - classStore.put(TLRPC.TL_peerNotifyEventsAll.constructor, TLRPC.TL_peerNotifyEventsAll.class); - classStore.put(TLRPC.TL_chatLocated.constructor, TLRPC.TL_chatLocated.class); - classStore.put(TLRPC.TL_decryptedMessageService.constructor, TLRPC.TL_decryptedMessageService.class); - classStore.put(TLRPC.TL_decryptedMessage.constructor, TLRPC.TL_decryptedMessage.class); - classStore.put(TLRPC.TL_inputPeerNotifyEventsAll.constructor, TLRPC.TL_inputPeerNotifyEventsAll.class); - classStore.put(TLRPC.TL_inputPeerNotifyEventsEmpty.constructor, TLRPC.TL_inputPeerNotifyEventsEmpty.class); - classStore.put(TLRPC.TL_client_DH_inner_data.constructor, TLRPC.TL_client_DH_inner_data.class); - classStore.put(TLRPC.TL_video.constructor, TLRPC.TL_video.class); - classStore.put(TLRPC.TL_videoEmpty.constructor, TLRPC.TL_videoEmpty.class); - classStore.put(TLRPC.TL_contactBlocked.constructor, TLRPC.TL_contactBlocked.class); - classStore.put(TLRPC.TL_inputDocumentEmpty.constructor, TLRPC.TL_inputDocumentEmpty.class); - classStore.put(TLRPC.TL_inputDocument.constructor, TLRPC.TL_inputDocument.class); - classStore.put(TLRPC.TL_inputAppEvent.constructor, TLRPC.TL_inputAppEvent.class); - classStore.put(TLRPC.TL_messages_affectedHistory.constructor, TLRPC.TL_messages_affectedHistory.class); - classStore.put(TLRPC.TL_documentEmpty.constructor, TLRPC.TL_documentEmpty.class); - classStore.put(TLRPC.TL_document.constructor, TLRPC.TL_document.class); - classStore.put(TLRPC.TL_inputPrivacyValueDisallowUsers.constructor, TLRPC.TL_inputPrivacyValueDisallowUsers.class); - classStore.put(TLRPC.TL_inputPrivacyValueDisallowAll.constructor, TLRPC.TL_inputPrivacyValueDisallowAll.class); - classStore.put(TLRPC.TL_inputPrivacyValueDisallowContacts.constructor, TLRPC.TL_inputPrivacyValueDisallowContacts.class); - classStore.put(TLRPC.TL_inputPrivacyValueAllowAll.constructor, TLRPC.TL_inputPrivacyValueAllowAll.class); - classStore.put(TLRPC.TL_inputPrivacyValueAllowContacts.constructor, TLRPC.TL_inputPrivacyValueAllowContacts.class); - classStore.put(TLRPC.TL_inputPrivacyValueAllowUsers.constructor, TLRPC.TL_inputPrivacyValueAllowUsers.class); - classStore.put(TLRPC.TL_inputMediaContact.constructor, TLRPC.TL_inputMediaContact.class); - classStore.put(TLRPC.TL_inputMediaUploadedThumbDocument.constructor, TLRPC.TL_inputMediaUploadedThumbDocument.class); - classStore.put(TLRPC.TL_inputMediaAudio.constructor, TLRPC.TL_inputMediaAudio.class); - classStore.put(TLRPC.TL_inputMediaDocument.constructor, TLRPC.TL_inputMediaDocument.class); - classStore.put(TLRPC.TL_inputMediaVideo.constructor, TLRPC.TL_inputMediaVideo.class); - classStore.put(TLRPC.TL_inputMediaGeoPoint.constructor, TLRPC.TL_inputMediaGeoPoint.class); - classStore.put(TLRPC.TL_inputMediaEmpty.constructor, TLRPC.TL_inputMediaEmpty.class); - classStore.put(TLRPC.TL_inputMediaUploadedThumbVideo.constructor, TLRPC.TL_inputMediaUploadedThumbVideo.class); - classStore.put(TLRPC.TL_inputMediaUploadedPhoto.constructor, TLRPC.TL_inputMediaUploadedPhoto.class); - classStore.put(TLRPC.TL_inputMediaUploadedAudio.constructor, TLRPC.TL_inputMediaUploadedAudio.class); - classStore.put(TLRPC.TL_inputMediaUploadedVideo.constructor, TLRPC.TL_inputMediaUploadedVideo.class); - classStore.put(TLRPC.TL_inputMediaUploadedDocument.constructor, TLRPC.TL_inputMediaUploadedDocument.class); - classStore.put(TLRPC.TL_inputMediaPhoto.constructor, TLRPC.TL_inputMediaPhoto.class); - classStore.put(TLRPC.TL_geochats_messagesSlice.constructor, TLRPC.TL_geochats_messagesSlice.class); - classStore.put(TLRPC.TL_geochats_messages.constructor, TLRPC.TL_geochats_messages.class); - classStore.put(TLRPC.TL_messages_sentMessage.constructor, TLRPC.TL_messages_sentMessage.class); - classStore.put(TLRPC.TL_messages_sentMessageLink.constructor, TLRPC.TL_messages_sentMessageLink.class); - classStore.put(TLRPC.TL_encryptedMessageService.constructor, TLRPC.TL_encryptedMessageService.class); - classStore.put(TLRPC.TL_encryptedMessage.constructor, TLRPC.TL_encryptedMessage.class); - classStore.put(TLRPC.TL_contactSuggested.constructor, TLRPC.TL_contactSuggested.class); - classStore.put(TLRPC.TL_server_DH_params_fail.constructor, TLRPC.TL_server_DH_params_fail.class); - classStore.put(TLRPC.TL_server_DH_params_ok.constructor, TLRPC.TL_server_DH_params_ok.class); - classStore.put(TLRPC.TL_userStatusOffline.constructor, TLRPC.TL_userStatusOffline.class); - classStore.put(TLRPC.TL_userStatusLastWeek.constructor, TLRPC.TL_userStatusLastWeek.class); - classStore.put(TLRPC.TL_userStatusEmpty.constructor, TLRPC.TL_userStatusEmpty.class); - classStore.put(TLRPC.TL_userStatusLastMonth.constructor, TLRPC.TL_userStatusLastMonth.class); - classStore.put(TLRPC.TL_userStatusOnline.constructor, TLRPC.TL_userStatusOnline.class); - classStore.put(TLRPC.TL_userStatusRecently.constructor, TLRPC.TL_userStatusRecently.class); - classStore.put(TLRPC.TL_msg_copy.constructor, TLRPC.TL_msg_copy.class); - classStore.put(TLRPC.TL_contacts_importedContacts.constructor, TLRPC.TL_contacts_importedContacts.class); - classStore.put(TLRPC.TL_disabledFeature.constructor, TLRPC.TL_disabledFeature.class); + classStore.put(TLRPC.TL_server_DH_inner_data.constructor, TLRPC.TL_server_DH_inner_data.class); + classStore.put(TLRPC.TL_msgs_ack.constructor, TLRPC.TL_msgs_ack.class); classStore.put(TLRPC.TL_futureSalt.constructor, TLRPC.TL_futureSalt.class); - classStore.put(TLRPC.TL_updateEncryptedMessagesRead.constructor, TLRPC.TL_updateEncryptedMessagesRead.class); - classStore.put(TLRPC.TL_updateContactLink.constructor, TLRPC.TL_updateContactLink.class); - classStore.put(TLRPC.TL_updateReadMessages.constructor, TLRPC.TL_updateReadMessages.class); - classStore.put(TLRPC.TL_updateChatParticipantDelete.constructor, TLRPC.TL_updateChatParticipantDelete.class); - classStore.put(TLRPC.TL_updateServiceNotification.constructor, TLRPC.TL_updateServiceNotification.class); - classStore.put(TLRPC.TL_updateNotifySettings.constructor, TLRPC.TL_updateNotifySettings.class); - classStore.put(TLRPC.TL_updateUserTyping.constructor, TLRPC.TL_updateUserTyping.class); - classStore.put(TLRPC.TL_updateChatUserTyping.constructor, TLRPC.TL_updateChatUserTyping.class); - classStore.put(TLRPC.TL_updateUserName.constructor, TLRPC.TL_updateUserName.class); - classStore.put(TLRPC.TL_updateNewEncryptedMessage.constructor, TLRPC.TL_updateNewEncryptedMessage.class); - classStore.put(TLRPC.TL_updateNewMessage.constructor, TLRPC.TL_updateNewMessage.class); - classStore.put(TLRPC.TL_updateMessageID.constructor, TLRPC.TL_updateMessageID.class); - classStore.put(TLRPC.TL_updateDeleteMessages.constructor, TLRPC.TL_updateDeleteMessages.class); - classStore.put(TLRPC.TL_updateEncryptedChatTyping.constructor, TLRPC.TL_updateEncryptedChatTyping.class); - classStore.put(TLRPC.TL_updateDcOptions.constructor, TLRPC.TL_updateDcOptions.class); - classStore.put(TLRPC.TL_updateChatParticipants.constructor, TLRPC.TL_updateChatParticipants.class); - classStore.put(TLRPC.TL_updatePrivacy.constructor, TLRPC.TL_updatePrivacy.class); - classStore.put(TLRPC.TL_updateEncryption.constructor, TLRPC.TL_updateEncryption.class); - classStore.put(TLRPC.TL_updateUserBlocked.constructor, TLRPC.TL_updateUserBlocked.class); - classStore.put(TLRPC.TL_updateActivation.constructor, TLRPC.TL_updateActivation.class); - classStore.put(TLRPC.TL_updateNewAuthorization.constructor, TLRPC.TL_updateNewAuthorization.class); - classStore.put(TLRPC.TL_updateNewGeoChatMessage.constructor, TLRPC.TL_updateNewGeoChatMessage.class); - classStore.put(TLRPC.TL_updateUserPhoto.constructor, TLRPC.TL_updateUserPhoto.class); - classStore.put(TLRPC.TL_updateContactRegistered.constructor, TLRPC.TL_updateContactRegistered.class); - classStore.put(TLRPC.TL_updateChatParticipantAdd.constructor, TLRPC.TL_updateChatParticipantAdd.class); - classStore.put(TLRPC.TL_updateUserStatus.constructor, TLRPC.TL_updateUserStatus.class); - classStore.put(TLRPC.TL_contacts_suggested.constructor, TLRPC.TL_contacts_suggested.class); + classStore.put(TLRPC.TL_msg_resend_req.constructor, TLRPC.TL_msg_resend_req.class); classStore.put(TLRPC.TL_rpc_error.constructor, TLRPC.TL_rpc_error.class); classStore.put(TLRPC.TL_rpc_req_error.constructor, TLRPC.TL_rpc_req_error.class); - classStore.put(TLRPC.TL_inputEncryptedFile.constructor, TLRPC.TL_inputEncryptedFile.class); - classStore.put(TLRPC.TL_inputEncryptedFileBigUploaded.constructor, TLRPC.TL_inputEncryptedFileBigUploaded.class); - classStore.put(TLRPC.TL_inputEncryptedFileEmpty.constructor, TLRPC.TL_inputEncryptedFileEmpty.class); - classStore.put(TLRPC.TL_inputEncryptedFileUploaded.constructor, TLRPC.TL_inputEncryptedFileUploaded.class); - classStore.put(TLRPC.TL_decryptedMessageActionFlushHistory.constructor, TLRPC.TL_decryptedMessageActionFlushHistory.class); - classStore.put(TLRPC.TL_decryptedMessageActionResend.constructor, TLRPC.TL_decryptedMessageActionResend.class); - classStore.put(TLRPC.TL_decryptedMessageActionNotifyLayer.constructor, TLRPC.TL_decryptedMessageActionNotifyLayer.class); - classStore.put(TLRPC.TL_decryptedMessageActionSetMessageTTL.constructor, TLRPC.TL_decryptedMessageActionSetMessageTTL.class); - classStore.put(TLRPC.TL_decryptedMessageActionDeleteMessages.constructor, TLRPC.TL_decryptedMessageActionDeleteMessages.class); - classStore.put(TLRPC.TL_decryptedMessageActionTyping.constructor, TLRPC.TL_decryptedMessageActionTyping.class); - classStore.put(TLRPC.TL_decryptedMessageActionReadMessages.constructor, TLRPC.TL_decryptedMessageActionReadMessages.class); - classStore.put(TLRPC.TL_decryptedMessageActionScreenshotMessages.constructor, TLRPC.TL_decryptedMessageActionScreenshotMessages.class); - classStore.put(TLRPC.TL_server_DH_inner_data.constructor, TLRPC.TL_server_DH_inner_data.class); + classStore.put(TLRPC.TL_decryptedMessageService.constructor, TLRPC.TL_decryptedMessageService.class); + classStore.put(TLRPC.TL_decryptedMessage.constructor, TLRPC.TL_decryptedMessage.class); + classStore.put(TLRPC.TL_bad_msg_notification.constructor, TLRPC.TL_bad_msg_notification.class); + classStore.put(TLRPC.TL_bad_server_salt.constructor, TLRPC.TL_bad_server_salt.class); classStore.put(TLRPC.TL_new_session_created.constructor, TLRPC.TL_new_session_created.class); - classStore.put(TLRPC.TL_account_password.constructor, TLRPC.TL_account_password.class); - classStore.put(TLRPC.TL_account_noPassword.constructor, TLRPC.TL_account_noPassword.class); - classStore.put(TLRPC.TL_userProfilePhotoEmpty.constructor, TLRPC.TL_userProfilePhotoEmpty.class); - classStore.put(TLRPC.TL_userProfilePhoto.constructor, TLRPC.TL_userProfilePhoto.class); - classStore.put(TLRPC.TL_photo.constructor, TLRPC.TL_photo.class); - classStore.put(TLRPC.TL_photoEmpty.constructor, TLRPC.TL_photoEmpty.class); - classStore.put(TLRPC.TL_encryptedChatWaiting.constructor, TLRPC.TL_encryptedChatWaiting.class); - classStore.put(TLRPC.TL_encryptedChatEmpty.constructor, TLRPC.TL_encryptedChatEmpty.class); - classStore.put(TLRPC.TL_encryptedChatDiscarded.constructor, TLRPC.TL_encryptedChatDiscarded.class); - classStore.put(TLRPC.TL_encryptedChat.constructor, TLRPC.TL_encryptedChat.class); - classStore.put(TLRPC.TL_encryptedChatRequested.constructor, TLRPC.TL_encryptedChatRequested.class); - classStore.put(TLRPC.TL_geochats_statedMessage.constructor, TLRPC.TL_geochats_statedMessage.class); - classStore.put(TLRPC.TL_contact.constructor, TLRPC.TL_contact.class); - classStore.put(TLRPC.TL_config.constructor, TLRPC.TL_config.class); - classStore.put(TLRPC.TL_inputAudio.constructor, TLRPC.TL_inputAudio.class); - classStore.put(TLRPC.TL_inputAudioEmpty.constructor, TLRPC.TL_inputAudioEmpty.class); - classStore.put(TLRPC.TL_help_support.constructor, TLRPC.TL_help_support.class); - classStore.put(TLRPC.TL_messages_chats.constructor, TLRPC.TL_messages_chats.class); - classStore.put(TLRPC.TL_contacts_found.constructor, TLRPC.TL_contacts_found.class); - classStore.put(TLRPC.TL_chatParticipants.constructor, TLRPC.TL_chatParticipants.class); - classStore.put(TLRPC.TL_chatParticipantsForbidden.constructor, TLRPC.TL_chatParticipantsForbidden.class); - classStore.put(TLRPC.TL_decryptedMessageMediaDocument.constructor, TLRPC.TL_decryptedMessageMediaDocument.class); - classStore.put(TLRPC.TL_decryptedMessageMediaGeoPoint.constructor, TLRPC.TL_decryptedMessageMediaGeoPoint.class); - classStore.put(TLRPC.TL_decryptedMessageMediaAudio.constructor, TLRPC.TL_decryptedMessageMediaAudio.class); - classStore.put(TLRPC.TL_decryptedMessageMediaVideo.constructor, TLRPC.TL_decryptedMessageMediaVideo.class); - classStore.put(TLRPC.TL_decryptedMessageMediaContact.constructor, TLRPC.TL_decryptedMessageMediaContact.class); - classStore.put(TLRPC.TL_decryptedMessageMediaEmpty.constructor, TLRPC.TL_decryptedMessageMediaEmpty.class); - classStore.put(TLRPC.TL_decryptedMessageMediaPhoto.constructor, TLRPC.TL_decryptedMessageMediaPhoto.class); - classStore.put(TLRPC.TL_chatParticipant.constructor, TLRPC.TL_chatParticipant.class); - classStore.put(TLRPC.TL_chatForbidden.constructor, TLRPC.TL_chatForbidden.class); - classStore.put(TLRPC.TL_geoChat.constructor, TLRPC.TL_geoChat.class); - classStore.put(TLRPC.TL_chatEmpty.constructor, TLRPC.TL_chatEmpty.class); - classStore.put(TLRPC.TL_chat.constructor, TLRPC.TL_chat.class); - classStore.put(TLRPC.TL_storage_fileUnknown.constructor, TLRPC.TL_storage_fileUnknown.class); - classStore.put(TLRPC.TL_storage_fileMp4.constructor, TLRPC.TL_storage_fileMp4.class); - classStore.put(TLRPC.TL_storage_fileWebp.constructor, TLRPC.TL_storage_fileWebp.class); - classStore.put(TLRPC.TL_storage_filePng.constructor, TLRPC.TL_storage_filePng.class); - classStore.put(TLRPC.TL_storage_fileGif.constructor, TLRPC.TL_storage_fileGif.class); - classStore.put(TLRPC.TL_storage_filePdf.constructor, TLRPC.TL_storage_filePdf.class); - classStore.put(TLRPC.TL_storage_fileMp3.constructor, TLRPC.TL_storage_fileMp3.class); - classStore.put(TLRPC.TL_storage_fileJpeg.constructor, TLRPC.TL_storage_fileJpeg.class); - classStore.put(TLRPC.TL_storage_fileMov.constructor, TLRPC.TL_storage_fileMov.class); - classStore.put(TLRPC.TL_storage_filePartial.constructor, TLRPC.TL_storage_filePartial.class); - classStore.put(TLRPC.TL_inputMessagesFilterVideo.constructor, TLRPC.TL_inputMessagesFilterVideo.class); - classStore.put(TLRPC.TL_inputMessagesFilterEmpty.constructor, TLRPC.TL_inputMessagesFilterEmpty.class); - classStore.put(TLRPC.TL_inputMessagesFilterPhotos.constructor, TLRPC.TL_inputMessagesFilterPhotos.class); - classStore.put(TLRPC.TL_inputMessagesFilterPhotoVideo.constructor, TLRPC.TL_inputMessagesFilterPhotoVideo.class); - classStore.put(TLRPC.TL_inputMessagesFilterDocument.constructor, TLRPC.TL_inputMessagesFilterDocument.class); - classStore.put(TLRPC.TL_inputMessagesFilterAudio.constructor, TLRPC.TL_inputMessagesFilterAudio.class); - classStore.put(TLRPC.TL_msgs_state_info.constructor, TLRPC.TL_msgs_state_info.class); - classStore.put(TLRPC.TL_upload_file.constructor, TLRPC.TL_upload_file.class); - classStore.put(TLRPC.TL_dialog.constructor, TLRPC.TL_dialog.class); - classStore.put(TLRPC.TL_fileLocation.constructor, TLRPC.TL_fileLocation.class); - classStore.put(TLRPC.TL_fileLocationUnavailable.constructor, TLRPC.TL_fileLocationUnavailable.class); - classStore.put(TLRPC.TL_messages_messageEmpty.constructor, TLRPC.TL_messages_messageEmpty.class); - classStore.put(TLRPC.TL_messages_message.constructor, TLRPC.TL_messages_message.class); - classStore.put(TLRPC.TL_geochats_located.constructor, TLRPC.TL_geochats_located.class); - classStore.put(TLRPC.TL_inputGeoChat.constructor, TLRPC.TL_inputGeoChat.class); - classStore.put(TLRPC.TL_protoMessage.constructor, TLRPC.TL_protoMessage.class); - classStore.put(TLRPC.TL_photoSize.constructor, TLRPC.TL_photoSize.class); - classStore.put(TLRPC.TL_photoSizeEmpty.constructor, TLRPC.TL_photoSizeEmpty.class); - classStore.put(TLRPC.TL_photoCachedSize.constructor, TLRPC.TL_photoCachedSize.class); - classStore.put(TLRPC.TL_contactFound.constructor, TLRPC.TL_contactFound.class); - classStore.put(TLRPC.TL_inputFileBig.constructor, TLRPC.TL_inputFileBig.class); - classStore.put(TLRPC.TL_inputFile.constructor, TLRPC.TL_inputFile.class); - classStore.put(TLRPC.TL_userFull.constructor, TLRPC.TL_userFull.class); - classStore.put(TLRPC.TL_updates_state.constructor, TLRPC.TL_updates_state.class); classStore.put(TLRPC.TL_resPQ.constructor, TLRPC.TL_resPQ.class); + classStore.put(TLRPC.TL_config.constructor, TLRPC.TL_config.class); + classStore.put(TLRPC.TL_msg_copy.constructor, TLRPC.TL_msg_copy.class); + classStore.put(TLRPC.TL_pong.constructor, TLRPC.TL_pong.class); + classStore.put(TLRPC.TL_rpc_answer_unknown.constructor, TLRPC.TL_rpc_answer_unknown.class); + classStore.put(TLRPC.TL_rpc_answer_dropped.constructor, TLRPC.TL_rpc_answer_dropped.class); + classStore.put(TLRPC.TL_rpc_answer_dropped_running.constructor, TLRPC.TL_rpc_answer_dropped_running.class); + classStore.put(TLRPC.TL_rpc_result.constructor, TLRPC.TL_rpc_result.class); + classStore.put(TLRPC.TL_auth_exportedAuthorization.constructor, TLRPC.TL_auth_exportedAuthorization.class); + classStore.put(TLRPC.TL_destroy_session_ok.constructor, TLRPC.TL_destroy_session_ok.class); + classStore.put(TLRPC.TL_destroy_session_none.constructor, TLRPC.TL_destroy_session_none.class); + classStore.put(TLRPC.TL_msgs_state_req.constructor, TLRPC.TL_msgs_state_req.class); + classStore.put(TLRPC.TL_server_DH_params_fail.constructor, TLRPC.TL_server_DH_params_fail.class); + classStore.put(TLRPC.TL_server_DH_params_ok.constructor, TLRPC.TL_server_DH_params_ok.class); + classStore.put(TLRPC.TL_protoMessage.constructor, TLRPC.TL_protoMessage.class); + classStore.put(TLRPC.TL_msgs_all_info.constructor, TLRPC.TL_msgs_all_info.class); + classStore.put(TLRPC.TL_p_q_inner_data.constructor, TLRPC.TL_p_q_inner_data.class); classStore.put(TLRPC.TL_updateShortChatMessage.constructor, TLRPC.TL_updateShortChatMessage.class); classStore.put(TLRPC.TL_updates.constructor, TLRPC.TL_updates.class); classStore.put(TLRPC.TL_updateShortMessage.constructor, TLRPC.TL_updateShortMessage.class); classStore.put(TLRPC.TL_updateShort.constructor, TLRPC.TL_updateShort.class); classStore.put(TLRPC.TL_updatesCombined.constructor, TLRPC.TL_updatesCombined.class); classStore.put(TLRPC.TL_updatesTooLong.constructor, TLRPC.TL_updatesTooLong.class); - classStore.put(TLRPC.TL_wallPaper.constructor, TLRPC.TL_wallPaper.class); - classStore.put(TLRPC.TL_wallPaperSolid.constructor, TLRPC.TL_wallPaperSolid.class); - classStore.put(TLRPC.TL_msg_new_detailed_info.constructor, TLRPC.TL_msg_new_detailed_info.class); - classStore.put(TLRPC.TL_msg_detailed_info.constructor, TLRPC.TL_msg_detailed_info.class); - classStore.put(TLRPC.TL_inputEncryptedChat.constructor, TLRPC.TL_inputEncryptedChat.class); - classStore.put(TLRPC.TL_inputChatPhoto.constructor, TLRPC.TL_inputChatPhoto.class); - classStore.put(TLRPC.TL_inputChatPhotoEmpty.constructor, TLRPC.TL_inputChatPhotoEmpty.class); - classStore.put(TLRPC.TL_inputChatUploadedPhoto.constructor, TLRPC.TL_inputChatUploadedPhoto.class); - classStore.put(TLRPC.TL_inputVideoEmpty.constructor, TLRPC.TL_inputVideoEmpty.class); - classStore.put(TLRPC.TL_inputVideo.constructor, TLRPC.TL_inputVideo.class); - classStore.put(TLRPC.TL_nearestDc.constructor, TLRPC.TL_nearestDc.class); - classStore.put(TLRPC.TL_inputPhotoEmpty.constructor, TLRPC.TL_inputPhotoEmpty.class); - classStore.put(TLRPC.TL_inputPhoto.constructor, TLRPC.TL_inputPhoto.class); - classStore.put(TLRPC.TL_importedContact.constructor, TLRPC.TL_importedContact.class); - classStore.put(TLRPC.TL_accountDaysTTL.constructor, TLRPC.TL_accountDaysTTL.class); - classStore.put(TLRPC.TL_stickerPack.constructor, TLRPC.TL_stickerPack.class); - classStore.put(TLRPC.TL_messages_allStickers.constructor, TLRPC.TL_messages_allStickers.class); - classStore.put(TLRPC.TL_messages_allStickersNotModified.constructor, TLRPC.TL_messages_allStickersNotModified.class); - classStore.put(TLRPC.TL_inputPeerContact.constructor, TLRPC.TL_inputPeerContact.class); - classStore.put(TLRPC.TL_inputPeerChat.constructor, TLRPC.TL_inputPeerChat.class); - classStore.put(TLRPC.TL_inputPeerEmpty.constructor, TLRPC.TL_inputPeerEmpty.class); - classStore.put(TLRPC.TL_inputPeerSelf.constructor, TLRPC.TL_inputPeerSelf.class); - classStore.put(TLRPC.TL_inputPeerForeign.constructor, TLRPC.TL_inputPeerForeign.class); - classStore.put(TLRPC.TL_dcOption.constructor, TLRPC.TL_dcOption.class); + classStore.put(TLRPC.TL_msgs_state_info.constructor, TLRPC.TL_msgs_state_info.class); classStore.put(TLRPC.TL_decryptedMessageLayer.constructor, TLRPC.TL_decryptedMessageLayer.class); - classStore.put(TLRPC.TL_inputPhotoCropAuto.constructor, TLRPC.TL_inputPhotoCropAuto.class); - classStore.put(TLRPC.TL_inputPhotoCrop.constructor, TLRPC.TL_inputPhotoCrop.class); - classStore.put(TLRPC.TL_messages_dialogs.constructor, TLRPC.TL_messages_dialogs.class); - classStore.put(TLRPC.TL_messages_dialogsSlice.constructor, TLRPC.TL_messages_dialogsSlice.class); - classStore.put(TLRPC.TL_account_sentChangePhoneCode.constructor, TLRPC.TL_account_sentChangePhoneCode.class); - classStore.put(TLRPC.TL_updateUserPhone.constructor, TLRPC.TL_updateUserPhone.class); - classStore.put(TLRPC.TL_decryptedMessageActionRequestKey.constructor, TLRPC.TL_decryptedMessageActionRequestKey.class); - classStore.put(TLRPC.TL_decryptedMessageActionAcceptKey.constructor, TLRPC.TL_decryptedMessageActionAcceptKey.class); - classStore.put(TLRPC.TL_decryptedMessageActionCommitKey.constructor, TLRPC.TL_decryptedMessageActionCommitKey.class); - classStore.put(TLRPC.TL_decryptedMessageActionAbortKey.constructor, TLRPC.TL_decryptedMessageActionAbortKey.class); - classStore.put(TLRPC.TL_decryptedMessageActionNoop.constructor, TLRPC.TL_decryptedMessageActionNoop.class); - classStore.put(TLRPC.TL_decryptedMessageMediaExternalDocument.constructor, TLRPC.TL_decryptedMessageMediaExternalDocument.class); - classStore.put(TLRPC.TL_updateReadHistoryInbox.constructor, TLRPC.TL_updateReadHistoryInbox.class); - classStore.put(TLRPC.TL_updateReadHistoryOutbox.constructor, TLRPC.TL_updateReadHistoryOutbox.class); - classStore.put(TLRPC.TL_contactLinkUnknown.constructor, TLRPC.TL_contactLinkUnknown.class); - classStore.put(TLRPC.TL_contactLinkNone.constructor, TLRPC.TL_contactLinkNone.class); - classStore.put(TLRPC.TL_contactLinkHasPhone.constructor, TLRPC.TL_contactLinkHasPhone.class); - classStore.put(TLRPC.TL_contactLinkContact.constructor, TLRPC.TL_contactLinkContact.class); - classStore.put(TLRPC.TL_messages_affectedMessages.constructor, TLRPC.TL_messages_affectedMessages.class); - classStore.put(TLRPC.TL_updateWebPage.constructor, TLRPC.TL_updateWebPage.class); - classStore.put(TLRPC.TL_webPagePending.constructor, TLRPC.TL_webPagePending.class); - classStore.put(TLRPC.TL_webPageEmpty.constructor, TLRPC.TL_webPageEmpty.class); - classStore.put(TLRPC.TL_webPage.constructor, TLRPC.TL_webPage.class); - classStore.put(TLRPC.TL_messageMediaWebPage.constructor, TLRPC.TL_messageMediaWebPage.class); - classStore.put(TLRPC.TL_authorization.constructor, TLRPC.TL_authorization.class); - classStore.put(TLRPC.TL_account_authorizations.constructor, TLRPC.TL_account_authorizations.class); - classStore.put(TLRPC.TL_account_passwordSettings.constructor, TLRPC.TL_account_passwordSettings.class); - classStore.put(TLRPC.TL_account_passwordInputSettings.constructor, TLRPC.TL_account_passwordInputSettings.class); - classStore.put(TLRPC.TL_auth_passwordRecovery.constructor, TLRPC.TL_auth_passwordRecovery.class); - classStore.put(TLRPC.TL_messages_getWebPagePreview.constructor, TLRPC.TL_messages_getWebPagePreview.class); - - classStore.put(TLRPC.TL_messageMediaUnsupported_old.constructor, TLRPC.TL_messageMediaUnsupported_old.class); - classStore.put(TLRPC.TL_userSelf_old2.constructor, TLRPC.TL_userSelf_old2.class); - classStore.put(TLRPC.TL_msg_container.constructor, TLRPC.TL_msg_container.class); - classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class); - classStore.put(TLRPC.TL_messageActionTTLChange.constructor, TLRPC.TL_messageActionTTLChange.class); - classStore.put(TLRPC.TL_videoEncrypted.constructor, TLRPC.TL_videoEncrypted.class); - classStore.put(TLRPC.TL_documentEncrypted.constructor, TLRPC.TL_documentEncrypted.class); - classStore.put(TLRPC.TL_audioEncrypted.constructor, TLRPC.TL_audioEncrypted.class); + classStore.put(TLRPC.TL_http_wait.constructor, TLRPC.TL_http_wait.class); classStore.put(TLRPC.TL_gzip_packed.constructor, TLRPC.TL_gzip_packed.class); - classStore.put(TLRPC.Vector.constructor, TLRPC.Vector.class); - classStore.put(TLRPC.TL_userProfilePhotoOld.constructor, TLRPC.TL_userProfilePhotoOld.class); - classStore.put(TLRPC.TL_messageActionUserUpdatedPhoto.constructor, TLRPC.TL_messageActionUserUpdatedPhoto.class); - classStore.put(TLRPC.TL_messageActionUserJoined.constructor, TLRPC.TL_messageActionUserJoined.class); - classStore.put(TLRPC.TL_messageActionLoginUnknownLocation.constructor, TLRPC.TL_messageActionLoginUnknownLocation.class); - classStore.put(TLRPC.TL_encryptedChat_old.constructor, TLRPC.TL_encryptedChat_old.class); - classStore.put(TLRPC.TL_encryptedChatRequested_old.constructor, TLRPC.TL_encryptedChatRequested_old.class); - classStore.put(TLRPC.TL_decryptedMessageMediaVideo_old.constructor, TLRPC.TL_decryptedMessageMediaVideo_old.class); - classStore.put(TLRPC.TL_decryptedMessageMediaAudio_old.constructor, TLRPC.TL_decryptedMessageMediaAudio_old.class); - classStore.put(TLRPC.TL_audio_old.constructor, TLRPC.TL_audio_old.class); - classStore.put(TLRPC.TL_video_old.constructor, TLRPC.TL_video_old.class); - classStore.put(TLRPC.TL_messageActionCreatedBroadcastList.constructor, TLRPC.TL_messageActionCreatedBroadcastList.class); - classStore.put(TLRPC.TL_messageForwarded_old.constructor, TLRPC.TL_messageForwarded_old.class); - classStore.put(TLRPC.TL_message_old.constructor, TLRPC.TL_message_old.class); - classStore.put(TLRPC.TL_messageService_old.constructor, TLRPC.TL_messageService_old.class); classStore.put(TLRPC.TL_decryptedMessageService_old.constructor, TLRPC.TL_decryptedMessageService_old.class); classStore.put(TLRPC.TL_decryptedMessage_old.constructor, TLRPC.TL_decryptedMessage_old.class); classStore.put(TLRPC.TL_message_secret.constructor, TLRPC.TL_message_secret.class); - classStore.put(TLRPC.TL_userSelf_old.constructor, TLRPC.TL_userSelf_old.class); - classStore.put(TLRPC.TL_userContact_old.constructor, TLRPC.TL_userContact_old.class); - classStore.put(TLRPC.TL_userRequest_old.constructor, TLRPC.TL_userRequest_old.class); - classStore.put(TLRPC.TL_userForeign_old.constructor, TLRPC.TL_userForeign_old.class); - classStore.put(TLRPC.TL_userDeleted_old.constructor, TLRPC.TL_userDeleted_old.class); classStore.put(TLRPC.TL_messageEncryptedAction.constructor, TLRPC.TL_messageEncryptedAction.class); classStore.put(TLRPC.TL_decryptedMessageHolder.constructor, TLRPC.TL_decryptedMessageHolder.class); + classStore.put(TLRPC.TL_client_DH_inner_data.constructor, TLRPC.TL_client_DH_inner_data.class); + classStore.put(TLRPC.TL_null.constructor, TLRPC.TL_null.class); + classStore.put(TLRPC.TL_destroy_sessions_res.constructor, TLRPC.TL_destroy_sessions_res.class); + classStore.put(TLRPC.TL_msg_container.constructor, TLRPC.TL_msg_container.class); + + + classStore.put(TLRPC.TL_video.constructor, TLRPC.TL_video.class); + classStore.put(TLRPC.TL_videoEmpty.constructor, TLRPC.TL_videoEmpty.class); + classStore.put(TLRPC.TL_video_old2.constructor, TLRPC.TL_video_old2.class); + classStore.put(TLRPC.TL_video_old.constructor, TLRPC.TL_video_old.class); + classStore.put(TLRPC.TL_videoEncrypted.constructor, TLRPC.TL_videoEncrypted.class); + + classStore.put(TLRPC.TL_audio.constructor, TLRPC.TL_audio.class); + classStore.put(TLRPC.TL_audioEncrypted.constructor, TLRPC.TL_audioEncrypted.class); + classStore.put(TLRPC.TL_audioEmpty.constructor, TLRPC.TL_audioEmpty.class); + classStore.put(TLRPC.TL_audio_old.constructor, TLRPC.TL_audio_old.class); + + classStore.put(TLRPC.TL_document.constructor, TLRPC.TL_document.class); + classStore.put(TLRPC.TL_documentEmpty.constructor, TLRPC.TL_documentEmpty.class); classStore.put(TLRPC.TL_documentEncrypted_old.constructor, TLRPC.TL_documentEncrypted_old.class); + classStore.put(TLRPC.TL_documentEncrypted.constructor, TLRPC.TL_documentEncrypted.class); classStore.put(TLRPC.TL_document_old.constructor, TLRPC.TL_document_old.class); - classStore.put(TLRPC.TL_config_old.constructor, TLRPC.TL_config_old.class); - classStore.put(TLRPC.TL_messageForwarded_old2.constructor, TLRPC.TL_messageForwarded_old2.class); - classStore.put(TLRPC.TL_message_old2.constructor, TLRPC.TL_message_old2.class); - classStore.put(TLRPC.TL_documentAttributeSticker_old.constructor, TLRPC.TL_documentAttributeSticker_old.class); + + classStore.put(TLRPC.TL_photo.constructor, TLRPC.TL_photo.class); + classStore.put(TLRPC.TL_photoEmpty.constructor, TLRPC.TL_photoEmpty.class); + classStore.put(TLRPC.TL_photoSize.constructor, TLRPC.TL_photoSize.class); + classStore.put(TLRPC.TL_photoSizeEmpty.constructor, TLRPC.TL_photoSizeEmpty.class); + classStore.put(TLRPC.TL_photoCachedSize.constructor, TLRPC.TL_photoCachedSize.class); + classStore.put(TLRPC.TL_photo_old.constructor, TLRPC.TL_photo_old.class); } static TLClassStore store = null; @@ -436,46 +107,27 @@ public class TLClassStore { return store; } - public TLObject TLdeserialize(AbsSerializedData stream, int constructor) { + public TLObject TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { try { - return TLdeserialize(stream, constructor, null); + return TLdeserialize(stream, constructor, null, exception); } catch (Exception e) { return null; } } - public TLObject TLdeserialize(AbsSerializedData stream, int constructor, TLObject request) { + public TLObject TLdeserialize(AbsSerializedData stream, int constructor, TLObject request, boolean exception) { Class objClass = classStore.get(constructor); if (objClass != null) { try { TLObject response = (TLObject)objClass.newInstance(); - if (response instanceof TLRPC.Vector) { - if (request != null) { - request.parseVector((TLRPC.Vector)response, stream); - } else { - int size = stream.readInt32(); - for (int a = 0; a < size; a++) { - ((TLRPC.Vector)response).objects.add(stream.readInt32()); - } - } - } else { - response.readParams(stream); - } + response.readParams(stream, exception); return response; - } catch (IllegalAccessException e) { - FileLog.e("tmessages", "can't create class"); - return null; - } catch (InstantiationException e2) { + } catch (Throwable e) { FileLog.e("tmessages", "can't create class"); return null; } } else { - FileLog.e("tmessages", String.format("unknown class %x", constructor)); - if (BuildVars.DEBUG_VERSION) { - throw new RuntimeException(String.format("unknown class %x", constructor)); - } else { - return null; - } + return null; } } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLObject.java index 8ee8bc00..17c49307 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLObject.java @@ -11,15 +11,15 @@ package org.telegram.messenger; public class TLObject { public boolean disableFree = false; - public TLObject () { + public TLObject() { } - public void readParams(AbsSerializedData stream) { + public void readParams(AbsSerializedData stream, boolean exception) { } - public byte[] serialize () { + public byte[] serialize() { return null; } @@ -27,16 +27,12 @@ public class TLObject { } - public Class responseClass () { - return this.getClass(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return null; } - public int layer () { - return 11; - } - - public void parseVector(TLRPC.Vector vector, AbsSerializedData data) { - + public int layer() { + return 11; } public void freeResources() { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java index ce412857..cd093459 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java @@ -19,2100 +19,37 @@ public class TLRPC { public static final int MESSAGE_FLAG_FWD = 4; public static final int MESSAGE_FLAG_REPLY = 8; public static final int MESSAGE_FLAG_MENTION = 16; - public static final int LAYER = 27; + public static final int MESSAGE_FLAG_CONTENT_UNREAD = 32; + public static final int LAYER = 28; - public static class ChatPhoto extends TLObject { - public FileLocation photo_small; - public FileLocation photo_big; - } + public static class TL_inputEncryptedChat extends TLObject { + public static int constructor = 0xf141b5e1; - public static class TL_chatPhotoEmpty extends ChatPhoto { - public static int constructor = 0x37c1011c; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_chatPhoto extends ChatPhoto { - public static int constructor = 0x6153276a; - - - public void readParams(AbsSerializedData stream) { - photo_small = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - photo_big = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - photo_small.serializeToStream(stream); - photo_big.serializeToStream(stream); - } - } - - public static class BadMsgNotification extends TLObject { - public long bad_msg_id; - public int bad_msg_seqno; - public int error_code; - public long new_server_salt; - } - - public static class TL_bad_msg_notification extends BadMsgNotification { - public static int constructor = 0xa7eff811; - - - public void readParams(AbsSerializedData stream) { - bad_msg_id = stream.readInt64(); - bad_msg_seqno = stream.readInt32(); - error_code = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(bad_msg_id); - stream.writeInt32(bad_msg_seqno); - stream.writeInt32(error_code); - } - } - - public static class TL_bad_server_salt extends BadMsgNotification { - public static int constructor = 0xedab447b; - - - public void readParams(AbsSerializedData stream) { - bad_msg_id = stream.readInt64(); - bad_msg_seqno = stream.readInt32(); - error_code = stream.readInt32(); - new_server_salt = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(bad_msg_id); - stream.writeInt32(bad_msg_seqno); - stream.writeInt32(error_code); - stream.writeInt64(new_server_salt); - } - } - - public static class TL_error extends TLObject { - public static int constructor = 0xc4b9f9bb; - - public int code; - public String text; - - public void readParams(AbsSerializedData stream) { - code = stream.readInt32(); - text = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(code); - stream.writeString(text); - } - } - - public static class messages_SentEncryptedMessage extends TLObject { - public int date; - public EncryptedFile file; - } - - public static class TL_messages_sentEncryptedMessage extends messages_SentEncryptedMessage { - public static int constructor = 0x560f8935; - - - public void readParams(AbsSerializedData stream) { - date = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(date); - } - } - - public static class TL_messages_sentEncryptedFile extends messages_SentEncryptedMessage { - public static int constructor = 0x9493ff32; - - - public void readParams(AbsSerializedData stream) { - date = stream.readInt32(); - file = (EncryptedFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(date); - file.serializeToStream(stream); - } - } - - public static class NotifyPeer extends TLObject { - public Peer peer; - } - - public static class TL_notifyAll extends NotifyPeer { - public static int constructor = 0x74d07c60; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_notifyChats extends NotifyPeer { - public static int constructor = 0xc007cec3; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_notifyUsers extends NotifyPeer { - public static int constructor = 0xb4c83b4c; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_notifyPeer extends NotifyPeer { - public static int constructor = 0x9fd40bd8; - - - public void readParams(AbsSerializedData stream) { - peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - } - } - - public static class TL_auth_checkedPhone extends TLObject { - public static int constructor = 0x811ea28e; - - public boolean phone_registered; - - public void readParams(AbsSerializedData stream) { - phone_registered = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeBool(phone_registered); - } - } - - public static class TL_msgs_ack extends TLObject { - public static int constructor = 0x62d6b459; - - public ArrayList msg_ids = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - msg_ids.add(stream.readInt64()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = msg_ids.size(); - stream.writeInt32(count); - for (Long msg_id : msg_ids) { - stream.writeInt64(msg_id); - } - } - } - - public static class TL_messages_chatFull extends TLObject { - public static int constructor = 0xe5d7d19c; - - public TL_chatFull full_chat; - public ArrayList chats = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - full_chat = (TL_chatFull)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(AbsSerializedData stream) { - stream.writeInt32(constructor); - full_chat.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_account_passwordSettings extends TLObject { - public static int constructor = 0xb7b72ab3; - - public String email; - - public void readParams(AbsSerializedData stream) { - email = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(email); - } - } - - public static class DocumentAttribute extends TLObject { - public int duration; - public String file_name; - public String alt; - public int w; - public int h; - } - - public static class TL_documentAttributeAnimated extends DocumentAttribute { - public static int constructor = 0x11b58939; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_documentAttributeAudio extends DocumentAttribute { - public static int constructor = 0x51448e5; - - - public void readParams(AbsSerializedData stream) { - duration = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(duration); - } - } - - public static class TL_documentAttributeFilename extends DocumentAttribute { - public static int constructor = 0x15590068; - - - public void readParams(AbsSerializedData stream) { - file_name = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(file_name); - } - } - - public static class TL_documentAttributeVideo extends DocumentAttribute { - public static int constructor = 0x5910cccb; - - - public void readParams(AbsSerializedData stream) { - duration = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(duration); - stream.writeInt32(w); - stream.writeInt32(h); - } - } - - public static class TL_documentAttributeSticker extends DocumentAttribute { - public static int constructor = 0x994c9882; - - - public void readParams(AbsSerializedData stream) { - alt = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(alt); - } - } - - public static class TL_documentAttributeImageSize extends DocumentAttribute { - public static int constructor = 0x6c37c15c; - - - public void readParams(AbsSerializedData stream) { - w = stream.readInt32(); - h = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(w); - stream.writeInt32(h); - } - } - - public static class TL_contactStatus extends TLObject { - public static int constructor = 0xd3680c61; - - public int user_id; - public UserStatus status; - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - status.serializeToStream(stream); - } - } - - public static class TL_auth_authorization extends TLObject { - public static int constructor = 0xf6b673a4; - - public int expires; - public User user; - - public void readParams(AbsSerializedData stream) { - expires = stream.readInt32(); - user = (User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(expires); - user.serializeToStream(stream); - } - } - - public static class messages_Messages extends TLObject { - public ArrayList messages = new ArrayList<>(); - public ArrayList chats = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - public int count; - } - - public static class TL_messages_messages extends messages_Messages { - public static int constructor = 0x8c718e87; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - messages.add((Message)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())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - messages.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); - } - } - } - - public static class TL_messages_messagesSlice extends messages_Messages { - public static int constructor = 0xb446ae3; - - - public void readParams(AbsSerializedData stream) { - count = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - messages.add((Message)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())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(count); - stream.writeInt32(0x1cb5c415); - int count = messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - messages.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); - } - } - } - - public static class RpcDropAnswer extends TLObject { - public long msg_id; - public int seq_no; - public int bytes; - } - - public static class TL_rpc_answer_unknown extends RpcDropAnswer { - public static int constructor = 0x5e2ad36e; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_rpc_answer_dropped extends RpcDropAnswer { - public static int constructor = 0xa43ad8b7; - - - public void readParams(AbsSerializedData stream) { - msg_id = stream.readInt64(); - seq_no = stream.readInt32(); - bytes = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(msg_id); - stream.writeInt32(seq_no); - stream.writeInt32(bytes); - } - } - - public static class TL_rpc_answer_dropped_running extends RpcDropAnswer { - public static int constructor = 0xcd78e586; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_contacts_link extends TLObject { - public static int constructor = 0x3ace484c; - - public ContactLink my_link; - public ContactLink foreign_link; - public User user; - - public void readParams(AbsSerializedData stream) { - my_link = (ContactLink)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - foreign_link = (ContactLink)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - user = (User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - my_link.serializeToStream(stream); - foreign_link.serializeToStream(stream); - user.serializeToStream(stream); - } - } - - public static class Peer extends TLObject { - public int user_id; public int chat_id; - } + public long access_hash; - public static class TL_peerUser extends Peer { - public static int constructor = 0x9db1bc6d; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); + public static TL_inputEncryptedChat TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_inputEncryptedChat.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inputEncryptedChat", constructor)); + } else { + return null; + } + } + TL_inputEncryptedChat result = new TL_inputEncryptedChat(); + result.readParams(stream, exception); + return result; } - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - } - } - - public static class TL_peerChat extends Peer { - public static int constructor = 0xbad0e5bb; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt32(chat_id); - } - } - - public static class EncryptedFile extends TLObject { - public long id; - public long access_hash; - public int size; - public int dc_id; - public int key_fingerprint; - } - - public static class TL_encryptedFile extends EncryptedFile { - public static int constructor = 0x4a70994c; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - size = stream.readInt32(); - dc_id = stream.readInt32(); - key_fingerprint = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); stream.writeInt64(access_hash); - stream.writeInt32(size); - stream.writeInt32(dc_id); - stream.writeInt32(key_fingerprint); - } - } - - public static class TL_encryptedFileEmpty extends EncryptedFile { - public static int constructor = 0xc21f497e; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messages_affectedMessages extends TLObject { - public static int constructor = 0x84d19185; - - public int pts; - public int pts_count; - - public void readParams(AbsSerializedData stream) { - pts = stream.readInt32(); - pts_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - - public static class TL_authorization extends TLObject { - public static int constructor = 0x7bf2e6f6; - - public long hash; - public int flags; - public String device_model; - public String platform; - public String system_version; - public int api_id; - public String app_name; - public String app_version; - public int date_created; - public int date_active; - public String ip; - public String country; - public String region; - - public void readParams(AbsSerializedData stream) { - hash = stream.readInt64(); - flags = stream.readInt32(); - device_model = stream.readString(); - platform = stream.readString(); - system_version = stream.readString(); - api_id = stream.readInt32(); - app_name = stream.readString(); - app_version = stream.readString(); - date_created = stream.readInt32(); - date_active = stream.readInt32(); - ip = stream.readString(); - country = stream.readString(); - region = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(hash); - stream.writeInt32(flags); - stream.writeString(device_model); - stream.writeString(platform); - stream.writeString(system_version); - stream.writeInt32(api_id); - stream.writeString(app_name); - stream.writeString(app_version); - stream.writeInt32(date_created); - stream.writeInt32(date_active); - stream.writeString(ip); - stream.writeString(country); - stream.writeString(region); - } - } - - public static class DestroySessionRes extends TLObject { - public long session_id; - } - - public static class TL_destroy_session_ok extends DestroySessionRes { - public static int constructor = 0xe22045fc; - - - public void readParams(AbsSerializedData stream) { - session_id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(session_id); - } - } - - public static class TL_destroy_session_none extends DestroySessionRes { - public static int constructor = 0x62d350c9; - - - public void readParams(AbsSerializedData stream) { - session_id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(session_id); - } - } - - public static class updates_Difference extends TLObject { - public int date; - public int seq; - public ArrayList 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 intermediate_state; - public TL_updates_state state; - } - - public static class TL_updates_differenceEmpty extends updates_Difference { - public static int constructor = 0x5d75a138; - - - public void readParams(AbsSerializedData stream) { - date = stream.readInt32(); - seq = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(date); - stream.writeInt32(seq); - } - } - - public static class TL_updates_differenceSlice extends updates_Difference { - public static int constructor = 0xa8fb1981; - - - public void readParams(AbsSerializedData 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())); - } - intermediate_state = (TL_updates_state)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData 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); - } - intermediate_state.serializeToStream(stream); - } - } - - public static class TL_updates_difference extends updates_Difference { - public static int constructor = 0xf49ca0; - - - public void readParams(AbsSerializedData 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()); - } - - public void serializeToStream(AbsSerializedData 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); - } - } - - public static class GeoPoint extends TLObject { - public double _long; - public double lat; - } - - public static class TL_geoPointEmpty extends GeoPoint { - public static int constructor = 0x1117dd5f; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_geoPoint extends GeoPoint { - public static int constructor = 0x2049d70c; - - - public void readParams(AbsSerializedData stream) { - _long = stream.readDouble(); - lat = stream.readDouble(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeDouble(_long); - stream.writeDouble(lat); - } - } - - public static class TL_privacyKeyStatusTimestamp extends TLObject { - public static int constructor = 0xbc2eab30; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_account_privacyRules extends TLObject { - public static int constructor = 0x554abb6f; - - public ArrayList rules = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - rules.add((PrivacyRule)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = rules.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - rules.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = users.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - users.get(a).serializeToStream(stream); - } - } - } - - public static class help_AppUpdate extends TLObject { - public int id; - public boolean critical; - public String url; - public String text; - } - - public static class TL_help_appUpdate extends help_AppUpdate { - public static int constructor = 0x8987f311; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - critical = stream.readBool(); - url = stream.readString(); - text = stream.readString(); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messageEmpty extends Message { - public static int constructor = 0x83e5de54; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - } - } - - public static class TL_inputPhoneContact extends TLObject { - public static int constructor = 0xf392b7f4; - - public long client_id; - public String phone; - public String first_name; - public String last_name; - - public void readParams(AbsSerializedData stream) { - client_id = stream.readInt64(); - phone = stream.readString(); - first_name = stream.readString(); - last_name = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(client_id); - stream.writeString(phone); - stream.writeString(first_name); - stream.writeString(last_name); - } - } - - public static class SendMessageAction extends TLObject { - } - - public static class TL_sendMessageGeoLocationAction extends SendMessageAction { - public static int constructor = 0x176f8ba1; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageChooseContactAction extends SendMessageAction { - public static int constructor = 0x628cbc6f; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageTypingAction extends SendMessageAction { - public static int constructor = 0x16bf744e; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageUploadDocumentAction extends SendMessageAction { - public static int constructor = 0x8faee98e; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageRecordVideoAction extends SendMessageAction { - public static int constructor = 0xa187d66f; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageUploadPhotoAction extends SendMessageAction { - public static int constructor = 0x990a3c1a; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageUploadVideoAction extends SendMessageAction { - public static int constructor = 0x92042ff7; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageUploadAudioAction extends SendMessageAction { - public static int constructor = 0xe6ac8a6f; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageCancelAction extends SendMessageAction { - public static int constructor = 0xfd5ec8f5; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_sendMessageRecordAudioAction extends SendMessageAction { - public static int constructor = 0xd52f73f7; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_invokeAfterMsg extends TLObject { - public static int constructor = 0xcb9f372d; - - public long msg_id; - public TLObject query; - - public void readParams(AbsSerializedData stream) { - msg_id = stream.readInt64(); - query = TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(msg_id); - query.serializeToStream(stream); - } - } - - public static class MessageMedia extends TLObject { - public Video video; - public Photo photo; - public WebPage webpage; - public Document document; - public GeoPoint geo; - public Audio audio; - public String phone_number; - public String first_name; - public String last_name; - public int user_id; - public byte[] bytes; - } - - public static class TL_messageMediaVideo extends MessageMedia { - public static int constructor = 0xa2d24290; - - - public void readParams(AbsSerializedData stream) { - video = (Video)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - video.serializeToStream(stream); - } - } - - public static class TL_messageMediaPhoto extends MessageMedia { - public static int constructor = 0xc8c45a2a; - - - public void readParams(AbsSerializedData stream) { - photo = (Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - photo.serializeToStream(stream); - } - } - - public static class TL_messageMediaWebPage extends MessageMedia { - public static int constructor = 0xa32dd600; - - - public void readParams(AbsSerializedData stream) { - webpage = (WebPage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - webpage.serializeToStream(stream); - } - } - - public static class TL_messageMediaDocument extends MessageMedia { - public static int constructor = 0x2fda2204; - - - public void readParams(AbsSerializedData stream) { - document = (Document)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - document.serializeToStream(stream); - } - } - - public static class TL_messageMediaGeo extends MessageMedia { - public static int constructor = 0x56e0d474; - - - public void readParams(AbsSerializedData stream) { - geo = (GeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - geo.serializeToStream(stream); - } - } - - public static class TL_messageMediaEmpty extends MessageMedia { - public static int constructor = 0x3ded6320; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messageMediaAudio extends MessageMedia { - public static int constructor = 0xc6b68300; - - - public void readParams(AbsSerializedData stream) { - audio = (Audio)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - audio.serializeToStream(stream); - } - } - - public static class TL_messageMediaContact extends MessageMedia { - public static int constructor = 0x5e7d2f39; - - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - first_name = stream.readString(); - last_name = stream.readString(); - user_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(phone_number); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeInt32(user_id); - } - } - - public static class TL_messageMediaUnsupported extends MessageMedia { - public static int constructor = 0x9f84f49e; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class auth_SentCode extends TLObject { - public boolean phone_registered; - public String phone_code_hash; - public int send_call_timeout; - public boolean is_password; - } - - public static class TL_auth_sentAppCode extends auth_SentCode { - public static int constructor = 0xe325edcf; - - - public void readParams(AbsSerializedData stream) { - phone_registered = stream.readBool(); - phone_code_hash = stream.readString(); - send_call_timeout = stream.readInt32(); - is_password = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeBool(phone_registered); - stream.writeString(phone_code_hash); - stream.writeInt32(send_call_timeout); - stream.writeBool(is_password); - } - } - - public static class TL_auth_sentCode extends auth_SentCode { - public static int constructor = 0xefed51d9; - - - public void readParams(AbsSerializedData stream) { - phone_registered = stream.readBool(); - phone_code_hash = stream.readString(); - send_call_timeout = stream.readInt32(); - is_password = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeBool(phone_registered); - stream.writeString(phone_code_hash); - stream.writeInt32(send_call_timeout); - stream.writeBool(is_password); - } - } - - public static class PeerNotifySettings extends TLObject { - public int mute_until; - public String sound; - public boolean show_previews; - public int events_mask; - } - - public static class TL_peerNotifySettingsEmpty extends PeerNotifySettings { - public static int constructor = 0x70a68512; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_peerNotifySettings extends PeerNotifySettings { - public static int constructor = 0x8d5e11ee; - - - public void readParams(AbsSerializedData stream) { - mute_until = stream.readInt32(); - sound = stream.readString(); - show_previews = stream.readBool(); - events_mask = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(mute_until); - stream.writeString(sound); - stream.writeBool(show_previews); - stream.writeInt32(events_mask); - } - } - - public static class TL_msg_resend_req extends TLObject { - public static int constructor = 0x7d861a08; - - public ArrayList msg_ids = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - msg_ids.add(stream.readInt64()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = msg_ids.size(); - stream.writeInt32(count); - for (Long msg_id : msg_ids) { - stream.writeInt64(msg_id); - } - } - } - - public static class TL_http_wait extends TLObject { - public static int constructor = 0x9299359f; - - public int max_delay; - public int wait_after; - public int max_wait; - - public void readParams(AbsSerializedData stream) { - max_delay = stream.readInt32(); - wait_after = stream.readInt32(); - max_wait = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(max_delay); - stream.writeInt32(wait_after); - stream.writeInt32(max_wait); - } - } - - public static class contacts_Blocked extends TLObject { - public ArrayList blocked = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - public int count; - } - - public static class TL_contacts_blocked extends contacts_Blocked { - public static int constructor = 0x1c138d15; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - blocked.add((TL_contactBlocked)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = blocked.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - blocked.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_contacts_blockedSlice extends contacts_Blocked { - public static int constructor = 0x900802a1; - - - public void readParams(AbsSerializedData stream) { - count = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - blocked.add((TL_contactBlocked)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(count); - stream.writeInt32(0x1cb5c415); - int count = blocked.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - blocked.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 InputGeoPoint extends TLObject { - public double lat; - public double _long; - } - - public static class TL_inputGeoPoint extends InputGeoPoint { - public static int constructor = 0xf3b7acc9; - - - public void readParams(AbsSerializedData stream) { - lat = stream.readDouble(); - _long = stream.readDouble(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeDouble(lat); - stream.writeDouble(_long); - } - } - - public static class TL_inputGeoPointEmpty extends InputGeoPoint { - public static int constructor = 0xe4c123d6; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_help_inviteText extends TLObject { - public static int constructor = 0x18cb9f78; - - public String message; - - public void readParams(AbsSerializedData stream) { - message = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(message); - } - } - - public static class messages_DhConfig extends TLObject { - public byte[] random; - public int g; - public byte[] p; - public int version; - } - - public static class TL_messages_dhConfigNotModified extends messages_DhConfig { - public static int constructor = 0xc0e24635; - - - public void readParams(AbsSerializedData stream) { - random = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(random); - } - } - - public static class TL_messages_dhConfig extends messages_DhConfig { - public static int constructor = 0x2c221edd; - - - public void readParams(AbsSerializedData stream) { - g = stream.readInt32(); - p = stream.readByteArray(); - version = stream.readInt32(); - random = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(g); - stream.writeByteArray(p); - stream.writeInt32(version); - stream.writeByteArray(random); - } - } - - public static class TL_audioEmpty extends Audio { - public static int constructor = 0x586988d8; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - } - } - - public static class TL_audio extends Audio { - public static int constructor = 0xc7ac6496; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - user_id = stream.readInt32(); - date = stream.readInt32(); - duration = stream.readInt32(); - mime_type = stream.readString(); - size = stream.readInt32(); - dc_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(user_id); - stream.writeInt32(date); - stream.writeInt32(duration); - stream.writeString(mime_type); - stream.writeInt32(size); - stream.writeInt32(dc_id); - } - } - - public static class TL_destroy_sessions_res extends TLObject { - public static int constructor = 0xfb95abcd; - - public ArrayList destroy_results = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - destroy_results.add((DestroySessionRes)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - int count = destroy_results.size(); - stream.writeInt32(count); - for (DestroySessionRes destroy_result : destroy_results) { - destroy_result.serializeToStream(stream); - } - } - } - - public static class PrivacyRule extends TLObject { - public ArrayList users = new ArrayList<>(); - } - - public static class TL_privacyValueAllowUsers extends PrivacyRule { - public static int constructor = 0x4d5bbe0c; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add(stream.readInt32()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = users.size(); - stream.writeInt32(count); - for (Integer user : users) { - stream.writeInt32(user); - } - } - } - - public static class TL_privacyValueDisallowAll extends PrivacyRule { - public static int constructor = 0x8b73e763; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_privacyValueAllowContacts extends PrivacyRule { - public static int constructor = 0xfffe1bac; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_privacyValueDisallowContacts extends PrivacyRule { - public static int constructor = 0xf888fa1a; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_privacyValueAllowAll extends PrivacyRule { - public static int constructor = 0x65427b82; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_privacyValueDisallowUsers extends PrivacyRule { - public static int constructor = 0xc7f49b7; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add(stream.readInt32()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = users.size(); - stream.writeInt32(count); - for (Integer user : users) { - stream.writeInt32(user); - } - } - } - - public static class contacts_Contacts extends TLObject { - public ArrayList contacts = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - } - - public static class TL_contacts_contacts extends contacts_Contacts { - public static int constructor = 0x6f8b8cb2; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - contacts.add((TL_contact)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = contacts.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - contacts.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_contacts_contactsNotModified extends contacts_Contacts { - public static int constructor = 0xb74ba9d2; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputPrivacyKeyStatusTimestamp extends TLObject { - public static int constructor = 0x4f96cb18; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class photos_Photos extends TLObject { - public ArrayList photos = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - public int count; - } - - public static class TL_photos_photos extends photos_Photos { - public static int constructor = 0x8dca6aa5; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - photos.add((Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = photos.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - photos.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_photos_photosSlice extends photos_Photos { - public static int constructor = 0x15051f54; - - - public void readParams(AbsSerializedData stream) { - count = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - photos.add((Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(count); - stream.writeInt32(0x1cb5c415); - int count = photos.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - photos.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_chatFull extends TLObject { - public static int constructor = 0x630e61be; - - public int id; - public ChatParticipants participants; - public Photo chat_photo; - public PeerNotifySettings notify_settings; - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - participants = (ChatParticipants)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - chat_photo = (Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - notify_settings = (PeerNotifySettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - participants.serializeToStream(stream); - chat_photo.serializeToStream(stream); - notify_settings.serializeToStream(stream); - } - } - - public static class TL_msgs_all_info extends TLObject { - public static int constructor = 0x8cc0d131; - - public ArrayList msg_ids = new ArrayList<>(); - public String info; - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - msg_ids.add(stream.readInt64()); - } - info = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = msg_ids.size(); - stream.writeInt32(count); - for (Long msg_id : msg_ids) { - stream.writeInt64(msg_id); - } - stream.writeString(info); - } - } - - public static class TL_inputPeerNotifySettings extends TLObject { - public static int constructor = 0x46a2ce98; - - public int mute_until; - public String sound; - public boolean show_previews; - public int events_mask; - - public void readParams(AbsSerializedData stream) { - mute_until = stream.readInt32(); - sound = stream.readString(); - show_previews = stream.readBool(); - events_mask = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(mute_until); - stream.writeString(sound); - stream.writeBool(show_previews); - stream.writeInt32(events_mask); - } - } - - public static class TL_null extends TLObject { - public static int constructor = 0x56730bcc; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class InputUser extends TLObject { - public int user_id; - public long access_hash; - } - - public static class TL_inputUserSelf extends InputUser { - public static int constructor = 0xf7c1b13f; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputUserForeign extends InputUser { - public static int constructor = 0x655e74ff; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt64(access_hash); - } - } - - public static class TL_inputUserEmpty extends InputUser { - public static int constructor = 0xb98886cf; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputUserContact extends InputUser { - public static int constructor = 0x86e94f65; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - } - } - - public static class TL_p_q_inner_data extends TLObject { - public static int constructor = 0x83c95aec; - - public byte[] pq; - public byte[] p; - public byte[] q; - public byte[] nonce; - public byte[] server_nonce; - public byte[] new_nonce; - - public void readParams(AbsSerializedData stream) { - pq = stream.readByteArray(); - p = stream.readByteArray(); - q = stream.readByteArray(); - nonce = stream.readData(16); - server_nonce = stream.readData(16); - new_nonce = stream.readData(32); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(pq); - stream.writeByteArray(p); - stream.writeByteArray(q); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeRaw(new_nonce); - } - } - - public static class TL_msgs_state_req extends TLObject { - public static int constructor = 0xda69fb52; - - public ArrayList msg_ids = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - msg_ids.add(stream.readInt64()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = msg_ids.size(); - stream.writeInt32(count); - for (Long msg_id : msg_ids) { - stream.writeInt64(msg_id); - } - } - } - - public static class Bool extends TLObject { - } - - public static class TL_boolTrue extends Bool { - public static int constructor = 0x997275b5; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_boolFalse extends Bool { - public static int constructor = 0xbc799737; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_auth_exportedAuthorization extends TLObject { - public static int constructor = 0xdf969c2d; - - public int id; - public byte[] bytes; - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - bytes = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeByteArray(bytes); } } @@ -2133,15 +70,37 @@ public class TLRPC { public int embed_height; public int duration; public String author; + + public static WebPage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + WebPage result = null; + switch(constructor) { + case 0xc586da1c: + result = new TL_webPagePending(); + break; + case 0xeb1477e8: + result = new TL_webPageEmpty(); + break; + case 0xa31ea0b5: + result = new TL_webPage(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in WebPage", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_webPagePending extends WebPage { public static int constructor = 0xc586da1c; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - date = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + date = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -2155,67 +114,57 @@ public class TLRPC { public static int constructor = 0xeb1477e8; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt64(id); } - } - - public static class TL_auth_passwordRecovery extends TLObject { - public static int constructor = 0x137948a5; - - public String email_pattern; - - public void readParams(AbsSerializedData stream) { - email_pattern = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(email_pattern); - } } public static class TL_webPage extends WebPage { public static int constructor = 0xa31ea0b5; - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt64(); - url = stream.readString(); - display_url = stream.readString(); + + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt64(exception); + url = stream.readString(exception); + display_url = stream.readString(exception); if ((flags & 1) != 0) { - type = stream.readString(); + type = stream.readString(exception); } if ((flags & 2) != 0) { - site_name = stream.readString(); + site_name = stream.readString(exception); } if ((flags & 4) != 0) { - title = stream.readString(); + title = stream.readString(exception); } if ((flags & 8) != 0) { - description = stream.readString(); + description = stream.readString(exception); } if ((flags & 16) != 0) { - photo = (Photo) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); } if ((flags & 32) != 0) { - embed_url = stream.readString(); - embed_type = stream.readString(); + embed_url = stream.readString(exception); + } + if ((flags & 32) != 0) { + embed_type = stream.readString(exception); } if ((flags & 64) != 0) { - embed_width = stream.readInt32(); - embed_height = stream.readInt32(); - } + embed_width = stream.readInt32(exception); + } + if ((flags & 64) != 0) { + embed_height = stream.readInt32(exception); + } if ((flags & 128) != 0) { - duration = stream.readInt32(); + duration = stream.readInt32(exception); } if ((flags & 256) != 0) { - author = stream.readString(); + author = stream.readString(exception); } } @@ -2242,10 +191,14 @@ public class TLRPC { } if ((flags & 32) != 0) { stream.writeString(embed_url); + } + if ((flags & 32) != 0) { stream.writeString(embed_type); } if ((flags & 64) != 0) { stream.writeInt32(embed_width); + } + if ((flags & 64) != 0) { stream.writeInt32(embed_height); } if ((flags & 128) != 0) { @@ -2257,479 +210,196 @@ public class TLRPC { } } - public static class InputNotifyPeer extends TLObject { - } + public static class TL_inputPeerNotifySettings extends TLObject { + public static int constructor = 0x46a2ce98; - public static class TL_inputNotifyChats extends InputNotifyPeer { - public static int constructor = 0x4a95e84e; + public int mute_until; + public String sound; + public boolean show_previews; + public int events_mask; - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputNotifyPeer extends InputNotifyPeer { - public static int constructor = 0xb8bc5b0c; - - public InputPeer peer; - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - } - } - - public static class TL_inputNotifyUsers extends InputNotifyPeer { - public static int constructor = 0x193b4417; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputNotifyGeoChatPeer extends InputNotifyPeer { - public static int constructor = 0x4d8ddec8; - - public TL_inputGeoChat peer; - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - } - } - - public static class TL_inputNotifyAll extends InputNotifyPeer { - public static int constructor = 0xa429b886; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class InputFileLocation extends TLObject { - public long id; - public long access_hash; - public long volume_id; - public int local_id; - public long secret; - } - - public static class TL_inputAudioFileLocation extends InputFileLocation { - public static int constructor = 0x74dc404d; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - } - } - - public static class TL_inputEncryptedFileLocation extends InputFileLocation { - public static int constructor = 0xf5235d55; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - } - } - - public static class TL_inputVideoFileLocation extends InputFileLocation { - public static int constructor = 0x3d0364ec; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - } - } - - public static class TL_inputFileLocation extends InputFileLocation { - public static int constructor = 0x14637196; - - - public void readParams(AbsSerializedData stream) { - volume_id = stream.readInt64(); - local_id = stream.readInt32(); - secret = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(volume_id); - stream.writeInt32(local_id); - stream.writeInt64(secret); - } - } - - public static class TL_photos_photo extends TLObject { - public static int constructor = 0x20212ca8; - - public Photo photo; - public ArrayList users = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - photo = (Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public static TL_inputPeerNotifySettings TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_inputPeerNotifySettings.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inputPeerNotifySettings", constructor)); + } else { + return null; + } } + TL_inputPeerNotifySettings result = new TL_inputPeerNotifySettings(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + mute_until = stream.readInt32(exception); + sound = stream.readString(exception); + show_previews = stream.readBool(exception); + events_mask = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - photo.serializeToStream(stream); - stream.writeInt32(0x1cb5c415); - int count = users.size(); - stream.writeInt32(count); - for (User user : users) { - user.serializeToStream(stream); - } + stream.writeInt32(mute_until); + stream.writeString(sound); + stream.writeBool(show_previews); + stream.writeInt32(events_mask); } } - public static class TL_userContact extends User { - public static int constructor = 0xcab35e18; + public static class TL_inputEncryptedFile extends InputEncryptedFile { + public static int constructor = 0x5a17b5e5; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - username = stream.readString(); - access_hash = stream.readInt64(); - phone = stream.readString(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(username); + stream.writeInt64(id); stream.writeInt64(access_hash); - stream.writeString(phone); - photo.serializeToStream(stream); - status.serializeToStream(stream); } } - public static class TL_userRequest extends User { - public static int constructor = 0xd9ccc4ef; + public static class TL_inputEncryptedFileBigUploaded extends InputEncryptedFile { + public static int constructor = 0x2dc173c8; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - username = stream.readString(); - access_hash = stream.readInt64(); - phone = stream.readString(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + parts = stream.readInt32(exception); + key_fingerprint = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(username); - stream.writeInt64(access_hash); - stream.writeString(phone); - photo.serializeToStream(stream); - status.serializeToStream(stream); + stream.writeInt64(id); + stream.writeInt32(parts); + stream.writeInt32(key_fingerprint); } } - public static class TL_userForeign extends User { - public static int constructor = 0x75cf7a8; + public static class TL_inputEncryptedFileEmpty extends InputEncryptedFile { + public static int constructor = 0x1837c364; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - username = stream.readString(); - access_hash = stream.readInt64(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputEncryptedFileUploaded extends InputEncryptedFile { + public static int constructor = 0x64bd0306; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + parts = stream.readInt32(exception); + md5_checksum = stream.readString(exception); + key_fingerprint = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(username); - stream.writeInt64(access_hash); - photo.serializeToStream(stream); - status.serializeToStream(stream); + stream.writeInt64(id); + stream.writeInt32(parts); + stream.writeString(md5_checksum); + stream.writeInt32(key_fingerprint); } } - public static class TL_userDeleted extends User { - public static int constructor = 0xd6016d7a; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - username = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(username); - } - } - - public static class TL_userSelf extends User { - public static int constructor = 0x1c60e608; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - username = stream.readString(); - phone = stream.readString(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(username); - stream.writeString(phone); - photo.serializeToStream(stream); - status.serializeToStream(stream); - } - } - - public static class GeoChatMessage extends TLObject { - public int chat_id; - public int id; - public int from_id; - public int date; - public String message; - public MessageMedia media; - public MessageAction action; - } - - public static class TL_geoChatMessage extends GeoChatMessage { - public static int constructor = 0x4505f8e1; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - id = stream.readInt32(); - from_id = stream.readInt32(); - date = stream.readInt32(); - message = stream.readString(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(id); - stream.writeInt32(from_id); - stream.writeInt32(date); - stream.writeString(message); - media.serializeToStream(stream); - } - } - - public static class TL_geoChatMessageService extends GeoChatMessage { - public static int constructor = 0xd34fa24e; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - id = stream.readInt32(); - from_id = stream.readInt32(); - date = stream.readInt32(); - action = (MessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(id); - stream.writeInt32(from_id); - stream.writeInt32(date); - action.serializeToStream(stream); - } - } - - public static class TL_geoChatMessageEmpty extends GeoChatMessage { - public static int constructor = 0x60311a9b; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(id); - } - } - - public static class TL_pong extends TLObject { - public static int constructor = 0x347773c5; - + public static class MsgDetailedInfo extends TLObject { + public long answer_msg_id; + public int bytes; + public int status; public long msg_id; - public long ping_id; - public void readParams(AbsSerializedData stream) { - msg_id = stream.readInt64(); - ping_id = stream.readInt64(); + public static MsgDetailedInfo TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + MsgDetailedInfo result = null; + switch(constructor) { + case 0x809db6df: + result = new TL_msg_new_detailed_info(); + break; + case 0x276d3ec6: + result = new TL_msg_detailed_info(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in MsgDetailedInfo", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_msg_new_detailed_info extends MsgDetailedInfo { + public static int constructor = 0x809db6df; + + + public void readParams(AbsSerializedData stream, boolean exception) { + answer_msg_id = stream.readInt64(exception); + bytes = stream.readInt32(exception); + status = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream, boolean exception) { + msg_id = stream.readInt64(exception); + answer_msg_id = stream.readInt64(exception); + bytes = stream.readInt32(exception); + status = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt64(msg_id); - stream.writeInt64(ping_id); + stream.writeInt64(answer_msg_id); + stream.writeInt32(bytes); + stream.writeInt32(status); } } - public static class TL_messageActionChatEditPhoto extends MessageAction { - public static int constructor = 0x7fcb13a8; + public static class GeoPoint extends TLObject { + public double _long; + public double lat; - - public void readParams(AbsSerializedData stream) { - photo = (Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - photo.serializeToStream(stream); - } - } - - public static class TL_messageActionChatDeleteUser extends MessageAction { - public static int constructor = 0xb2ae9b0c; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - } - } - - public static class TL_messageActionChatDeletePhoto extends MessageAction { - public static int constructor = 0x95e3fbef; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messageActionChatAddUser extends MessageAction { - public static int constructor = 0x5e3cfc4b; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - } - } - - public static class TL_messageActionChatCreate extends MessageAction { - public static int constructor = 0xa6638b9a; - - - public void readParams(AbsSerializedData stream) { - title = stream.readString(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add(stream.readInt32()); + public static GeoPoint TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + GeoPoint result = null; + switch(constructor) { + case 0x1117dd5f: + result = new TL_geoPointEmpty(); + break; + case 0x2049d70c: + result = new TL_geoPoint(); + break; } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(title); - stream.writeInt32(0x1cb5c415); - int count = users.size(); - stream.writeInt32(count); - for (Integer user : users) { - stream.writeInt32(user); + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in GeoPoint", constructor)); } + if (result != null) { + result.readParams(stream, exception); + } + return result; } } - public static class TL_messageActionEmpty extends MessageAction { - public static int constructor = 0xb6aef7b0; + public static class TL_geoPointEmpty extends GeoPoint { + public static int constructor = 0x1117dd5f; public void serializeToStream(AbsSerializedData stream) { @@ -2737,307 +407,171 @@ public class TLRPC { } } - public static class TL_messageActionChatEditTitle extends MessageAction { - public static int constructor = 0xb5a1ce5a; + public static class TL_geoPoint extends GeoPoint { + public static int constructor = 0x2049d70c; - public void readParams(AbsSerializedData stream) { - title = stream.readString(); + public void readParams(AbsSerializedData stream, boolean exception) { + _long = stream.readDouble(exception); + lat = stream.readDouble(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeString(title); + stream.writeDouble(_long); + stream.writeDouble(lat); } } - public static class TL_messageActionGeoChatCreate extends MessageAction { - public static int constructor = 0x6f038ebc; + public static class TL_accountDaysTTL extends TLObject { + public static int constructor = 0xb8d0afdf; + public int days; - public void readParams(AbsSerializedData stream) { - title = stream.readString(); - address = stream.readString(); + public static TL_accountDaysTTL TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_accountDaysTTL.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_accountDaysTTL", constructor)); + } else { + return null; + } + } + TL_accountDaysTTL result = new TL_accountDaysTTL(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + days = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeString(title); - stream.writeString(address); + stream.writeInt32(days); } } - public static class TL_messageActionGeoChatCheckin extends MessageAction { - public static int constructor = 0xc7d53de; + public static class TL_error extends TLObject { + public static int constructor = 0xc4b9f9bb; + public int code; + public String text; - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); + public static TL_error TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_error.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_error", constructor)); + } else { + return null; + } + } + TL_error result = new TL_error(); + result.readParams(stream, exception); + return result; } - } - public static class Set_client_DH_params_answer extends TLObject { - public byte[] nonce; - public byte[] server_nonce; - public byte[] new_nonce_hash2; - public byte[] new_nonce_hash3; - public byte[] new_nonce_hash1; - } - - public static class TL_dh_gen_retry extends Set_client_DH_params_answer { - public static int constructor = 0x46dc1fb9; - - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - new_nonce_hash2 = stream.readData(16); + public void readParams(AbsSerializedData stream, boolean exception) { + code = stream.readInt32(exception); + text = stream.readString(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeRaw(new_nonce_hash2); + stream.writeInt32(code); + stream.writeString(text); } } - public static class TL_dh_gen_fail extends Set_client_DH_params_answer { - public static int constructor = 0xa69dae02; + public static class TL_messageService extends Message { + public static int constructor = 0x1d86f70e; - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - new_nonce_hash3 = stream.readData(16); + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + date = stream.readInt32(exception); + action = MessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeRaw(new_nonce_hash3); - } - } - - public static class TL_dh_gen_ok extends Set_client_DH_params_answer { - public static int constructor = 0x3bcbf734; - - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - new_nonce_hash1 = stream.readData(16); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeRaw(new_nonce_hash1); - } - } - - public static class PeerNotifyEvents extends TLObject { - } - - public static class TL_peerNotifyEventsEmpty extends PeerNotifyEvents { - public static int constructor = 0xadd53cb3; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_peerNotifyEventsAll extends PeerNotifyEvents { - public static int constructor = 0x6d1ded88; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_chatLocated extends TLObject { - public static int constructor = 0x3631cf4c; - - public int chat_id; - public int distance; - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - distance = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(distance); - } - } - - public static class DecryptedMessage extends TLObject { - public long random_id; - public byte[] random_bytes; - public DecryptedMessageAction action; - public int ttl; - public String message; - public DecryptedMessageMedia media; - } - - public static class TL_decryptedMessageService extends DecryptedMessage { - public static int constructor = 0x73164160; - - - public void readParams(AbsSerializedData stream) { - random_id = stream.readInt64(); - action = (DecryptedMessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(random_id); + stream.writeInt32(flags); + stream.writeInt32(id); + stream.writeInt32(from_id); + to_id.serializeToStream(stream); + stream.writeInt32(date); action.serializeToStream(stream); } } - public static class TL_decryptedMessage extends DecryptedMessage { - public static int constructor = 0x204d3878; + public static class TL_messageEmpty extends Message { + public static int constructor = 0x83e5de54; - public void readParams(AbsSerializedData stream) { - random_id = stream.readInt64(); - ttl = stream.readInt32(); - message = stream.readString(); - media = (DecryptedMessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(random_id); - stream.writeInt32(ttl); - stream.writeString(message); - media.serializeToStream(stream); + stream.writeInt32(id); } } - public static class InputPeerNotifyEvents extends TLObject { - } - - public static class TL_inputPeerNotifyEventsAll extends InputPeerNotifyEvents { - public static int constructor = 0xe86a2c74; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputPeerNotifyEventsEmpty extends InputPeerNotifyEvents { - public static int constructor = 0xf03064d8; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_client_DH_inner_data extends TLObject { - public static int constructor = 0x6643b654; - - public byte[] nonce; - public byte[] server_nonce; - public long retry_id; - public byte[] g_b; - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - retry_id = stream.readInt64(); - g_b = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeInt64(retry_id); - stream.writeByteArray(g_b); - } - } - - public static class TL_video extends Video { - public static int constructor = 0x388fa391; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - user_id = stream.readInt32(); - date = stream.readInt32(); - caption = stream.readString(); - duration = stream.readInt32(); - mime_type = stream.readString(); - size = stream.readInt32(); - thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - dc_id = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(user_id); - stream.writeInt32(date); - stream.writeString(caption); - stream.writeInt32(duration); - stream.writeString(mime_type); - stream.writeInt32(size); - thumb.serializeToStream(stream); - stream.writeInt32(dc_id); - stream.writeInt32(w); - stream.writeInt32(h); - } - } - - public static class TL_videoEmpty extends Video { - public static int constructor = 0xc10658a8; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - } - } - - public static class TL_contactBlocked extends TLObject { - public static int constructor = 0x561bc879; + public static class TL_contactStatus extends TLObject { + public static int constructor = 0xd3680c61; public int user_id; - public int date; + public UserStatus status; - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - date = stream.readInt32(); + public static TL_contactStatus TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contactStatus.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contactStatus", constructor)); + } else { + return null; + } + } + TL_contactStatus result = new TL_contactStatus(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt32(user_id); - stream.writeInt32(date); + status.serializeToStream(stream); } } public static class InputDocument extends TLObject { public long id; public long access_hash; + + public static InputDocument TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputDocument result = null; + switch(constructor) { + case 0x72f0eaae: + result = new TL_inputDocumentEmpty(); + break; + case 0x18798952: + result = new TL_inputDocument(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputDocument", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_inputDocumentEmpty extends InputDocument { @@ -3053,9 +587,9 @@ public class TLRPC { public static int constructor = 0x18798952; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -3065,93 +599,239 @@ public class TLRPC { } } - public static class TL_inputAppEvent extends TLObject { - public static int constructor = 0x770656a8; + public static class TL_auth_authorization extends TLObject { + public static int constructor = 0xf6b673a4; - public double time; - public String type; - public long peer; - public String data; + public int expires; + public User user; - public void readParams(AbsSerializedData stream) { - time = stream.readDouble(); - type = stream.readString(); - peer = stream.readInt64(); - data = stream.readString(); + public static TL_auth_authorization TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_auth_authorization.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_auth_authorization", constructor)); + } else { + return null; + } + } + TL_auth_authorization result = new TL_auth_authorization(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + expires = stream.readInt32(exception); + user = User.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeDouble(time); - stream.writeString(type); - stream.writeInt64(peer); - stream.writeString(data); + stream.writeInt32(expires); + user.serializeToStream(stream); } } - public static class TL_messages_affectedHistory extends TLObject { - public static int constructor = 0xb45c69d1; + public static class Set_client_DH_params_answer extends TLObject { + public byte[] nonce; + public byte[] server_nonce; + public byte[] new_nonce_hash2; + public byte[] new_nonce_hash3; + public byte[] new_nonce_hash1; - public int pts; - public int pts_count; - public int offset; + public static Set_client_DH_params_answer TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Set_client_DH_params_answer result = null; + switch(constructor) { + case 0x46dc1fb9: + result = new TL_dh_gen_retry(); + break; + case 0xa69dae02: + result = new TL_dh_gen_fail(); + break; + case 0x3bcbf734: + result = new TL_dh_gen_ok(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Set_client_DH_params_answer", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } - public void readParams(AbsSerializedData stream) { - pts = stream.readInt32(); - pts_count = stream.readInt32(); - offset = stream.readInt32(); + public static class TL_dh_gen_retry extends Set_client_DH_params_answer { + public static int constructor = 0x46dc1fb9; + + + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + new_nonce_hash2 = stream.readData(16, exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(pts); - stream.writeInt32(pts_count); - stream.writeInt32(offset); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeRaw(new_nonce_hash2); } } - public static class TL_documentEmpty extends Document { - public static int constructor = 0x36f8c871; + public static class TL_dh_gen_fail extends Set_client_DH_params_answer { + public static int constructor = 0xa69dae02; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + new_nonce_hash3 = stream.readData(16, exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(id); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeRaw(new_nonce_hash3); } } - public static class TL_document extends Document { - public static int constructor = 0xf9a39f4f; + public static class TL_dh_gen_ok extends Set_client_DH_params_answer { + public static int constructor = 0x3bcbf734; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - date = stream.readInt32(); - mime_type = stream.readString(); - size = stream.readInt32(); - thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - dc_id = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + new_nonce_hash1 = stream.readData(16, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeRaw(new_nonce_hash1); + } + } + + public static class InputMedia extends TLObject { + public String phone_number; + public String first_name; + public String last_name; + public InputFile file; + public InputFile thumb; + public String mime_type; + public ArrayList attributes = new ArrayList<>(); + public String caption; + public InputGeoPoint geo_point; + public int duration; + public int w; + public int h; + public String title; + public String address; + public String provider; + public String venue_id; + + public static InputMedia TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputMedia result = null; + switch(constructor) { + case 0xa6e45987: + result = new TL_inputMediaContact(); + break; + case 0x41481486: + result = new TL_inputMediaUploadedThumbDocument(); + break; + case 0x89938781: + result = new TL_inputMediaAudio(); + break; + case 0xd184e841: + result = new TL_inputMediaDocument(); + break; + case 0x936a4ebd: + result = new TL_inputMediaVideo(); + break; + case 0xf9c44144: + result = new TL_inputMediaGeoPoint(); + break; + case 0x9664f57f: + result = new TL_inputMediaEmpty(); + break; + case 0x96fb97dc: + result = new TL_inputMediaUploadedThumbVideo(); + break; + case 0xf7aff1c0: + result = new TL_inputMediaUploadedPhoto(); + break; + case 0x2827a81a: + result = new TL_inputMediaVenue(); + break; + case 0x4e498cab: + result = new TL_inputMediaUploadedAudio(); + break; + case 0xe13fd4bc: + result = new TL_inputMediaUploadedVideo(); + break; + case 0xffe76b78: + result = new TL_inputMediaUploadedDocument(); + break; + case 0xe9bfb4f3: + result = new TL_inputMediaPhoto(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputMedia", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputMediaContact extends InputMedia { + public static int constructor = 0xa6e45987; + + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_number = stream.readString(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData 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 = 0x41481486; + + + public void readParams(AbsSerializedData stream, boolean exception) { + file = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + thumb = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + mime_type = stream.readString(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - attributes.add((DocumentAttribute)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + attributes.add(DocumentAttribute.TLdeserialize(stream, stream.readInt32(exception), exception)); } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(date); - stream.writeString(mime_type); - stream.writeInt32(size); + file.serializeToStream(stream); thumb.serializeToStream(stream); - stream.writeInt32(dc_id); + stream.writeString(mime_type); stream.writeInt32(0x1cb5c415); int count = attributes.size(); stream.writeInt32(count); @@ -3161,11 +841,69 @@ public class TLRPC { } } - public static class ContactLink extends TLObject { + public static class TL_inputMediaAudio extends InputMedia { + public static int constructor = 0x89938781; + + public InputAudio id; + + public void readParams(AbsSerializedData stream, boolean exception) { + id = InputAudio.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + id.serializeToStream(stream); + } } - public static class TL_contactLinkNone extends ContactLink { - public static int constructor = 0xfeedd3ad; + public static class TL_inputMediaDocument extends InputMedia { + public static int constructor = 0xd184e841; + + public InputDocument id; + + public void readParams(AbsSerializedData stream, boolean exception) { + id = InputDocument.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + id.serializeToStream(stream); + } + } + + public static class TL_inputMediaVideo extends InputMedia { + public static int constructor = 0x936a4ebd; + + public InputVideo id; + + public void readParams(AbsSerializedData stream, boolean exception) { + id = InputVideo.TLdeserialize(stream, stream.readInt32(exception), exception); + caption = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + id.serializeToStream(stream); + stream.writeString(caption); + } + } + + public static class TL_inputMediaGeoPoint extends InputMedia { + public static int constructor = 0xf9c44144; + + + public void readParams(AbsSerializedData stream, boolean exception) { + geo_point = InputGeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + geo_point.serializeToStream(stream); + } + } + + public static class TL_inputMediaEmpty extends InputMedia { + public static int constructor = 0x9664f57f; public void serializeToStream(AbsSerializedData stream) { @@ -3173,46 +911,507 @@ public class TLRPC { } } - public static class TL_contactLinkContact extends ContactLink { - public static int constructor = 0xd502c2d0; + public static class TL_inputMediaUploadedThumbVideo extends InputMedia { + public static int constructor = 0x96fb97dc; + public void readParams(AbsSerializedData stream, boolean exception) { + file = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + thumb = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + duration = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + caption = stream.readString(exception); + } + public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); + file.serializeToStream(stream); + thumb.serializeToStream(stream); + stream.writeInt32(duration); + stream.writeInt32(w); + stream.writeInt32(h); + stream.writeString(caption); } } - public static class TL_contactLinkHasPhone extends ContactLink { - public static int constructor = 0x268f3f59; + public static class TL_inputMediaUploadedPhoto extends InputMedia { + public static int constructor = 0xf7aff1c0; + public void readParams(AbsSerializedData stream, boolean exception) { + file = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + caption = stream.readString(exception); + } + public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); + file.serializeToStream(stream); + stream.writeString(caption); } } - public static class TL_contactLinkUnknown extends ContactLink { - public static int constructor = 0x5f4f9247; + public static class TL_inputMediaVenue extends InputMedia { + public static int constructor = 0x2827a81a; + public void readParams(AbsSerializedData stream, boolean exception) { + geo_point = InputGeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + title = stream.readString(exception); + address = stream.readString(exception); + provider = stream.readString(exception); + venue_id = stream.readString(exception); + } + public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); + geo_point.serializeToStream(stream); + stream.writeString(title); + stream.writeString(address); + stream.writeString(provider); + stream.writeString(venue_id); + } + } + + public static class TL_inputMediaUploadedAudio extends InputMedia { + public static int constructor = 0x4e498cab; + + + public void readParams(AbsSerializedData stream, boolean exception) { + file = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + duration = stream.readInt32(exception); + mime_type = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + file.serializeToStream(stream); + stream.writeInt32(duration); + stream.writeString(mime_type); + } + } + + public static class TL_inputMediaUploadedVideo extends InputMedia { + public static int constructor = 0xe13fd4bc; + + + public void readParams(AbsSerializedData stream, boolean exception) { + file = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + duration = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + caption = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + file.serializeToStream(stream); + stream.writeInt32(duration); + stream.writeInt32(w); + stream.writeInt32(h); + stream.writeString(caption); + } + } + + public static class TL_inputMediaUploadedDocument extends InputMedia { + public static int constructor = 0xffe76b78; + + + public void readParams(AbsSerializedData stream, boolean exception) { + file = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + mime_type = stream.readString(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + attributes.add(DocumentAttribute.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + file.serializeToStream(stream); + stream.writeString(mime_type); + stream.writeInt32(0x1cb5c415); + int count = attributes.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + attributes.get(a).serializeToStream(stream); + } + } + } + + public static class TL_inputMediaPhoto extends InputMedia { + public static int constructor = 0xe9bfb4f3; + + public InputPhoto id; + + public void readParams(AbsSerializedData stream, boolean exception) { + id = InputPhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + caption = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + id.serializeToStream(stream); + stream.writeString(caption); + } + } + + public static class TL_geochats_statedMessage extends TLObject { + public static int constructor = 0x17b1578b; + + public GeoChatMessage message; + public ArrayList chats = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + public int seq; + + public static TL_geochats_statedMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_geochats_statedMessage.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_geochats_statedMessage", constructor)); + } else { + return null; + } + } + TL_geochats_statedMessage result = new TL_geochats_statedMessage(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + message = GeoChatMessage.TLdeserialize(stream, stream.readInt32(exception), exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + seq = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData 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); + } + stream.writeInt32(seq); + } + } + + public static class messages_Dialogs extends TLObject { + public ArrayList dialogs = new ArrayList<>(); + public ArrayList messages = new ArrayList<>(); + public ArrayList chats = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + public int count; + + public static messages_Dialogs TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + messages_Dialogs result = null; + switch(constructor) { + case 0x15ba6c40: + result = new TL_messages_dialogs(); + break; + case 0x71e094f3: + result = new TL_messages_dialogsSlice(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in messages_Dialogs", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messages_dialogs extends messages_Dialogs { + public static int constructor = 0x15ba6c40; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + dialogs.add(TL_dialog.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + messages.add(Message.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = dialogs.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + dialogs.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + messages.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); + } + } + } + + public static class TL_messages_dialogsSlice extends messages_Dialogs { + public static int constructor = 0x71e094f3; + + + public void readParams(AbsSerializedData stream, boolean exception) { + count = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + dialogs.add(TL_dialog.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + messages.add(Message.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(count); + stream.writeInt32(0x1cb5c415); + int count = dialogs.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + dialogs.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + messages.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); + } + } + } + + public static class TL_server_DH_inner_data extends TLObject { + public static int constructor = 0xb5890dba; + + public byte[] nonce; + public byte[] server_nonce; + public int g; + public byte[] dh_prime; + public byte[] g_a; + public int server_time; + + public static TL_server_DH_inner_data TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_server_DH_inner_data.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_server_DH_inner_data", constructor)); + } else { + return null; + } + } + TL_server_DH_inner_data result = new TL_server_DH_inner_data(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + g = stream.readInt32(exception); + dh_prime = stream.readByteArray(exception); + g_a = stream.readByteArray(exception); + server_time = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeInt32(g); + stream.writeByteArray(dh_prime); + stream.writeByteArray(g_a); + stream.writeInt32(server_time); } } public static class InputPrivacyRule extends TLObject { public ArrayList users = new ArrayList<>(); + + public static InputPrivacyRule TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputPrivacyRule result = null; + switch(constructor) { + case 0x90110467: + result = new TL_inputPrivacyValueDisallowUsers(); + break; + case 0xd66b66c9: + result = new TL_inputPrivacyValueDisallowAll(); + break; + case 0xba52007: + result = new TL_inputPrivacyValueDisallowContacts(); + break; + case 0x184b35ce: + result = new TL_inputPrivacyValueAllowAll(); + break; + case 0xd09e07b: + result = new TL_inputPrivacyValueAllowContacts(); + break; + case 0x131cc67f: + result = new TL_inputPrivacyValueAllowUsers(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputPrivacyRule", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_inputPrivacyValueDisallowUsers extends InputPrivacyRule { public static int constructor = 0x90110467; - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - users.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + users.add(InputUser.TLdeserialize(stream, stream.readInt32(exception), exception)); } } @@ -3221,8 +1420,8 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = users.size(); stream.writeInt32(count); - for (InputUser user : users) { - user.serializeToStream(stream); + for (int a = 0; a < count; a++) { + users.get(a).serializeToStream(stream); } } } @@ -3267,11 +1466,17 @@ public class TLRPC { public static int constructor = 0x131cc67f; - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - users.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + users.add(InputUser.TLdeserialize(stream, stream.readInt32(exception), exception)); } } @@ -3280,34 +1485,954 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = users.size(); stream.writeInt32(count); - for (InputUser user : users) { - user.serializeToStream(stream); + for (int a = 0; a < count; a++) { + users.get(a).serializeToStream(stream); } } } - public static class InputMedia extends TLObject { - public String phone_number; - public String first_name; - public String last_name; - public InputFile file; - public InputFile thumb; - public String mime_type; - public ArrayList attributes = new ArrayList<>(); - public InputGeoPoint geo_point; - public int duration; - public int w; - public int h; + public static class TL_contacts_link extends TLObject { + public static int constructor = 0x3ace484c; + + public ContactLink my_link; + public ContactLink foreign_link; + public User user; + + public static TL_contacts_link TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contacts_link.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contacts_link", constructor)); + } else { + return null; + } + } + TL_contacts_link result = new TL_contacts_link(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + my_link = ContactLink.TLdeserialize(stream, stream.readInt32(exception), exception); + foreign_link = ContactLink.TLdeserialize(stream, stream.readInt32(exception), exception); + user = User.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + my_link.serializeToStream(stream); + foreign_link.serializeToStream(stream); + user.serializeToStream(stream); + } } - public static class TL_inputMediaContact extends InputMedia { - public static int constructor = 0xa6e45987; + public static class photos_Photos extends TLObject { + public ArrayList photos = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + public int count; + + public static photos_Photos TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + photos_Photos result = null; + switch(constructor) { + case 0x8dca6aa5: + result = new TL_photos_photos(); + break; + case 0x15051f54: + result = new TL_photos_photosSlice(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in photos_Photos", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_photos_photos extends photos_Photos { + public static int constructor = 0x8dca6aa5; - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - first_name = stream.readString(); - last_name = stream.readString(); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + photos.add(Photo.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = photos.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + photos.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_photos_photosSlice extends photos_Photos { + public static int constructor = 0x15051f54; + + + public void readParams(AbsSerializedData stream, boolean exception) { + count = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + photos.add(Photo.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(count); + stream.writeInt32(0x1cb5c415); + int count = photos.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + photos.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_msgs_ack extends TLObject { + public static int constructor = 0x62d6b459; + + public ArrayList msg_ids = new ArrayList<>(); + + public static TL_msgs_ack TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_msgs_ack.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_msgs_ack", constructor)); + } else { + return null; + } + } + TL_msgs_ack result = new TL_msgs_ack(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + msg_ids.add(stream.readInt64(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = msg_ids.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(msg_ids.get(a)); + } + } + } + + public static class TL_userStatusLastWeek extends UserStatus { + public static int constructor = 0x7bf09fc; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_userStatusEmpty extends UserStatus { + public static int constructor = 0x9d05049; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_userStatusLastMonth extends UserStatus { + public static int constructor = 0x77ebc742; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_userStatusOnline extends UserStatus { + public static int constructor = 0xedb93949; + + + public void readParams(AbsSerializedData stream, boolean exception) { + expires = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(expires); + } + } + + public static class TL_userStatusRecently extends UserStatus { + public static int constructor = 0xe26f42f1; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_userFull extends TLObject { + public static int constructor = 0x771095da; + + public User user; + public TL_contacts_link link; + public Photo profile_photo; + public PeerNotifySettings notify_settings; + public boolean blocked; + public String real_first_name; + public String real_last_name; + + public static TL_userFull TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_userFull.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_userFull", constructor)); + } else { + return null; + } + } + TL_userFull result = new TL_userFull(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user = User.TLdeserialize(stream, stream.readInt32(exception), exception); + link = TL_contacts_link.TLdeserialize(stream, stream.readInt32(exception), exception); + profile_photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); + notify_settings = PeerNotifySettings.TLdeserialize(stream, stream.readInt32(exception), exception); + blocked = stream.readBool(exception); + real_first_name = stream.readString(exception); + real_last_name = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + user.serializeToStream(stream); + link.serializeToStream(stream); + profile_photo.serializeToStream(stream); + notify_settings.serializeToStream(stream); + stream.writeBool(blocked); + stream.writeString(real_first_name); + stream.writeString(real_last_name); + } + } + + public static class TL_msg_resend_req extends TLObject { + public static int constructor = 0x7d861a08; + + public ArrayList msg_ids = new ArrayList<>(); + + public static TL_msg_resend_req TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_msg_resend_req.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_msg_resend_req", constructor)); + } else { + return null; + } + } + TL_msg_resend_req result = new TL_msg_resend_req(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + msg_ids.add(stream.readInt64(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = msg_ids.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(msg_ids.get(a)); + } + } + } + + public static class TL_contact extends TLObject { + public static int constructor = 0xf911c994; + + public int user_id; + public boolean mutual; + + public static TL_contact TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contact.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contact", constructor)); + } else { + return null; + } + } + TL_contact result = new TL_contact(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + mutual = stream.readBool(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeBool(mutual); + } + } + + public static class TL_chatLocated extends TLObject { + public static int constructor = 0x3631cf4c; + + public int chat_id; + public int distance; + + public static TL_chatLocated TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_chatLocated.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_chatLocated", constructor)); + } else { + return null; + } + } + TL_chatLocated result = new TL_chatLocated(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + distance = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(distance); + } + } + + public static class RpcError extends TLObject { + public int error_code; + public String error_message; + public long query_id; + + public static RpcError TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + RpcError result = null; + switch(constructor) { + case 0x2144ca19: + result = new TL_rpc_error(); + break; + case 0x7ae432f5: + result = new TL_rpc_req_error(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in RpcError", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_rpc_error extends RpcError { + public static int constructor = 0x2144ca19; + + + public void readParams(AbsSerializedData stream, boolean exception) { + error_code = stream.readInt32(exception); + error_message = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(error_code); + stream.writeString(error_message); + } + } + + public static class TL_rpc_req_error extends RpcError { + public static int constructor = 0x7ae432f5; + + + public void readParams(AbsSerializedData stream, boolean exception) { + query_id = stream.readInt64(exception); + error_code = stream.readInt32(exception); + error_message = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(query_id); + stream.writeInt32(error_code); + stream.writeString(error_message); + } + } + + public static class TL_privacyKeyStatusTimestamp extends TLObject { + public static int constructor = 0xbc2eab30; + + + public static TL_privacyKeyStatusTimestamp TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_privacyKeyStatusTimestamp.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_privacyKeyStatusTimestamp", constructor)); + } else { + return null; + } + } + TL_privacyKeyStatusTimestamp result = new TL_privacyKeyStatusTimestamp(); + result.readParams(stream, exception); + return result; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class ChatParticipants extends TLObject { + public int chat_id; + public int admin_id; + public ArrayList participants = new ArrayList<>(); + public int version; + + public static ChatParticipants TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + ChatParticipants result = null; + switch(constructor) { + case 0x7841b415: + result = new TL_chatParticipants(); + break; + case 0xfd2bb8a: + result = new TL_chatParticipantsForbidden(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in ChatParticipants", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_chatParticipants extends ChatParticipants { + public static int constructor = 0x7841b415; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + admin_id = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + participants.add(TL_chatParticipant.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + version = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(admin_id); + stream.writeInt32(0x1cb5c415); + int count = participants.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + participants.get(a).serializeToStream(stream); + } + stream.writeInt32(version); + } + } + + public static class TL_chatParticipantsForbidden extends ChatParticipants { + public static int constructor = 0xfd2bb8a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + } + } + + public static class TL_auth_passwordRecovery extends TLObject { + public static int constructor = 0x137948a5; + + public String email_pattern; + + public static TL_auth_passwordRecovery TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_auth_passwordRecovery.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_auth_passwordRecovery", constructor)); + } else { + return null; + } + } + TL_auth_passwordRecovery result = new TL_auth_passwordRecovery(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + email_pattern = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(email_pattern); + } + } + + public static class TL_decryptedMessageService extends DecryptedMessage { + public static int constructor = 0x73164160; + + + public void readParams(AbsSerializedData stream, boolean exception) { + random_id = stream.readInt64(exception); + action = DecryptedMessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(random_id); + action.serializeToStream(stream); + } + } + + public static class TL_decryptedMessage extends DecryptedMessage { + public static int constructor = 0x204d3878; + + + public void readParams(AbsSerializedData stream, boolean exception) { + random_id = stream.readInt64(exception); + ttl = stream.readInt32(exception); + message = stream.readString(exception); + media = DecryptedMessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(random_id); + stream.writeInt32(ttl); + stream.writeString(message); + media.serializeToStream(stream); + } + } + + public static class messages_Messages extends TLObject { + public ArrayList messages = new ArrayList<>(); + public ArrayList chats = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + public int count; + + public static messages_Messages TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + messages_Messages result = null; + switch(constructor) { + case 0x8c718e87: + result = new TL_messages_messages(); + break; + case 0xb446ae3: + result = new TL_messages_messagesSlice(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in messages_Messages", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messages_messages extends messages_Messages { + public static int constructor = 0x8c718e87; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + messages.add(Message.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + messages.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); + } + } + } + + public static class TL_messages_messagesSlice extends messages_Messages { + public static int constructor = 0xb446ae3; + + + public void readParams(AbsSerializedData stream, boolean exception) { + count = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + messages.add(Message.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(count); + stream.writeInt32(0x1cb5c415); + int count = messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + messages.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); + } + } + } + + public static class BadMsgNotification extends TLObject { + public long bad_msg_id; + public int bad_msg_seqno; + public int error_code; + public long new_server_salt; + + public static BadMsgNotification TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + BadMsgNotification result = null; + switch(constructor) { + case 0xa7eff811: + result = new TL_bad_msg_notification(); + break; + case 0xedab447b: + result = new TL_bad_server_salt(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in BadMsgNotification", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_bad_msg_notification extends BadMsgNotification { + public static int constructor = 0xa7eff811; + + + public void readParams(AbsSerializedData stream, boolean exception) { + bad_msg_id = stream.readInt64(exception); + bad_msg_seqno = stream.readInt32(exception); + error_code = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(bad_msg_id); + stream.writeInt32(bad_msg_seqno); + stream.writeInt32(error_code); + } + } + + public static class TL_bad_server_salt extends BadMsgNotification { + public static int constructor = 0xedab447b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + bad_msg_id = stream.readInt64(exception); + bad_msg_seqno = stream.readInt32(exception); + error_code = stream.readInt32(exception); + new_server_salt = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(bad_msg_id); + stream.writeInt32(bad_msg_seqno); + stream.writeInt32(error_code); + stream.writeInt64(new_server_salt); + } + } + + public static class TL_decryptedMessageMediaDocument extends DecryptedMessageMedia { + public static int constructor = 0xb095434b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + thumb = stream.readByteArray(exception); + thumb_w = stream.readInt32(exception); + thumb_h = stream.readInt32(exception); + file_name = stream.readString(exception); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + 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(AbsSerializedData stream, boolean exception) { + lat = stream.readDouble(exception); + _long = stream.readDouble(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeDouble(lat); + stream.writeDouble(_long); + } + } + + public static class TL_decryptedMessageMediaAudio extends DecryptedMessageMedia { + public static int constructor = 0x57e0a9cb; + + + public void readParams(AbsSerializedData stream, boolean exception) { + duration = stream.readInt32(exception); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(duration); + stream.writeString(mime_type); + stream.writeInt32(size); + stream.writeByteArray(key); + stream.writeByteArray(iv); + } + } + + public static class TL_decryptedMessageMediaVideo extends DecryptedMessageMedia { + public static int constructor = 0x524a415d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + thumb = stream.readByteArray(exception); + thumb_w = stream.readInt32(exception); + thumb_h = stream.readInt32(exception); + duration = stream.readInt32(exception); + mime_type = stream.readString(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + size = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeByteArray(thumb); + stream.writeInt32(thumb_w); + stream.writeInt32(thumb_h); + stream.writeInt32(duration); + stream.writeString(mime_type); + stream.writeInt32(w); + stream.writeInt32(h); + stream.writeInt32(size); + stream.writeByteArray(key); + stream.writeByteArray(iv); + } + } + + public static class TL_decryptedMessageMediaContact extends DecryptedMessageMedia { + public static int constructor = 0x588a0a97; + + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_number = stream.readString(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + user_id = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -3315,99 +2440,12 @@ public class TLRPC { stream.writeString(phone_number); stream.writeString(first_name); stream.writeString(last_name); + stream.writeInt32(user_id); } } - public static class TL_inputMediaUploadedThumbDocument extends InputMedia { - public static int constructor = 0x41481486; - - - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - thumb = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - mime_type = stream.readString(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - attributes.add((DocumentAttribute)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - file.serializeToStream(stream); - thumb.serializeToStream(stream); - stream.writeString(mime_type); - stream.writeInt32(0x1cb5c415); - int count = attributes.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - attributes.get(a).serializeToStream(stream); - } - } - } - - public static class TL_inputMediaAudio extends InputMedia { - public static int constructor = 0x89938781; - - public InputAudio id; - - public void readParams(AbsSerializedData stream) { - id = (InputAudio)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - id = (InputDocument)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - id.serializeToStream(stream); - } - } - - public static class TL_inputMediaVideo extends InputMedia { - public static int constructor = 0x7f023ae6; - - public InputVideo id; - - public void readParams(AbsSerializedData stream) { - id = (InputVideo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - id.serializeToStream(stream); - } - } - - public static class TL_inputMediaGeoPoint extends InputMedia { - public static int constructor = 0xf9c44144; - - - public void readParams(AbsSerializedData stream) { - geo_point = (InputGeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - geo_point.serializeToStream(stream); - } - } - - public static class TL_inputMediaEmpty extends InputMedia { - public static int constructor = 0x9664f57f; + public static class TL_decryptedMessageMediaEmpty extends DecryptedMessageMedia { + public static int constructor = 0x89f5c4a; public void serializeToStream(AbsSerializedData stream) { @@ -3415,123 +2453,5226 @@ public class TLRPC { } } - public static class TL_inputMediaUploadedThumbVideo extends InputMedia { - public static int constructor = 0x9912dabf; + public static class TL_decryptedMessageMediaPhoto extends DecryptedMessageMedia { + public static int constructor = 0x32798a8c; - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - thumb = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - duration = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - mime_type = stream.readString(); + public void readParams(AbsSerializedData stream, boolean exception) { + thumb = stream.readByteArray(exception); + thumb_w = stream.readInt32(exception); + thumb_h = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + size = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - file.serializeToStream(stream); - thumb.serializeToStream(stream); - stream.writeInt32(duration); + stream.writeByteArray(thumb); + stream.writeInt32(thumb_w); + stream.writeInt32(thumb_h); stream.writeInt32(w); stream.writeInt32(h); - stream.writeString(mime_type); + stream.writeInt32(size); + stream.writeByteArray(key); + stream.writeByteArray(iv); } } - public static class TL_inputMediaUploadedPhoto extends InputMedia { - public static int constructor = 0x2dc53a7d; + public static class TL_userContact extends User { + public static int constructor = 0xcab35e18; - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + username = stream.readString(exception); + access_hash = stream.readInt64(exception); + phone = stream.readString(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - file.serializeToStream(stream); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(username); + stream.writeInt64(access_hash); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); } } - public static class TL_inputMediaUploadedAudio extends InputMedia { - public static int constructor = 0x4e498cab; + public static class TL_userRequest extends User { + public static int constructor = 0xd9ccc4ef; - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - duration = stream.readInt32(); - mime_type = stream.readString(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + username = stream.readString(exception); + access_hash = stream.readInt64(exception); + phone = stream.readString(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - file.serializeToStream(stream); - stream.writeInt32(duration); - stream.writeString(mime_type); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(username); + stream.writeInt64(access_hash); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); } } - public static class TL_inputMediaUploadedVideo extends InputMedia { - public static int constructor = 0x133ad6f6; + public static class TL_userForeign extends User { + public static int constructor = 0x75cf7a8; - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - duration = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - mime_type = stream.readString(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + username = stream.readString(exception); + access_hash = stream.readInt64(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - file.serializeToStream(stream); - stream.writeInt32(duration); - stream.writeInt32(w); - stream.writeInt32(h); - stream.writeString(mime_type); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(username); + stream.writeInt64(access_hash); + photo.serializeToStream(stream); + status.serializeToStream(stream); } } - public static class TL_inputMediaUploadedDocument extends InputMedia { - public static int constructor = 0xffe76b78; + public static class TL_userDeleted extends User { + public static int constructor = 0xd6016d7a; - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - mime_type = stream.readString(); - stream.readInt32(); - int count = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + username = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(username); + } + } + + public static class TL_userSelf extends User { + public static int constructor = 0x1c60e608; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + username = stream.readString(exception); + phone = stream.readString(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(username); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); + } + } + + public static class TL_messageMediaVideo extends MessageMedia { + public static int constructor = 0x5bcf1675; + + + public void readParams(AbsSerializedData stream, boolean exception) { + video = Video.TLdeserialize(stream, stream.readInt32(exception), exception); + caption = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + video.serializeToStream(stream); + stream.writeString(caption); + } + } + + public static class TL_messageMediaPhoto extends MessageMedia { + public static int constructor = 0x3d8ce53d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); + caption = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + photo.serializeToStream(stream); + stream.writeString(caption); + } + } + + public static class TL_messageMediaWebPage extends MessageMedia { + public static int constructor = 0xa32dd600; + + + public void readParams(AbsSerializedData stream, boolean exception) { + webpage = WebPage.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + webpage.serializeToStream(stream); + } + } + + public static class TL_messageMediaDocument extends MessageMedia { + public static int constructor = 0x2fda2204; + + + public void readParams(AbsSerializedData stream, boolean exception) { + document = Document.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + document.serializeToStream(stream); + } + } + + public static class TL_messageMediaGeo extends MessageMedia { + public static int constructor = 0x56e0d474; + + + public void readParams(AbsSerializedData stream, boolean exception) { + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + geo.serializeToStream(stream); + } + } + + public static class TL_messageMediaEmpty extends MessageMedia { + public static int constructor = 0x3ded6320; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messageMediaAudio extends MessageMedia { + public static int constructor = 0xc6b68300; + + + public void readParams(AbsSerializedData stream, boolean exception) { + audio = Audio.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + audio.serializeToStream(stream); + } + } + + public static class TL_messageMediaVenue extends MessageMedia { + public static int constructor = 0x7912b71f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + title = stream.readString(exception); + address = stream.readString(exception); + provider = stream.readString(exception); + venue_id = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + geo.serializeToStream(stream); + stream.writeString(title); + stream.writeString(address); + stream.writeString(provider); + stream.writeString(venue_id); + } + } + + public static class TL_messageMediaContact extends MessageMedia { + public static int constructor = 0x5e7d2f39; + + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_number = stream.readString(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + user_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_number); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt32(user_id); + } + } + + public static class TL_messageMediaUnsupported extends MessageMedia { + public static int constructor = 0x9f84f49e; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_nearestDc extends TLObject { + public static int constructor = 0x8e1a1775; + + public String country; + public int this_dc; + public int nearest_dc; + + public static TL_nearestDc TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_nearestDc.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_nearestDc", constructor)); + } else { + return null; + } + } + TL_nearestDc result = new TL_nearestDc(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + country = stream.readString(exception); + this_dc = stream.readInt32(exception); + nearest_dc = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(country); + stream.writeInt32(this_dc); + stream.writeInt32(nearest_dc); + } + } + + public static class TL_contactFound extends TLObject { + public static int constructor = 0xea879f95; + + public int user_id; + + public static TL_contactFound TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contactFound.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contactFound", constructor)); + } else { + return null; + } + } + TL_contactFound result = new TL_contactFound(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + } + } + + public static class TL_new_session_created extends TLObject { + public static int constructor = 0x9ec20908; + + public long first_msg_id; + public long unique_id; + public long server_salt; + + public static TL_new_session_created TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_new_session_created.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_new_session_created", constructor)); + } else { + return null; + } + } + TL_new_session_created result = new TL_new_session_created(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + first_msg_id = stream.readInt64(exception); + unique_id = stream.readInt64(exception); + server_salt = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(first_msg_id); + stream.writeInt64(unique_id); + stream.writeInt64(server_salt); + } + } + + public static class TL_contacts_suggested extends TLObject { + public static int constructor = 0x5649dcc5; + + public ArrayList results = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + + public static TL_contacts_suggested TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contacts_suggested.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contacts_suggested", constructor)); + } else { + return null; + } + } + TL_contacts_suggested result = new TL_contacts_suggested(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - attributes.add((DocumentAttribute)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + results.add(TL_contactSuggested.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - file.serializeToStream(stream); - stream.writeString(mime_type); stream.writeInt32(0x1cb5c415); - int count = attributes.size(); + int count = results.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - attributes.get(a).serializeToStream(stream); + 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 TL_inputMediaPhoto extends InputMedia { - public static int constructor = 0x8f2ab2ec; + public static class WallPaper extends TLObject { + public int id; + public String title; + public ArrayList sizes = new ArrayList<>(); + public int color; + public int bg_color; + public static WallPaper TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + WallPaper result = null; + switch(constructor) { + case 0xccb03657: + result = new TL_wallPaper(); + break; + case 0x63117f24: + result = new TL_wallPaperSolid(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in WallPaper", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_wallPaper extends WallPaper { + public static int constructor = 0xccb03657; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + title = stream.readString(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + sizes.add(PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + color = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(title); + stream.writeInt32(0x1cb5c415); + int count = sizes.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + sizes.get(a).serializeToStream(stream); + } + stream.writeInt32(color); + } + } + + public static class TL_wallPaperSolid extends WallPaper { + public static int constructor = 0x63117f24; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + title = stream.readString(exception); + bg_color = stream.readInt32(exception); + color = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(title); + stream.writeInt32(bg_color); + stream.writeInt32(color); + } + } + + public static class NotifyPeer extends TLObject { + public Peer peer; + + public static NotifyPeer TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + NotifyPeer result = null; + switch(constructor) { + case 0x74d07c60: + result = new TL_notifyAll(); + break; + case 0xc007cec3: + result = new TL_notifyChats(); + break; + case 0xb4c83b4c: + result = new TL_notifyUsers(); + break; + case 0x9fd40bd8: + result = new TL_notifyPeer(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in NotifyPeer", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_notifyAll extends NotifyPeer { + public static int constructor = 0x74d07c60; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_notifyChats extends NotifyPeer { + public static int constructor = 0xc007cec3; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_notifyUsers extends NotifyPeer { + public static int constructor = 0xb4c83b4c; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_notifyPeer extends NotifyPeer { + public static int constructor = 0x9fd40bd8; + + + public void readParams(AbsSerializedData stream, boolean exception) { + peer = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + } + } + + public static class TL_inputPrivacyKeyStatusTimestamp extends TLObject { + public static int constructor = 0x4f96cb18; + + + public static TL_inputPrivacyKeyStatusTimestamp TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_inputPrivacyKeyStatusTimestamp.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inputPrivacyKeyStatusTimestamp", constructor)); + } else { + return null; + } + } + TL_inputPrivacyKeyStatusTimestamp result = new TL_inputPrivacyKeyStatusTimestamp(); + result.readParams(stream, exception); + return result; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_account_sentChangePhoneCode extends TLObject { + public static int constructor = 0xa4f58c4c; + + public String phone_code_hash; + public int send_call_timeout; + + public static TL_account_sentChangePhoneCode TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_account_sentChangePhoneCode.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_account_sentChangePhoneCode", constructor)); + } else { + return null; + } + } + TL_account_sentChangePhoneCode result = new TL_account_sentChangePhoneCode(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_code_hash = stream.readString(exception); + send_call_timeout = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_code_hash); + stream.writeInt32(send_call_timeout); + } + } + + public static class ChatInvite extends TLObject { + public String title; + public Chat chat; + + public static ChatInvite TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + ChatInvite result = null; + switch(constructor) { + case 0xce917dcd: + result = new TL_chatInvite(); + break; + case 0x5a686d7c: + result = new TL_chatInviteAlready(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in ChatInvite", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_chatInvite extends ChatInvite { + public static int constructor = 0xce917dcd; + + + public void readParams(AbsSerializedData stream, boolean exception) { + title = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(title); + } + } + + public static class TL_chatInviteAlready extends ChatInvite { + public static int constructor = 0x5a686d7c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat = Chat.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + chat.serializeToStream(stream); + } + } + + public static class TL_photos_photo extends TLObject { + public static int constructor = 0x20212ca8; + + public Photo photo; + public ArrayList users = new ArrayList<>(); + + public static TL_photos_photo TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_photos_photo.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_photos_photo", constructor)); + } else { + return null; + } + } + TL_photos_photo result = new TL_photos_photo(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + photo.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = users.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + users.get(a).serializeToStream(stream); + } + } + } + + public static class TL_resPQ extends TLObject { + public static int constructor = 0x05162463; + + public byte[] nonce; + public byte[] server_nonce; + public byte[] pq; + public ArrayList server_public_key_fingerprints = new ArrayList<>(); + + public static TL_resPQ TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_resPQ.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_resPQ", constructor)); + } else { + return null; + } + } + TL_resPQ result = new TL_resPQ(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + pq = stream.readByteArray(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + server_public_key_fingerprints.add(stream.readInt64(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeByteArray(pq); + stream.writeInt32(0x1cb5c415); + int count = server_public_key_fingerprints.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(server_public_key_fingerprints.get(a)); + } + } + } + + public static class messages_SentEncryptedMessage extends TLObject { + public int date; + public EncryptedFile file; + + public static messages_SentEncryptedMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + messages_SentEncryptedMessage result = null; + switch(constructor) { + case 0x560f8935: + result = new TL_messages_sentEncryptedMessage(); + break; + case 0x9493ff32: + result = new TL_messages_sentEncryptedFile(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in messages_SentEncryptedMessage", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messages_sentEncryptedMessage extends messages_SentEncryptedMessage { + public static int constructor = 0x560f8935; + + + public void readParams(AbsSerializedData stream, boolean exception) { + date = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(date); + } + } + + public static class TL_messages_sentEncryptedFile extends messages_SentEncryptedMessage { + public static int constructor = 0x9493ff32; + + + public void readParams(AbsSerializedData stream, boolean exception) { + date = stream.readInt32(exception); + file = EncryptedFile.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(date); + file.serializeToStream(stream); + } + } + + public static class Update extends TLObject { + public int chat_id; + public int max_date; + public int date; + public int user_id; + public ContactLink my_link; + public ContactLink foreign_link; + public int max_id; + public int pts; + public int pts_count; + public int version; + public WebPage webpage; + public String type; + public MessageMedia media; + public boolean popup; + public PeerNotifySettings notify_settings; + public SendMessageAction action; + public String first_name; + public String last_name; + public String username; + public int qts; + public int id; + public long random_id; + public ArrayList dc_options = new ArrayList<>(); + public ArrayList messages = new ArrayList<>(); + public ChatParticipants participants; + public TL_privacyKeyStatusTimestamp key; + public ArrayList rules = new ArrayList<>(); + public EncryptedChat chat; + public boolean blocked; + public String phone; + public long auth_key_id; + public String device; + public String location; + public UserProfilePhoto photo; + public boolean previous; + public int inviter_id; + public UserStatus status; + public NotifyPeer peer; + + public static Update TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Update result = null; + switch(constructor) { + case 0x38fe25b7: + result = new TL_updateEncryptedMessagesRead(); + break; + case 0x9d2e67c5: + result = new TL_updateContactLink(); + break; + case 0x9961fd5c: + result = new TL_updateReadHistoryInbox(); + break; + case 0x2f2f21bf: + result = new TL_updateReadHistoryOutbox(); + break; + case 0x6e5f8c22: + result = new TL_updateChatParticipantDelete(); + break; + case 0x2cc36971: + result = new TL_updateWebPage(); + break; + case 0x382dd3e4: + result = new TL_updateServiceNotification(); + break; + case 0xbec268ef: + result = new TL_updateNotifySettings(); + break; + case 0x5c486927: + result = new TL_updateUserTyping(); + break; + case 0x9a65ea1f: + result = new TL_updateChatUserTyping(); + break; + case 0xa7332b73: + result = new TL_updateUserName(); + break; + case 0x12bcbd9a: + result = new TL_updateNewEncryptedMessage(); + break; + case 0x1f2b0afd: + result = new TL_updateNewMessage(); + break; + case 0x4e90bfd6: + result = new TL_updateMessageID(); + break; + case 0x8e5e9873: + result = new TL_updateDcOptions(); + break; + case 0x1710f156: + result = new TL_updateEncryptedChatTyping(); + break; + case 0xa20db0e5: + result = new TL_updateDeleteMessages(); + break; + case 0x68c13933: + result = new TL_updateReadMessagesContents(); + break; + case 0x7761198: + result = new TL_updateChatParticipants(); + break; + case 0xee3b272a: + result = new TL_updatePrivacy(); + break; + case 0xb4a2e88d: + result = new TL_updateEncryption(); + break; + case 0x80ece81a: + result = new TL_updateUserBlocked(); + break; + case 0x12b9417b: + result = new TL_updateUserPhone(); + break; + case 0x8f06529a: + result = new TL_updateNewAuthorization(); + break; + case 0x5a68e3f7: + result = new TL_updateNewGeoChatMessage(); + break; + case 0x95313b0c: + result = new TL_updateUserPhoto(); + break; + case 0x2575bbb9: + result = new TL_updateContactRegistered(); + break; + case 0x3a0eeb22: + result = new TL_updateChatParticipantAdd(); + break; + case 0x1bfbd823: + result = new TL_updateUserStatus(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Update", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_updateEncryptedMessagesRead extends Update { + public static int constructor = 0x38fe25b7; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + max_date = stream.readInt32(exception); + date = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(max_date); + stream.writeInt32(date); + } + } + + public static class TL_updateContactLink extends Update { + public static int constructor = 0x9d2e67c5; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + my_link = ContactLink.TLdeserialize(stream, stream.readInt32(exception), exception); + foreign_link = ContactLink.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + my_link.serializeToStream(stream); + foreign_link.serializeToStream(stream); + } + } + + public static class TL_updateReadHistoryInbox extends Update { + public static int constructor = 0x9961fd5c; + + public Peer peer; + + public void readParams(AbsSerializedData stream, boolean exception) { + peer = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + max_id = stream.readInt32(exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt32(max_id); + stream.writeInt32(pts); + stream.writeInt32(pts_count); + } + } + + public static class TL_updateReadHistoryOutbox extends Update { + public static int constructor = 0x2f2f21bf; + + public Peer peer; + + public void readParams(AbsSerializedData stream, boolean exception) { + peer = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + max_id = stream.readInt32(exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt32(max_id); + stream.writeInt32(pts); + stream.writeInt32(pts_count); + } + } + + public static class TL_updateChatParticipantDelete extends Update { + public static int constructor = 0x6e5f8c22; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + user_id = stream.readInt32(exception); + version = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(user_id); + stream.writeInt32(version); + } + } + + public static class TL_updateWebPage extends Update { + public static int constructor = 0x2cc36971; + + + public void readParams(AbsSerializedData stream, boolean exception) { + webpage = WebPage.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + webpage.serializeToStream(stream); + } + } + + public static class TL_updateServiceNotification extends Update { + public static int constructor = 0x382dd3e4; + + public String message; + + public void readParams(AbsSerializedData stream, boolean exception) { + type = stream.readString(exception); + message = stream.readString(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + popup = stream.readBool(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(type); + stream.writeString(message); + media.serializeToStream(stream); + stream.writeBool(popup); + } + } + + public static class TL_updateNotifySettings extends Update { + public static int constructor = 0xbec268ef; + + public void readParams(AbsSerializedData stream, boolean exception) { + peer = NotifyPeer.TLdeserialize(stream, stream.readInt32(exception), exception); + notify_settings = PeerNotifySettings.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + notify_settings.serializeToStream(stream); + } + } + + public static class TL_updateUserTyping extends Update { + public static int constructor = 0x5c486927; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + action = SendMessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + action.serializeToStream(stream); + } + } + + public static class TL_updateChatUserTyping extends Update { + public static int constructor = 0x9a65ea1f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + user_id = stream.readInt32(exception); + action = SendMessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(user_id); + action.serializeToStream(stream); + } + } + + public static class TL_updateUserName extends Update { + public static int constructor = 0xa7332b73; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + username = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(username); + } + } + + public static class TL_updateNewEncryptedMessage extends Update { + public static int constructor = 0x12bcbd9a; + + public EncryptedMessage message; + + public void readParams(AbsSerializedData stream, boolean exception) { + message = EncryptedMessage.TLdeserialize(stream, stream.readInt32(exception), exception); + qts = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + message.serializeToStream(stream); + stream.writeInt32(qts); + } + } + + public static class TL_updateNewMessage extends Update { + public static int constructor = 0x1f2b0afd; + + public Message message; + + public void readParams(AbsSerializedData stream, boolean exception) { + message = Message.TLdeserialize(stream, stream.readInt32(exception), exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + message.serializeToStream(stream); + stream.writeInt32(pts); + stream.writeInt32(pts_count); + } + } + + public static class TL_updateMessageID extends Update { + public static int constructor = 0x4e90bfd6; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + random_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeInt64(random_id); + } + } + + public static class TL_updateDcOptions extends Update { + public static int constructor = 0x8e5e9873; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + dc_options.add(TL_dcOption.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = dc_options.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + dc_options.get(a).serializeToStream(stream); + } + } + } + + public static class TL_updateEncryptedChatTyping extends Update { + public static int constructor = 0x1710f156; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + } + } + + public static class TL_updateDeleteMessages extends Update { + public static int constructor = 0xa20db0e5; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + messages.add(stream.readInt32(exception)); + } + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt32(messages.get(a)); + } + stream.writeInt32(pts); + stream.writeInt32(pts_count); + } + } + + public static class TL_updateReadMessagesContents extends Update { + public static int constructor = 0x68c13933; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + messages.add(stream.readInt32(exception)); + } + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt32(messages.get(a)); + } + stream.writeInt32(pts); + stream.writeInt32(pts_count); + } + } + + public static class TL_updateChatParticipants extends Update { + public static int constructor = 0x7761198; + + + public void readParams(AbsSerializedData stream, boolean exception) { + participants = ChatParticipants.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + participants.serializeToStream(stream); + } + } + + public static class TL_updatePrivacy extends Update { + public static int constructor = 0xee3b272a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + key = TL_privacyKeyStatusTimestamp.TLdeserialize(stream, stream.readInt32(exception), exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + rules.add(PrivacyRule.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + key.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = rules.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + rules.get(a).serializeToStream(stream); + } + } + } + + public static class TL_updateEncryption extends Update { + public static int constructor = 0xb4a2e88d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat = EncryptedChat.TLdeserialize(stream, stream.readInt32(exception), exception); + date = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + chat.serializeToStream(stream); + stream.writeInt32(date); + } + } + + public static class TL_updateUserBlocked extends Update { + public static int constructor = 0x80ece81a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + blocked = stream.readBool(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeBool(blocked); + } + } + + public static class TL_updateUserPhone extends Update { + public static int constructor = 0x12b9417b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + phone = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeString(phone); + } + } + + public static class TL_updateNewAuthorization extends Update { + public static int constructor = 0x8f06529a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + auth_key_id = stream.readInt64(exception); + date = stream.readInt32(exception); + device = stream.readString(exception); + location = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(auth_key_id); + stream.writeInt32(date); + stream.writeString(device); + stream.writeString(location); + } + } + + public static class TL_updateNewGeoChatMessage extends Update { + public static int constructor = 0x5a68e3f7; + + public GeoChatMessage message; + + public void readParams(AbsSerializedData stream, boolean exception) { + message = GeoChatMessage.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + message.serializeToStream(stream); + } + } + + public static class TL_updateUserPhoto extends Update { + public static int constructor = 0x95313b0c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + previous = stream.readBool(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt32(date); + photo.serializeToStream(stream); + stream.writeBool(previous); + } + } + + public static class TL_updateContactRegistered extends Update { + public static int constructor = 0x2575bbb9; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt32(date); + } + } + + public static class TL_updateChatParticipantAdd extends Update { + public static int constructor = 0x3a0eeb22; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + user_id = stream.readInt32(exception); + inviter_id = stream.readInt32(exception); + version = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData 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; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + status.serializeToStream(stream); + } + } + + public static class TL_config extends TLObject { + public static int constructor = 0x4e32b894; + + public int date; + public int expires; + public boolean test_mode; + public int this_dc; + public ArrayList dc_options = new ArrayList<>(); + public int chat_size_max; + public int broadcast_size_max; + public int forwarded_count_max; + public int online_update_period_ms; + public int offline_blur_timeout_ms; + public int offline_idle_timeout_ms; + public int online_cloud_timeout_ms; + public int notify_cloud_delay_ms; + public int notify_default_delay_ms; + public int chat_big_size; + public int push_chat_period_ms; + public int push_chat_limit; + public ArrayList disabled_features = new ArrayList<>(); + + public static TL_config TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_config.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_config", constructor)); + } else { + return null; + } + } + TL_config result = new TL_config(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + date = stream.readInt32(exception); + expires = stream.readInt32(exception); + test_mode = stream.readBool(exception); + this_dc = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + dc_options.add(TL_dcOption.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + chat_size_max = stream.readInt32(exception); + broadcast_size_max = stream.readInt32(exception); + forwarded_count_max = stream.readInt32(exception); + online_update_period_ms = stream.readInt32(exception); + offline_blur_timeout_ms = stream.readInt32(exception); + offline_idle_timeout_ms = stream.readInt32(exception); + online_cloud_timeout_ms = stream.readInt32(exception); + notify_cloud_delay_ms = stream.readInt32(exception); + notify_default_delay_ms = stream.readInt32(exception); + chat_big_size = stream.readInt32(exception); + push_chat_period_ms = stream.readInt32(exception); + push_chat_limit = stream.readInt32(exception); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + disabled_features.add(TL_disabledFeature.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(date); + stream.writeInt32(expires); + stream.writeBool(test_mode); + stream.writeInt32(this_dc); + stream.writeInt32(0x1cb5c415); + int count = dc_options.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + dc_options.get(a).serializeToStream(stream); + } + stream.writeInt32(chat_size_max); + stream.writeInt32(broadcast_size_max); + stream.writeInt32(forwarded_count_max); + stream.writeInt32(online_update_period_ms); + stream.writeInt32(offline_blur_timeout_ms); + stream.writeInt32(offline_idle_timeout_ms); + stream.writeInt32(online_cloud_timeout_ms); + stream.writeInt32(notify_cloud_delay_ms); + stream.writeInt32(notify_default_delay_ms); + stream.writeInt32(chat_big_size); + stream.writeInt32(push_chat_period_ms); + stream.writeInt32(push_chat_limit); + stream.writeInt32(0x1cb5c415); + count = disabled_features.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + disabled_features.get(a).serializeToStream(stream); + } + } + } + + public static class InputAudio extends TLObject { + public long id; + public long access_hash; + + public static InputAudio TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputAudio result = null; + switch(constructor) { + case 0x77d440ff: + result = new TL_inputAudio(); + break; + case 0xd95adc84: + result = new TL_inputAudioEmpty(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputAudio", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputAudio extends InputAudio { + public static int constructor = 0x77d440ff; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class PeerNotifySettings extends TLObject { + public int mute_until; + public String sound; + public boolean show_previews; + public int events_mask; + + public static PeerNotifySettings TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + PeerNotifySettings result = null; + switch(constructor) { + case 0x70a68512: + result = new TL_peerNotifySettingsEmpty(); + break; + case 0x8d5e11ee: + result = new TL_peerNotifySettings(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in PeerNotifySettings", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_peerNotifySettingsEmpty extends PeerNotifySettings { + public static int constructor = 0x70a68512; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_peerNotifySettings extends PeerNotifySettings { + public static int constructor = 0x8d5e11ee; + + + public void readParams(AbsSerializedData stream, boolean exception) { + mute_until = stream.readInt32(exception); + sound = stream.readString(exception); + show_previews = stream.readBool(exception); + events_mask = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(mute_until); + stream.writeString(sound); + stream.writeBool(show_previews); + stream.writeInt32(events_mask); + } + } + + public static class GeoChatMessage extends TLObject { + public int chat_id; + public int id; + public int from_id; + public int date; + public String message; + public MessageMedia media; + public MessageAction action; + + public static GeoChatMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + GeoChatMessage result = null; + switch(constructor) { + case 0x4505f8e1: + result = new TL_geoChatMessage(); + break; + case 0xd34fa24e: + result = new TL_geoChatMessageService(); + break; + case 0x60311a9b: + result = new TL_geoChatMessageEmpty(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in GeoChatMessage", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_geoChatMessage extends GeoChatMessage { + public static int constructor = 0x4505f8e1; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + date = stream.readInt32(exception); + message = stream.readString(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(id); + stream.writeInt32(from_id); + stream.writeInt32(date); + stream.writeString(message); + media.serializeToStream(stream); + } + } + + public static class TL_geoChatMessageService extends GeoChatMessage { + public static int constructor = 0xd34fa24e; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + date = stream.readInt32(exception); + action = MessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(id); + stream.writeInt32(from_id); + stream.writeInt32(date); + action.serializeToStream(stream); + } + } + + public static class TL_geoChatMessageEmpty extends GeoChatMessage { + public static int constructor = 0x60311a9b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt32(id); + } + } + + public static class messages_SentMessage extends TLObject { + public int id; + public int date; + public MessageMedia media; + public int pts; + public int pts_count; + public ArrayList links = new ArrayList<>(); + public int seq; + + public static messages_SentMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + messages_SentMessage result = null; + switch(constructor) { + case 0x4c3d47f3: + result = new TL_messages_sentMessage(); + break; + case 0x35a1a663: + result = new TL_messages_sentMessageLink(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in messages_SentMessage", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messages_sentMessage extends messages_SentMessage { + public static int constructor = 0x4c3d47f3; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + date = stream.readInt32(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeInt32(date); + media.serializeToStream(stream); + stream.writeInt32(pts); + stream.writeInt32(pts_count); + } + } + + public static class TL_messages_sentMessageLink extends messages_SentMessage { + public static int constructor = 0x35a1a663; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + date = stream.readInt32(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + links.add(TL_contacts_link.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + seq = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeInt32(date); + media.serializeToStream(stream); + stream.writeInt32(pts); + stream.writeInt32(pts_count); + stream.writeInt32(0x1cb5c415); + int count = links.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + links.get(a).serializeToStream(stream); + } + stream.writeInt32(seq); + } + } + + public static class TL_contactSuggested extends TLObject { + public static int constructor = 0x3de191a1; + + public int user_id; + public int mutual_contacts; + + public static TL_contactSuggested TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contactSuggested.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contactSuggested", constructor)); + } else { + return null; + } + } + TL_contactSuggested result = new TL_contactSuggested(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + mutual_contacts = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt32(mutual_contacts); + } + } + + public static class InputChatPhoto extends TLObject { public InputPhoto id; + public InputPhotoCrop crop; + public InputFile file; - public void readParams(AbsSerializedData stream) { - id = (InputPhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public static InputChatPhoto TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputChatPhoto result = null; + switch(constructor) { + case 0xb2e1bf08: + result = new TL_inputChatPhoto(); + break; + case 0x1ca48f57: + result = new TL_inputChatPhotoEmpty(); + break; + case 0x94254732: + result = new TL_inputChatUploadedPhoto(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputChatPhoto", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputChatPhoto extends InputChatPhoto { + public static int constructor = 0xb2e1bf08; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = InputPhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + crop = InputPhotoCrop.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); id.serializeToStream(stream); + crop.serializeToStream(stream); + } + } + + public static class TL_inputChatPhotoEmpty extends InputChatPhoto { + public static int constructor = 0x1ca48f57; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputChatUploadedPhoto extends InputChatPhoto { + public static int constructor = 0x94254732; + + + public void readParams(AbsSerializedData stream, boolean exception) { + file = InputFile.TLdeserialize(stream, stream.readInt32(exception), exception); + crop = InputPhotoCrop.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + file.serializeToStream(stream); + crop.serializeToStream(stream); + } + } + + public static class InputPeer extends TLObject { + public int user_id; + public int chat_id; + public long access_hash; + + public static InputPeer TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputPeer result = null; + switch(constructor) { + case 0x1023dbe8: + result = new TL_inputPeerContact(); + break; + case 0x179be863: + result = new TL_inputPeerChat(); + break; + case 0x7f3b18ea: + result = new TL_inputPeerEmpty(); + break; + case 0x7da07ec9: + result = new TL_inputPeerSelf(); + break; + case 0x9b447325: + result = new TL_inputPeerForeign(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputPeer", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputPeerContact extends InputPeer { + public static int constructor = 0x1023dbe8; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + } + } + + public static class TL_inputPeerChat extends InputPeer { + public static int constructor = 0x179be863; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + } + } + + public static class TL_inputPeerEmpty extends InputPeer { + public static int constructor = 0x7f3b18ea; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPeerSelf extends InputPeer { + public static int constructor = 0x7da07ec9; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPeerForeign extends InputPeer { + public static int constructor = 0x9b447325; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt64(access_hash); + } + } + + public static class TL_msg_copy extends TLObject { + public static int constructor = 0xe06046b2; + + public TL_protoMessage orig_message; + + public static TL_msg_copy TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_msg_copy.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_msg_copy", constructor)); + } else { + return null; + } + } + TL_msg_copy result = new TL_msg_copy(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + orig_message = TL_protoMessage.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + orig_message.serializeToStream(stream); + } + } + + public static class TL_fileLocation extends FileLocation { + public static int constructor = 0x53d69076; + + + public void readParams(AbsSerializedData stream, boolean exception) { + dc_id = stream.readInt32(exception); + volume_id = stream.readInt64(exception); + local_id = stream.readInt32(exception); + secret = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream, boolean exception) { + volume_id = stream.readInt64(exception); + local_id = stream.readInt32(exception); + secret = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(volume_id); + stream.writeInt32(local_id); + stream.writeInt64(secret); + } + } + + public static class TL_pong extends TLObject { + public static int constructor = 0x347773c5; + + public long msg_id; + public long ping_id; + + public static TL_pong TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_pong.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_pong", constructor)); + } else { + return null; + } + } + TL_pong result = new TL_pong(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + msg_id = stream.readInt64(exception); + ping_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(msg_id); + stream.writeInt64(ping_id); + } + } + + public static class TL_inputAppEvent extends TLObject { + public static int constructor = 0x770656a8; + + public double time; + public String type; + public long peer; + public String data; + + public static TL_inputAppEvent TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_inputAppEvent.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inputAppEvent", constructor)); + } else { + return null; + } + } + TL_inputAppEvent result = new TL_inputAppEvent(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + time = stream.readDouble(exception); + type = stream.readString(exception); + peer = stream.readInt64(exception); + data = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeDouble(time); + stream.writeString(type); + stream.writeInt64(peer); + stream.writeString(data); + } + } + + public static class TL_messages_chatFull extends TLObject { + public static int constructor = 0xe5d7d19c; + + public TL_chatFull full_chat; + public ArrayList chats = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + + public static TL_messages_chatFull TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_messages_chatFull.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_messages_chatFull", constructor)); + } else { + return null; + } + } + TL_messages_chatFull result = new TL_messages_chatFull(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + full_chat = TL_chatFull.TLdeserialize(stream, stream.readInt32(exception), exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + full_chat.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 InputNotifyPeer extends TLObject { + + public static InputNotifyPeer TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputNotifyPeer result = null; + switch(constructor) { + case 0x4a95e84e: + result = new TL_inputNotifyChats(); + break; + case 0xb8bc5b0c: + result = new TL_inputNotifyPeer(); + break; + case 0x193b4417: + result = new TL_inputNotifyUsers(); + break; + case 0x4d8ddec8: + result = new TL_inputNotifyGeoChatPeer(); + break; + case 0xa429b886: + result = new TL_inputNotifyAll(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputNotifyPeer", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputNotifyChats extends InputNotifyPeer { + public static int constructor = 0x4a95e84e; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputNotifyPeer extends InputNotifyPeer { + public static int constructor = 0xb8bc5b0c; + + public InputPeer peer; + + public void readParams(AbsSerializedData stream, boolean exception) { + peer = InputPeer.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + } + } + + public static class TL_inputNotifyUsers extends InputNotifyPeer { + public static int constructor = 0x193b4417; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputNotifyGeoChatPeer extends InputNotifyPeer { + public static int constructor = 0x4d8ddec8; + + public TL_inputGeoChat peer; + + public void readParams(AbsSerializedData stream, boolean exception) { + peer = TL_inputGeoChat.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + } + } + + public static class TL_inputNotifyAll extends InputNotifyPeer { + public static int constructor = 0xa429b886; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messages_affectedHistory extends TLObject { + public static int constructor = 0xb45c69d1; + + public int pts; + public int pts_count; + public int offset; + + public static TL_messages_affectedHistory TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_messages_affectedHistory.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_messages_affectedHistory", constructor)); + } else { + return null; + } + } + TL_messages_affectedHistory result = new TL_messages_affectedHistory(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + offset = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(pts); + stream.writeInt32(pts_count); + stream.writeInt32(offset); + } + } + + public static class RpcDropAnswer extends TLObject { + public long msg_id; + public int seq_no; + public int bytes; + + public static RpcDropAnswer TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + RpcDropAnswer result = null; + switch(constructor) { + case 0x5e2ad36e: + result = new TL_rpc_answer_unknown(); + break; + case 0xa43ad8b7: + result = new TL_rpc_answer_dropped(); + break; + case 0xcd78e586: + result = new TL_rpc_answer_dropped_running(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in RpcDropAnswer", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_rpc_answer_unknown extends RpcDropAnswer { + public static int constructor = 0x5e2ad36e; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_rpc_answer_dropped extends RpcDropAnswer { + public static int constructor = 0xa43ad8b7; + + + public void readParams(AbsSerializedData stream, boolean exception) { + msg_id = stream.readInt64(exception); + seq_no = stream.readInt32(exception); + bytes = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(msg_id); + stream.writeInt32(seq_no); + stream.writeInt32(bytes); + } + } + + public static class TL_rpc_answer_dropped_running extends RpcDropAnswer { + public static int constructor = 0xcd78e586; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class InputVideo extends TLObject { + public long id; + public long access_hash; + + public static InputVideo TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputVideo result = null; + switch(constructor) { + case 0x5508ec75: + result = new TL_inputVideoEmpty(); + break; + case 0xee579652: + result = new TL_inputVideo(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputVideo", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputVideoEmpty extends InputVideo { + public static int constructor = 0x5508ec75; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputVideo extends InputVideo { + public static int constructor = 0xee579652; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + + public static class messages_DhConfig extends TLObject { + public byte[] random; + public int g; + public byte[] p; + public int version; + + public static messages_DhConfig TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + messages_DhConfig result = null; + switch(constructor) { + case 0xc0e24635: + result = new TL_messages_dhConfigNotModified(); + break; + case 0x2c221edd: + result = new TL_messages_dhConfig(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in messages_DhConfig", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messages_dhConfigNotModified extends messages_DhConfig { + public static int constructor = 0xc0e24635; + + + public void readParams(AbsSerializedData stream, boolean exception) { + random = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeByteArray(random); + } + } + + public static class TL_messages_dhConfig extends messages_DhConfig { + public static int constructor = 0x2c221edd; + + + public void readParams(AbsSerializedData stream, boolean exception) { + g = stream.readInt32(exception); + p = stream.readByteArray(exception); + version = stream.readInt32(exception); + random = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(g); + stream.writeByteArray(p); + stream.writeInt32(version); + stream.writeByteArray(random); + } + } + + public static class Peer extends TLObject { + public int user_id; + public int chat_id; + + public static Peer TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Peer result = null; + switch(constructor) { + case 0x9db1bc6d: + result = new TL_peerUser(); + break; + case 0xbad0e5bb: + result = new TL_peerChat(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Peer", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_peerUser extends Peer { + public static int constructor = 0x9db1bc6d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + } + } + + public static class TL_peerChat extends Peer { + public static int constructor = 0xbad0e5bb; + + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + } + } + + public static class TL_dcOption extends TLObject { + public static int constructor = 0x2ec2a43c; + + public int id; + public String hostname; + public String ip_address; + public int port; + + public static TL_dcOption TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_dcOption.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_dcOption", constructor)); + } else { + return null; + } + } + TL_dcOption result = new TL_dcOption(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + hostname = stream.readString(exception); + ip_address = stream.readString(exception); + port = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(hostname); + stream.writeString(ip_address); + stream.writeInt32(port); + } + } + + public static class InputFile extends TLObject { + public long id; + public int parts; + public String name; + public String md5_checksum; + + public static InputFile TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputFile result = null; + switch(constructor) { + case 0xfa4f0bb5: + result = new TL_inputFileBig(); + break; + case 0xf52ff27f: + result = new TL_inputFile(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputFile", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputFileBig extends InputFile { + public static int constructor = 0xfa4f0bb5; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + parts = stream.readInt32(exception); + name = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt32(parts); + stream.writeString(name); + } + } + + public static class TL_inputFile extends InputFile { + public static int constructor = 0xf52ff27f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + parts = stream.readInt32(exception); + name = stream.readString(exception); + md5_checksum = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt32(parts); + stream.writeString(name); + stream.writeString(md5_checksum); + } + } + + public static class TL_account_passwordInputSettings extends TLObject { + public static int constructor = 0xbcfc532c; + + public int flags; + public byte[] new_salt; + public byte[] new_password_hash; + public String hint; + public String email; + + public static TL_account_passwordInputSettings TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_account_passwordInputSettings.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_account_passwordInputSettings", constructor)); + } else { + return null; + } + } + TL_account_passwordInputSettings result = new TL_account_passwordInputSettings(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + if ((flags & 1) != 0) { + new_salt = stream.readByteArray(exception); + } + if ((flags & 1) != 0) { + new_password_hash = stream.readByteArray(exception); + } + if ((flags & 1) != 0) { + hint = stream.readString(exception); + } + if ((flags & 2) != 0) { + email = stream.readString(exception); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(flags); + if ((flags & 1) != 0) { + stream.writeByteArray(new_salt); + } + if ((flags & 1) != 0) { + stream.writeByteArray(new_password_hash); + } + if ((flags & 1) != 0) { + stream.writeString(hint); + } + if ((flags & 2) != 0) { + stream.writeString(email); + } + } + } + + public static class InputUser extends TLObject { + public int user_id; + public long access_hash; + + public static InputUser TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputUser result = null; + switch(constructor) { + case 0xf7c1b13f: + result = new TL_inputUserSelf(); + break; + case 0x655e74ff: + result = new TL_inputUserForeign(); + break; + case 0xb98886cf: + result = new TL_inputUserEmpty(); + break; + case 0x86e94f65: + result = new TL_inputUserContact(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputUser", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputUserSelf extends InputUser { + public static int constructor = 0xf7c1b13f; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputUserForeign extends InputUser { + public static int constructor = 0x655e74ff; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt64(access_hash); + } + } + + public static class TL_inputUserEmpty extends InputUser { + public static int constructor = 0xb98886cf; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputUserContact extends InputUser { + public static int constructor = 0x86e94f65; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + } + } + + public static class TL_chatParticipant extends TLObject { + public static int constructor = 0xc8d7493e; + + public int user_id; + public int inviter_id; + public int date; + + public static TL_chatParticipant TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_chatParticipant.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_chatParticipant", constructor)); + } else { + return null; + } + } + TL_chatParticipant result = new TL_chatParticipant(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + inviter_id = stream.readInt32(exception); + date = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt32(inviter_id); + stream.writeInt32(date); + } + } + + public static class EncryptedFile extends TLObject { + public long id; + public long access_hash; + public int size; + public int dc_id; + public int key_fingerprint; + + public static EncryptedFile TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + EncryptedFile result = null; + switch(constructor) { + case 0x4a70994c: + result = new TL_encryptedFile(); + break; + case 0xc21f497e: + result = new TL_encryptedFileEmpty(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in EncryptedFile", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_encryptedFile extends EncryptedFile { + public static int constructor = 0x4a70994c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + size = stream.readInt32(exception); + dc_id = stream.readInt32(exception); + key_fingerprint = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(size); + stream.writeInt32(dc_id); + stream.writeInt32(key_fingerprint); + } + } + + public static class TL_encryptedFileEmpty extends EncryptedFile { + public static int constructor = 0xc21f497e; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_account_privacyRules extends TLObject { + public static int constructor = 0x554abb6f; + + public ArrayList rules = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + + public static TL_account_privacyRules TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_account_privacyRules.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_account_privacyRules", constructor)); + } else { + return null; + } + } + TL_account_privacyRules result = new TL_account_privacyRules(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + rules.add(PrivacyRule.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = rules.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + rules.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = users.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + users.get(a).serializeToStream(stream); + } + } + } + + public static class TL_auth_exportedAuthorization extends TLObject { + public static int constructor = 0xdf969c2d; + + public int id; + public byte[] bytes; + + public static TL_auth_exportedAuthorization TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_auth_exportedAuthorization.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_auth_exportedAuthorization", constructor)); + } else { + return null; + } + } + TL_auth_exportedAuthorization result = new TL_auth_exportedAuthorization(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + bytes = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeByteArray(bytes); + } + } + + public static class InputFileLocation extends TLObject { + public long id; + public long access_hash; + public long volume_id; + public int local_id; + public long secret; + + public static InputFileLocation TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputFileLocation result = null; + switch(constructor) { + case 0x74dc404d: + result = new TL_inputAudioFileLocation(); + break; + case 0xf5235d55: + result = new TL_inputEncryptedFileLocation(); + break; + case 0x3d0364ec: + result = new TL_inputVideoFileLocation(); + break; + case 0x4e45abe9: + result = new TL_inputDocumentFileLocation(); + break; + case 0x14637196: + result = new TL_inputFileLocation(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputFileLocation", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputAudioFileLocation extends InputFileLocation { + public static int constructor = 0x74dc404d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + + public static class TL_inputEncryptedFileLocation extends InputFileLocation { + public static int constructor = 0xf5235d55; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + + public static class TL_inputVideoFileLocation extends InputFileLocation { + public static int constructor = 0x3d0364ec; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + + public static class TL_inputFileLocation extends InputFileLocation { + public static int constructor = 0x14637196; + + + public void readParams(AbsSerializedData stream, boolean exception) { + volume_id = stream.readInt64(exception); + local_id = stream.readInt32(exception); + secret = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(volume_id); + stream.writeInt32(local_id); + stream.writeInt64(secret); + } + } + + public static class TL_chatFull extends TLObject { + public static int constructor = 0xcade0791; + + public int id; + public ChatParticipants participants; + public Photo chat_photo; + public PeerNotifySettings notify_settings; + public ExportedChatInvite exported_invite; + + public static TL_chatFull TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_chatFull.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_chatFull", constructor)); + } else { + return null; + } + } + TL_chatFull result = new TL_chatFull(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + participants = ChatParticipants.TLdeserialize(stream, stream.readInt32(exception), exception); + chat_photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); + notify_settings = PeerNotifySettings.TLdeserialize(stream, stream.readInt32(exception), exception); + exported_invite = ExportedChatInvite.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + participants.serializeToStream(stream); + chat_photo.serializeToStream(stream); + notify_settings.serializeToStream(stream); + exported_invite.serializeToStream(stream); + } + } + + public static class InputGeoPoint extends TLObject { + public double lat; + public double _long; + + public static InputGeoPoint TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputGeoPoint result = null; + switch(constructor) { + case 0xf3b7acc9: + result = new TL_inputGeoPoint(); + break; + case 0xe4c123d6: + result = new TL_inputGeoPointEmpty(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputGeoPoint", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputGeoPoint extends InputGeoPoint { + public static int constructor = 0xf3b7acc9; + + + public void readParams(AbsSerializedData stream, boolean exception) { + lat = stream.readDouble(exception); + _long = stream.readDouble(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeDouble(lat); + stream.writeDouble(_long); + } + } + + public static class TL_inputGeoPointEmpty extends InputGeoPoint { + public static int constructor = 0xe4c123d6; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_photo extends Photo { + public static int constructor = 0xc3838076; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + sizes.add(PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + geo.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = sizes.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + sizes.get(a).serializeToStream(stream); + } + } + } + + public static class TL_photoEmpty extends Photo { + public static int constructor = 0x2331b22d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + } + } + + public static class TL_help_support extends TLObject { + public static int constructor = 0x17c6b5f6; + + public String phone_number; + public User user; + + public static TL_help_support TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_help_support.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_help_support", constructor)); + } else { + return null; + } + } + TL_help_support result = new TL_help_support(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_number = stream.readString(exception); + user = User.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_number); + user.serializeToStream(stream); + } + } + + public static class TL_inputPhoneContact extends TLObject { + public static int constructor = 0xf392b7f4; + + public long client_id; + public String phone; + public String first_name; + public String last_name; + + public static TL_inputPhoneContact TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_inputPhoneContact.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inputPhoneContact", constructor)); + } else { + return null; + } + } + TL_inputPhoneContact result = new TL_inputPhoneContact(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + client_id = stream.readInt64(exception); + phone = stream.readString(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(client_id); + stream.writeString(phone); + stream.writeString(first_name); + stream.writeString(last_name); + } + } + + public static class Bool extends TLObject { + + public static Bool TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Bool result = null; + switch(constructor) { + case 0x997275b5: + result = new TL_boolTrue(); + break; + case 0xbc799737: + result = new TL_boolFalse(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Bool", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_boolTrue extends Bool { + public static int constructor = 0x997275b5; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_boolFalse extends Bool { + public static int constructor = 0xbc799737; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class EncryptedMessage extends TLObject { + public long random_id; + public int chat_id; + public int date; + public byte[] bytes; + public EncryptedFile file; + + public static EncryptedMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + EncryptedMessage result = null; + switch(constructor) { + case 0x23734b06: + result = new TL_encryptedMessageService(); + break; + case 0xed18c118: + result = new TL_encryptedMessage(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in EncryptedMessage", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_encryptedMessageService extends EncryptedMessage { + public static int constructor = 0x23734b06; + + + public void readParams(AbsSerializedData stream, boolean exception) { + random_id = stream.readInt64(exception); + chat_id = stream.readInt32(exception); + date = stream.readInt32(exception); + bytes = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(random_id); + stream.writeInt32(chat_id); + stream.writeInt32(date); + stream.writeByteArray(bytes); + } + } + + public static class TL_encryptedMessage extends EncryptedMessage { + public static int constructor = 0xed18c118; + + + public void readParams(AbsSerializedData stream, boolean exception) { + random_id = stream.readInt64(exception); + chat_id = stream.readInt32(exception); + date = stream.readInt32(exception); + bytes = stream.readByteArray(exception); + file = EncryptedFile.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(random_id); + stream.writeInt32(chat_id); + stream.writeInt32(date); + stream.writeByteArray(bytes); + file.serializeToStream(stream); + } + } + + public static class TL_messages_messageEmpty extends TLObject { + public static int constructor = 0x3f4e0648; + + + public static TL_messages_messageEmpty TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_messages_messageEmpty.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_messages_messageEmpty", constructor)); + } else { + return null; + } + } + TL_messages_messageEmpty result = new TL_messages_messageEmpty(); + result.readParams(stream, exception); + return result; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class DestroySessionRes extends TLObject { + public long session_id; + + public static DestroySessionRes TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + DestroySessionRes result = null; + switch(constructor) { + case 0xe22045fc: + result = new TL_destroy_session_ok(); + break; + case 0x62d350c9: + result = new TL_destroy_session_none(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in DestroySessionRes", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_destroy_session_ok extends DestroySessionRes { + public static int constructor = 0xe22045fc; + + + public void readParams(AbsSerializedData stream, boolean exception) { + session_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(session_id); + } + } + + public static class TL_destroy_session_none extends DestroySessionRes { + public static int constructor = 0x62d350c9; + + + public void readParams(AbsSerializedData stream, boolean exception) { + session_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(session_id); + } + } + + public static class PhotoSize extends TLObject { + public String type; + public FileLocation location; + public int w; + public int h; + public int size; + public byte[] bytes; + + public static PhotoSize TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + PhotoSize result = null; + switch(constructor) { + case 0x77bfb61b: + result = new TL_photoSize(); + break; + case 0xe17e23c: + result = new TL_photoSizeEmpty(); + break; + case 0xe9a734fa: + result = new TL_photoCachedSize(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in PhotoSize", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_photoSize extends PhotoSize { + public static int constructor = 0x77bfb61b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + type = stream.readString(exception); + location = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + size = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(type); + location.serializeToStream(stream); + stream.writeInt32(w); + stream.writeInt32(h); + stream.writeInt32(size); + } + } + + public static class TL_photoSizeEmpty extends PhotoSize { + public static int constructor = 0xe17e23c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + type = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(type); + } + } + + public static class TL_photoCachedSize extends PhotoSize { + public static int constructor = 0xe9a734fa; + + + public void readParams(AbsSerializedData stream, boolean exception) { + type = stream.readString(exception); + location = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + bytes = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(type); + location.serializeToStream(stream); + stream.writeInt32(w); + stream.writeInt32(h); + stream.writeByteArray(bytes); + } + } + + public static class TL_messageActionChatEditPhoto extends MessageAction { + public static int constructor = 0x7fcb13a8; + + + public void readParams(AbsSerializedData stream, boolean exception) { + photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + photo.serializeToStream(stream); + } + } + + public static class TL_messageActionChatDeleteUser extends MessageAction { + public static int constructor = 0xb2ae9b0c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + } + } + + public static class TL_messageActionChatJoinedByLink extends MessageAction { + public static int constructor = 0xf89cf5e8; + + + public void readParams(AbsSerializedData stream, boolean exception) { + inviter_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(inviter_id); + } + } + + public static class TL_messageActionChatDeletePhoto extends MessageAction { + public static int constructor = 0x95e3fbef; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messageActionChatAddUser extends MessageAction { + public static int constructor = 0x5e3cfc4b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + } + } + + public static class TL_messageActionChatCreate extends MessageAction { + public static int constructor = 0xa6638b9a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + title = stream.readString(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(stream.readInt32(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(title); + stream.writeInt32(0x1cb5c415); + int count = users.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt32(users.get(a)); + } + } + } + + public static class TL_messageActionEmpty extends MessageAction { + public static int constructor = 0xb6aef7b0; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messageActionChatEditTitle extends MessageAction { + public static int constructor = 0xb5a1ce5a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + title = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(title); + } + } + + public static class TL_messageActionGeoChatCreate extends MessageAction { + public static int constructor = 0x6f038ebc; + + + public void readParams(AbsSerializedData stream, boolean exception) { + title = stream.readString(exception); + address = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(title); + stream.writeString(address); + } + } + + public static class TL_messageActionGeoChatCheckin extends MessageAction { + public static int constructor = 0xc7d53de; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class DecryptedMessageAction extends TLObject { + public int ttl_seconds; + public int layer; + public ArrayList random_ids = new ArrayList<>(); + public long exchange_id; + public long key_fingerprint; + public SendMessageAction action; + public byte[] g_b; + public int start_seq_no; + public int end_seq_no; + public byte[] g_a; + + public static DecryptedMessageAction TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + DecryptedMessageAction result = null; + switch(constructor) { + case 0xa1733aec: + result = new TL_decryptedMessageActionSetMessageTTL(); + break; + case 0xf3048883: + result = new TL_decryptedMessageActionNotifyLayer(); + break; + case 0x65614304: + result = new TL_decryptedMessageActionDeleteMessages(); + break; + case 0xec2e0b9b: + result = new TL_decryptedMessageActionCommitKey(); + break; + case 0xdd05ec6b: + result = new TL_decryptedMessageActionAbortKey(); + break; + case 0x6719e45c: + result = new TL_decryptedMessageActionFlushHistory(); + break; + case 0xccb27641: + result = new TL_decryptedMessageActionTyping(); + break; + case 0x6fe1735b: + result = new TL_decryptedMessageActionAcceptKey(); + break; + case 0xc4f40be: + result = new TL_decryptedMessageActionReadMessages(); + break; + case 0x511110b0: + result = new TL_decryptedMessageActionResend(); + break; + case 0xf3c9611b: + result = new TL_decryptedMessageActionRequestKey(); + break; + case 0x8ac1f475: + result = new TL_decryptedMessageActionScreenshotMessages(); + break; + case 0xa82fdd63: + result = new TL_decryptedMessageActionNoop(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in DecryptedMessageAction", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_decryptedMessageActionSetMessageTTL extends DecryptedMessageAction { + public static int constructor = 0xa1733aec; + + + public void readParams(AbsSerializedData stream, boolean exception) { + ttl_seconds = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(ttl_seconds); + } + } + + public static class TL_decryptedMessageActionNotifyLayer extends DecryptedMessageAction { + public static int constructor = 0xf3048883; + + + public void readParams(AbsSerializedData stream, boolean exception) { + layer = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(layer); + } + } + + public static class TL_decryptedMessageActionDeleteMessages extends DecryptedMessageAction { + public static int constructor = 0x65614304; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + random_ids.add(stream.readInt64(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = random_ids.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(random_ids.get(a)); + } + } + } + + public static class TL_decryptedMessageActionCommitKey extends DecryptedMessageAction { + public static int constructor = 0xec2e0b9b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + exchange_id = stream.readInt64(exception); + key_fingerprint = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(exchange_id); + stream.writeInt64(key_fingerprint); + } + } + + public static class TL_decryptedMessageActionAbortKey extends DecryptedMessageAction { + public static int constructor = 0xdd05ec6b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + exchange_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(exchange_id); + } + } + + public static class TL_decryptedMessageActionFlushHistory extends DecryptedMessageAction { + public static int constructor = 0x6719e45c; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_decryptedMessageActionTyping extends DecryptedMessageAction { + public static int constructor = 0xccb27641; + + + public void readParams(AbsSerializedData stream, boolean exception) { + action = SendMessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + action.serializeToStream(stream); + } + } + + public static class TL_decryptedMessageActionAcceptKey extends DecryptedMessageAction { + public static int constructor = 0x6fe1735b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + exchange_id = stream.readInt64(exception); + g_b = stream.readByteArray(exception); + key_fingerprint = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(exchange_id); + stream.writeByteArray(g_b); + stream.writeInt64(key_fingerprint); + } + } + + public static class TL_decryptedMessageActionReadMessages extends DecryptedMessageAction { + public static int constructor = 0xc4f40be; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + random_ids.add(stream.readInt64(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = random_ids.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(random_ids.get(a)); + } + } + } + + public static class TL_decryptedMessageActionResend extends DecryptedMessageAction { + public static int constructor = 0x511110b0; + + + public void readParams(AbsSerializedData stream, boolean exception) { + start_seq_no = stream.readInt32(exception); + end_seq_no = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(start_seq_no); + stream.writeInt32(end_seq_no); + } + } + + public static class TL_decryptedMessageActionRequestKey extends DecryptedMessageAction { + public static int constructor = 0xf3c9611b; + + + public void readParams(AbsSerializedData stream, boolean exception) { + exchange_id = stream.readInt64(exception); + g_a = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(exchange_id); + stream.writeByteArray(g_a); + } + } + + public static class TL_decryptedMessageActionScreenshotMessages extends DecryptedMessageAction { + public static int constructor = 0x8ac1f475; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + random_ids.add(stream.readInt64(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = random_ids.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(random_ids.get(a)); + } + } + } + + public static class TL_decryptedMessageActionNoop extends DecryptedMessageAction { + public static int constructor = 0xa82fdd63; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputGeoChat extends TLObject { + public static int constructor = 0x74d456fa; + + public int chat_id; + public long access_hash; + + public static TL_inputGeoChat TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_inputGeoChat.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inputGeoChat", constructor)); + } else { + return null; + } + } + TL_inputGeoChat result = new TL_inputGeoChat(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + chat_id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + stream.writeInt64(access_hash); + } + } + + public static class TL_msgs_state_req extends TLObject { + public static int constructor = 0xda69fb52; + + public ArrayList msg_ids = new ArrayList<>(); + + public static TL_msgs_state_req TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_msgs_state_req.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_msgs_state_req", constructor)); + } else { + return null; + } + } + TL_msgs_state_req result = new TL_msgs_state_req(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + msg_ids.add(stream.readInt64(exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = msg_ids.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(msg_ids.get(a)); + } + } + } + + public static class TL_importedContact extends TLObject { + public static int constructor = 0xd0028438; + + public int user_id; + public long client_id; + + public static TL_importedContact TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_importedContact.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_importedContact", constructor)); + } else { + return null; + } + } + TL_importedContact result = new TL_importedContact(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + client_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(user_id); + stream.writeInt64(client_id); + } + } + + public static class auth_SentCode extends TLObject { + public boolean phone_registered; + public String phone_code_hash; + public int send_call_timeout; + public boolean is_password; + + public static auth_SentCode TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + auth_SentCode result = null; + switch(constructor) { + case 0xe325edcf: + result = new TL_auth_sentAppCode(); + break; + case 0xefed51d9: + result = new TL_auth_sentCode(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in auth_SentCode", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_auth_sentAppCode extends auth_SentCode { + public static int constructor = 0xe325edcf; + + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_registered = stream.readBool(exception); + phone_code_hash = stream.readString(exception); + send_call_timeout = stream.readInt32(exception); + is_password = stream.readBool(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeBool(phone_registered); + stream.writeString(phone_code_hash); + stream.writeInt32(send_call_timeout); + stream.writeBool(is_password); + } + } + + public static class TL_auth_sentCode extends auth_SentCode { + public static int constructor = 0xefed51d9; + + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_registered = stream.readBool(exception); + phone_code_hash = stream.readString(exception); + send_call_timeout = stream.readInt32(exception); + is_password = stream.readBool(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeBool(phone_registered); + stream.writeString(phone_code_hash); + stream.writeInt32(send_call_timeout); + stream.writeBool(is_password); + } + } + + public static class TL_help_inviteText extends TLObject { + public static int constructor = 0x18cb9f78; + + public String message; + + public static TL_help_inviteText TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_help_inviteText.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_help_inviteText", constructor)); + } else { + return null; + } + } + TL_help_inviteText result = new TL_help_inviteText(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + message = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(message); + } + } + + public static class messages_AllStickers extends TLObject { + public String hash; + public ArrayList packs = new ArrayList<>(); + public ArrayList documents = new ArrayList<>(); + + public static messages_AllStickers TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + messages_AllStickers result = null; + switch(constructor) { + case 0xdcef3102: + result = new TL_messages_allStickers(); + break; + case 0xe86602c3: + result = new TL_messages_allStickersNotModified(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in messages_AllStickers", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messages_allStickers extends messages_AllStickers { + public static int constructor = 0xdcef3102; + + + public void readParams(AbsSerializedData stream, boolean exception) { + hash = stream.readString(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + packs.add(TL_stickerPack.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + documents.add(Document.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(hash); + stream.writeInt32(0x1cb5c415); + int count = packs.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + packs.get(a).serializeToStream(stream); + } + stream.writeInt32(0x1cb5c415); + count = documents.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + documents.get(a).serializeToStream(stream); + } + } + } + + public static class TL_messages_allStickersNotModified extends messages_AllStickers { + public static int constructor = 0xe86602c3; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_auth_checkedPhone extends TLObject { + public static int constructor = 0x811ea28e; + + public boolean phone_registered; + + public static TL_auth_checkedPhone TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_auth_checkedPhone.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_auth_checkedPhone", constructor)); + } else { + return null; + } + } + TL_auth_checkedPhone result = new TL_auth_checkedPhone(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + phone_registered = stream.readBool(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeBool(phone_registered); + } + } + + public static class TL_userProfilePhotoEmpty extends UserProfilePhoto { + public static int constructor = 0x4f11bae1; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_userProfilePhoto extends UserProfilePhoto { + public static int constructor = 0xd559d8c8; + + + public void readParams(AbsSerializedData stream, boolean exception) { + photo_id = stream.readInt64(exception); + photo_small = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + photo_big = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(photo_id); + photo_small.serializeToStream(stream); + photo_big.serializeToStream(stream); + } + } + + public static class TL_authorization extends TLObject { + public static int constructor = 0x7bf2e6f6; + + public long hash; + public int flags; + public String device_model; + public String platform; + public String system_version; + public int api_id; + public String app_name; + public String app_version; + public int date_created; + public int date_active; + public String ip; + public String country; + public String region; + + public static TL_authorization TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_authorization.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_authorization", constructor)); + } else { + return null; + } + } + TL_authorization result = new TL_authorization(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + hash = stream.readInt64(exception); + flags = stream.readInt32(exception); + device_model = stream.readString(exception); + platform = stream.readString(exception); + system_version = stream.readString(exception); + api_id = stream.readInt32(exception); + app_name = stream.readString(exception); + app_version = stream.readString(exception); + date_created = stream.readInt32(exception); + date_active = stream.readInt32(exception); + ip = stream.readString(exception); + country = stream.readString(exception); + region = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(hash); + stream.writeInt32(flags); + stream.writeString(device_model); + stream.writeString(platform); + stream.writeString(system_version); + stream.writeInt32(api_id); + stream.writeString(app_name); + stream.writeString(app_version); + stream.writeInt32(date_created); + stream.writeInt32(date_active); + stream.writeString(ip); + stream.writeString(country); + stream.writeString(region); + } + } + + public static class Server_DH_Params extends TLObject { + public byte[] nonce; + public byte[] server_nonce; + public byte[] new_nonce_hash; + public byte[] encrypted_answer; + + public static Server_DH_Params TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Server_DH_Params result = null; + switch(constructor) { + case 0x79cb045d: + result = new TL_server_DH_params_fail(); + break; + case 0xd0e8075c: + result = new TL_server_DH_params_ok(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Server_DH_Params", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_server_DH_params_fail extends Server_DH_Params { + public static int constructor = 0x79cb045d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + new_nonce_hash = stream.readData(16, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeRaw(new_nonce_hash); + } + } + + public static class TL_server_DH_params_ok extends Server_DH_Params { + public static int constructor = 0xd0e8075c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + encrypted_answer = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeByteArray(encrypted_answer); + } + } + + public static class TL_protoMessage extends TLObject { + public static int constructor = 0x5bb8e511; + + public long msg_id; + public int seqno; + public int bytes; + public TLObject body; + + public static TL_protoMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_protoMessage.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_protoMessage", constructor)); + } else { + return null; + } + } + TL_protoMessage result = new TL_protoMessage(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + msg_id = stream.readInt64(exception); + seqno = stream.readInt32(exception); + bytes = stream.readInt32(exception); + body = TLClassStore.Instance().TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(msg_id); + stream.writeInt32(seqno); + stream.writeInt32(bytes); + body.serializeToStream(stream); + } + } + + public static class TL_geochats_located extends TLObject { + public static int constructor = 0x48feb267; + + public ArrayList results = new ArrayList<>(); + public ArrayList messages = new ArrayList<>(); + public ArrayList chats = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + + public static TL_geochats_located TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_geochats_located.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_geochats_located", constructor)); + } else { + return null; + } + } + TL_geochats_located result = new TL_geochats_located(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + results.add(TL_chatLocated.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + messages.add(GeoChatMessage.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData 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 = messages.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + messages.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); + } + } + } + + public static class TL_msgs_all_info extends TLObject { + public static int constructor = 0x8cc0d131; + + public ArrayList msg_ids = new ArrayList<>(); + public String info; + + public static TL_msgs_all_info TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_msgs_all_info.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_msgs_all_info", constructor)); + } else { + return null; + } + } + TL_msgs_all_info result = new TL_msgs_all_info(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + msg_ids.add(stream.readInt64(exception)); + } + info = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = msg_ids.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt64(msg_ids.get(a)); + } + stream.writeString(info); + } + } + + public static class contacts_Blocked extends TLObject { + public ArrayList blocked = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + public int count; + + public static contacts_Blocked TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + contacts_Blocked result = null; + switch(constructor) { + case 0x1c138d15: + result = new TL_contacts_blocked(); + break; + case 0x900802a1: + result = new TL_contacts_blockedSlice(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in contacts_Blocked", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_contacts_blocked extends contacts_Blocked { + public static int constructor = 0x1c138d15; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + blocked.add(TL_contactBlocked.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = blocked.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + blocked.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_contacts_blockedSlice extends contacts_Blocked { + public static int constructor = 0x900802a1; + + + public void readParams(AbsSerializedData stream, boolean exception) { + count = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + blocked.add(TL_contactBlocked.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(count); + stream.writeInt32(0x1cb5c415); + int count = blocked.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + blocked.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_encryptedChatWaiting extends EncryptedChat { + public static int constructor = 0x3bf703dc; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + admin_id = stream.readInt32(exception); + participant_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeInt64(access_hash); + stream.writeInt32(date); + stream.writeInt32(admin_id); + stream.writeInt32(participant_id); + } + } + + public static class TL_encryptedChatEmpty extends EncryptedChat { + public static int constructor = 0xab7ec0a0; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + } + } + + public static class TL_encryptedChatDiscarded extends EncryptedChat { + public static int constructor = 0x13d6dd27; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + } + } + + public static class TL_encryptedChat extends EncryptedChat { + public static int constructor = 0xfa56ce36; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + admin_id = stream.readInt32(exception); + participant_id = stream.readInt32(exception); + g_a_or_b = stream.readByteArray(exception); + key_fingerprint = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(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 extends EncryptedChat { + public static int constructor = 0xc878527e; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + admin_id = stream.readInt32(exception); + participant_id = stream.readInt32(exception); + g_a = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeInt64(access_hash); + stream.writeInt32(date); + stream.writeInt32(admin_id); + stream.writeInt32(participant_id); + stream.writeByteArray(g_a); + } + } + + public static class help_AppUpdate extends TLObject { + public int id; + public boolean critical; + public String url; + public String text; + + public static help_AppUpdate TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + help_AppUpdate result = null; + switch(constructor) { + case 0x8987f311: + result = new TL_help_appUpdate(); + break; + case 0xc45a6536: + result = new TL_help_noAppUpdate(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in help_AppUpdate", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_help_appUpdate extends help_AppUpdate { + public static int constructor = 0x8987f311; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + critical = stream.readBool(exception); + url = stream.readString(exception); + text = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class messages_Stickers extends TLObject { + public String hash; + public ArrayList stickers = new ArrayList<>(); + + public static messages_Stickers TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + messages_Stickers result = null; + switch(constructor) { + case 0xf1749a22: + result = new TL_messages_stickersNotModified(); + break; + case 0x8a8ecd32: + result = new TL_messages_stickers(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in messages_Stickers", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messages_stickersNotModified extends messages_Stickers { + public static int constructor = 0xf1749a22; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messages_stickers extends messages_Stickers { + public static int constructor = 0x8a8ecd32; + + + public void readParams(AbsSerializedData stream, boolean exception) { + hash = stream.readString(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + stickers.add(Document.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(hash); + stream.writeInt32(0x1cb5c415); + int count = stickers.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stickers.get(a).serializeToStream(stream); + } + } + } + + public static class TL_video extends Video { + public static int constructor = 0xee9f4a4d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + duration = stream.readInt32(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeInt32(duration); + stream.writeInt32(size); + thumb.serializeToStream(stream); + stream.writeInt32(dc_id); + stream.writeInt32(w); + stream.writeInt32(h); + } + } + + public static class TL_videoEmpty extends Video { + public static int constructor = 0xc10658a8; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + } + } + + public static class TL_messages_affectedMessages extends TLObject { + public static int constructor = 0x84d19185; + + public int pts; + public int pts_count; + + public static TL_messages_affectedMessages TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_messages_affectedMessages.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_messages_affectedMessages", constructor)); + } else { + return null; + } + } + TL_messages_affectedMessages result = new TL_messages_affectedMessages(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(pts); + stream.writeInt32(pts_count); } } @@ -3540,28 +7681,65 @@ public class TLRPC { public ArrayList messages = new ArrayList<>(); public ArrayList chats = new ArrayList<>(); public ArrayList users = new ArrayList<>(); + + public static geochats_Messages TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + geochats_Messages result = null; + switch(constructor) { + case 0xbc5863e8: + result = new TL_geochats_messagesSlice(); + break; + case 0xd1526db1: + result = new TL_geochats_messages(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in geochats_Messages", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_geochats_messagesSlice extends geochats_Messages { public static int constructor = 0xbc5863e8; - public void readParams(AbsSerializedData stream) { - count = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - messages.add((GeoChatMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public void readParams(AbsSerializedData stream, boolean exception) { + count = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.readInt32(); - count = stream.readInt32(); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + messages.add(GeoChatMessage.TLdeserialize(stream, stream.readInt32(exception), exception)); } - stream.readInt32(); - count = stream.readInt32(); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); } } @@ -3593,21 +7771,39 @@ public class TLRPC { public static int constructor = 0xd1526db1; - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - messages.add((GeoChatMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.readInt32(); - count = stream.readInt32(); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + messages.add(GeoChatMessage.TLdeserialize(stream, stream.readInt32(exception), exception)); } - stream.readInt32(); - count = stream.readInt32(); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); } } @@ -3634,243 +7830,48 @@ public class TLRPC { } } - public static class messages_SentMessage extends TLObject { - public int id; - public int date; - public MessageMedia media; - public int pts; - public int pts_count; - public ArrayList links = new ArrayList<>(); - public int seq; - } + public static class TL_stickerPack extends TLObject { + public static int constructor = 0x12b299d4; - public static class TL_messages_sentMessage extends messages_SentMessage { - public static int constructor = 0x4c3d47f3; + public String emoticon; + public ArrayList documents = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - date = stream.readInt32(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - pts = stream.readInt32(); - pts_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt32(date); - media.serializeToStream(stream); - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - - public static class TL_messages_sentMessageLink extends messages_SentMessage { - public static int constructor = 0x35a1a663; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - date = stream.readInt32(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - pts = stream.readInt32(); - pts_count = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - links.add((TL_contacts_link)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public static TL_stickerPack TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_stickerPack.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_stickerPack", constructor)); + } else { + return null; + } + } + TL_stickerPack result = new TL_stickerPack(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + emoticon = stream.readString(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + documents.add(stream.readInt64(exception)); } - seq = stream.readInt32(); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt32(date); - media.serializeToStream(stream); - stream.writeInt32(pts); - stream.writeInt32(pts_count); + stream.writeString(emoticon); stream.writeInt32(0x1cb5c415); - int count = links.size(); + int count = documents.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - links.get(a).serializeToStream(stream); - } - stream.writeInt32(seq); - } - } - - public static class EncryptedMessage extends TLObject { - public long random_id; - public int chat_id; - public int date; - public byte[] bytes; - public EncryptedFile file; - } - - public static class TL_encryptedMessageService extends EncryptedMessage { - public static int constructor = 0x23734b06; - - - public void readParams(AbsSerializedData stream) { - random_id = stream.readInt64(); - chat_id = stream.readInt32(); - date = stream.readInt32(); - bytes = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(random_id); - stream.writeInt32(chat_id); - stream.writeInt32(date); - stream.writeByteArray(bytes); - } - } - - public static class TL_encryptedMessage extends EncryptedMessage { - public static int constructor = 0xed18c118; - - - public void readParams(AbsSerializedData stream) { - random_id = stream.readInt64(); - chat_id = stream.readInt32(); - date = stream.readInt32(); - bytes = stream.readByteArray(); - file = (EncryptedFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(random_id); - stream.writeInt32(chat_id); - stream.writeInt32(date); - stream.writeByteArray(bytes); - file.serializeToStream(stream); - } - } - - public static class TL_contactSuggested extends TLObject { - public static int constructor = 0x3de191a1; - - public int user_id; - public int mutual_contacts; - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - mutual_contacts = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData 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; - public byte[] new_nonce_hash; - public byte[] encrypted_answer; - } - - public static class TL_server_DH_params_fail extends Server_DH_Params { - public static int constructor = 0x79cb045d; - - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - new_nonce_hash = stream.readData(16); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeRaw(new_nonce_hash); - } - } - - public static class TL_server_DH_params_ok extends Server_DH_Params { - public static int constructor = 0xd0e8075c; - - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - encrypted_answer = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeByteArray(encrypted_answer); - } - } - - public static class TL_msg_copy extends TLObject { - public static int constructor = 0xe06046b2; - - public TL_protoMessage orig_message; - - public void readParams(AbsSerializedData stream) { - orig_message = (TL_protoMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - orig_message.serializeToStream(stream); - } - } - - public static class TL_contacts_importedContacts extends TLObject { - public static int constructor = 0xad524315; - - public ArrayList imported = new ArrayList<>(); - public ArrayList retry_contacts = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - imported.add((TL_importedContact)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - retry_contacts.add(stream.readInt64()); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = imported.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - imported.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = retry_contacts.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - stream.writeInt64(retry_contacts.get(a)); - } - stream.writeInt32(0x1cb5c415); - count = users.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - users.get(a).serializeToStream(stream); + stream.writeInt64(documents.get(a)); } } } @@ -3881,9 +7882,22 @@ public class TLRPC { public String feature; public String description; - public void readParams(AbsSerializedData stream) { - feature = stream.readString(); - description = stream.readString(); + public static TL_disabledFeature TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_disabledFeature.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_disabledFeature", constructor)); + } else { + return null; + } + } + TL_disabledFeature result = new TL_disabledFeature(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + feature = stream.readString(exception); + description = stream.readString(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -3893,2219 +7907,50 @@ public class TLRPC { } } - public static class TL_futureSalt extends TLObject { - public static int constructor = 0x0949d9dc; - - public int valid_since; - public int valid_until; - public long salt; - - public void readParams(AbsSerializedData stream) { - valid_since = stream.readInt32(); - valid_until = stream.readInt32(); - salt = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(valid_since); - stream.writeInt32(valid_until); - stream.writeInt64(salt); - } - } - - public static class Update extends TLObject { - public int chat_id; - public int max_date; - public int date; - public int user_id; - public ContactLink my_link; - public ContactLink foreign_link; - public ArrayList messages = new ArrayList<>(); - public int pts; - public int pts_count; - public int max_id; - public int version; - public WebPage webpage; - public String type; - public MessageMedia media; - public boolean popup; - public NotifyPeer peer; - public PeerNotifySettings notify_settings; - public SendMessageAction action; - public String first_name; - public String last_name; - public String username; - public String phone; - public int qts; - public int id; - public long random_id; - public ArrayList dc_options = new ArrayList<>(); - public ChatParticipants participants; - public TL_privacyKeyStatusTimestamp key; - public ArrayList rules = new ArrayList<>(); - public EncryptedChat chat; - public boolean blocked; - public long auth_key_id; - public String device; - public String location; - public UserProfilePhoto photo; - public boolean previous; - public int inviter_id; - public UserStatus status; - } - - public static class TL_updateEncryptedMessagesRead extends Update { - public static int constructor = 0x38fe25b7; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - max_date = stream.readInt32(); - date = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(max_date); - stream.writeInt32(date); - } - } - - public static class TL_updateContactLink extends Update { - public static int constructor = 0x9d2e67c5; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - my_link = (ContactLink)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - foreign_link = (ContactLink)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - my_link.serializeToStream(stream); - foreign_link.serializeToStream(stream); - } - } - - public static class TL_updateReadMessages extends Update { - public static int constructor = 0x2e5ab668; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - messages.add(stream.readInt32()); - } - pts = stream.readInt32(); - pts_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - stream.writeInt32(messages.get(a)); - } - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - - public static class TL_updateReadHistoryInbox extends Update { - public static int constructor = 0x9961fd5c; - - public Peer peer; - - public void readParams(AbsSerializedData stream) { - peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - max_id = stream.readInt32(); - pts = stream.readInt32(); - pts_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - stream.writeInt32(max_id); - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - - public static class TL_updateChatParticipantDelete extends Update { - public static int constructor = 0x6e5f8c22; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - user_id = stream.readInt32(); - version = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(user_id); - stream.writeInt32(version); - } - } - - public static class TL_updateReadHistoryOutbox extends Update { - public static int constructor = 0x2f2f21bf; - - public Peer peer; - - public void readParams(AbsSerializedData stream) { - peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - max_id = stream.readInt32(); - pts = stream.readInt32(); - pts_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - stream.writeInt32(max_id); - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - - public static class TL_updateWebPage extends Update { - public static int constructor = 0x2cc36971; - - - public void readParams(AbsSerializedData stream) { - webpage = (WebPage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - webpage.serializeToStream(stream); - } - } - - public static class TL_updateServiceNotification extends Update { - public static int constructor = 0x382dd3e4; - - public String message; - - public void readParams(AbsSerializedData stream) { - type = stream.readString(); - message = stream.readString(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - popup = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(type); - stream.writeString(message); - media.serializeToStream(stream); - stream.writeBool(popup); - } - } - - public static class TL_updateNotifySettings extends Update { - public static int constructor = 0xbec268ef; - - - public void readParams(AbsSerializedData stream) { - peer = (NotifyPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - notify_settings = (PeerNotifySettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - notify_settings.serializeToStream(stream); - } - } - - public static class TL_updateUserTyping extends Update { - public static int constructor = 0x5c486927; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - action = (SendMessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - action.serializeToStream(stream); - } - } - - public static class TL_updateChatUserTyping extends Update { - public static int constructor = 0x9a65ea1f; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - user_id = stream.readInt32(); - action = (SendMessageAction) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(user_id); - action.serializeToStream(stream); - } - } - - public static class TL_updateUserName extends Update { - public static int constructor = 0xa7332b73; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - username = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(username); - } - } - - public static class TL_updateNewEncryptedMessage extends Update { - public static int constructor = 0x12bcbd9a; - - public EncryptedMessage message; - - public void readParams(AbsSerializedData stream) { - message = (EncryptedMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - qts = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - message.serializeToStream(stream); - stream.writeInt32(qts); - } - } - - public static class TL_updateNewMessage extends Update { - public static int constructor = 0x1f2b0afd; - - public Message message; - - public void readParams(AbsSerializedData stream) { - message = (Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - pts = stream.readInt32(); - pts_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - message.serializeToStream(stream); - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - - public static class TL_updateMessageID extends Update { - public static int constructor = 0x4e90bfd6; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - random_id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt64(random_id); - } - } - - public static class TL_updateDeleteMessages extends Update { - public static int constructor = 0xa20db0e5; - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - messages.add(stream.readInt32()); - } - pts = stream.readInt32(); - pts_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - stream.writeInt32(messages.get(a)); - } - stream.writeInt32(pts); - stream.writeInt32(pts_count); - } - } - - public static class TL_updateEncryptedChatTyping extends Update { - public static int constructor = 0x1710f156; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - } - } - - public static class TL_updateDcOptions extends Update { - public static int constructor = 0x8e5e9873; - - - public void readParams(AbsSerializedData 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(AbsSerializedData 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; - - - public void readParams(AbsSerializedData stream) { - participants = (ChatParticipants)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - participants.serializeToStream(stream); - } - } - - public static class TL_updateUserPhone extends Update { - public static int constructor = 0x12b9417b; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - phone = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeString(phone); - } - } - - public static class TL_updatePrivacy extends Update { - public static int constructor = 0xee3b272a; - - - public void readParams(AbsSerializedData stream) { - key = (TL_privacyKeyStatusTimestamp)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - rules.add((PrivacyRule)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - key.serializeToStream(stream); - stream.writeInt32(0x1cb5c415); - int count = rules.size(); - stream.writeInt32(count); - for (PrivacyRule rule : rules) { - rule.serializeToStream(stream); - } - } - } - - public static class TL_updateEncryption extends Update { - public static int constructor = 0xb4a2e88d; - - - public void readParams(AbsSerializedData stream) { - chat = (EncryptedChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - date = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - chat.serializeToStream(stream); - stream.writeInt32(date); - } - } - - public static class TL_updateUserBlocked extends Update { - public static int constructor = 0x80ece81a; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - blocked = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeBool(blocked); - } - } - - public static class TL_updateActivation extends Update { - public static int constructor = 0x6f690963; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - } - } - - public static class TL_updateNewAuthorization extends Update { - public static int constructor = 0x8f06529a; - - - public void readParams(AbsSerializedData stream) { - auth_key_id = stream.readInt64(); - date = stream.readInt32(); - device = stream.readString(); - location = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(auth_key_id); - stream.writeInt32(date); - stream.writeString(device); - stream.writeString(location); - } - } - - public static class TL_updateNewGeoChatMessage extends Update { - public static int constructor = 0x5a68e3f7; - - public GeoChatMessage message; - - public void readParams(AbsSerializedData stream) { - message = (GeoChatMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - message.serializeToStream(stream); - } - } - - public static class TL_updateUserPhoto extends Update { - public static int constructor = 0x95313b0c; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - date = stream.readInt32(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - previous = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt32(date); - photo.serializeToStream(stream); - stream.writeBool(previous); - } - } - - public static class TL_updateContactRegistered extends Update { - public static int constructor = 0x2575bbb9; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - date = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt32(date); - } - } - - public static class TL_updateChatParticipantAdd extends Update { - public static int constructor = 0x3a0eeb22; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - user_id = stream.readInt32(); - inviter_id = stream.readInt32(); - version = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData 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; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - status.serializeToStream(stream); - } - } - - 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(AbsSerializedData 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(AbsSerializedData 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; - public long query_id; - } - - public static class TL_rpc_error extends RpcError { - public static int constructor = 0x2144ca19; - - - public void readParams(AbsSerializedData stream) { - error_code = stream.readInt32(); - error_message = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(error_code); - stream.writeString(error_message); - } - } - - public static class TL_rpc_req_error extends RpcError { - public static int constructor = 0x7ae432f5; - - - public void readParams(AbsSerializedData stream) { - query_id = stream.readInt64(); - error_code = stream.readInt32(); - error_message = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(query_id); - stream.writeInt32(error_code); - stream.writeString(error_message); - } - } - - public static class TL_inputEncryptedFile extends InputEncryptedFile { - public static int constructor = 0x5a17b5e5; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - } - } - - public static class TL_inputEncryptedFileBigUploaded extends InputEncryptedFile { - public static int constructor = 0x2dc173c8; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - parts = stream.readInt32(); - key_fingerprint = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt32(parts); - stream.writeInt32(key_fingerprint); - } - } - - public static class TL_inputEncryptedFileEmpty extends InputEncryptedFile { - public static int constructor = 0x1837c364; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputEncryptedFileUploaded extends InputEncryptedFile { - public static int constructor = 0x64bd0306; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - parts = stream.readInt32(); - md5_checksum = stream.readString(); - key_fingerprint = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt32(parts); - stream.writeString(md5_checksum); - stream.writeInt32(key_fingerprint); - } - } - - public static class DecryptedMessageAction extends TLObject { - public int start_seq_no; - public int end_seq_no; - public int ttl_seconds; - public int layer; - public ArrayList random_ids = new ArrayList<>(); - public long exchange_id; - public long key_fingerprint; - public byte[] g_b; - public SendMessageAction action; - public byte[] g_a; - } - - public static class TL_decryptedMessageActionSetMessageTTL extends DecryptedMessageAction { - public static int constructor = 0xa1733aec; - - public void readParams(AbsSerializedData stream) { - ttl_seconds = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(ttl_seconds); - } - } - - public static class TL_decryptedMessageActionFlushHistory extends DecryptedMessageAction { - public static int constructor = 0x6719e45c; - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_decryptedMessageActionAcceptKey extends DecryptedMessageAction { - public static int constructor = 0x6fe1735b; - - - public void readParams(AbsSerializedData stream) { - exchange_id = stream.readInt64(); - g_b = stream.readByteArray(); - key_fingerprint = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(exchange_id); - stream.writeByteArray(g_b); - stream.writeInt64(key_fingerprint); - } - } - - public static class TL_decryptedMessageActionResend extends DecryptedMessageAction { - public static int constructor = 0x511110b0; - - - public void readParams(AbsSerializedData stream) { - start_seq_no = stream.readInt32(); - end_seq_no = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(start_seq_no); - stream.writeInt32(end_seq_no); - } - } - - public static class TL_decryptedMessageActionNotifyLayer extends DecryptedMessageAction { - public static int constructor = 0xf3048883; - - - public void readParams(AbsSerializedData stream) { - layer = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(layer); - } - } - - public static class TL_decryptedMessageActionReadMessages extends DecryptedMessageAction { - public static int constructor = 0xc4f40be; - - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - random_ids.add(stream.readInt64()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = random_ids.size(); - stream.writeInt32(count); - for (Long random_id : random_ids) { - stream.writeInt64(random_id); - } - } - } - - public static class TL_decryptedMessageActionRequestKey extends DecryptedMessageAction { - public static int constructor = 0xf3c9611b; - - - public void readParams(AbsSerializedData stream) { - exchange_id = stream.readInt64(); - g_a = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(exchange_id); - stream.writeByteArray(g_a); - } - } - - public static class TL_decryptedMessageActionTyping extends DecryptedMessageAction { - public static int constructor = 0xccb27641; - - - public void readParams(AbsSerializedData stream) { - action = (SendMessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - action.serializeToStream(stream); - } - } - - public static class TL_server_DH_inner_data extends TLObject { - public static int constructor = 0xb5890dba; - - public byte[] nonce; - public byte[] server_nonce; - public int g; - public byte[] dh_prime; - public byte[] g_a; - public int server_time; - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - g = stream.readInt32(); - dh_prime = stream.readByteArray(); - g_a = stream.readByteArray(); - server_time = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeInt32(g); - stream.writeByteArray(dh_prime); - stream.writeByteArray(g_a); - stream.writeInt32(server_time); - } - } - - public static class TL_new_session_created extends TLObject { - public static int constructor = 0x9ec20908; - - public long first_msg_id; - public long unique_id; - public long server_salt; - - public void readParams(AbsSerializedData stream) { - first_msg_id = stream.readInt64(); - unique_id = stream.readInt64(); - server_salt = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(first_msg_id); - stream.writeInt64(unique_id); - stream.writeInt64(server_salt); - } - } - - public static class messages_AllStickers extends TLObject { - public String hash; - public ArrayList packs = new ArrayList<>(); - public ArrayList documents = new ArrayList<>(); - } - - public static class TL_messages_allStickers extends messages_AllStickers { - public static int constructor = 0xdcef3102; - - - public void readParams(AbsSerializedData stream) { - hash = stream.readString(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - packs.add((TL_stickerPack)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - documents.add((Document)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(hash); - stream.writeInt32(0x1cb5c415); - int count = packs.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - packs.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = documents.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - documents.get(a).serializeToStream(stream); - } - } - } - - public static class TL_messages_allStickersNotModified extends messages_AllStickers { - public static int constructor = 0xe86602c3; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class account_Password extends TLObject { - public byte[] current_salt; - public byte[] new_salt; - public String hint; - public boolean has_recovery; - public String email_unconfirmed_pattern; - } - - public static class TL_account_password extends account_Password { - public static int constructor = 0x7c18141c; - - - public void readParams(AbsSerializedData stream) { - current_salt = stream.readByteArray(); - new_salt = stream.readByteArray(); - hint = stream.readString(); - has_recovery = stream.readBool(); - email_unconfirmed_pattern = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(current_salt); - stream.writeByteArray(new_salt); - stream.writeString(hint); - stream.writeBool(has_recovery); - stream.writeString(email_unconfirmed_pattern); - } - } - - public static class TL_account_noPassword extends account_Password { - public static int constructor = 0x96dabc18; - - - public void readParams(AbsSerializedData stream) { - new_salt = stream.readByteArray(); - email_unconfirmed_pattern = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(new_salt); - stream.writeString(email_unconfirmed_pattern); - } - } - - public static class UserProfilePhoto extends TLObject { - public long photo_id; - public FileLocation photo_small; - public FileLocation photo_big; - } - - public static class TL_userProfilePhotoEmpty extends UserProfilePhoto { - public static int constructor = 0x4f11bae1; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_userProfilePhoto extends UserProfilePhoto { - public static int constructor = 0xd559d8c8; - - - public void readParams(AbsSerializedData stream) { - photo_id = stream.readInt64(); - photo_small = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - photo_big = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(photo_id); - photo_small.serializeToStream(stream); - photo_big.serializeToStream(stream); - } - } - - public static class Photo extends TLObject { - public long id; - public long access_hash; - public int user_id; - public int date; - public String caption; - public GeoPoint geo; - public ArrayList sizes = new ArrayList<>(); - } - - public static class TL_photo extends Photo { - public static int constructor = 0x22b56751; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - user_id = stream.readInt32(); - date = stream.readInt32(); - caption = stream.readString(); - geo = (GeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - PhotoSize size = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - if (size != null) { - sizes.add(size); - } - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(user_id); - stream.writeInt32(date); - stream.writeString(caption); - geo.serializeToStream(stream); - stream.writeInt32(0x1cb5c415); - int count = sizes.size(); - stream.writeInt32(count); - for (PhotoSize size : sizes) { - size.serializeToStream(stream); - } - } - } - - public static class TL_photoEmpty extends Photo { - public static int constructor = 0x2331b22d; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - } - } - - public static class TL_encryptedChatWaiting extends EncryptedChat { - public static int constructor = 0x3bf703dc; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - access_hash = stream.readInt64(); - date = stream.readInt32(); - admin_id = stream.readInt32(); - participant_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt64(access_hash); - stream.writeInt32(date); - stream.writeInt32(admin_id); - stream.writeInt32(participant_id); - } - } - - public static class TL_encryptedChatEmpty extends EncryptedChat { - public static int constructor = 0xab7ec0a0; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - } - } - - public static class TL_encryptedChatDiscarded extends EncryptedChat { - public static int constructor = 0x13d6dd27; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - } - } - - public static class TL_encryptedChat extends EncryptedChat { - public static int constructor = 0xfa56ce36; - - - public void readParams(AbsSerializedData 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(); - key_fingerprint = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(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 extends EncryptedChat { - public static int constructor = 0xc878527e; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - access_hash = stream.readInt64(); - date = stream.readInt32(); - admin_id = stream.readInt32(); - participant_id = stream.readInt32(); - g_a = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt64(access_hash); - stream.writeInt32(date); - stream.writeInt32(admin_id); - stream.writeInt32(participant_id); - stream.writeByteArray(g_a); - } - } - - public static class TL_geochats_statedMessage extends TLObject { - public static int constructor = 0x17b1578b; - - public GeoChatMessage message; - public ArrayList chats = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - public int seq; - - public void readParams(AbsSerializedData stream) { - message = (GeoChatMessage)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())); - } - seq = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData 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); - } - stream.writeInt32(seq); - } - } - - public static class TL_contact extends TLObject { - public static int constructor = 0xf911c994; - - public int user_id; - public boolean mutual; - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - mutual = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeBool(mutual); - } - } - - public static class TL_config extends TLObject { - public static int constructor = 0x68bac247; - - public int date; - public int expires; - public boolean test_mode; - public int this_dc; - public ArrayList dc_options = new ArrayList<>(); - public int chat_size_max; - public int broadcast_size_max; - public int forwarded_count_max; - public int online_update_period_ms; - public int offline_blur_timeout_ms; - public int offline_idle_timeout_ms; - public int online_cloud_timeout_ms; - public int notify_cloud_delay_ms; - public int notify_default_delay_ms; - public int chat_big_size; - public ArrayList disabled_features = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - date = stream.readInt32(); - expires = stream.readInt32(); - test_mode = stream.readBool(); - this_dc = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - dc_options.add((TL_dcOption)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - chat_size_max = stream.readInt32(); - broadcast_size_max = stream.readInt32(); - forwarded_count_max = stream.readInt32(); - online_update_period_ms = stream.readInt32(); - offline_blur_timeout_ms = stream.readInt32(); - offline_idle_timeout_ms = stream.readInt32(); - online_cloud_timeout_ms = stream.readInt32(); - notify_cloud_delay_ms = stream.readInt32(); - notify_default_delay_ms = stream.readInt32(); - chat_big_size = stream.readInt32(); - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - disabled_features.add((TL_disabledFeature)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(date); - stream.writeInt32(expires); - stream.writeBool(test_mode); - stream.writeInt32(this_dc); - stream.writeInt32(0x1cb5c415); - int count = dc_options.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - dc_options.get(a).serializeToStream(stream); - } - stream.writeInt32(chat_size_max); - stream.writeInt32(broadcast_size_max); - stream.writeInt32(forwarded_count_max); - stream.writeInt32(online_update_period_ms); - stream.writeInt32(offline_blur_timeout_ms); - stream.writeInt32(offline_idle_timeout_ms); - stream.writeInt32(online_cloud_timeout_ms); - stream.writeInt32(notify_cloud_delay_ms); - stream.writeInt32(notify_default_delay_ms); - stream.writeInt32(chat_big_size); - stream.writeInt32(0x1cb5c415); - count = disabled_features.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - disabled_features.get(a).serializeToStream(stream); - } - } - } - - public static class TL_help_support extends TLObject { - public static int constructor = 0x17c6b5f6; - - public String phone_number; - public User user; - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - user = (User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(phone_number); - user.serializeToStream(stream); - } - } - - public static class TL_help_getSupport extends TLObject { - public static int constructor = 0x9cdf08cd; - - public Class responseClass () { - return TL_help_support.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_auth_sendSms extends TLObject { - public static int constructor = 0xda9f3e8; - - public String phone_number; - public String phone_code_hash; - - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - phone_code_hash = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(phone_number); - stream.writeString(phone_code_hash); - } - } - - public static class TL_messages_readMessageContents extends TLObject { - public static int constructor = 0x36a73f77; - - public ArrayList id = new ArrayList<>(); - - public Class responseClass () { - return TL_messages_affectedMessages.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - id.add(stream.readInt32()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = id.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - stream.writeInt32(id.get(a)); - } - } - } - - public static class TL_account_getPrivacy extends TLObject { - public static int constructor = 0xdadbc950; - - public TL_inputPrivacyKeyStatusTimestamp key; - - public Class responseClass () { - return TL_account_privacyRules.class; - } - - public void readParams(AbsSerializedData stream) { - key = (TL_inputPrivacyKeyStatusTimestamp)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - key.serializeToStream(stream); - } - } - - public static class TL_account_setPrivacy extends TLObject { - public static int constructor = 0xc9f81ce8; - - public TL_inputPrivacyKeyStatusTimestamp key; - public ArrayList rules = new ArrayList<>(); - - public Class responseClass () { - return TL_account_privacyRules.class; - } - - public void readParams(AbsSerializedData stream) { - key = (TL_inputPrivacyKeyStatusTimestamp)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - rules.add((InputPrivacyRule)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - key.serializeToStream(stream); - stream.writeInt32(0x1cb5c415); - int count = rules.size(); - stream.writeInt32(count); - for (InputPrivacyRule rule : rules) { - rule.serializeToStream(stream); - } - } - } - - public static class TL_account_deleteAccount extends TLObject { - public static int constructor = 0x418d4e0b; - - public String reason; - - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - reason = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(reason); - } - } - - public static class TL_account_getAccountTTL extends TLObject { - public static int constructor = 0x8fc711d; - - - public Class responseClass () { - return TL_accountDaysTTL.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_account_setAccountTTL extends TLObject { - public static int constructor = 0x2442485e; - - public TL_accountDaysTTL ttl; - - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - ttl = (TL_accountDaysTTL)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - ttl.serializeToStream(stream); - } - } - - public static class TL_account_sendChangePhoneCode extends TLObject { - public static int constructor = 0xa407a8f4; - - public String phone_number; - - public Class responseClass() { - return TL_account_sentChangePhoneCode.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(phone_number); - } - } - - public static class TL_account_changePhone extends TLObject { - public static int constructor = 0x70c32edb; - - public String phone_number; - public String phone_code_hash; - public String phone_code; - - public Class responseClass () { - return User.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - phone_code_hash = stream.readString(); - phone_code = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(phone_number); - stream.writeString(phone_code_hash); - stream.writeString(phone_code); - } - } - - public static class TL_account_updateDeviceLocked extends TLObject { - public static int constructor = 0x38df3532; - - public int period; - - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - period = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(period); - } - } - - public static class TL_account_getAuthorizations extends TLObject { - public static int constructor = 0xe320c158; - - - public Class responseClass () { - return TL_account_authorizations.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_account_resetAuthorization extends TLObject { - public static int constructor = 0xdf77f3bc; - - public long hash; - - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(hash); - } - } - - public static class TL_messages_getAllStickers extends TLObject { - public static int constructor = 0xaa3bc868; - - public String hash; - - public Class responseClass () { - return messages_AllStickers.class; - } - - public void readParams(AbsSerializedData stream) { - hash = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(hash); - } - } - - public static class TL_messages_getWebPagePreview extends TLObject { - public static int constructor = 0x25223e24; - - public String message; - - public Class responseClass () { - return MessageMedia.class; - } - - public void readParams(AbsSerializedData stream) { - message = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(message); - } - } - - public static class TL_account_checkUsername extends TLObject { - public static int constructor = 0x2714d86c; - - public String username; - - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - username = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(username); - } - } - - public static class TL_account_updateUsername extends TLObject { - public static int constructor = 0x3e0bdd7c; - - public String username; - - public Class responseClass () { - return User.class; - } - - public void readParams(AbsSerializedData stream) { - username = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(username); - } - } - - public static class TL_contacts_resolveUsername extends TLObject { - public static int constructor = 0xbf0131c; - - public String username; - - public Class responseClass () { - return User.class; - } - - public void readParams(AbsSerializedData stream) { - username = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(username); - } - } - - public static class InputAudio extends TLObject { - public long id; - public long access_hash; - } - - public static class TL_inputAudio extends InputAudio { - public static int constructor = 0x77d440ff; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messages_chats extends TLObject { - public static int constructor = 0x64ff9fd5; - - public ArrayList chats = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = chats.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - chats.get(a).serializeToStream(stream); - } - } - } - - 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(AbsSerializedData 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(AbsSerializedData 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; - public ArrayList participants = new ArrayList<>(); - public int version; - } - - public static class TL_chatParticipants extends ChatParticipants { - public static int constructor = 0x7841b415; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - admin_id = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - participants.add((TL_chatParticipant)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - version = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt32(admin_id); - stream.writeInt32(0x1cb5c415); - int count = participants.size(); - stream.writeInt32(count); - for (TL_chatParticipant participant : participants) { - participant.serializeToStream(stream); - } - stream.writeInt32(version); - } - } - - public static class TL_chatParticipantsForbidden extends ChatParticipants { - public static int constructor = 0xfd2bb8a; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - } - } - - public static class DecryptedMessageMedia extends TLObject { - public long id; - public long access_hash; - public int date; - public PhotoSize thumbImage; - public byte[] thumb; - public int thumb_w; - public int thumb_h; - public String file_name; - public String mime_type; - public int size; - public int dc_id; - public ArrayList attributes = new ArrayList<>(); - public byte[] key; - public byte[] iv; - public double lat; - public double _long; - 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_decryptedMessageMediaExternalDocument extends DecryptedMessageMedia { - public static int constructor = 0xfa95b0dd; - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - date = stream.readInt32(); - mime_type = stream.readString(); - size = stream.readInt32(); - thumbImage = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - dc_id = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - attributes.add((DocumentAttribute)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(date); - stream.writeString(mime_type); - stream.writeInt32(size); - thumbImage.serializeToStream(stream); - stream.writeInt32(dc_id); - stream.writeInt32(0x1cb5c415); - int count = attributes.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - attributes.get(a).serializeToStream(stream); - } - } - } - - public static class TL_decryptedMessageMediaDocument extends DecryptedMessageMedia { - public static int constructor = 0xb095434b; - - - public void readParams(AbsSerializedData stream) { - 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(AbsSerializedData stream) { - stream.writeInt32(constructor); - 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(AbsSerializedData stream) { - lat = stream.readDouble(); - _long = stream.readDouble(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeDouble(lat); - stream.writeDouble(_long); - } - } - - public static class TL_decryptedMessageMediaAudio extends DecryptedMessageMedia { - public static int constructor = 0x57e0a9cb; - - - public void readParams(AbsSerializedData stream) { - duration = stream.readInt32(); - mime_type = stream.readString(); - size = stream.readInt32(); - key = stream.readByteArray(); - iv = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(duration); - stream.writeString(mime_type); - stream.writeInt32(size); - stream.writeByteArray(key); - stream.writeByteArray(iv); - } - } - - public static class TL_decryptedMessageMediaVideo extends DecryptedMessageMedia { - public static int constructor = 0x524a415d; - - - public void readParams(AbsSerializedData stream) { - thumb = stream.readByteArray(); - thumb_w = stream.readInt32(); - thumb_h = stream.readInt32(); - duration = stream.readInt32(); - mime_type = stream.readString(); - w = stream.readInt32(); - h = stream.readInt32(); - size = stream.readInt32(); - key = stream.readByteArray(); - iv = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(thumb); - stream.writeInt32(thumb_w); - stream.writeInt32(thumb_h); - stream.writeInt32(duration); - stream.writeString(mime_type); - stream.writeInt32(w); - stream.writeInt32(h); - stream.writeInt32(size); - stream.writeByteArray(key); - stream.writeByteArray(iv); - } - } - - public static class TL_decryptedMessageMediaContact extends DecryptedMessageMedia { - public static int constructor = 0x588a0a97; - - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - first_name = stream.readString(); - last_name = stream.readString(); - user_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(phone_number); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeInt32(user_id); - } - } - - public static class TL_decryptedMessageMediaEmpty extends DecryptedMessageMedia { - public static int constructor = 0x89f5c4a; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_decryptedMessageMediaPhoto extends DecryptedMessageMedia { - public static int constructor = 0x32798a8c; - - - public void readParams(AbsSerializedData stream) { - thumb = stream.readByteArray(); - thumb_w = stream.readInt32(); - thumb_h = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - size = stream.readInt32(); - key = stream.readByteArray(); - iv = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(thumb); - stream.writeInt32(thumb_w); - stream.writeInt32(thumb_h); - stream.writeInt32(w); - stream.writeInt32(h); - stream.writeInt32(size); - stream.writeByteArray(key); - stream.writeByteArray(iv); - } - } - - public static class TL_chatParticipant extends TLObject { - public static int constructor = 0xc8d7493e; - - public int user_id; - public int inviter_id; - public int date; - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - inviter_id = stream.readInt32(); - date = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt32(inviter_id); - stream.writeInt32(date); - } - } - - public static class Chat extends TLObject { - public int id; - public String title; - public int date; - public long access_hash; - public String address; - public String venue; - public GeoPoint geo; - public ChatPhoto photo; - public int participants_count; - public boolean checked_in; - public int version; - public boolean left; - //Smart Notifications - public java.util.Queue sound_timestamps = null; - // - } - - public static class TL_chatForbidden extends Chat { - public static int constructor = 0xfb0ccc41; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - title = stream.readString(); - date = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(title); - stream.writeInt32(date); - } - } - - public static class TL_geoChat extends Chat { - public static int constructor = 0x75eaea5a; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - access_hash = stream.readInt64(); - title = stream.readString(); - address = stream.readString(); - venue = stream.readString(); - geo = (GeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - photo = (ChatPhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - participants_count = stream.readInt32(); - date = stream.readInt32(); - checked_in = stream.readBool(); - version = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeInt64(access_hash); - stream.writeString(title); - stream.writeString(address); - stream.writeString(venue); - geo.serializeToStream(stream); - photo.serializeToStream(stream); - stream.writeInt32(participants_count); - stream.writeInt32(date); - stream.writeBool(checked_in); - stream.writeInt32(version); - } - } - public static class TL_chat extends Chat { - public static int constructor = 0x6e9c9bc7; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - title = stream.readString(); - photo = (ChatPhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - participants_count = stream.readInt32(); - date = stream.readInt32(); - left = stream.readBool(); - version = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(title); - photo.serializeToStream(stream); - stream.writeInt32(participants_count); - stream.writeInt32(date); - stream.writeBool(left); - stream.writeInt32(version); - } - } - public static class storage_FileType extends TLObject { + + public static storage_FileType TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + storage_FileType result = null; + switch(constructor) { + case 0xaa963b05: + result = new TL_storage_fileUnknown(); + break; + case 0xb3cea0e4: + result = new TL_storage_fileMp4(); + break; + case 0x1081464c: + result = new TL_storage_fileWebp(); + break; + case 0xa4f63c0: + result = new TL_storage_filePng(); + break; + case 0xcae1aadf: + result = new TL_storage_fileGif(); + break; + case 0xae1e508d: + result = new TL_storage_filePdf(); + break; + case 0x528a0677: + result = new TL_storage_fileMp3(); + break; + case 0x7efe0e: + result = new TL_storage_fileJpeg(); + break; + case 0x4b09ebbc: + result = new TL_storage_fileMov(); + break; + case 0x40bc6f52: + result = new TL_storage_filePartial(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in storage_FileType", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_storage_fileUnknown extends storage_FileType { @@ -6117,6 +7962,15 @@ public class TLRPC { } } + public static class TL_storage_fileMp4 extends storage_FileType { + public static int constructor = 0xb3cea0e4; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_storage_fileWebp extends storage_FileType { public static int constructor = 0x1081464c; @@ -6153,15 +8007,6 @@ public class TLRPC { } } - public static class TL_storage_fileMov extends storage_FileType { - public static int constructor = 0x4b09ebbc; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - public static class TL_storage_fileMp3 extends storage_FileType { public static int constructor = 0x528a0677; @@ -6180,6 +8025,15 @@ public class TLRPC { } } + public static class TL_storage_fileMov extends storage_FileType { + public static int constructor = 0x4b09ebbc; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_storage_filePartial extends storage_FileType { public static int constructor = 0x40bc6f52; @@ -6189,522 +8043,255 @@ public class TLRPC { } } - public static class TL_storage_fileMp4 extends storage_FileType { - public static int constructor = 0xb3cea0e4; + public static class TL_account_authorizations extends TLObject { + public static int constructor = 0x1250abde; + public ArrayList authorizations = new ArrayList<>(); - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class MessagesFilter extends TLObject { - } - - public static class TL_inputMessagesFilterVideo extends MessagesFilter { - public static int constructor = 0x9fc00e65; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputMessagesFilterEmpty extends MessagesFilter { - public static int constructor = 0x57e2f66c; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputMessagesFilterPhotos extends MessagesFilter { - public static int constructor = 0x9609a51c; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputMessagesFilterPhotoVideo extends MessagesFilter { - public static int constructor = 0x56e9f0e4; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputMessagesFilterDocument extends MessagesFilter { - public static int constructor = 0x9eddf188; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputMessagesFilterAudio extends MessagesFilter { - public static int constructor = 0xcfc87522; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - 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(AbsSerializedData stream) { - req_msg_id = stream.readInt64(); - info = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(req_msg_id); - stream.writeString(info); - } - } - - public static class TL_fileLocation extends FileLocation { - public static int constructor = 0x53d69076; - - - public void readParams(AbsSerializedData stream) { - dc_id = stream.readInt32(); - volume_id = stream.readInt64(); - local_id = stream.readInt32(); - secret = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - volume_id = stream.readInt64(); - local_id = stream.readInt32(); - secret = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messages_message extends messages_Message { - public static int constructor = 0xff90c417; - - - public void readParams(AbsSerializedData 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 static TL_account_authorizations TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_account_authorizations.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_account_authorizations", constructor)); + } else { + return null; + } } + TL_account_authorizations result = new TL_account_authorizations(); + result.readParams(stream, exception); + return result; } - public void serializeToStream(AbsSerializedData 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); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.writeInt32(0x1cb5c415); - count = users.size(); - stream.writeInt32(count); + int count = stream.readInt32(exception); 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; - - public ArrayList results = new ArrayList<>(); - public ArrayList messages = new ArrayList<>(); - public ArrayList chats = new ArrayList<>(); - public ArrayList users = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - results.add((TL_chatLocated)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - messages.add((GeoChatMessage)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())); + authorizations.add(TL_authorization.TLdeserialize(stream, stream.readInt32(exception), exception)); } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt32(0x1cb5c415); - int count = results.size(); + int count = authorizations.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - results.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - messages.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); + authorizations.get(a).serializeToStream(stream); } } } - public static class TL_inputGeoChat extends TLObject { - public static int constructor = 0x74d456fa; + public static class TL_p_q_inner_data extends TLObject { + public static int constructor = 0x83c95aec; - public int chat_id; + public byte[] pq; + public byte[] p; + public byte[] q; + public byte[] nonce; + public byte[] server_nonce; + public byte[] new_nonce; + + public static TL_p_q_inner_data TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_p_q_inner_data.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_p_q_inner_data", constructor)); + } else { + return null; + } + } + TL_p_q_inner_data result = new TL_p_q_inner_data(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + pq = stream.readByteArray(exception); + p = stream.readByteArray(exception); + q = stream.readByteArray(exception); + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + new_nonce = stream.readData(32, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeByteArray(pq); + stream.writeByteArray(p); + stream.writeByteArray(q); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeRaw(new_nonce); + } + } + + public static class InputPhoto extends TLObject { + public long id; public long access_hash; - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - access_hash = stream.readInt64(); + public static InputPhoto TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputPhoto result = null; + switch(constructor) { + case 0x1cd7bf0d: + result = new TL_inputPhotoEmpty(); + break; + case 0xfb95c6c4: + result = new TL_inputPhoto(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputPhoto", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputPhotoEmpty extends InputPhoto { + public static int constructor = 0x1cd7bf0d; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPhoto extends InputPhoto { + public static int constructor = 0xfb95c6c4; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(chat_id); + stream.writeInt64(id); stream.writeInt64(access_hash); } } - public static class TL_protoMessage extends TLObject { - public static int constructor = 0x5bb8e511; + public static class contacts_Contacts extends TLObject { + public ArrayList contacts = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); - public long msg_id; - public int seqno; - public int bytes; - public TLObject body; + public static contacts_Contacts TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + contacts_Contacts result = null; + switch(constructor) { + case 0xb74ba9d2: + result = new TL_contacts_contactsNotModified(); + break; + case 0x6f8b8cb2: + result = new TL_contacts_contacts(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in contacts_Contacts", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } - public void readParams(AbsSerializedData stream) { - msg_id = stream.readInt64(); - seqno = stream.readInt32(); - bytes = stream.readInt32(); - body = TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public static class TL_contacts_contactsNotModified extends contacts_Contacts { + public static int constructor = 0xb74ba9d2; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_contacts_contacts extends contacts_Contacts { + public static int constructor = 0x6f8b8cb2; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + contacts.add(TL_contact.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(msg_id); - stream.writeInt32(seqno); - stream.writeInt32(bytes); - body.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = contacts.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + contacts.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 PhotoSize extends TLObject { - public String type; - public FileLocation location; - public int w; - public int h; - public int size; - public byte[] bytes; - } - - public static class TL_photoSize extends PhotoSize { - public static int constructor = 0x77bfb61b; - - - public void readParams(AbsSerializedData stream) { - type = stream.readString(); - location = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - w = stream.readInt32(); - h = stream.readInt32(); - size = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(type); - location.serializeToStream(stream); - stream.writeInt32(w); - stream.writeInt32(h); - stream.writeInt32(size); - } - } - - public static class TL_photoSizeEmpty extends PhotoSize { - public static int constructor = 0xe17e23c; - - - public void readParams(AbsSerializedData stream) { - type = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(type); - } - } - - public static class TL_photoCachedSize extends PhotoSize { - public static int constructor = 0xe9a734fa; - - - public void readParams(AbsSerializedData stream) { - type = stream.readString(); - location = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - w = stream.readInt32(); - h = stream.readInt32(); - bytes = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(type); - location.serializeToStream(stream); - stream.writeInt32(w); - stream.writeInt32(h); - stream.writeByteArray(bytes); - } - } - - public static class TL_contactFound extends TLObject { - public static int constructor = 0xea879f95; + public static class TL_contactBlocked extends TLObject { + public static int constructor = 0x561bc879; public int user_id; + public int date; - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); + public static TL_contactBlocked TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contactBlocked.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contactBlocked", constructor)); + } else { + return null; + } + } + TL_contactBlocked result = new TL_contactBlocked(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt32(user_id); - } - } - - public static class TL_account_sentChangePhoneCode extends TLObject { - public static int constructor = 0xa4f58c4c; - - public String phone_code_hash; - public int send_call_timeout; - - public void readParams(AbsSerializedData stream) { - phone_code_hash = stream.readString(); - send_call_timeout = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(phone_code_hash); - stream.writeInt32(send_call_timeout); - } - } - - public static class InputFile extends TLObject { - public long id; - public int parts; - public String name; - public String md5_checksum; - } - - public static class TL_inputFileBig extends InputFile { - public static int constructor = 0xfa4f0bb5; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - parts = stream.readInt32(); - name = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt32(parts); - stream.writeString(name); - } - } - - public static class TL_inputFile extends InputFile { - public static int constructor = 0xf52ff27f; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - parts = stream.readInt32(); - name = stream.readString(); - md5_checksum = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt32(parts); - stream.writeString(name); - stream.writeString(md5_checksum); - } - } - - public static class TL_userFull extends TLObject { - public static int constructor = 0x771095da; - - public User user; - public TL_contacts_link link; - public Photo profile_photo; - public PeerNotifySettings notify_settings; - public boolean blocked; - public String real_first_name; - public String real_last_name; - - public void readParams(AbsSerializedData stream) { - user = (User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - link = (TL_contacts_link)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - profile_photo = (Photo)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - notify_settings = (PeerNotifySettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - blocked = stream.readBool(); - real_first_name = stream.readString(); - real_last_name = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - user.serializeToStream(stream); - link.serializeToStream(stream); - profile_photo.serializeToStream(stream); - notify_settings.serializeToStream(stream); - stream.writeBool(blocked); - stream.writeString(real_first_name); - stream.writeString(real_last_name); - } - } - - 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(AbsSerializedData stream) { - pts = stream.readInt32(); - qts = stream.readInt32(); - date = stream.readInt32(); - seq = stream.readInt32(); - unread_count = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(pts); - stream.writeInt32(qts); stream.writeInt32(date); - stream.writeInt32(seq); - stream.writeInt32(unread_count); - } - } - - public static class TL_resPQ extends TLObject { - public static int constructor = 0x05162463; - - public byte[] nonce; - public byte[] server_nonce; - public byte[] pq; - public ArrayList server_public_key_fingerprints = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - pq = stream.readByteArray(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - server_public_key_fingerprints.add(stream.readInt64()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeByteArray(pq); - stream.writeInt32(0x1cb5c415); - int count = server_public_key_fingerprints.size(); - stream.writeInt32(count); - for (Long server_public_key_fingerprint : server_public_key_fingerprints) { - stream.writeInt64(server_public_key_fingerprint); - } } } public static class Updates extends TLObject { public int flags; public int id; + public int from_id; public int chat_id; public String message; public int pts; @@ -6721,27 +8308,60 @@ public class TLRPC { public Update update; public int seq_start; public int qts; + + public static Updates TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Updates result = null; + switch(constructor) { + case 0x52238b3c: + result = new TL_updateShortChatMessage(); + break; + case 0x74ae4240: + result = new TL_updates(); + break; + case 0xed5c2127: + result = new TL_updateShortMessage(); + break; + case 0x78d4dec1: + result = new TL_updateShort(); + break; + case 0x725b04c3: + result = new TL_updatesCombined(); + break; + case 0xe317af7e: + result = new TL_updatesTooLong(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Updates", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_updateShortChatMessage extends Updates { public static int constructor = 0x52238b3c; - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt32(); - user_id = stream.readInt32(); - chat_id = stream.readInt32(); - message = stream.readString(); - pts = stream.readInt32(); - pts_count = stream.readInt32(); - date = stream.readInt32(); - if ((flags & MESSAGE_FLAG_FWD) != 0) { - fwd_from_id = stream.readInt32(); - fwd_date = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + chat_id = stream.readInt32(exception); + message = stream.readString(exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + date = stream.readInt32(exception); + if ((flags & 4) != 0) { + fwd_from_id = stream.readInt32(exception); } - if ((flags & MESSAGE_FLAG_REPLY) != 0) { - reply_to_msg_id = stream.readInt32(); + if ((flags & 4) != 0) { + fwd_date = stream.readInt32(exception); + } + if ((flags & 8) != 0) { + reply_to_msg_id = stream.readInt32(exception); } } @@ -6749,17 +8369,19 @@ public class TLRPC { stream.writeInt32(constructor); stream.writeInt32(flags); stream.writeInt32(id); - stream.writeInt32(user_id); + stream.writeInt32(from_id); stream.writeInt32(chat_id); stream.writeString(message); stream.writeInt32(pts); stream.writeInt32(pts_count); stream.writeInt32(date); - if ((flags & MESSAGE_FLAG_FWD) != 0) { + if ((flags & 4) != 0) { stream.writeInt32(fwd_from_id); + } + if ((flags & 4) != 0) { stream.writeInt32(fwd_date); } - if ((flags & MESSAGE_FLAG_REPLY) != 0) { + if ((flags & 8) != 0) { stream.writeInt32(reply_to_msg_id); } } @@ -6769,24 +8391,42 @@ public class TLRPC { public static int constructor = 0x74ae4240; - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - updates.add((Update)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.readInt32(); - count = stream.readInt32(); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + updates.add(Update.TLdeserialize(stream, stream.readInt32(exception), exception)); } - stream.readInt32(); - count = stream.readInt32(); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); } - date = stream.readInt32(); - seq = stream.readInt32(); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + date = stream.readInt32(exception); + seq = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -6818,20 +8458,22 @@ public class TLRPC { public static int constructor = 0xed5c2127; - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt32(); - user_id = stream.readInt32(); - message = stream.readString(); - pts = stream.readInt32(); - pts_count = stream.readInt32(); - date = stream.readInt32(); - if ((flags & MESSAGE_FLAG_FWD) != 0) { - fwd_from_id = stream.readInt32(); - fwd_date = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt32(exception); + user_id = stream.readInt32(exception); + message = stream.readString(exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + date = stream.readInt32(exception); + if ((flags & 4) != 0) { + fwd_from_id = stream.readInt32(exception); } - if ((flags & MESSAGE_FLAG_REPLY) != 0) { - reply_to_msg_id = stream.readInt32(); + if ((flags & 4) != 0) { + fwd_date = stream.readInt32(exception); + } + if ((flags & 8) != 0) { + reply_to_msg_id = stream.readInt32(exception); } } @@ -6844,11 +8486,13 @@ public class TLRPC { stream.writeInt32(pts); stream.writeInt32(pts_count); stream.writeInt32(date); - if ((flags & MESSAGE_FLAG_FWD) != 0) { + if ((flags & 4) != 0) { stream.writeInt32(fwd_from_id); + } + if ((flags & 4) != 0) { stream.writeInt32(fwd_date); } - if ((flags & MESSAGE_FLAG_REPLY) != 0) { + if ((flags & 8) != 0) { stream.writeInt32(reply_to_msg_id); } } @@ -6858,9 +8502,9 @@ public class TLRPC { public static int constructor = 0x78d4dec1; - public void readParams(AbsSerializedData stream) { - update = (Update)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - date = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + update = Update.TLdeserialize(stream, stream.readInt32(exception), exception); + date = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -6874,25 +8518,43 @@ public class TLRPC { public static int constructor = 0x725b04c3; - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - updates.add((Update)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.readInt32(); - count = stream.readInt32(); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + updates.add(Update.TLdeserialize(stream, stream.readInt32(exception), exception)); } - stream.readInt32(); - count = stream.readInt32(); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); } - date = stream.readInt32(); - seq_start = stream.readInt32(); - seq = stream.readInt32(); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + date = stream.readInt32(exception); + seq_start = stream.readInt32(exception); + seq = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -6930,438 +8592,371 @@ public class TLRPC { } } - public static class WallPaper extends TLObject { - public int id; - public String title; - public ArrayList sizes = new ArrayList<>(); - public int color; - public int bg_color; + public static class InputPeerNotifyEvents extends TLObject { + + public static InputPeerNotifyEvents TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputPeerNotifyEvents result = null; + switch(constructor) { + case 0xe86a2c74: + result = new TL_inputPeerNotifyEventsAll(); + break; + case 0xf03064d8: + result = new TL_inputPeerNotifyEventsEmpty(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputPeerNotifyEvents", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } - public static class TL_wallPaper extends WallPaper { - public static int constructor = 0xccb03657; + public static class TL_inputPeerNotifyEventsAll extends InputPeerNotifyEvents { + public static int constructor = 0xe86a2c74; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - title = stream.readString(); - stream.readInt32(); - int count = stream.readInt32(); + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputPeerNotifyEventsEmpty extends InputPeerNotifyEvents { + public static int constructor = 0xf03064d8; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_msgs_state_info extends TLObject { + public static int constructor = 0x04deb57d; + + public long req_msg_id; + public String info; + + public static TL_msgs_state_info TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_msgs_state_info.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_msgs_state_info", constructor)); + } else { + return null; + } + } + TL_msgs_state_info result = new TL_msgs_state_info(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + req_msg_id = stream.readInt64(exception); + info = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(req_msg_id); + stream.writeString(info); + } + } + + public static class updates_Difference extends TLObject { + public int date; + public int seq; + public ArrayList 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 intermediate_state; + public TL_updates_state state; + + public static updates_Difference TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + updates_Difference result = null; + switch(constructor) { + case 0x5d75a138: + result = new TL_updates_differenceEmpty(); + break; + case 0xa8fb1981: + result = new TL_updates_differenceSlice(); + break; + case 0xf49ca0: + result = new TL_updates_difference(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in updates_Difference", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_updates_differenceEmpty extends updates_Difference { + public static int constructor = 0x5d75a138; + + + public void readParams(AbsSerializedData stream, boolean exception) { + date = stream.readInt32(exception); + seq = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(date); + stream.writeInt32(seq); + } + } + + public static class TL_updates_differenceSlice extends updates_Difference { + public static int constructor = 0xa8fb1981; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - sizes.add((PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + new_messages.add(Message.TLdeserialize(stream, stream.readInt32(exception), exception)); } - color = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(title); - stream.writeInt32(0x1cb5c415); - int count = sizes.size(); - stream.writeInt32(count); - for (PhotoSize size : sizes) { - size.serializeToStream(stream); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.writeInt32(color); - } - } - - public static class TL_wallPaperSolid extends WallPaper { - public static int constructor = 0x63117f24; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - title = stream.readString(); - bg_color = stream.readInt32(); - color = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(title); - stream.writeInt32(bg_color); - stream.writeInt32(color); - } - } - - 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 void readParams(AbsSerializedData stream) { - answer_msg_id = stream.readInt64(); - bytes = stream.readInt32(); - status = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - msg_id = stream.readInt64(); - answer_msg_id = stream.readInt64(); - bytes = stream.readInt32(); - status = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(msg_id); - stream.writeInt64(answer_msg_id); - stream.writeInt32(bytes); - stream.writeInt32(status); - } - } - - public static class TL_stickerPack extends TLObject { - public static int constructor = 0x12b299d4; - - public String emoticon; - public ArrayList documents = new ArrayList<>(); - - public void readParams(AbsSerializedData stream) { - emoticon = stream.readString(); - stream.readInt32(); - int count = stream.readInt32(); + count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - documents.add(stream.readInt64()); + new_encrypted_messages.add(EncryptedMessage.TLdeserialize(stream, stream.readInt32(exception), exception)); } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + other_updates.add(Update.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + intermediate_state = TL_updates_state.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeString(emoticon); stream.writeInt32(0x1cb5c415); - int count = documents.size(); + int count = new_messages.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - stream.writeInt64(documents.get(a)); + new_messages.get(a).serializeToStream(stream); } - } - } - - public static class TL_inputEncryptedChat extends TLObject { - public static int constructor = 0xf141b5e1; - - public int chat_id; - public long access_hash; - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - stream.writeInt64(access_hash); - } - } - - public static class InputChatPhoto extends TLObject { - public InputPhoto id; - public InputPhotoCrop crop; - public InputFile file; - } - - public static class TL_inputChatPhoto extends InputChatPhoto { - public static int constructor = 0xb2e1bf08; - - - public void readParams(AbsSerializedData stream) { - id = (InputPhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - crop = (InputPhotoCrop)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - id.serializeToStream(stream); - crop.serializeToStream(stream); - } - } - - public static class TL_inputChatPhotoEmpty extends InputChatPhoto { - public static int constructor = 0x1ca48f57; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputChatUploadedPhoto extends InputChatPhoto { - public static int constructor = 0x94254732; - - - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - crop = (InputPhotoCrop)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - file.serializeToStream(stream); - crop.serializeToStream(stream); - } - } - - public static class InputVideo extends TLObject { - public long id; - public long access_hash; - } - - public static class TL_inputVideoEmpty extends InputVideo { - public static int constructor = 0x5508ec75; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputVideo extends InputVideo { - public static int constructor = 0xee579652; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - } - } - - public static class TL_nearestDc extends TLObject { - public static int constructor = 0x8e1a1775; - - public String country; - public int this_dc; - public int nearest_dc; - - public void readParams(AbsSerializedData stream) { - country = stream.readString(); - this_dc = stream.readInt32(); - nearest_dc = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(country); - stream.writeInt32(this_dc); - stream.writeInt32(nearest_dc); - } - } - - public static class InputPhoto extends TLObject { - public long id; - public long access_hash; - } - - public static class TL_inputPhotoEmpty extends InputPhoto { - public static int constructor = 0x1cd7bf0d; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputPhoto extends InputPhoto { - public static int constructor = 0xfb95c6c4; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - } - } - - public static class TL_importedContact extends TLObject { - public static int constructor = 0xd0028438; - - public int user_id; - public long client_id; - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - client_id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt64(client_id); - } - } - - public static class TL_accountDaysTTL extends TLObject { - public static int constructor = 0xb8d0afdf; - - public int days; - - public void readParams(AbsSerializedData stream) { - days = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(days); - } - } - - public static class InputPeer extends TLObject { - public int user_id; - public int chat_id; - public long access_hash; - } - - public static class TL_inputPeerContact extends InputPeer { - public static int constructor = 0x1023dbe8; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - } - } - - public static class TL_inputPeerChat extends InputPeer { - public static int constructor = 0x179be863; - - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(chat_id); - } - } - - public static class TL_inputPeerEmpty extends InputPeer { - public static int constructor = 0x7f3b18ea; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputPeerSelf extends InputPeer { - public static int constructor = 0x7da07ec9; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_inputPeerForeign extends InputPeer { - public static int constructor = 0x9b447325; - - - public void readParams(AbsSerializedData stream) { - user_id = stream.readInt32(); - access_hash = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(user_id); - stream.writeInt64(access_hash); - } - } - - public static class TL_account_passwordInputSettings extends TLObject { - public static int constructor = 0xbcfc532c; - - public int flags; - public byte[] new_salt; - public byte[] new_password_hash; - public String hint; - public String email; - - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - if ((flags & 1) != 0) { - new_salt = stream.readByteArray(); - new_password_hash = stream.readByteArray(); - hint = stream.readString(); + 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); } - if ((flags & 2) != 0) { - email = stream.readString(); + stream.writeInt32(0x1cb5c415); + count = other_updates.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + other_updates.get(a).serializeToStream(stream); } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(flags); - if ((flags & 1) != 0) { - stream.writeByteArray(new_salt); - stream.writeByteArray(new_password_hash); - stream.writeString(hint); + stream.writeInt32(0x1cb5c415); + count = chats.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + chats.get(a).serializeToStream(stream); } - if ((flags & 2) != 0) { - stream.writeString(email); + stream.writeInt32(0x1cb5c415); + count = users.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + users.get(a).serializeToStream(stream); } + intermediate_state.serializeToStream(stream); } } - public static class TL_dcOption extends TLObject { - public static int constructor = 0x2ec2a43c; + public static class TL_updates_difference extends updates_Difference { + public static int constructor = 0xf49ca0; - public int id; - public String hostname; - public String ip_address; - public int port; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - hostname = stream.readString(); - ip_address = stream.readString(); - port = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + new_messages.add(Message.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + new_encrypted_messages.add(EncryptedMessage.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + other_updates.add(Update.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + state = TL_updates_state.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(hostname); - stream.writeString(ip_address); - stream.writeInt32(port); + 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); + } + } + + public static class ChatPhoto extends TLObject { + public FileLocation photo_small; + public FileLocation photo_big; + + public static ChatPhoto TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + ChatPhoto result = null; + switch(constructor) { + case 0x37c1011c: + result = new TL_chatPhotoEmpty(); + break; + case 0x6153276a: + result = new TL_chatPhoto(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in ChatPhoto", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_chatPhotoEmpty extends ChatPhoto { + public static int constructor = 0x37c1011c; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_chatPhoto extends ChatPhoto { + public static int constructor = 0x6153276a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + photo_small = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + photo_big = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + photo_small.serializeToStream(stream); + photo_big.serializeToStream(stream); } } @@ -7374,12 +8969,25 @@ public class TLRPC { public int out_seq_no; public DecryptedMessage message; - public void readParams(AbsSerializedData stream) { - random_bytes = stream.readByteArray(); - layer = stream.readInt32(); - in_seq_no = stream.readInt32(); - out_seq_no = stream.readInt32(); - message = (DecryptedMessage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public static TL_decryptedMessageLayer TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_decryptedMessageLayer.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_decryptedMessageLayer", constructor)); + } else { + return null; + } + } + TL_decryptedMessageLayer result = new TL_decryptedMessageLayer(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + random_bytes = stream.readByteArray(exception); + layer = stream.readInt32(exception); + in_seq_no = stream.readInt32(exception); + out_seq_no = stream.readInt32(exception); + message = DecryptedMessage.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7392,10 +9000,397 @@ public class TLRPC { } } + public static class TL_audioEmpty extends Audio { + public static int constructor = 0x586988d8; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + } + } + + public static class TL_audio extends Audio { + public static int constructor = 0xc7ac6496; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + duration = stream.readInt32(exception); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + dc_id = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeInt32(duration); + stream.writeString(mime_type); + stream.writeInt32(size); + stream.writeInt32(dc_id); + } + } + + public static class TL_contacts_found extends TLObject { + public static int constructor = 0x566000e; + + public ArrayList results = new ArrayList<>(); + public ArrayList users = new ArrayList<>(); + + public static TL_contacts_found TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contacts_found.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contacts_found", constructor)); + } else { + return null; + } + } + TL_contacts_found result = new TL_contacts_found(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + results.add(TL_contactFound.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData 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 TL_documentEmpty extends Document { + public static int constructor = 0x36f8c871; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + } + } + + public static class TL_document extends Document { + public static int constructor = 0xf9a39f4f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + attributes.add(DocumentAttribute.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(date); + stream.writeString(mime_type); + stream.writeInt32(size); + thumb.serializeToStream(stream); + stream.writeInt32(dc_id); + stream.writeInt32(0x1cb5c415); + int count = attributes.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + attributes.get(a).serializeToStream(stream); + } + } + } + + public static class MessagesFilter extends TLObject { + + public static MessagesFilter TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + MessagesFilter result = null; + switch(constructor) { + case 0x9eddf188: + result = new TL_inputMessagesFilterDocument(); + break; + case 0x9fc00e65: + result = new TL_inputMessagesFilterVideo(); + break; + case 0x9609a51c: + result = new TL_inputMessagesFilterPhotos(); + break; + case 0xd95e73bb: + result = new TL_inputMessagesFilterPhotoVideoDocuments(); + break; + case 0xcfc87522: + result = new TL_inputMessagesFilterAudio(); + break; + case 0x57e2f66c: + result = new TL_inputMessagesFilterEmpty(); + break; + case 0x56e9f0e4: + result = new TL_inputMessagesFilterPhotoVideo(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in MessagesFilter", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputMessagesFilterDocument extends MessagesFilter { + public static int constructor = 0x9eddf188; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputMessagesFilterVideo extends MessagesFilter { + public static int constructor = 0x9fc00e65; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputMessagesFilterPhotos extends MessagesFilter { + public static int constructor = 0x9609a51c; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputMessagesFilterPhotoVideoDocuments extends MessagesFilter { + public static int constructor = 0xd95e73bb; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputMessagesFilterAudio extends MessagesFilter { + public static int constructor = 0xcfc87522; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputMessagesFilterEmpty extends MessagesFilter { + public static int constructor = 0x57e2f66c; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_inputMessagesFilterPhotoVideo extends MessagesFilter { + public static int constructor = 0x56e9f0e4; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_account_passwordSettings extends TLObject { + public static int constructor = 0xb7b72ab3; + + public String email; + + public static TL_account_passwordSettings TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_account_passwordSettings.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_account_passwordSettings", constructor)); + } else { + return null; + } + } + TL_account_passwordSettings result = new TL_account_passwordSettings(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + email = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(email); + } + } + + public static class ExportedChatInvite extends TLObject { + public String link; + + public static ExportedChatInvite TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + ExportedChatInvite result = null; + switch(constructor) { + case 0xfc2e05bc: + result = new TL_chatInviteExported(); + break; + case 0x69df3769: + result = new TL_chatInviteEmpty(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in ExportedChatInvite", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_chatInviteExported extends ExportedChatInvite { + public static int constructor = 0xfc2e05bc; + + + public void readParams(AbsSerializedData stream, boolean exception) { + link = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(link); + } + } + + public static class TL_chatInviteEmpty extends ExportedChatInvite { + public static int constructor = 0x69df3769; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_http_wait extends TLObject { + public static int constructor = 0x9299359f; + + public int max_delay; + public int wait_after; + public int max_wait; + + public static TL_http_wait TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_http_wait.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_http_wait", constructor)); + } else { + return null; + } + } + TL_http_wait result = new TL_http_wait(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + max_delay = stream.readInt32(exception); + wait_after = stream.readInt32(exception); + max_wait = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(max_delay); + stream.writeInt32(wait_after); + stream.writeInt32(max_wait); + } + } + public static class InputPhotoCrop extends TLObject { public double crop_left; public double crop_top; public double crop_width; + + public static InputPhotoCrop TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputPhotoCrop result = null; + switch(constructor) { + case 0xade6b004: + result = new TL_inputPhotoCropAuto(); + break; + case 0xd9915325: + result = new TL_inputPhotoCrop(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputPhotoCrop", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_inputPhotoCropAuto extends InputPhotoCrop { @@ -7411,10 +9406,10 @@ public class TLRPC { public static int constructor = 0xd9915325; - public void readParams(AbsSerializedData stream) { - crop_left = stream.readDouble(); - crop_top = stream.readDouble(); - crop_width = stream.readDouble(); + public void readParams(AbsSerializedData stream, boolean exception) { + crop_left = stream.readDouble(exception); + crop_top = stream.readDouble(exception); + crop_width = stream.readDouble(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7425,60 +9420,659 @@ public class TLRPC { } } - public static class messages_Dialogs extends TLObject { - public ArrayList dialogs = new ArrayList<>(); - public ArrayList messages = new ArrayList<>(); + public static class Chat extends TLObject { + public int id; + public String title; + public int date; + public long access_hash; + public String address; + public String venue; + public GeoPoint geo; + public ChatPhoto photo; + public int participants_count; + public boolean checked_in; + public int version; + public boolean left; + + public static Chat TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Chat result = null; + switch(constructor) { + case 0xfb0ccc41: + result = new TL_chatForbidden(); + break; + case 0x75eaea5a: + result = new TL_geoChat(); + break; + case 0x9ba2d800: + result = new TL_chatEmpty(); + break; + case 0x6e9c9bc7: + result = new TL_chat(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Chat", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_chatForbidden extends Chat { + public static int constructor = 0xfb0ccc41; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + title = stream.readString(exception); + date = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(title); + stream.writeInt32(date); + } + } + + public static class TL_geoChat extends Chat { + public static int constructor = 0x75eaea5a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + title = stream.readString(exception); + address = stream.readString(exception); + venue = stream.readString(exception); + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + photo = ChatPhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + participants_count = stream.readInt32(exception); + date = stream.readInt32(exception); + checked_in = stream.readBool(exception); + version = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeInt64(access_hash); + stream.writeString(title); + stream.writeString(address); + stream.writeString(venue); + geo.serializeToStream(stream); + photo.serializeToStream(stream); + stream.writeInt32(participants_count); + stream.writeInt32(date); + stream.writeBool(checked_in); + stream.writeInt32(version); + } + } + + public static class TL_chat extends Chat { + public static int constructor = 0x6e9c9bc7; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + title = stream.readString(exception); + photo = ChatPhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + participants_count = stream.readInt32(exception); + date = stream.readInt32(exception); + left = stream.readBool(exception); + version = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeString(title); + photo.serializeToStream(stream); + stream.writeInt32(participants_count); + stream.writeInt32(date); + stream.writeBool(left); + stream.writeInt32(version); + } + } + + public static class TL_messages_chats extends TLObject { + public static int constructor = 0x64ff9fd5; + public ArrayList chats = new ArrayList<>(); + + public static TL_messages_chats TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_messages_chats.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_messages_chats", constructor)); + } else { + return null; + } + } + TL_messages_chats result = new TL_messages_chats(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + chats.add(Chat.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = chats.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + chats.get(a).serializeToStream(stream); + } + } + } + + public static class ContactLink extends TLObject { + + public static ContactLink TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + ContactLink result = null; + switch(constructor) { + case 0xfeedd3ad: + result = new TL_contactLinkNone(); + break; + case 0xd502c2d0: + result = new TL_contactLinkContact(); + break; + case 0x268f3f59: + result = new TL_contactLinkHasPhone(); + break; + case 0x5f4f9247: + result = new TL_contactLinkUnknown(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in ContactLink", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_contactLinkNone extends ContactLink { + public static int constructor = 0xfeedd3ad; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_contactLinkContact extends ContactLink { + public static int constructor = 0xd502c2d0; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_contactLinkHasPhone extends ContactLink { + public static int constructor = 0x268f3f59; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_contactLinkUnknown extends ContactLink { + public static int constructor = 0x5f4f9247; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class PeerNotifyEvents extends TLObject { + + public static PeerNotifyEvents TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + PeerNotifyEvents result = null; + switch(constructor) { + case 0xadd53cb3: + result = new TL_peerNotifyEventsEmpty(); + break; + case 0x6d1ded88: + result = new TL_peerNotifyEventsAll(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in PeerNotifyEvents", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_peerNotifyEventsEmpty extends PeerNotifyEvents { + public static int constructor = 0xadd53cb3; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_peerNotifyEventsAll extends PeerNotifyEvents { + public static int constructor = 0x6d1ded88; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageRecordAudioAction extends SendMessageAction { + public static int constructor = 0xd52f73f7; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageUploadAudioAction extends SendMessageAction { + public static int constructor = 0xf351d7ab; + + + public void readParams(AbsSerializedData stream, boolean exception) { + progress = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(progress); + } + } + + public static class TL_sendMessageUploadPhotoAction extends SendMessageAction { + public static int constructor = 0xd1d34a26; + + + public void readParams(AbsSerializedData stream, boolean exception) { + progress = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(progress); + } + } + + public static class TL_sendMessageUploadVideoAction extends SendMessageAction { + public static int constructor = 0xe9763aec; + + + public void readParams(AbsSerializedData stream, boolean exception) { + progress = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(progress); + } + } + + public static class TL_sendMessageCancelAction extends SendMessageAction { + public static int constructor = 0xfd5ec8f5; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageGeoLocationAction extends SendMessageAction { + public static int constructor = 0x176f8ba1; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageChooseContactAction extends SendMessageAction { + public static int constructor = 0x628cbc6f; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageTypingAction extends SendMessageAction { + public static int constructor = 0x16bf744e; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageUploadDocumentAction extends SendMessageAction { + public static int constructor = 0xaa0cd9e4; + + + public void readParams(AbsSerializedData stream, boolean exception) { + progress = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(progress); + } + } + + public static class TL_sendMessageRecordVideoAction extends SendMessageAction { + public static int constructor = 0xa187d66f; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_client_DH_inner_data extends TLObject { + public static int constructor = 0x6643b654; + + public byte[] nonce; + public byte[] server_nonce; + public long retry_id; + public byte[] g_b; + + public static TL_client_DH_inner_data TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_client_DH_inner_data.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_client_DH_inner_data", constructor)); + } else { + return null; + } + } + TL_client_DH_inner_data result = new TL_client_DH_inner_data(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + nonce = stream.readData(16, exception); + server_nonce = stream.readData(16, exception); + retry_id = stream.readInt64(exception); + g_b = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeInt64(retry_id); + stream.writeByteArray(g_b); + } + } + + public static class TL_null extends TLObject { + public static int constructor = 0x56730bcc; + + + public static TL_null TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_null.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_null", constructor)); + } else { + return null; + } + } + TL_null result = new TL_null(); + result.readParams(stream, exception); + return result; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class account_Password extends TLObject { + public byte[] current_salt; + public byte[] new_salt; + public String hint; + public boolean has_recovery; + public String email_unconfirmed_pattern; + + public static account_Password TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + account_Password result = null; + switch(constructor) { + case 0x7c18141c: + result = new TL_account_password(); + break; + case 0x96dabc18: + result = new TL_account_noPassword(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in account_Password", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_account_password extends account_Password { + public static int constructor = 0x7c18141c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + current_salt = stream.readByteArray(exception); + new_salt = stream.readByteArray(exception); + hint = stream.readString(exception); + has_recovery = stream.readBool(exception); + email_unconfirmed_pattern = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeByteArray(current_salt); + stream.writeByteArray(new_salt); + stream.writeString(hint); + stream.writeBool(has_recovery); + stream.writeString(email_unconfirmed_pattern); + } + } + + public static class TL_account_noPassword extends account_Password { + public static int constructor = 0x96dabc18; + + + public void readParams(AbsSerializedData stream, boolean exception) { + new_salt = stream.readByteArray(exception); + email_unconfirmed_pattern = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeByteArray(new_salt); + stream.writeString(email_unconfirmed_pattern); + } + } + + public static class TL_documentAttributeAnimated extends DocumentAttribute { + public static int constructor = 0x11b58939; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_documentAttributeImageSize extends DocumentAttribute { + public static int constructor = 0x6c37c15c; + + + public void readParams(AbsSerializedData stream, boolean exception) { + w = stream.readInt32(exception); + h = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(w); + stream.writeInt32(h); + } + } + + public static class TL_documentAttributeFilename extends DocumentAttribute { + public static int constructor = 0x15590068; + + + public void readParams(AbsSerializedData stream, boolean exception) { + file_name = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(file_name); + } + } + + public static class TL_documentAttributeVideo extends DocumentAttribute { + public static int constructor = 0x5910cccb; + + + public void readParams(AbsSerializedData stream, boolean exception) { + duration = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(duration); + stream.writeInt32(w); + stream.writeInt32(h); + } + } + + public static class TL_documentAttributeSticker extends DocumentAttribute { + public static int constructor = 0x994c9882; + + + public void readParams(AbsSerializedData stream, boolean exception) { + alt = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(alt); + } + } + + public static class TL_documentAttributeAudio extends DocumentAttribute { + public static int constructor = 0x51448e5; + + + public void readParams(AbsSerializedData stream, boolean exception) { + duration = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(duration); + } + } + + public static class TL_contacts_importedContacts extends TLObject { + public static int constructor = 0xad524315; + + public ArrayList imported = new ArrayList<>(); + public ArrayList retry_contacts = new ArrayList<>(); public ArrayList users = new ArrayList<>(); - public int count; - } - public static class TL_messages_dialogs extends messages_Dialogs { - public static int constructor = 0x15ba6c40; + public static TL_contacts_importedContacts TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_contacts_importedContacts.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_contacts_importedContacts", constructor)); + } else { + return null; + } + } + TL_contacts_importedContacts result = new TL_contacts_importedContacts(); + result.readParams(stream, exception); + return result; + } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - dialogs.add((TL_dialog)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.readInt32(); - count = stream.readInt32(); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - messages.add((Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + imported.add(TL_importedContact.TLdeserialize(stream, stream.readInt32(exception), exception)); } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.readInt32(); - count = stream.readInt32(); + count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + retry_contacts.add(stream.readInt64(exception)); + } + magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + users.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt32(0x1cb5c415); - int count = dialogs.size(); + int count = imported.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - dialogs.get(a).serializeToStream(stream); + imported.get(a).serializeToStream(stream); } stream.writeInt32(0x1cb5c415); - count = messages.size(); + count = retry_contacts.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - messages.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.writeInt64(retry_contacts.get(a)); } stream.writeInt32(0x1cb5c415); count = users.size(); @@ -7489,99 +10083,248 @@ public class TLRPC { } } - public static class TL_messages_dialogsSlice extends messages_Dialogs { - public static int constructor = 0x71e094f3; + public static class PrivacyRule extends TLObject { + public ArrayList users = new ArrayList<>(); + + public static PrivacyRule TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + PrivacyRule result = null; + switch(constructor) { + case 0x4d5bbe0c: + result = new TL_privacyValueAllowUsers(); + break; + case 0x8b73e763: + result = new TL_privacyValueDisallowAll(); + break; + case 0xfffe1bac: + result = new TL_privacyValueAllowContacts(); + break; + case 0xf888fa1a: + result = new TL_privacyValueDisallowContacts(); + break; + case 0x65427b82: + result = new TL_privacyValueAllowAll(); + break; + case 0xc7f49b7: + result = new TL_privacyValueDisallowUsers(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in PrivacyRule", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_privacyValueAllowUsers extends PrivacyRule { + public static int constructor = 0x4d5bbe0c; - public void readParams(AbsSerializedData stream) { - count = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - dialogs.add((TL_dialog)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; } - stream.readInt32(); - count = stream.readInt32(); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - messages.add((Message)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())); + users.add(stream.readInt32(exception)); } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(count); stream.writeInt32(0x1cb5c415); - int count = dialogs.size(); + int count = users.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - dialogs.get(a).serializeToStream(stream); - } - stream.writeInt32(0x1cb5c415); - count = messages.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - messages.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); + stream.writeInt32(users.get(a)); } } } - public static class TL_account_authorizations extends TLObject { - public static int constructor = 0x1250abde; + public static class TL_privacyValueDisallowAll extends PrivacyRule { + public static int constructor = 0x8b73e763; - public ArrayList authorizations = new ArrayList<>(); - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueAllowContacts extends PrivacyRule { + public static int constructor = 0xfffe1bac; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueDisallowContacts extends PrivacyRule { + public static int constructor = 0xf888fa1a; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueAllowAll extends PrivacyRule { + public static int constructor = 0x65427b82; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_privacyValueDisallowUsers extends PrivacyRule { + public static int constructor = 0xc7f49b7; + + + public void readParams(AbsSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - authorizations.add((TL_authorization)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + users.add(stream.readInt32(exception)); } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt32(0x1cb5c415); - int count = authorizations.size(); + int count = users.size(); stream.writeInt32(count); for (int a = 0; a < count; a++) { - authorizations.get(a).serializeToStream(stream); + stream.writeInt32(users.get(a)); } } } + 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 static TL_updates_state TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_updates_state.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_updates_state", constructor)); + } else { + return null; + } + } + TL_updates_state result = new TL_updates_state(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + pts = stream.readInt32(exception); + qts = stream.readInt32(exception); + date = stream.readInt32(exception); + seq = stream.readInt32(exception); + unread_count = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(pts); + stream.writeInt32(qts); + stream.writeInt32(date); + stream.writeInt32(seq); + stream.writeInt32(unread_count); + } + } + + public static class TL_destroy_sessions_res extends TLObject { + public static int constructor = 0xfb95abcd; + + public ArrayList destroy_results = new ArrayList<>(); + + public static TL_destroy_sessions_res TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_destroy_sessions_res.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_destroy_sessions_res", constructor)); + } else { + return null; + } + } + TL_destroy_sessions_res result = new TL_destroy_sessions_res(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + destroy_results.add(DestroySessionRes.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + int count = destroy_results.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + destroy_results.get(a).serializeToStream(stream); + } + } + } + + public static class TL_receivedNotifyMessage extends TLObject { + public static int constructor = 0xa384b779; + + public int id; + public int flags; + + public static TL_receivedNotifyMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_receivedNotifyMessage.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_receivedNotifyMessage", constructor)); + } else { + return null; + } + } + TL_receivedNotifyMessage result = new TL_receivedNotifyMessage(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + flags = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + stream.writeInt32(flags); + } + } + public static class TL_req_pq extends TLObject { public static int constructor = 0x60469778; public byte[] nonce; - public Class responseClass () { - return TL_resPQ.class; - } - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_resPQ.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7600,17 +10343,8 @@ public class TLRPC { public long public_key_fingerprint; public byte[] encrypted_data; - public Class responseClass () { - return Server_DH_Params.class; - } - - public void readParams(AbsSerializedData stream) { - nonce = stream.readData(16); - server_nonce = stream.readData(16); - p = stream.readByteArray(); - q = stream.readByteArray(); - public_key_fingerprint = stream.readInt64(); - encrypted_data = stream.readByteArray(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Server_DH_Params.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7629,12 +10363,8 @@ public class TLRPC { public String phone_number; - public Class responseClass () { - return TL_auth_checkedPhone.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_checkedPhone.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7652,16 +10382,8 @@ public class TLRPC { public String api_hash; public String lang_code; - public Class responseClass () { - return TL_auth_sentCode.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - sms_type = stream.readInt32(); - api_id = stream.readInt32(); - api_hash = stream.readString(); - lang_code = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return auth_SentCode.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7680,13 +10402,8 @@ public class TLRPC { public String phone_number; public String phone_code_hash; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - phone_code_hash = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7705,16 +10422,8 @@ public class TLRPC { public String first_name; public String last_name; - public Class responseClass () { - return TL_auth_authorization.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - phone_code_hash = stream.readString(); - phone_code = stream.readString(); - first_name = stream.readString(); - last_name = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_authorization.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7734,14 +10443,8 @@ public class TLRPC { public String phone_code_hash; public String phone_code; - public Class responseClass () { - return TL_auth_authorization.class; - } - - public void readParams(AbsSerializedData stream) { - phone_number = stream.readString(); - phone_code_hash = stream.readString(); - phone_code = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_authorization.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7756,8 +10459,8 @@ public class TLRPC { public static int constructor = 0x5717da40; - public Class responseClass () { - return Bool.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7769,8 +10472,8 @@ public class TLRPC { public static int constructor = 0x9fab0d1a; - public Class responseClass () { - return Bool.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7784,17 +10487,8 @@ public class TLRPC { public ArrayList phone_numbers = new ArrayList<>(); public String message; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - phone_numbers.add(stream.readString()); - } - message = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7802,8 +10496,8 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = phone_numbers.size(); stream.writeInt32(count); - for (String phone_number : phone_numbers) { - stream.writeString(phone_number); + for (int a = 0; a < count; a++) { + stream.writeString(phone_numbers.get(a)); } stream.writeString(message); } @@ -7814,12 +10508,8 @@ public class TLRPC { public int dc_id; - public Class responseClass () { - return TL_auth_exportedAuthorization.class; - } - - public void readParams(AbsSerializedData stream) { - dc_id = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_exportedAuthorization.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7834,13 +10524,8 @@ public class TLRPC { public int id; public byte[] bytes; - public Class responseClass () { - return TL_auth_authorization.class; - } - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - bytes = stream.readByteArray(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_authorization.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7850,6 +10535,27 @@ public class TLRPC { } } + public static class TL_auth_bindTempAuthKey extends TLObject { + public static int constructor = 0xcdd42a05; + + public long perm_auth_key_id; + public long nonce; + public int expires_at; + public byte[] encrypted_message; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(perm_auth_key_id); + stream.writeInt64(nonce); + stream.writeInt32(expires_at); + stream.writeByteArray(encrypted_message); + } + } + public static class TL_account_registerDevice extends TLObject { public static int constructor = 0x446c712c; @@ -7861,18 +10567,8 @@ public class TLRPC { public boolean app_sandbox; public String lang_code; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - token_type = stream.readInt32(); - token = stream.readString(); - device_model = stream.readString(); - system_version = stream.readString(); - app_version = stream.readString(); - app_sandbox = stream.readBool(); - lang_code = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7893,13 +10589,8 @@ public class TLRPC { public int token_type; public String token; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - token_type = stream.readInt32(); - token = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7915,13 +10606,8 @@ public class TLRPC { public InputNotifyPeer peer; public TL_inputPeerNotifySettings settings; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputNotifyPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - settings = (TL_inputPeerNotifySettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7936,12 +10622,8 @@ public class TLRPC { public InputNotifyPeer peer; - public Class responseClass () { - return PeerNotifySettings.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputNotifyPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return PeerNotifySettings.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7954,8 +10636,8 @@ public class TLRPC { public static int constructor = 0xdb7e1747; - public Class responseClass () { - return Bool.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7969,13 +10651,8 @@ public class TLRPC { public String first_name; public String last_name; - public Class responseClass () { - return User.class; - } - - public void readParams(AbsSerializedData stream) { - first_name = stream.readString(); - last_name = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return User.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -7990,12 +10667,8 @@ public class TLRPC { public boolean offline; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - offline = stream.readBool(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8004,17 +10677,36 @@ public class TLRPC { } } + public static class TL_account_getWallPapers extends TLObject { + public static int constructor = 0xc04cfac2; + + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + Vector vector = new Vector(); + int size = stream.readInt32(exception); + for (int a = 0; a < size; a++) { + vector.objects.add(WallPaper.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + return vector; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_users_getUsers extends TLObject { public static int constructor = 0xd91a548; public ArrayList id = new ArrayList<>(); - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - id.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + Vector vector = new Vector(); + int size = stream.readInt32(exception); + for (int a = 0; a < size; a++) { + vector.objects.add(User.TLdeserialize(stream, stream.readInt32(exception), exception)); } + return vector; } public void serializeToStream(AbsSerializedData stream) { @@ -8022,8 +10714,8 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = id.size(); stream.writeInt32(count); - for (InputUser anId : id) { - anId.serializeToStream(stream); + for (int a = 0; a < count; a++) { + id.get(a).serializeToStream(stream); } } } @@ -8033,12 +10725,8 @@ public class TLRPC { public InputUser id; - public Class responseClass () { - return TL_userFull.class; - } - - public void readParams(AbsSerializedData stream) { - id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_userFull.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8050,17 +10738,14 @@ public class TLRPC { public static class TL_contacts_getStatuses extends TLObject { public static int constructor = 0xc4a353ee; - public ArrayList id = new ArrayList<>(); - public Class responseClass () { - return Vector.class; - } - - public void parseVector(Vector vector, AbsSerializedData data) { - int size = data.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + Vector vector = new Vector(); + int size = stream.readInt32(exception); for (int a = 0; a < size; a++) { - vector.objects.add(TLClassStore.Instance().TLdeserialize(data, data.readInt32())); + vector.objects.add(TL_contactStatus.TLdeserialize(stream, stream.readInt32(exception), exception)); } + return vector; } public void serializeToStream(AbsSerializedData stream) { @@ -8073,12 +10758,8 @@ public class TLRPC { public String hash; - public Class responseClass () { - return contacts_Contacts.class; - } - - public void readParams(AbsSerializedData stream) { - hash = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return contacts_Contacts.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8093,17 +10774,8 @@ public class TLRPC { public ArrayList contacts = new ArrayList<>(); public boolean replace; - public Class responseClass () { - return TL_contacts_importedContacts.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - contacts.add((TL_inputPhoneContact)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - replace = stream.readBool(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_contacts_importedContacts.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8111,46 +10783,20 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = contacts.size(); stream.writeInt32(count); - for (TL_inputPhoneContact contact : contacts) { - contact.serializeToStream(stream); + for (int a = 0; a < count; a++) { + contacts.get(a).serializeToStream(stream); } stream.writeBool(replace); } } - 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(AbsSerializedData stream) { - q = stream.readString(); - limit = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream) { - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_contacts_suggested.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8164,12 +10810,8 @@ public class TLRPC { public InputUser id; - public Class responseClass () { - return TL_contacts_link.class; - } - - public void readParams(AbsSerializedData stream) { - id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_contacts_link.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8183,16 +10825,8 @@ public class TLRPC { public ArrayList id = new ArrayList<>(); - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - id.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8200,8 +10834,8 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = id.size(); stream.writeInt32(count); - for (InputUser anId : id) { - anId.serializeToStream(stream); + for (int a = 0; a < count; a++) { + id.get(a).serializeToStream(stream); } } } @@ -8211,12 +10845,8 @@ public class TLRPC { public InputUser id; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8230,12 +10860,8 @@ public class TLRPC { public InputUser id; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8250,13 +10876,8 @@ public class TLRPC { public int offset; public int limit; - public Class responseClass () { - return contacts_Blocked.class; - } - - public void readParams(AbsSerializedData stream) { - offset = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return contacts_Blocked.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8266,21 +10887,51 @@ public class TLRPC { } } + public static class TL_contacts_exportCard extends TLObject { + public static int constructor = 0x84e53737; + + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + Vector vector = new Vector(); + int size = stream.readInt32(exception); + for (int a = 0; a < size; a++) { + vector.objects.add(stream.readInt32(exception)); + } + return vector; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_contacts_importCard extends TLObject { + public static int constructor = 0x4fe196fe; + + public ArrayList export_card = new ArrayList<>(); + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return User.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = export_card.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt32(export_card.get(a)); + } + } + } + public static class TL_messages_getMessages extends TLObject { public static int constructor = 0x4222fa74; public ArrayList id = new ArrayList<>(); - public Class responseClass () { - return messages_Messages.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - id.add(stream.readInt32()); - } + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_Messages.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8288,8 +10939,8 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = id.size(); stream.writeInt32(count); - for (Integer anId : id) { - stream.writeInt32(anId); + for (int a = 0; a < count; a++) { + stream.writeInt32(id.get(a)); } } } @@ -8301,14 +10952,8 @@ public class TLRPC { public int max_id; public int limit; - public Class responseClass () { - return messages_Dialogs.class; - } - - public void readParams(AbsSerializedData stream) { - offset = stream.readInt32(); - max_id = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_Dialogs.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8327,15 +10972,8 @@ public class TLRPC { public int max_id; public int limit; - public Class responseClass () { - return messages_Messages.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - offset = stream.readInt32(); - max_id = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_Messages.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8359,19 +10997,8 @@ public class TLRPC { public int max_id; public int limit; - public Class responseClass () { - return messages_Messages.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - q = stream.readString(); - filter = (MessagesFilter)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - min_date = stream.readInt32(); - max_date = stream.readInt32(); - offset = stream.readInt32(); - max_id = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_Messages.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8394,14 +11021,8 @@ public class TLRPC { public int max_id; public int offset; - public Class responseClass () { - return TL_messages_affectedHistory.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - max_id = stream.readInt32(); - offset = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_messages_affectedHistory.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8418,13 +11039,8 @@ public class TLRPC { public InputPeer peer; public int offset; - public Class responseClass () { - return TL_messages_affectedHistory.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - offset = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_messages_affectedHistory.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8434,19 +11050,54 @@ public class TLRPC { } } + public static class TL_messages_deleteMessages extends TLObject { + public static int constructor = 0xa5f18925; + + public ArrayList id = new ArrayList<>(); + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_messages_affectedMessages.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = id.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt32(id.get(a)); + } + } + } + + public static class TL_messages_receivedMessages extends TLObject { + public static int constructor = 0x5a954c0; + + public int max_id; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + Vector vector = new Vector(); + int size = stream.readInt32(exception); + for (int a = 0; a < size; a++) { + vector.objects.add(TL_receivedNotifyMessage.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + return vector; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(max_id); + } + } + public static class TL_messages_setTyping extends TLObject { public static int constructor = 0xa3825e50; public InputPeer peer; public SendMessageAction action; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - action = (SendMessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8465,18 +11116,8 @@ public class TLRPC { public String message; public long random_id; - public Class responseClass () { - return messages_SentMessage.class; - } - - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - if ((flags & 1) != 0) { - reply_to_msg_id = stream.readInt32(); - } - message = stream.readString(); - random_id = stream.readInt64(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_SentMessage.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8500,18 +11141,8 @@ public class TLRPC { public InputMedia media; public long random_id; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - if ((flags & 1) != 0) { - reply_to_msg_id = stream.readInt32(); - } - media = (InputMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - random_id = stream.readInt64(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8533,22 +11164,8 @@ public class TLRPC { public ArrayList id = new ArrayList<>(); public ArrayList random_id = new ArrayList<>(); - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - id.add(stream.readInt32()); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - random_id.add(stream.readInt64()); - } + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8574,16 +11191,8 @@ public class TLRPC { public ArrayList id = new ArrayList<>(); - public Class responseClass () { - return TL_messages_chats.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - id.add(stream.readInt32()); - } + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_messages_chats.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8591,8 +11200,8 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = id.size(); stream.writeInt32(count); - for (Integer anId : id) { - stream.writeInt32(anId); + for (int a = 0; a < count; a++) { + stream.writeInt32(id.get(a)); } } } @@ -8602,12 +11211,8 @@ public class TLRPC { public int chat_id; - public Class responseClass () { - return TL_messages_chatFull.class; - } - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_messages_chatFull.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8622,13 +11227,8 @@ public class TLRPC { public int chat_id; public String title; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - title = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8644,13 +11244,8 @@ public class TLRPC { public int chat_id; public InputChatPhoto photo; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - photo = (InputChatPhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8667,14 +11262,8 @@ public class TLRPC { public InputUser user_id; public int fwd_limit; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - user_id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - fwd_limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8691,13 +11280,8 @@ public class TLRPC { public int chat_id; public InputUser user_id; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); - user_id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8713,17 +11297,8 @@ public class TLRPC { public ArrayList users = new ArrayList<>(); public String title; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - users.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - title = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8742,8 +11317,8 @@ public class TLRPC { public static int constructor = 0xedd4882a; - public Class responseClass () { - return TL_updates_state.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_updates_state.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8758,14 +11333,8 @@ public class TLRPC { public int date; public int qts; - public Class responseClass () { - return updates_Difference.class; - } - - public void readParams(AbsSerializedData stream) { - pts = stream.readInt32(); - date = stream.readInt32(); - qts = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return updates_Difference.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8782,13 +11351,8 @@ public class TLRPC { public InputPhoto id; public InputPhotoCrop crop; - public Class responseClass () { - return UserProfilePhoto.class; - } - - public void readParams(AbsSerializedData stream) { - id = (InputPhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - crop = (InputPhotoCrop)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return UserProfilePhoto.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8798,32 +11362,6 @@ public class TLRPC { } } - public static class TL_photos_deletePhotos extends TLObject { - public static int constructor = 0x87cf7f2f; - - public ArrayList id = new ArrayList<>(); - - public Class responseClass () { - return Vector.class; - } - - public void parseVector(Vector vector, AbsSerializedData data) { - int size = data.readInt32(); - for (int a = 0; a < size; a++) { - vector.objects.add(data.readInt64()); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - stream.writeInt32(id.size()); - for (InputPhoto inputPhoto : id) { - inputPhoto.serializeToStream(stream); - } - } - } - public static class TL_photos_uploadProfilePhoto extends TLObject { public static int constructor = 0xd50f9c88; @@ -8832,15 +11370,8 @@ public class TLRPC { public InputGeoPoint geo_point; public InputPhotoCrop crop; - public Class responseClass () { - return TL_photos_photo.class; - } - - public void readParams(AbsSerializedData stream) { - file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - caption = stream.readString(); - geo_point = (InputGeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - crop = (InputPhotoCrop)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_photos_photo.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8852,6 +11383,31 @@ public class TLRPC { } } + public static class TL_photos_deletePhotos extends TLObject { + public static int constructor = 0x87cf7f2f; + + public ArrayList id = new ArrayList<>(); + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + Vector vector = new Vector(); + int size = stream.readInt32(exception); + for (int a = 0; a < size; a++) { + vector.objects.add(stream.readInt64(exception)); + } + return vector; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = id.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + id.get(a).serializeToStream(stream); + } + } + } + public static class TL_upload_getFile extends TLObject { public static int constructor = 0xe3a6cfb5; @@ -8859,14 +11415,8 @@ public class TLRPC { public int offset; public int limit; - public Class responseClass() { - return TL_upload_file.class; - } - - public void readParams(AbsSerializedData stream) { - location = (InputFileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - offset = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_upload_file.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8881,8 +11431,8 @@ public class TLRPC { public static int constructor = 0xc4f9186b; - public Class responseClass () { - return TL_config.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_config.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8894,8 +11444,8 @@ public class TLRPC { public static int constructor = 0x1fb33026; - public Class responseClass () { - return TL_nearestDc.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_nearestDc.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8911,15 +11461,8 @@ public class TLRPC { public String app_version; public String lang_code; - public Class responseClass () { - return help_AppUpdate.class; - } - - public void readParams(AbsSerializedData stream) { - device_model = stream.readString(); - system_version = stream.readString(); - app_version = stream.readString(); - lang_code = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return help_AppUpdate.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8936,16 +11479,8 @@ public class TLRPC { public ArrayList events = new ArrayList<>(); - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - events.add((TL_inputAppEvent)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8953,8 +11488,8 @@ public class TLRPC { stream.writeInt32(0x1cb5c415); int count = events.size(); stream.writeInt32(count); - for (TL_inputAppEvent event : events) { - event.serializeToStream(stream); + for (int a = 0; a < count; a++) { + events.get(a).serializeToStream(stream); } } } @@ -8964,12 +11499,8 @@ public class TLRPC { public String lang_code; - public Class responseClass () { - return TL_help_inviteText.class; - } - - public void readParams(AbsSerializedData stream) { - lang_code = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_help_inviteText.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -8986,15 +11517,8 @@ public class TLRPC { public int max_id; public int limit; - public Class responseClass () { - return photos_Photos.class; - } - - public void readParams(AbsSerializedData stream) { - user_id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - offset = stream.readInt32(); - max_id = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return photos_Photos.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9013,14 +11537,8 @@ public class TLRPC { public int id; public long random_id; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - id = stream.readInt32(); - random_id = stream.readInt64(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9039,23 +11557,8 @@ public class TLRPC { public String message; public InputMedia media; - public Class responseClass () { - return Updates.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - contacts.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - stream.readInt32(); - count = stream.readInt32(); - for (int a = 0; a < count; a++) { - random_id.add(stream.readInt64()); - } - message = stream.readString(); - media = (InputMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9084,14 +11587,8 @@ public class TLRPC { public int radius; public int limit; - public Class responseClass () { - return TL_geochats_located.class; - } - - public void readParams(AbsSerializedData stream) { - geo_point = (InputGeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - radius = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_geochats_located.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9108,13 +11605,8 @@ public class TLRPC { public int offset; public int limit; - public Class responseClass () { - return geochats_Messages.class; - } - - public void readParams(AbsSerializedData stream) { - offset = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return geochats_Messages.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9129,12 +11621,8 @@ public class TLRPC { public TL_inputGeoChat peer; - public Class responseClass () { - return TL_geochats_statedMessage.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_geochats_statedMessage.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9148,12 +11636,8 @@ public class TLRPC { public TL_inputGeoChat peer; - public Class responseClass() { - return TL_messages_chatFull.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_messages_chatFull.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9169,14 +11653,8 @@ public class TLRPC { public String title; public String address; - public Class responseClass () { - return TL_geochats_statedMessage.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - title = stream.readString(); - address = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_geochats_statedMessage.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9193,13 +11671,8 @@ public class TLRPC { public TL_inputGeoChat peer; public InputChatPhoto photo; - public Class responseClass () { - return TL_geochats_statedMessage.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - photo = (InputChatPhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_geochats_statedMessage.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9221,19 +11694,8 @@ public class TLRPC { public int max_id; public int limit; - public Class responseClass () { - return geochats_Messages.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - q = stream.readString(); - filter = (MessagesFilter)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - min_date = stream.readInt32(); - max_date = stream.readInt32(); - offset = stream.readInt32(); - max_id = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return geochats_Messages.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9257,15 +11719,8 @@ public class TLRPC { public int max_id; public int limit; - public Class responseClass () { - return geochats_Messages.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - offset = stream.readInt32(); - max_id = stream.readInt32(); - limit = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return geochats_Messages.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9283,13 +11738,8 @@ public class TLRPC { public TL_inputGeoChat peer; public boolean typing; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - typing = stream.readBool(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9306,14 +11756,8 @@ public class TLRPC { public String message; public long random_id; - public Class responseClass () { - return TL_geochats_statedMessage.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - message = stream.readString(); - random_id = stream.readInt64(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_geochats_statedMessage.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9331,14 +11775,8 @@ public class TLRPC { public InputMedia media; public long random_id; - public Class responseClass () { - return TL_geochats_statedMessage.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputGeoChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - media = (InputMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - random_id = stream.readInt64(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_geochats_statedMessage.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9357,15 +11795,8 @@ public class TLRPC { public String address; public String venue; - public Class responseClass () { - return TL_geochats_statedMessage.class; - } - - public void readParams(AbsSerializedData stream) { - title = stream.readString(); - geo_point = (InputGeoPoint)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - address = stream.readString(); - venue = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_geochats_statedMessage.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9383,13 +11814,8 @@ public class TLRPC { public int version; public int random_length; - public Class responseClass () { - return messages_DhConfig.class; - } - - public void readParams(AbsSerializedData stream) { - version = stream.readInt32(); - random_length = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_DhConfig.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9406,14 +11832,8 @@ public class TLRPC { public int random_id; public byte[] g_a; - public Class responseClass () { - return EncryptedChat.class; - } - - public void readParams(AbsSerializedData stream) { - user_id = (InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - random_id = stream.readInt32(); - g_a = stream.readByteArray(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return EncryptedChat.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9431,14 +11851,8 @@ public class TLRPC { public byte[] g_b; public long key_fingerprint; - public Class responseClass () { - return EncryptedChat.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputEncryptedChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - g_b = stream.readByteArray(); - key_fingerprint = stream.readInt64(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return EncryptedChat.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9454,12 +11868,8 @@ public class TLRPC { public int chat_id; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - chat_id = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9474,13 +11884,8 @@ public class TLRPC { public TL_inputEncryptedChat peer; public boolean typing; - public Class responseClass() { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputEncryptedChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - typing = stream.readBool(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9496,13 +11901,8 @@ public class TLRPC { public TL_inputEncryptedChat peer; public int max_date; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - peer = (TL_inputEncryptedChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - max_date = stream.readInt32(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9512,21 +11912,63 @@ public class TLRPC { } } - public static class TL_messages_deleteMessages extends TLObject { - public static int constructor = 0xa5f18925; + public static class TL_messages_receivedQueue extends TLObject { + public static int constructor = 0x55a5bb66; + + public int max_qts; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + Vector vector = new Vector(); + int size = stream.readInt32(exception); + for (int a = 0; a < size; a++) { + vector.objects.add(stream.readInt64(exception)); + } + return vector; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(max_qts); + } + } + + public static class TL_help_getSupport extends TLObject { + public static int constructor = 0x9cdf08cd; + + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_help_support.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_auth_sendSms extends TLObject { + public static int constructor = 0xda9f3e8; + + public String phone_number; + public String phone_code_hash; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_number); + stream.writeString(phone_code_hash); + } + } + + public static class TL_messages_readMessageContents extends TLObject { + public static int constructor = 0x36a73f77; public ArrayList id = new ArrayList<>(); - public Class responseClass () { - return TL_messages_affectedMessages.class; - } - - public void readParams(AbsSerializedData stream) { - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - id.add(stream.readInt32()); - } + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_messages_affectedMessages.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9540,12 +11982,278 @@ public class TLRPC { } } + public static class TL_account_checkUsername extends TLObject { + public static int constructor = 0x2714d86c; + + public String username; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(username); + } + } + + public static class TL_account_updateUsername extends TLObject { + public static int constructor = 0x3e0bdd7c; + + public String username; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return User.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(username); + } + } + + public static class TL_contacts_search extends TLObject { + public static int constructor = 0x11f812d8; + + public String q; + public int limit; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_contacts_found.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(q); + stream.writeInt32(limit); + } + } + + public static class TL_account_getPrivacy extends TLObject { + public static int constructor = 0xdadbc950; + + public TL_inputPrivacyKeyStatusTimestamp key; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_account_privacyRules.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + key.serializeToStream(stream); + } + } + + public static class TL_account_setPrivacy extends TLObject { + public static int constructor = 0xc9f81ce8; + + public TL_inputPrivacyKeyStatusTimestamp key; + public ArrayList rules = new ArrayList<>(); + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_account_privacyRules.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + key.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = rules.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + rules.get(a).serializeToStream(stream); + } + } + } + + public static class TL_account_deleteAccount extends TLObject { + public static int constructor = 0x418d4e0b; + + public String reason; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(reason); + } + } + + public static class TL_account_getAccountTTL extends TLObject { + public static int constructor = 0x8fc711d; + + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_accountDaysTTL.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_account_setAccountTTL extends TLObject { + public static int constructor = 0x2442485e; + + public TL_accountDaysTTL ttl; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + ttl.serializeToStream(stream); + } + } + + public static class TL_contacts_resolveUsername extends TLObject { + public static int constructor = 0xbf0131c; + + public String username; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return User.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(username); + } + } + + public static class TL_account_sendChangePhoneCode extends TLObject { + public static int constructor = 0xa407a8f4; + + public String phone_number; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_account_sentChangePhoneCode.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_number); + } + } + + public static class TL_account_changePhone extends TLObject { + public static int constructor = 0x70c32edb; + + public String phone_number; + public String phone_code_hash; + public String phone_code; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return User.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_number); + stream.writeString(phone_code_hash); + stream.writeString(phone_code); + } + } + + public static class TL_messages_getStickers extends TLObject { + public static int constructor = 0xae22e045; + + public String emoticon; + public String hash; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_Stickers.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(emoticon); + stream.writeString(hash); + } + } + + public static class TL_messages_getAllStickers extends TLObject { + public static int constructor = 0xaa3bc868; + + public String hash; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_AllStickers.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(hash); + } + } + + public static class TL_account_updateDeviceLocked extends TLObject { + public static int constructor = 0x38df3532; + + public int period; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(period); + } + } + + public static class TL_messages_getWebPagePreview extends TLObject { + public static int constructor = 0x25223e24; + + public String message; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return MessageMedia.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(message); + } + } + + public static class TL_account_getAuthorizations extends TLObject { + public static int constructor = 0xe320c158; + + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_account_authorizations.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_account_resetAuthorization extends TLObject { + public static int constructor = 0xdf77f3bc; + + public long hash; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(hash); + } + } + public static class TL_account_getPassword extends TLObject { public static int constructor = 0x548a30f5; - public Class responseClass () { - return account_Password.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return account_Password.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9558,12 +12266,8 @@ public class TLRPC { public byte[] current_password_hash; - public Class responseClass () { - return TL_account_passwordSettings.class; - } - - public void readParams(AbsSerializedData stream) { - current_password_hash = stream.readByteArray(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_account_passwordSettings.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9578,13 +12282,8 @@ public class TLRPC { public byte[] current_password_hash; public TL_account_passwordInputSettings new_settings; - public Class responseClass () { - return Bool.class; - } - - public void readParams(AbsSerializedData stream) { - current_password_hash = stream.readByteArray(); - new_settings = (TL_account_passwordInputSettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9599,12 +12298,8 @@ public class TLRPC { public byte[] password_hash; - public Class responseClass () { - return TL_auth_authorization.class; - } - - public void readParams(AbsSerializedData stream) { - password_hash = stream.readByteArray(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_authorization.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9617,8 +12312,8 @@ public class TLRPC { public static int constructor = 0xd897bc66; - public Class responseClass () { - return TL_auth_passwordRecovery.class; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_passwordRecovery.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9631,12 +12326,8 @@ public class TLRPC { public String code; - public Class responseClass () { - return TL_auth_authorization.class; - } - - public void readParams(AbsSerializedData stream) { - code = stream.readString(); + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_auth_authorization.TLdeserialize(stream, constructor, exception); } public void serializeToStream(AbsSerializedData stream) { @@ -9645,765 +12336,323 @@ public class TLRPC { } } + public static class TL_messages_exportChatInvite extends TLObject { + public static int constructor = 0x7d885289; + + public int chat_id; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return ExportedChatInvite.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(chat_id); + } + } + + public static class TL_messages_checkChatInvite extends TLObject { + public static int constructor = 0x3eadb1bb; + + public String hash; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return ChatInvite.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(hash); + } + } + + public static class TL_messages_importChatInvite extends TLObject { + public static int constructor = 0x6c50051c; + + public String hash; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(hash); + } + } + //manually created - public static class TL_documentAttributeSticker_old extends TL_documentAttributeSticker { - public static int constructor = 0xfb0a5727; - - public void readParams(AbsSerializedData stream) { - - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_messageMediaUnsupported_old extends TL_messageMediaUnsupported { - public static int constructor = 0x29632a36; - - - public void readParams(AbsSerializedData stream) { - bytes = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(bytes); - } - } - - public static class TL_config_old extends TL_config { - public static int constructor = 0x2e54dd74; - - public void readParams(AbsSerializedData stream) { - date = stream.readInt32(); - test_mode = stream.readBool(); - this_dc = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - dc_options.add((TL_dcOption) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); - } - chat_size_max = stream.readInt32(); - broadcast_size_max = stream.readInt32(); - expires = (int) (System.currentTimeMillis() / 1000) + 3600; - chat_big_size = 10; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(date); - stream.writeBool(test_mode); - stream.writeInt32(this_dc); - stream.writeInt32(0x1cb5c415); - int count = dc_options.size(); - stream.writeInt32(count); - for (TL_dcOption dc_option : dc_options) { - dc_option.serializeToStream(stream); - } - stream.writeInt32(chat_size_max); - stream.writeInt32(broadcast_size_max); - } - } - - public static class TL_document_old extends TL_document { - public static int constructor = 0x9efc6326; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - stream.readInt32(); - date = stream.readInt32(); - TL_documentAttributeFilename fileName = new TL_documentAttributeFilename(); - fileName.file_name = stream.readString(); - attributes.add(fileName); - mime_type = stream.readString(); - size = stream.readInt32(); - thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - dc_id = stream.readInt32(); - } - } - - public static class TL_decryptedMessageHolder extends TLObject { - public static int constructor = 0x555555F9; - - public long random_id; + //Photo start + public static class Photo extends TLObject { + public long id; + public long access_hash; + public int user_id; public int date; - public TL_decryptedMessageLayer layer; - public EncryptedFile file; - public boolean new_key_used; + public GeoPoint geo; + public ArrayList sizes = new ArrayList<>(); + public String caption; //custom - public void readParams(AbsSerializedData stream) { - random_id = stream.readInt64(); - date = stream.readInt32(); - layer = (TL_decryptedMessageLayer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - if (stream.readBool()) { - file = (EncryptedFile) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public static Photo TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Photo result = null; + switch(constructor) { + case 0xc3838076: + result = new TL_photo(); + break; + case 0x2331b22d: + result = new TL_photoEmpty(); + break; + case 0x22b56751: + result = new TL_photo_old(); //custom + break; } - new_key_used = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(random_id); - stream.writeInt32(date); - layer.serializeToStream(stream); - stream.writeBool(file != null); - if (file != null) { - file.serializeToStream(stream); - } - stream.writeBool(new_key_used); - } - } - - public static class TL_messages_sendEncryptedService extends TLObject { - public static int constructor = 0x32d439a4; - - public TL_inputEncryptedChat peer; - public long random_id; - public ByteBufferDesc data; - - public Class responseClass () { - return messages_SentEncryptedMessage.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - stream.writeInt64(random_id); - stream.writeByteBuffer(data); - } - - @Override - public void freeResources() { - if (disableFree) { - return; - } - if (data != null) { - BuffersStorage.getInstance().reuseFreeBuffer(data); - data = null; - } - } - } - - public static class TL_userDeleted_old extends TL_userDeleted { - public static int constructor = 0xb29ad7cc; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - } - } - - public static class TL_userForeign_old extends TL_userForeign { - public static int constructor = 0x5214c89d; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - access_hash = stream.readInt64(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeInt64(access_hash); - photo.serializeToStream(stream); - status.serializeToStream(stream); - } - } - - public static class TL_userRequest_old extends TL_userRequest { - public static int constructor = 0x22e8ceb0; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - access_hash = stream.readInt64(); - phone = stream.readString(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeInt64(access_hash); - stream.writeString(phone); - photo.serializeToStream(stream); - status.serializeToStream(stream); - } - } - - public static class TL_userContact_old extends TL_userContact { - public static int constructor = 0xf2fb8319; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - access_hash = stream.readInt64(); - phone = stream.readString(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeInt64(access_hash); - stream.writeString(phone); - photo.serializeToStream(stream); - status.serializeToStream(stream); - } - } - - public static class TL_userSelf_old2 extends TL_userSelf { - public static int constructor = 0x7007b451; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - username = stream.readString(); - phone = stream.readString(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - inactive = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(username); - stream.writeString(phone); - photo.serializeToStream(stream); - status.serializeToStream(stream); - stream.writeBool(inactive); - } - } - - public static class TL_userSelf_old extends TL_userSelf { - public static int constructor = 0x720535ec; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - first_name = stream.readString(); - last_name = stream.readString(); - phone = stream.readString(); - photo = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - status = (UserStatus)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - inactive = stream.readBool(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(id); - stream.writeString(first_name); - stream.writeString(last_name); - stream.writeString(phone); - photo.serializeToStream(stream); - status.serializeToStream(stream); - stream.writeBool(inactive); - } - } - - public static class TL_set_client_DH_params extends TLObject { - public static int constructor = 0xf5045f1f; - - public byte[] nonce; - public byte[] server_nonce; - public ByteBufferDesc encrypted_data; - - public Class responseClass () { - return Set_client_DH_params_answer.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeRaw(nonce); - stream.writeRaw(server_nonce); - stream.writeByteBuffer(encrypted_data); - } - - @Override - public void freeResources() { - if (disableFree) { - return; - } - if (encrypted_data != null) { - BuffersStorage.getInstance().reuseFreeBuffer(encrypted_data); - encrypted_data = null; - } - } - } - - public static class TL_messages_sendEncrypted extends TLObject { - public static int constructor = 0xa9776773; - - public TL_inputEncryptedChat peer; - public long random_id; - public ByteBufferDesc data; - - public Class responseClass () { - return messages_SentEncryptedMessage.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - stream.writeInt64(random_id); - stream.writeByteBuffer(data); - } - - @Override - public void freeResources() { - if (disableFree) { - return; - } - if (data != null) { - BuffersStorage.getInstance().reuseFreeBuffer(data); - data = null; - } - } - } - - public static class TL_decryptedMessageService_old extends TL_decryptedMessageService { - public static int constructor = 0xaa48327d; - - - public void readParams(AbsSerializedData stream) { - random_id = stream.readInt64(); - random_bytes = stream.readByteArray(); - action = (DecryptedMessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(random_id); - stream.writeByteArray(random_bytes); - action.serializeToStream(stream); - } - } - - public static class TL_decryptedMessage_old extends TL_decryptedMessage { - public static int constructor = 0x1f814f1f; - - - public void readParams(AbsSerializedData stream) { - random_id = stream.readInt64(); - random_bytes = stream.readByteArray(); - message = stream.readString(); - media = (DecryptedMessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(random_id); - stream.writeByteArray(random_bytes); - stream.writeString(message); - media.serializeToStream(stream); - } - } - - public static class TL_messages_sendEncryptedFile extends TLObject { - public static int constructor = 0x9a901b66; - - public TL_inputEncryptedChat peer; - public long random_id; - public ByteBufferDesc data; - public InputEncryptedFile file; - - public Class responseClass () { - return messages_SentEncryptedMessage.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - stream.writeInt64(random_id); - stream.writeByteBuffer(data); - file.serializeToStream(stream); - } - - @Override - public void freeResources() { - if (disableFree) { - return; - } - if (data != null) { - BuffersStorage.getInstance().reuseFreeBuffer(data); - data = null; - } - } - } - - public static class UserStatus extends TLObject { - public int expires; - } - - public static class TL_userStatusLastWeek extends UserStatus { - public static int constructor = 0x7bf09fc; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_userStatusEmpty extends UserStatus { - public static int constructor = 0x9d05049; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_userStatusLastMonth extends UserStatus { - public static int constructor = 0x77ebc742; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_userStatusOnline extends UserStatus { - public static int constructor = 0xedb93949; - - - public void readParams(AbsSerializedData stream) { - expires = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(expires); - } - } - - public static class TL_userStatusRecently extends UserStatus { - public static int constructor = 0xe26f42f1; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_userStatusOffline extends UserStatus { - public static int constructor = 0x8c703f; - - - public void readParams(AbsSerializedData stream) { - expires = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(expires); - } - } - - public static class TL_upload_file extends TLObject { - public static int constructor = 0x96a18d5; - - public storage_FileType type; - public int mtime; - public ByteBufferDesc bytes; - - public void readParams(AbsSerializedData stream) { - type = (storage_FileType)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - mtime = stream.readInt32(); - bytes = stream.readByteBuffer(); - } - - @Override - public void freeResources() { - if (disableFree) { - return; - } - if (bytes != null) { - BuffersStorage.getInstance().reuseFreeBuffer(bytes); - bytes = null; - } - } - } - - public static class TL_messages_receivedQueue extends TLObject { - public static int constructor = 0x55a5bb66; - - public int max_qts; - - public Class responseClass () { - return Vector.class; - } - - public void parseVector(Vector vector, AbsSerializedData data) { - int size = data.readInt32(); - for (int a = 0; a < size; a++) { - vector.objects.add(data.readInt64()); - } - } - - public void readParams(AbsSerializedData stream) { - max_qts = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(max_qts); - } - } - - public static class TL_account_getWallPapers extends TLObject { - public static int constructor = 0xc04cfac2; - - public Class responseClass () { - return Vector.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - - public void parseVector(Vector vector, AbsSerializedData data) { - int size = data.readInt32(); - for (int a = 0; a < size; a++) { - vector.objects.add(TLClassStore.Instance().TLdeserialize(data, data.readInt32())); - } - } - } - - public static class TL_get_future_salts extends TLObject { - public static int constructor = 0xb921bd04; - - public int num; - - public int layer () { - return 0; - } - - public Class responseClass () { - return TL_futuresalts.class; - } - - public void readParams(AbsSerializedData stream) { - num = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(num); - } - } - - public static class TL_rpc_drop_answer extends TLObject { - public static int constructor = 0x58e4a740; - - public long req_msg_id; - - public int layer () { - return 0; - } - - public Class responseClass() { - return RpcDropAnswer.class; - } - - public void readParams(AbsSerializedData stream) { - req_msg_id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(req_msg_id); - } - } - - public static class TL_msg_container extends TLObject { - public ArrayList messages; - - public static int constructor = 0x73f1f8dc; - - public void readParams(AbsSerializedData stream) { - messages = new ArrayList<>(); - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - TL_protoMessage message = new TL_protoMessage(); - message.msg_id = stream.readInt64(); - message.seqno = stream.readInt32(); - message.bytes = stream.readInt32(); - int constructor = stream.readInt32(); - TLObject request = ConnectionsManager.getInstance().getRequestWithMessageId(message.msg_id); - message.body = TLClassStore.Instance().TLdeserialize(stream, constructor, request); - messages.add(message); - } - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(messages.size()); - for (TLObject obj : messages) { - TL_protoMessage proto = (TL_protoMessage)obj; - stream.writeInt64(proto.msg_id); - stream.writeInt32(proto.seqno); - stream.writeInt32(proto.bytes); - proto.body.serializeToStream(stream); - } - } - } - - public static class TL_rpc_result extends TLObject { - public static int constructor = 0xf35c6d01; - - public long req_msg_id; - public TLObject result; - - public void readParams(AbsSerializedData stream) { - req_msg_id = stream.readInt64(); - TLObject request = ConnectionsManager.getInstance().getRequestWithMessageId(req_msg_id); - result = TLClassStore.Instance().TLdeserialize(stream, stream.readInt32(), request); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(req_msg_id); - result.serializeToStream(stream); - } - - @Override - public void freeResources() { - if (disableFree) { - return; + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Photo", constructor)); } if (result != null) { - result.freeResources(); + result.readParams(stream, exception); } + return result; } } - public static class TL_futuresalts extends TLObject { - public static int constructor = 0xae500895; + public static class TL_photo_old extends TL_photo { + public static int constructor = 0x22b56751; - public long req_msg_id; - public int now; - public ArrayList salts = new ArrayList<>(); - public void readParams(AbsSerializedData stream) { - req_msg_id = stream.readInt64(); - now = stream.readInt32(); - int count = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + caption = stream.readString(exception); + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + stream.readInt32(exception); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - TL_futureSalt salt = new TL_futureSalt(); - salt.readParams(stream); - salts.add(salt); + sizes.add(PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception)); } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(req_msg_id); - stream.writeInt32(now); - int count = salts.size(); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeString(caption); + geo.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = sizes.size(); stream.writeInt32(count); - for (TL_futureSalt salt : salts) { - salt.serializeToStream(stream); + for (int a = 0; a < count; a++) { + sizes.get(a).serializeToStream(stream); } } } + //Photo end - public static class TL_gzip_packed extends TLObject { - public static int constructor = 0x3072cfa1; + //EncryptedChat start + public static class EncryptedChat extends TLObject { + public int id; + public long access_hash; + public int date; + public int admin_id; + public int participant_id; + public byte[] g_a_or_b; + public long key_fingerprint; + public byte[] g_a; + public byte[] a_or_b; //custom + public byte[] auth_key; //custom + public int user_id; //custom + public int ttl; //custom + public int layer; //custom + public int seq_in; //custom + public int seq_out; //custom + public byte[] key_hash; //custom + public short key_use_count_in; //custom + public short key_use_count_out; //custom + public long exchange_id; //custom + public int key_create_date; //custom + public long future_key_fingerprint; //custom + public byte[] future_auth_key; //custom - public byte[] packed_data; - - public void readParams(AbsSerializedData stream) { - packed_data = stream.readByteArray(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeByteArray(packed_data); + public static EncryptedChat TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + EncryptedChat result = null; + switch(constructor) { + case 0x3bf703dc: + result = new TL_encryptedChatWaiting(); + break; + case 0xab7ec0a0: + result = new TL_encryptedChatEmpty(); + break; + case 0x13d6dd27: + result = new TL_encryptedChatDiscarded(); + break; + case 0xfa56ce36: + result = new TL_encryptedChat(); + break; + case 0xc878527e: + result = new TL_encryptedChatRequested(); + break; + case 0x6601d14f: + result = new TL_encryptedChat_old(); //custom + break; + case 0xfda9a7b7: + result = new TL_encryptedChatRequested_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in EncryptedChat", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; } } + public static class TL_encryptedChat_old extends TL_encryptedChat { + public static int constructor = 0x6601d14f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + admin_id = stream.readInt32(exception); + participant_id = stream.readInt32(exception); + g_a_or_b = stream.readByteArray(exception); + stream.readByteArray(exception); + key_fingerprint = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData 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(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + admin_id = stream.readInt32(exception); + participant_id = stream.readInt32(exception); + g_a = stream.readByteArray(exception); + stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData 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); + } + } + //EncryptedChat end + + //Message start public static class Message extends TLObject { - public int flags; public int id; - public int fwd_from_id; - public int fwd_date; public int from_id; public Peer to_id; public int date; + public MessageAction action; + public int fwd_from_id; + public int fwd_date; + public int reply_to_msg_id; public String message; public MessageMedia media; - public int reply_to_msg_id; - public MessageAction action; - public int send_state = 0; - public int fwd_msg_id = 0; - public String attachPath = ""; - public long random_id; - public int local_id = 0; - public long dialog_id; - public int ttl; - public int destroyTime; - public int layer; - public int seq_in; - public int seq_out; - public TLRPC.Message replyMessage; - public VideoEditedInfo videoEditedInfo = null; + public int flags; + public int send_state = 0; //custom + public int fwd_msg_id = 0; //custom + public String attachPath = ""; //custom + public long random_id; //custom + public int local_id = 0; //custom + public long dialog_id; //custom + public int ttl; //custom + public int destroyTime; //custom + public int layer; //custom + public int seq_in; //custom + public int seq_out; //custom + public TLRPC.Message replyMessage; //custom + public VideoEditedInfo videoEditedInfo = null; //custom + + public static Message TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Message result = null; + switch(constructor) { + case 0x1d86f70e: + result = new TL_messageService(); + break; + case 0xa7ab1991: + result = new TL_message(); + break; + case 0x83e5de54: + result = new TL_messageEmpty(); + break; + case 0xa367e716: + result = new TL_messageForwarded_old2(); //custom + break; + case 0x5f46804: + result = new TL_messageForwarded_old(); //custom + break; + case 0x567699b3: + result = new TL_message_old2(); //custom + break; + case 0x9f8d60bb: + result = new TL_messageService_old(); //custom + break; + case 0x22eb6aba: + result = new TL_message_old(); //custom + break; + case 0x555555F8: + result = new TL_message_secret(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Message", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_messageForwarded_old2 extends Message { public static int constructor = 0xa367e716; - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt32(); - fwd_from_id = stream.readInt32(); - fwd_date = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - date = stream.readInt32(); - message = stream.readString(); + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt32(exception); + fwd_from_id = stream.readInt32(exception); + fwd_date = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + date = stream.readInt32(exception); + message = stream.readString(exception); flags |= MESSAGE_FLAG_FWD; - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); if (id < 0) { - fwd_msg_id = stream.readInt32(); + fwd_msg_id = stream.readInt32(exception); } if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(); + attachPath = stream.readString(exception); } if (id < 0 && message.length() > 6 && media instanceof TL_messageMediaVideo) { videoEditedInfo = new VideoEditedInfo(); @@ -10432,31 +12681,32 @@ public class TLRPC { public static class TL_message extends Message { public static int constructor = 0xa7ab1991; - - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - if ((flags & MESSAGE_FLAG_FWD) != 0) { - fwd_from_id = stream.readInt32(); - fwd_date = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + if ((flags & 4) != 0) { + fwd_from_id = stream.readInt32(exception); } - if ((flags & MESSAGE_FLAG_REPLY) != 0) { - reply_to_msg_id = stream.readInt32(); + if ((flags & 4) != 0) { + fwd_date = stream.readInt32(exception); } - date = stream.readInt32(); - message = stream.readString(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + if ((flags & 8) != 0) { + reply_to_msg_id = stream.readInt32(exception); + } + date = stream.readInt32(exception); + message = stream.readString(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(); + attachPath = stream.readString(exception); } if (id < 0 && message.length() > 6 && media instanceof TL_messageMediaVideo) { videoEditedInfo = new VideoEditedInfo(); videoEditedInfo.parseString(message); } if ((flags & MESSAGE_FLAG_FWD) != 0 && id < 0) { - fwd_msg_id = stream.readInt32(); + fwd_msg_id = stream.readInt32(exception); } } @@ -10466,11 +12716,13 @@ public class TLRPC { stream.writeInt32(id); stream.writeInt32(from_id); to_id.serializeToStream(stream); - if ((flags & MESSAGE_FLAG_FWD) != 0) { + if ((flags & 4) != 0) { stream.writeInt32(fwd_from_id); + } + if ((flags & 4) != 0) { stream.writeInt32(fwd_date); } - if ((flags & MESSAGE_FLAG_REPLY) != 0) { + if ((flags & 8) != 0) { stream.writeInt32(reply_to_msg_id); } stream.writeInt32(date); @@ -10487,16 +12739,16 @@ public class TLRPC { public static int constructor = 0x567699b3; - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - date = stream.readInt32(); - message = stream.readString(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + date = stream.readInt32(exception); + message = stream.readString(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(); + attachPath = stream.readString(exception); } if (id < 0 && message.length() > 6 && media instanceof TL_messageMediaVideo) { videoEditedInfo = new VideoEditedInfo(); @@ -10517,42 +12769,18 @@ public class TLRPC { } } - public static class TL_messageService extends Message { - public static int constructor = 0x1d86f70e; - - - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - date = stream.readInt32(); - action = (MessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(flags); - stream.writeInt32(id); - stream.writeInt32(from_id); - to_id.serializeToStream(stream); - stream.writeInt32(date); - action.serializeToStream(stream); - } - } - public static class TL_messageService_old extends TL_messageService { public static int constructor = 0x9f8d60bb; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - flags |= stream.readBool() ? MESSAGE_FLAG_OUT : 0; - flags |= stream.readBool() ? MESSAGE_FLAG_UNREAD : 0; - date = stream.readInt32(); - action = (MessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + flags |= stream.readBool(exception) ? MESSAGE_FLAG_OUT : 0; + flags |= stream.readBool(exception) ? MESSAGE_FLAG_UNREAD : 0; + date = stream.readInt32(exception); + action = MessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { @@ -10571,23 +12799,23 @@ public class TLRPC { public static int constructor = 0x5f46804; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - fwd_from_id = stream.readInt32(); - fwd_date = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - flags |= stream.readBool() ? MESSAGE_FLAG_OUT : 0; - flags |= stream.readBool() ? MESSAGE_FLAG_UNREAD : 0; + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + fwd_from_id = stream.readInt32(exception); + fwd_date = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + flags |= stream.readBool(exception) ? MESSAGE_FLAG_OUT : 0; + flags |= stream.readBool(exception) ? MESSAGE_FLAG_UNREAD : 0; flags |= MESSAGE_FLAG_FWD; - date = stream.readInt32(); - message = stream.readString(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + date = stream.readInt32(exception); + message = stream.readString(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); if (id < 0) { - fwd_msg_id = stream.readInt32(); + fwd_msg_id = stream.readInt32(exception); } if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(); + attachPath = stream.readString(exception); } if (id < 0 && message.length() > 6 && media instanceof TL_messageMediaVideo) { videoEditedInfo = new VideoEditedInfo(); @@ -10617,17 +12845,17 @@ public class TLRPC { public static class TL_message_old extends TL_message { public static int constructor = 0x22eb6aba; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - flags |= stream.readBool() ? MESSAGE_FLAG_OUT : 0; - flags |= stream.readBool() ? MESSAGE_FLAG_UNREAD : 0; - date = stream.readInt32(); - message = stream.readString(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + flags |= stream.readBool(exception) ? MESSAGE_FLAG_OUT : 0; + flags |= stream.readBool(exception) ? MESSAGE_FLAG_UNREAD : 0; + date = stream.readInt32(exception); + message = stream.readString(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(); + attachPath = stream.readString(exception); } if (id < 0 && message.length() > 6 && media instanceof TL_messageMediaVideo) { videoEditedInfo = new VideoEditedInfo(); @@ -10652,17 +12880,17 @@ public class TLRPC { public static class TL_message_secret extends TL_message { public static int constructor = 0x555555F8; - public void readParams(AbsSerializedData stream) { - flags = stream.readInt32(); - id = stream.readInt32(); - ttl = stream.readInt32(); - from_id = stream.readInt32(); - to_id = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - date = stream.readInt32(); - message = stream.readString(); - media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readInt32(exception); + ttl = stream.readInt32(exception); + from_id = stream.readInt32(exception); + to_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + date = stream.readInt32(exception); + message = stream.readString(exception); + media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); if (id < 0 || (media != null && !(media instanceof TL_messageMediaEmpty) && message != null && message.length() != 0 && message.startsWith("-1"))) { - attachPath = stream.readString(); + attachPath = stream.readString(exception); } if (id < 0 && message.length() > 6 && media instanceof TL_messageMediaVideo) { videoEditedInfo = new VideoEditedInfo(); @@ -10683,12 +12911,294 @@ public class TLRPC { stream.writeString(attachPath); } } + //Message end - public static class Vector extends TLObject { - public static int constructor = 0x1cb5c415; - public ArrayList objects = new ArrayList<>(); + //MessageAction start + public static class MessageAction extends TLObject { + public Photo photo; + public int user_id; + public int inviter_id; + public String title; + public ArrayList users = new ArrayList<>(); + public String address; + public int ttl; + public DecryptedMessageAction encryptedAction; + public UserProfilePhoto newUserPhoto; + + public static MessageAction TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + MessageAction result = null; + switch(constructor) { + case 0x7fcb13a8: + result = new TL_messageActionChatEditPhoto(); + break; + case 0xb2ae9b0c: + result = new TL_messageActionChatDeleteUser(); + break; + case 0xf89cf5e8: + result = new TL_messageActionChatJoinedByLink(); + break; + case 0x95e3fbef: + result = new TL_messageActionChatDeletePhoto(); + break; + case 0x5e3cfc4b: + result = new TL_messageActionChatAddUser(); + break; + case 0xa6638b9a: + result = new TL_messageActionChatCreate(); + break; + case 0xb6aef7b0: + result = new TL_messageActionEmpty(); + break; + case 0xb5a1ce5a: + result = new TL_messageActionChatEditTitle(); + break; + case 0x6f038ebc: + result = new TL_messageActionGeoChatCreate(); + break; + case 0xc7d53de: + result = new TL_messageActionGeoChatCheckin(); + break; + case 0x55555552: + result = new TL_messageActionTTLChange(); //custom + break; + case 0x55555557: + result = new TL_messageActionCreatedBroadcastList(); //custom + break; + case 0x55555551: + result = new TL_messageActionUserUpdatedPhoto(); //custom + break; + case 0x55555550: + result = new TL_messageActionUserJoined(); //custom + break; + case 0x555555F5: + result = new TL_messageActionLoginUnknownLocation(); //custom + break; + case 0x555555F7: + result = new TL_messageEncryptedAction(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in MessageAction", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } + public static class TL_messageActionTTLChange extends MessageAction { + public static int constructor = 0x55555552; + + public void readParams(AbsSerializedData stream, boolean exception) { + ttl = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(ttl); + } + } + + public static class TL_messageActionCreatedBroadcastList extends MessageAction { + public static int constructor = 0x55555557; + + public void readParams(AbsSerializedData stream, boolean exception) { + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messageActionUserUpdatedPhoto extends MessageAction { + public static int constructor = 0x55555551; + + public void readParams(AbsSerializedData stream, boolean exception) { + newUserPhoto = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + newUserPhoto.serializeToStream(stream); + } + } + + public static class TL_messageActionUserJoined extends MessageAction { + public static int constructor = 0x55555550; + + public void readParams(AbsSerializedData stream, boolean exception) { + + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_messageActionLoginUnknownLocation extends MessageAction { + public static int constructor = 0x555555F5; + + public void readParams(AbsSerializedData stream, boolean exception) { + title = stream.readString(exception); + address = stream.readString(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(title); + stream.writeString(address); + } + } + + public static class TL_messageEncryptedAction extends MessageAction { + public static int constructor = 0x555555F7; + + public void readParams(AbsSerializedData stream, boolean exception) { + encryptedAction = DecryptedMessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + encryptedAction.serializeToStream(stream); + } + } + //MessageAction end + + //InputEncryptedFile start + public static class InputEncryptedFile extends TLObject { + public long id; + public long access_hash; + public int parts; + public int key_fingerprint; + public String md5_checksum; + public byte[] key; //custom + public byte[] iv; //custom + + public static InputEncryptedFile TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + InputEncryptedFile result = null; + switch(constructor) { + case 0x5a17b5e5: + result = new TL_inputEncryptedFile(); + break; + case 0x2dc173c8: + result = new TL_inputEncryptedFileBigUploaded(); + break; + case 0x1837c364: + result = new TL_inputEncryptedFileEmpty(); + break; + case 0x64bd0306: + result = new TL_inputEncryptedFileUploaded(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputEncryptedFile", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + //InputEncryptedFile end + + //UserStatus start + public static class UserStatus extends TLObject { + public int expires; + + public static UserStatus TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + UserStatus result = null; + switch(constructor) { + case 0x8c703f: + result = new TL_userStatusOffline(); + break; + case 0x7bf09fc: + result = new TL_userStatusLastWeek(); + break; + case 0x9d05049: + result = new TL_userStatusEmpty(); + break; + case 0x77ebc742: + result = new TL_userStatusLastMonth(); + break; + case 0xedb93949: + result = new TL_userStatusOnline(); + break; + case 0xe26f42f1: + result = new TL_userStatusRecently(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in UserStatus", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_userStatusOffline extends UserStatus { + public static int constructor = 0x8c703f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + expires = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(expires); + } + } + //UserStatus end + + //TL_dialog start + public static class TL_dialog extends TLObject { + public static int constructor = 0xc1dd804a; + + public Peer peer; + public int top_message; + public int read_inbox_max_id; + public int unread_count; + public PeerNotifySettings notify_settings; + public int last_message_date; //custom + public long id; //custom + public int last_read; //custom + + public static TL_dialog TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_dialog.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_dialog", constructor)); + } else { + return null; + } + } + TL_dialog result = new TL_dialog(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + peer = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + top_message = stream.readInt32(exception); + read_inbox_max_id = stream.readInt32(exception); + unread_count = stream.readInt32(exception); + notify_settings = PeerNotifySettings.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt32(top_message); + stream.writeInt32(read_inbox_max_id); + stream.writeInt32(unread_count); + notify_settings.serializeToStream(stream); + } + } + //TL_dialog end + + //User start public static class User extends TLObject { public int id; public String first_name; @@ -10698,15 +13208,63 @@ public class TLRPC { public String phone; public UserProfilePhoto photo; public UserStatus status; - public boolean inactive; + + public static User TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + User result = null; + switch(constructor) { + case 0xcab35e18: + result = new TL_userContact(); + break; + case 0xd9ccc4ef: + result = new TL_userRequest(); + break; + case 0x75cf7a8: + result = new TL_userForeign(); + break; + case 0xd6016d7a: + result = new TL_userDeleted(); + break; + case 0x1c60e608: + result = new TL_userSelf(); + break; + case 0x200250ba: + result = new TL_userEmpty(); + break; + case 0xb29ad7cc: + result = new TL_userDeleted_old(); //custom + break; + case 0x5214c89d: + result = new TL_userForeign_old(); //custom + break; + case 0x22e8ceb0: + result = new TL_userRequest_old(); //custom + break; + case 0xf2fb8319: + result = new TL_userContact_old(); //custom + break; + case 0x7007b451: + result = new TL_userSelf_old2(); //custom + break; + case 0x720535ec: + result = new TL_userSelf_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in User", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } public static class TL_userEmpty extends User { public static int constructor = 0x200250ba; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); first_name = "DELETED"; last_name = ""; @@ -10720,224 +13278,305 @@ public class TLRPC { } } - public static class TL_chatEmpty extends Chat { - public static int constructor = 0x9ba2d800; + public static class TL_userDeleted_old extends TL_userDeleted { + public static int constructor = 0xb29ad7cc; - public void readParams(AbsSerializedData stream) { - id = stream.readInt32(); - - title = "DELETED"; + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); } } - public static class TL_userProfilePhotoOld extends UserProfilePhoto { - public static int constructor = 0x990d1493; + public static class TL_userForeign_old extends TL_userForeign { + public static int constructor = 0x5214c89d; - public void readParams(AbsSerializedData stream) { - photo_small = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - photo_big = (FileLocation)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + access_hash = stream.readInt64(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - photo_small.serializeToStream(stream); - photo_big.serializeToStream(stream); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt64(access_hash); + photo.serializeToStream(stream); + status.serializeToStream(stream); } } - public static class TL_ping extends TLObject { - public static int constructor = 0x7abe77ec; + public static class TL_userRequest_old extends TL_userRequest { + public static int constructor = 0x22e8ceb0; - public long ping_id; - public Class responseClass () { - return TL_pong.class; - } - - public int layer () { - return 0; - } - - public void readParams(AbsSerializedData stream) { - ping_id = stream.readInt64(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + access_hash = stream.readInt64(exception); + phone = stream.readString(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(ping_id); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt64(access_hash); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); } } - public static class TL_ping_delay_disconnect extends TLObject { - public static int constructor = 0xf3427b8c; + public static class TL_userContact_old extends TL_userContact { + public static int constructor = 0xf2fb8319; - public long ping_id; - public int disconnect_delay; - public Class responseClass () { - return TL_pong.class; - } - - public int layer () { - return 0; - } - - public void readParams(AbsSerializedData stream) { - ping_id = stream.readInt64(); - disconnect_delay = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + access_hash = stream.readInt64(exception); + phone = stream.readString(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(ping_id); - stream.writeInt32(disconnect_delay); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeInt64(access_hash); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); } } - public static class TL_destroy_session extends TLObject { - public static int constructor = 0xe7512126; + public static class TL_userSelf_old2 extends TL_userSelf { + public static int constructor = 0x7007b451; - public long session_id; - public Class responseClass () { - return DestroySessionRes.class; - } - - public int layer () { - return 0; - } - - public void readParams(AbsSerializedData stream) { - session_id = stream.readInt64(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + username = stream.readString(exception); + phone = stream.readString(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); + stream.readBool(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(session_id); + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(username); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); + stream.writeBool(false); } } - public static class TL_destroy_sessions extends TLObject { - public static int constructor = 0xa13dc52f; + public static class TL_userSelf_old extends TL_userSelf { + public static int constructor = 0x720535ec; - public ArrayList session_ids = new ArrayList<>(); - public Class responseClass () { - return TL_destroy_sessions_res.class; - } - - public int layer () { - return 0; - } - - public void readParams(AbsSerializedData stream) { - int count = stream.readInt32(); - for (int a = 0; a < count; a++) { - session_ids.add(stream.readInt64()); - } + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + phone = stream.readString(exception); + photo = UserProfilePhoto.TLdeserialize(stream, stream.readInt32(exception), exception); + status = UserStatus.TLdeserialize(stream, stream.readInt32(exception), exception); + stream.readBool(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - int count = session_ids.size(); - stream.writeInt32(count); - for (Long session_id : session_ids) { - stream.writeInt64(session_id); - } + stream.writeInt32(id); + stream.writeString(first_name); + stream.writeString(last_name); + stream.writeString(phone); + photo.serializeToStream(stream); + status.serializeToStream(stream); + stream.writeBool(false); } } + //User end - public static class TL_dialog extends TLObject { - public static int constructor = 0xc1dd804a; - - public Peer peer; - public int top_message; - public int unread_count; - public int read_inbox_max_id; - public PeerNotifySettings notify_settings; - public int last_message_date; + //Video start + public static class Video extends TLObject { public long id; - public int last_read; - - public void readParams(AbsSerializedData stream) { - peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - top_message = stream.readInt32(); - read_inbox_max_id = stream.readInt32(); - unread_count = stream.readInt32(); - notify_settings = (PeerNotifySettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - peer.serializeToStream(stream); - stream.writeInt32(top_message); - stream.writeInt32(read_inbox_max_id); - stream.writeInt32(unread_count); - notify_settings.serializeToStream(stream); - } - } - - public static class EncryptedChat extends TLObject { - public int id; public long access_hash; - public int date; - public int admin_id; - public int participant_id; - public byte[] g_a_or_b; - public long key_fingerprint; - public byte[] g_a; - public byte[] a_or_b; - public byte[] auth_key; public int user_id; - public int ttl; - public int layer; - public int seq_in; - public int seq_out; - public byte[] key_hash; - public short key_use_count_in; - public short key_use_count_out; - public long exchange_id; - public int key_create_date; - public long future_key_fingerprint; - public byte[] future_auth_key; - } - - public static class FileLocation extends TLObject { + public int date; + public int duration; + public int size; + public PhotoSize thumb; public int dc_id; - public long volume_id; - public int local_id; - public long secret; - public String ext; - public byte[] key; - public byte[] iv; + public int w; + public int h; + public String caption; + public String mime_type; + public byte[] key; //custom + public byte[] iv; //custom + public VideoEditedInfo videoEditedInfo = null; //custom + + public static Video TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Video result = null; + switch(constructor) { + case 0xee9f4a4d: + result = new TL_video(); + break; + case 0xc10658a8: + result = new TL_videoEmpty(); + break; + case 0x5a04a49f: + result = new TL_video_old(); //custom + break; + case 0x55555553: + result = new TL_videoEncrypted(); //custom + break; + case 0x388fa391: + result = new TL_video_old2(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Video", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } } - public static class TL_fileEncryptedLocation extends FileLocation { - public static int constructor = 0x55555554; + public static class TL_video_old extends TL_video { + public static int constructor = 0x5a04a49f; - public void readParams(AbsSerializedData stream) { - dc_id = stream.readInt32(); - volume_id = stream.readInt64(); - local_id = stream.readInt32(); - secret = stream.readInt64(); - key = stream.readByteArray(); - iv = stream.readByteArray(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + caption = stream.readString(exception); + duration = stream.readInt32(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeString(caption); + stream.writeInt32(duration); + stream.writeInt32(size); + thumb.serializeToStream(stream); stream.writeInt32(dc_id); - stream.writeInt64(volume_id); - stream.writeInt32(local_id); - stream.writeInt64(secret); + stream.writeInt32(w); + stream.writeInt32(h); + } + } + + public static class TL_video_old2 extends TL_video { + public static int constructor = 0x388fa391; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + caption = stream.readString(exception); + duration = stream.readInt32(exception); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeString(caption); + stream.writeInt32(duration); + stream.writeString(mime_type); + stream.writeInt32(size); + thumb.serializeToStream(stream); + stream.writeInt32(dc_id); + stream.writeInt32(w); + stream.writeInt32(h); + } + } + + public static class TL_videoEncrypted extends TL_video { + public static int constructor = 0x55555553; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + caption = stream.readString(exception); + duration = stream.readInt32(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeString(caption); + stream.writeInt32(duration); + stream.writeInt32(size); + thumb.serializeToStream(stream); + stream.writeInt32(dc_id); + stream.writeInt32(w); + stream.writeInt32(h); stream.writeByteArray(key); stream.writeByteArray(iv); } @@ -10982,25 +13621,9 @@ public class TLRPC { } } } + //Video end - public static class Video extends TLObject { - public long id; - public long access_hash; - public int user_id; - public int date; - public String caption; - public int duration; - public String mime_type; - public int size; - public PhotoSize thumb; - public int dc_id; - public int w; - public int h; - public byte[] key; - public byte[] iv; - public VideoEditedInfo videoEditedInfo = null; - } - + //Document start public static class Document extends TLObject { public long id; public long access_hash; @@ -11010,76 +13633,56 @@ public class TLRPC { public PhotoSize thumb; public int dc_id; public ArrayList attributes = new ArrayList<>(); - public byte[] key; - public byte[] iv; - } + public byte[] key; //custom + public byte[] iv; //custom - public static class Audio extends TLObject { - public long id; - public long access_hash; - public int user_id; - public int date; - public int duration; - public String mime_type; - public int size; - public int dc_id; - public byte[] key; - public byte[] iv; - } - - public static class MessageAction extends TLObject { - public Photo photo; - public UserProfilePhoto newUserPhoto; - public int user_id; - public String title; - public ArrayList users = new ArrayList<>(); - public String address; - public int ttl; - public DecryptedMessageAction encryptedAction; - } - - public static class TL_messageActionTTLChange extends MessageAction { - public static int constructor = 0x55555552; - - public void readParams(AbsSerializedData stream) { - ttl = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt32(ttl); - } - } - - public static class TL_messageActionCreatedBroadcastList extends MessageAction { - public static int constructor = 0x55555557; - - public void readParams(AbsSerializedData stream) { - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); + public static Document TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Document result = null; + switch(constructor) { + case 0x36f8c871: + result = new TL_documentEmpty(); + break; + case 0xf9a39f4f: + result = new TL_document(); + break; + case 0x55555558: + result = new TL_documentEncrypted(); //custom + break; + case 0x55555556: + result = new TL_documentEncrypted_old(); //custom + break; + case 0x9efc6326: + result = new TL_document_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Document", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; } } public static class TL_documentEncrypted extends TL_document { public static int constructor = 0x55555558; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - date = stream.readInt32(); - mime_type = stream.readString(); - size = stream.readInt32(); - thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - dc_id = stream.readInt32(); - stream.readInt32(); - int count = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + stream.readInt32(exception); + int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - attributes.add((DocumentAttribute)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32())); + attributes.add(DocumentAttribute.TLdeserialize(stream, stream.readInt32(exception), exception)); } - key = stream.readByteArray(); - iv = stream.readByteArray(); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -11106,58 +13709,79 @@ public class TLRPC { public static int constructor = 0x55555556; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - stream.readInt32(); - date = stream.readInt32(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + stream.readInt32(exception); + date = stream.readInt32(exception); TL_documentAttributeFilename fileName = new TL_documentAttributeFilename(); - fileName.file_name = stream.readString(); + fileName.file_name = stream.readString(exception); attributes.add(fileName); - 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(); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); } } - public static class TL_videoEncrypted extends TL_video { - public static int constructor = 0x55555553; + public static class TL_document_old extends TL_document { + public static int constructor = 0x9efc6326; - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - user_id = stream.readInt32(); - date = stream.readInt32(); - caption = stream.readString(); - duration = stream.readInt32(); - size = stream.readInt32(); - thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - dc_id = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - key = stream.readByteArray(); - iv = stream.readByteArray(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + stream.readInt32(exception); + date = stream.readInt32(exception); + TL_documentAttributeFilename fileName = new TL_documentAttributeFilename(); + fileName.file_name = stream.readString(exception); + attributes.add(fileName); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + thumb = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); } + } + //Document end - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(user_id); - stream.writeInt32(date); - stream.writeString(caption); - stream.writeInt32(duration); - stream.writeInt32(size); - thumb.serializeToStream(stream); - stream.writeInt32(dc_id); - stream.writeInt32(w); - stream.writeInt32(h); - stream.writeByteArray(key); - stream.writeByteArray(iv); + //Audio start + public static class Audio extends TLObject { + public long id; + public long access_hash; + public int user_id; + public int date; + public int duration; + public String mime_type; + public int size; + public int dc_id; + public byte[] key; + public byte[] iv; + + public static Audio TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + Audio result = null; + switch(constructor) { + case 0x586988d8: + result = new TL_audioEmpty(); + break; + case 0xc7ac6496: + result = new TL_audio(); + break; + case 0x555555F6: + result = new TL_audioEncrypted(); //custom + break; + case 0x427425e7: + result = new TL_audio_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in Audio", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; } } @@ -11165,16 +13789,16 @@ public class TLRPC { public static int constructor = 0x555555F6; - public void readParams(AbsSerializedData 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(); - key = stream.readByteArray(); - iv = stream.readByteArray(); + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + duration = stream.readInt32(exception); + size = stream.readInt32(exception); + dc_id = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); } public void serializeToStream(AbsSerializedData stream) { @@ -11191,23 +13815,235 @@ public class TLRPC { } } - public static class TL_messageActionUserUpdatedPhoto extends MessageAction { - public static int constructor = 0x55555551; + public static class TL_audio_old extends TL_audio { + public static int constructor = 0x427425e7; - public void readParams(AbsSerializedData stream) { - newUserPhoto = (UserProfilePhoto)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + user_id = stream.readInt32(exception); + date = stream.readInt32(exception); + duration = stream.readInt32(exception); + size = stream.readInt32(exception); + dc_id = stream.readInt32(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - newUserPhoto.serializeToStream(stream); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(user_id); + stream.writeInt32(date); + stream.writeInt32(duration); + stream.writeInt32(size); + stream.writeInt32(dc_id); + } + } + //Audio end + + //SendMessageAction start + public static class SendMessageAction extends TLObject { + public int progress; + + public static SendMessageAction TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + SendMessageAction result = null; + switch(constructor) { + case 0xd52f73f7: + result = new TL_sendMessageRecordAudioAction(); + break; + case 0xf351d7ab: + result = new TL_sendMessageUploadAudioAction(); + break; + case 0xd1d34a26: + result = new TL_sendMessageUploadPhotoAction(); + break; + case 0xe9763aec: + result = new TL_sendMessageUploadVideoAction(); + break; + case 0xfd5ec8f5: + result = new TL_sendMessageCancelAction(); + break; + case 0x176f8ba1: + result = new TL_sendMessageGeoLocationAction(); + break; + case 0x628cbc6f: + result = new TL_sendMessageChooseContactAction(); + break; + case 0x16bf744e: + result = new TL_sendMessageTypingAction(); + break; + case 0xaa0cd9e4: + result = new TL_sendMessageUploadDocumentAction(); + break; + case 0xa187d66f: + result = new TL_sendMessageRecordVideoAction(); + break; + case 0x92042ff7: + result = new TL_sendMessageUploadVideoAction_old(); //custom + break; + case 0xe6ac8a6f: + result = new TL_sendMessageUploadAudioAction_old(); //custom + break; + case 0x990a3c1a: + result = new TL_sendMessageUploadPhotoAction_old(); //custom + break; + case 0x8faee98e: + result = new TL_sendMessageUploadDocumentAction_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in SendMessageAction", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; } } - public static class TL_messageActionUserJoined extends MessageAction { - public static int constructor = 0x55555550; + public static class TL_sendMessageUploadDocumentAction_old extends TL_sendMessageUploadDocumentAction { + public static int constructor = 0x8faee98e; - public void readParams(AbsSerializedData stream) { + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageUploadVideoAction_old extends TL_sendMessageUploadVideoAction { + public static int constructor = 0x92042ff7; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageUploadPhotoAction_old extends TL_sendMessageUploadPhotoAction { + public static int constructor = 0x990a3c1a; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + + public static class TL_sendMessageUploadAudioAction_old extends TL_sendMessageUploadAudioAction { + public static int constructor = 0xe6ac8a6f; + + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + } + } + //SendMessageAction end + + //FileLocation start + public static class FileLocation extends TLObject { + public int dc_id; + public long volume_id; + public int local_id; + public long secret; + public String ext; //custom + public byte[] key; //custom + public byte[] iv; //custom + + public static FileLocation TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + FileLocation result = null; + switch(constructor) { + case 0x53d69076: + result = new TL_fileLocation(); + break; + case 0x7c596b46: + result = new TL_fileLocationUnavailable(); + break; + case 0x55555554: + result = new TL_fileEncryptedLocation(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in FileLocation", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_fileEncryptedLocation extends FileLocation { + public static int constructor = 0x55555554; + + + public void readParams(AbsSerializedData stream, boolean exception) { + dc_id = stream.readInt32(exception); + volume_id = stream.readInt64(exception); + local_id = stream.readInt32(exception); + secret = stream.readInt64(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(dc_id); + stream.writeInt64(volume_id); + stream.writeInt32(local_id); + stream.writeInt64(secret); + stream.writeByteArray(key); + stream.writeByteArray(iv); + } + } + //FileLocation end + + //DocumentAttribute start + public static class DocumentAttribute extends TLObject { + public int w; + public int h; + public String file_name; + public int duration; + public String alt; + + public static DocumentAttribute TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + DocumentAttribute result = null; + switch(constructor) { + case 0x11b58939: + result = new TL_documentAttributeAnimated(); + break; + case 0x6c37c15c: + result = new TL_documentAttributeImageSize(); + break; + case 0x15590068: + result = new TL_documentAttributeFilename(); + break; + case 0x5910cccb: + result = new TL_documentAttributeVideo(); + break; + case 0x994c9882: + result = new TL_documentAttributeSticker(); + break; + case 0x51448e5: + result = new TL_documentAttributeAudio(); + break; + case 0xfb0a5727: + result = new TL_documentAttributeSticker_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in DocumentAttribute", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_documentAttributeSticker_old extends TL_documentAttributeSticker { + public static int constructor = 0xfb0a5727; + + public void readParams(AbsSerializedData stream, boolean exception) { } @@ -11215,22 +14051,649 @@ public class TLRPC { stream.writeInt32(constructor); } } + //DocumentAttribute end - public static class TL_messageActionLoginUnknownLocation extends MessageAction { - public static int constructor = 0x555555F5; + //MessageMedia start + public static class MessageMedia extends TLObject { + public Video video; + public String caption; + public Photo photo; + public WebPage webpage; + public Document document; + public GeoPoint geo; + public Audio audio; + public String title; + public String address; + public String provider; + public String venue_id; + public String phone_number; + public String first_name; + public String last_name; + public int user_id; + public byte[] bytes; //custom - public void readParams(AbsSerializedData stream) { - title = stream.readString(); - address = stream.readString(); + public static MessageMedia TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + MessageMedia result = null; + switch(constructor) { + case 0x5bcf1675: + result = new TL_messageMediaVideo(); + break; + case 0x3d8ce53d: + result = new TL_messageMediaPhoto(); + break; + case 0xa32dd600: + result = new TL_messageMediaWebPage(); + break; + case 0x2fda2204: + result = new TL_messageMediaDocument(); + break; + case 0x56e0d474: + result = new TL_messageMediaGeo(); + break; + case 0x3ded6320: + result = new TL_messageMediaEmpty(); + break; + case 0xc6b68300: + result = new TL_messageMediaAudio(); + break; + case 0x7912b71f: + result = new TL_messageMediaVenue(); + break; + case 0x5e7d2f39: + result = new TL_messageMediaContact(); + break; + case 0x9f84f49e: + result = new TL_messageMediaUnsupported(); + break; + case 0xa2d24290: + result = new TL_messageMediaVideo_old(); //custom + break; + case 0xc8c45a2a: + result = new TL_messageMediaPhoto_old(); //custom + break; + case 0x29632a36: + result = new TL_messageMediaUnsupported_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in MessageMedia", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_messageMediaUnsupported_old extends TL_messageMediaUnsupported { + public static int constructor = 0x29632a36; + + + public void readParams(AbsSerializedData stream, boolean exception) { + bytes = stream.readByteArray(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeString(title); - stream.writeString(address); + stream.writeByteArray(bytes); } } + public static class TL_messageMediaPhoto_old extends TL_messageMediaPhoto { + public static int constructor = 0xc8c45a2a; + + + public void readParams(AbsSerializedData stream, boolean exception) { + photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + photo.serializeToStream(stream); + } + } + + public static class TL_messageMediaVideo_old extends TL_messageMediaVideo { + public static int constructor = 0xa2d24290; + + + public void readParams(AbsSerializedData stream, boolean exception) { + video = Video.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + video.serializeToStream(stream); + } + } + //MessageMedia end + + //DecryptedMessage start + public static class DecryptedMessage extends TLObject { + public long random_id; + public DecryptedMessageAction action; + public int ttl; + public String message; + public DecryptedMessageMedia media; + public byte[] random_bytes; //custom + + public static DecryptedMessage TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + DecryptedMessage result = null; + switch(constructor) { + case 0x73164160: + result = new TL_decryptedMessageService(); + break; + case 0x204d3878: + result = new TL_decryptedMessage(); + break; + case 0xaa48327d: + result = new TL_decryptedMessageService_old(); //custom + break; + case 0x1f814f1f: + result = new TL_decryptedMessage_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in DecryptedMessage", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_decryptedMessageService_old extends TL_decryptedMessageService { + public static int constructor = 0xaa48327d; + + + public void readParams(AbsSerializedData stream, boolean exception) { + random_id = stream.readInt64(exception); + random_bytes = stream.readByteArray(exception); + action = DecryptedMessageAction.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(random_id); + stream.writeByteArray(random_bytes); + action.serializeToStream(stream); + } + } + + public static class TL_decryptedMessage_old extends TL_decryptedMessage { + public static int constructor = 0x1f814f1f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + random_id = stream.readInt64(exception); + random_bytes = stream.readByteArray(exception); + message = stream.readString(exception); + media = DecryptedMessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(random_id); + stream.writeByteArray(random_bytes); + stream.writeString(message); + media.serializeToStream(stream); + } + } + //DecryptedMessage end + + //Chat start + public static class TL_chatEmpty extends Chat { + public static int constructor = 0x9ba2d800; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt32(exception); + + title = "DELETED"; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(id); + } + } + //Chat end + + //UserProfilePhoto start + public static class UserProfilePhoto extends TLObject { + public long photo_id; + public FileLocation photo_small; + public FileLocation photo_big; + + public static UserProfilePhoto TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + UserProfilePhoto result = null; + switch(constructor) { + case 0x4f11bae1: + result = new TL_userProfilePhotoEmpty(); + break; + case 0xd559d8c8: + result = new TL_userProfilePhoto(); + break; + case 0x990d1493: + result = new TL_userProfilePhotoOld(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in UserProfilePhoto", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_userProfilePhotoOld extends UserProfilePhoto { + public static int constructor = 0x990d1493; + + + public void readParams(AbsSerializedData stream, boolean exception) { + photo_small = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + photo_big = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + photo_small.serializeToStream(stream); + photo_big.serializeToStream(stream); + } + } + //UserProfilePhoto end + + //DecryptedMessageMedia start + public static class DecryptedMessageMedia extends TLObject { + public long id; + public long access_hash; + public int date; + public String mime_type; + public int size; + public int dc_id; + public ArrayList attributes = new ArrayList<>(); + public int thumb_w; + public int thumb_h; + public String file_name; + public byte[] key; + public byte[] iv; + public double lat; + public double _long; + 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 byte[] thumb; //custom + public PhotoSize thumbImage; //custom + + public static DecryptedMessageMedia TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + DecryptedMessageMedia result = null; + switch(constructor) { + case 0xfa95b0dd: + result = new TL_decryptedMessageMediaExternalDocument(); + break; + case 0xb095434b: + result = new TL_decryptedMessageMediaDocument(); + break; + case 0x35480a59: + result = new TL_decryptedMessageMediaGeoPoint(); + break; + case 0x57e0a9cb: + result = new TL_decryptedMessageMediaAudio(); + break; + case 0x524a415d: + result = new TL_decryptedMessageMediaVideo(); + break; + case 0x588a0a97: + result = new TL_decryptedMessageMediaContact(); + break; + case 0x89f5c4a: + result = new TL_decryptedMessageMediaEmpty(); + break; + case 0x32798a8c: + result = new TL_decryptedMessageMediaPhoto(); + break; + case 0x4cee6ef3: + result = new TL_decryptedMessageMediaVideo_old(); //custom + break; + case 0x6080758f: + result = new TL_decryptedMessageMediaAudio_old(); //custom + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in DecryptedMessageMedia", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_decryptedMessageMediaExternalDocument extends DecryptedMessageMedia { + public static int constructor = 0xfa95b0dd; + + + public void readParams(AbsSerializedData stream, boolean exception) { + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + date = stream.readInt32(exception); + mime_type = stream.readString(exception); + size = stream.readInt32(exception); + thumbImage = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception); + dc_id = stream.readInt32(exception); + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + attributes.add(DocumentAttribute.TLdeserialize(stream, stream.readInt32(exception), exception)); + } + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(id); + stream.writeInt64(access_hash); + stream.writeInt32(date); + stream.writeString(mime_type); + stream.writeInt32(size); + thumbImage.serializeToStream(stream); + stream.writeInt32(dc_id); + stream.writeInt32(0x1cb5c415); + int count = attributes.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + attributes.get(a).serializeToStream(stream); + } + } + } + + public static class TL_decryptedMessageMediaVideo_old extends TL_decryptedMessageMediaVideo { + public static int constructor = 0x4cee6ef3; + + + public void readParams(AbsSerializedData stream, boolean exception) { + thumb = stream.readByteArray(exception); + thumb_w = stream.readInt32(exception); + thumb_h = stream.readInt32(exception); + duration = stream.readInt32(exception); + w = stream.readInt32(exception); + h = stream.readInt32(exception); + size = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeByteArray(thumb); + stream.writeInt32(thumb_w); + stream.writeInt32(thumb_h); + stream.writeInt32(duration); + stream.writeInt32(w); + stream.writeInt32(h); + stream.writeInt32(size); + stream.writeByteArray(key); + stream.writeByteArray(iv); + } + } + + public static class TL_decryptedMessageMediaAudio_old extends TL_decryptedMessageMediaAudio { + public static int constructor = 0x6080758f; + + + public void readParams(AbsSerializedData stream, boolean exception) { + duration = stream.readInt32(exception); + size = stream.readInt32(exception); + key = stream.readByteArray(exception); + iv = stream.readByteArray(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(duration); + stream.writeInt32(size); + stream.writeByteArray(key); + stream.writeByteArray(iv); + } + } + //DecryptedMessageMedia end + + //functions memory optimize + public static class TL_upload_saveFilePart extends TLObject { + public static int constructor = 0xb304a621; + + public long file_id; + public int file_part; + public ByteBufferDesc bytes; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(file_id); + stream.writeInt32(file_part); + stream.writeByteBuffer(bytes); + } + + @Override + public void freeResources() { + if (disableFree) { + return; + } + if (bytes != null) { + BuffersStorage.getInstance().reuseFreeBuffer(bytes); + bytes = null; + } + } + } + + 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 ByteBufferDesc bytes; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(file_id); + stream.writeInt32(file_part); + stream.writeInt32(file_total_parts); + stream.writeByteBuffer(bytes); + } + + @Override + public void freeResources() { + if (disableFree) { + return; + } + if (bytes != null) { + BuffersStorage.getInstance().reuseFreeBuffer(bytes); + bytes = null; + } + } + } + + public static class TL_upload_file extends TLObject { + public static int constructor = 0x96a18d5; + + public storage_FileType type; + public int mtime; + public ByteBufferDesc bytes; + + public static TL_upload_file TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_upload_file.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_upload_file", constructor)); + } else { + return null; + } + } + TL_upload_file result = new TL_upload_file(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + type = storage_FileType.TLdeserialize(stream, stream.readInt32(exception), exception); + mtime = stream.readInt32(exception); + bytes = stream.readByteBuffer(exception); + } + + @Override + public void freeResources() { + if (disableFree) { + return; + } + if (bytes != null) { + BuffersStorage.getInstance().reuseFreeBuffer(bytes); + bytes = null; + } + } + } + + public static class TL_messages_sendEncryptedFile extends TLObject { + public static int constructor = 0x9a901b66; + + public TL_inputEncryptedChat peer; + public long random_id; + public ByteBufferDesc data; + public InputEncryptedFile file; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_SentEncryptedMessage.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt64(random_id); + stream.writeByteBuffer(data); + file.serializeToStream(stream); + } + + @Override + public void freeResources() { + if (disableFree) { + return; + } + if (data != null) { + BuffersStorage.getInstance().reuseFreeBuffer(data); + data = null; + } + } + } + + public static class TL_messages_sendEncrypted extends TLObject { + public static int constructor = 0xa9776773; + + public TL_inputEncryptedChat peer; + public long random_id; + public ByteBufferDesc data; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_SentEncryptedMessage.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt64(random_id); + stream.writeByteBuffer(data); + } + + @Override + public void freeResources() { + if (disableFree) { + return; + } + if (data != null) { + BuffersStorage.getInstance().reuseFreeBuffer(data); + data = null; + } + } + } + + public static class TL_messages_sendEncryptedService extends TLObject { + public static int constructor = 0x32d439a4; + + public TL_inputEncryptedChat peer; + public long random_id; + public ByteBufferDesc data; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return messages_SentEncryptedMessage.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt64(random_id); + stream.writeByteBuffer(data); + } + + @Override + public void freeResources() { + if (disableFree) { + return; + } + if (data != null) { + BuffersStorage.getInstance().reuseFreeBuffer(data); + data = null; + } + } + } + + public static class TL_set_client_DH_params extends TLObject { + public static int constructor = 0xf5045f1f; + + public byte[] nonce; + public byte[] server_nonce; + public ByteBufferDesc encrypted_data; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return Set_client_DH_params_answer.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeRaw(nonce); + stream.writeRaw(server_nonce); + stream.writeByteBuffer(encrypted_data); + } + + @Override + public void freeResources() { + if (disableFree) { + return; + } + if (encrypted_data != null) { + BuffersStorage.getInstance().reuseFreeBuffer(encrypted_data); + encrypted_data = null; + } + } + } + + //functions public static class invokeWithLayer extends TLObject { public static int constructor = 0xda9b0d0d; @@ -11265,194 +14728,231 @@ public class TLRPC { } } - public static class TL_encryptedChat_old extends TL_encryptedChat { - public static int constructor = 0x6601d14f; + public static class TL_destroy_sessions extends TLObject { + public static int constructor = 0xa13dc52f; + public ArrayList session_ids = new ArrayList<>(); - public void readParams(AbsSerializedData 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 TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_destroy_sessions_res.TLdeserialize(stream, constructor, exception); + } + + public int layer() { + return 0; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + session_ids.add(stream.readInt64(exception)); + } } public void serializeToStream(AbsSerializedData 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); + stream.writeInt32(constructor); + int count = session_ids.size(); + stream.writeInt32(count); + for (Long session_id : session_ids) { + stream.writeInt64(session_id); + } } } - public static class TL_encryptedChatRequested_old extends EncryptedChat { - public static int constructor = 0xfda9a7b7; + public static class TL_ping extends TLObject { + public static int constructor = 0x7abe77ec; + public long ping_id; - public void readParams(AbsSerializedData 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 TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_pong.TLdeserialize(stream, constructor, exception); + } + + public int layer() { + return 0; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + ping_id = stream.readInt64(exception); } public void serializeToStream(AbsSerializedData 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); + stream.writeInt32(constructor); + stream.writeInt64(ping_id); } } - public static class TL_decryptedMessageActionDeleteMessages extends DecryptedMessageAction { - public static int constructor = 0x65614304; + public static class TL_ping_delay_disconnect extends TLObject { + public static int constructor = 0xf3427b8c; + public long ping_id; + public int disconnect_delay; - public void readParams(AbsSerializedData stream) { - boolean[] error = new boolean[1]; - stream.readInt32(error); - if (error[0]) { - return; - } - int count = stream.readInt32(error); - if (error[0]) { - return; - } - for (long a = 0; a < count; a++) { - random_ids.add(stream.readInt64(error)); - if (error[0]) { - return; + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_pong.TLdeserialize(stream, constructor, exception); + } + + public int layer() { + return 0; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + ping_id = stream.readInt64(exception); + disconnect_delay = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(ping_id); + stream.writeInt32(disconnect_delay); + } + } + + public static class TL_destroy_session extends TLObject { + public static int constructor = 0xe7512126; + + public long session_id; + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return DestroySessionRes.TLdeserialize(stream, constructor, exception); + } + + public int layer() { + return 0; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + session_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(session_id); + } + } + + public static class TL_invokeAfterMsg extends TLObject { + public static int constructor = 0xcb9f372d; + + public long msg_id; + public TLObject query; + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(msg_id); + query.serializeToStream(stream); + } + } + + public static class TL_get_future_salts extends TLObject { + public static int constructor = 0xb921bd04; + + public int num; + + public int layer() { + return 0; + } + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return TL_futuresalts.TLdeserialize(stream, constructor, exception); + } + + public void readParams(AbsSerializedData stream, boolean exception) { + num = stream.readInt32(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(num); + } + } + + public static class TL_rpc_drop_answer extends TLObject { + public static int constructor = 0x58e4a740; + + public long req_msg_id; + + public int layer() { + return 0; + } + + public TLObject deserializeResponse(AbsSerializedData stream, int constructor, boolean exception) { + return RpcDropAnswer.TLdeserialize(stream, constructor, exception); + } + + public void readParams(AbsSerializedData stream, boolean exception) { + req_msg_id = stream.readInt64(exception); + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(req_msg_id); + } + } + + public static class TL_msg_container extends TLObject { + public ArrayList messages; + + public static int constructor = 0x73f1f8dc; + + public void readParams(AbsSerializedData stream, boolean exception) { + messages = new ArrayList<>(); + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + TL_protoMessage message = new TL_protoMessage(); + message.msg_id = stream.readInt64(exception); + message.seqno = stream.readInt32(exception); + message.bytes = stream.readInt32(exception); + int position = stream.getPosition(); + message.body = ConnectionsManager.getInstance().deserialize(ConnectionsManager.getInstance().getRequestWithMessageId(message.msg_id), stream, exception); + if (message.body == null) { + stream.skip(message.bytes - (stream.getPosition() - position)); + } else { + messages.add(message); } } } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = random_ids.size(); - stream.writeInt32(count); - for (Long value : random_ids) { - stream.writeInt64(value); + stream.writeInt32(messages.size()); + for (TLObject obj : messages) { + TL_protoMessage proto = (TL_protoMessage) obj; + stream.writeInt64(proto.msg_id); + stream.writeInt32(proto.seqno); + stream.writeInt32(proto.bytes); + proto.body.serializeToStream(stream); } } } - public static class TL_decryptedMessageActionCommitKey extends DecryptedMessageAction { - public static int constructor = 0xec2e0b9b; + public static class TL_rpc_result extends TLObject { + public static int constructor = 0xf35c6d01; + public long req_msg_id; + public TLObject result; - public void readParams(AbsSerializedData stream) { - exchange_id = stream.readInt64(); - key_fingerprint = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(exchange_id); - stream.writeInt64(key_fingerprint); - } - } - - public static class TL_decryptedMessageActionAbortKey extends DecryptedMessageAction { - public static int constructor = 0xdd05ec6b; - - - public void readParams(AbsSerializedData stream) { - exchange_id = stream.readInt64(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(exchange_id); - } - } - - public static class TL_decryptedMessageActionNoop extends DecryptedMessageAction { - public static int constructor = 0xa82fdd63; - - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - } - } - - public static class TL_decryptedMessageActionScreenshotMessages extends DecryptedMessageAction { - public static int constructor = 0x8ac1f475; - - - public void readParams(AbsSerializedData stream) { - boolean[] error = new boolean[1]; - stream.readInt32(error); - if (error[0]) { - return; - } - int count = stream.readInt32(error); - if (error[0]) { - return; - } - for (long a = 0; a < count; a++) { - random_ids.add(stream.readInt64(error)); - if (error[0]) { - return; + public static TL_rpc_result TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_rpc_result.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_rpc_result", constructor)); + } else { + return null; } } + TL_rpc_result result = new TL_rpc_result(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbsSerializedData stream, boolean exception) { + req_msg_id = stream.readInt64(exception); + result = ConnectionsManager.getInstance().deserialize(ConnectionsManager.getInstance().getRequestWithMessageId(req_msg_id), stream, exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(0x1cb5c415); - int count = random_ids.size(); - stream.writeInt32(count); - for (Long value : random_ids) { - stream.writeInt64(value); - } - } - } - - public static class TL_messageEncryptedAction extends MessageAction { - public static int constructor = 0x555555F7; - - public void readParams(AbsSerializedData stream) { - encryptedAction = (DecryptedMessageAction)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - encryptedAction.serializeToStream(stream); - } - } - - 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 ByteBufferDesc bytes; - - public Class responseClass () { - return Bool.class; - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(file_id); - stream.writeInt32(file_part); - stream.writeInt32(file_total_parts); - stream.writeByteBuffer(bytes); + stream.writeInt64(req_msg_id); + result.serializeToStream(stream); } @Override @@ -11460,160 +14960,125 @@ public class TLRPC { if (disableFree) { return; } - if (bytes != null) { - BuffersStorage.getInstance().reuseFreeBuffer(bytes); - bytes = null; + if (result != null) { + result.freeResources(); } } } - public static class TL_upload_saveFilePart extends TLObject { - public static int constructor = 0xb304a621; + public static class TL_futureSalt extends TLObject { + public static int constructor = 0x0949d9dc; - public long file_id; - public int file_part; - public ByteBufferDesc bytes; + public int valid_since; + public int valid_until; + public long salt; - public Class responseClass () { - return Bool.class; + public void readParams(AbsSerializedData stream, boolean exception) { + valid_since = stream.readInt32(exception); + valid_until = stream.readInt32(exception); + salt = stream.readInt64(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt64(file_id); - stream.writeInt32(file_part); - stream.writeByteBuffer(bytes); + stream.writeInt32(valid_since); + stream.writeInt32(valid_until); + stream.writeInt64(salt); + } + } + + public static class TL_futuresalts extends TLObject { + public static int constructor = 0xae500895; + + public long req_msg_id; + public int now; + public ArrayList salts = new ArrayList<>(); + + public static TL_futuresalts TLdeserialize(AbsSerializedData stream, int constructor, boolean exception) { + if (TL_futuresalts.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_futuresalts", constructor)); + } else { + return null; + } + } + TL_futuresalts result = new TL_futuresalts(); + result.readParams(stream, exception); + return result; } - @Override - public void freeResources() { - if (disableFree) { - return; + public void readParams(AbsSerializedData stream, boolean exception) { + req_msg_id = stream.readInt64(exception); + now = stream.readInt32(exception); + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + TL_futureSalt salt = new TL_futureSalt(); + salt.readParams(stream, exception); + salts.add(salt); } - if (bytes != null) { - BuffersStorage.getInstance().reuseFreeBuffer(bytes); - bytes = null; + } + + public void serializeToStream(AbsSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(req_msg_id); + stream.writeInt32(now); + int count = salts.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + salts.get(a).serializeToStream(stream); } } } - public static class InputEncryptedFile extends TLObject { - public long id; - public long access_hash; - public int parts; - public int key_fingerprint; - public String md5_checksum; - public byte[] key; - public byte[] iv; - } + public static class TL_gzip_packed extends TLObject { + public static int constructor = 0x3072cfa1; - public static class TL_decryptedMessageMediaVideo_old extends TL_decryptedMessageMediaVideo { - public static int constructor = 0x4cee6ef3; + public byte[] packed_data; - - public void readParams(AbsSerializedData stream) { - thumb = stream.readByteArray(); - thumb_w = stream.readInt32(); - thumb_h = stream.readInt32(); - duration = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - size = stream.readInt32(); - key = stream.readByteArray(); - iv = stream.readByteArray(); + public void readParams(AbsSerializedData stream, boolean exception) { + packed_data = stream.readByteArray(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeByteArray(thumb); - stream.writeInt32(thumb_w); - stream.writeInt32(thumb_h); - stream.writeInt32(duration); - stream.writeInt32(w); - stream.writeInt32(h); - stream.writeInt32(size); - stream.writeByteArray(key); - stream.writeByteArray(iv); + stream.writeByteArray(packed_data); } } - public static class TL_decryptedMessageMediaAudio_old extends TL_decryptedMessageMediaAudio { - public static int constructor = 0x6080758f; + public static class Vector extends TLObject { + public static int constructor = 0x1cb5c415; + public ArrayList objects = new ArrayList<>(); + } + public static class TL_decryptedMessageHolder extends TLObject { + public static int constructor = 0x555555F9; - public void readParams(AbsSerializedData stream) { - duration = stream.readInt32(); - size = stream.readInt32(); - key = stream.readByteArray(); - iv = stream.readByteArray(); + public long random_id; + public int date; + public TL_decryptedMessageLayer layer; + public EncryptedFile file; + public boolean new_key_used; + + public void readParams(AbsSerializedData stream, boolean exception) { + random_id = stream.readInt64(exception); + date = stream.readInt32(exception); + layer = TL_decryptedMessageLayer.TLdeserialize(stream, stream.readInt32(exception), exception); + if (stream.readBool(exception)) { + file = EncryptedFile.TLdeserialize(stream, stream.readInt32(exception), exception); + } + new_key_used = stream.readBool(exception); } public void serializeToStream(AbsSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(duration); - stream.writeInt32(size); - stream.writeByteArray(key); - stream.writeByteArray(iv); - } - } - - public static class TL_audio_old extends TL_audio { - public static int constructor = 0x427425e7; - - - public void readParams(AbsSerializedData 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(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(user_id); + stream.writeInt64(random_id); stream.writeInt32(date); - stream.writeInt32(duration); - stream.writeInt32(size); - stream.writeInt32(dc_id); - } - } - - public static class TL_video_old extends TL_video { - public static int constructor = 0x5a04a49f; - - - public void readParams(AbsSerializedData stream) { - id = stream.readInt64(); - access_hash = stream.readInt64(); - user_id = stream.readInt32(); - date = stream.readInt32(); - caption = stream.readString(); - duration = stream.readInt32(); - size = stream.readInt32(); - thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); - dc_id = stream.readInt32(); - w = stream.readInt32(); - h = stream.readInt32(); - } - - public void serializeToStream(AbsSerializedData stream) { - stream.writeInt32(constructor); - stream.writeInt64(id); - stream.writeInt64(access_hash); - stream.writeInt32(user_id); - stream.writeInt32(date); - stream.writeString(caption); - stream.writeInt32(duration); - stream.writeInt32(size); - thumb.serializeToStream(stream); - stream.writeInt32(dc_id); - stream.writeInt32(w); - stream.writeInt32(h); + layer.serializeToStream(stream); + stream.writeBool(file != null); + if (file != null) { + file.serializeToStream(stream); + } + stream.writeBool(new_key_used); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java index 42e44a7c..2ae522fb 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java @@ -36,6 +36,7 @@ public class UserConfig { public static int autoLockIn = 60 * 60; public static int lastPauseTime = 0; public static boolean isWaitingForPasscodeEnter = false; + public static int lastUpdateVersion; public static int getNewMessageId() { int id; @@ -71,6 +72,7 @@ public class UserConfig { editor.putInt("passcodeType", passcodeType); editor.putInt("autoLockIn", autoLockIn); editor.putInt("lastPauseTime", lastPauseTime); + editor.putInt("lastUpdateVersion", lastUpdateVersion); if (currentUser != null) { if (withFile) { @@ -123,28 +125,28 @@ public class UserConfig { if (configFile.exists()) { try { SerializedData data = new SerializedData(configFile); - int ver = data.readInt32(); + int ver = data.readInt32(false); if (ver == 1) { - int constructor = data.readInt32(); - currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, constructor); - MessagesStorage.lastDateValue = data.readInt32(); - MessagesStorage.lastPtsValue = data.readInt32(); - MessagesStorage.lastSeqValue = data.readInt32(); - registeredForPush = data.readBool(); - pushString = data.readString(); - lastSendMessageId = data.readInt32(); - lastLocalId = data.readInt32(); - contactsHash = data.readString(); - importHash = data.readString(); - saveIncomingPhotos = data.readBool(); + int constructor = data.readInt32(false); + currentUser = TLRPC.TL_userSelf.TLdeserialize(data, constructor, false); + MessagesStorage.lastDateValue = data.readInt32(false); + MessagesStorage.lastPtsValue = data.readInt32(false); + MessagesStorage.lastSeqValue = data.readInt32(false); + registeredForPush = data.readBool(false); + pushString = data.readString(false); + lastSendMessageId = data.readInt32(false); + lastLocalId = data.readInt32(false); + contactsHash = data.readString(false); + importHash = data.readString(false); + saveIncomingPhotos = data.readBool(false); contactsVersion = 0; - MessagesStorage.lastQtsValue = data.readInt32(); - MessagesStorage.lastSecretVersion = data.readInt32(); - int val = data.readInt32(); + MessagesStorage.lastQtsValue = data.readInt32(false); + MessagesStorage.lastSecretVersion = data.readInt32(false); + int val = data.readInt32(false); if (val == 1) { - MessagesStorage.secretPBytes = data.readByteArray(); + MessagesStorage.secretPBytes = data.readByteArray(false); } - MessagesStorage.secretG = data.readInt32(); + MessagesStorage.secretG = data.readInt32(false); Utilities.stageQueue.postRunnable(new Runnable() { @Override public void run() { @@ -152,8 +154,8 @@ public class UserConfig { } }); } else if (ver == 2) { - int constructor = data.readInt32(); - currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, constructor); + int constructor = data.readInt32(false); + currentUser = TLRPC.TL_userSelf.TLdeserialize(data, constructor, false); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE); registeredForPush = preferences.getBoolean("registeredForPush", false); @@ -199,12 +201,13 @@ public class UserConfig { passcodeType = preferences.getInt("passcodeType", 0); autoLockIn = preferences.getInt("autoLockIn", 60 * 60); lastPauseTime = preferences.getInt("lastPauseTime", 0); + lastUpdateVersion = preferences.getInt("lastUpdateVersion", 511); String user = preferences.getString("user", null); if (user != null) { byte[] userBytes = Base64.decode(user, Base64.DEFAULT); if (userBytes != null) { SerializedData data = new SerializedData(userBytes); - currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + currentUser = TLRPC.TL_userSelf.TLdeserialize(data, data.readInt32(false), false); data.cleanup(); } } @@ -229,6 +232,7 @@ public class UserConfig { autoLockIn = 60 * 60; lastPauseTime = 0; isWaitingForPasscodeEnter = false; + lastUpdateVersion = BuildVars.BUILD_VERSION; saveConfig(true); } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java index 0177cbc8..33b0d60b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java @@ -23,7 +23,6 @@ import android.os.Build; import android.os.Environment; import android.provider.DocumentsContract; import android.provider.MediaStore; -import android.text.Html; import android.text.SpannableStringBuilder; import android.util.Base64; import android.util.Log; @@ -69,6 +68,9 @@ public class Utilities { public static Pattern pattern = Pattern.compile("[0-9]+"); public static SecureRandom random = new SecureRandom(); + private static byte[] decompressBuffer; + private static ByteArrayOutputStreamExpand decompressStream; + public static ArrayList goodPrimes = new ArrayList<>(); public static class TPFactorizedValue { @@ -78,7 +80,7 @@ public class Utilities { public static volatile DispatchQueue stageQueue = new DispatchQueue("stageQueue"); public static volatile DispatchQueue globalQueue = new DispatchQueue("globalQueue"); public static volatile DispatchQueue searchQueue = new DispatchQueue("searchQueue"); - public static volatile DispatchQueue photoBookQueue = new DispatchQueue("photoBookQueue"); + public static volatile DispatchQueue phoneBookQueue = new DispatchQueue("photoBookQueue"); final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); @@ -103,9 +105,9 @@ public class Utilities { byte[] bytes = Base64.decode(primes, Base64.DEFAULT); if (bytes != null) { SerializedData data = new SerializedData(bytes); - int count = data.readInt32(); + int count = data.readInt32(false); for (int a = 0; a < count; a++) { - goodPrimes.add(data.readString()); + goodPrimes.add(data.readString(false)); } data.cleanup(); } @@ -120,7 +122,7 @@ public class Utilities { public native static long doPQNative(long _what); public native static void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride); public native static int pinBitmap(Bitmap bitmap); - public native static void blurBitmap(Object bitmap, int radius); + public native static void blurBitmap(Object bitmap, int radius, int unpin); public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer); public native static Bitmap loadWebpImage(ByteBuffer buffer, int len, BitmapFactory.Options options); public native static Bitmap loadBpgImage(ByteBuffer buffer, int len, BitmapFactory.Options options); @@ -422,17 +424,21 @@ public class Utilities { return keyData; } - public static TLObject decompress(byte[] data, TLObject parentObject) { - final int BUFFER_SIZE = 512; + public static TLObject decompress(byte[] data, TLObject parentObject, boolean exception) { + final int BUFFER_SIZE = 16384; ByteArrayInputStream is = new ByteArrayInputStream(data); GZIPInputStream gis; + SerializedData stream = null; try { + if (decompressBuffer == null) { + decompressBuffer = new byte[BUFFER_SIZE]; + decompressStream = new ByteArrayOutputStreamExpand(BUFFER_SIZE); + } + decompressStream.reset(); gis = new GZIPInputStream(is, BUFFER_SIZE); - ByteArrayOutputStream bytesOutput = new ByteArrayOutputStream(); - data = new byte[BUFFER_SIZE]; int bytesRead; - while ((bytesRead = gis.read(data)) != -1) { - bytesOutput.write(data, 0, bytesRead); + while ((bytesRead = gis.read(decompressBuffer)) != -1) { + decompressStream.write(decompressBuffer, 0, bytesRead); } try { gis.close(); @@ -444,18 +450,15 @@ public class Utilities { } catch (Exception e) { FileLog.e("tmessages", e); } - SerializedData stream = new SerializedData(bytesOutput.toByteArray()); - try { - bytesOutput.close(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - TLObject object = TLClassStore.Instance().TLdeserialize(stream, stream.readInt32(), parentObject); - stream.cleanup(); - return object; + stream = new SerializedData(decompressStream.toByteArray()); } catch (IOException e) { FileLog.e("tmessages", e); } + if (stream != null) { + TLObject object = ConnectionsManager.getInstance().deserialize(parentObject, stream, exception); + stream.cleanup(); + return object; + } return null; } @@ -685,7 +688,7 @@ public class Utilities { } wholeString = wholeString.trim(); String lower = " " + wholeString.toLowerCase(); - String hexDarkColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));/*Search Name*/ + String hexDarkColor = String.format("#%08X", (0xFFFFFFFF & AndroidUtilities.getIntDarkerColor("chatsNameColor", -0x40)));/*Search Name*/ int index = -1; int lastIndex = 0; while ((index = lower.indexOf(" " + q, lastIndex)) != -1) { @@ -702,9 +705,9 @@ public class Utilities { if (query.startsWith(" ")) { builder.append(" "); } - query.trim(); - builder.append(Html.fromHtml("" + query + "")); - //builder.append(Html.fromHtml("" + query + "")); + query = query.trim(); + builder.append(AndroidUtilities.replaceTags("" + query + "")); + //builder.append(AndroidUtilities.replaceTags("" + query + "")); lastIndex = end; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index 0fec97e2..7bebbb51 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -24,6 +24,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.messenger.R; +import org.telegram.ui.Components.LayoutHelper; public class ActionBar extends FrameLayout { @@ -62,8 +63,8 @@ public class ActionBar extends FrameLayout { titleFrameLayout = new FrameLayout(context); addView(titleFrameLayout); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)titleFrameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.FILL_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; titleFrameLayout.setLayoutParams(layoutParams); titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0); @@ -97,8 +98,8 @@ public class ActionBar extends FrameLayout { } layoutParams = (LayoutParams) titleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; titleTextView.setLayoutParams(layoutParams); titleTextView.measure(width, height); @@ -112,8 +113,8 @@ public class ActionBar extends FrameLayout { } layoutParams = (LayoutParams) subTitleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; subTitleTextView.setLayoutParams(layoutParams); subTitleTextView.measure(width, height); @@ -133,7 +134,7 @@ public class ActionBar extends FrameLayout { if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) { layoutParams = (LayoutParams) titleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = titleTextView.getMeasuredHeight(); int y; if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { @@ -146,7 +147,7 @@ public class ActionBar extends FrameLayout { } if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { layoutParams = (LayoutParams) subTitleTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = subTitleTextView.getMeasuredHeight(); layoutParams.setMargins(x, height / 2 + (height / 2 - subTitleTextView.getMeasuredHeight()) / 2 - offset, 0, 0); subTitleTextView.setLayoutParams(layoutParams); @@ -163,7 +164,7 @@ public class ActionBar extends FrameLayout { return; } FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams(); - layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT; + layoutParams.width = isSearchFieldVisible ? LayoutHelper.MATCH_PARENT : LayoutHelper.WRAP_CONTENT; layoutParams.height = height; layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(AndroidUtilities.isTablet() ? 74 : 66) : 0; layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0; @@ -277,14 +278,19 @@ public class ActionBar extends FrameLayout { } public void setTitle(CharSequence value) { + boolean created = false; if (value != null && titleTextView == null) { createTitleTextView(); + created = true; } if (titleTextView != null) { lastTitle = value; titleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE); titleTextView.setText(value); positionTitle(getMeasuredWidth(), getMeasuredHeight()); + if (!created) { + titleTextView.setText(value); + } } } @@ -301,13 +307,13 @@ public class ActionBar extends FrameLayout { return subTitleTextView.getCompoundDrawables()[0]; } - public CharSequence getTitle() { + public String getTitle() { if (titleTextView == null) { return null; } - return titleTextView.getText(); + return titleTextView.getText().toString(); } - + //Plus public void setTitleColor(int color) { if (titleTextView == null) { createTitleTextView(); @@ -316,7 +322,6 @@ public class ActionBar extends FrameLayout { titleTextView.setTextColor(color); } } - public ActionBarMenu createMenu() { if (menu != null) { return menu; @@ -324,8 +329,8 @@ public class ActionBar extends FrameLayout { menu = new ActionBarMenu(getContext(), this); addView(menu); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams(); - layoutParams.height = LayoutParams.FILL_PARENT; - layoutParams.width = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.RIGHT; menu.setLayoutParams(layoutParams); return menu; @@ -340,8 +345,8 @@ public class ActionBar extends FrameLayout { View view = li.inflate(resourceId, null); addView(view); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)view.getLayoutParams(); - layoutParams.width = LayoutParams.FILL_PARENT; - layoutParams.height = LayoutParams.FILL_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.topMargin = occupyStatusBar ? AndroidUtilities.statusBarHeight : 0; view.setLayoutParams(layoutParams); } @@ -355,8 +360,8 @@ public class ActionBar extends FrameLayout { addView(actionMode); actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams(); - layoutParams.height = LayoutParams.FILL_PARENT; - layoutParams.width = LayoutParams.FILL_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.RIGHT; actionMode.setLayoutParams(layoutParams); actionMode.setVisibility(INVISIBLE); @@ -367,7 +372,7 @@ public class ActionBar extends FrameLayout { addView(actionModeTop); layoutParams = (FrameLayout.LayoutParams)actionModeTop.getLayoutParams(); layoutParams.height = AndroidUtilities.statusBarHeight; - layoutParams.width = LayoutParams.FILL_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; actionModeTop.setLayoutParams(layoutParams); actionModeTop.setVisibility(INVISIBLE); @@ -508,9 +513,7 @@ public class ActionBar extends FrameLayout { if (backButtonImageView != null) { backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); } - // - setBackgroundColor(AndroidUtilities.getIntColor("themeColor")); - // + setBackgroundColor(AndroidUtilities.getIntColor("themeColor")); //Plus } public void setCastShadows(boolean value) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java index 69e67cf9..0e5166a5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -28,12 +28,13 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; @@ -108,6 +109,8 @@ public class ActionBarLayout extends FrameLayout { private ActionBar currentActionBar; private AnimatorSetProxy currentAnimation; + private DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f); + private AccelerateDecelerateInterpolator accelerateDecelerateInterpolator = new AccelerateDecelerateInterpolator(); public float innerTranslationX; @@ -128,6 +131,9 @@ public class ActionBarLayout extends FrameLayout { private View backgroundView; private boolean removeActionBarExtraHeight; + private float animationProgress = 0.0f; + private long lastFrameTime; + private String titleOverlayText; private ActionBarLayoutDelegate delegate = null; @@ -151,16 +157,16 @@ public class ActionBarLayout extends FrameLayout { containerViewBack = new LinearLayoutContainer(parentActivity); addView(containerViewBack); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; containerViewBack.setLayoutParams(layoutParams); containerView = new LinearLayoutContainer(parentActivity); addView(containerView); layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; containerView.setLayoutParams(layoutParams); @@ -325,10 +331,10 @@ public class ActionBarLayout extends FrameLayout { if (fragmentView == null) { fragmentView = lastFragment.createView(parentActivity, parentActivity.getLayoutInflater()); } else { - ViewGroup parent = (ViewGroup) fragmentView.getParent(); - if (parent != null) { - parent.removeView(fragmentView); - } + ViewGroup parent = (ViewGroup) fragmentView.getParent(); + if (parent != null) { + parent.removeView(fragmentView); + } } ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { @@ -347,8 +353,8 @@ public class ActionBarLayout extends FrameLayout { } containerViewBack.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); if (!lastFragment.hasOwnBackground && fragmentView.getBackground() == null) { fragmentView.setBackgroundColor(0xffffffff); @@ -380,7 +386,7 @@ public class ActionBarLayout extends FrameLayout { int dx = Math.max(0, (int) (ev.getX() - startedTrackingX)); int dy = Math.abs((int) ev.getY() - startedTrackingY); velocityTracker.addMovement(ev); - if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.getPixelsInCM(0.3f, true) && Math.abs(dx) / 3 > dy) { + if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.getPixelsInCM(0.4f, true) && Math.abs(dx) / 3 > dy) { prepareForMoving(ev); } else if (startedTracking) { if (!beginTrackingSent) { @@ -399,10 +405,10 @@ public class ActionBarLayout extends FrameLayout { velocityTracker = VelocityTracker.obtain(); } velocityTracker.computeCurrentVelocity(1000); - if (!startedTracking) { + if (!startedTracking && fragmentsStack.get(fragmentsStack.size() - 1).swipeBackEnabled) { float velX = velocityTracker.getXVelocity(); float velY = velocityTracker.getYVelocity(); - if (velX >= 3500 && velX > velY) { + if (velX >= 3500 && velX > Math.abs(velY)) { prepareForMoving(ev); if (!beginTrackingSent) { if (((Activity) getContext()).getCurrentFocus() != null) { @@ -550,6 +556,44 @@ public class ActionBarLayout extends FrameLayout { return presentFragment(fragment, removeLast, false, true); } + private void startLayoutAnimation(final boolean open, final boolean first) { + if (first) { + animationProgress = 0.0f; + lastFrameTime = System.nanoTime() / 1000000; + } + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (first) { + transitionAnimationStartTime = System.currentTimeMillis(); + } + long newTime = System.nanoTime() / 1000000; + long dt = newTime - lastFrameTime; + if (dt > 18) { + dt = 18; + } + lastFrameTime = newTime; + animationProgress += dt / 150.0f; + if (animationProgress > 1.0f) { + animationProgress = 1.0f; + } + float interpolated = decelerateInterpolator.getInterpolation(animationProgress); + if (open) { + ViewProxy.setAlpha(containerView, interpolated); + ViewProxy.setTranslationX(containerView, AndroidUtilities.dp(48) * (1.0f - interpolated)); + } else { + ViewProxy.setAlpha(containerViewBack, 1.0f - interpolated); + ViewProxy.setTranslationX(containerViewBack, AndroidUtilities.dp(48) * interpolated); + } + if (animationProgress < 1) { + startLayoutAnimation(open, false); + } else { + onAnimationEndCheck(false); + } + } + }); + } + public boolean presentFragment(final BaseFragment fragment, final boolean removeLast, boolean forceWithoutAnimation, boolean check) { if (checkTransitionAnimation() || delegate != null && check && !delegate.needPresentFragment(fragment, removeLast, forceWithoutAnimation, this) || !fragment.onFragmentCreate()) { return false; @@ -586,8 +630,8 @@ public class ActionBarLayout extends FrameLayout { containerViewBack.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); fragmentsStack.add(fragment); fragment.onResume(); @@ -615,6 +659,14 @@ public class ActionBarLayout extends FrameLayout { if (useAlphaAnimations && fragmentsStack.size() == 1) { presentFragmentInternalRemoveOld(removeLast, currentFragment); + transitionAnimationStartTime = System.currentTimeMillis(); + transitionAnimationInProgress = true; + onOpenAnimationEndRunnable = new Runnable() { + @Override + public void run() { + fragment.onOpenAnimationEnd(); + } + }; ArrayList animators = new ArrayList<>(); animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 0.0f, 1.0f)); if (backgroundView != null) { @@ -624,7 +676,7 @@ public class ActionBarLayout extends FrameLayout { currentAnimation = new AnimatorSetProxy(); currentAnimation.playTogether(animators); - currentAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); + currentAnimation.setInterpolator(accelerateDecelerateInterpolator); currentAnimation.setDuration(200); currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override @@ -651,11 +703,12 @@ public class ActionBarLayout extends FrameLayout { }; ViewProxy.setAlpha(containerView, 0.0f); ViewProxy.setTranslationX(containerView, 48.0f); - currentAnimation = new AnimatorSetProxy(); + startLayoutAnimation(true, true); + /*currentAnimation = new AnimatorSetProxy(); currentAnimation.playTogether( ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f), ObjectAnimatorProxy.ofFloat(containerView, "translationX", AndroidUtilities.dp(48), 0)); - currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + currentAnimation.setInterpolator(decelerateInterpolator); currentAnimation.setDuration(200); currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override @@ -673,7 +726,7 @@ public class ActionBarLayout extends FrameLayout { onAnimationEndCheck(false); } }); - currentAnimation.start(); + currentAnimation.start();*/ } } else { if (backgroundView != null) { @@ -771,8 +824,8 @@ public class ActionBarLayout extends FrameLayout { } containerView.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); previousFragment.onResume(); currentActionBar = previousFragment.actionBar; @@ -794,12 +847,13 @@ public class ActionBarLayout extends FrameLayout { ViewProxy.setTranslationX(containerViewBack, 0); } }; + startLayoutAnimation(false, true); - currentAnimation = new AnimatorSetProxy(); + /*currentAnimation = new AnimatorSetProxy(); currentAnimation.playTogether( ObjectAnimatorProxy.ofFloat(containerViewBack, "alpha", 1.0f, 0.0f), ObjectAnimatorProxy.ofFloat(containerViewBack, "translationX", 0, AndroidUtilities.dp(48))); - currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); + currentAnimation.setInterpolator(decelerateInterpolator); currentAnimation.setDuration(200); currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override @@ -817,7 +871,7 @@ public class ActionBarLayout extends FrameLayout { onAnimationEndCheck(false); } }); - currentAnimation.start(); + currentAnimation.start();*/ } } else { if (useAlphaAnimations) { @@ -846,7 +900,7 @@ public class ActionBarLayout extends FrameLayout { currentAnimation = new AnimatorSetProxy(); currentAnimation.playTogether(animators); - currentAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); + currentAnimation.setInterpolator(accelerateDecelerateInterpolator); currentAnimation.setDuration(200); currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override @@ -903,8 +957,8 @@ public class ActionBarLayout extends FrameLayout { } containerView.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); previousFragment.onResume(); currentActionBar = previousFragment.actionBar; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java index 3a63dd18..ef85bd22 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java @@ -13,10 +13,10 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; -import android.widget.FrameLayout; import android.widget.LinearLayout; import org.telegram.android.AndroidUtilities; +import org.telegram.ui.Components.LayoutHelper; public class ActionBarMenu extends LinearLayout { @@ -46,7 +46,7 @@ public class ActionBarMenu extends LinearLayout { view.setTag(id); addView(view); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)view.getLayoutParams(); - layoutParams.height = FrameLayout.LayoutParams.FILL_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; view.setBackgroundResource(parentActionBar.itemsBackgroundResourceId); view.setLayoutParams(layoutParams); view.setOnClickListener(new OnClickListener() { @@ -84,7 +84,7 @@ public class ActionBarMenu extends LinearLayout { } addView(menuItem); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams(); - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = width; menuItem.setLayoutParams(layoutParams); menuItem.setOnClickListener(new OnClickListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java index 25d1b713..2bb7c44d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java @@ -9,7 +9,6 @@ package org.telegram.ui.ActionBar; import android.content.Context; -import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; @@ -33,10 +32,11 @@ import android.widget.LinearLayout; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.LocaleController; import org.telegram.messenger.R; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; import java.lang.reflect.Field; @@ -76,8 +76,8 @@ public class ActionBarMenuItem extends FrameLayoutFixed { iconView.setScaleType(ImageView.ScaleType.CENTER); addView(iconView); LayoutParams layoutParams = (LayoutParams) iconView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; iconView.setLayoutParams(layoutParams); } @@ -218,7 +218,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed { if (LocaleController.isRTL) { layoutParams.gravity = Gravity.RIGHT; } - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(48); textView.setLayoutParams(layoutParams); textView.setOnClickListener(new OnClickListener() { @@ -251,7 +251,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed { return; } if (popupWindow == null) { - popupWindow = new ActionBarPopupWindow(popupLayout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); + popupWindow = new ActionBarPopupWindow(popupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); //popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.setAnimationStyle(R.style.PopupAnimation); popupWindow.setOutsideTouchable(true); @@ -352,7 +352,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed { public void setIcon(int resId) { iconView.setImageResource(resId); } - + //Plus public void setIcon(Drawable drawable) { iconView.setImageDrawable(drawable); } @@ -368,7 +368,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed { LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)searchContainer.getLayoutParams(); layoutParams.weight = 1; layoutParams.width = 0; - layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(6); searchContainer.setLayoutParams(layoutParams); searchContainer.setVisibility(GONE); @@ -452,7 +452,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed { } searchContainer.addView(searchField); FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) searchField.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams2.width = LayoutHelper.MATCH_PARENT; layoutParams2.gravity = Gravity.CENTER_VERTICAL; layoutParams2.height = AndroidUtilities.dp(36); layoutParams2.rightMargin = AndroidUtilities.dp(48); @@ -472,7 +472,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed { layoutParams2 = (FrameLayout.LayoutParams) clearButton.getLayoutParams(); layoutParams2.width = AndroidUtilities.dp(48); layoutParams2.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT; - layoutParams2.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams2.height = LayoutHelper.MATCH_PARENT; clearButton.setLayoutParams(layoutParams2); } isSearchField = value; @@ -502,11 +502,15 @@ public class ActionBarMenuItem extends FrameLayoutFixed { popupWindow.update(this, -AndroidUtilities.dp(8), getOffsetY(), -1, -1); } } - if(clearButton!=null){ + /*if(clearButton!=null){ //Plus Drawable clear = getResources().getDrawable(R.drawable.ic_close_white); clear.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); clearButton.setImageDrawable(clear); - } + }*/ + } + + public ImageView getClearButton(){ + return clearButton; } public void hideSubItem(int id) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java index 7d48a094..76ebe7e1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java @@ -24,6 +24,7 @@ import org.telegram.android.AndroidUtilities; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; +import org.telegram.messenger.Utilities; public class BaseFragment { private boolean isFinished = false; @@ -82,7 +83,7 @@ public class BaseFragment { actionBar = new ActionBar(parentLayout.getContext()); actionBar.parentFragment = this; //actionBar.setBackgroundColor(0xff54759e); - actionBar.setBackgroundResource(R.color.header); + actionBar.setBackgroundResource(R.color.header); //Plus actionBar.setItemsBackground(R.drawable.bar_selector); } } @@ -119,7 +120,10 @@ public class BaseFragment { } public void onResume() { - + if(AndroidUtilities.needRestart){ + AndroidUtilities.needRestart = false; + Utilities.restartApp(); + } } public void onPause() { @@ -208,7 +212,7 @@ public class BaseFragment { } public AlertDialog showAlertDialog(AlertDialog.Builder builder) { - if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) { + if (parentLayout == null || parentLayout.animationInProgress || parentLayout.startedTracking || parentLayout.checkTransitionAnimation()) { return null; } try { @@ -221,7 +225,7 @@ public class BaseFragment { } try { visibleDialog = builder.show(); - // + //Plus int color = AndroidUtilities.getIntColor("themeColor"); int id = visibleDialog.getContext().getResources().getIdentifier("android:id/alertTitle", null, null); TextView tv = (TextView) visibleDialog.findViewById(id); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java index 435bd463..c21bdd62 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java @@ -25,10 +25,10 @@ import android.widget.FrameLayout; import android.widget.ListView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.R; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; public class DrawerLayoutContainer extends FrameLayout { @@ -57,6 +57,7 @@ public class DrawerLayoutContainer extends FrameLayout { private float drawerPosition = 0; private boolean drawerOpened = false; + private boolean allowDrawContent = true; public DrawerLayoutContainer(Context context) { super(context); @@ -150,7 +151,7 @@ public class DrawerLayoutContainer extends FrameLayout { if (drawerLayout.getVisibility() != newVisibility) { drawerLayout.setVisibility(newVisibility); } - setScrimOpacity(drawerPosition / (float)drawerLayout.getMeasuredWidth()); + setScrimOpacity(drawerPosition / (float) drawerLayout.getMeasuredWidth()); } public float getDrawerPosition() { @@ -276,6 +277,13 @@ public class DrawerLayoutContainer extends FrameLayout { return drawerOpened; } + public void setAllowDrawContent(boolean value) { + if (allowDrawContent != value) { + allowDrawContent = value; + invalidate(); + } + } + public boolean onTouchEvent(MotionEvent ev) { if (!parentActionBarLayout.checkTransitionAnimation()) { if (drawerOpened && ev != null && ev.getX() > drawerPosition && !startedTracking) { @@ -301,7 +309,7 @@ public class DrawerLayoutContainer extends FrameLayout { float dx = (int) (ev.getX() - startedTrackingX); float dy = Math.abs((int) ev.getY() - startedTrackingY); velocityTracker.addMovement(ev); - if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.2f, true) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.3f, true))) { + if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.2f, true) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.4f, true))) { prepareForDrawerOpen(ev); startedTrackingX = (int) ev.getX(); requestDisallowInterceptTouchEvent(true); @@ -441,11 +449,14 @@ public class DrawerLayoutContainer extends FrameLayout { child.measure(drawerWidthSpec, drawerHeightSpec); } } - getDrawerLayout().setBackgroundColor(AndroidUtilities.getIntDef("drawerListColor",0xffffffff)); + getDrawerLayout().setBackgroundColor(AndroidUtilities.getIntDef("drawerListColor",0xffffffff)); //Plus } @Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { + if (!allowDrawContent) { + return false; + } final int height = getHeight(); final boolean drawingContent = child != drawerLayout; int clipLeft = 0, clipRight = getWidth(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java index 811143c8..c9aaa6b3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java @@ -87,11 +87,7 @@ public class MenuDrawable extends Drawable { canvas.drawLine(startXDiff, -startYDiff, endXDiff, -endYDiff, paint); canvas.drawLine(startXDiff, startYDiff, endXDiff, endYDiff, paint); canvas.restore(); - updateTheme(); - } - - private void updateTheme(){ - paint.setColor(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff)); + paint.setColor(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff)); //Plus } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java index 92a45e30..d317bccf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java @@ -17,13 +17,13 @@ import android.view.View; import android.view.ViewGroup; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.ContactsController; import org.telegram.android.LocaleController; import org.telegram.android.MessagesController; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.GreySectionCell; import org.telegram.ui.Cells.LetterSectionCell; @@ -41,12 +41,14 @@ public class ContactsAdapter extends BaseSectionsAdapter { private HashMap ignoreUsers; private HashMap checkedMap; private boolean scrolling; + private boolean isAdmin; - public ContactsAdapter(Context context, boolean arg1, boolean arg2, HashMap arg3) { + public ContactsAdapter(Context context, boolean arg1, boolean arg2, HashMap arg3, boolean arg4) { mContext = context; onlyUsers = arg1; needPhonebook = arg2; ignoreUsers = arg3; + isAdmin = arg4; } public void setCheckedMap(HashMap map) { @@ -59,7 +61,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { @Override public Object getItem(int section, int position) { - if (onlyUsers) { + if (onlyUsers && !isAdmin) { if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) { ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); if (position < arr.size()) { @@ -88,12 +90,12 @@ public class ContactsAdapter extends BaseSectionsAdapter { @Override public boolean isRowEnabled(int section, int row) { - if (onlyUsers) { + if (onlyUsers && !isAdmin) { ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); return row < arr.size(); } else { if (section == 0) { - if (needPhonebook) { + if (needPhonebook || isAdmin) { if (row == 1) { return false; } @@ -117,6 +119,9 @@ public class ContactsAdapter extends BaseSectionsAdapter { if (!onlyUsers) { count++; } + if (isAdmin) { + count++; + } if (needPhonebook) { count++; } @@ -125,7 +130,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { @Override public int getCountForSection(int section) { - if (onlyUsers) { + if (onlyUsers && !isAdmin) { if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) { ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); int count = arr.size(); @@ -136,7 +141,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { } } else { if (section == 0) { - if (needPhonebook) { + if (needPhonebook || isAdmin) { return 2; } else { return 4; @@ -161,7 +166,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { if (convertView == null) { convertView = new LetterSectionCell(mContext); } - if (onlyUsers) { + if (onlyUsers && !isAdmin) { if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) { ((LetterSectionCell) convertView).setLetter(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); } else { @@ -176,7 +181,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { ((LetterSectionCell) convertView).setLetter(""); } } - ((LetterSectionCell) convertView).setLetterColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff808080)); + ((LetterSectionCell) convertView).setLetterColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff808080)); //Plus return convertView; } @@ -190,7 +195,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { if (convertView == null) { convertView = new DividerCell(mContext); convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 28 : 72), 0, AndroidUtilities.dp(LocaleController.isRTL ? 72 : 28), 0); - convertView.setTag("contactsRowColor"); + convertView.setTag("contactsRowColor"); //Plus } } else if (type == 3) { if (convertView == null) { @@ -211,6 +216,11 @@ public class ContactsAdapter extends BaseSectionsAdapter { Drawable invite = mContext.getResources().getDrawable(R.drawable.menu_invite); invite.setColorFilter(cColorGrey, PorterDuff.Mode.SRC_IN); actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), invite); + } else if (isAdmin) { + //actionCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.menu_invite); + Drawable invite = mContext.getResources().getDrawable(R.drawable.menu_invite); + invite.setColorFilter(cColorGrey, PorterDuff.Mode.SRC_IN); + actionCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), invite); } else { if (position == 0) { //actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup); @@ -252,7 +262,7 @@ public class ContactsAdapter extends BaseSectionsAdapter { ((UserCell) convertView).setAvatarRadius(themePrefs.getInt("contactsAvatarRadius", 32)); } - ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers ? 0 : 1))); + ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers && !isAdmin ? 0 : 1))); TLRPC.User user = MessagesController.getInstance().getUser(arr.get(position).user_id); ((UserCell)convertView).setData(user, null, null, 0); if (checkedMap != null) { @@ -266,18 +276,18 @@ public class ContactsAdapter extends BaseSectionsAdapter { } } } - parent.setBackgroundColor(themePrefs.getInt("contactsRowColor", 0xffffffff)); + parent.setBackgroundColor(themePrefs.getInt("contactsRowColor", 0xffffffff)); //Plus return convertView; } @Override public int getItemViewType(int section, int position) { - if (onlyUsers) { + if (onlyUsers && !isAdmin) { ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); return position < arr.size() ? 0 : 4; } else { if (section == 0) { - if (needPhonebook) { + if (needPhonebook || isAdmin) { if (position == 1) { return 3; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java index 297ed318..eb4bf7a3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -8,17 +8,14 @@ package org.telegram.ui.Adapters; -import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.view.View; import android.view.ViewGroup; import org.telegram.android.AndroidUtilities; -import org.telegram.android.MessageObject; import org.telegram.android.MessagesController; import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.ui.Cells.DialogCell; import org.telegram.ui.Cells.LoadingCell; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java index 448e3e9e..87e92423 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java @@ -25,10 +25,8 @@ import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.RPCRequest; -import org.telegram.messenger.TLClassStore; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; -import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; import org.telegram.ui.Cells.DialogCell; import org.telegram.ui.Cells.GreySectionCell; @@ -242,8 +240,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { if (found != 0) { ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.User user = (TLRPC.User) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); - if (user.id != UserConfig.getClientUserId()) { + TLRPC.User user = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); DialogSearchResult dialogSearchResult = dialogsResult.get((long) user.id); if (user.status != null) { user.status.expires = cursor.intValue(1); @@ -256,7 +253,6 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { dialogSearchResult.object = user; resultCount++; } - } MessagesStorage.getInstance().getBuffersStorage().reuseFreeBuffer(data); break; } @@ -277,7 +273,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { if (name.startsWith(q) || name.contains(" " + q) || tName != null && (tName.startsWith(q) || tName.contains(" " + q))) { ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.Chat chat = (TLRPC.Chat) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Chat chat = TLRPC.Chat.TLdeserialize(data, data.readInt32(false), false); long dialog_id; if (chat.id > 0) { dialog_id = -chat.id; @@ -323,7 +319,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0)); ByteBufferDesc data2 = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(6)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0 && cursor.byteBufferValue(6, data2.buffer) != 0) { - TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.EncryptedChat chat = TLRPC.EncryptedChat.TLdeserialize(data, data.readInt32(false), false); DialogSearchResult dialogSearchResult = dialogsResult.get((long) chat.id << 32); chat.user_id = cursor.intValue(2); @@ -342,7 +338,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { chat.future_auth_key = cursor.byteArrayValue(15); chat.key_hash = cursor.byteArrayValue(16); - TLRPC.User user = (TLRPC.User) TLClassStore.Instance().TLdeserialize(data2, data2.readInt32()); + TLRPC.User user = TLRPC.User.TLdeserialize(data2, data2.readInt32(false), false); if (user.status != null) { user.status.expires = cursor.intValue(7); } @@ -417,8 +413,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { if (found != 0) { ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - TLRPC.User user = (TLRPC.User) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); - if (user.id != UserConfig.getClientUserId()) { + TLRPC.User user = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); if (user.status != null) { user.status.expires = cursor.intValue(1); } @@ -429,7 +424,6 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { } resultArray.add(user); } - } MessagesStorage.getInstance().getBuffersStorage().reuseFreeBuffer(data); break; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java index 05a051b0..7d23982b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java @@ -9,7 +9,6 @@ package org.telegram.ui.Adapters; import android.content.Context; -import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; @@ -18,12 +17,12 @@ import org.telegram.SQLite.SQLitePreparedStatement; import org.telegram.android.AndroidUtilities; import org.telegram.android.MessagesStorage; import org.telegram.android.NotificationCenter; +import org.telegram.android.support.widget.RecyclerView; import org.telegram.messenger.ByteBufferDesc; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.RPCRequest; -import org.telegram.messenger.TLClassStore; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; import org.telegram.messenger.Utilities; @@ -109,7 +108,7 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio if (cursor.next()) { ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { - result = (TLRPC.messages_AllStickers) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + result = TLRPC.messages_AllStickers.TLdeserialize(data, data.readInt32(false), false); } date = cursor.intValue(1); MessagesStorage.getInstance().getBuffersStorage().reuseFreeBuffer(data); @@ -320,7 +319,6 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio @Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { - Holder holder = (Holder) viewHolder; int side = 0; if (i == 0) { if (stickers.size() == 1) { @@ -331,6 +329,6 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio } else if (i == stickers.size() - 1) { side = 1; } - ((StickerCell) holder.itemView).setSticker(stickers.get(i), side); + ((StickerCell) viewHolder.itemView).setSticker(stickers.get(i), side); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Animator10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Animator10.java deleted file mode 100644 index 31a6d756..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Animator10.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.view.animation.Interpolator; - -import java.util.ArrayList; - -public abstract class Animator10 implements Cloneable { - - ArrayList mListeners = null; - ArrayList mPauseListeners = null; - boolean mPaused = false; - - public abstract long getStartDelay(); - - public abstract void setStartDelay(long startDelay); - - public abstract Animator10 setDuration(long duration); - - public abstract long getDuration(); - - public abstract void setInterpolator(Interpolator value); - - public abstract boolean isRunning(); - - public void start() { - - } - - public void cancel() { - - } - - public void end() { - - } - - @SuppressWarnings("unchecked") - public void pause() { - if (isStarted() && !mPaused) { - mPaused = true; - if (mPauseListeners != null) { - ArrayList tmpListeners = (ArrayList) mPauseListeners.clone(); - int numListeners = tmpListeners.size(); - for (AnimatorPauseListener tmpListener : tmpListeners) { - tmpListener.onAnimationPause(this); - } - } - } - } - - @SuppressWarnings("unchecked") - public void resume() { - if (mPaused) { - mPaused = false; - if (mPauseListeners != null) { - ArrayList tmpListeners = (ArrayList) mPauseListeners.clone(); - int numListeners = tmpListeners.size(); - for (AnimatorPauseListener tmpListener : tmpListeners) { - tmpListener.onAnimationResume(this); - } - } - } - } - - public boolean isPaused() { - return mPaused; - } - - public boolean isStarted() { - return isRunning(); - } - - public Interpolator getInterpolator() { - return null; - } - - public void addListener(AnimatorListener listener) { - if (mListeners == null) { - mListeners = new ArrayList(); - } - mListeners.add(listener); - } - - public void removeListener(AnimatorListener listener) { - if (mListeners == null) { - return; - } - mListeners.remove(listener); - if (mListeners.size() == 0) { - mListeners = null; - } - } - - public ArrayList getListeners() { - return mListeners; - } - - public void addPauseListener(AnimatorPauseListener listener) { - if (mPauseListeners == null) { - mPauseListeners = new ArrayList(); - } - mPauseListeners.add(listener); - } - - public void removePauseListener(AnimatorPauseListener listener) { - if (mPauseListeners == null) { - return; - } - mPauseListeners.remove(listener); - if (mPauseListeners.size() == 0) { - mPauseListeners = null; - } - } - - public void removeAllListeners() { - if (mListeners != null) { - mListeners.clear(); - mListeners = null; - } - if (mPauseListeners != null) { - mPauseListeners.clear(); - mPauseListeners = null; - } - } - - @Override - public Animator10 clone() { - try { - final Animator10 anim = (Animator10) super.clone(); - if (mListeners != null) { - ArrayList oldListeners = mListeners; - anim.mListeners = new ArrayList(); - int numListeners = oldListeners.size(); - for (AnimatorListener oldListener : oldListeners) { - anim.mListeners.add(oldListener); - } - } - if (mPauseListeners != null) { - ArrayList oldListeners = mPauseListeners; - anim.mPauseListeners = new ArrayList(); - int numListeners = oldListeners.size(); - for (AnimatorPauseListener oldListener : oldListeners) { - anim.mPauseListeners.add(oldListener); - } - } - return anim; - } catch (CloneNotSupportedException e) { - throw new AssertionError(); - } - } - - public void setupStartValues() { - - } - - public void setupEndValues() { - - } - - public void setTarget(Object target) { - - } - - public interface AnimatorListener { - void onAnimationStart(Animator10 animation); - void onAnimationEnd(Animator10 animation); - void onAnimationCancel(Animator10 animation); - void onAnimationRepeat(Animator10 animation); - } - - public interface AnimatorPauseListener { - void onAnimationPause(Animator10 animation); - void onAnimationResume(Animator10 animation); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorListenerAdapter10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorListenerAdapter10.java deleted file mode 100644 index 42349cd1..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorListenerAdapter10.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -public abstract class AnimatorListenerAdapter10 implements Animator10.AnimatorListener, Animator10.AnimatorPauseListener { - - @Override - public void onAnimationCancel(Animator10 animation) { - - } - - @Override - public void onAnimationEnd(Animator10 animation) { - - } - - @Override - public void onAnimationRepeat(Animator10 animation) { - - } - - @Override - public void onAnimationStart(Animator10 animation) { - - } - - @Override - public void onAnimationPause(Animator10 animation) { - - } - - @Override - public void onAnimationResume(Animator10 animation) { - - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorSet10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorSet10.java deleted file mode 100644 index 274dd604..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorSet10.java +++ /dev/null @@ -1,705 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.view.animation.Interpolator; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; - -public final class AnimatorSet10 extends Animator10 { - - private ArrayList mPlayingSet = new ArrayList<>(); - private HashMap mNodeMap = new HashMap<>(); - private ArrayList mNodes = new ArrayList<>(); - private ArrayList mSortedNodes = new ArrayList<>(); - private boolean mNeedsSort = true; - private AnimatorSetListener mSetListener = null; - boolean mTerminated = false; - private boolean mStarted = false; - private long mStartDelay = 0; - private ValueAnimator mDelayAnim = null; - private long mDuration = -1; - private Interpolator mInterpolator = null; - - public void playTogether(Animator10... items) { - if (items != null) { - mNeedsSort = true; - Builder builder = play(items[0]); - for (int i = 1; i < items.length; ++i) { - builder.with(items[i]); - } - } - } - - public void playTogether(Collection items) { - if (items != null && items.size() > 0) { - mNeedsSort = true; - Builder builder = null; - for (Animator10 anim : items) { - if (builder == null) { - builder = play(anim); - } else { - builder.with(anim); - } - } - } - } - - public void playSequentially(Animator10... items) { - if (items != null) { - mNeedsSort = true; - if (items.length == 1) { - play(items[0]); - } else { - for (int i = 0; i < items.length - 1; ++i) { - play(items[i]).before(items[i+1]); - } - } - } - } - - public void playSequentially(List items) { - if (items != null && items.size() > 0) { - mNeedsSort = true; - if (items.size() == 1) { - play(items.get(0)); - } else { - for (int i = 0; i < items.size() - 1; ++i) { - play(items.get(i)).before(items.get(i+1)); - } - } - } - } - - public ArrayList getChildAnimations() { - ArrayList childList = new ArrayList<>(); - for (Node node : mNodes) { - childList.add(node.animation); - } - return childList; - } - - @Override - public void setTarget(Object target) { - for (Node node : mNodes) { - Animator10 animation = node.animation; - if (animation instanceof AnimatorSet10) { - animation.setTarget(target); - } else if (animation instanceof ObjectAnimator10) { - animation.setTarget(target); - } - } - } - - @Override - public void setInterpolator(Interpolator interpolator) { - mInterpolator = interpolator; - } - - @Override - public Interpolator getInterpolator() { - return mInterpolator; - } - - public Builder play(Animator10 anim) { - if (anim != null) { - mNeedsSort = true; - return new Builder(anim); - } - return null; - } - - @SuppressWarnings("unchecked") - @Override - public void cancel() { - mTerminated = true; - if (isStarted()) { - ArrayList tmpListeners = null; - if (mListeners != null) { - tmpListeners = (ArrayList) mListeners.clone(); - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationCancel(this); - } - } - if (mDelayAnim != null && mDelayAnim.isRunning()) { - mDelayAnim.cancel(); - } else if (mSortedNodes.size() > 0) { - for (Node node : mSortedNodes) { - node.animation.cancel(); - } - } - if (tmpListeners != null) { - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationEnd(this); - } - } - mStarted = false; - } - } - - @SuppressWarnings("unchecked") - @Override - public void end() { - mTerminated = true; - if (isStarted()) { - if (mSortedNodes.size() != mNodes.size()) { - // hasn't been started yet - sort the nodes now, then end them - sortNodes(); - for (Node node : mSortedNodes) { - if (mSetListener == null) { - mSetListener = new AnimatorSetListener(this); - } - node.animation.addListener(mSetListener); - } - } - if (mDelayAnim != null) { - mDelayAnim.cancel(); - } - if (mSortedNodes.size() > 0) { - for (Node node : mSortedNodes) { - node.animation.end(); - } - } - if (mListeners != null) { - ArrayList tmpListeners = (ArrayList) mListeners.clone(); - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationEnd(this); - } - } - mStarted = false; - } - } - - @Override - public boolean isRunning() { - for (Node node : mNodes) { - if (node.animation.isRunning()) { - return true; - } - } - return false; - } - - @Override - public boolean isStarted() { - return mStarted; - } - - @Override - public long getStartDelay() { - return mStartDelay; - } - - @Override - public void setStartDelay(long startDelay) { - mStartDelay = startDelay; - } - - @Override - public long getDuration() { - return mDuration; - } - - @Override - public AnimatorSet10 setDuration(long duration) { - if (duration < 0) { - throw new IllegalArgumentException("duration must be a value of zero or greater"); - } - mDuration = duration; - return this; - } - - @Override - public void setupStartValues() { - for (Node node : mNodes) { - node.animation.setupStartValues(); - } - } - - @Override - public void setupEndValues() { - for (Node node : mNodes) { - node.animation.setupEndValues(); - } - } - - @Override - public void pause() { - boolean previouslyPaused = mPaused; - super.pause(); - if (!previouslyPaused && mPaused) { - if (mDelayAnim != null) { - mDelayAnim.pause(); - } else { - for (Node node : mNodes) { - node.animation.pause(); - } - } - } - } - - @Override - public void resume() { - boolean previouslyPaused = mPaused; - super.resume(); - if (previouslyPaused && !mPaused) { - if (mDelayAnim != null) { - mDelayAnim.resume(); - } else { - for (Node node : mNodes) { - node.animation.resume(); - } - } - } - } - - @SuppressWarnings("unchecked") - @Override - public void start() { - mTerminated = false; - mStarted = true; - mPaused = false; - - if (mDuration >= 0) { - for (Node node : mNodes) { - node.animation.setDuration(mDuration); - } - } - if (mInterpolator != null) { - for (Node node : mNodes) { - node.animation.setInterpolator(mInterpolator); - } - } - - sortNodes(); - - int numSortedNodes = mSortedNodes.size(); - for (Node node : mSortedNodes) { - ArrayList oldListeners = node.animation.getListeners(); - if (oldListeners != null && oldListeners.size() > 0) { - final ArrayList clonedListeners = new - ArrayList<>(oldListeners); - - for (AnimatorListener listener : clonedListeners) { - if (listener instanceof DependencyListener || - listener instanceof AnimatorSetListener) { - node.animation.removeListener(listener); - } - } - } - } - - final ArrayList nodesToStart = new ArrayList<>(); - for (Node node : mSortedNodes) { - if (mSetListener == null) { - mSetListener = new AnimatorSetListener(this); - } - if (node.dependencies == null || node.dependencies.size() == 0) { - nodesToStart.add(node); - } else { - int numDependencies = node.dependencies.size(); - for (int j = 0; j < numDependencies; ++j) { - Dependency dependency = node.dependencies.get(j); - dependency.node.animation.addListener( - new DependencyListener(this, node, dependency.rule)); - } - node.tmpDependencies = (ArrayList) node.dependencies.clone(); - } - node.animation.addListener(mSetListener); - } - - if (mStartDelay <= 0) { - for (Node node : nodesToStart) { - node.animation.start(); - mPlayingSet.add(node.animation); - } - } else { - mDelayAnim = ValueAnimator.ofFloat(0f, 1f); - mDelayAnim.setDuration(mStartDelay); - mDelayAnim.addListener(new AnimatorListenerAdapter10() { - boolean canceled = false; - public void onAnimationCancel(Animator10 anim) { - canceled = true; - } - public void onAnimationEnd(Animator10 anim) { - if (!canceled) { - int numNodes = nodesToStart.size(); - for (Node node : nodesToStart) { - node.animation.start(); - mPlayingSet.add(node.animation); - } - } - mDelayAnim = null; - } - }); - mDelayAnim.start(); - } - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (AnimatorListener tmpListener : tmpListeners) { - tmpListener.onAnimationStart(this); - } - } - if (mNodes.size() == 0 && mStartDelay == 0) { - mStarted = false; - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (AnimatorListener tmpListener : tmpListeners) { - tmpListener.onAnimationEnd(this); - } - } - } - } - - @Override - public AnimatorSet10 clone() { - final AnimatorSet10 anim = (AnimatorSet10) super.clone(); - - anim.mNeedsSort = true; - anim.mTerminated = false; - anim.mStarted = false; - anim.mPlayingSet = new ArrayList<>(); - anim.mNodeMap = new HashMap<>(); - anim.mNodes = new ArrayList<>(); - anim.mSortedNodes = new ArrayList<>(); - - HashMap nodeCloneMap = new HashMap<>(); - for (Node node : mNodes) { - Node nodeClone = node.clone(); - nodeCloneMap.put(node, nodeClone); - anim.mNodes.add(nodeClone); - anim.mNodeMap.put(nodeClone.animation, nodeClone); - nodeClone.dependencies = null; - nodeClone.tmpDependencies = null; - nodeClone.nodeDependents = null; - nodeClone.nodeDependencies = null; - ArrayList cloneListeners = nodeClone.animation.getListeners(); - if (cloneListeners != null) { - ArrayList listenersToRemove = null; - for (AnimatorListener listener : cloneListeners) { - if (listener instanceof AnimatorSetListener) { - if (listenersToRemove == null) { - listenersToRemove = new ArrayList<>(); - } - listenersToRemove.add(listener); - } - } - if (listenersToRemove != null) { - for (AnimatorListener listener : listenersToRemove) { - cloneListeners.remove(listener); - } - } - } - } - for (Node node : mNodes) { - Node nodeClone = nodeCloneMap.get(node); - if (node.dependencies != null) { - for (Dependency dependency : node.dependencies) { - Node clonedDependencyNode = nodeCloneMap.get(dependency.node); - Dependency cloneDependency = new Dependency(clonedDependencyNode, dependency.rule); - nodeClone.addDependency(cloneDependency); - } - } - } - return anim; - } - - private static class DependencyListener implements AnimatorListener { - - private AnimatorSet10 mAnimatorSet; - private Node mNode; - private int mRule; - - public DependencyListener(AnimatorSet10 animatorSet, Node node, int rule) { - this.mAnimatorSet = animatorSet; - this.mNode = node; - this.mRule = rule; - } - - public void onAnimationCancel(Animator10 animation) { - - } - - public void onAnimationEnd(Animator10 animation) { - if (mRule == Dependency.AFTER) { - startIfReady(animation); - } - } - - public void onAnimationRepeat(Animator10 animation) { - - } - - public void onAnimationStart(Animator10 animation) { - if (mRule == Dependency.WITH) { - startIfReady(animation); - } - } - - private void startIfReady(Animator10 dependencyAnimation) { - if (mAnimatorSet.mTerminated) { - return; - } - Dependency dependencyToRemove = null; - int numDependencies = mNode.tmpDependencies.size(); - for (int i = 0; i < numDependencies; ++i) { - Dependency dependency = mNode.tmpDependencies.get(i); - if (dependency.rule == mRule && dependency.node.animation == dependencyAnimation) { - dependencyToRemove = dependency; - dependencyAnimation.removeListener(this); - break; - } - } - mNode.tmpDependencies.remove(dependencyToRemove); - if (mNode.tmpDependencies.size() == 0) { - mNode.animation.start(); - mAnimatorSet.mPlayingSet.add(mNode.animation); - } - } - } - - private class AnimatorSetListener implements AnimatorListener { - - private AnimatorSet10 mAnimatorSet; - - AnimatorSetListener(AnimatorSet10 animatorSet) { - mAnimatorSet = animatorSet; - } - - public void onAnimationCancel(Animator10 animation) { - if (!mTerminated) { - if (mPlayingSet.size() == 0) { - if (mListeners != null) { - int numListeners = mListeners.size(); - for (AnimatorListener mListener : mListeners) { - mListener.onAnimationCancel(mAnimatorSet); - } - } - } - } - } - - @SuppressWarnings("unchecked") - public void onAnimationEnd(Animator10 animation) { - animation.removeListener(this); - mPlayingSet.remove(animation); - Node animNode = mAnimatorSet.mNodeMap.get(animation); - animNode.done = true; - if (!mTerminated) { - ArrayList sortedNodes = mAnimatorSet.mSortedNodes; - boolean allDone = true; - int numSortedNodes = sortedNodes.size(); - for (Node sortedNode : sortedNodes) { - if (!sortedNode.done) { - allDone = false; - break; - } - } - if (allDone) { - if (mListeners != null) { - ArrayList tmpListeners = - (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (AnimatorListener tmpListener : tmpListeners) { - tmpListener.onAnimationEnd(mAnimatorSet); - } - } - mAnimatorSet.mStarted = false; - mAnimatorSet.mPaused = false; - } - } - } - - public void onAnimationRepeat(Animator10 animation) { - - } - - public void onAnimationStart(Animator10 animation) { - - } - } - - private void sortNodes() { - if (mNeedsSort) { - mSortedNodes.clear(); - ArrayList roots = new ArrayList<>(); - int numNodes = mNodes.size(); - for (Node node : mNodes) { - if (node.dependencies == null || node.dependencies.size() == 0) { - roots.add(node); - } - } - ArrayList tmpRoots = new ArrayList<>(); - while (roots.size() > 0) { - int numRoots = roots.size(); - for (Node root : roots) { - mSortedNodes.add(root); - if (root.nodeDependents != null) { - int numDependents = root.nodeDependents.size(); - for (int j = 0; j < numDependents; ++j) { - Node node = root.nodeDependents.get(j); - node.nodeDependencies.remove(root); - if (node.nodeDependencies.size() == 0) { - tmpRoots.add(node); - } - } - } - } - roots.clear(); - roots.addAll(tmpRoots); - tmpRoots.clear(); - } - mNeedsSort = false; - if (mSortedNodes.size() != mNodes.size()) { - throw new IllegalStateException("Circular dependencies cannot exist in AnimatorSet"); - } - } else { - int numNodes = mNodes.size(); - for (Node node : mNodes) { - if (node.dependencies != null && node.dependencies.size() > 0) { - int numDependencies = node.dependencies.size(); - for (int j = 0; j < numDependencies; ++j) { - Dependency dependency = node.dependencies.get(j); - if (node.nodeDependencies == null) { - node.nodeDependencies = new ArrayList<>(); - } - if (!node.nodeDependencies.contains(dependency.node)) { - node.nodeDependencies.add(dependency.node); - } - } - } - node.done = false; - } - } - } - - private static class Dependency { - static final int WITH = 0; - static final int AFTER = 1; - public Node node; - public int rule; - - public Dependency(Node node, int rule) { - this.node = node; - this.rule = rule; - } - } - - private static class Node implements Cloneable { - public Animator10 animation; - public ArrayList dependencies = null; - public ArrayList tmpDependencies = null; - public ArrayList nodeDependencies = null; - public ArrayList nodeDependents = null; - public boolean done = false; - - public Node(Animator10 animation) { - this.animation = animation; - } - - public void addDependency(Dependency dependency) { - if (dependencies == null) { - dependencies = new ArrayList<>(); - nodeDependencies = new ArrayList<>(); - } - dependencies.add(dependency); - if (!nodeDependencies.contains(dependency.node)) { - nodeDependencies.add(dependency.node); - } - Node dependencyNode = dependency.node; - if (dependencyNode.nodeDependents == null) { - dependencyNode.nodeDependents = new ArrayList<>(); - } - dependencyNode.nodeDependents.add(this); - } - - @Override - public Node clone() { - try { - Node node = (Node) super.clone(); - node.animation = animation.clone(); - return node; - } catch (CloneNotSupportedException e) { - throw new AssertionError(); - } - } - } - - public class Builder { - - private Node mCurrentNode; - - Builder(Animator10 anim) { - mCurrentNode = mNodeMap.get(anim); - if (mCurrentNode == null) { - mCurrentNode = new Node(anim); - mNodeMap.put(anim, mCurrentNode); - mNodes.add(mCurrentNode); - } - } - - public Builder with(Animator10 anim) { - Node node = mNodeMap.get(anim); - if (node == null) { - node = new Node(anim); - mNodeMap.put(anim, node); - mNodes.add(node); - } - Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH); - node.addDependency(dependency); - return this; - } - - public Builder before(Animator10 anim) { - Node node = mNodeMap.get(anim); - if (node == null) { - node = new Node(anim); - mNodeMap.put(anim, node); - mNodes.add(node); - } - Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER); - node.addDependency(dependency); - return this; - } - - public Builder after(Animator10 anim) { - Node node = mNodeMap.get(anim); - if (node == null) { - node = new Node(anim); - mNodeMap.put(anim, node); - mNodes.add(node); - } - Dependency dependency = new Dependency(node, Dependency.AFTER); - mCurrentNode.addDependency(dependency); - return this; - } - - public Builder after(long delay) { - ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); - anim.setDuration(delay); - after(anim); - return this; - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatEvaluator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatEvaluator.java deleted file mode 100644 index 2591ebf7..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatEvaluator.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -public class FloatEvaluator implements TypeEvaluator { - public Float evaluate(float fraction, Number startValue, Number endValue) { - float startFloat = startValue.floatValue(); - return startFloat + fraction * (endValue.floatValue() - startFloat); - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatKeyframeSet.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatKeyframeSet.java deleted file mode 100644 index 52d0da5f..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatKeyframeSet.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.view.animation.Interpolator; - -import org.telegram.ui.Animation.Keyframe.FloatKeyframe; - -import java.util.ArrayList; - -class FloatKeyframeSet extends KeyframeSet { - private float firstValue; - private float lastValue; - private float deltaValue; - private boolean firstTime = true; - - public FloatKeyframeSet(FloatKeyframe... keyframes) { - super(keyframes); - } - - @Override - public Object getValue(float fraction) { - return getFloatValue(fraction); - } - - @Override - public FloatKeyframeSet clone() { - ArrayList keyframes = mKeyframes; - int numKeyframes = mKeyframes.size(); - FloatKeyframe[] newKeyframes = new FloatKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - newKeyframes[i] = (FloatKeyframe) keyframes.get(i).clone(); - } - return new FloatKeyframeSet(newKeyframes); - } - - @SuppressWarnings("unchecked") - public float getFloatValue(float fraction) { - if (mNumKeyframes == 2) { - if (firstTime) { - firstTime = false; - firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue(); - lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue(); - deltaValue = lastValue - firstValue; - } - if (mInterpolator != null) { - fraction = mInterpolator.getInterpolation(fraction); - } - if (mEvaluator == null) { - return firstValue + fraction * deltaValue; - } else { - return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue(); - } - } - if (fraction <= 0f) { - final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); - final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1); - float prevValue = prevKeyframe.getFloatValue(); - float nextValue = nextKeyframe.getFloatValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? prevValue + intervalFraction * (nextValue - prevValue) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).floatValue(); - } else if (fraction >= 1f) { - final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 2); - final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 1); - float prevValue = prevKeyframe.getFloatValue(); - float nextValue = nextKeyframe.getFloatValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? prevValue + intervalFraction * (nextValue - prevValue) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).floatValue(); - } - FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0); - for (int i = 1; i < mNumKeyframes; ++i) { - FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(i); - if (fraction < nextKeyframe.getFraction()) { - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevKeyframe.getFraction()) / - (nextKeyframe.getFraction() - prevKeyframe.getFraction()); - float prevValue = prevKeyframe.getFloatValue(); - float nextValue = nextKeyframe.getFloatValue(); - return mEvaluator == null ? prevValue + intervalFraction * (nextValue - prevValue) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).floatValue(); - } - prevKeyframe = nextKeyframe; - } - return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).floatValue(); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty10.java deleted file mode 100755 index 1a05b3bc..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty10.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.telegram.ui.Animation; - -public abstract class FloatProperty10 extends Property { - - public FloatProperty10(String name) { - super(Float.class, name); - } - - public abstract void setValue(T object, float value); - - @Override - final public void set(T object, Float value) { - setValue(object, value.floatValue()); - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntEvaluator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntEvaluator.java deleted file mode 100644 index cd3a19eb..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntEvaluator.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -public class IntEvaluator implements TypeEvaluator { - public Integer evaluate(float fraction, Integer startValue, Integer endValue) { - int startInt = startValue; - return (int)(startInt + fraction * (endValue - startInt)); - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntKeyframeSet.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntKeyframeSet.java deleted file mode 100644 index 9d58863c..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntKeyframeSet.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.view.animation.Interpolator; - -import org.telegram.ui.Animation.Keyframe.IntKeyframe; - -import java.util.ArrayList; - -class IntKeyframeSet extends KeyframeSet { - private int firstValue; - private int lastValue; - private int deltaValue; - private boolean firstTime = true; - - public IntKeyframeSet(IntKeyframe... keyframes) { - super(keyframes); - } - - @Override - public Object getValue(float fraction) { - return getIntValue(fraction); - } - - @Override - public IntKeyframeSet clone() { - ArrayList keyframes = mKeyframes; - int numKeyframes = mKeyframes.size(); - IntKeyframe[] newKeyframes = new IntKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - newKeyframes[i] = (IntKeyframe) keyframes.get(i).clone(); - } - return new IntKeyframeSet(newKeyframes); - } - - @SuppressWarnings("unchecked") - public int getIntValue(float fraction) { - if (mNumKeyframes == 2) { - if (firstTime) { - firstTime = false; - firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue(); - lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue(); - deltaValue = lastValue - firstValue; - } - if (mInterpolator != null) { - fraction = mInterpolator.getInterpolation(fraction); - } - if (mEvaluator == null) { - return firstValue + (int)(fraction * deltaValue); - } else { - return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue(); - } - } - if (fraction <= 0f) { - final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); - final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1); - int prevValue = prevKeyframe.getIntValue(); - int nextValue = nextKeyframe.getIntValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? prevValue + (int)(intervalFraction * (nextValue - prevValue)) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue(); - } else if (fraction >= 1f) { - final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 2); - final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 1); - int prevValue = prevKeyframe.getIntValue(); - int nextValue = nextKeyframe.getIntValue(); - float prevFraction = prevKeyframe.getFraction(); - float nextFraction = nextKeyframe.getFraction(); - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction); - return mEvaluator == null ? prevValue + (int)(intervalFraction * (nextValue - prevValue)) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue(); - } - IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0); - for (int i = 1; i < mNumKeyframes; ++i) { - IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(i); - if (fraction < nextKeyframe.getFraction()) { - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - float intervalFraction = (fraction - prevKeyframe.getFraction()) / (nextKeyframe.getFraction() - prevKeyframe.getFraction()); - int prevValue = prevKeyframe.getIntValue(); - int nextValue = nextKeyframe.getIntValue(); - return mEvaluator == null ? prevValue + (int)(intervalFraction * (nextValue - prevValue)) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue(); - } - prevKeyframe = nextKeyframe; - } - return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).intValue(); - } -} - diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java deleted file mode 100755 index 07e72511..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.telegram.ui.Animation; - -public abstract class IntProperty extends Property { - - public IntProperty(String name) { - super(Integer.class, name); - } - - public abstract void setValue(T object, int value); - - @Override - final public void set(T object, Integer value) { - setValue(object, value.intValue()); - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Keyframe.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Keyframe.java deleted file mode 100644 index cb71460c..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Keyframe.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.view.animation.Interpolator; - -public abstract class Keyframe implements Cloneable { - - float mFraction; - Class mValueType; - private Interpolator mInterpolator = null; - boolean mHasValue = false; - - public static Keyframe ofInt(float fraction, int value) { - return new IntKeyframe(fraction, value); - } - - public static Keyframe ofInt(float fraction) { - return new IntKeyframe(fraction); - } - - public static Keyframe ofFloat(float fraction, float value) { - return new FloatKeyframe(fraction, value); - } - - public static Keyframe ofFloat(float fraction) { - return new FloatKeyframe(fraction); - } - - public static Keyframe ofObject(float fraction, Object value) { - return new ObjectKeyframe(fraction, value); - } - - public static Keyframe ofObject(float fraction) { - return new ObjectKeyframe(fraction, null); - } - - public boolean hasValue() { - return mHasValue; - } - - public abstract Object getValue(); - public abstract void setValue(Object value); - - public float getFraction() { - return mFraction; - } - - public void setFraction(float fraction) { - mFraction = fraction; - } - - public Interpolator getInterpolator() { - return mInterpolator; - } - - public void setInterpolator(Interpolator interpolator) { - mInterpolator = interpolator; - } - - public Class getType() { - return mValueType; - } - - @Override - public abstract Keyframe clone(); - - static class ObjectKeyframe extends Keyframe { - - Object mValue; - - ObjectKeyframe(float fraction, Object value) { - mFraction = fraction; - mValue = value; - mHasValue = (value != null); - mValueType = mHasValue ? value.getClass() : Object.class; - } - - public Object getValue() { - return mValue; - } - - public void setValue(Object value) { - mValue = value; - mHasValue = (value != null); - } - - @Override - public ObjectKeyframe clone() { - ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mHasValue ? mValue : null); - kfClone.setInterpolator(getInterpolator()); - return kfClone; - } - } - - static class IntKeyframe extends Keyframe { - - int mValue; - - IntKeyframe(float fraction, int value) { - mFraction = fraction; - mValue = value; - mValueType = int.class; - mHasValue = true; - } - - IntKeyframe(float fraction) { - mFraction = fraction; - mValueType = int.class; - } - - public int getIntValue() { - return mValue; - } - - public Object getValue() { - return mValue; - } - - public void setValue(Object value) { - if (value != null && value.getClass() == Integer.class) { - mValue = (Integer) value; - mHasValue = true; - } - } - - @Override - public IntKeyframe clone() { - IntKeyframe kfClone = mHasValue ? new IntKeyframe(getFraction(), mValue) : new IntKeyframe(getFraction()); - kfClone.setInterpolator(getInterpolator()); - return kfClone; - } - } - - static class FloatKeyframe extends Keyframe { - - float mValue; - - FloatKeyframe(float fraction, float value) { - mFraction = fraction; - mValue = value; - mValueType = float.class; - mHasValue = true; - } - - FloatKeyframe(float fraction) { - mFraction = fraction; - mValueType = float.class; - } - - public float getFloatValue() { - return mValue; - } - - public Object getValue() { - return mValue; - } - - public void setValue(Object value) { - if (value != null && value.getClass() == Float.class) { - mValue = (Float) value; - mHasValue = true; - } - } - - @Override - public FloatKeyframe clone() { - FloatKeyframe kfClone = mHasValue ? new FloatKeyframe(getFraction(), mValue) : new FloatKeyframe(getFraction()); - kfClone.setInterpolator(getInterpolator()); - return kfClone; - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/KeyframeSet.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/KeyframeSet.java deleted file mode 100644 index 98a34ff6..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/KeyframeSet.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import java.util.ArrayList; -import java.util.Arrays; -import android.util.Log; -import android.view.animation.Interpolator; - -import org.telegram.ui.Animation.Keyframe.IntKeyframe; -import org.telegram.ui.Animation.Keyframe.FloatKeyframe; -import org.telegram.ui.Animation.Keyframe.ObjectKeyframe; - -class KeyframeSet { - - int mNumKeyframes; - - Keyframe mFirstKeyframe; - Keyframe mLastKeyframe; - Interpolator mInterpolator; - ArrayList mKeyframes; - TypeEvaluator mEvaluator; - - public KeyframeSet(Keyframe... keyframes) { - mNumKeyframes = keyframes.length; - mKeyframes = new ArrayList(); - mKeyframes.addAll(Arrays.asList(keyframes)); - mFirstKeyframe = mKeyframes.get(0); - mLastKeyframe = mKeyframes.get(mNumKeyframes - 1); - mInterpolator = mLastKeyframe.getInterpolator(); - } - - public static KeyframeSet ofInt(int... values) { - int numKeyframes = values.length; - IntKeyframe keyframes[] = new IntKeyframe[Math.max(numKeyframes,2)]; - if (numKeyframes == 1) { - keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f); - keyframes[1] = (IntKeyframe) Keyframe.ofInt(1f, values[0]); - } else { - keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f, values[0]); - for (int i = 1; i < numKeyframes; ++i) { - keyframes[i] = (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]); - } - } - return new IntKeyframeSet(keyframes); - } - - public static KeyframeSet ofFloat(float... values) { - boolean badValue = false; - int numKeyframes = values.length; - FloatKeyframe keyframes[] = new FloatKeyframe[Math.max(numKeyframes,2)]; - if (numKeyframes == 1) { - keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f); - keyframes[1] = (FloatKeyframe) Keyframe.ofFloat(1f, values[0]); - if (Float.isNaN(values[0])) { - badValue = true; - } - } else { - keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f, values[0]); - for (int i = 1; i < numKeyframes; ++i) { - keyframes[i] = (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]); - if (Float.isNaN(values[i])) { - badValue = true; - } - } - } - if (badValue) { - Log.w("Animator", "Bad value (NaN) in float animator"); - } - return new FloatKeyframeSet(keyframes); - } - - public static KeyframeSet ofKeyframe(Keyframe... keyframes) { - int numKeyframes = keyframes.length; - boolean hasFloat = false; - boolean hasInt = false; - boolean hasOther = false; - for (Keyframe keyframe : keyframes) { - if (keyframe instanceof FloatKeyframe) { - hasFloat = true; - } else if (keyframe instanceof IntKeyframe) { - hasInt = true; - } else { - hasOther = true; - } - } - if (hasFloat && !hasInt && !hasOther) { - FloatKeyframe floatKeyframes[] = new FloatKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - floatKeyframes[i] = (FloatKeyframe) keyframes[i]; - } - return new FloatKeyframeSet(floatKeyframes); - } else if (hasInt && !hasFloat && !hasOther) { - IntKeyframe intKeyframes[] = new IntKeyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - intKeyframes[i] = (IntKeyframe) keyframes[i]; - } - return new IntKeyframeSet(intKeyframes); - } else { - return new KeyframeSet(keyframes); - } - } - - public static KeyframeSet ofObject(Object... values) { - int numKeyframes = values.length; - ObjectKeyframe keyframes[] = new ObjectKeyframe[Math.max(numKeyframes,2)]; - if (numKeyframes == 1) { - keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f); - keyframes[1] = (ObjectKeyframe) Keyframe.ofObject(1f, values[0]); - } else { - keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f, values[0]); - for (int i = 1; i < numKeyframes; ++i) { - keyframes[i] = (ObjectKeyframe) Keyframe.ofObject((float) i / (numKeyframes - 1), values[i]); - } - } - return new KeyframeSet(keyframes); - } - - public void setEvaluator(TypeEvaluator evaluator) { - mEvaluator = evaluator; - } - - @Override - public KeyframeSet clone() { - ArrayList keyframes = mKeyframes; - int numKeyframes = mKeyframes.size(); - Keyframe[] newKeyframes = new Keyframe[numKeyframes]; - for (int i = 0; i < numKeyframes; ++i) { - newKeyframes[i] = keyframes.get(i).clone(); - } - return new KeyframeSet(newKeyframes); - } - - @SuppressWarnings("unchecked") - public Object getValue(float fraction) { - if (mNumKeyframes == 2) { - if (mInterpolator != null) { - fraction = mInterpolator.getInterpolation(fraction); - } - return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(), mLastKeyframe.getValue()); - } - if (fraction <= 0f) { - final Keyframe nextKeyframe = mKeyframes.get(1); - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - final float prevFraction = mFirstKeyframe.getFraction(); - float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction); - return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(), nextKeyframe.getValue()); - } else if (fraction >= 1f) { - final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2); - final Interpolator interpolator = mLastKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - final float prevFraction = prevKeyframe.getFraction(); - float intervalFraction = (fraction - prevFraction) / (mLastKeyframe.getFraction() - prevFraction); - return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), mLastKeyframe.getValue()); - } - Keyframe prevKeyframe = mFirstKeyframe; - for (int i = 1; i < mNumKeyframes; ++i) { - Keyframe nextKeyframe = mKeyframes.get(i); - if (fraction < nextKeyframe.getFraction()) { - final Interpolator interpolator = nextKeyframe.getInterpolator(); - if (interpolator != null) { - fraction = interpolator.getInterpolation(fraction); - } - final float prevFraction = prevKeyframe.getFraction(); - float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction); - return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), nextKeyframe.getValue()); - } - prevKeyframe = nextKeyframe; - } - return mLastKeyframe.getValue(); - } - - @Override - public String toString() { - String returnVal = " "; - for (int i = 0; i < mNumKeyframes; ++i) { - returnVal += mKeyframes.get(i).getValue() + " "; - } - return returnVal; - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/NoSuchPropertyException.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/NoSuchPropertyException.java deleted file mode 100755 index a3c59a4f..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/NoSuchPropertyException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.telegram.ui.Animation; - -public class NoSuchPropertyException extends RuntimeException { - - public NoSuchPropertyException(String s) { - super(s); - } - -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java deleted file mode 100644 index 9f7ea736..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java +++ /dev/null @@ -1,488 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.view.View; - -import java.util.HashMap; - -public final class ObjectAnimator10 extends ValueAnimator { - - private static final HashMap PROXY_PROPERTIES = new HashMap(); - - static { - Property ALPHA = new FloatProperty10("alpha") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setAlpha(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getAlpha(); - } - }; - - Property PIVOT_X = new FloatProperty10("pivotX") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setPivotX(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getPivotX(); - } - }; - - Property PIVOT_Y = new FloatProperty10("pivotY") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setPivotY(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getPivotY(); - } - }; - - Property TRANSLATION_X = new FloatProperty10("translationX") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setTranslationX(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getTranslationX(); - } - }; - - Property TRANSLATION_Y = new FloatProperty10("translationY") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setTranslationY(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getTranslationY(); - } - }; - - Property ROTATION = new FloatProperty10("rotation") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setRotation(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getRotation(); - } - }; - - Property ROTATION_X = new FloatProperty10("rotationX") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setRotationX(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getRotationX(); - } - }; - - Property ROTATION_Y = new FloatProperty10("rotationY") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setRotationY(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getRotationY(); - } - }; - - Property SCALE_X = new FloatProperty10("scaleX") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setScaleX(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getScaleX(); - } - }; - - Property SCALE_Y = new FloatProperty10("scaleY") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setScaleY(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getScaleY(); - } - }; - - Property SCROLL_X = new IntProperty("scrollX") { - @Override - public void setValue(View object, int value) { - View10.wrap(object).setScrollX(value); - } - - @Override - public Integer get(View object) { - return View10.wrap(object).getScrollX(); - } - }; - - Property SCROLL_Y = new IntProperty("scrollY") { - @Override - public void setValue(View object, int value) { - View10.wrap(object).setScrollY(value); - } - - @Override - public Integer get(View object) { - return View10.wrap(object).getScrollY(); - } - }; - - Property X = new FloatProperty10("x") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setX(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getX(); - } - }; - - Property Y = new FloatProperty10("y") { - @Override - public void setValue(View object, float value) { - View10.wrap(object).setY(value); - } - - @Override - public Float get(View object) { - return View10.wrap(object).getY(); - } - }; - - PROXY_PROPERTIES.put("alpha", ALPHA); - PROXY_PROPERTIES.put("pivotX", PIVOT_X); - PROXY_PROPERTIES.put("pivotY", PIVOT_Y); - PROXY_PROPERTIES.put("translationX", TRANSLATION_X); - PROXY_PROPERTIES.put("translationY", TRANSLATION_Y); - PROXY_PROPERTIES.put("rotation", ROTATION); - PROXY_PROPERTIES.put("rotationX", ROTATION_X); - PROXY_PROPERTIES.put("rotationY", ROTATION_Y); - PROXY_PROPERTIES.put("scaleX", SCALE_X); - PROXY_PROPERTIES.put("scaleY", SCALE_Y); - PROXY_PROPERTIES.put("scrollX", SCROLL_X); - PROXY_PROPERTIES.put("scrollY", SCROLL_Y); - PROXY_PROPERTIES.put("x", X); - PROXY_PROPERTIES.put("y", Y); - } - - private Object mTarget; - private String mPropertyName; - private Property mProperty; - private boolean mAutoCancel = false; - - public void setPropertyName(String propertyName) { - if (mValues != null) { - PropertyValuesHolder valuesHolder = mValues[0]; - String oldName = valuesHolder.getPropertyName(); - valuesHolder.setPropertyName(propertyName); - mValuesMap.remove(oldName); - mValuesMap.put(propertyName, valuesHolder); - } - mPropertyName = propertyName; - mInitialized = false; - } - - public void setProperty(Property property) { - if (mValues != null) { - PropertyValuesHolder valuesHolder = mValues[0]; - String oldName = valuesHolder.getPropertyName(); - valuesHolder.setProperty(property); - mValuesMap.remove(oldName); - mValuesMap.put(mPropertyName, valuesHolder); - } - if (mProperty != null) { - mPropertyName = property.getName(); - } - mProperty = property; - mInitialized = false; - } - - public String getPropertyName() { - String propertyName = null; - if (mPropertyName != null) { - propertyName = mPropertyName; - } else if (mProperty != null) { - propertyName = mProperty.getName(); - } else if (mValues != null && mValues.length > 0) { - for (int i = 0; i < mValues.length; ++i) { - if (i == 0) { - propertyName = ""; - } else { - propertyName += ","; - } - propertyName += mValues[i].getPropertyName(); - } - } - return propertyName; - } - - public ObjectAnimator10() { - - } - - private ObjectAnimator10(Object target, String propertyName) { - mTarget = target; - setPropertyName(propertyName); - } - - private ObjectAnimator10(T target, Property property) { - mTarget = target; - setProperty(property); - } - - public static ObjectAnimator10 ofInt(Object target, String propertyName, int... values) { - ObjectAnimator10 anim = new ObjectAnimator10(target, propertyName); - anim.setIntValues(values); - return anim; - } - - public static ObjectAnimator10 ofInt(T target, Property property, int... values) { - ObjectAnimator10 anim = new ObjectAnimator10(target, property); - anim.setIntValues(values); - return anim; - } - - public static ObjectAnimator10 ofFloat(Object target, String propertyName, float... values) { - ObjectAnimator10 anim = new ObjectAnimator10(target, propertyName); - anim.setFloatValues(values); - return anim; - } - - public static ObjectAnimator10 ofFloat(T target, Property property, float... values) { - ObjectAnimator10 anim = new ObjectAnimator10(target, property); - anim.setFloatValues(values); - return anim; - } - - public static ObjectAnimator10 ofObject(Object target, String propertyName, TypeEvaluator evaluator, Object... values) { - ObjectAnimator10 anim = new ObjectAnimator10(target, propertyName); - anim.setObjectValues(values); - anim.setEvaluator(evaluator); - return anim; - } - - public static ObjectAnimator10 ofObject(T target, Property property, TypeEvaluator evaluator, V... values) { - ObjectAnimator10 anim = new ObjectAnimator10(target, property); - anim.setObjectValues(values); - anim.setEvaluator(evaluator); - return anim; - } - - public static ObjectAnimator10 ofPropertyValuesHolder(Object target, PropertyValuesHolder... values) { - ObjectAnimator10 anim = new ObjectAnimator10(); - anim.mTarget = target; - anim.setValues(values); - return anim; - } - - @SuppressWarnings("unchecked") - @Override - public void setIntValues(int... values) { - if (mValues == null || mValues.length == 0) { - if (mProperty != null) { - setValues(PropertyValuesHolder.ofInt(mProperty, values)); - } else { - setValues(PropertyValuesHolder.ofInt(mPropertyName, values)); - } - } else { - super.setIntValues(values); - } - } - - @SuppressWarnings("unchecked") - @Override - public void setFloatValues(float... values) { - if (mValues == null || mValues.length == 0) { - if (mProperty != null) { - setValues(PropertyValuesHolder.ofFloat(mProperty, values)); - } else { - setValues(PropertyValuesHolder.ofFloat(mPropertyName, values)); - } - } else { - super.setFloatValues(values); - } - } - - @Override - public void setObjectValues(Object... values) { - if (mValues == null || mValues.length == 0) { - if (mProperty != null) { - setValues(PropertyValuesHolder.ofObject(mProperty, null, values)); - } else { - setValues(PropertyValuesHolder.ofObject(mPropertyName, null, values)); - } - } else { - super.setObjectValues(values); - } - } - - public void setAutoCancel(boolean cancel) { - mAutoCancel = cancel; - } - - private boolean hasSameTargetAndProperties(Animator10 anim) { - if (anim instanceof ObjectAnimator10) { - PropertyValuesHolder[] theirValues = ((ObjectAnimator10) anim).getValues(); - if (((ObjectAnimator10) anim).getTarget() == mTarget && - mValues.length == theirValues.length) { - for (int i = 0; i < mValues.length; ++i) { - PropertyValuesHolder pvhMine = mValues[i]; - PropertyValuesHolder pvhTheirs = theirValues[i]; - if (pvhMine.getPropertyName() == null || - !pvhMine.getPropertyName().equals(pvhTheirs.getPropertyName())) { - return false; - } - } - return true; - } - } - return false; - } - - @Override - public void start() { - AnimationHandler handler = sAnimationHandler.get(); - if (handler != null) { - int numAnims = handler.mAnimations.size(); - for (int i = numAnims - 1; i >= 0; i--) { - if (handler.mAnimations.get(i) instanceof ObjectAnimator10) { - ObjectAnimator10 anim = (ObjectAnimator10) handler.mAnimations.get(i); - if (anim.mAutoCancel && hasSameTargetAndProperties(anim)) { - anim.cancel(); - } - } - } - numAnims = handler.mPendingAnimations.size(); - for (int i = numAnims - 1; i >= 0; i--) { - if (handler.mPendingAnimations.get(i) instanceof ObjectAnimator10) { - ObjectAnimator10 anim = (ObjectAnimator10) handler.mPendingAnimations.get(i); - if (anim.mAutoCancel && hasSameTargetAndProperties(anim)) { - anim.cancel(); - } - } - } - numAnims = handler.mDelayedAnims.size(); - for (int i = numAnims - 1; i >= 0; i--) { - if (handler.mDelayedAnims.get(i) instanceof ObjectAnimator10) { - ObjectAnimator10 anim = (ObjectAnimator10) handler.mDelayedAnims.get(i); - if (anim.mAutoCancel && hasSameTargetAndProperties(anim)) { - anim.cancel(); - } - } - } - } - super.start(); - } - - @Override - void initAnimation() { - if (!mInitialized) { - if ((mProperty == null) && (mTarget instanceof View) && PROXY_PROPERTIES.containsKey(mPropertyName)) { - setProperty(PROXY_PROPERTIES.get(mPropertyName)); - } - int numValues = mValues.length; - for (PropertyValuesHolder mValue : mValues) { - mValue.setupSetterAndGetter(mTarget); - } - super.initAnimation(); - } - } - - @Override - public ObjectAnimator10 setDuration(long duration) { - super.setDuration(duration); - return this; - } - - public Object getTarget() { - return mTarget; - } - - @Override - public void setTarget(Object target) { - if (mTarget != target) { - final Object oldTarget = mTarget; - mTarget = target; - if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) { - return; - } - mInitialized = false; - } - } - - @Override - public void setupStartValues() { - initAnimation(); - int numValues = mValues.length; - for (PropertyValuesHolder mValue : mValues) { - mValue.setupStartValue(mTarget); - } - } - - @Override - public void setupEndValues() { - initAnimation(); - int numValues = mValues.length; - for (PropertyValuesHolder mValue : mValues) { - mValue.setupEndValue(mTarget); - } - } - - @Override - void animateValue(float fraction) { - super.animateValue(fraction); - int numValues = mValues.length; - for (PropertyValuesHolder mValue : mValues) { - mValue.setAnimatedValue(mTarget); - } - } - - @Override - public ObjectAnimator10 clone() { - return (ObjectAnimator10) super.clone(); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java deleted file mode 100755 index 96beb210..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.telegram.ui.Animation; - -public abstract class Property { - - private final String mName; - private final Class mType; - - public static Property of(Class hostType, Class valueType, String name) { - return new ReflectiveProperty(hostType, valueType, name); - } - - public Property(Class type, String name) { - mName = name; - mType = type; - } - - public boolean isReadOnly() { - return false; - } - - public void set(T object, V value) { - throw new UnsupportedOperationException("Property " + getName() +" is read-only"); - } - - public abstract V get(T object); - - public String getName() { - return mName; - } - - public Class getType() { - return mType; - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java deleted file mode 100644 index 0420fb7b..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java +++ /dev/null @@ -1,546 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -public class PropertyValuesHolder implements Cloneable { - - String mPropertyName; - protected Property mProperty; - Method mSetter = null; - private Method mGetter = null; - Class mValueType; - KeyframeSet mKeyframeSet = null; - - private static final TypeEvaluator sIntEvaluator = new IntEvaluator(); - private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator(); - - private static Class[] FLOAT_VARIANTS = {float.class, Float.class, double.class, int.class, Double.class, Integer.class}; - private static Class[] INTEGER_VARIANTS = {int.class, Integer.class, float.class, double.class, Float.class, Double.class}; - private static Class[] DOUBLE_VARIANTS = {double.class, Double.class, float.class, int.class, Float.class, Integer.class}; - - private static final HashMap> sSetterPropertyMap = new HashMap>(); - private static final HashMap> sGetterPropertyMap = new HashMap>(); - - final ReentrantReadWriteLock mPropertyMapLock = new ReentrantReadWriteLock(); - final Object[] mTmpValueArray = new Object[1]; - - private TypeEvaluator mEvaluator; - - private Object mAnimatedValue; - - private PropertyValuesHolder(String propertyName) { - mPropertyName = propertyName; - } - - private PropertyValuesHolder(Property property) { - mProperty = property; - if (property != null) { - mPropertyName = property.getName(); - } - } - - public static PropertyValuesHolder ofInt(String propertyName, int... values) { - return new IntPropertyValuesHolder(propertyName, values); - } - - public static PropertyValuesHolder ofInt(Property property, int... values) { - return new IntPropertyValuesHolder(property, values); - } - - public static PropertyValuesHolder ofFloat(String propertyName, float... values) { - return new FloatPropertyValuesHolder(propertyName, values); - } - - public static PropertyValuesHolder ofFloat(Property property, float... values) { - return new FloatPropertyValuesHolder(property, values); - } - - public static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator, - Object... values) { - PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); - pvh.setObjectValues(values); - pvh.setEvaluator(evaluator); - return pvh; - } - - public static PropertyValuesHolder ofObject(Property property, - TypeEvaluator evaluator, V... values) { - PropertyValuesHolder pvh = new PropertyValuesHolder(property); - pvh.setObjectValues(values); - pvh.setEvaluator(evaluator); - return pvh; - } - - public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) { - KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); - if (keyframeSet instanceof IntKeyframeSet) { - return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet); - } else if (keyframeSet instanceof FloatKeyframeSet) { - return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet); - } else { - PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName); - pvh.mKeyframeSet = keyframeSet; - pvh.mValueType = values[0].getType(); - return pvh; - } - } - - public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) { - KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values); - if (keyframeSet instanceof IntKeyframeSet) { - return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet); - } else if (keyframeSet instanceof FloatKeyframeSet) { - return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet); - } else { - PropertyValuesHolder pvh = new PropertyValuesHolder(property); - pvh.mKeyframeSet = keyframeSet; - pvh.mValueType = values[0].getType(); - return pvh; - } - } - - public void setIntValues(int... values) { - mValueType = int.class; - mKeyframeSet = KeyframeSet.ofInt(values); - } - - public void setFloatValues(float... values) { - mValueType = float.class; - mKeyframeSet = KeyframeSet.ofFloat(values); - } - - public void setKeyframes(Keyframe... values) { - int numKeyframes = values.length; - Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes, 2)]; - mValueType = values[0].getType(); - System.arraycopy(values, 0, keyframes, 0, numKeyframes); - mKeyframeSet = new KeyframeSet(keyframes); - } - - public void setObjectValues(Object... values) { - mValueType = values[0].getClass(); - mKeyframeSet = KeyframeSet.ofObject(values); - } - - @SuppressWarnings("unchecked") - private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) { - Method returnVal = null; - String methodName = getMethodName(prefix, mPropertyName); - Class args[] = null; - if (valueType == null) { - try { - returnVal = targetClass.getMethod(methodName); - } catch (Throwable e) { - try { - returnVal = targetClass.getDeclaredMethod(methodName); - returnVal.setAccessible(true); - } catch (Throwable e2) { - e2.printStackTrace(); - } - } - } else { - args = new Class[1]; - Class typeVariants[]; - if (mValueType.equals(Float.class)) { - typeVariants = FLOAT_VARIANTS; - } else if (mValueType.equals(Integer.class)) { - typeVariants = INTEGER_VARIANTS; - } else if (mValueType.equals(Double.class)) { - typeVariants = DOUBLE_VARIANTS; - } else { - typeVariants = new Class[1]; - typeVariants[0] = mValueType; - } - for (Class typeVariant : typeVariants) { - args[0] = typeVariant; - try { - returnVal = targetClass.getMethod(methodName, args); - mValueType = typeVariant; - return returnVal; - } catch (Throwable e) { - try { - returnVal = targetClass.getDeclaredMethod(methodName, args); - returnVal.setAccessible(true); - mValueType = typeVariant; - return returnVal; - } catch (Throwable e2) { - // Swallow the error and keep trying other variants - } - } - } - } - - return returnVal; - } - - private Method setupSetterOrGetter(Class targetClass, HashMap> propertyMapMap, String prefix, Class valueType) { - Method setterOrGetter = null; - try { - mPropertyMapLock.writeLock().lock(); - HashMap propertyMap = propertyMapMap.get(targetClass); - if (propertyMap != null) { - setterOrGetter = propertyMap.get(mPropertyName); - } - if (setterOrGetter == null) { - setterOrGetter = getPropertyFunction(targetClass, prefix, valueType); - if (propertyMap == null) { - propertyMap = new HashMap(); - propertyMapMap.put(targetClass, propertyMap); - } - propertyMap.put(mPropertyName, setterOrGetter); - } - } finally { - mPropertyMapLock.writeLock().unlock(); - } - return setterOrGetter; - } - - void setupSetter(Class targetClass) { - mSetter = setupSetterOrGetter(targetClass, sSetterPropertyMap, "set", mValueType); - } - - private void setupGetter(Class targetClass) { - mGetter = setupSetterOrGetter(targetClass, sGetterPropertyMap, "get", null); - } - - @SuppressWarnings("unchecked") - void setupSetterAndGetter(Object target) { - if (mProperty != null) { - try { - Object testValue = mProperty.get(target); - for (Keyframe kf : mKeyframeSet.mKeyframes) { - if (!kf.hasValue()) { - kf.setValue(mProperty.get(target)); - } - } - return; - } catch (Throwable e) { - mProperty = null; - } - } - Class targetClass = target.getClass(); - if (mSetter == null) { - setupSetter(targetClass); - } - for (Keyframe kf : mKeyframeSet.mKeyframes) { - if (!kf.hasValue()) { - if (mGetter == null) { - setupGetter(targetClass); - if (mGetter == null) { - return; - } - } - try { - kf.setValue(mGetter.invoke(target)); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - } - - @SuppressWarnings("unchecked") - private void setupValue(Object target, Keyframe kf) { - if (mProperty != null) { - kf.setValue(mProperty.get(target)); - } - try { - if (mGetter == null) { - Class targetClass = target.getClass(); - setupGetter(targetClass); - if (mGetter == null) { - return; - } - } - kf.setValue(mGetter.invoke(target)); - } catch (Throwable e) { - e.printStackTrace(); - } - } - - void setupStartValue(Object target) { - setupValue(target, mKeyframeSet.mKeyframes.get(0)); - } - - void setupEndValue(Object target) { - setupValue(target, mKeyframeSet.mKeyframes.get(mKeyframeSet.mKeyframes.size() - 1)); - } - - @Override - public PropertyValuesHolder clone() { - try { - PropertyValuesHolder newPVH = (PropertyValuesHolder) super.clone(); - newPVH.mPropertyName = mPropertyName; - newPVH.mProperty = mProperty; - newPVH.mKeyframeSet = mKeyframeSet.clone(); - newPVH.mEvaluator = mEvaluator; - return newPVH; - } catch (CloneNotSupportedException e) { - return null; - } - } - - @SuppressWarnings("unchecked") - void setAnimatedValue(Object target) { - if (mProperty != null) { - mProperty.set(target, getAnimatedValue()); - } - if (mSetter != null) { - try { - mTmpValueArray[0] = getAnimatedValue(); - mSetter.invoke(target, mTmpValueArray); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - - void init() { - if (mEvaluator == null) { - mEvaluator = (mValueType == Integer.class) ? sIntEvaluator : (mValueType == Float.class) ? sFloatEvaluator : null; - } - if (mEvaluator != null) { - mKeyframeSet.setEvaluator(mEvaluator); - } - } - - public void setEvaluator(TypeEvaluator evaluator) { - mEvaluator = evaluator; - mKeyframeSet.setEvaluator(evaluator); - } - - void calculateValue(float fraction) { - mAnimatedValue = mKeyframeSet.getValue(fraction); - } - - public void setPropertyName(String propertyName) { - mPropertyName = propertyName; - } - - public void setProperty(Property property) { - mProperty = property; - } - - public String getPropertyName() { - return mPropertyName; - } - - Object getAnimatedValue() { - return mAnimatedValue; - } - - @Override - public String toString() { - return mPropertyName + ": " + mKeyframeSet.toString(); - } - - static String getMethodName(String prefix, String propertyName) { - if (propertyName == null || propertyName.length() == 0) { - return prefix; - } - char firstLetter = Character.toUpperCase(propertyName.charAt(0)); - String theRest = propertyName.substring(1); - return prefix + firstLetter + theRest; - } - - static class IntPropertyValuesHolder extends PropertyValuesHolder { - private static final HashMap> sJNISetterPropertyMap = new HashMap>(); - private IntProperty mIntProperty; - - IntKeyframeSet mIntKeyframeSet; - int mIntAnimatedValue; - - public IntPropertyValuesHolder(String propertyName, IntKeyframeSet keyframeSet) { - super(propertyName); - mValueType = int.class; - mKeyframeSet = keyframeSet; - mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; - } - - public IntPropertyValuesHolder(Property property, IntKeyframeSet keyframeSet) { - super(property); - mValueType = int.class; - mKeyframeSet = keyframeSet; - mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; - if (property instanceof IntProperty) { - mIntProperty = (IntProperty) mProperty; - } - } - - public IntPropertyValuesHolder(String propertyName, int... values) { - super(propertyName); - setIntValues(values); - } - - public IntPropertyValuesHolder(Property property, int... values) { - super(property); - setIntValues(values); - if (property instanceof IntProperty) { - mIntProperty = (IntProperty) mProperty; - } - } - - @Override - public void setIntValues(int... values) { - super.setIntValues(values); - mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet; - } - - @Override - void calculateValue(float fraction) { - mIntAnimatedValue = mIntKeyframeSet.getIntValue(fraction); - } - - @Override - Object getAnimatedValue() { - return mIntAnimatedValue; - } - - @Override - public IntPropertyValuesHolder clone() { - IntPropertyValuesHolder newPVH = (IntPropertyValuesHolder) super.clone(); - newPVH.mIntKeyframeSet = (IntKeyframeSet) newPVH.mKeyframeSet; - return newPVH; - } - - @SuppressWarnings("unchecked") - @Override - void setAnimatedValue(Object target) { - if (mIntProperty != null) { - mIntProperty.setValue(target, mIntAnimatedValue); - return; - } - if (mProperty != null) { - mProperty.set(target, mIntAnimatedValue); - return; - } - if (mSetter != null) { - try { - mTmpValueArray[0] = mIntAnimatedValue; - mSetter.invoke(target, mTmpValueArray); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - - @Override - void setupSetter(Class targetClass) { - if (mProperty != null) { - return; - } - - super.setupSetter(targetClass); - } - } - - static class FloatPropertyValuesHolder extends PropertyValuesHolder { - - private static final HashMap> sJNISetterPropertyMap = new HashMap>(); - private FloatProperty10 mFloatProperty; - - FloatKeyframeSet mFloatKeyframeSet; - float mFloatAnimatedValue; - - public FloatPropertyValuesHolder(String propertyName, FloatKeyframeSet keyframeSet) { - super(propertyName); - mValueType = float.class; - mKeyframeSet = keyframeSet; - mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; - } - - public FloatPropertyValuesHolder(Property property, FloatKeyframeSet keyframeSet) { - super(property); - mValueType = float.class; - mKeyframeSet = keyframeSet; - mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; - if (property instanceof FloatProperty10) { - mFloatProperty = (FloatProperty10) mProperty; - } - } - - public FloatPropertyValuesHolder(String propertyName, float... values) { - super(propertyName); - setFloatValues(values); - } - - public FloatPropertyValuesHolder(Property property, float... values) { - super(property); - setFloatValues(values); - if (property instanceof FloatProperty10) { - mFloatProperty = (FloatProperty10) mProperty; - } - } - - @Override - public void setFloatValues(float... values) { - super.setFloatValues(values); - mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet; - } - - @Override - void calculateValue(float fraction) { - mFloatAnimatedValue = mFloatKeyframeSet.getFloatValue(fraction); - } - - @Override - Object getAnimatedValue() { - return mFloatAnimatedValue; - } - - @Override - public FloatPropertyValuesHolder clone() { - FloatPropertyValuesHolder newPVH = (FloatPropertyValuesHolder) super.clone(); - newPVH.mFloatKeyframeSet = (FloatKeyframeSet) newPVH.mKeyframeSet; - return newPVH; - } - - @SuppressWarnings("unchecked") - @Override - void setAnimatedValue(Object target) { - if (mFloatProperty != null) { - mFloatProperty.setValue(target, mFloatAnimatedValue); - return; - } - if (mProperty != null) { - mProperty.set(target, mFloatAnimatedValue); - return; - } - if (mSetter != null) { - try { - mTmpValueArray[0] = mFloatAnimatedValue; - mSetter.invoke(target, mTmpValueArray); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - - @Override - void setupSetter(Class targetClass) { - if (mProperty != null) { - return; - } - super.setupSetter(targetClass); - } - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java deleted file mode 100755 index ce487b4f..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.telegram.ui.Animation; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * Internal class to automatically generate a Property for a given class/name pair, given the - * specification of {@link Property#of(java.lang.Class, java.lang.Class, java.lang.String)} - */ -class ReflectiveProperty extends Property { - - private static final String PREFIX_GET = "get"; - private static final String PREFIX_IS = "is"; - private static final String PREFIX_SET = "set"; - private Method mSetter; - private Method mGetter; - private Field mField; - - /** - * For given property name 'name', look for getName/isName method or 'name' field. - * Also look for setName method (optional - could be readonly). Failing method getters and - * field results in throwing NoSuchPropertyException. - * - * @param propertyHolder The class on which the methods or field are found - * @param name The name of the property, where this name is capitalized and appended to - * "get" and "is to search for the appropriate methods. If the get/is methods are not found, - * the constructor will search for a field with that exact name. - */ - public ReflectiveProperty(Class propertyHolder, Class valueType, String name) { - // TODO: cache reflection info for each new class/name pair - super(valueType, name); - char firstLetter = Character.toUpperCase(name.charAt(0)); - String theRest = name.substring(1); - String capitalizedName = firstLetter + theRest; - String getterName = PREFIX_GET + capitalizedName; - try { - mGetter = propertyHolder.getMethod(getterName, (Class[]) null); - } catch (NoSuchMethodException e) { - try { - /* The native implementation uses JNI to do reflection, which allows access to private methods. - * getDeclaredMethod(..) does not find superclass methods, so it's implemented as a fallback. - */ - mGetter = propertyHolder.getDeclaredMethod(getterName, (Class[]) null); - mGetter.setAccessible(true); - } catch (NoSuchMethodException e2) { - // getName() not available - try isName() instead - getterName = PREFIX_IS + capitalizedName; - try { - mGetter = propertyHolder.getMethod(getterName, (Class[]) null); - } catch (NoSuchMethodException e3) { - try { - /* The native implementation uses JNI to do reflection, which allows access to private methods. - * getDeclaredMethod(..) does not find superclass methods, so it's implemented as a fallback. - */ - mGetter = propertyHolder.getDeclaredMethod(getterName, (Class[]) null); - mGetter.setAccessible(true); - } catch (NoSuchMethodException e4) { - // Try public field instead - try { - mField = propertyHolder.getField(name); - Class fieldType = mField.getType(); - if (!typesMatch(valueType, fieldType)) { - throw new NoSuchPropertyException("Underlying type (" + fieldType + ") " + - "does not match Property type (" + valueType + ")"); - } - return; - } catch (NoSuchFieldException e5) { - // no way to access property - throw appropriate exception - throw new NoSuchPropertyException("No accessor method or field found for" - + " property with name " + name); - } - } - } - } - } - Class getterType = mGetter.getReturnType(); - // Check to make sure our getter type matches our valueType - if (!typesMatch(valueType, getterType)) { - throw new NoSuchPropertyException("Underlying type (" + getterType + ") " + - "does not match Property type (" + valueType + ")"); - } - String setterName = PREFIX_SET + capitalizedName; - try { - // mSetter = propertyHolder.getMethod(setterName, getterType); - // The native implementation uses JNI to do reflection, which allows access to private methods. - mSetter = propertyHolder.getDeclaredMethod(setterName, getterType); - mSetter.setAccessible(true); - } catch (NoSuchMethodException ignored) { - // Okay to not have a setter - just a readonly property - } - } - - /** - * Utility method to check whether the type of the underlying field/method on the target - * object matches the type of the Property. The extra checks for primitive types are because - * generics will force the Property type to be a class, whereas the type of the underlying - * method/field will probably be a primitive type instead. Accept float as matching Float, - * etc. - */ - private boolean typesMatch(Class valueType, Class getterType) { - if (getterType != valueType) { - if (getterType.isPrimitive()) { - return (getterType == float.class && valueType == Float.class) || - (getterType == int.class && valueType == Integer.class) || - (getterType == boolean.class && valueType == Boolean.class) || - (getterType == long.class && valueType == Long.class) || - (getterType == double.class && valueType == Double.class) || - (getterType == short.class && valueType == Short.class) || - (getterType == byte.class && valueType == Byte.class) || - (getterType == char.class && valueType == Character.class); - } - return false; - } - return true; - } - - @Override - public void set(T object, V value) { - if (mSetter != null) { - try { - mSetter.invoke(object, value); - } catch (IllegalAccessException e) { - throw new AssertionError(); - } catch (InvocationTargetException e) { - throw new RuntimeException(e.getCause()); - } - } else if (mField != null) { - try { - mField.set(object, value); - } catch (IllegalAccessException e) { - throw new AssertionError(); - } - } else { - throw new UnsupportedOperationException("Property " + getName() +" is read-only"); - } - } - - @Override - public V get(T object) { - if (mGetter != null) { - try { - return (V) mGetter.invoke(object, (Object[])null); - } catch (IllegalAccessException e) { - throw new AssertionError(); - } catch (InvocationTargetException e) { - throw new RuntimeException(e.getCause()); - } - } else if (mField != null) { - try { - return (V) mField.get(object); - } catch (IllegalAccessException e) { - throw new AssertionError(); - } - } - // Should not get here: there should always be a non-null getter or field - throw new AssertionError(); - } - - /** - * Returns false if there is no setter or public field underlying this Property. - */ - @Override - public boolean isReadOnly() { - return (mSetter == null && mField == null); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/TypeEvaluator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/TypeEvaluator.java deleted file mode 100644 index db5769e0..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/TypeEvaluator.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -public interface TypeEvaluator { - T evaluate(float fraction, T startValue, T endValue); -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ValueAnimator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ValueAnimator.java deleted file mode 100644 index 168ff1da..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ValueAnimator.java +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.os.Looper; -import android.util.AndroidRuntimeException; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.view.animation.AnimationUtils; -import android.view.animation.Interpolator; -import android.view.animation.LinearInterpolator; - -import org.telegram.android.AndroidUtilities; - -import java.util.ArrayList; -import java.util.HashMap; - -public class ValueAnimator extends Animator10 { - - private static float sDurationScale = 1.0f; - static final int STOPPED = 0; - static final int RUNNING = 1; - static final int SEEKED = 2; - - long mStartTime; - long mSeekTime = -1; - private long mPauseTime; - private boolean mResumed = false; - protected static ThreadLocal sAnimationHandler = new ThreadLocal(); - private static final Interpolator sDefaultInterpolator = new AccelerateDecelerateInterpolator(); - private boolean mPlayingBackwards = false; - private int mCurrentIteration = 0; - private float mCurrentFraction = 0f; - private boolean mStartedDelay = false; - private long mDelayStartTime; - int mPlayingState = STOPPED; - private boolean mRunning = false; - private boolean mStarted = false; - private boolean mStartListenersCalled = false; - boolean mInitialized = false; - - private long mDuration = (long)(300 * sDurationScale); - private long mUnscaledDuration = 300; - private long mStartDelay = 0; - private long mUnscaledStartDelay = 0; - private int mRepeatCount = 0; - private int mRepeatMode = RESTART; - private Interpolator mInterpolator = sDefaultInterpolator; - private ArrayList mUpdateListeners = null; - PropertyValuesHolder[] mValues; - HashMap mValuesMap; - - public static final int RESTART = 1; - public static final int REVERSE = 2; - public static final int INFINITE = -1; - - public static void setDurationScale(float durationScale) { - sDurationScale = durationScale; - } - - public static float getDurationScale() { - return sDurationScale; - } - - public ValueAnimator() { - - } - - public static ValueAnimator ofInt(int... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setIntValues(values); - return anim; - } - - public static ValueAnimator ofFloat(float... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setFloatValues(values); - return anim; - } - - public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setValues(values); - return anim; - } - - public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) { - ValueAnimator anim = new ValueAnimator(); - anim.setObjectValues(values); - anim.setEvaluator(evaluator); - return anim; - } - - public void setIntValues(int... values) { - if (values == null || values.length == 0) { - return; - } - if (mValues == null || mValues.length == 0) { - setValues(PropertyValuesHolder.ofInt("", values)); - } else { - PropertyValuesHolder valuesHolder = mValues[0]; - valuesHolder.setIntValues(values); - } - mInitialized = false; - } - - public void setFloatValues(float... values) { - if (values == null || values.length == 0) { - return; - } - if (mValues == null || mValues.length == 0) { - setValues(PropertyValuesHolder.ofFloat("", values)); - } else { - PropertyValuesHolder valuesHolder = mValues[0]; - valuesHolder.setFloatValues(values); - } - mInitialized = false; - } - - public void setObjectValues(Object... values) { - if (values == null || values.length == 0) { - return; - } - if (mValues == null || mValues.length == 0) { - setValues(PropertyValuesHolder.ofObject("", null, values)); - } else { - PropertyValuesHolder valuesHolder = mValues[0]; - valuesHolder.setObjectValues(values); - } - mInitialized = false; - } - - public void setValues(PropertyValuesHolder... values) { - int numValues = values.length; - mValues = values; - mValuesMap = new HashMap(numValues); - for (PropertyValuesHolder valuesHolder : values) { - mValuesMap.put(valuesHolder.getPropertyName(), valuesHolder); - } - mInitialized = false; - } - - public PropertyValuesHolder[] getValues() { - return mValues; - } - - void initAnimation() { - if (!mInitialized) { - int numValues = mValues.length; - for (PropertyValuesHolder mValue : mValues) { - mValue.init(); - } - mInitialized = true; - } - } - - public ValueAnimator setDuration(long duration) { - if (duration < 0) { - throw new IllegalArgumentException("Animators cannot have negative duration: " + duration); - } - mUnscaledDuration = duration; - mDuration = (long)(duration * sDurationScale); - return this; - } - - public long getDuration() { - return mUnscaledDuration; - } - - public void setCurrentPlayTime(long playTime) { - initAnimation(); - long currentTime = AnimationUtils.currentAnimationTimeMillis(); - if (mPlayingState != RUNNING) { - mSeekTime = playTime; - mPlayingState = SEEKED; - } - mStartTime = currentTime - playTime; - doAnimationFrame(currentTime); - } - - public long getCurrentPlayTime() { - if (!mInitialized || mPlayingState == STOPPED) { - return 0; - } - return AnimationUtils.currentAnimationTimeMillis() - mStartTime; - } - - @SuppressWarnings("unchecked") - protected static class AnimationHandler implements Runnable { - - protected final ArrayList mAnimations = new ArrayList(); - private final ArrayList mTmpAnimations = new ArrayList(); - protected final ArrayList mPendingAnimations = new ArrayList(); - protected final ArrayList mDelayedAnims = new ArrayList(); - private final ArrayList mEndingAnims = new ArrayList(); - private final ArrayList mReadyAnims = new ArrayList(); - - private boolean mAnimationScheduled; - - public void start() { - scheduleAnimation(); - } - - private void doAnimationFrame(long frameTime) { - while (mPendingAnimations.size() > 0) { - ArrayList pendingCopy = (ArrayList) mPendingAnimations.clone(); - mPendingAnimations.clear(); - int count = pendingCopy.size(); - for (ValueAnimator anim : pendingCopy) { - if (anim.mStartDelay == 0) { - anim.startAnimation(this); - } else { - mDelayedAnims.add(anim); - } - } - } - - int numDelayedAnims = mDelayedAnims.size(); - for (ValueAnimator anim : mDelayedAnims) { - if (anim.delayedAnimationFrame(frameTime)) { - mReadyAnims.add(anim); - } - } - int numReadyAnims = mReadyAnims.size(); - if (numReadyAnims > 0) { - for (ValueAnimator anim : mReadyAnims) { - anim.startAnimation(this); - anim.mRunning = true; - mDelayedAnims.remove(anim); - } - mReadyAnims.clear(); - } - - int numAnims = mAnimations.size(); - for (ValueAnimator mAnimation : mAnimations) { - mTmpAnimations.add(mAnimation); - } - for (int i = 0; i < numAnims; ++i) { - ValueAnimator anim = mTmpAnimations.get(i); - if (mAnimations.contains(anim) && anim.doAnimationFrame(frameTime)) { - mEndingAnims.add(anim); - } - } - mTmpAnimations.clear(); - if (mEndingAnims.size() > 0) { - for (ValueAnimator mEndingAnim : mEndingAnims) { - mEndingAnim.endAnimation(this); - } - mEndingAnims.clear(); - } - - if (!mAnimations.isEmpty() || !mDelayedAnims.isEmpty()) { - scheduleAnimation(); - } - } - - @Override - public void run() { - mAnimationScheduled = false; - doAnimationFrame(System.nanoTime() / 1000000); - } - - private void scheduleAnimation() { - if (!mAnimationScheduled) { - AndroidUtilities.runOnUIThread(this); - mAnimationScheduled = true; - } - } - } - - public long getStartDelay() { - return mUnscaledStartDelay; - } - - public void setStartDelay(long startDelay) { - this.mStartDelay = (long)(startDelay * sDurationScale); - mUnscaledStartDelay = startDelay; - } - - public Object getAnimatedValue() { - if (mValues != null && mValues.length > 0) { - return mValues[0].getAnimatedValue(); - } - return null; - } - - public Object getAnimatedValue(String propertyName) { - PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName); - if (valuesHolder != null) { - return valuesHolder.getAnimatedValue(); - } else { - return null; - } - } - - public void setRepeatCount(int value) { - mRepeatCount = value; - } - - public int getRepeatCount() { - return mRepeatCount; - } - - public void setRepeatMode(int value) { - mRepeatMode = value; - } - - public int getRepeatMode() { - return mRepeatMode; - } - - public void addUpdateListener(AnimatorUpdateListener listener) { - if (mUpdateListeners == null) { - mUpdateListeners = new ArrayList(); - } - mUpdateListeners.add(listener); - } - - public void removeAllUpdateListeners() { - if (mUpdateListeners == null) { - return; - } - mUpdateListeners.clear(); - mUpdateListeners = null; - } - - public void removeUpdateListener(AnimatorUpdateListener listener) { - if (mUpdateListeners == null) { - return; - } - mUpdateListeners.remove(listener); - if (mUpdateListeners.size() == 0) { - mUpdateListeners = null; - } - } - - @Override - public void setInterpolator(Interpolator value) { - if (value != null) { - mInterpolator = value; - } else { - mInterpolator = new LinearInterpolator(); - } - } - - @Override - public Interpolator getInterpolator() { - return mInterpolator; - } - - public void setEvaluator(TypeEvaluator value) { - if (value != null && mValues != null && mValues.length > 0) { - mValues[0].setEvaluator(value); - } - } - - @SuppressWarnings("unchecked") - private void notifyStartListeners() { - if (mListeners != null && !mStartListenersCalled) { - ArrayList tmpListeners = (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (AnimatorListener tmpListener : tmpListeners) { - tmpListener.onAnimationStart(this); - } - } - mStartListenersCalled = true; - } - - private void start(boolean playBackwards) { - if (Looper.myLooper() == null) { - throw new AndroidRuntimeException("Animators may only be run on Looper threads"); - } - mPlayingBackwards = playBackwards; - mCurrentIteration = 0; - mPlayingState = STOPPED; - mStarted = true; - mStartedDelay = false; - mPaused = false; - AnimationHandler animationHandler = getOrCreateAnimationHandler(); - animationHandler.mPendingAnimations.add(this); - if (mStartDelay == 0) { - setCurrentPlayTime(0); - mPlayingState = STOPPED; - mRunning = true; - notifyStartListeners(); - } - animationHandler.start(); - } - - @Override - public void start() { - start(false); - } - - @SuppressWarnings("unchecked") - @Override - public void cancel() { - AnimationHandler handler = getOrCreateAnimationHandler(); - if (mPlayingState != STOPPED || handler.mPendingAnimations.contains(this) || handler.mDelayedAnims.contains(this)) { - if ((mStarted || mRunning) && mListeners != null) { - if (!mRunning) { - notifyStartListeners(); - } - ArrayList tmpListeners = (ArrayList) mListeners.clone(); - for (AnimatorListener listener : tmpListeners) { - listener.onAnimationCancel(this); - } - } - endAnimation(handler); - } - } - - @Override - public void end() { - AnimationHandler handler = getOrCreateAnimationHandler(); - if (!handler.mAnimations.contains(this) && !handler.mPendingAnimations.contains(this)) { - mStartedDelay = false; - startAnimation(handler); - mStarted = true; - } else if (!mInitialized) { - initAnimation(); - } - animateValue(mPlayingBackwards ? 0f : 1f); - endAnimation(handler); - } - - @Override - public void resume() { - if (mPaused) { - mResumed = true; - } - super.resume(); - } - - @Override - public void pause() { - boolean previouslyPaused = mPaused; - super.pause(); - if (!previouslyPaused && mPaused) { - mPauseTime = -1; - mResumed = false; - } - } - - @Override - public boolean isRunning() { - return (mPlayingState == RUNNING || mRunning); - } - - @Override - public boolean isStarted() { - return mStarted; - } - - public void reverse() { - mPlayingBackwards = !mPlayingBackwards; - if (mPlayingState == RUNNING) { - long currentTime = AnimationUtils.currentAnimationTimeMillis(); - long currentPlayTime = currentTime - mStartTime; - long timeLeft = mDuration - currentPlayTime; - mStartTime = currentTime - timeLeft; - } else if (mStarted) { - end(); - } else { - start(true); - } - } - - @SuppressWarnings("unchecked") - private void endAnimation(AnimationHandler handler) { - handler.mAnimations.remove(this); - handler.mPendingAnimations.remove(this); - handler.mDelayedAnims.remove(this); - mPlayingState = STOPPED; - mPaused = false; - if ((mStarted || mRunning) && mListeners != null) { - if (!mRunning) { - notifyStartListeners(); - } - ArrayList tmpListeners = (ArrayList) mListeners.clone(); - int numListeners = tmpListeners.size(); - for (AnimatorListener tmpListener : tmpListeners) { - tmpListener.onAnimationEnd(this); - } - } - mRunning = false; - mStarted = false; - mStartListenersCalled = false; - mPlayingBackwards = false; - } - - private void startAnimation(AnimationHandler handler) { - initAnimation(); - handler.mAnimations.add(this); - if (mStartDelay > 0 && mListeners != null) { - notifyStartListeners(); - } - } - - private boolean delayedAnimationFrame(long currentTime) { - if (!mStartedDelay) { - mStartedDelay = true; - mDelayStartTime = currentTime; - } else { - if (mPaused) { - if (mPauseTime < 0) { - mPauseTime = currentTime; - } - return false; - } else if (mResumed) { - mResumed = false; - if (mPauseTime > 0) { - mDelayStartTime += (currentTime - mPauseTime); - } - } - long deltaTime = currentTime - mDelayStartTime; - if (deltaTime > mStartDelay) { - mStartTime = currentTime - (deltaTime - mStartDelay); - mPlayingState = RUNNING; - return true; - } - } - return false; - } - - boolean animationFrame(long currentTime) { - boolean done = false; - switch (mPlayingState) { - case RUNNING: - case SEEKED: - float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f; - if (fraction >= 1f) { - if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) { - if (mListeners != null) { - int numListeners = mListeners.size(); - for (AnimatorListener mListener : mListeners) { - mListener.onAnimationRepeat(this); - } - } - if (mRepeatMode == REVERSE) { - mPlayingBackwards = !mPlayingBackwards; - } - mCurrentIteration += (int)fraction; - fraction = fraction % 1f; - mStartTime += mDuration; - } else { - done = true; - fraction = Math.min(fraction, 1.0f); - } - } - if (mPlayingBackwards) { - fraction = 1f - fraction; - } - animateValue(fraction); - break; - } - - return done; - } - - final boolean doAnimationFrame(long frameTime) { - if (mPlayingState == STOPPED) { - mPlayingState = RUNNING; - if (mSeekTime < 0) { - mStartTime = frameTime; - } else { - mStartTime = frameTime - mSeekTime; - mSeekTime = -1; - } - } - if (mPaused) { - if (mPauseTime < 0) { - mPauseTime = frameTime; - } - return false; - } else if (mResumed) { - mResumed = false; - if (mPauseTime > 0) { - mStartTime += (frameTime - mPauseTime); - } - } - final long currentTime = Math.max(frameTime, mStartTime); - return animationFrame(currentTime); - } - - public float getAnimatedFraction() { - return mCurrentFraction; - } - - void animateValue(float fraction) { - fraction = mInterpolator.getInterpolation(fraction); - mCurrentFraction = fraction; - int numValues = mValues.length; - for (PropertyValuesHolder mValue : mValues) { - mValue.calculateValue(fraction); - } - if (mUpdateListeners != null) { - int numListeners = mUpdateListeners.size(); - for (AnimatorUpdateListener mUpdateListener : mUpdateListeners) { - mUpdateListener.onAnimationUpdate(this); - } - } - } - - @Override - public ValueAnimator clone() { - final ValueAnimator anim = (ValueAnimator) super.clone(); - if (mUpdateListeners != null) { - ArrayList oldListeners = mUpdateListeners; - anim.mUpdateListeners = new ArrayList(); - int numListeners = oldListeners.size(); - for (AnimatorUpdateListener oldListener : oldListeners) { - anim.mUpdateListeners.add(oldListener); - } - } - anim.mSeekTime = -1; - anim.mPlayingBackwards = false; - anim.mCurrentIteration = 0; - anim.mInitialized = false; - anim.mPlayingState = STOPPED; - anim.mStartedDelay = false; - PropertyValuesHolder[] oldValues = mValues; - if (oldValues != null) { - int numValues = oldValues.length; - anim.mValues = new PropertyValuesHolder[numValues]; - anim.mValuesMap = new HashMap(numValues); - for (int i = 0; i < numValues; ++i) { - PropertyValuesHolder newValuesHolder = oldValues[i].clone(); - anim.mValues[i] = newValuesHolder; - anim.mValuesMap.put(newValuesHolder.getPropertyName(), newValuesHolder); - } - } - return anim; - } - - public interface AnimatorUpdateListener { - void onAnimationUpdate(ValueAnimator animation); - } - - public static int getCurrentAnimationsCount() { - AnimationHandler handler = sAnimationHandler.get(); - return handler != null ? handler.mAnimations.size() : 0; - } - - public static void clearAllAnimations() { - AnimationHandler handler = sAnimationHandler.get(); - if (handler != null) { - handler.mAnimations.clear(); - handler.mPendingAnimations.clear(); - handler.mDelayedAnims.clear(); - } - } - - private static AnimationHandler getOrCreateAnimationHandler() { - AnimationHandler handler = sAnimationHandler.get(); - if (handler == null) { - handler = new AnimationHandler(); - sAnimationHandler.set(handler); - } - return handler; - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/View10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/View10.java deleted file mode 100644 index 4a89fe9c..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Animation/View10.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - Copyright 2012 Jake Wharton - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ - -package org.telegram.ui.Animation; - -import android.graphics.Camera; -import android.graphics.Matrix; -import android.graphics.RectF; -import android.os.Build; -import android.view.View; -import android.view.animation.Animation; -import android.view.animation.Transformation; - -import java.lang.ref.WeakReference; -import java.util.WeakHashMap; - -public class View10 extends Animation { - - public static boolean NEED_PROXY = Build.VERSION.SDK_INT < 11; - - private static final WeakHashMap PROXIES = new WeakHashMap<>(); - - public static View10 wrap(View view) { - View10 proxy = PROXIES.get(view); - Animation animation = view.getAnimation(); - if (proxy == null || proxy != animation && animation != null) { - proxy = new View10(view); - PROXIES.put(view, proxy); - } else if (animation == null) { - view.setAnimation(proxy); - } - return proxy; - } - - private final WeakReference mView; - private final Camera mCamera = new Camera(); - private boolean mHasPivot; - - private float mAlpha = 1; - private float mPivotX; - private float mPivotY; - private float mRotationX; - private float mRotationY; - private float mRotationZ; - private float mScaleX = 1; - private float mScaleY = 1; - private float mTranslationX; - private float mTranslationY; - - private final RectF mBefore = new RectF(); - private final RectF mAfter = new RectF(); - private final Matrix mTempMatrix = new Matrix(); - - private View10(View view) { - setDuration(0); - setFillAfter(true); - view.setAnimation(this); - mView = new WeakReference<>(view); - } - - public float getAlpha() { - return mAlpha; - } - - public void setAlpha(float alpha) { - if (mAlpha != alpha) { - mAlpha = alpha; - View view = mView.get(); - if (view != null) { - view.invalidate(); - } - } - } - - public float getPivotX() { - return mPivotX; - } - - public void setPivotX(float pivotX) { - if (!mHasPivot || mPivotX != pivotX) { - prepareForUpdate(); - mHasPivot = true; - mPivotX = pivotX; - invalidateAfterUpdate(); - } - } - - public float getPivotY() { - return mPivotY; - } - - public void setPivotY(float pivotY) { - if (!mHasPivot || mPivotY != pivotY) { - prepareForUpdate(); - mHasPivot = true; - mPivotY = pivotY; - invalidateAfterUpdate(); - } - } - - public float getRotation() { - return mRotationZ; - } - - public void setRotation(float rotation) { - if (mRotationZ != rotation) { - prepareForUpdate(); - mRotationZ = rotation; - invalidateAfterUpdate(); - } - } - - public float getRotationX() { - return mRotationX; - } - - public void setRotationX(float rotationX) { - if (mRotationX != rotationX) { - prepareForUpdate(); - mRotationX = rotationX; - invalidateAfterUpdate(); - } - } - - public float getRotationY() { - return mRotationY; - } - - public void setRotationY(float rotationY) { - if (mRotationY != rotationY) { - prepareForUpdate(); - mRotationY = rotationY; - invalidateAfterUpdate(); - } - } - - public float getScaleX() { - return mScaleX; - } - - public void setScaleX(float scaleX) { - if (mScaleX != scaleX) { - prepareForUpdate(); - mScaleX = scaleX; - invalidateAfterUpdate(); - } - } - - public float getScaleY() { - return mScaleY; - } - - public void setScaleY(float scaleY) { - if (mScaleY != scaleY) { - prepareForUpdate(); - mScaleY = scaleY; - invalidateAfterUpdate(); - } - } - - public int getScrollX() { - View view = mView.get(); - if (view == null) { - return 0; - } - return view.getScrollX(); - } - - public void setScrollX(int value) { - View view = mView.get(); - if (view != null) { - view.scrollTo(value, view.getScrollY()); - } - } - - public int getScrollY() { - View view = mView.get(); - if (view == null) { - return 0; - } - return view.getScrollY(); - } - - public void setScrollY(int value) { - View view = mView.get(); - if (view != null) { - view.scrollTo(view.getScrollX(), value); - } - } - - public float getTranslationX() { - return mTranslationX; - } - - public void setTranslationX(float translationX) { - if (mTranslationX != translationX) { - prepareForUpdate(); - mTranslationX = translationX; - invalidateAfterUpdate(); - } - } - - public float getTranslationY() { - return mTranslationY; - } - - public void setTranslationY(float translationY) { - if (mTranslationY != translationY) { - prepareForUpdate(); - mTranslationY = translationY; - invalidateAfterUpdate(); - } - } - - public float getX() { - View view = mView.get(); - if (view == null) { - return 0; - } - return view.getLeft() + mTranslationX; - } - - public void setX(float x) { - View view = mView.get(); - if (view != null) { - setTranslationX(x - view.getLeft()); - } - } - - public float getY() { - View view = mView.get(); - if (view == null) { - return 0; - } - return view.getTop() + mTranslationY; - } - - public void setY(float y) { - View view = mView.get(); - if (view != null) { - setTranslationY(y - view.getTop()); - } - } - - private void prepareForUpdate() { - View view = mView.get(); - if (view != null) { - computeRect(mBefore, view); - } - } - - private void invalidateAfterUpdate() { - View view = mView.get(); - if (view == null || view.getParent() == null) { - return; - } - - final RectF after = mAfter; - computeRect(after, view); - after.union(mBefore); - - ((View) view.getParent()).invalidate( - (int) Math.floor(after.left), - (int) Math.floor(after.top), - (int) Math.ceil(after.right), - (int) Math.ceil(after.bottom)); - } - - private void computeRect(final RectF r, View view) { - final float w = view.getWidth(); - final float h = view.getHeight(); - - r.set(0, 0, w, h); - - final Matrix m = mTempMatrix; - m.reset(); - transformMatrix(m, view); - mTempMatrix.mapRect(r); - - r.offset(view.getLeft(), view.getTop()); - - if (r.right < r.left) { - final float f = r.right; - r.right = r.left; - r.left = f; - } - if (r.bottom < r.top) { - final float f = r.top; - r.top = r.bottom; - r.bottom = f; - } - } - - private void transformMatrix(Matrix m, View view) { - final float w = view.getWidth(); - final float h = view.getHeight(); - final boolean hasPivot = mHasPivot; - final float pX = hasPivot ? mPivotX : w / 2f; - final float pY = hasPivot ? mPivotY : h / 2f; - - final float rX = mRotationX; - final float rY = mRotationY; - final float rZ = mRotationZ; - if ((rX != 0) || (rY != 0) || (rZ != 0)) { - final Camera camera = mCamera; - camera.save(); - camera.rotateX(rX); - camera.rotateY(rY); - camera.rotateZ(-rZ); - camera.getMatrix(m); - camera.restore(); - m.preTranslate(-pX, -pY); - m.postTranslate(pX, pY); - } - - final float sX = mScaleX; - final float sY = mScaleY; - if ((sX != 1.0f) || (sY != 1.0f)) { - m.postScale(sX, sY); - final float sPX = -(pX / w) * ((sX * w) - w); - final float sPY = -(pY / h) * ((sY * h) - h); - m.postTranslate(sPX, sPY); - } - - m.postTranslate(mTranslationX, mTranslationY); - } - - @Override - protected void applyTransformation(float interpolatedTime, Transformation t) { - View view = mView.get(); - if (view != null) { - t.setAlpha(mAlpha); - transformMatrix(t.getMatrix(), view); - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorListenerAdapterProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorListenerAdapterProxy.java deleted file mode 100644 index 2c416a11..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorListenerAdapterProxy.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.7.x. - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Nikolai Kudashov, 2013-2014. - */ - -package org.telegram.ui.AnimationCompat; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; - -import org.telegram.ui.Animation.Animator10; -import org.telegram.ui.Animation.AnimatorListenerAdapter10; -import org.telegram.ui.Animation.View10; - -public class AnimatorListenerAdapterProxy { - protected Object animatorListenerAdapter; - - public AnimatorListenerAdapterProxy() { - if (View10.NEED_PROXY) { - animatorListenerAdapter = new AnimatorListenerAdapter10() { - @Override - public void onAnimationCancel(Animator10 animation) { - AnimatorListenerAdapterProxy.this.onAnimationCancel(animation); - } - - @Override - public void onAnimationEnd(Animator10 animation) { - AnimatorListenerAdapterProxy.this.onAnimationEnd(animation); - } - - @Override - public void onAnimationRepeat(Animator10 animation) { - AnimatorListenerAdapterProxy.this.onAnimationRepeat(animation); - } - - @Override - public void onAnimationStart(Animator10 animation) { - AnimatorListenerAdapterProxy.this.onAnimationStart(animation); - } - - @Override - public void onAnimationPause(Animator10 animation) { - AnimatorListenerAdapterProxy.this.onAnimationPause(animation); - } - - @Override - public void onAnimationResume(Animator10 animation) { - AnimatorListenerAdapterProxy.this.onAnimationResume(animation); - } - }; - } else { - animatorListenerAdapter = new AnimatorListenerAdapter() { - @Override - public void onAnimationCancel(Animator animation) { - AnimatorListenerAdapterProxy.this.onAnimationCancel(animation); - } - - @Override - public void onAnimationEnd(Animator animation) { - AnimatorListenerAdapterProxy.this.onAnimationEnd(animation); - } - - @Override - public void onAnimationRepeat(Animator animation) { - AnimatorListenerAdapterProxy.this.onAnimationRepeat(animation); - } - - @Override - public void onAnimationStart(Animator animation) { - AnimatorListenerAdapterProxy.this.onAnimationStart(animation); - } - - @Override - public void onAnimationPause(Animator animation) { - AnimatorListenerAdapterProxy.this.onAnimationPause(animation); - } - - @Override - public void onAnimationResume(Animator animation) { - AnimatorListenerAdapterProxy.this.onAnimationResume(animation); - } - }; - } - } - - public void onAnimationCancel(Object animation) { - - } - - public void onAnimationEnd(Object animation) { - - } - - public void onAnimationRepeat(Object animation) { - - } - - public void onAnimationStart(Object animation) { - - } - - public void onAnimationPause(Object animation) { - - } - - public void onAnimationResume(Object animation) { - - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java deleted file mode 100644 index 50ac0c1d..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.7.x. - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Nikolai Kudashov, 2013-2014. - */ - -package org.telegram.ui.AnimationCompat; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.AnimatorSet; -import android.view.animation.Interpolator; - -import org.telegram.ui.Animation.Animator10; -import org.telegram.ui.Animation.AnimatorListenerAdapter10; -import org.telegram.ui.Animation.AnimatorSet10; -import org.telegram.ui.Animation.View10; - -import java.lang.reflect.Array; -import java.util.ArrayList; - -public class AnimatorSetProxy { - - private Object animatorSet; - - public static T[] copyOf(U[] original, int newLength, Class newType) { - return copyOfRange(original, 0, newLength, newType); - } - - @SuppressWarnings("unchecked") - public static T[] copyOfRange(U[] original, int start, int end, Class newType) { - if (start > end) { - throw new IllegalArgumentException(); - } - int originalLength = original.length; - if (start < 0 || start > originalLength) { - throw new ArrayIndexOutOfBoundsException(); - } - int resultLength = end - start; - int copyLength = Math.min(resultLength, originalLength - start); - T[] result = (T[]) Array.newInstance(newType.getComponentType(), resultLength); - System.arraycopy(original, start, result, 0, copyLength); - return result; - } - - public AnimatorSetProxy() { - if (View10.NEED_PROXY) { - animatorSet = new AnimatorSet10(); - } else { - animatorSet = new AnimatorSet(); - } - } - - @SuppressWarnings("unchecked") - public void playTogether(Object... items) { - if (View10.NEED_PROXY) { - Animator10[] animators = copyOf(items, items.length, Animator10[].class); - ((AnimatorSet10) animatorSet).playTogether(animators); - } else { - Animator[] animators = copyOf(items, items.length, Animator[].class); - ((AnimatorSet) animatorSet).playTogether(animators); - } - } - - public void playTogether(ArrayList items) { - if (View10.NEED_PROXY) { - ArrayList animators = new ArrayList(); - for (Object obj : items) { - animators.add((Animator10)obj); - } - ((AnimatorSet10) animatorSet).playTogether(animators); - } else { - ArrayList animators = new ArrayList(); - for (Object obj : items) { - animators.add((Animator)obj); - } - ((AnimatorSet) animatorSet).playTogether(animators); - } - } - - public AnimatorSetProxy setDuration(long duration) { - if (View10.NEED_PROXY) { - ((AnimatorSet10) animatorSet).setDuration(duration); - } else { - ((AnimatorSet) animatorSet).setDuration(duration); - } - return this; - } - - public void start() { - if (View10.NEED_PROXY) { - ((AnimatorSet10) animatorSet).start(); - } else { - ((AnimatorSet) animatorSet).start(); - } - } - - public void cancel() { - if (View10.NEED_PROXY) { - ((AnimatorSet10) animatorSet).cancel(); - } else { - ((AnimatorSet) animatorSet).cancel(); - } - } - - public void addListener(AnimatorListenerAdapterProxy listener) { - if (View10.NEED_PROXY) { - ((AnimatorSet10) animatorSet).addListener((AnimatorListenerAdapter10) listener.animatorListenerAdapter); - } else { - ((AnimatorSet) animatorSet).addListener((AnimatorListenerAdapter) listener.animatorListenerAdapter); - } - } - - public void setInterpolator(Interpolator interpolator) { - if (View10.NEED_PROXY) { - ((AnimatorSet10) animatorSet).setInterpolator(interpolator); - } else { - ((AnimatorSet) animatorSet).setInterpolator(interpolator); - } - } - - @Override - public boolean equals(Object o) { - return animatorSet == o; - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java deleted file mode 100644 index c9fd8cf1..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.7.x. - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Nikolai Kudashov, 2013-2014. - */ - -package org.telegram.ui.AnimationCompat; - -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.view.animation.Interpolator; - -import org.telegram.ui.Animation.AnimatorListenerAdapter10; -import org.telegram.ui.Animation.ObjectAnimator10; -import org.telegram.ui.Animation.View10; - -public class ObjectAnimatorProxy { - - private Object objectAnimator; - - public ObjectAnimatorProxy(Object animator) { - objectAnimator = animator; - } - - public static Object ofFloat(Object target, String propertyName, float... values) { - if (View10.NEED_PROXY) { - return ObjectAnimator10.ofFloat(target, propertyName, values); - } else { - return ObjectAnimator.ofFloat(target, propertyName, values); - } - } - - public static Object ofInt(Object target, String propertyName, int... values) { - if (View10.NEED_PROXY) { - return ObjectAnimator10.ofInt(target, propertyName, values); - } else { - return ObjectAnimator.ofInt(target, propertyName, values); - } - } - - public static ObjectAnimatorProxy ofFloatProxy(Object target, String propertyName, float... values) { - if (View10.NEED_PROXY) { - return new ObjectAnimatorProxy(ObjectAnimator10.ofFloat(target, propertyName, values)); - } else { - return new ObjectAnimatorProxy(ObjectAnimator.ofFloat(target, propertyName, values)); - } - } - - public static ObjectAnimatorProxy ofIntProxy(Object target, String propertyName, int... values) { - if (View10.NEED_PROXY) { - return new ObjectAnimatorProxy(ObjectAnimator10.ofInt(target, propertyName, values)); - } else { - return new ObjectAnimatorProxy(ObjectAnimator.ofInt(target, propertyName, values)); - } - } - - public ObjectAnimatorProxy setDuration(long duration) { - if (View10.NEED_PROXY) { - ((ObjectAnimator10) objectAnimator).setDuration(duration); - } else { - ((ObjectAnimator) objectAnimator).setDuration(duration); - } - return this; - } - - public void setInterpolator(Interpolator value) { - if (View10.NEED_PROXY) { - ((ObjectAnimator10) objectAnimator).setInterpolator(value); - } else { - ((ObjectAnimator) objectAnimator).setInterpolator(value); - } - } - - public void start() { - if (View10.NEED_PROXY) { - ((ObjectAnimator10) objectAnimator).start(); - } else { - ((ObjectAnimator) objectAnimator).start(); - } - } - - public void setAutoCancel(boolean cancel) { - if (View10.NEED_PROXY) { - ((ObjectAnimator10) objectAnimator).setAutoCancel(cancel); - } else { - ((ObjectAnimator) objectAnimator).setAutoCancel(cancel); - } - } - - public boolean isRunning() { - if (View10.NEED_PROXY) { - return ((ObjectAnimator10) objectAnimator).isRunning(); - } else { - return ((ObjectAnimator) objectAnimator).isRunning(); - } - } - - public void end() { - if (View10.NEED_PROXY) { - ((ObjectAnimator10) objectAnimator).end(); - } else { - ((ObjectAnimator) objectAnimator).end(); - } - } - - public void cancel() { - if (View10.NEED_PROXY) { - ((ObjectAnimator10) objectAnimator).cancel(); - } else { - ((ObjectAnimator) objectAnimator).cancel(); - } - } - - public ObjectAnimatorProxy addListener(AnimatorListenerAdapterProxy listener) { - if (View10.NEED_PROXY) { - ((ObjectAnimator10) objectAnimator).addListener((AnimatorListenerAdapter10) listener.animatorListenerAdapter); - } else { - ((ObjectAnimator) objectAnimator).addListener((AnimatorListenerAdapter) listener.animatorListenerAdapter); - } - return this; - } - - @Override - public boolean equals(Object o) { - return objectAnimator == o; - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ViewProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ViewProxy.java deleted file mode 100644 index 478398be..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ViewProxy.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.7.x. - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Nikolai Kudashov, 2013-2014. - */ - -package org.telegram.ui.AnimationCompat; - -import android.view.View; - -import org.telegram.ui.Animation.View10; - -public class ViewProxy { - - public static float getAlpha(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getAlpha(); - } else { - return view.getAlpha(); - } - } - - public static void setAlpha(View view, float alpha) { - if (View10.NEED_PROXY) { - View10.wrap(view).setAlpha(alpha); - } else { - view.setAlpha(alpha); - } - } - - public static float getPivotX(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getPivotX(); - } else { - return view.getPivotX(); - } - } - - public static void setPivotX(View view, float pivotX) { - if (View10.NEED_PROXY) { - View10.wrap(view).setPivotX(pivotX); - } else { - view.setPivotX(pivotX); - } - } - - public static float getPivotY(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getPivotY(); - } else { - return view.getPivotY(); - } - } - - public static void setPivotY(View view, float pivotY) { - if (View10.NEED_PROXY) { - View10.wrap(view).setPivotY(pivotY); - } else { - view.setPivotY(pivotY); - } - } - - public static float getRotation(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getRotation(); - } else { - return view.getRotation(); - } - } - - public static void setRotation(View view, float rotation) { - if (View10.NEED_PROXY) { - View10.wrap(view).setRotation(rotation); - } else { - view.setRotation(rotation); - } - } - - public static float getRotationX(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getRotationX(); - } else { - return view.getRotationX(); - } - } - - public void setRotationX(View view, float rotationX) { - if (View10.NEED_PROXY) { - View10.wrap(view).setRotationX(rotationX); - } else { - view.setRotationX(rotationX); - } - } - - public static float getRotationY(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getRotationY(); - } else { - return view.getRotationY(); - } - } - - public void setRotationY(View view, float rotationY) { - if (View10.NEED_PROXY) { - View10.wrap(view).setRotationY(rotationY); - } else { - view.setRotationY(rotationY); - } - } - - public static float getScaleX(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getScaleX(); - } else { - return view.getScaleX(); - } - } - - public static void setScaleX(View view, float scaleX) { - if (View10.NEED_PROXY) { - View10.wrap(view).setScaleX(scaleX); - } else { - view.setScaleX(scaleX); - } - } - - public static float getScaleY(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getScaleY(); - } else { - return view.getScaleY(); - } - } - - public static void setScaleY(View view, float scaleY) { - if (View10.NEED_PROXY) { - View10.wrap(view).setScaleY(scaleY); - } else { - view.setScaleY(scaleY); - } - } - - public static int getScrollX(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getScrollX(); - } else { - return view.getScrollX(); - } - } - - public static void setScrollX(View view, int value) { - if (View10.NEED_PROXY) { - View10.wrap(view).setScrollX(value); - } else { - view.setScrollX(value); - } - } - - public static int getScrollY(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getScrollY(); - } else { - return view.getScrollY(); - } - } - - public static void setScrollY(View view, int value) { - if (View10.NEED_PROXY) { - View10.wrap(view).setScrollY(value); - } else { - view.setScrollY(value); - } - } - - public static float getTranslationX(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getTranslationX(); - } else { - return view.getTranslationX(); - } - } - - public static void setTranslationX(View view, float translationX) { - if (View10.NEED_PROXY) { - View10.wrap(view).setTranslationX(translationX); - } else { - view.setTranslationX(translationX); - } - } - - public static float getTranslationY(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getTranslationY(); - } else { - return view.getTranslationY(); - } - } - - public static void setTranslationY(View view, float translationY) { - if (View10.NEED_PROXY) { - View10.wrap(view).setTranslationY(translationY); - } else { - view.setTranslationY(translationY); - } - } - - public static float getX(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getX(); - } else { - return view.getX(); - } - } - - public static void setX(View view, float x) { - if (View10.NEED_PROXY) { - View10.wrap(view).setX(x); - } else { - view.setX(x); - } - } - - public static float getY(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view).getY(); - } else { - return view.getY(); - } - } - - public static void setY(View view, float y) { - if (View10.NEED_PROXY) { - View10.wrap(view).setY(y); - } else { - view.setY(y); - } - } - - public static Object wrap(View view) { - if (View10.NEED_PROXY) { - return View10.wrap(view); - } else { - return view; - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java index 47d26486..70ef5c57 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java @@ -36,6 +36,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.TextInfoCell; import org.telegram.ui.Cells.UserCell; +import org.telegram.ui.Components.LayoutHelper; public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate { @@ -99,8 +100,8 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked)); frameLayout.addView(emptyTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; emptyTextView.setLayoutParams(layoutParams); emptyTextView.setOnTouchListener(new View.OnTouchListener() { @@ -113,15 +114,15 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe progressView = new FrameLayout(context); frameLayout.addView(progressView); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; progressView.setLayoutParams(layoutParams); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressView.setLayoutParams(layoutParams); @@ -136,8 +137,8 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe } frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java index 71660a93..17b05e07 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java @@ -34,6 +34,7 @@ import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.ui.Components.AvatarDrawable; +import org.telegram.ui.ImageListActivity; import org.telegram.ui.PhotoViewer; public class ChatActionCell extends BaseCell { @@ -44,8 +45,6 @@ public class ChatActionCell extends BaseCell { void needOpenUserProfile(int uid); } - private static Drawable backgroundBlack; - private static Drawable backgroundBlue; private static TextPaint textPaint; private static Drawable backgroundWhite; @@ -69,12 +68,8 @@ public class ChatActionCell extends BaseCell { public ChatActionCell(Context context) { super(context); - if (backgroundBlack == null) { - backgroundBlack = getResources().getDrawable(R.drawable.system_black); - backgroundBlue = getResources().getDrawable(R.drawable.system_blue); - + if (textPaint == null) { backgroundWhite = getResources().getDrawable(R.drawable.system_white); - textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setColor(0xffffffff); textPaint.linkColor = 0xffffffff; @@ -276,9 +271,21 @@ public class ChatActionCell extends BaseCell { textPaint.linkColor = AndroidUtilities.getIntDarkerColor("chatDateColor", -0x50); } textPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatDateSize", 16)));//16 + setBubbles(themePrefs.getString("chatBubbleStyle", ImageListActivity.getBubbleName(0))); backgroundWhite.setColorFilter(themePrefs.getInt("chatDateBubbleColor", 0x59000000), PorterDuff.Mode.MULTIPLY); } + private void setBubbles(String bubble){ + if(bubble.equals(ImageListActivity.getBubbleName(0))){ + backgroundWhite = getResources().getDrawable(R.drawable.system_white); + } else if(bubble.equals(ImageListActivity.getBubbleName(1))){ + backgroundWhite = getResources().getDrawable(R.drawable.system_white); + } else if(bubble.equals(ImageListActivity.getBubbleName(2))){ + backgroundWhite = getResources().getDrawable(R.drawable.system_white_3); + } else if(bubble.equals(ImageListActivity.getBubbleName(3))){ + backgroundWhite = getResources().getDrawable(R.drawable.system_white_4); + } + } @Override protected void onDraw(Canvas canvas) { if (currentMessageObject == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java index 844e2c31..32caffb5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java @@ -10,6 +10,7 @@ package org.telegram.ui.Cells; import android.content.Context; import android.graphics.Canvas; +import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.text.Layout; import android.text.StaticLayout; @@ -19,27 +20,21 @@ import android.view.SoundEffectConstants; import org.telegram.android.AndroidUtilities; import org.telegram.android.ImageLoader; -import org.telegram.messenger.FileLoader; import org.telegram.android.MediaController; -import org.telegram.messenger.TLRPC; -import org.telegram.android.MessagesController; -import org.telegram.messenger.R; import org.telegram.android.MessageObject; -import org.telegram.android.ImageReceiver; -import org.telegram.ui.Components.AvatarDrawable; +import org.telegram.android.MessagesController; +import org.telegram.messenger.FileLoader; import org.telegram.ui.Components.ProgressView; +import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.SeekBar; import java.io.File; public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelegate, MediaController.FileDownloadProgressListener { - private static Drawable[][] statesDrawable = new Drawable[8][2]; private static TextPaint timePaint; + private static Paint circlePaint; - private ImageReceiver avatarImage; - private AvatarDrawable avatarDrawable; - private boolean needAvatarImage = false; private SeekBar seekBar; private ProgressView progressView; private int seekBarX; @@ -50,66 +45,47 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega private int buttonY; private boolean buttonPressed = false; - private boolean avatarPressed = false; - private StaticLayout timeLayout; private int timeX; + private int timeWidth; private String lastTimeString = null; private int TAG; - public TLRPC.User audioUser; - private TLRPC.FileLocation currentPhoto; - public ChatAudioCell(Context context) { super(context); TAG = MediaController.getInstance().generateObserverTag(); - avatarImage = new ImageReceiver(this); - avatarImage.setRoundRadius(AndroidUtilities.dp(25)); seekBar = new SeekBar(context); seekBar.delegate = this; progressView = new ProgressView(); - avatarDrawable = new AvatarDrawable(); + drawForwardedName = true; + /*avatarDrawable = new AvatarDrawable(); //Chat Audio Photo int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32)); avatarImage.setRoundRadius(radius); - avatarDrawable.setRadius(radius); + avatarDrawable.setRadius(radius);*/ // if (timePaint == null) { - statesDrawable[0][0] = getResources().getDrawable(R.drawable.play1); - statesDrawable[0][1] = getResources().getDrawable(R.drawable.play1_pressed); - statesDrawable[1][0] = getResources().getDrawable(R.drawable.pause1); - statesDrawable[1][1] = getResources().getDrawable(R.drawable.pause1_pressed); - statesDrawable[2][0] = getResources().getDrawable(R.drawable.audioload1); - statesDrawable[2][1] = getResources().getDrawable(R.drawable.audioload1_pressed); - statesDrawable[3][0] = getResources().getDrawable(R.drawable.audiocancel1); - statesDrawable[3][1] = getResources().getDrawable(R.drawable.audiocancel1_pressed); - - statesDrawable[4][0] = getResources().getDrawable(R.drawable.play2); - statesDrawable[4][1] = getResources().getDrawable(R.drawable.play2_pressed); - statesDrawable[5][0] = getResources().getDrawable(R.drawable.pause2); - statesDrawable[5][1] = getResources().getDrawable(R.drawable.pause2_pressed); - statesDrawable[6][0] = getResources().getDrawable(R.drawable.audioload2); - statesDrawable[6][1] = getResources().getDrawable(R.drawable.audioload2_pressed); - statesDrawable[7][0] = getResources().getDrawable(R.drawable.audiocancel2); - statesDrawable[7][1] = getResources().getDrawable(R.drawable.audiocancel2_pressed); - timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); timePaint.setTextSize(AndroidUtilities.dp(12)); + + circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); } } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - if (avatarImage != null) { - avatarImage.clearImage(); - currentPhoto = null; - } MediaController.getInstance().removeLoadingFileObserver(this); } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + updateButtonState(); + } + @Override public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); @@ -127,9 +103,6 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega buttonPressed = true; invalidate(); result = true; - } else if (needAvatarImage && avatarImage.isInsideImage(x, y)) { - avatarPressed = true; - result = true; } } else if (buttonPressed) { if (event.getAction() == MotionEvent.ACTION_UP) { @@ -146,20 +119,6 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega invalidate(); } } - } else if (avatarPressed) { - if (event.getAction() == MotionEvent.ACTION_UP) { - avatarPressed = false; - playSoundEffect(SoundEffectConstants.CLICK); - if (delegate != null) { - delegate.didPressedUserAvatar(this, audioUser); - } - } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { - avatarPressed = false; - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!avatarImage.isInsideImage(x, y)) { - avatarPressed = false; - } - } } if (!result) { result = super.onTouchEvent(event); @@ -172,6 +131,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega private void didPressedButton() { if (buttonState == 0) { boolean result = MediaController.getInstance().playAudio(currentMessageObject); + if (!currentMessageObject.isOut() && currentMessageObject.isContentUnread()) { + MessagesController.getInstance().markMessageContentAsRead(currentMessageObject.getId()); + } if (result) { buttonState = 1; invalidate(); @@ -216,7 +178,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega } String timeString = String.format("%02d:%02d", duration / 60, duration % 60); if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { - int timeWidth = (int)Math.ceil(timePaint.measureText(timeString)); + timeWidth = (int)Math.ceil(timePaint.measureText(timeString)); timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } invalidate(); @@ -231,6 +193,12 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega } public void updateButtonState() { + if (currentMessageObject == null) { + return; + } + if (currentMessageObject.isOut() && currentMessageObject.isSending()) { + buttonState = 4; + } else { String fileName = currentMessageObject.getFileName(); File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); if (cacheFile.exists()) { @@ -257,6 +225,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega } } } + } updateProgress(); } @@ -301,65 +270,39 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = MeasureSpec.getSize(widthMeasureSpec); - setMeasuredDimension(width, AndroidUtilities.dp(68) + namesOffset); + setMeasuredDimension(width, AndroidUtilities.dp(66) + namesOffset); } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - int x; - if (currentMessageObject.isOut()) { - x = layoutWidth - backgroundWidth + AndroidUtilities.dp(8); - seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(97); - buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(67); - timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(71); + seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(55); + buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(13); + timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(66); } else { if (isChat) { - x = AndroidUtilities.dp(69); - seekBarX = AndroidUtilities.dp(158); - buttonX = AndroidUtilities.dp(128); - timeX = AndroidUtilities.dp(132); + seekBarX = AndroidUtilities.dp(116); + buttonX = AndroidUtilities.dp(74); + timeX = AndroidUtilities.dp(127); } else { - x = AndroidUtilities.dp(16); - seekBarX = AndroidUtilities.dp(106); - buttonX = AndroidUtilities.dp(76); - timeX = AndroidUtilities.dp(80); + seekBarX = AndroidUtilities.dp(64); + buttonX = AndroidUtilities.dp(22); + timeX = AndroidUtilities.dp(75); } } - int diff = 0; - if (needAvatarImage) { - avatarImage.setImageCoords(x, AndroidUtilities.dp(9) + namesOffset, AndroidUtilities.dp(50), AndroidUtilities.dp(50)); - } else { - diff = AndroidUtilities.dp(56); - seekBarX -= diff; - buttonX -= diff; - timeX -= diff; - } - seekBar.width = backgroundWidth - AndroidUtilities.dp(112) + diff; + seekBar.width = backgroundWidth - AndroidUtilities.dp(70); seekBar.height = AndroidUtilities.dp(30); - progressView.width = backgroundWidth - AndroidUtilities.dp(136) + diff; + progressView.width = backgroundWidth - AndroidUtilities.dp(94); progressView.height = AndroidUtilities.dp(30); - seekBarY = AndroidUtilities.dp(13) + namesOffset; - buttonY = AndroidUtilities.dp(10) + namesOffset; + seekBarY = AndroidUtilities.dp(11) + namesOffset; + buttonY = AndroidUtilities.dp(13) + namesOffset; updateProgress(); } - @Override - protected boolean isUserDataChanged() { - TLRPC.User newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.audio.user_id); - TLRPC.FileLocation newPhoto = null; - - if (avatarImage != null && newUser != null && newUser.photo != null) { - newPhoto = newUser.photo.photo_small; - } - - return currentPhoto == null && newPhoto != null || currentPhoto != null && newPhoto == null || currentPhoto != null && newPhoto != null && (currentPhoto.local_id != newPhoto.local_id || currentPhoto.volume_id != newPhoto.volume_id) || super.isUserDataChanged(); - } - @Override public void setMessageObject(MessageObject messageObject) { if (currentMessageObject != messageObject || isUserDataChanged()) { @@ -373,23 +316,6 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega if (uid == 0) { uid = messageObject.messageOwner.from_id; } - needAvatarImage = !(messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.chat_id != 0 && !messageObject.isOut() && messageObject.messageOwner.media.audio.user_id == messageObject.messageOwner.from_id); - audioUser = MessagesController.getInstance().getUser(uid); - - if (needAvatarImage) { - if (audioUser != null) { - if (audioUser.photo != null) { - currentPhoto = audioUser.photo.photo_small; - } else { - currentPhoto = null; - } - avatarDrawable.setInfo(audioUser); - } else { - avatarDrawable.setInfo(uid, null, null, false); - currentPhoto = null; - } - avatarImage.setImage(currentPhoto, "50_50", avatarDrawable, false); - } if (messageObject.isOut()) { seekBar.type = 0; @@ -412,10 +338,6 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega return; } - if (needAvatarImage) { - avatarImage.draw(canvas); - } - canvas.save(); if (buttonState == 0 || buttonState == 1) { canvas.translate(seekBarX, seekBarY); @@ -427,22 +349,25 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega canvas.restore(); int state = buttonState; - if (!currentMessageObject.isOut()) { - state += 4; - timePaint.setColor(0xffa1aab3); - } else { + if (currentMessageObject.isOut()) { timePaint.setColor(0xff70b15c); + circlePaint.setColor(0xff87bf78); + } else { + state += 5; + timePaint.setColor(0xffa1aab3); + circlePaint.setColor(0xff4195e5); } - Drawable buttonDrawable = statesDrawable[state][buttonPressed ? 1 : 0]; - int side = AndroidUtilities.dp(36); - int x = (side - buttonDrawable.getIntrinsicWidth()) / 2; - int y = (side - buttonDrawable.getIntrinsicHeight()) / 2; - setDrawableBounds(buttonDrawable, x + buttonX, y + buttonY); + Drawable buttonDrawable = ResourceLoader.audioStatesDrawable[state][buttonPressed ? 1 : 0]; + setDrawableBounds(buttonDrawable, buttonX, buttonY); buttonDrawable.draw(canvas); canvas.save(); - canvas.translate(timeX, AndroidUtilities.dp(45) + namesOffset); + canvas.translate(timeX, AndroidUtilities.dp(42) + namesOffset); timeLayout.draw(canvas); canvas.restore(); + + if (currentMessageObject.isContentUnread()) { + canvas.drawCircle(timeX + timeWidth + AndroidUtilities.dp(8), AndroidUtilities.dp(49.5f) + namesOffset, AndroidUtilities.dp(3), circlePaint); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java index a09f0e8e..0a324885 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java @@ -14,12 +14,14 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; +import android.text.style.ClickableSpan; import android.view.MotionEvent; import android.view.SoundEffectConstants; @@ -36,6 +38,8 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.ui.Components.AvatarDrawable; +import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.Components.StaticLayoutEx; public class ChatBaseCell extends BaseCell { @@ -48,6 +52,46 @@ public class ChatBaseCell extends BaseCell { boolean canPerformActions(); } + protected class MyPath extends Path { + + private StaticLayout currentLayout; + private int currentLine; + private float lastTop = -1; + + public void setCurrentLayout(StaticLayout layout, int start) { + currentLayout = layout; + currentLine = layout.getLineForOffset(start); + lastTop = -1; + } + + @Override + public void addRect(float left, float top, float right, float bottom, Direction dir) { + if (lastTop == -1) { + lastTop = top; + } else if (lastTop != top) { + lastTop = top; + currentLine++; + } + float lineRight = currentLayout.getLineRight(currentLine); + float lineLeft = currentLayout.getLineLeft(currentLine); + if (left >= lineRight) { + return; + } + if (right > lineRight) { + right = lineRight; + } + if (left < lineLeft) { + left = lineLeft; + } + super.addRect(left, top, right, bottom, dir); + } + } + + protected ClickableSpan pressedLink; + protected boolean linkPreviewPressed; + protected MyPath urlPath = new MyPath(); + protected static Paint urlPaint; + public boolean isChat = false; protected boolean isPressed = false; protected boolean forwardName = false; @@ -59,26 +103,6 @@ public class ChatBaseCell extends BaseCell { protected boolean drawBackground = true; protected MessageObject currentMessageObject; - private static Drawable backgroundDrawableIn; - private static Drawable backgroundDrawableInSelected; - private static Drawable backgroundDrawableOut; - private static Drawable backgroundDrawableOutSelected; - private static Drawable backgroundMediaDrawableIn; - private static Drawable backgroundMediaDrawableInSelected; - private static Drawable backgroundMediaDrawableOut; - private static Drawable backgroundMediaDrawableOutSelected; - private static Drawable checkDrawable; - private static Drawable halfCheckDrawable; - private static Drawable clockDrawable; - private static Drawable broadcastDrawable; - private static Drawable checkMediaDrawable; - private static Drawable halfCheckMediaDrawable; - private static Drawable clockMediaDrawable; - private static Drawable broadcastMediaDrawable; - private static Drawable errorDrawable; - private static Drawable backgroundBlack; - private static Drawable backgroundBlue; - protected static Drawable mediaBackgroundDrawable; private static TextPaint timePaintIn; private static TextPaint timePaintOut; private static TextPaint timeMediaPaint; @@ -144,30 +168,14 @@ public class ChatBaseCell extends BaseCell { private int last_send_state = 0; private int last_delete_date = 0; + private int leftBound = 52;//52 + private int avatarSize = AndroidUtilities.dp(42); + protected boolean avatarAlignTop = false; + private int avatarLeft = AndroidUtilities.dp(6); + public ChatBaseCell(Context context) { super(context); - if (backgroundDrawableIn == null) { - backgroundDrawableIn = getResources().getDrawable(R.drawable.msg_in); - backgroundDrawableInSelected = getResources().getDrawable(R.drawable.msg_in_selected); - backgroundDrawableOut = getResources().getDrawable(R.drawable.msg_out); - backgroundDrawableOutSelected = getResources().getDrawable(R.drawable.msg_out_selected); - backgroundMediaDrawableIn = getResources().getDrawable(R.drawable.msg_in_photo); - backgroundMediaDrawableInSelected = getResources().getDrawable(R.drawable.msg_in_photo_selected); - backgroundMediaDrawableOut = getResources().getDrawable(R.drawable.msg_out_photo); - backgroundMediaDrawableOutSelected = getResources().getDrawable(R.drawable.msg_out_photo_selected); - checkDrawable = getResources().getDrawable(R.drawable.msg_check); - halfCheckDrawable = getResources().getDrawable(R.drawable.msg_halfcheck); - clockDrawable = getResources().getDrawable(R.drawable.msg_clock); - checkMediaDrawable = getResources().getDrawable(R.drawable.msg_check_w); - halfCheckMediaDrawable = getResources().getDrawable(R.drawable.msg_halfcheck_w); - clockMediaDrawable = getResources().getDrawable(R.drawable.msg_clock_photo); - errorDrawable = getResources().getDrawable(R.drawable.msg_warning); - mediaBackgroundDrawable = getResources().getDrawable(R.drawable.phototime); - broadcastDrawable = getResources().getDrawable(R.drawable.broadcast3); - broadcastMediaDrawable = getResources().getDrawable(R.drawable.broadcast4); - backgroundBlack = getResources().getDrawable(R.drawable.system_black); - backgroundBlue = getResources().getDrawable(R.drawable.system_blue); - + if (timePaintIn == null) { timePaintIn = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); timePaintIn.setTextSize(AndroidUtilities.dp(12)); timePaintIn.setColor(0xffa1aab3); @@ -206,54 +214,83 @@ public class ChatBaseCell extends BaseCell { int radius = AndroidUtilities.dp(themePrefs.getInt("chatAvatarRadius", 32)); avatarImage.setRoundRadius(radius); avatarDrawable.setRadius(radius); + avatarSize = AndroidUtilities.dp(themePrefs.getInt("chatAvatarSize", 42)); + avatarLeft = AndroidUtilities.dp(themePrefs.getInt("chatAvatarMarginLeft", 6)); + avatarAlignTop = themePrefs.getBoolean("chatAvatarAlignTop", false); + //setBubbles(themePrefs.getString("chatBubbleStyle", ImageListActivity.getBubbleName(0))); } private void updateTheme(){ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); + int defColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); int lColor = AndroidUtilities.getDefBubbleColor(); - int dColor = AndroidUtilities.getIntDarkerColor("themeColor", 0x15); + int dColor = AndroidUtilities.setDarkColor(defColor, 0x15); int rBubbleColor = themePrefs.getInt("chatRBubbleColor", lColor); - int rBubbleSColor = AndroidUtilities.getIntDarkerColor("chatRBubbleColor", 0x15); + int rBubbleSColor = AndroidUtilities.setDarkColor(rBubbleColor, 0x15); int lBubbleColor = themePrefs.getInt("chatLBubbleColor", 0xffffffff); - - backgroundDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN); - backgroundMediaDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN); - backgroundDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN); - backgroundMediaDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN); - - backgroundDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.MULTIPLY); - backgroundMediaDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.MULTIPLY); - - int checksColor = themePrefs.getInt("chatChecksColor", tColor); - checkDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN); - halfCheckDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN); - clockDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN); + int lBubbleSColor = AndroidUtilities.setDarkColor(lBubbleColor, 0x15); timePaintOut.setColor(themePrefs.getInt("chatRTimeColor", dColor)); timePaintOut.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatTimeSize", 12))); timePaintIn.setColor(themePrefs.getInt("chatLTimeColor", 0xffa1aab3)); timePaintIn.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatTimeSize", 12))); - int linkColor = themePrefs.getInt("chatLLinkColor", tColor); - + int linkColor = themePrefs.getInt("chatLLinkColor", defColor); int bColor = AndroidUtilities.getIntAlphaColor("chatLBubbleColor", 0xffffffff, 0.9f); if(currentMessageObject.isOut()){ bColor = AndroidUtilities.getIntAlphaColor("chatRBubbleColor", lColor, 0.9f); - linkColor = themePrefs.getInt("chatRLinkColor", tColor); + linkColor = themePrefs.getInt("chatRLinkColor", defColor); } - mediaBackgroundDrawable.setColorFilter(bColor, PorterDuff.Mode.SRC_IN); - replyTextPaint.linkColor = linkColor; + //ResourceLoader.loadRecources(getContext()); + /*if(ResourceLoader.mediaBackgroundDrawable == null){ + ResourceLoader.mediaBackgroundDrawable = getResources().getDrawable(R.drawable.phototime); + ResourceLoader.checkDrawable = getResources().getDrawable(R.drawable.msg_check); + ResourceLoader.halfCheckDrawable = getResources().getDrawable(R.drawable.msg_halfcheck); + ResourceLoader.clockDrawable = getResources().getDrawable(R.drawable.msg_clock); + ResourceLoader.checkMediaDrawable = getResources().getDrawable(R.drawable.msg_check_w); + ResourceLoader.halfCheckMediaDrawable = getResources().getDrawable(R.drawable.msg_halfcheck_w); + ResourceLoader.clockMediaDrawable = getResources().getDrawable(R.drawable.msg_clock_photo); + //ResourceLoader.videoIconDrawable = getResources().getDrawable(R.drawable.ic_video); + ResourceLoader.docMenuInDrawable = getResources().getDrawable(R.drawable.doc_actions_b); + ResourceLoader.docMenuOutDrawable = getResources().getDrawable(R.drawable.doc_actions_g); + }*/ + + ResourceLoader.mediaBackgroundDrawable.setColorFilter(bColor, PorterDuff.Mode.SRC_IN); + + ResourceLoader.backgroundDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.backgroundMediaDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.backgroundDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.backgroundMediaDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN); + + ResourceLoader.backgroundDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.backgroundMediaDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.backgroundDrawableInSelected.setColorFilter(lBubbleSColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.backgroundMediaDrawableInSelected.setColorFilter(lBubbleSColor, PorterDuff.Mode.SRC_IN); + + int checksColor = themePrefs.getInt("chatChecksColor", defColor); + ResourceLoader.checkDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.halfCheckDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.clockDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN); + ResourceLoader.checkMediaDrawable.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY); + ResourceLoader.halfCheckMediaDrawable.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY); + ResourceLoader.halfCheckMediaDrawable.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY); } + + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - avatarImage.clearImage(); - replyImageReceiver.clearImage(); - currentPhoto = null; - currentReplyPhoto = null; + avatarImage.onDetachedFromWindow(); + replyImageReceiver.onDetachedFromWindow(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + avatarImage.onAttachedToWindow(); + replyImageReceiver.onAttachedToWindow(); } @Override @@ -262,6 +299,14 @@ public class ChatBaseCell extends BaseCell { invalidate(); } + protected void resetPressedLink() { + if (pressedLink != null) { + pressedLink = null; + } + linkPreviewPressed = false; + invalidate(); + } + public void setDelegate(ChatBaseCellDelegate delegate) { this.delegate = delegate; } @@ -336,6 +381,20 @@ public class ChatBaseCell extends BaseCell { return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString); } + protected void measureTime(MessageObject messageObject) { + if (!media) { + if (messageObject.isOut()) { + currentTimePaint = timePaintOut; + } else { + currentTimePaint = timePaintIn; + } + } else { + currentTimePaint = timeMediaPaint; + } + currentTimeString = LocaleController.formatterDay.format((long) (messageObject.messageOwner.date) * 1000); + timeWidth = (int)Math.ceil(currentTimePaint.measureText(currentTimeString)); + } + public void setMessageObject(MessageObject messageObject) { currentMessageObject = messageObject; last_send_state = messageObject.messageOwner.send_state; @@ -415,7 +474,7 @@ public class ChatBaseCell extends BaseCell { CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40), TextUtils.TruncateAt.END); str = AndroidUtilities.replaceTags(String.format("%s\n%s %s", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str)); - forwardedNameLayout = new StaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + forwardedNameLayout = StaticLayoutEx.createStaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, forwardedNameWidth, 2); if (forwardedNameLayout.getLineCount() > 1) { forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1))); namesOffset += AndroidUtilities.dp(36); @@ -629,20 +688,21 @@ public class ChatBaseCell extends BaseCell { timeLayout = new StaticLayout(currentTimeString, currentTimePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (!media) { if (!currentMessageObject.isOut()) { - timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat ? AndroidUtilities.dp(52) : 0); + timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat ? AndroidUtilities.dp(leftBound) : 0); } else { timeX = layoutWidth - timeWidth - AndroidUtilities.dp(38.5f); } } else { if (!currentMessageObject.isOut()) { - timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + (isChat ? AndroidUtilities.dp(52) : 0); + timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + (isChat ? AndroidUtilities.dp(leftBound) : 0); } else { timeX = layoutWidth - timeWidth - AndroidUtilities.dp(42.0f); } } if (isAvatarVisible) { - avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(45), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); + //avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(45), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); + avatarImage.setImageCoords(avatarLeft, avatarAlignTop ? AndroidUtilities.dp(3) : layoutHeight - AndroidUtilities.dp(3) - avatarSize, avatarSize, avatarSize); } wasLayout = true; @@ -662,7 +722,7 @@ public class ChatBaseCell extends BaseCell { @Override protected void onDraw(Canvas canvas) { - updateTheme(); + if (currentMessageObject == null) { return; } @@ -675,39 +735,39 @@ public class ChatBaseCell extends BaseCell { if (isAvatarVisible) { avatarImage.draw(canvas); } - + updateTheme(); Drawable currentBackgroundDrawable = null; if (currentMessageObject.isOut()) { if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) { if (!media) { - currentBackgroundDrawable = backgroundDrawableOutSelected; + currentBackgroundDrawable = ResourceLoader.backgroundDrawableOutSelected; } else { - currentBackgroundDrawable = backgroundMediaDrawableOutSelected; + currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableOutSelected; } } else { if (!media) { - currentBackgroundDrawable = backgroundDrawableOut; + currentBackgroundDrawable = ResourceLoader.backgroundDrawableOut; } else { - currentBackgroundDrawable = backgroundMediaDrawableOut; + currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableOut; } } setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); } else { if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) { if (!media) { - currentBackgroundDrawable = backgroundDrawableInSelected; + currentBackgroundDrawable = ResourceLoader.backgroundDrawableInSelected; } else { - currentBackgroundDrawable = backgroundMediaDrawableInSelected; + currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableInSelected; } } else { if (!media) { - currentBackgroundDrawable = backgroundDrawableIn; + currentBackgroundDrawable = ResourceLoader.backgroundDrawableIn; } else { - currentBackgroundDrawable = backgroundMediaDrawableIn; + currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableIn; } } if (isChat) { - setDrawableBounds(currentBackgroundDrawable, AndroidUtilities.dp(52 + (!media ? 0 : 9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); + setDrawableBounds(currentBackgroundDrawable, AndroidUtilities.dp(leftBound + (!media ? 0 : 9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); } else { setDrawableBounds(currentBackgroundDrawable, (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); } @@ -732,13 +792,14 @@ public class ChatBaseCell extends BaseCell { if (drawForwardedName && forwardedNameLayout != null) { forwardNameY = AndroidUtilities.dp(10 + (drawName ? 19 : 0)); + int defColor = themePrefs.getInt("themeColor",AndroidUtilities.defColor); if (currentMessageObject.isOut()) { //forwardNamePaint.setColor(0xff4a923c); - forwardNamePaint.setColor(themePrefs.getInt("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); + forwardNamePaint.setColor(themePrefs.getInt("chatForwardColor", AndroidUtilities.setDarkColor(defColor, 0x15))); forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10); } else { //forwardNamePaint.setColor(0xff006fc8); - forwardNamePaint.setColor(themePrefs.getInt("chatForwardColor", 0xff006fc8)); + forwardNamePaint.setColor(themePrefs.getInt("chatForwardColor", defColor)); forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19); } canvas.save(); @@ -762,25 +823,34 @@ public class ChatBaseCell extends BaseCell { } Drawable back; if (ApplicationLoader.isCustomTheme()) { - back = backgroundBlack; + back = ResourceLoader.backgroundBlack; } else { - back = backgroundBlue; + back = ResourceLoader.backgroundBlue; } replyStartY = layoutHeight - AndroidUtilities.dp(58); back.setBounds(replyStartX - AndroidUtilities.dp(7), replyStartY - AndroidUtilities.dp(6), replyStartX - AndroidUtilities.dp(7) + backWidth, replyStartY + AndroidUtilities.dp(41)); back.draw(canvas); } else { + int color = themePrefs.getInt("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)); if (currentMessageObject.isOut()) { - int color = themePrefs.getInt("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)); replyLinePaint.setColor(color);//0xff8dc97a); replyNamePaint.setColor(color);//0xff61a349); - replyTextPaint.setColor(color);//0xff70b15c); + int outColor = themePrefs.getInt("chatRTextColor", 0xff000000); + if (currentMessageObject.replyMessageObject != null && currentMessageObject.replyMessageObject.type == 0) { + replyTextPaint.setColor(outColor);//0xff000000); + } else { + replyTextPaint.setColor(color);//0xff70b15c); + } replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); } else { - int color = themePrefs.getInt("chatForwardColor", 0xff999999); replyLinePaint.setColor(color);//0xff6c9fd2); replyNamePaint.setColor(color);//0xff377aae); - replyTextPaint.setColor(color);//0xff999999); + int inColor = themePrefs.getInt("chatLTextColor", 0xff000000); + if (currentMessageObject.replyMessageObject != null && currentMessageObject.replyMessageObject.type == 0) { + replyTextPaint.setColor(inColor);//0xff000000); + } else { + replyTextPaint.setColor(color);//0xff999999); + } if (currentMessageObject.contentType == 1 && media) { replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); } else { @@ -808,10 +878,10 @@ public class ChatBaseCell extends BaseCell { } } - if (drawTime) { + if (drawTime || !media) { if (media) { - setDrawableBounds(mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dp(16.5f)); - mediaBackgroundDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dp(16.5f)); + ResourceLoader.mediaBackgroundDrawable.draw(canvas); canvas.save(); canvas.translate(timeX, layoutHeight - AndroidUtilities.dp(12.0f) - timeLayout.getHeight()); @@ -854,62 +924,62 @@ public class ChatBaseCell extends BaseCell { } if (drawClock) { - clockDrawable = clockMediaDrawable; + //ResourceLoader.clockDrawable = ResourceLoader.clockMediaDrawable; if (!media) { - setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - clockDrawable.getIntrinsicHeight()); - clockDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - ResourceLoader.clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - ResourceLoader.clockDrawable.getIntrinsicHeight()); + ResourceLoader.clockDrawable.draw(canvas); } else { - setDrawableBounds(clockMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - clockMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - clockMediaDrawable.getIntrinsicHeight()); - clockMediaDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.clockMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - ResourceLoader.clockMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.clockMediaDrawable.getIntrinsicHeight()); + ResourceLoader.clockMediaDrawable.draw(canvas); } } if (isBroadcast) { if (drawCheck1 || drawCheck2) { if (!media) { - setDrawableBounds(broadcastDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - broadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - broadcastDrawable.getIntrinsicHeight()); - broadcastDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.broadcastDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - ResourceLoader.broadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.broadcastDrawable.getIntrinsicHeight()); + ResourceLoader.broadcastDrawable.draw(canvas); } else { - setDrawableBounds(broadcastMediaDrawable, layoutWidth - AndroidUtilities.dp(24.0f) - broadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - broadcastMediaDrawable.getIntrinsicHeight()); - broadcastMediaDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.broadcastMediaDrawable, layoutWidth - AndroidUtilities.dp(24.0f) - ResourceLoader.broadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.broadcastMediaDrawable.getIntrinsicHeight()); + ResourceLoader.broadcastMediaDrawable.draw(canvas); } } } else { if (drawCheck2) { - checkDrawable = checkMediaDrawable; + //ResourceLoader.checkDrawable = ResourceLoader.checkMediaDrawable; if (!media) { if (drawCheck1) { - setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - checkDrawable.getIntrinsicHeight()); + setDrawableBounds(ResourceLoader.checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - ResourceLoader.checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.checkDrawable.getIntrinsicHeight()); } else { - setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - checkDrawable.getIntrinsicHeight()); + setDrawableBounds(ResourceLoader.checkDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - ResourceLoader.checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.checkDrawable.getIntrinsicHeight()); } - checkDrawable.draw(canvas); + ResourceLoader.checkDrawable.draw(canvas); } else { if (drawCheck1) { - setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dp(26.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - checkMediaDrawable.getIntrinsicHeight()); + setDrawableBounds(ResourceLoader.checkMediaDrawable, layoutWidth - AndroidUtilities.dp(26.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicHeight()); } else { - setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - checkMediaDrawable.getIntrinsicHeight()); + setDrawableBounds(ResourceLoader.checkMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicHeight()); } - checkMediaDrawable.draw(canvas); + ResourceLoader.checkMediaDrawable.draw(canvas); } } if (drawCheck1) { - halfCheckDrawable = halfCheckMediaDrawable; + //ResourceLoader.halfCheckDrawable = ResourceLoader.halfCheckMediaDrawable; if (!media) { - setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - halfCheckDrawable.getIntrinsicHeight()); - halfCheckDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - ResourceLoader.halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.halfCheckDrawable.getIntrinsicHeight()); + ResourceLoader.halfCheckDrawable.draw(canvas); } else { - setDrawableBounds(halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - halfCheckMediaDrawable.getIntrinsicHeight()); - halfCheckMediaDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - ResourceLoader.halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.halfCheckMediaDrawable.getIntrinsicHeight()); + ResourceLoader.halfCheckMediaDrawable.draw(canvas); } } } if (drawError) { if (!media) { - setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dp(18) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(6.5f) - errorDrawable.getIntrinsicHeight()); - errorDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.errorDrawable, layoutWidth - AndroidUtilities.dp(18) - ResourceLoader.errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(6.5f) - ResourceLoader.errorDrawable.getIntrinsicHeight()); + ResourceLoader.errorDrawable.draw(canvas); } else { - setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - errorDrawable.getIntrinsicHeight()); - errorDrawable.draw(canvas); + setDrawableBounds(ResourceLoader.errorDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - ResourceLoader.errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - ResourceLoader.errorDrawable.getIntrinsicHeight()); + ResourceLoader.errorDrawable.draw(canvas); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java index f823d5a1..8bb43c40 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java @@ -18,9 +18,11 @@ import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.text.Layout; +import android.text.Spannable; import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; +import android.text.style.ClickableSpan; import android.view.MotionEvent; import android.view.SoundEffectConstants; @@ -35,12 +37,16 @@ import org.telegram.android.SendMessagesHelper; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLoader; +import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.messenger.Utilities; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.GifDrawable; import org.telegram.ui.Components.RadialProgress; +import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.Components.StaticLayoutEx; +import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.PhotoViewer; import java.io.File; @@ -50,22 +56,17 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD public interface ChatMediaCellDelegate { void didClickedImage(ChatMediaCell cell); + void didPressedOther(ChatMediaCell cell); } - private static Drawable placeholderDocInDrawable; - private static Drawable placeholderDocOutDrawable; - private static Drawable videoIconDrawable; - private static Drawable docMenuInDrawable; - private static Drawable docMenuOutDrawable; - private static Drawable docMenuWhiteDrawable; - private static Drawable[] buttonStatesDrawables = new Drawable[8]; - private static Drawable[][] buttonStatesDrawablesDoc = new Drawable[3][2]; private static TextPaint infoPaint; private static MessageObject lastDownloadedGifMessage = null; private static TextPaint namePaint; private static Paint docBackPaint; private static Paint deleteProgressPaint; + private static TextPaint locationTitlePaint; + private static TextPaint locationAddressPaint; private GifDrawable gifDrawable = null; private RadialProgress radialProgress; @@ -79,6 +80,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD private ImageReceiver photoImage; private boolean photoNotSet = false; private boolean cancelLoading = false; + private int additionHeight; private boolean allowedToSetPhoto = true; @@ -95,11 +97,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD private int infoWidth; private int infoOffset = 0; private String currentInfoString; - + //Plus private StaticLayout infoLayout2; private int infoWidth2; private static TextPaint senderPaint; - + private int infoOffset2 = 0; + // private StaticLayout nameLayout; private int nameWidth = 0; private String currentNameString; @@ -107,30 +110,14 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD private ChatMediaCellDelegate mediaDelegate = null; private RectF deleteProgressRect = new RectF(); + private int captionX; + private int captionY; + private int captionHeight; + public ChatMediaCell(Context context) { super(context); - if (placeholderDocInDrawable == null) { - placeholderDocInDrawable = getResources().getDrawable(R.drawable.doc_blue); - placeholderDocOutDrawable = getResources().getDrawable(R.drawable.doc_green); - buttonStatesDrawables[0] = getResources().getDrawable(R.drawable.photoload); - buttonStatesDrawables[1] = getResources().getDrawable(R.drawable.photocancel); - buttonStatesDrawables[2] = getResources().getDrawable(R.drawable.photogif); - buttonStatesDrawables[3] = getResources().getDrawable(R.drawable.playvideo); - buttonStatesDrawables[4] = getResources().getDrawable(R.drawable.photopause); - buttonStatesDrawables[5] = getResources().getDrawable(R.drawable.burn); - buttonStatesDrawables[6] = getResources().getDrawable(R.drawable.circle); - buttonStatesDrawables[7] = getResources().getDrawable(R.drawable.photocheck); - buttonStatesDrawablesDoc[0][0] = getResources().getDrawable(R.drawable.docload_b); - buttonStatesDrawablesDoc[1][0] = getResources().getDrawable(R.drawable.doccancel_b); - buttonStatesDrawablesDoc[2][0] = getResources().getDrawable(R.drawable.docpause_b); - buttonStatesDrawablesDoc[0][1] = getResources().getDrawable(R.drawable.docload_g); - buttonStatesDrawablesDoc[1][1] = getResources().getDrawable(R.drawable.doccancel_g); - buttonStatesDrawablesDoc[2][1] = getResources().getDrawable(R.drawable.docpause_g); - videoIconDrawable = getResources().getDrawable(R.drawable.ic_video); - docMenuInDrawable = getResources().getDrawable(R.drawable.doc_actions_b); - docMenuOutDrawable = getResources().getDrawable(R.drawable.doc_actions_g); - + if (infoPaint == null) { infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); infoPaint.setTextSize(AndroidUtilities.dp(12)); @@ -139,8 +126,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD namePaint.setTextSize(AndroidUtilities.dp(16)); //namePaint.setColor(AndroidUtilities.getIntDef("chatFileInfoColor", 0xff212121)); - docMenuWhiteDrawable = getResources().getDrawable(R.drawable.doc_actions_w); - //docMenuWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatFileInfoColor", 0xff70b15c), PorterDuff.Mode.MULTIPLY); senderPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); senderPaint.setColor(0xffffffff); senderPaint.setTextSize(AndroidUtilities.dp(15)); @@ -149,6 +134,13 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD deleteProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); deleteProgressPaint.setColor(0xffe4e2e0); + + locationTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + locationTitlePaint.setTextSize(AndroidUtilities.dp(14)); + locationTitlePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + + locationAddressPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + locationAddressPaint.setTextSize(AndroidUtilities.dp(14)); } TAG = MediaController.getInstance().generateObserverTag(); @@ -173,12 +165,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - if (photoImage != null) { - photoImage.clearImage(); - currentPhotoObject = null; - currentPhotoObjectThumb = null; - } - currentUrl = null; + photoImage.onDetachedFromWindow(); if (gifDrawable != null) { MediaController.getInstance().clearGifDrawable(this); gifDrawable = null; @@ -186,6 +173,14 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD MediaController.getInstance().removeLoadingFileObserver(this); } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (photoImage.onAttachedToWindow()) { + updateButtonState(false); + } + } + @Override public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); @@ -193,6 +188,78 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD boolean result = false; int side = AndroidUtilities.dp(48); + if (currentMessageObject.caption instanceof Spannable && !isPressed) { + if (event.getAction() == MotionEvent.ACTION_DOWN || (linkPreviewPressed || pressedLink != null) && event.getAction() == MotionEvent.ACTION_UP) { + if (nameLayout != null && x >= captionX && x <= captionX + backgroundWidth && y >= captionY && y <= captionY + captionHeight) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + resetPressedLink(); + try { + int x2 = (int) (x - captionX); + int y2 = (int) (y - captionY); + final int line = nameLayout.getLineForVertical(y2); + final int off = nameLayout.getOffsetForHorizontal(line, x2); + + final float left = nameLayout.getLineLeft(line); + if (left <= x2 && left + nameLayout.getLineWidth(line) >= x2) { + Spannable buffer = (Spannable) currentMessageObject.caption; + ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); + if (link.length != 0) { + resetPressedLink(); + pressedLink = link[0]; + linkPreviewPressed = true; + result = true; + try { + int start = buffer.getSpanStart(pressedLink); + urlPath.setCurrentLayout(nameLayout, start); + nameLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), urlPath); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } else { + resetPressedLink(); + } + } else { + resetPressedLink(); + } + } catch (Exception e) { + resetPressedLink(); + FileLog.e("tmessages", e); + } + } else if (linkPreviewPressed) { + try { + if (pressedLink instanceof URLSpanNoUnderline) { + String url = ((URLSpanNoUnderline) pressedLink).getURL(); + if (url.startsWith("@") || url.startsWith("#")) { + if (delegate != null) { + delegate.didPressUrl(url); + } + } + } else { + pressedLink.onClick(this); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + resetPressedLink(); + result = true; + } + } else { + resetPressedLink(); + } + } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { + resetPressedLink(); + } + + if (result && event.getAction() == MotionEvent.ACTION_DOWN) { + startCheckLongPress(); + } + if (event.getAction() != MotionEvent.ACTION_DOWN && event.getAction() != MotionEvent.ACTION_MOVE) { + cancelCheckLongPress(); + } + if (result) { + return result; + } + } if (event.getAction() == MotionEvent.ACTION_DOWN) { if (delegate == null || delegate.canPerformActions()) { if (buttonState != -1 && x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side) { @@ -331,25 +398,59 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD Drawable currentButtonDrawable = null; if (currentMessageObject.type == 9 && gifDrawable == null) { if (buttonState == 1 && !currentMessageObject.isSending()) { - return buttonStatesDrawablesDoc[2][currentMessageObject.isOut() ? 1 : 0]; + return ResourceLoader.buttonStatesDrawablesDoc[2][currentMessageObject.isOut() ? 1 : 0]; } else { - return buttonStatesDrawablesDoc[buttonState][currentMessageObject.isOut() ? 1 : 0]; + return ResourceLoader.buttonStatesDrawablesDoc[buttonState][currentMessageObject.isOut() ? 1 : 0]; } } else { if (buttonState == 1 && !currentMessageObject.isSending()) { - return buttonStatesDrawables[4]; + return ResourceLoader.buttonStatesDrawables[4]; } else { - return buttonStatesDrawables[buttonState]; + return ResourceLoader.buttonStatesDrawables[buttonState]; } } } else if (buttonState == -1) { if (currentMessageObject.type == 9 && gifDrawable == null) { - return currentMessageObject.isOut() ? placeholderDocOutDrawable : placeholderDocInDrawable; + //return getThumbForName(currentMessageObject.getFileName()); + return currentMessageObject.isOut() ? ResourceLoader.placeholderDocOutDrawable : ResourceLoader.placeholderDocInDrawable; } } return null; - } + }/* + //Plus + private int icons[] = { + R.drawable.media_doc_blue, + R.drawable.media_doc_green, + R.drawable.media_doc_red, + R.drawable.media_doc_yellow + }; + private Drawable getThumbForName(String name) { + if (name != null && name.length() != 0) { + int color = -1; + if (name.contains(".doc") || name.contains(".txt") || name.contains(".psd")) { + color = 0; + } else if (name.contains(".xls") || name.contains(".csv")) { + color = 1; + } else if (name.contains(".pdf") || name.contains(".ppt") || name.contains(".key")) { + color = 2; + } else if (name.contains(".zip") || name.contains(".rar") || name.contains(".ai") || name.contains(".mp3") || name.contains(".mov") || name.contains(".avi")) { + color = 3; + } + if (color == -1) { + int idx; + String ext = (idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1); + if (ext.length() != 0) { + color = ext.charAt(0) % icons.length; + } else { + color = name.charAt(0) % icons.length; + } + } + return getResources().getDrawable(icons[color]); + } + return getResources().getDrawable(icons[0]); + }*/ + // private void didPressedButton(boolean animated) { if (buttonState == 0) { cancelLoading = false; @@ -410,7 +511,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD } double lat = object.messageOwner.media.geo.lat; double lon = object.messageOwner.media.geo._long; - String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(AndroidUtilities.density)), lat, lon); + String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); if (!url.equals(currentUrl)) { return true; } @@ -427,10 +528,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD @Override public void setMessageObject(MessageObject messageObject) { - media = messageObject.type != 9; boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet); if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || dataChanged) { + media = messageObject.type != 9; cancelLoading = false; + additionHeight = 0; + resetPressedLink(); buttonState = -1; gifDrawable = null; @@ -454,6 +557,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD } if (currentNameString == null || !currentNameString.equals(name)) { currentNameString = name; + nameLayout = StaticLayoutEx.createStaticLayout(currentNameString, namePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth, 1); + if (nameLayout.getLineCount() > 0) { + nameWidth = Math.min(maxWidth, (int) Math.ceil(nameLayout.getLineWidth(0))); + } else { + nameWidth = maxWidth; + } nameWidth = Math.min(maxWidth, (int) Math.ceil(namePaint.measureText(currentNameString))); CharSequence str = TextUtils.ellipsize(currentNameString, namePaint, nameWidth, TextUtils.TruncateAt.END); nameLayout = new StaticLayout(str, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); @@ -475,21 +584,20 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD if (currentInfoString == null || !currentInfoString.equals(str)) { currentInfoString = str; infoOffset = 0; + infoWidth = Math.min(maxWidth, (int) Math.ceil(infoPaint.measureText(currentInfoString))); + infoLayout2 = null; - if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat) ){ - infoLayout2 = null; - }else{ + if(isChat){ TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id); String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name); infoWidth2 = Math.min(maxWidth, (int) Math.ceil(senderPaint.measureText(senderName))); CharSequence str2 = TextUtils.ellipsize(senderName, senderPaint, infoWidth2, TextUtils.TruncateAt.END); infoLayout2 = new StaticLayout(str2, senderPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + infoWidth = Math.max(infoWidth2, (int) Math.ceil(infoPaint.measureText(currentInfoString))); } - - infoWidth = Math.max(infoWidth2, (int) Math.ceil(infoPaint.measureText(currentInfoString))); CharSequence str2 = TextUtils.ellipsize(currentInfoString, infoPaint, infoWidth, TextUtils.TruncateAt.END); infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - // + } } else if (messageObject.type == 8) { //GIF gifDrawable = MediaController.getInstance().getGifDrawable(this, false); @@ -498,20 +606,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD if (currentInfoString == null || !currentInfoString.equals(str)) { currentInfoString = str; infoOffset = 0; - // - if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat) ){ - //infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString)); - //infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - infoLayout = null; - infoLayout2 = null; - }else{ - TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id); - String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name); - infoWidth = (int) Math.ceil(senderPaint.measureText(senderName)); - infoLayout = new StaticLayout(senderName, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - infoWidth2 = (int) Math.ceil(infoPaint.measureText(currentInfoString)); - infoLayout2 = new StaticLayout(currentInfoString, infoPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - } + infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString)); + infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } nameLayout = null; currentNameString = null; @@ -522,49 +618,52 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD String str = String.format("%d:%02d, %s", minutes, seconds, Utilities.formatFileSize(messageObject.messageOwner.media.video.size)); if (currentInfoString == null || !currentInfoString.equals(str)) { currentInfoString = str; - infoOffset = videoIconDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4); - if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat)){ - //infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString)); - //infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - infoLayout = null; - infoLayout2 = null; - }else{ + //infoOffset = ResourceLoader.videoIconDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4); + //infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString)); + //infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + //Plus + infoLayout = null; + infoLayout2 = null; + if(isChat){ + infoOffset2 = ResourceLoader.videoIconDrawable.getIntrinsicWidth() + AndroidUtilities.dp(5); + infoOffset = 0; TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id); String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name); - infoWidth = (int) Math.ceil(senderPaint.measureText(senderName)); - infoLayout = new StaticLayout(senderName, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); infoWidth2 = (int) Math.ceil(infoPaint.measureText(currentInfoString)); + //infoWidth = (int) Math.ceil(senderPaint.measureText(senderName)); + infoWidth = Math.max(infoWidth2, (int) Math.ceil(senderPaint.measureText(senderName))); + infoLayout = new StaticLayout(senderName, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + infoLayout2 = new StaticLayout(currentInfoString, infoPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - } + + }// } nameLayout = null; currentNameString = null; - } else if (messageObject.type == 1) { //PHOTO + }//Plus: member name in photos + else if (messageObject.type == 1) { //PHOTO TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id); String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name); - if (currentInfoString == null || !currentInfoString.equals(senderName)) { currentInfoString = senderName; infoOffset = 0; - if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat) ){ - infoLayout = null; - }else{ + infoLayout = null; + if(isChat){ infoWidth = (int) Math.ceil(senderPaint.measureText(currentInfoString)); infoLayout = new StaticLayout(currentInfoString, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } - if(!isChat)infoLayout = null; - infoLayout2 = null; } nameLayout = null; currentNameString = null; - } + infoLayout2 = null; + }// else { currentInfoString = null; currentNameString = null; infoLayout = null; nameLayout = null; updateSecretTimeText(); - infoLayout2 = null; + infoLayout2 = null; //Plus } if (messageObject.type == 9) { //doc photoWidth = AndroidUtilities.dp(86); @@ -581,17 +680,46 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD photoImage.setImageBitmap((BitmapDrawable) null); } } else if (messageObject.type == 4) { //geo - photoWidth = AndroidUtilities.dp(200); - photoHeight = AndroidUtilities.dp(100); - backgroundWidth = photoWidth + AndroidUtilities.dp(12); - double lat = messageObject.messageOwner.media.geo.lat; double lon = messageObject.messageOwner.media.geo._long; - currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=200x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(AndroidUtilities.density)), lat, lon); + + if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) { + int maxWidth = (AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() : Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) - AndroidUtilities.dp((isChat && !messageObject.isOut() ? 102 : 40) + 86 + 24); + nameLayout = StaticLayoutEx.createStaticLayout(messageObject.messageOwner.media.title, locationTitlePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth - AndroidUtilities.dp(4), 3); + int lineCount = nameLayout.getLineCount(); + if (messageObject.messageOwner.media.address != null && messageObject.messageOwner.media.address.length() > 0) { + infoLayout = StaticLayoutEx.createStaticLayout(messageObject.messageOwner.media.address, locationAddressPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth - AndroidUtilities.dp(4), Math.min(3, 4 - lineCount)); + } else { + infoLayout = null; + } + + media = false; + measureTime(messageObject); + photoWidth = AndroidUtilities.dp(86); + photoHeight = AndroidUtilities.dp(86); + maxWidth = timeWidth + AndroidUtilities.dp(messageObject.isOut() ? 29 : 9); + for (int a = 0; a < lineCount; a++) { + maxWidth = (int) Math.max(maxWidth, nameLayout.getLineWidth(a) + AndroidUtilities.dp(16)); + } + if (infoLayout != null) { + lineCount = infoLayout.getLineCount(); + for (int a = 0; a < infoLayout.getLineCount(); a++) { + maxWidth = (int) Math.max(maxWidth, infoLayout.getLineWidth(a) + AndroidUtilities.dp(16)); + } + } + backgroundWidth = photoWidth + AndroidUtilities.dp(21) + maxWidth; + currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=72x72&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); + } else { + photoWidth = AndroidUtilities.dp(200); + photoHeight = AndroidUtilities.dp(100); + backgroundWidth = photoWidth + AndroidUtilities.dp(12); + currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=200x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); + } + photoImage.setNeedsQualityThumb(false); photoImage.setShouldGenerateQualityThumb(false); photoImage.setParentMessageObject(null); - photoImage.setImage(currentUrl, null, null, 0); + photoImage.setImage(currentUrl, null, messageObject.isOut() ? ResourceLoader.geoOutDrawable : ResourceLoader.geoInDrawable, 0); } else if (messageObject.type == 13) { //webp drawBackground = false; for (TLRPC.DocumentAttribute attribute : messageObject.messageOwner.media.document.attributes) { @@ -614,11 +742,11 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD } if (photoHeight > maxHeight) { photoWidth *= maxHeight / photoHeight; - photoHeight = (int)maxHeight; + photoHeight = (int) maxHeight; } if (photoWidth > maxWidth) { photoHeight *= maxWidth / photoWidth; - photoWidth = (int)maxWidth; + photoWidth = (int) maxWidth; } backgroundWidth = photoWidth + AndroidUtilities.dp(12); currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); @@ -674,10 +802,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD } //8 - gif, 1 - photo, 3 - video + if (messageObject.caption != null) { + media = false; + } currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); if (currentPhotoObject != null) { + if (currentPhotoObject == currentPhotoObjectThumb) { + currentPhotoObjectThumb = null; + } boolean noSize = false; if (messageObject.type == 3 || messageObject.type == 8) { noSize = true; @@ -712,6 +846,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD w = (int) (currentPhotoObject.w / hScale); } } + measureTime(messageObject); int timeWidthTotal = timeWidth + AndroidUtilities.dp(14 + (messageObject.isOut() ? 20 : 0)); if (w < timeWidthTotal) { w = timeWidthTotal; @@ -728,6 +863,20 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD photoWidth = w; photoHeight = h; backgroundWidth = w + AndroidUtilities.dp(12); + if (!media) { + backgroundWidth += AndroidUtilities.dp(9); + } + if (messageObject.caption != null) { + nameLayout = new StaticLayout(messageObject.caption, MessageObject.textPaint, photoWidth - AndroidUtilities.dp(10), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + if (nameLayout.getLineCount() > 0) { + captionHeight = nameLayout.getHeight(); + additionHeight += captionHeight + AndroidUtilities.dp(9); + float lastLineWidth = nameLayout.getLineWidth(nameLayout.getLineCount() - 1) + nameLayout.getLineLeft(nameLayout.getLineCount() - 1); + if (photoWidth - AndroidUtilities.dp(8) - lastLineWidth < timeWidthTotal) { + additionHeight += AndroidUtilities.dp(14); + } + } + } currentPhotoFilter = String.format(Locale.US, "%d_%d", (int) (w / AndroidUtilities.density), (int) (h / AndroidUtilities.density)); if (messageObject.photoThumbs.size() > 1 || messageObject.type == 3 || messageObject.type == 8) { @@ -769,7 +918,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD photoImage.setImage(null, null, currentPhotoObject.location, currentPhotoFilter, 0, false); } } else { - photoImage.setImageBitmap((Bitmap)null); + photoImage.setImageBitmap((Bitmap) null); } } super.setMessageObject(messageObject); @@ -790,7 +939,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD if (currentPhotoObject == null) { return; } - fileName = FileLoader.getAttachFileName(currentPhotoObject); + //fileName = FileLoader.getAttachFileName(currentPhotoObject); + fileName = FileLoader.getAttachFileName(currentPhotoObject, currentMessageObject.isOut()); cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); } else if (currentMessageObject.type == 8 || currentMessageObject.type == 3 || currentMessageObject.type == 9) { if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() != 0) { @@ -828,6 +978,11 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD if (cacheFile.exists() && cacheFile.length() == 0) { cacheFile.delete(); } + // + if (!currentMessageObject.isOut() && cacheFile.exists() && cacheFile.length() != 0 && currentMessageObject.messageOwner.media.document != null) { + if(cacheFile.lastModified()/1000 < currentMessageObject.messageOwner.media.document.date)cacheFile.delete(); + } + // if (!cacheFile.exists()) { MediaController.getInstance().addLoadingFileObserver(fileName, this); float setProgress = 0; @@ -865,7 +1020,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), photoHeight + AndroidUtilities.dp(14) + namesOffset); + setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), photoHeight + AndroidUtilities.dp(14) + namesOffset + additionHeight); } @Override @@ -888,8 +1043,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD } photoImage.setImageCoords(x, AndroidUtilities.dp(7) + namesOffset, photoWidth, photoHeight); int size = AndroidUtilities.dp(48); - buttonX = (int)(x + (photoWidth - size) / 2.0f); - buttonY = (int)(AndroidUtilities.dp(7) + (photoHeight - size) / 2.0f) + namesOffset; + buttonX = (int) (x + (photoWidth - size) / 2.0f); + buttonY = (int) (AndroidUtilities.dp(7) + (photoHeight - size) / 2.0f) + namesOffset; radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(48), buttonY + AndroidUtilities.dp(48)); deleteProgressRect.set(buttonX + AndroidUtilities.dp(3), buttonY + AndroidUtilities.dp(3), buttonX + AndroidUtilities.dp(45), buttonY + AndroidUtilities.dp(45)); @@ -906,7 +1061,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD if (currentInfoString == null || !currentInfoString.equals(str)) { currentInfoString = str; infoOffset = 0; - infoWidth = (int)Math.ceil(infoPaint.measureText(currentInfoString)); + infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString)); CharSequence str2 = TextUtils.ellipsize(currentInfoString, infoPaint, infoWidth, TextUtils.TruncateAt.END); infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); invalidate(); @@ -945,7 +1100,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD radialProgress.setHideCurrentDrawable(false); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); + //int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); if (currentMessageObject.type == 9) { Drawable menuDrawable = null; int color = themePrefs.getInt("chatRTextColor", 0xff000000); @@ -953,16 +1108,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD //infoPaint.setColor(0xff70b15c); infoPaint.setColor(color); docBackPaint.setColor(0xffdaf5c3); - docMenuWhiteDrawable.setColorFilter(themePrefs.getInt("chatRTimeColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)), PorterDuff.Mode.MULTIPLY); - menuDrawable = docMenuOutDrawable = docMenuWhiteDrawable; + ResourceLoader.docMenuOutDrawable.setColorFilter(themePrefs.getInt("chatRTimeColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)), PorterDuff.Mode.SRC_IN); + menuDrawable = ResourceLoader.docMenuOutDrawable; namePaint.setColor(color); } else { color = themePrefs.getInt("chatLTextColor", 0xff000000); //infoPaint.setColor(0xffa1adbb); infoPaint.setColor(color); docBackPaint.setColor(0xffebf0f5); - docMenuWhiteDrawable.setColorFilter(themePrefs.getInt("chatLTimeColor", 0xffa1adbb), PorterDuff.Mode.MULTIPLY); - menuDrawable = docMenuInDrawable = docMenuWhiteDrawable; + ResourceLoader.docMenuInDrawable.setColorFilter(themePrefs.getInt("chatLTimeColor", 0xffa1adbb), PorterDuff.Mode.SRC_IN); + menuDrawable = ResourceLoader.docMenuInDrawable; namePaint.setColor(color); } @@ -972,15 +1127,15 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD if (buttonState >= 0 && buttonState < 4) { if (!imageDrawn) { if (buttonState == 1 && !currentMessageObject.isSending()) { - radialProgress.swapBackground(buttonStatesDrawablesDoc[2][currentMessageObject.isOut() ? 1 : 0]); + radialProgress.swapBackground(ResourceLoader.buttonStatesDrawablesDoc[2][currentMessageObject.isOut() ? 1 : 0]); } else { - radialProgress.swapBackground(buttonStatesDrawablesDoc[buttonState][currentMessageObject.isOut() ? 1 : 0]); + radialProgress.swapBackground(ResourceLoader.buttonStatesDrawablesDoc[buttonState][currentMessageObject.isOut() ? 1 : 0]); } } else { if (buttonState == 1 && !currentMessageObject.isSending()) { - radialProgress.swapBackground(buttonStatesDrawables[4]); + radialProgress.swapBackground(ResourceLoader.buttonStatesDrawables[4]); } else { - radialProgress.swapBackground(buttonStatesDrawables[buttonState]); + radialProgress.swapBackground(ResourceLoader.buttonStatesDrawables[buttonState]); } } } @@ -1011,16 +1166,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD drawable = 6; } } - setDrawableBounds(buttonStatesDrawables[drawable], buttonX, buttonY); - buttonStatesDrawables[drawable].setAlpha((int)(255 * (1.0f - radialProgress.getAlpha()))); - buttonStatesDrawables[drawable].draw(canvas); + setDrawableBounds(ResourceLoader.buttonStatesDrawables[drawable], buttonX, buttonY); + ResourceLoader.buttonStatesDrawables[drawable].setAlpha((int) (255 * (1.0f - radialProgress.getAlpha()))); + ResourceLoader.buttonStatesDrawables[drawable].draw(canvas); if (!currentMessageObject.isOut() && currentMessageObject.messageOwner.destroyTime != 0) { long msTime = System.currentTimeMillis() + ConnectionsManager.getInstance().getTimeDifference() * 1000; - float progress = Math.max(0, (long)currentMessageObject.messageOwner.destroyTime * 1000 - msTime) / (currentMessageObject.messageOwner.ttl * 1000.0f); + float progress = Math.max(0, (long) currentMessageObject.messageOwner.destroyTime * 1000 - msTime) / (currentMessageObject.messageOwner.ttl * 1000.0f); canvas.drawArc(deleteProgressRect, -90, -360 * progress, true, deleteProgressPaint); if (progress != 0) { int offset = AndroidUtilities.dp(2); - invalidate((int)deleteProgressRect.left - offset, (int)deleteProgressRect.top - offset, (int)deleteProgressRect.right + offset * 2, (int)deleteProgressRect.bottom + offset * 2); + invalidate((int) deleteProgressRect.left - offset, (int) deleteProgressRect.top - offset, (int) deleteProgressRect.right + offset * 2, (int) deleteProgressRect.bottom + offset * 2); } updateSecretTimeText(); } @@ -1030,66 +1185,99 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD if(themePrefs.getBoolean("chatMemberColorCheck", false)){ senderPaint.setColor(themePrefs.getInt("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); }else{ - //if(currentMessageObject.type == 9){ - senderPaint.setColor(AvatarDrawable.getNameColorForId(MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id).id)); - //}else{ - //senderPaint.setColor(0xffffffff); - //} + senderPaint.setColor(AvatarDrawable.getNameColorForId(MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id).id)); } - if (nameLayout != null) { - if (infoLayout2 != null) { + if (currentMessageObject.type == 1 || currentMessageObject.type == 3) {//1: photo 3: video + if (nameLayout != null) { canvas.save(); - canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); - infoLayout2.draw(canvas); + canvas.translate(captionX = photoImage.getImageX() + AndroidUtilities.dp(5), captionY = photoImage.getImageY() + photoHeight + AndroidUtilities.dp(6)); + if (pressedLink != null) { + canvas.drawPath(urlPath, urlPaint); + } + nameLayout.draw(canvas); canvas.restore(); } + if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto() || currentMessageObject.type == 1)) { + infoPaint.setColor(0xffffffff); + + if (currentMessageObject.type == 1){ + setDrawableBounds(ResourceLoader.mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(20)); + }else if (currentMessageObject.type == 3){ + setDrawableBounds(ResourceLoader.mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset2, AndroidUtilities.dp(35)); + }else{ + setDrawableBounds(ResourceLoader.mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(16.5f)); + } + ResourceLoader.mediaBackgroundDrawable.draw(canvas); + + if (currentMessageObject.type == 3) { + //setDrawableBounds(ResourceLoader.videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(7.5f)); + if (infoLayout2 != null) { + setDrawableBounds(ResourceLoader.videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), 2*(photoImage.getImageY() + AndroidUtilities.dp(10))); + }else{ + setDrawableBounds(ResourceLoader.videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(8)); + } + ResourceLoader.videoIconDrawable.draw(canvas); + } + + canvas.save(); + canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8) + infoOffset, photoImage.getImageY() + AndroidUtilities.dp(5.5f)); + infoLayout.draw(canvas); + if (infoLayout2 != null) { + canvas.translate(infoOffset2, photoImage.getImageY() + AndroidUtilities.dp(12)); + infoLayout2.draw(canvas); + } + canvas.restore(); + } + } else if (currentMessageObject.type == 4) { + if (nameLayout != null) { + locationAddressPaint.setColor(currentMessageObject.isOut() ? 0xff70b15c : 0xff999999); + + canvas.save(); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(3)); + nameLayout.draw(canvas); + canvas.restore(); + + if (infoLayout != null) { + canvas.save(); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(nameLayout.getLineCount() * 16 + 5)); + infoLayout.draw(canvas); + canvas.restore(); + } + } + } else if (currentMessageObject.type == 9) { + if (nameLayout != null) { + if (infoLayout2 != null) { + canvas.save(); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); + infoLayout2.draw(canvas); + canvas.restore(); + } + + canvas.save(); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(30));//8 + nameLayout.draw(canvas); + canvas.restore(); + + if (infoLayout != null) { + canvas.save(); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(50));//30 + infoLayout.draw(canvas); + canvas.restore(); + } + } + } else if (nameLayout != null) { canvas.save(); - canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(30)); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); nameLayout.draw(canvas); canvas.restore(); if (infoLayout != null) { canvas.save(); - canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(50)); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(30)); infoLayout.draw(canvas); canvas.restore(); } - } else if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto() || currentMessageObject.type == 1 || (buttonState == 2 && currentMessageObject.type == 8) )) { - //infoPaint.setColor(0xffffffff); - if(currentMessageObject.isOut()){ - int color = themePrefs.getInt("chatRTextColor", 0xff000000); - infoPaint.setColor(color); - videoIconDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY); - }else{ - int color = themePrefs.getInt("chatLTextColor", 0xff000000); - infoPaint.setColor(color); - videoIconDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY); - } - if (currentMessageObject.type == 1){ - setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(20)); - } else { - setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), Math.max(infoWidth , infoWidth2 + infoOffset) + AndroidUtilities.dp(8) + infoOffset, 2 * AndroidUtilities.dp(20)); - } - mediaBackgroundDrawable.draw(canvas); - - if (currentMessageObject.type == 3) { - if (infoLayout2 != null) { - setDrawableBounds(videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), 2*(photoImage.getImageY() + AndroidUtilities.dp(10))); - }else{ - setDrawableBounds(videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(8)); - } - videoIconDrawable.draw(canvas); - } - - canvas.save(); - canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8) + infoOffset, photoImage.getImageY() + AndroidUtilities.dp(6)); - infoLayout.draw(canvas); - if (infoLayout2 != null) { - canvas.translate(infoOffset, photoImage.getImageY() + AndroidUtilities.dp(12)); - infoLayout2.draw(canvas); - } - canvas.restore(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 97831921..49a9f4d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -13,7 +13,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Canvas; import android.graphics.Paint; -import android.graphics.Path; import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.Browser; @@ -35,6 +34,7 @@ import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; +import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.StaticLayoutEx; import org.telegram.ui.Components.URLSpanNoUnderline; @@ -44,11 +44,7 @@ public class ChatMessageCell extends ChatBaseCell { private int textX, textY; private int totalHeight = 0; - private ClickableSpan pressedLink; private int linkBlockNum; - private MyPath urlPath = new MyPath(); - private boolean linkPreviewPressed; - private static Paint urlPaint; private int lastVisibleBlockNum = 0; private int firstVisibleBlockNum = 0; @@ -60,7 +56,6 @@ public class ChatMessageCell extends ChatBaseCell { private boolean hasLinkPreview; private int linkPreviewHeight; private boolean isInstagram; - private int smallImageX; private int descriptionY; private int durationWidth; private StaticLayout siteNameLayout; @@ -69,47 +64,9 @@ public class ChatMessageCell extends ChatBaseCell { private StaticLayout durationLayout; private StaticLayout authorLayout; private static TextPaint durationPaint; - private TLRPC.PhotoSize currentPhotoObject; - private TLRPC.PhotoSize currentPhotoObjectThumb; - private boolean imageCleared; private static Drawable igvideoDrawable; - private class MyPath extends Path { - - private StaticLayout currentLayout; - private int currentLine; - private float lastTop = -1; - - public void setCurrentLayout(StaticLayout layout, int start) { - currentLayout = layout; - currentLine = layout.getLineForOffset(start); - lastTop = -1; - } - - @Override - public void addRect(float left, float top, float right, float bottom, Direction dir) { - if (lastTop == -1) { - lastTop = top; - } else if (lastTop != top) { - lastTop = top; - currentLine++; - } - float lineRight = currentLayout.getLineRight(currentLine); - float lineLeft = currentLayout.getLineLeft(currentLine); - if (left >= lineRight) { - return; - } - if (right > lineRight) { - right = lineRight; - } - if (left < lineLeft) { - left = lineLeft; - } - super.addRect(left, top, right, bottom, dir); - } - } - public ChatMessageCell(Context context) { super(context); drawForwardedName = true; @@ -120,35 +77,27 @@ public class ChatMessageCell extends ChatBaseCell { } } - private void resetPressedLink() { - if (pressedLink != null) { - pressedLink = null; - } - linkPreviewPressed = false; - invalidate(); - } - @Override public boolean onTouchEvent(MotionEvent event) { boolean result = false; if (currentMessageObject != null && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty() && currentMessageObject.messageText instanceof Spannable && !isPressed) { if (event.getAction() == MotionEvent.ACTION_DOWN || (linkPreviewPressed || pressedLink != null) && event.getAction() == MotionEvent.ACTION_UP) { - int x = (int)event.getX(); - int y = (int)event.getY(); + int x = (int) event.getX(); + int y = (int) event.getY(); if (x >= textX && y >= textY && x <= textX + currentMessageObject.textWidth && y <= textY + currentMessageObject.textHeight) { y -= textY; int blockNum = Math.max(0, y / currentMessageObject.blockHeight); if (blockNum < currentMessageObject.textLayoutBlocks.size()) { try { MessageObject.TextLayoutBlock block = currentMessageObject.textLayoutBlocks.get(blockNum); - x -= textX - (int)Math.ceil(block.textXOffset); + x -= textX - (int) Math.ceil(block.textXOffset); y -= block.textYOffset; final int line = block.textLayout.getLineForVertical(y); final int off = block.textLayout.getOffsetForHorizontal(line, x) + block.charactersOffset; final float left = block.textLayout.getLineLeft(line); if (left <= x && left + block.textLayout.getLineWidth(line) >= x) { - Spannable buffer = (Spannable)currentMessageObject.messageText; + Spannable buffer = (Spannable) currentMessageObject.messageText; ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { if (event.getAction() == MotionEvent.ACTION_DOWN) { @@ -320,7 +269,7 @@ public class ChatMessageCell extends ChatBaseCell { pos--; if (stringBuilder.charAt(pos + addedChars) == ' ') { stringBuilder.replace(pos + addedChars, pos + addedChars + 1, "\n"); - } else { + } else if (stringBuilder.charAt(pos + addedChars) != '\n') { stringBuilder.insert(pos + addedChars, "\n"); addedChars++; } @@ -333,7 +282,7 @@ public class ChatMessageCell extends ChatBaseCell { @Override protected boolean isUserDataChanged() { - if (imageCleared || !hasLinkPreview && currentMessageObject.messageOwner.media != null && currentMessageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage) { + if (!hasLinkPreview && currentMessageObject.messageOwner.media != null && currentMessageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage) { return true; } //suppress warning @@ -343,14 +292,13 @@ public class ChatMessageCell extends ChatBaseCell { @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - if (linkImageView != null) { - linkImageView.clearImage(); - if (currentPhotoObject != null) { - imageCleared = true; - currentPhotoObject = null; - currentPhotoObjectThumb = null; - } - } + linkImageView.onDetachedFromWindow(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + linkImageView.onAttachedToWindow(); } @Override @@ -365,16 +313,12 @@ public class ChatMessageCell extends ChatBaseCell { resetPressedLink(); linkPreviewPressed = false; linkPreviewHeight = 0; - smallImageX = 0; isInstagram = false; durationLayout = null; descriptionLayout = null; titleLayout = null; siteNameLayout = null; authorLayout = null; - currentPhotoObject = null; - imageCleared = false; - currentPhotoObjectThumb = null; int maxWidth; if (AndroidUtilities.isTablet()) { @@ -427,13 +371,19 @@ public class ChatMessageCell extends ChatBaseCell { linkPreviewMaxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80); } } + + TLRPC.TL_webPage webPage = (TLRPC.TL_webPage) messageObject.messageOwner.media.webpage; + + if (webPage.site_name != null && webPage.photo != null && webPage.site_name.toLowerCase().equals("instagram")) { + linkPreviewMaxWidth = Math.max(AndroidUtilities.displaySize.y / 3, currentMessageObject.textWidth); + } + int additinalWidth = AndroidUtilities.dp(10); int restLinesCount = 3; int additionalHeight = 0; linkPreviewMaxWidth -= additinalWidth; hasLinkPreview = true; - TLRPC.TL_webPage webPage = (TLRPC.TL_webPage) messageObject.messageOwner.media.webpage; if (currentMessageObject.photoThumbs == null && webPage.photo != null) { currentMessageObject.generateThumbs(true); @@ -477,7 +427,6 @@ public class ChatMessageCell extends ChatBaseCell { for (int a = 0; a < titleLayout.getLineCount(); a++) { int width = (int) Math.ceil(titleLayout.getLineWidth(a)); if (a < restLines) { - smallImageX = Math.max(smallImageX, width); width += AndroidUtilities.dp(48 + 2); } maxChildWidth = Math.max(maxChildWidth, width + additinalWidth); @@ -529,7 +478,6 @@ public class ChatMessageCell extends ChatBaseCell { for (int a = 0; a < descriptionLayout.getLineCount(); a++) { int width = (int) Math.ceil(descriptionLayout.getLineWidth(a)); if (a < restLines) { - smallImageX = Math.max(smallImageX, width); width += AndroidUtilities.dp(48 + 2); } maxChildWidth = Math.max(maxChildWidth, width + additinalWidth); @@ -546,8 +494,8 @@ public class ChatMessageCell extends ChatBaseCell { isSmallImage = false; } int maxPhotoWidth = smallImage ? AndroidUtilities.dp(48) : linkPreviewMaxWidth; - currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, maxPhotoWidth); - currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); + TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, maxPhotoWidth, true); + TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); if (currentPhotoObjectThumb == currentPhotoObject) { currentPhotoObjectThumb = null; } @@ -573,10 +521,12 @@ public class ChatMessageCell extends ChatBaseCell { float scale = width / (float) maxPhotoWidth; width /= scale; height /= scale; + if (webPage.site_name != null && !webPage.site_name.toLowerCase().equals("instagram")) { if (height > AndroidUtilities.displaySize.y / 3) { height = AndroidUtilities.displaySize.y / 3; } } + } if (isSmallImage) { if (AndroidUtilities.dp(50) + additionalHeight > linkPreviewHeight) { totalHeight += AndroidUtilities.dp(50) + additionalHeight - linkPreviewHeight + AndroidUtilities.dp(8); @@ -767,7 +717,7 @@ public class ChatMessageCell extends ChatBaseCell { } if (isSmallImage) { - linkImageView.setImageCoords(textX + smallImageX + AndroidUtilities.dp(12), smallImageStartY, linkImageView.getImageWidth(), linkImageView.getImageHeight()); + linkImageView.setImageCoords(textX + backgroundWidth - AndroidUtilities.dp(77), smallImageStartY, linkImageView.getImageWidth(), linkImageView.getImageHeight()); } else { linkImageView.setImageCoords(textX + AndroidUtilities.dp(10), linkPreviewY, linkImageView.getImageWidth(), linkImageView.getImageHeight()); } @@ -783,8 +733,8 @@ public class ChatMessageCell extends ChatBaseCell { if (durationLayout != null) { int x = linkImageView.getImageX() + linkImageView.getImageWidth() - AndroidUtilities.dp(8) - durationWidth; int y = linkImageView.getImageY() + linkImageView.getImageHeight() - AndroidUtilities.dp(19); - mediaBackgroundDrawable.setBounds(x - AndroidUtilities.dp(4), y - AndroidUtilities.dp(1.5f), x + durationWidth + AndroidUtilities.dp(4), y + AndroidUtilities.dp(14.5f)); - mediaBackgroundDrawable.draw(canvas); + ResourceLoader.mediaBackgroundDrawable.setBounds(x - AndroidUtilities.dp(4), y - AndroidUtilities.dp(1.5f), x + durationWidth + AndroidUtilities.dp(4), y + AndroidUtilities.dp(14.5f)); + ResourceLoader.mediaBackgroundDrawable.draw(canvas); canvas.save(); canvas.translate(x, y); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index ed8f4ffc..54da1ecf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -37,6 +37,7 @@ import org.telegram.ui.Components.AvatarDrawable; public class DialogCell extends BaseCell { private static TextPaint namePaint; + private static TextPaint groupPaint; private static TextPaint nameEncryptedPaint; private static TextPaint nameUnknownPaint; private static TextPaint messagePaint; @@ -55,14 +56,6 @@ public class DialogCell extends BaseCell { private static Drawable broadcastDrawable; private static Drawable muteDrawable; - private static Drawable checkWhiteDrawable; - private static Drawable halfCheckWhiteDrawable; - private static Drawable countWhiteDrawable; - private static Drawable lockWhiteDrawable; - private static Drawable groupWhiteDrawable; - private static Drawable broadcastWhiteDrawable; - //private static Drawable muteWhiteDrawable; - private static Paint linePaint; private long currentDialogId; @@ -123,6 +116,10 @@ public class DialogCell extends BaseCell { private int avatarTop = AndroidUtilities.dp(10); + private int avatarSize = AndroidUtilities.dp(52); + + private int avatarLeftMargin; + private void init() { if (namePaint == null) { namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); @@ -130,6 +127,11 @@ public class DialogCell extends BaseCell { namePaint.setColor(0xff212121); namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + groupPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); + groupPaint.setTextSize(AndroidUtilities.dp(17)); + groupPaint.setColor(0xff212121); + groupPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); nameEncryptedPaint.setTextSize(AndroidUtilities.dp(17)); nameEncryptedPaint.setColor(0xff00a60e); @@ -175,20 +177,6 @@ public class DialogCell extends BaseCell { broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast); muteDrawable = getResources().getDrawable(R.drawable.mute_grey); - checkWhiteDrawable = getResources().getDrawable(R.drawable.dialogs_check_white); - checkDrawable = checkWhiteDrawable; - halfCheckWhiteDrawable = getResources().getDrawable(R.drawable.dialogs_halfcheck_white); - halfCheckDrawable = halfCheckWhiteDrawable; - countWhiteDrawable = getResources().getDrawable(R.drawable.dialogs_badge_white); - countDrawable = countWhiteDrawable; - lockWhiteDrawable = getResources().getDrawable(R.drawable.list_secret_white); - lockDrawable = lockWhiteDrawable; - groupWhiteDrawable = getResources().getDrawable(R.drawable.list_group_white); - groupDrawable = groupWhiteDrawable; - broadcastWhiteDrawable = getResources().getDrawable(R.drawable.list_broadcast_white); - broadcastDrawable = broadcastWhiteDrawable; - //muteWhiteDrawable = getResources().getDrawable(R.drawable.mute_white); - //muteDrawable = muteWhiteDrawable; updateTheme(); } } @@ -229,9 +217,13 @@ public class DialogCell extends BaseCell { @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - if (avatarImage != null) { - avatarImage.clearImage(); - } + avatarImage.onDetachedFromWindow(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + avatarImage.onAttachedToWindow(); } @Override @@ -377,28 +369,42 @@ public class DialogCell extends BaseCell { checkMessage = false; SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int defColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); - String hexColor = String.format("#%08X", (0xFFFFFFFF & defColor)); - String hexMsgColor = String.format("#%08X", (0xFFFFFFFF & themePrefs.getInt("chatsMessageColor", 0xff8f8f8f))); + //String hexColor = String.format("#%08X", (0xFFFFFFFF & defColor)); + String hexMsgColor = String.format("#%08X", (0xFFFFFFFF & themePrefs.getInt("chatsMessageColor", 0xff808080))); String hexDarkColor = String.format("#%08X", (0xFFFFFFFF & themePrefs.getInt("chatsMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)))); - if (message.messageOwner.media != null && !message.isMediaEmpty()) { - currentMessagePaint = messagePrintingPaint; - //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); - messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + if (message.caption != null) { + String mess = message.caption.toString(); + if (mess.length() > 150) { + mess = mess.substring(0, 150); + } + mess = mess.replace("\n", " "); //hexMsgColor //hexMsgColor + //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); } else { - if (message.messageOwner.message != null) { - String mess = message.messageOwner.message; - if (mess.length() > 150) { - mess = mess.substring(0, 150); + if (message.messageOwner.media != null && !message.isMediaEmpty()) { + currentMessagePaint = messagePrintingPaint; + //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + } else { + if (message.messageOwner.message != null) { + String mess = message.messageOwner.message; + if (mess.length() > 150) { + mess = mess.substring(0, 150); + } + mess = mess.replace("\n", " "); + //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); } - mess = mess.replace("\n", " "); - //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); - messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); } } } else { - messageString = message.messageText; - if (message.messageOwner.media != null && !message.isMediaEmpty()) { - currentMessagePaint = messagePrintingPaint; + if (message.caption != null) { + messageString = message.caption; + } else { + messageString = message.messageText; + if (message.messageOwner.media != null && !message.isMediaEmpty()) { + currentMessagePaint = messagePrintingPaint; + } } } } @@ -452,6 +458,7 @@ public class DialogCell extends BaseCell { if (chat != null) { nameString = chat.title; + currentNamePaint = groupPaint; } else if (user != null) { if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) { if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) { @@ -542,12 +549,16 @@ public class DialogCell extends BaseCell { int avatarLeft; if (!LocaleController.isRTL) { messageLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline); - avatarLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 13 : 9); + //avatarLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 13 : 9); + avatarLeft = avatarLeftMargin; } else { messageLeft = AndroidUtilities.dp(16); - avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.isTablet() ? 65 : 61); + //avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.isTablet() ? 65 : 61); + avatarLeft = getMeasuredWidth() - avatarSize - avatarLeftMargin; } - avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(52), AndroidUtilities.dp(52)); + //avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(52), AndroidUtilities.dp(52)); + avatarTop = (getMeasuredHeight() - (avatarSize)) / 2; + avatarImage.setImageCoords(avatarLeft, avatarTop, avatarSize, avatarSize); if (drawError) { int w = errorDrawable.getIntrinsicWidth() + AndroidUtilities.dp(8); messageWidth -= w; @@ -677,12 +688,14 @@ public class DialogCell extends BaseCell { if (mask != 0) { boolean continueUpdate = false; - if (isDialogCell && (mask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) { + if (isDialogCell) { + if ((mask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) { CharSequence printString = MessagesController.getInstance().printingStrings.get(currentDialogId); if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) { continueUpdate = true; } } + } if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_AVATAR) != 0) { if (chat == null) { continueUpdate = true; @@ -777,16 +790,23 @@ public class DialogCell extends BaseCell { private void updateTheme(){ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); - int dColor = AndroidUtilities.getIntDarkerColor("themeColor",0x15); + int dColor = AndroidUtilities.getIntDarkerColor("themeColor", 0x15); + + int nColor = themePrefs.getInt("chatsNameColor", 0xff212121); namePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17))); - namePaint.setColor(themePrefs.getInt("chatsNameColor", 0xff212121)); + namePaint.setColor(nColor); + + groupPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsGroupNameSize", themePrefs.getInt("chatsNameSize", 17)))); + groupPaint.setColor(themePrefs.getInt("chatsGroupNameColor", nColor)); + + lockDrawable.setColorFilter(themePrefs.getInt("chatsNameColor", tColor), PorterDuff.Mode.SRC_IN); nameEncryptedPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17))); nameEncryptedPaint.setColor(themePrefs.getInt("chatsNameColor", dColor));//0xff00a60e nameUnknownPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17))); - nameUnknownPaint.setColor(themePrefs.getInt("chatsNameColor", 0xff000000));//0xff4d83b3 + nameUnknownPaint.setColor(themePrefs.getInt("chatsUnknownNameColor", nColor));//0xff4d83b3 messagePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16))); messagePaint.setColor(themePrefs.getInt("chatsMessageColor", 0xff8f8f8f)); @@ -803,16 +823,15 @@ public class DialogCell extends BaseCell { countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13))); countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff)); - checkWhiteDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.MULTIPLY); - halfCheckWhiteDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.MULTIPLY); + checkDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.SRC_IN); + halfCheckDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.SRC_IN); clockDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.SRC_IN); - countWhiteDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.MULTIPLY); - lockWhiteDrawable.setColorFilter(dColor, PorterDuff.Mode.MULTIPLY); + countDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.SRC_IN); - int nColor = themePrefs.getInt("chatsNameColor", 0xff000000); - groupWhiteDrawable.setColorFilter(nColor, PorterDuff.Mode.MULTIPLY); - broadcastWhiteDrawable.setColorFilter(nColor, PorterDuff.Mode.MULTIPLY); + nColor = themePrefs.getInt("chatsNameColor", 0xff000000); + groupDrawable.setColorFilter(nColor, PorterDuff.Mode.SRC_IN); + broadcastDrawable.setColorFilter(nColor, PorterDuff.Mode.SRC_IN); int mColor = themePrefs.getInt("chatsMuteColor", 0xffa8a8a8); //muteWhiteDrawable.setColorFilter(mColor, PorterDuff.Mode.MULTIPLY); @@ -823,6 +842,8 @@ public class DialogCell extends BaseCell { int radius = AndroidUtilities.dp(themePrefs.getInt("chatsAvatarRadius", 32)); if(avatarImage != null)avatarImage.setRoundRadius(radius); if(avatarDrawable != null)avatarDrawable.setRadius(radius); + avatarSize = AndroidUtilities.dp(themePrefs.getInt("chatsAvatarSize", 52)); + avatarLeftMargin = AndroidUtilities.dp(themePrefs.getInt("chatsAvatarMarginLeft", AndroidUtilities.isTablet() ? 13 : 9)); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java index 62a42f58..e30a7258 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java @@ -13,7 +13,6 @@ import android.graphics.Canvas; import android.graphics.Paint; import org.telegram.android.AndroidUtilities; -import org.telegram.ui.LaunchActivity; public class DividerCell extends BaseCell { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java index 0b7fab23..23c7d957 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java @@ -17,6 +17,7 @@ import android.widget.FrameLayout; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.ui.Components.LayoutHelper; public class DrawerActionCell extends FrameLayout { @@ -36,8 +37,8 @@ public class DrawerActionCell extends FrameLayout { textView.setCompoundDrawablePadding(AndroidUtilities.dp(34)); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(14); layoutParams.rightMargin = AndroidUtilities.dp(16); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java index 907e88f7..c3e3fb33 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java @@ -37,6 +37,7 @@ import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.PhotoViewer; public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoViewerProvider{ @@ -59,7 +60,7 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV shadowView.setImageResource(R.drawable.bottom_shadow); addView(shadowView); LayoutParams layoutParams = (FrameLayout.LayoutParams) shadowView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(70); layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM; shadowView.setLayoutParams(layoutParams); @@ -99,8 +100,8 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV nameTextView.setGravity(Gravity.LEFT); addView(nameTextView); layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.bottomMargin = AndroidUtilities.dp(28); @@ -116,8 +117,8 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV phoneTextView.setGravity(Gravity.LEFT); addView(phoneTextView); layoutParams = (FrameLayout.LayoutParams) phoneTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.bottomMargin = AndroidUtilities.dp(9); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java index fd06f4e8..0458b98f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java @@ -11,8 +11,6 @@ package org.telegram.ui.Cells; import android.content.Context; import android.widget.FrameLayout; -import org.telegram.android.AndroidUtilities; - public class EmptyCell extends FrameLayout { int cellHeight; @@ -33,6 +31,6 @@ public class EmptyCell extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(cellHeight), MeasureSpec.EXACTLY)); + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(cellHeight, MeasureSpec.EXACTLY)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java index 51230b90..cfc2fe5f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java @@ -16,6 +16,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.ui.Components.LayoutHelper; public class GreySectionCell extends FrameLayout { private TextView textView; @@ -32,8 +33,8 @@ public class GreySectionCell extends FrameLayout { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)textView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.rightMargin = AndroidUtilities.dp(16); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java index 3cc09042..d69e7160 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java @@ -8,9 +8,7 @@ package org.telegram.ui.Cells; -import android.app.Activity; import android.content.Context; -import android.content.SharedPreferences; import android.util.AttributeSet; import android.util.TypedValue; import android.view.Gravity; @@ -19,6 +17,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.ui.Components.LayoutHelper; public class HeaderCell extends FrameLayout { @@ -35,8 +34,8 @@ public class HeaderCell extends FrameLayout { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)textView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.topMargin = AndroidUtilities.dp(15); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java index 36617a24..adbda020 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java @@ -16,6 +16,7 @@ import android.widget.FrameLayout; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.ui.Components.LayoutHelper; public class LetterSectionCell extends FrameLayout { @@ -32,8 +33,8 @@ public class LetterSectionCell extends FrameLayout { textView.setGravity(Gravity.CENTER); addView(textView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)textView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; textView.setLayoutParams(layoutParams); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java index a98c5a0c..aad139aa 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java @@ -14,6 +14,7 @@ import android.widget.FrameLayout; import android.widget.ProgressBar; import org.telegram.android.AndroidUtilities; +import org.telegram.ui.Components.LayoutHelper; public class LoadingCell extends FrameLayout { @@ -23,8 +24,8 @@ public class LoadingCell extends FrameLayout { ProgressBar progressBar = new ProgressBar(context); addView(progressBar); LayoutParams layoutParams = (FrameLayout.LayoutParams) progressBar.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressBar.setLayoutParams(layoutParams); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java index 25d67fe4..f723a537 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java @@ -17,6 +17,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; public class PhotoEditToolCell extends FrameLayoutFixed { @@ -31,8 +32,8 @@ public class PhotoEditToolCell extends FrameLayoutFixed { iconImage.setScaleType(ImageView.ScaleType.CENTER); addView(iconImage); LayoutParams layoutParams = (LayoutParams) iconImage.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.bottomMargin = AndroidUtilities.dp(12); iconImage.setLayoutParams(layoutParams); @@ -46,8 +47,8 @@ public class PhotoEditToolCell extends FrameLayoutFixed { nameTextView.setEllipsize(TextUtils.TruncateAt.END); addView(nameTextView); layoutParams = (LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM; layoutParams.leftMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(4); @@ -59,8 +60,8 @@ public class PhotoEditToolCell extends FrameLayoutFixed { valueTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); addView(valueTextView); layoutParams = (LayoutParams) valueTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.LEFT | Gravity.TOP; layoutParams.leftMargin = AndroidUtilities.dp(57); layoutParams.topMargin = AndroidUtilities.dp(3); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java index 16540b5d..d469e950 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java @@ -23,6 +23,7 @@ import org.telegram.android.MediaController; import org.telegram.messenger.R; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; public class PhotoPickerAlbumsCell extends FrameLayoutFixed { @@ -48,8 +49,8 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed { imageView = new BackupImageView(context); addView(imageView); LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; imageView.setLayoutParams(layoutParams); LinearLayout linearLayout = new LinearLayout(context); @@ -57,7 +58,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed { linearLayout.setBackgroundColor(0x7f000000); addView(linearLayout); layoutParams = (LayoutParams) linearLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(28); layoutParams.gravity = Gravity.BOTTOM; linearLayout.setLayoutParams(layoutParams); @@ -72,7 +73,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed { linearLayout.addView(nameTextView); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) nameTextView.getLayoutParams(); layoutParams1.width = 0; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.leftMargin = AndroidUtilities.dp(8); layoutParams1.weight = 1; nameTextView.setLayoutParams(layoutParams1); @@ -86,8 +87,8 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed { countTextView.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView(countTextView); layoutParams1 = (LinearLayout.LayoutParams) countTextView.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.leftMargin = AndroidUtilities.dp(4); layoutParams1.rightMargin = AndroidUtilities.dp(4); countTextView.setLayoutParams(layoutParams1); @@ -96,8 +97,8 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed { selector.setBackgroundResource(R.drawable.list_selector); addView(selector); layoutParams = (LayoutParams) selector.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; selector.setLayoutParams(layoutParams); } @@ -149,7 +150,11 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed { albumView.imageView.setOrientation(0, true); if (albumEntry.coverPhoto != null && albumEntry.coverPhoto.path != null) { albumView.imageView.setOrientation(albumEntry.coverPhoto.orientation, true); - albumView.imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, getContext().getResources().getDrawable(R.drawable.nophotos)); + if (albumEntry.coverPhoto.isVideo) { + albumView.imageView.setImage("vthumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, getContext().getResources().getDrawable(R.drawable.nophotos)); + } else { + albumView.imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, getContext().getResources().getDrawable(R.drawable.nophotos)); + } } else { albumView.imageView.setImageResource(R.drawable.nophotos); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java index f0043492..40005597 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java @@ -16,6 +16,7 @@ import org.telegram.android.AndroidUtilities; import org.telegram.messenger.R; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.CheckBox; +import org.telegram.ui.Components.LayoutHelper; public class PhotoPickerPhotoCell extends FrameLayout { @@ -30,8 +31,8 @@ public class PhotoPickerPhotoCell extends FrameLayout { photoImage = new BackupImageView(context); addView(photoImage); LayoutParams layoutParams = (LayoutParams) photoImage.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; photoImage.setLayoutParams(layoutParams); checkFrame = new FrameLayout(context); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java index e24419ed..bc3ce4f1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java @@ -23,6 +23,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; import org.telegram.messenger.R; +import org.telegram.ui.Components.LayoutHelper; public class PhotoPickerSearchCell extends LinearLayout { @@ -46,8 +47,8 @@ public class PhotoPickerSearchCell extends LinearLayout { selector.setBackgroundResource(R.drawable.list_selector); addView(selector); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) selector.getLayoutParams(); - layoutParams1.width = LayoutParams.MATCH_PARENT; - layoutParams1.height = LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; selector.setLayoutParams(layoutParams1); imageView = new ImageView(context); @@ -68,8 +69,8 @@ public class PhotoPickerSearchCell extends LinearLayout { textView1.setEllipsize(TextUtils.TruncateAt.END); addView(textView1); layoutParams1 = (FrameLayout.LayoutParams) textView1.getLayoutParams(); - layoutParams1.width = LayoutParams.MATCH_PARENT; - layoutParams1.height = LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.gravity = Gravity.TOP | Gravity.LEFT; layoutParams1.rightMargin = AndroidUtilities.dp(4); layoutParams1.leftMargin = AndroidUtilities.dp(51); @@ -85,8 +86,8 @@ public class PhotoPickerSearchCell extends LinearLayout { textView2.setEllipsize(TextUtils.TruncateAt.END); addView(textView2); layoutParams1 = (FrameLayout.LayoutParams) textView2.getLayoutParams(); - layoutParams1.width = LayoutParams.MATCH_PARENT; - layoutParams1.height = LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.gravity = Gravity.TOP | Gravity.LEFT; layoutParams1.leftMargin = AndroidUtilities.dp(51); layoutParams1.rightMargin = AndroidUtilities.dp(4); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java index a3af3d26..db6b4041 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java @@ -9,6 +9,7 @@ package org.telegram.ui.Cells; import android.content.Context; +import android.content.SharedPreferences; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.drawable.Drawable; @@ -23,6 +24,7 @@ import org.telegram.android.ContactsController; import org.telegram.android.ImageReceiver; import org.telegram.android.LocaleController; import org.telegram.android.MessagesController; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; @@ -81,7 +83,8 @@ public class ProfileSearchCell extends BaseCell { namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); namePaint.setTextSize(AndroidUtilities.dp(17)); //namePaint.setColor(0xff212121); - namePaint.setColor(AndroidUtilities.getIntDef("chatsNameColor", 0xff212121)); + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + namePaint.setColor(themePrefs.getInt("chatsNameColor", 0xff212121)); namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); @@ -118,10 +121,13 @@ public class ProfileSearchCell extends BaseCell { @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - if (avatarImage != null) { - avatarImage.clearImage(); - lastAvatar = null; - } + avatarImage.onDetachedFromWindow(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + avatarImage.onAttachedToWindow(); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java index a41172b0..92f83da3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java @@ -31,6 +31,7 @@ import org.telegram.messenger.TLRPC; import org.telegram.messenger.Utilities; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.CheckBox; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LineProgressView; import java.io.File; @@ -98,7 +99,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F addView(extTextView); layoutParams = (LayoutParams) extTextView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(32); - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(22); layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16); layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : 0; @@ -134,8 +135,8 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(nameTextView); layoutParams = (LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(5); layoutParams.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(72); layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(72) : AndroidUtilities.dp(8); @@ -146,8 +147,8 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F statusImageView.setVisibility(INVISIBLE); addView(statusImageView); layoutParams = (LayoutParams) statusImageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(35); layoutParams.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(72); layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(72) : AndroidUtilities.dp(8); @@ -164,8 +165,8 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F dateTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(dateTextView); layoutParams = (LayoutParams) dateTextView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(30); layoutParams.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(72); layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(72) : AndroidUtilities.dp(8); @@ -175,7 +176,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F progressView = new LineProgressView(context); addView(progressView); layoutParams = (LayoutParams) progressView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(2); layoutParams.topMargin = AndroidUtilities.dp(54); layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(72); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java index 4b7d29c5..7c39b0bf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java @@ -16,6 +16,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.ui.Components.LayoutHelper; public class SharedMediaSectionCell extends FrameLayout { @@ -31,8 +32,8 @@ public class SharedMediaSectionCell extends FrameLayout { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)textView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(13); layoutParams.rightMargin = AndroidUtilities.dp(13); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java index 7b6085d4..95463226 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java @@ -27,6 +27,7 @@ import org.telegram.messenger.TLRPC; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.CheckBox; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.PhotoViewer; public class SharedPhotoVideoCell extends FrameLayoutFixed { @@ -57,63 +58,36 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { imageView = new BackupImageView(context); imageView.getImageReceiver().setNeedsQualityThumb(true); imageView.getImageReceiver().setShouldGenerateQualityThumb(true); - addView(imageView); - LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; - imageView.setLayoutParams(layoutParams); + addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); videoInfoContainer = new LinearLayout(context); videoInfoContainer.setOrientation(LinearLayout.HORIZONTAL); videoInfoContainer.setBackgroundResource(R.drawable.phototime); videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0); videoInfoContainer.setGravity(Gravity.CENTER_VERTICAL); - addView(videoInfoContainer); - layoutParams = (LayoutParams) videoInfoContainer.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = AndroidUtilities.dp(16); - layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; - videoInfoContainer.setLayoutParams(layoutParams); + addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT)); ImageView imageView1 = new ImageView(context); imageView1.setImageResource(R.drawable.ic_video); videoInfoContainer.addView(imageView1); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) imageView1.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; imageView1.setLayoutParams(layoutParams1); videoTextView = new TextView(context); videoTextView.setTextColor(0xffffffff); videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); videoTextView.setGravity(Gravity.CENTER_VERTICAL); - videoInfoContainer.addView(videoTextView); - layoutParams1 = (LinearLayout.LayoutParams) videoTextView.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.leftMargin = AndroidUtilities.dp(4); - layoutParams1.gravity = Gravity.CENTER_VERTICAL; - layoutParams1.bottomMargin = AndroidUtilities.dp(1); - videoTextView.setLayoutParams(layoutParams1); + videoInfoContainer.addView(videoTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 4, 0, 0, 1)); selector = new View(context); selector.setBackgroundResource(R.drawable.list_selector); - addView(selector); - layoutParams = (LayoutParams) selector.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; - selector.setLayoutParams(layoutParams); + addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); checkBox = new CheckBox(context, R.drawable.round_check2); checkBox.setVisibility(INVISIBLE); - addView(checkBox); - layoutParams = (LayoutParams) checkBox.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(22); - layoutParams.height = AndroidUtilities.dp(22); - layoutParams.gravity = Gravity.RIGHT | Gravity.TOP; - layoutParams.topMargin = AndroidUtilities.dp(6); - layoutParams.rightMargin = AndroidUtilities.dp(6); - checkBox.setLayoutParams(layoutParams); + addView(checkBox, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 6, 0, 6, 0)); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java index a7fe6573..a184c40a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java @@ -19,6 +19,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.ui.Components.LayoutHelper; public class TextCell extends FrameLayout { @@ -40,8 +41,8 @@ public class TextCell extends FrameLayout { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; @@ -57,8 +58,8 @@ public class TextCell extends FrameLayout { valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); addView(valueTextView); layoutParams = (LayoutParams) valueTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 24 : 0); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 24); layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT; @@ -68,8 +69,8 @@ public class TextCell extends FrameLayout { imageView.setScaleType(ImageView.ScaleType.CENTER); addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL; @@ -79,8 +80,8 @@ public class TextCell extends FrameLayout { valueImageView.setScaleType(ImageView.ScaleType.CENTER); addView(valueImageView); layoutParams = (LayoutParams) valueImageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 24 : 0); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 24); layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java index 4e5da029..f49e6ea3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java @@ -19,6 +19,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.Switch; public class TextCheckCell extends FrameLayoutFixed { @@ -46,8 +47,8 @@ public class TextCheckCell extends FrameLayoutFixed { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; @@ -60,12 +61,18 @@ public class TextCheckCell extends FrameLayoutFixed { checkBox.setClickable(false); addView(checkBox); layoutParams = (LayoutParams) checkBox.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(14); layoutParams.rightMargin = AndroidUtilities.dp(14); layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL; checkBox.setLayoutParams(layoutParams); + //setDarkTheme(); + } + + private void setDarkTheme(){ + textView.setTextColor(0xff747474); + paint.setColor(0xff474747); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java index 59b6c9e6..348e5b7b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java @@ -22,6 +22,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; import org.telegram.messenger.R; +import org.telegram.ui.Components.LayoutHelper; public class TextColorCell extends FrameLayout { private TextView textView; @@ -48,8 +49,8 @@ public class TextColorCell extends FrameLayout { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java index d9921211..60a4f44a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java @@ -19,6 +19,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.ui.Components.LayoutHelper; public class TextDetailCell extends FrameLayout { @@ -38,8 +39,8 @@ public class TextDetailCell extends FrameLayout { textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); addView(textView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(10); layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16); @@ -55,8 +56,8 @@ public class TextDetailCell extends FrameLayout { valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); addView(valueTextView); layoutParams = (FrameLayout.LayoutParams) valueTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(35); layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 71 : 16); @@ -67,8 +68,8 @@ public class TextDetailCell extends FrameLayout { imageView.setScaleType(ImageView.ScaleType.CENTER); addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java index 4d62db65..1ac52592 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java @@ -18,6 +18,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; public class TextDetailSettingsCell extends FrameLayoutFixed { @@ -45,8 +46,8 @@ public class TextDetailSettingsCell extends FrameLayoutFixed { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(10); layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); @@ -63,8 +64,8 @@ public class TextDetailSettingsCell extends FrameLayoutFixed { valueTextView.setPadding(0, 0, 0, 0); addView(valueTextView); layoutParams = (LayoutParams) valueTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(35); layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java index ba7bd11a..3320db1c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java @@ -15,6 +15,7 @@ import android.widget.FrameLayout; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.LaunchActivity; public class TextInfoCell extends FrameLayout { @@ -31,12 +32,17 @@ public class TextInfoCell extends FrameLayout { textView.setPadding(0, AndroidUtilities.dp(19), 0, AndroidUtilities.dp(19)); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.gravity = Gravity.CENTER; textView.setLayoutParams(layoutParams); + //setDarkTheme(); + } + + private void setDarkTheme(){ + textView.setTextColor(0xff5c5c5c); } @Override @@ -51,12 +57,12 @@ public class TextInfoCell extends FrameLayout { public void setText(String text) { textView.setText(text); } -/* + public void setTextColor(int color) { textView.setTextColor(color); } public void setTextSize(int size) { textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP,size); - }*/ + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java index 6c8bcffa..8ba0f723 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java @@ -16,6 +16,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.ui.Components.LayoutHelper; public class TextInfoPrivacyCell extends FrameLayout { @@ -31,8 +32,8 @@ public class TextInfoPrivacyCell extends FrameLayout { textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(17)); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java index a6ccb507..94f927ea 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java @@ -20,6 +20,7 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; +import org.telegram.ui.Components.LayoutHelper; public class TextSettingsCell extends FrameLayout { @@ -48,8 +49,8 @@ public class TextSettingsCell extends FrameLayout { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; @@ -66,8 +67,8 @@ public class TextSettingsCell extends FrameLayout { valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); addView(valueTextView); layoutParams = (LayoutParams) valueTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(17); layoutParams.rightMargin = AndroidUtilities.dp(17); layoutParams.gravity = LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT; @@ -78,12 +79,18 @@ public class TextSettingsCell extends FrameLayout { valueImageView.setVisibility(INVISIBLE); addView(valueImageView); layoutParams = (LayoutParams) valueImageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 17 : 0); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 17); layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL; valueImageView.setLayoutParams(layoutParams); + //setDarkTheme(); + } + + private void setDarkTheme(){ + textView.setTextColor(0xff747474); + paint.setColor(0xff474747); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java index 15fae3f8..61e71e2c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java @@ -11,12 +11,9 @@ package org.telegram.ui.Cells; import android.content.Context; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; -import android.text.TextUtils; -import android.util.TypedValue; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.ContactsController; @@ -30,12 +27,14 @@ import org.telegram.messenger.UserConfig; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.CheckBox; +import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.SimpleTextView; public class UserCell extends FrameLayout { private BackupImageView avatarImageView; - private TextView nameTextView; - private TextView statusTextView; + private SimpleTextView nameTextView; + private SimpleTextView statusTextView; private ImageView imageView; private CheckBox checkBox; @@ -62,76 +61,31 @@ public class UserCell extends FrameLayout { public UserCell(Context context, int padding) { super(context); - avatarImageView = new BackupImageView(context); - avatarImageView.setRoundRadius(AndroidUtilities.dp(24)); - addView(avatarImageView); - LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(48); - layoutParams.height = AndroidUtilities.dp(48); - layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; - layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(7 + padding); - layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(7 + padding) : 0; - layoutParams.topMargin = AndroidUtilities.dp(8); - avatarImageView.setLayoutParams(layoutParams); avatarDrawable = new AvatarDrawable(); - nameTextView = new TextView(context); - nameTextView.setTextColor(0xff212121); - nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); - nameTextView.setLines(1); - nameTextView.setMaxLines(1); - nameTextView.setSingleLine(true); - nameTextView.setEllipsize(TextUtils.TruncateAt.END); - nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); - addView(nameTextView); - layoutParams = (LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : (68 + padding)); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68 + padding) : 16); - layoutParams.topMargin = AndroidUtilities.dp(10.5f); - layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; - nameTextView.setLayoutParams(layoutParams); + avatarImageView = new BackupImageView(context); + avatarImageView.setRoundRadius(AndroidUtilities.dp(24)); + addView(avatarImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 7 + padding, 8, LocaleController.isRTL ? 7 + padding : 0, 0)); - statusTextView = new TextView(context); - statusTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - statusTextView.setLines(1); - statusTextView.setMaxLines(1); - statusTextView.setSingleLine(true); - statusTextView.setEllipsize(TextUtils.TruncateAt.END); - statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); - addView(statusTextView); - layoutParams = (LayoutParams) statusTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : (68 + padding)); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68 + padding) : 16); - layoutParams.topMargin = AndroidUtilities.dp(33.5f); - layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; - statusTextView.setLayoutParams(layoutParams); + nameTextView = new SimpleTextView(context); + nameTextView.setTextColor(0xff212121); + nameTextView.setTextSize(17); + nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); + addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : (68 + padding), 11.5f, LocaleController.isRTL ? (68 + padding) : 28, 0)); + + statusTextView = new SimpleTextView(context); + statusTextView.setTextSize(14); + statusTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); + addView(statusTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : (68 + padding), 34.5f, LocaleController.isRTL ? (68 + padding) : 28, 0)); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); - addView(imageView); - layoutParams = (LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); - layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL; - imageView.setLayoutParams(layoutParams); + imageView.setVisibility(GONE); + addView(imageView, LayoutHelper.createFrame(LayoutParams.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 0 : 16, 0, LocaleController.isRTL ? 16 : 0, 0)); checkBox = new CheckBox(context, R.drawable.round_check2); checkBox.setVisibility(INVISIBLE); - addView(checkBox); - layoutParams = (LayoutParams) checkBox.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(22); - layoutParams.height = AndroidUtilities.dp(22); - layoutParams.topMargin = AndroidUtilities.dp(38); - layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(37 + padding); - layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(37 + padding) : 0; - layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); - checkBox.setLayoutParams(layoutParams); + addView(checkBox, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 37 + padding, 38, LocaleController.isRTL ? 37 + padding : 0, 0)); } public void setData(TLRPC.User user, CharSequence name, CharSequence status, int resId) { @@ -158,12 +112,6 @@ public class UserCell extends FrameLayout { checkBox.setChecked(checked, animated); } - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - lastAvatar = null; - } - @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), MeasureSpec.EXACTLY)); @@ -179,6 +127,7 @@ public class UserCell extends FrameLayout { return; } TLRPC.FileLocation photo = null; + String newName = null; if (currentUser.photo != null) { photo = currentUser.photo.photo_small; } @@ -199,9 +148,9 @@ public class UserCell extends FrameLayout { continueUpdate = true; } } - if (!continueUpdate && (mask & MessagesController.UPDATE_MASK_NAME) != 0) { - String newName = currentUser.first_name + currentUser.last_name; - if (newName == null || !newName.equals(lastName)) { + if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) { + newName = ContactsController.formatName(currentUser.first_name, currentUser.last_name); + if (!newName.equals(lastName)) { continueUpdate = true; } } @@ -216,31 +165,36 @@ public class UserCell extends FrameLayout { } else { lastStatus = 0; } - lastName = currentUser.first_name + currentUser.last_name; - lastAvatar = photo; if (currentName != null) { + lastName = null; nameTextView.setText(currentName); } else { - nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); + lastName = newName == null ? ContactsController.formatName(currentUser.first_name, currentUser.last_name) : newName; + nameTextView.setText(lastName); nameTextView.setTextColor(nameColor); nameTextView.setTextSize(themePrefs.getInt("contactsNameSize", 17)); } if (currrntStatus != null) { - statusTextView.setText(currrntStatus); statusTextView.setTextColor(statusColor); + statusTextView.setText(currrntStatus); } else { if (currentUser.id == UserConfig.getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance().getCurrentTime()) { - statusTextView.setText(LocaleController.getString("Online", R.string.Online)); statusTextView.setTextColor(statusOnlineColor); + statusTextView.setText(LocaleController.getString("Online", R.string.Online)); } else { - statusTextView.setText(LocaleController.formatUserStatus(currentUser)); statusTextView.setTextColor(statusColor); + statusTextView.setText(LocaleController.formatUserStatus(currentUser)); } } + + if (imageView.getVisibility() == VISIBLE && currentDrawable == 0 || imageView.getVisibility() == GONE && currentDrawable != 0) { + imageView.setVisibility(currentDrawable == 0 ? GONE : VISIBLE); + imageView.setImageResource(currentDrawable); + } statusTextView.setTextSize(themePrefs.getInt("contactsStatusSize", 14)); - imageView.setVisibility(currentDrawable == 0 ? INVISIBLE : VISIBLE); - imageView.setImageResource(currentDrawable); + //imageView.setVisibility(currentDrawable == 0 ? INVISIBLE : VISIBLE); + //imageView.setImageResource(currentDrawable); if(curDrawable != null)imageView.setImageDrawable(curDrawable); //int radius = AndroidUtilities.dp(themePrefs.getInt("contactsAvatarRadius", 32)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java index f8d9adc3..ea8b0921 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java @@ -35,6 +35,7 @@ import org.telegram.messenger.TLRPC; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Components.LayoutHelper; public class ChangeChatNameActivity extends BaseFragment { @@ -120,7 +121,7 @@ public class ChangeChatNameActivity extends BaseFragment { layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; firstNameField.setLayoutParams(layoutParams); if (chat_id > 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java index 6a71bdd0..4d2ee04d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java @@ -39,6 +39,7 @@ import org.telegram.messenger.UserConfig; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Components.LayoutHelper; public class ChangeNameActivity extends BaseFragment { @@ -105,7 +106,7 @@ public class ChangeNameActivity extends BaseFragment { layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; firstNameField.setLayoutParams(layoutParams); firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override @@ -138,7 +139,7 @@ public class ChangeNameActivity extends BaseFragment { layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; lastNameField.setLayoutParams(layoutParams); lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java index 69b0622b..589e1d76 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java @@ -38,6 +38,10 @@ import android.widget.TextView; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.LocaleController; import org.telegram.android.MessagesController; import org.telegram.android.MessagesStorage; @@ -54,10 +58,7 @@ import org.telegram.messenger.UserConfig; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.SlideView; import org.telegram.ui.Components.TypefaceSpan; @@ -134,8 +135,8 @@ public class ChangePhoneActivity extends BaseFragment { views[0].setVisibility(View.VISIBLE); frameLayout.addView(views[0]); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) views[0].getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.leftMargin = AndroidUtilities.dp(16); layoutParams1.rightMargin = AndroidUtilities.dp(16); layoutParams1.topMargin = AndroidUtilities.dp(30); @@ -146,8 +147,8 @@ public class ChangePhoneActivity extends BaseFragment { views[1].setVisibility(View.GONE); frameLayout.addView(views[1]); layoutParams1 = (FrameLayout.LayoutParams) views[1].getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.leftMargin = AndroidUtilities.dp(16); layoutParams1.rightMargin = AndroidUtilities.dp(16); layoutParams1.topMargin = AndroidUtilities.dp(30); @@ -308,7 +309,7 @@ public class ChangePhoneActivity extends BaseFragment { countryButton.setBackgroundResource(R.drawable.spinner_states); addView(countryButton); LayoutParams layoutParams = (LayoutParams) countryButton.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); @@ -334,7 +335,7 @@ public class ChangePhoneActivity extends BaseFragment { view.setBackgroundColor(0xffdbdbdb); addView(view); layoutParams = (LayoutParams) view.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = 1; layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); @@ -345,8 +346,8 @@ public class ChangePhoneActivity extends BaseFragment { linearLayout.setOrientation(HORIZONTAL); addView(linearLayout); layoutParams = (LayoutParams) linearLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(20); linearLayout.setLayoutParams(layoutParams); @@ -356,8 +357,8 @@ public class ChangePhoneActivity extends BaseFragment { textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); linearLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(24); textView.setLayoutParams(layoutParams); @@ -449,7 +450,7 @@ public class ChangePhoneActivity extends BaseFragment { phoneField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI); linearLayout.addView(phoneField); layoutParams = (LayoutParams) phoneField.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(36); layoutParams.rightMargin = AndroidUtilities.dp(24); phoneField.setLayoutParams(layoutParams); @@ -519,8 +520,8 @@ public class ChangePhoneActivity extends BaseFragment { textView.setLineSpacing(AndroidUtilities.dp(2), 1.0f); addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); layoutParams.topMargin = AndroidUtilities.dp(28); @@ -749,8 +750,8 @@ public class ChangePhoneActivity extends BaseFragment { confirmTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f); addView(confirmTextView); LayoutParams layoutParams = (LayoutParams) confirmTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); @@ -768,7 +769,7 @@ public class ChangePhoneActivity extends BaseFragment { codeField.setPadding(0, 0, 0, 0); addView(codeField); layoutParams = (LayoutParams) codeField.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(36); layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(20); @@ -793,8 +794,8 @@ public class ChangePhoneActivity extends BaseFragment { timeText.setGravity(Gravity.LEFT); addView(timeText); layoutParams = (LayoutParams) timeText.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.LEFT; layoutParams.topMargin = AndroidUtilities.dp(30); layoutParams.leftMargin = AndroidUtilities.dp(24); @@ -805,8 +806,8 @@ public class ChangePhoneActivity extends BaseFragment { linearLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL); addView(linearLayout); layoutParams = (LayoutParams) linearLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; linearLayout.setLayoutParams(layoutParams); TextView wrongNumber = new TextView(context); @@ -818,8 +819,8 @@ public class ChangePhoneActivity extends BaseFragment { wrongNumber.setPadding(0, AndroidUtilities.dp(24), 0, 0); linearLayout.addView(wrongNumber); layoutParams = (LayoutParams) wrongNumber.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.bottomMargin = AndroidUtilities.dp(10); layoutParams.leftMargin = AndroidUtilities.dp(24); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java index 03d088be..a678fa63 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java @@ -31,6 +31,7 @@ import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Components.LayoutHelper; public class ChangePhoneHelpActivity extends BaseFragment { @@ -70,8 +71,8 @@ public class ChangePhoneHelpActivity extends BaseFragment { ScrollView scrollView = new ScrollView(context); relativeLayout.addView(scrollView); RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = RelativeLayout.LayoutParams.WRAP_CONTENT; + layoutParams3.width = LayoutHelper.MATCH_PARENT; + layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); scrollView.setLayoutParams(layoutParams3); @@ -88,8 +89,8 @@ public class ChangePhoneHelpActivity extends BaseFragment { imageView.setImageResource(R.drawable.phone_change); linearLayout.addView(imageView); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams(); - layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.width = LayoutHelper.WRAP_CONTENT; + layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; imageView.setLayoutParams(layoutParams2); @@ -106,8 +107,8 @@ public class ChangePhoneHelpActivity extends BaseFragment { } linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); - layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.width = LayoutHelper.WRAP_CONTENT; + layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); @@ -124,8 +125,8 @@ public class ChangePhoneHelpActivity extends BaseFragment { textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10)); linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); - layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.width = LayoutHelper.WRAP_CONTENT; + layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java index c9eb58de..edc71dae 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java @@ -46,6 +46,7 @@ import org.telegram.messenger.UserConfig; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; @@ -126,7 +127,7 @@ public class ChangeUsernameActivity extends BaseFragment { layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; firstNameField.setLayoutParams(layoutParams); if (user != null && user.username != null && user.username.length() > 0) { @@ -140,8 +141,8 @@ public class ChangeUsernameActivity extends BaseFragment { ((LinearLayout) fragmentView).addView(checkTextView); layoutParams = (LinearLayout.LayoutParams) checkTextView.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(12); - layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); @@ -155,8 +156,8 @@ public class ChangeUsernameActivity extends BaseFragment { ((LinearLayout) fragmentView).addView(helpTextView); layoutParams = (LinearLayout.LayoutParams) helpTextView.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(10); - layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 2ebdc1e3..a9332abd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -27,7 +27,6 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.provider.MediaStore; -import android.support.v7.widget.LinearLayoutManager; import android.text.TextUtils; import android.util.Base64; import android.util.SparseArray; @@ -40,7 +39,6 @@ import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.WindowManager; import android.webkit.MimeTypeMap; -import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ImageView; @@ -53,6 +51,10 @@ import android.widget.Toast; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.ContactsController; import org.telegram.android.Emoji; import org.telegram.android.ImageReceiver; @@ -66,6 +68,8 @@ import org.telegram.android.NotificationsController; import org.telegram.android.SecretChatHelper; import org.telegram.android.SendMessagesHelper; import org.telegram.android.query.ReplyMessageQuery; +import org.telegram.android.support.widget.LinearLayoutManager; +import org.telegram.android.support.widget.RecyclerView; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLoader; @@ -73,7 +77,6 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.RPCRequest; import org.telegram.messenger.SerializedData; -import org.telegram.messenger.TLClassStore; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; @@ -82,13 +85,8 @@ import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.MentionsAdapter; import org.telegram.ui.Adapters.StickersAdapter; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Cells.ChatActionCell; import org.telegram.ui.Cells.ChatAudioCell; import org.telegram.ui.Cells.ChatBaseCell; @@ -99,15 +97,18 @@ import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.ChatActivityEnterView; import org.telegram.ui.Components.FrameLayoutFixed; -import org.telegram.ui.Components.LayoutListView; +import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.RecordStatusDrawable; +import org.telegram.ui.Components.RecyclerExListView; import org.telegram.ui.Components.RecyclerListView; +import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.Components.SendingFileExDrawable; import org.telegram.ui.Components.SizeNotifierRelativeLayout; import org.telegram.ui.Components.TimerDrawable; import org.telegram.ui.Components.TypingDotsDrawable; import java.io.File; import java.io.IOException; -import java.io.RandomAccessFile; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -116,14 +117,16 @@ import java.util.concurrent.Semaphore; public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider { - private TLRPC.Chat currentChat; - private TLRPC.User currentUser; - private TLRPC.EncryptedChat currentEncryptedChat; + protected TLRPC.Chat currentChat; + protected TLRPC.User currentUser; + protected TLRPC.EncryptedChat currentEncryptedChat; private boolean userBlocked = false; + private ArrayList chatMessageCellsCache = new ArrayList<>(); + private ArrayList chatMediaCellsCache = new ArrayList<>(); + private FrameLayout progressView; private FrameLayout bottomOverlay; - private ChatAdapter chatAdapter; private ChatActivityEnterView chatActivityEnterView; private ImageView timeItem; private View timeItem2; @@ -132,11 +135,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private ActionBarMenuItem attachItem; private ActionBarMenuItem headerItem; private TextView addContactItem; - private LayoutListView chatListView; + private RecyclerExListView chatListView; + private LinearLayoutManager chatLayoutManager; + private ChatActivityAdapter chatAdapter; private BackupImageView avatarImageView; private TextView bottomOverlayChatText; private FrameLayout bottomOverlayChat; private TypingDotsDrawable typingDotsDrawable; + private RecordStatusDrawable recordStatusDrawable; + private SendingFileExDrawable sendingFileDrawable; private FrameLayout emptyViewContainer; private ArrayList actionModeViews = new ArrayList<>(); private TextView nameTextView; @@ -166,6 +173,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private MessageObject forwaringMessage; private MessageObject replyingMessageObject; private boolean paused = true; + private boolean wasPaused = false; private boolean readWhenResume = false; private TLRPC.FileLocation replyImageLocation; private long linkSearchRequestId; @@ -187,7 +195,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private HashMap messagesDict = new HashMap<>(); private HashMap> messagesByDays = new HashMap<>(); - private ArrayList messages = new ArrayList<>(); + protected ArrayList messages = new ArrayList<>(); private int maxMessageId = Integer.MAX_VALUE; private int minMessageId = Integer.MIN_VALUE; private int maxDate = Integer.MIN_VALUE; @@ -216,11 +224,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private String currentPicturePath; - private TLRPC.ChatParticipants info = null; + private Rect scrollRect = new Rect(); + + protected TLRPC.ChatParticipants info = null; private int onlineCount = -1; private CharSequence lastPrintString; private String lastStatus; + private int lastStatusDrawable; private long chatEnterTime = 0; private long chatLeaveTime = 0; @@ -253,19 +264,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private static boolean QuoteForward; - AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener() { + RecyclerExListView.OnItemLongClickListener onItemLongClickListener = new RecyclerExListView.OnItemLongClickListener() { @Override - public boolean onItemLongClick(AdapterView adapter, View view, int position, long id) { + public void onItemClick(View view, int position) { if (!actionBar.isActionModeShowed()) { createMenu(view, false); } - return true; } }; - AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() { + RecyclerExListView.OnItemClickListener onItemClickListener = new RecyclerExListView.OnItemClickListener() { @Override - public void onItemClick(AdapterView adapterView, View view, int i, long l) { + public void onItemClick(View view, int position) { if (actionBar.isActionModeShowed()) { processRowSelect(view); return; @@ -308,12 +318,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return false; } } - //Smart Notifications - if (chatId > 0){ - if (currentChat.sound_timestamps != null) - currentChat.sound_timestamps.clear(); - } - // if (chatId > 0) { dialog_id = -chatId; } else { @@ -419,7 +423,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not NotificationCenter.getInstance().addObserver(this, NotificationCenter.chatInfoDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated); - NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagesReadedEncrypted); + NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagesReadEncrypted); NotificationCenter.getInstance().addObserver(this, NotificationCenter.removeAllMessagesFromDialog); NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioProgressDidChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset); @@ -434,6 +438,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not NotificationCenter.getInstance().addObserver(this, NotificationCenter.didLoadedReplyMessages); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceivedWebpages); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceivedWebpagesInUpdates); + NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagesReadContent); super.onFragmentCreate(); @@ -456,6 +461,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not typingDotsDrawable = new TypingDotsDrawable(); typingDotsDrawable.setIsChat(currentChat != null); + recordStatusDrawable = new RecordStatusDrawable(); + recordStatusDrawable.setIsChat(currentChat != null); + sendingFileDrawable = new SendingFileExDrawable(); + sendingFileDrawable.setIsChat(currentChat != null); if (currentEncryptedChat != null && AndroidUtilities.getMyLayerVersion(currentEncryptedChat.layer) != SecretChatHelper.CURRENT_SECRET_CHAT_LAYER) { SecretChatHelper.getInstance().sendNotifyLayerMessage(currentEncryptedChat, null); @@ -482,7 +491,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageSendError); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.chatInfoDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesReadedEncrypted); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesReadEncrypted); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.removeAllMessagesFromDialog); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioProgressDidChanged); @@ -498,6 +507,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didLoadedReplyMessages); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceivedWebpages); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceivedWebpagesInUpdates); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesReadContent); if (AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true); @@ -521,9 +531,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public View createView(Context context, LayoutInflater inflater) { + for (int a = 0; a < 8; a++) { + chatMessageCellsCache.add(new ChatMessageCell(context)); + } + for (int a = 0; a < 4; a++) { + chatMediaCellsCache.add(new ChatMediaCell(context)); + } + lastPrintString = null; lastStatus = null; hasOwnBackground = true; + + ResourceLoader.loadRecources(context); + //actionBar.setBackButtonImage(R.drawable.ic_ab_back); Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); @@ -560,6 +580,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } if (id == -1) { + if (chatActivityEnterView != null) { + chatActivityEnterView.hideEmojiPopup(); + } finishFragment(); } else if (id == -2) { selectedMessagesIds.clear(); @@ -579,11 +602,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not FileLog.e("tmessages", e); } } else if (id == attach_gallery) { - PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false); + PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, ChatActivity.this); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override - public void didSelectPhotos(ArrayList photos, ArrayList webPhotos) { - SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject); + public void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos) { + SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject, captions); SendMessagesHelper.prepareSendingPhotosSearch(webPhotos, dialog_id, replyingMessageObject); showReplyPanel(false, null, null, null, false, true); } @@ -591,21 +614,36 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void startPhotoSelectActivity() { try { + Intent videoPickerIntent = new Intent(); + videoPickerIntent.setType("video/*"); + videoPickerIntent.setAction(Intent.ACTION_GET_CONTENT); + videoPickerIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1536)); + Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); - startActivityForResult(photoPickerIntent, 1); - } catch (Exception e) { - FileLog.e("tmessages", e); + Intent chooserIntent = Intent.createChooser(photoPickerIntent, null); + chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{videoPickerIntent}); + + startActivityForResult(chooserIntent, 1); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + + @Override + public boolean didSelectVideo(String path) { + if (Build.VERSION.SDK_INT >= 16) { + return !openVideoEditor(path, true, true); + } else { + SendMessagesHelper.prepareSendingVideo(path, 0, 0, 0, 0, null, dialog_id, replyingMessageObject); + showReplyPanel(false, null, null, null, false, true); + return true; } } }); presentFragment(fragment); } else if (id == attach_video) { try { - Intent pickIntent = new Intent(); - pickIntent.setType("video/*"); - pickIntent.setAction(Intent.ACTION_GET_CONTENT); - pickIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1536)); Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); File video = Utilities.generateVideoPath(); if (video != null) { @@ -615,14 +653,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1536)); currentPicturePath = video.getAbsolutePath(); } - Intent chooserIntent = Intent.createChooser(pickIntent, null); - chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{takeVideoIntent}); - - startActivityForResult(chooserIntent, 2); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - //PLUS + startActivityForResult(takeVideoIntent, 2); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + //PLUS } else if (id == attach_music) { try { Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI); @@ -631,11 +666,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not FileLog.e("tmessages", e); } } else if (id == attach_sticker) { - PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false); + PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, ChatActivity.this); + fragment.imageFilter = ".webp"; fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override - public void didSelectPhotos(ArrayList photos, ArrayList webPhotos) { - SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject); + public void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos) { + SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject, captions); SendMessagesHelper.prepareSendingPhotosSearch(webPhotos, dialog_id, replyingMessageObject); showReplyPanel(false, null, null, null, false, true); } @@ -644,24 +680,34 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void startPhotoSelectActivity() { try { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); - photoPickerIntent.setType("image/webp"); startActivityForResult(photoPickerIntent, 4); } catch (Exception e) { FileLog.e("tmessages", e); } } + + @Override + public boolean didSelectVideo(String path) { + if (Build.VERSION.SDK_INT >= 16) { + return !openVideoEditor(path, true, true); + } else { + SendMessagesHelper.prepareSendingVideo(path, 0, 0, 0, 0, null, dialog_id, replyingMessageObject); + showReplyPanel(false, null, null, null, false, true); + return true; + } + } }); presentFragment(fragment); - }// - else if (id == attach_location) { + // + } else if (id == attach_location) { if (!isGoogleMapsInstalled()) { return; } LocationActivity fragment = new LocationActivity(); fragment.setDelegate(new LocationActivity.LocationActivityDelegate() { @Override - public void didSelectLocation(double latitude, double longitude) { - SendMessagesHelper.getInstance().sendMessage(latitude, longitude, dialog_id, replyingMessageObject); + public void didSelectLocation(TLRPC.MessageMedia location) { + SendMessagesHelper.getInstance().sendMessage(location, dialog_id, replyingMessageObject); moveScrollToLastMessage(); showReplyPanel(false, null, null, null, false, true); if (paused) { @@ -906,14 +952,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not avatarContainer = new FrameLayoutFixed(context); avatarContainer.setBackgroundResource(R.drawable.bar_selector); avatarContainer.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0); - actionBar.addView(avatarContainer); - FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams(); - layoutParams2.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.rightMargin = AndroidUtilities.dp(40); - layoutParams2.leftMargin = AndroidUtilities.dp(56); - layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; - avatarContainer.setLayoutParams(layoutParams2); + actionBar.addView(avatarContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 56, 0, 40, 0)); avatarContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -946,30 +985,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not avatarImageView = new BackupImageView(context); avatarImageView.setRoundRadius(AndroidUtilities.dp(21)); - avatarContainer.addView(avatarImageView); - layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams(); - layoutParams2.width = AndroidUtilities.dp(42); - layoutParams2.height = AndroidUtilities.dp(42); - layoutParams2.topMargin = AndroidUtilities.dp(3); - layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; - avatarImageView.setLayoutParams(layoutParams2); + avatarContainer.addView(avatarImageView, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 0, 3, 0, 0)); if (currentEncryptedChat != null) { timeItem = new ImageView(context); timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5)); timeItem.setScaleType(ImageView.ScaleType.CENTER); - avatarContainer.addView(timeItem); - timerDrawable = new TimerDrawable(context); - - layoutParams2 = (FrameLayout.LayoutParams) timeItem.getLayoutParams(); - layoutParams2.width = AndroidUtilities.dp(34); - layoutParams2.height = AndroidUtilities.dp(34); - layoutParams2.topMargin = AndroidUtilities.dp(18); - layoutParams2.leftMargin = AndroidUtilities.dp(16); - layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; - timeItem.setLayoutParams(layoutParams2); - timeItem.setImageDrawable(timerDrawable); - + timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context)); + avatarContainer.addView(timeItem, LayoutHelper.createFrame(34, 34, Gravity.TOP | Gravity.LEFT, 16, 18, 0, 0)); timeItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -991,14 +1014,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not nameTextView.setGravity(Gravity.LEFT); nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - avatarContainer.addView(nameTextView); - layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.leftMargin = AndroidUtilities.dp(54); - layoutParams2.bottomMargin = AndroidUtilities.dp(22); - layoutParams2.gravity = Gravity.BOTTOM; - nameTextView.setLayoutParams(layoutParams2); + avatarContainer.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 54, 0, 0, 22)); onlineTextView = new TextView(context); onlineTextView.setTextColor(0xffd7e8f7); @@ -1008,14 +1024,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not onlineTextView.setSingleLine(true); onlineTextView.setEllipsize(TextUtils.TruncateAt.END); onlineTextView.setGravity(Gravity.LEFT); - avatarContainer.addView(onlineTextView); - layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.leftMargin = AndroidUtilities.dp(54); - layoutParams2.bottomMargin = AndroidUtilities.dp(4); - layoutParams2.gravity = Gravity.BOTTOM; - onlineTextView.setLayoutParams(layoutParams2); + avatarContainer.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 54, 0, 0, 4)); ActionBarMenu menu = actionBar.createMenu(); //headerItem = menu.addItem(0, R.drawable.ic_ab_other); @@ -1035,10 +1044,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not headerItem.addSubItem(delete_chat, LocaleController.getString("DeleteChatUser", R.string.DeleteChatUser), 0); } muteItem = headerItem.addSubItem(mute, null, 0); - - LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) headerItem.getLayoutParams(); - layoutParams.rightMargin = AndroidUtilities.dp(-48); - headerItem.setLayoutParams(layoutParams); + ((LinearLayout.LayoutParams) headerItem.getLayoutParams()).setMargins(0, 0, AndroidUtilities.dp(-48), 0); updateTitle(); updateSubtitle(); @@ -1048,7 +1054,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not attachItem = menu.addItem(chat_menu_attach, dots); attachItem.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo); attachItem.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery); - //attachItem.addSubItem(attach_sticker, "Sticker", R.drawable.ic_msg_panel_smiles); + attachItem.addSubItem(attach_sticker, LocaleController.getString("AttachSticker", R.string.AttachSticker), R.drawable.ic_attach_sticker); attachItem.addSubItem(attach_music, LocaleController.getString("ChatMusic", R.string.ChatMusic), R.drawable.ic_attach_music); attachItem.addSubItem(attach_video, LocaleController.getString("ChatVideo", R.string.ChatVideo), R.drawable.ic_attach_video); attachItem.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc); @@ -1061,7 +1067,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not //menuItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach); menuItem.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo); menuItem.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery); - //menuItem.addSubItem(attach_sticker, "Sticker", R.drawable.ic_msg_panel_smiles); + menuItem.addSubItem(attach_sticker, LocaleController.getString("AttachSticker", R.string.AttachSticker), R.drawable.ic_attach_sticker); menuItem.addSubItem(attach_music, LocaleController.getString("ChatMusic", R.string.ChatMusic), R.drawable.ic_attach_music); menuItem.addSubItem(attach_video, LocaleController.getString("ChatVideo", R.string.ChatVideo), R.drawable.ic_attach_video); menuItem.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc); @@ -1083,18 +1089,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END); selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2)); selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL); + actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f)); selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); - actionMode.addView(selectedMessagesCountTextView); - layoutParams = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams(); - layoutParams.weight = 1; - layoutParams.width = 0; - layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; - selectedMessagesCountTextView.setLayoutParams(layoutParams); if (currentEncryptedChat == null) { actionModeViews.add(actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); @@ -1115,6 +1116,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not checkActionBarMenu(); fragmentView = new SizeNotifierRelativeLayout(context); + + /* + { + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + if (chatActivityEnterView chatActivityEnterView.isEmojiPopupShowing()) { + int height = MeasureSpec.getSize(heightMeasureSpec); + heightMeasureSpec = MeasureSpec.makeMeasureSpec(height - chatActivityEnterView.getEmojiHeight(), MeasureSpec.getMode(heightMeasureSpec)); + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + }; + */ + SizeNotifierRelativeLayout contentView = (SizeNotifierRelativeLayout) fragmentView; contentView.setBackgroundImage(ApplicationLoader.getCachedWallpaper()); @@ -1122,11 +1137,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not emptyViewContainer = new FrameLayout(context); emptyViewContainer.setPadding(0, 0, 0, AndroidUtilities.dp(48)); emptyViewContainer.setVisibility(View.INVISIBLE); - contentView.addView(emptyViewContainer); - RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) emptyViewContainer.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = RelativeLayout.LayoutParams.MATCH_PARENT; - emptyViewContainer.setLayoutParams(layoutParams3); + contentView.addView(emptyViewContainer, new RelativeLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); emptyViewContainer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -1146,23 +1157,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not emptyView.setTextColor(0xffffffff); emptyView.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_black : R.drawable.system_blue); emptyView.setPadding(AndroidUtilities.dp(7), AndroidUtilities.dp(1), AndroidUtilities.dp(7), AndroidUtilities.dp(1)); - emptyViewContainer.addView(emptyView); - layoutParams2 = (FrameLayout.LayoutParams) emptyView.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.gravity = Gravity.CENTER; - emptyView.setLayoutParams(layoutParams2); + emptyViewContainer.addView(emptyView, new FrameLayout.LayoutParams(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); } else { LinearLayout secretChatPlaceholder = new LinearLayout(context); secretChatPlaceholder.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_black : R.drawable.system_blue); secretChatPlaceholder.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12)); secretChatPlaceholder.setOrientation(LinearLayout.VERTICAL); - emptyViewContainer.addView(secretChatPlaceholder); - layoutParams2 = (FrameLayout.LayoutParams) secretChatPlaceholder.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.gravity = Gravity.CENTER; - secretChatPlaceholder.setLayoutParams(layoutParams2); + emptyViewContainer.addView(secretChatPlaceholder, new FrameLayout.LayoutParams(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); secretViewStatusTextView = new TextView(context); secretViewStatusTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); @@ -1182,12 +1183,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleIncoming", R.string.EncryptedPlaceholderTitleIncoming, currentUser.last_name)); } } - secretChatPlaceholder.addView(secretViewStatusTextView); - layoutParams = (LinearLayout.LayoutParams) secretViewStatusTextView.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.gravity = Gravity.CENTER_HORIZONTAL; - secretViewStatusTextView.setLayoutParams(layoutParams); + secretChatPlaceholder.addView(secretViewStatusTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP)); TextView textView = new TextView(context); textView.setText(LocaleController.getString("EncryptedDescriptionTitle", R.string.EncryptedDescriptionTitle)); @@ -1195,24 +1191,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not textView.setTextColor(0xffffffff); textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setMaxWidth(AndroidUtilities.dp(260)); - secretChatPlaceholder.addView(textView); - layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.topMargin = AndroidUtilities.dp(8); - layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; - textView.setLayoutParams(layoutParams); + secretChatPlaceholder.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 0, 8, 0, 0)); for (int a = 0; a < 4; a++) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.HORIZONTAL); - secretChatPlaceholder.addView(linearLayout); - layoutParams = (LinearLayout.LayoutParams) linearLayout.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.topMargin = AndroidUtilities.dp(8); - layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; - linearLayout.setLayoutParams(layoutParams); + secretChatPlaceholder.addView(linearLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 8, 0, 0)); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.ic_lock_white); @@ -1239,45 +1223,123 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (LocaleController.isRTL) { - linearLayout.addView(textView); - linearLayout.addView(imageView); + linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); + linearLayout.addView(imageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 8, 3, 0, 0)); } else { - linearLayout.addView(imageView); - linearLayout.addView(textView); + linearLayout.addView(imageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 4, 8, 0)); + linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); } - layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.rightMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(8); - layoutParams.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(8) : 0; - layoutParams.topMargin = AndroidUtilities.dp(LocaleController.isRTL ? 3 : 4); - imageView.setLayoutParams(layoutParams); + } + } - layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; - textView.setLayoutParams(layoutParams); + chatListView = (RecyclerExListView) inflater.inflate(R.layout.recycler_view, null); + chatListView.setAdapter(chatAdapter = new ChatActivityAdapter(context)); + chatListView.setClipToPadding(false); + chatListView.setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(3)); + chatListView.setItemAnimator(null); + chatListView.setLayoutAnimation(null); + chatLayoutManager = new LinearLayoutManager(context) { + @Override + public boolean supportsPredictiveItemAnimations() { + return false; + } + }; + chatLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); + chatLayoutManager.setStackFromEnd(true); + chatListView.setLayoutManager(chatLayoutManager); + contentView.addView(chatListView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 0, -3, RelativeLayout.ABOVE, id_chat_compose_panel)); + chatListView.setOnItemLongClickListener(onItemLongClickListener); + chatListView.setOnItemClickListener(onItemClickListener); + chatListView.setOnScrollListener(new RecyclerView.OnScrollListener() { + + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + if (newState != RecyclerView.SCROLL_STATE_DRAGGING && highlightMessageId != Integer.MAX_VALUE) { + highlightMessageId = Integer.MAX_VALUE; + updateVisibleRows(); } } - chatListView = new LayoutListView(context); - chatListView.setAdapter(chatAdapter = new ChatAdapter(context)); - chatListView.setCacheColorHint(ApplicationLoader.getSelectedColor()); - chatListView.setClipToPadding(false); - chatListView.setStackFromBottom(true); - chatListView.setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(3)); - chatListView.setDivider(null); - chatListView.setSelector(R.drawable.transparent); - chatListView.setOnItemLongClickListener(onItemLongClickListener); - chatListView.setOnItemClickListener(onItemClickListener); - contentView.addView(chatListView); - layoutParams3 = (RelativeLayout.LayoutParams) chatListView.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.bottomMargin = -AndroidUtilities.dp(3); - layoutParams3.addRule(RelativeLayout.ABOVE, id_chat_compose_panel); - chatListView.setLayoutParams(layoutParams3); - chatListView.setOnInterceptTouchEventListener(new LayoutListView.OnInterceptTouchEventListener() { + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + int firstVisibleItem = chatLayoutManager.findFirstVisibleItemPosition(); + int visibleItemCount = Math.abs(chatLayoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1; + if (visibleItemCount > 0) { + int totalItemCount = chatAdapter.getItemCount(); + if (firstVisibleItem <= 10) { + if (!endReached && !loading) { + if (messagesByDays.size() != 0) { + MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced && startLoadFromMessageId == 0, minDate, classGuid, 0, 0, 0, startLoadFromMessageId == 0); + } else { + MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReaced && startLoadFromMessageId == 0, minDate, classGuid, 0, 0, 0, startLoadFromMessageId == 0); + } + loading = true; + } + } + if (firstVisibleItem + visibleItemCount >= totalItemCount - 6) { + if (!forward_end_reached && !loadingForward) { + MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, startLoadFromMessageId == 0, maxDate, classGuid, 1, 0, 0, startLoadFromMessageId == 0); + loadingForward = true; + } + } + if (firstVisibleItem + visibleItemCount == totalItemCount && forward_end_reached) { + showPagedownButton(false, true); + } + } + updateMessagesVisisblePart(); + } + }); + chatListView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (openSecretPhotoRunnable != null || SecretPhotoViewer.getInstance().isVisible()) { + if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_POINTER_UP) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + chatListView.setOnItemClickListener(onItemClickListener); + } + }, 150); + if (openSecretPhotoRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable); + openSecretPhotoRunnable = null; + try { + Toast.makeText(v.getContext(), LocaleController.getString("PhotoTip", R.string.PhotoTip), Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } else { + if (SecretPhotoViewer.getInstance().isVisible()) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + chatListView.setOnItemLongClickListener(onItemLongClickListener); + chatListView.setLongClickable(true); + } + }); + SecretPhotoViewer.getInstance().closePhoto(); + } + } + } else if (event.getAction() != MotionEvent.ACTION_DOWN) { + if (SecretPhotoViewer.getInstance().isVisible()) { + return true; + } else if (openSecretPhotoRunnable != null) { + if (event.getAction() == MotionEvent.ACTION_MOVE) { + if (Math.hypot(startX - event.getX(), startY - event.getY()) > AndroidUtilities.dp(5)) { + AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable); + openSecretPhotoRunnable = null; + } + } else { + AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable); + openSecretPhotoRunnable = null; + } + } + } + } + return false; + } + }); + chatListView.setOnInterceptTouchListener(new RecyclerExListView.OnInterceptTouchListener() { @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (actionBar.isActionModeShowed()) { @@ -1335,111 +1397,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return false; } }); - chatListView.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (openSecretPhotoRunnable != null || SecretPhotoViewer.getInstance().isVisible()) { - if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_POINTER_UP) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - chatListView.setOnItemClickListener(onItemClickListener); - } - }, 150); - if (openSecretPhotoRunnable != null) { - AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable); - openSecretPhotoRunnable = null; - try { - Toast.makeText(v.getContext(), LocaleController.getString("PhotoTip", R.string.PhotoTip), Toast.LENGTH_SHORT).show(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } else { - if (SecretPhotoViewer.getInstance().isVisible()) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - chatListView.setOnItemLongClickListener(onItemLongClickListener); - chatListView.setLongClickable(true); - } - }); - SecretPhotoViewer.getInstance().closePhoto(); - } - } - } else if (event.getAction() != MotionEvent.ACTION_DOWN) { - if (SecretPhotoViewer.getInstance().isVisible()) { - return true; - } else if (openSecretPhotoRunnable != null) { - if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (Math.hypot(startX - event.getX(), startY - event.getY()) > AndroidUtilities.dp(5)) { - AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable); - openSecretPhotoRunnable = null; - } - } else { - AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable); - openSecretPhotoRunnable = null; - } - } - } - } - return false; - } - }); - chatListView.setOnScrollListener(new AbsListView.OnScrollListener() { - Rect scrollRect = new Rect(); - - @Override - public void onScrollStateChanged(AbsListView absListView, int i) { - if (i == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL || i == AbsListView.OnScrollListener.SCROLL_STATE_FLING && highlightMessageId != Integer.MAX_VALUE) { - highlightMessageId = Integer.MAX_VALUE; - updateVisibleRows(); - } - } - - @Override - public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { - if (visibleItemCount > 0) { - if (firstVisibleItem <= 10) { - if (!endReached && !loading) { - if (messagesByDays.size() != 0) { - MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced && startLoadFromMessageId == 0, minDate, classGuid, 0, 0, 0, startLoadFromMessageId == 0); - } else { - MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReaced && startLoadFromMessageId == 0, minDate, classGuid, 0, 0, 0, startLoadFromMessageId == 0); - } - loading = true; - } - } - if (firstVisibleItem + visibleItemCount >= totalItemCount - 6) { - if (!forward_end_reached && !loadingForward) { - MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, startLoadFromMessageId == 0, maxDate, classGuid, 1, 0, 0, startLoadFromMessageId == 0); - loadingForward = true; - } - } - if (firstVisibleItem + visibleItemCount == totalItemCount && forward_end_reached) { - showPagedownButton(false, true); - } - } - for (int a = 0; a < visibleItemCount; a++) { - View view = absListView.getChildAt(a); - if (view instanceof ChatMessageCell) { - ChatMessageCell messageCell = (ChatMessageCell) view; - messageCell.getLocalVisibleRect(scrollRect); - messageCell.setVisiblePart(scrollRect.top, scrollRect.bottom - scrollRect.top); - } - } - } - }); progressView = new FrameLayout(context); progressView.setVisibility(View.INVISIBLE); - progressView.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_loader2 : R.drawable.system_loader1); - contentView.addView(progressView); - layoutParams3 = (RelativeLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams3.width = AndroidUtilities.dp(36); - layoutParams3.height = AndroidUtilities.dp(36); - layoutParams3.bottomMargin = AndroidUtilities.dp(48); - layoutParams3.addRule(RelativeLayout.CENTER_IN_PARENT); - progressView.setLayoutParams(layoutParams3); + contentView.addView(progressView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 0, 48)); + + View view = new View(context); + view.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_loader2 : R.drawable.system_loader1); + progressView.addView(view, LayoutHelper.createFrame(36, 36, Gravity.CENTER)); ProgressBar progressBar = new ProgressBar(context); try { @@ -1449,12 +1414,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } progressBar.setIndeterminate(true); AndroidUtilities.setProgressBarAnimationDuration(progressBar, 1500); - progressView.addView(progressBar); - layoutParams2 = (FrameLayout.LayoutParams) progressBar.getLayoutParams(); - layoutParams2.width = AndroidUtilities.dp(32); - layoutParams2.height = AndroidUtilities.dp(32); - layoutParams2.gravity = Gravity.CENTER; - progressBar.setLayoutParams(layoutParams2); + progressView.addView(progressBar, LayoutHelper.createFrame(32, 32, Gravity.CENTER)); if (currentEncryptedChat == null && !isBroadcast) { mentionListView = new ListView(context); @@ -1467,15 +1427,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (Build.VERSION.SDK_INT > 8) { mentionListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); } - contentView.addView(mentionListView); - layoutParams3 = (RelativeLayout.LayoutParams) mentionListView.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = AndroidUtilities.dp(110); - layoutParams3.topMargin = -AndroidUtilities.dp(108); - layoutParams3.addRule(RelativeLayout.ALIGN_TOP, id_chat_compose_panel); - mentionListView.setLayoutParams(layoutParams3); + contentView.addView(mentionListView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 110, 0, -108, 0, 0, RelativeLayout.ALIGN_TOP, id_chat_compose_panel)); - mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(context, new MentionsAdapter.MentionsAdapterDelegate() { + mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(context, false, new MentionsAdapter.MentionsAdapterDelegate() { @Override public void needChangePanelVisibility(boolean show) { if (show) { @@ -1599,12 +1553,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatActivityEnterView.setDialogId(dialog_id); chatActivityEnterView.addToAttachLayout(menuItem); chatActivityEnterView.setId(id_chat_compose_panel); - contentView.addView(chatActivityEnterView); - layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = RelativeLayout.LayoutParams.WRAP_CONTENT; - layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - chatActivityEnterView.setLayoutParams(layoutParams3); + contentView.addView(chatActivityEnterView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, RelativeLayout.ALIGN_PARENT_BOTTOM)); chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() { @Override public void onMessageSend(String message) { @@ -1630,6 +1579,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not AndroidUtilities.cancelRunOnUIThread(waitingForCharaterEnterRunnable); waitingForCharaterEnterRunnable = null; } + if (chatActivityEnterView.isMessageWebPageSearchEnabled()) { if (bigChange) { searchLinks(text, true); } else { @@ -1642,13 +1592,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } }; - AndroidUtilities.runOnUIThread(waitingForCharaterEnterRunnable, 1000); + AndroidUtilities.runOnUIThread(waitingForCharaterEnterRunnable, 3000); + } } } @Override public void needSendTyping() { - MessagesController.getInstance().sendTyping(dialog_id, classGuid); + MessagesController.getInstance().sendTyping(dialog_id, 0, classGuid); } @Override @@ -1694,6 +1645,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not mentionListView.setVisibility(View.VISIBLE); } } + updateMessagesVisisblePart(); } }); @@ -1703,32 +1655,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not View lineView = new View(context); lineView.setBackgroundColor(0xffe8e8e8); - replyLayout.addView(lineView); - layoutParams2 = (FrameLayout.LayoutParams) lineView.getLayoutParams(); - layoutParams2.gravity = Gravity.BOTTOM; - layoutParams2.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams2.height = AndroidUtilities.dp(1); - lineView.setLayoutParams(layoutParams2); + replyLayout.addView(lineView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 1, Gravity.BOTTOM | Gravity.LEFT)); replyIconImageView = new ImageView(context); replyIconImageView.setScaleType(ImageView.ScaleType.CENTER); - replyLayout.addView(replyIconImageView); - layoutParams2 = (FrameLayout.LayoutParams) replyIconImageView.getLayoutParams(); - layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; - layoutParams2.width = AndroidUtilities.dp(52); - layoutParams2.height = AndroidUtilities.dp(46); - replyIconImageView.setLayoutParams(layoutParams2); + replyLayout.addView(replyIconImageView, LayoutHelper.createFrame(52, 46, Gravity.TOP | Gravity.LEFT)); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.delete_reply); imageView.setScaleType(ImageView.ScaleType.CENTER); - replyLayout.addView(imageView); - layoutParams2 = (FrameLayout.LayoutParams) imageView.getLayoutParams(); - layoutParams2.topMargin = AndroidUtilities.dp(0.5f); - layoutParams2.width = AndroidUtilities.dp(52); - layoutParams2.height = AndroidUtilities.dp(46); - layoutParams2.gravity = Gravity.RIGHT | Gravity.TOP; - imageView.setLayoutParams(layoutParams2); + replyLayout.addView(imageView, LayoutHelper.createFrame(52, 46, Gravity.RIGHT | Gravity.TOP, 0, 0.5f, 0, 0)); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1746,15 +1682,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not replyNameTextView.setSingleLine(true); replyNameTextView.setEllipsize(TextUtils.TruncateAt.END); replyNameTextView.setMaxLines(1); - replyLayout.addView(replyNameTextView); - layoutParams2 = (FrameLayout.LayoutParams) replyNameTextView.getLayoutParams(); - layoutParams2.leftMargin = AndroidUtilities.dp(52); - layoutParams2.rightMargin = AndroidUtilities.dp(52); - layoutParams2.topMargin = AndroidUtilities.dp(4); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; - replyNameTextView.setLayoutParams(layoutParams2); + replyLayout.addView(replyNameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, 4, 52, 0)); replyObjectTextView = new TextView(context); replyObjectTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); @@ -1762,36 +1690,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not replyObjectTextView.setSingleLine(true); replyObjectTextView.setEllipsize(TextUtils.TruncateAt.END); replyObjectTextView.setMaxLines(1); - replyLayout.addView(replyObjectTextView); - layoutParams2 = (FrameLayout.LayoutParams) replyObjectTextView.getLayoutParams(); - layoutParams2.leftMargin = AndroidUtilities.dp(52); - layoutParams2.rightMargin = AndroidUtilities.dp(52); - layoutParams2.topMargin = AndroidUtilities.dp(22); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; - replyObjectTextView.setLayoutParams(layoutParams2); + replyLayout.addView(replyObjectTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, 22, 52, 0)); replyImageView = new BackupImageView(context); - replyLayout.addView(replyImageView); - layoutParams2 = (FrameLayout.LayoutParams) replyImageView.getLayoutParams(); - layoutParams2.leftMargin = AndroidUtilities.dp(52); - layoutParams2.topMargin = AndroidUtilities.dp(6); - layoutParams2.width = AndroidUtilities.dp(34); - layoutParams2.height = AndroidUtilities.dp(34); - layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; - replyImageView.setLayoutParams(layoutParams2); + replyLayout.addView(replyImageView, LayoutHelper.createFrame(34, 34, Gravity.TOP | Gravity.LEFT, 52, 6, 0, 0)); stickersPanel = new FrameLayout(context); stickersPanel.setVisibility(View.GONE); - contentView.addView(stickersPanel); - layoutParams3 = (RelativeLayout.LayoutParams) stickersPanel.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.WRAP_CONTENT; - layoutParams3.height = AndroidUtilities.dp(81.5f); - //layoutParams3.height = AndroidUtilities.dp(100); - layoutParams3.bottomMargin = AndroidUtilities.dp(38); - layoutParams3.addRule(RelativeLayout.ALIGN_BOTTOM, id_chat_compose_panel); - stickersPanel.setLayoutParams(layoutParams3); + contentView.addView(stickersPanel, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, 81.5f, 0, 0, 0, 38, RelativeLayout.ALIGN_BOTTOM, id_chat_compose_panel)); stickersListView = new RecyclerListView(context); LinearLayoutManager layoutManager = new LinearLayoutManager(context); @@ -1801,13 +1707,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (Build.VERSION.SDK_INT >= 9) { stickersListView.setOverScrollMode(RecyclerListView.OVER_SCROLL_NEVER); } - stickersPanel.addView(stickersListView); - layoutParams2 = (FrameLayout.LayoutParams) stickersListView.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams2.height = AndroidUtilities.dp(78); - //layoutParams2.height = AndroidUtilities.dp(97); - stickersListView.setLayoutParams(layoutParams2); + stickersPanel.addView(stickersListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 78)); if (currentEncryptedChat == null || currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 23) { + chatActivityEnterView.setAllowStickers(true); if (stickersAdapter != null) { stickersAdapter.destroy(); } @@ -1857,45 +1759,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void onItemClick(View view, int position) { TLRPC.Document document = stickersAdapter.getItem(position); if (document instanceof TLRPC.TL_document) { - if (currentEncryptedChat != null && document.thumb instanceof TLRPC.TL_photoSize) { - File file = FileLoader.getPathToAttach(document.thumb, true); - if (file.exists()) { - try { - int len = (int) file.length(); - byte[] arr = new byte[(int) file.length()]; - RandomAccessFile reader = new RandomAccessFile(file, "r"); - reader.readFully(arr); - TLRPC.TL_document newDocument = new TLRPC.TL_document(); - newDocument.thumb = new TLRPC.TL_photoCachedSize(); - newDocument.thumb.location = document.thumb.location; - newDocument.thumb.size = document.thumb.size; - newDocument.thumb.w = document.thumb.w; - newDocument.thumb.h = document.thumb.h; - newDocument.thumb.type = document.thumb.type; - newDocument.thumb.bytes = arr; - - newDocument.id = document.id; - newDocument.access_hash = document.access_hash; - newDocument.date = document.date; - newDocument.mime_type = document.mime_type; - newDocument.size = document.size; - newDocument.dc_id = document.dc_id; - newDocument.attributes = document.attributes; - document = newDocument; - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - } - for (int a = 0; a < document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeSticker) { - document.attributes.remove(a); - document.attributes.add(new TLRPC.TL_documentAttributeSticker_old()); - break; - } - } - SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, dialog_id, replyingMessageObject); + SendMessagesHelper.getInstance().sendSticker(document, dialog_id, replyingMessageObject); showReplyPanel(false, null, null, null, false, true); } chatActivityEnterView.setFieldText(""); @@ -1905,13 +1769,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not imageView = new ImageView(context); imageView.setImageResource(R.drawable.stickers_back_arrow); - stickersPanel.addView(imageView); - layoutParams2 = (FrameLayout.LayoutParams) imageView.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.gravity = Gravity.BOTTOM; - layoutParams2.leftMargin = AndroidUtilities.dp(53); - imageView.setLayoutParams(layoutParams2); + stickersPanel.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 53, 0, 0, 0)); bottomOverlay = new FrameLayout(context); bottomOverlay.setBackgroundColor(0xffffffff); @@ -1919,32 +1777,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not bottomOverlay.setFocusable(true); bottomOverlay.setFocusableInTouchMode(true); bottomOverlay.setClickable(true); - contentView.addView(bottomOverlay); - layoutParams3 = (RelativeLayout.LayoutParams) bottomOverlay.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = AndroidUtilities.dp(48); - layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - bottomOverlay.setLayoutParams(layoutParams3); + contentView.addView(bottomOverlay, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM)); bottomOverlayText = new TextView(context); bottomOverlayText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); bottomOverlayText.setTextColor(0xff7f7f7f); - bottomOverlay.addView(bottomOverlayText); - layoutParams2 = (FrameLayout.LayoutParams) bottomOverlayText.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.gravity = Gravity.CENTER; - bottomOverlayText.setLayoutParams(layoutParams2); + bottomOverlay.addView(bottomOverlayText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); bottomOverlayChat = new FrameLayout(context); bottomOverlayChat.setBackgroundColor(0xfffbfcfd); bottomOverlayChat.setVisibility(View.INVISIBLE); - contentView.addView(bottomOverlayChat); - layoutParams3 = (RelativeLayout.LayoutParams) bottomOverlayChat.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = AndroidUtilities.dp(48); - layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - bottomOverlayChat.setLayoutParams(layoutParams3); + contentView.addView(bottomOverlayChat, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM)); bottomOverlayChat.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -1979,25 +1822,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not bottomOverlayChatText = new TextView(context); bottomOverlayChatText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); bottomOverlayChatText.setTextColor(0xff3e6fa1); - bottomOverlayChat.addView(bottomOverlayChatText); - layoutParams2 = (FrameLayout.LayoutParams) bottomOverlayChatText.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.gravity = Gravity.CENTER; - bottomOverlayChatText.setLayoutParams(layoutParams2); + bottomOverlayChat.addView(bottomOverlayChatText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); pagedownButton = new ImageView(context); pagedownButton.setVisibility(View.INVISIBLE); pagedownButton.setImageResource(R.drawable.pagedown); - contentView.addView(pagedownButton); - layoutParams3 = (RelativeLayout.LayoutParams) pagedownButton.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.WRAP_CONTENT; - layoutParams3.height = RelativeLayout.LayoutParams.WRAP_CONTENT; - layoutParams3.rightMargin = AndroidUtilities.dp(6); - layoutParams3.bottomMargin = AndroidUtilities.dp(4); - layoutParams3.addRule(RelativeLayout.ABOVE, id_chat_compose_panel); - layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - pagedownButton.setLayoutParams(layoutParams3); + contentView.addView(pagedownButton, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 0, 6, 4, RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.ABOVE, id_chat_compose_panel)); pagedownButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -2052,7 +1882,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not pendingLinkSearchString = null; showReplyPanel(false, null, null, foundWebPage, false, true); } - if (charSequence.length() == 0 || TextUtils.indexOf(charSequence, "http") == -1 && TextUtils.indexOf(charSequence, ".com/") == -1) { + if (charSequence.length() < 13 || TextUtils.indexOf(charSequence, "http://") == -1 && TextUtils.indexOf(charSequence, "https://") == -1) { return; } final TLRPC.TL_messages_getWebPagePreview req = new TLRPC.TL_messages_getWebPagePreview(); @@ -2298,15 +2128,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private void moveScrollToLastMessage() { if (chatListView != null) { - chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); - chatListView.setForceTop(-100000 - chatListView.getPaddingTop()); - chatListView.post(new Runnable() { - @Override - public void run() { - chatListView.setForceTop(-100000 - chatListView.getPaddingTop()); - chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); - } - }); + chatLayoutManager.scrollToPositionWithOffset(messages.size() - 1, -100000 - chatListView.getPaddingTop()); } } @@ -2321,7 +2143,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private void scrollToLastMessage() { if (forward_end_reached && first_unread_id == 0 && startLoadFromMessageId == 0) { - chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); + chatLayoutManager.scrollToPositionWithOffset(messages.size() - 1, -100000 - chatListView.getPaddingTop()); } else { messages.clear(); messagesByDays.clear(); @@ -2346,6 +2168,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } + private void updateMessagesVisisblePart() { + if (chatListView == null) { + return; + } + int count = chatListView.getChildCount(); + for (int a = 0; a < count; a++) { + View view = chatListView.getChildAt(a); + if (view instanceof ChatMessageCell) { + ChatMessageCell messageCell = (ChatMessageCell) view; + messageCell.getLocalVisibleRect(scrollRect); + messageCell.setVisiblePart(scrollRect.top, scrollRect.bottom - scrollRect.top); + } + } + } + private void scrollToMessageId(int id, int fromMessageId, boolean select) { returnToMessageId = fromMessageId; needSelectFromMessageId = select; @@ -2362,9 +2199,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } final int yOffset = Math.max(0, (chatListView.getHeight() - object.getApproximateHeight()) / 2); if (messages.get(messages.size() - 1) == object) { - chatListView.setSelectionFromTop(0, AndroidUtilities.dp(-11) + yOffset); + chatLayoutManager.scrollToPositionWithOffset(0, AndroidUtilities.dp(-11) + yOffset); } else { - chatListView.setSelectionFromTop(messages.size() - messages.indexOf(object), AndroidUtilities.dp(-11) + yOffset); + chatLayoutManager.scrollToPositionWithOffset(messages.size() - messages.indexOf(object), AndroidUtilities.dp(-11) + yOffset); } updateVisibleRows(); showPagedownButton(true, true); @@ -2604,7 +2441,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return 7; } } else if (messageObject.type == 10 || messageObject.type == 11) { - if (messageObject.isSending()) { + if (messageObject.getId() == 0 || messageObject.isSending()) { return -1; } else { return 1; @@ -2794,23 +2631,62 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (start) { try { + Integer type = MessagesController.getInstance().printingStringsTypes.get(dialog_id); + if (type == 0) { + if (lastStatusDrawable == 1) { + return; + } + lastStatusDrawable = 1; if (onlineTextView != null) { onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null); onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); - } - if (typingDotsDrawable != null) { + typingDotsDrawable.start(); + recordStatusDrawable.stop(); + sendingFileDrawable.stop(); + } + } else if (type == 1) { + if (lastStatusDrawable == 2) { + return; + } + lastStatusDrawable = 2; + if (onlineTextView != null) { + onlineTextView.setCompoundDrawablesWithIntrinsicBounds(recordStatusDrawable, null, null, null); + onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); + + recordStatusDrawable.start(); + typingDotsDrawable.stop(); + sendingFileDrawable.stop(); + } + } else if (type == 2) { + if (lastStatusDrawable == 3) { + return; + } + lastStatusDrawable = 3; + if (onlineTextView != null) { + onlineTextView.setCompoundDrawablesWithIntrinsicBounds(sendingFileDrawable, null, null, null); + onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); + + sendingFileDrawable.start(); + typingDotsDrawable.stop(); + recordStatusDrawable.stop(); + } } } catch (Exception e) { FileLog.e("tmessages", e); } } else { + if (lastStatusDrawable == 0) { + return; + } + lastStatusDrawable = 0; if (onlineTextView != null) { onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); onlineTextView.setCompoundDrawablePadding(0); - } - if (typingDotsDrawable != null) { + typingDotsDrawable.stop(); + recordStatusDrawable.stop(); + sendingFileDrawable.stop(); } } } @@ -2849,7 +2725,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - public boolean openVideoEditor(String videoPath, boolean removeLast) { + public boolean openVideoEditor(String videoPath, boolean removeLast, boolean animated) { Bundle args = new Bundle(); args.putString("videoPath", videoPath); VideoEditorActivity fragment = new VideoEditorActivity(args); @@ -2876,7 +2752,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not showReplyPanel(false, null, null, null, false, true); return false; } - parentLayout.presentFragment(fragment, removeLast, true, true); + parentLayout.presentFragment(fragment, removeLast, !animated, true); return true; } @@ -2912,21 +2788,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } catch (Exception e) { FileLog.e("tmessages", e); } - arrayList.add(new MediaController.PhotoEntry(0, 0, 0, currentPicturePath, orientation)); + arrayList.add(new MediaController.PhotoEntry(0, 0, 0, currentPicturePath, orientation, false)); PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 2, new PhotoViewer.EmptyPhotoViewerProvider() { @Override public void sendButtonPressed(int index) { MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) arrayList.get(0); if (photoEntry.imagePath != null) { - SendMessagesHelper.prepareSendingPhoto(photoEntry.imagePath, null, dialog_id, replyingMessageObject); + SendMessagesHelper.prepareSendingPhoto(photoEntry.imagePath, null, dialog_id, replyingMessageObject, photoEntry.caption); showReplyPanel(false, null, null, null, false, true); } else if (photoEntry.path != null) { - SendMessagesHelper.prepareSendingPhoto(photoEntry.path, null, dialog_id, replyingMessageObject); + SendMessagesHelper.prepareSendingPhoto(photoEntry.path, null, dialog_id, replyingMessageObject, photoEntry.caption); showReplyPanel(false, null, null, null, false, true); } } - }); + }, this); Utilities.addMediaToGallery(currentPicturePath); currentPicturePath = null; } else if (requestCode == 1) { @@ -2934,33 +2810,42 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not showAttachmentError(); return; } - SendMessagesHelper.prepareSendingPhoto(null, data.getData(), dialog_id, replyingMessageObject); - showReplyPanel(false, null, null, null, false, true); - } else if (requestCode == 2) { + Uri uri = data.getData(); + if (uri.toString().contains("video")) { String videoPath = null; - if (data != null) { - Uri uri = data.getData(); - boolean fromCamera = false; - if (uri != null && uri.getScheme() != null) { - fromCamera = uri.getScheme().contains("file"); - } else if (uri == null) { - fromCamera = true; - } - if (fromCamera) { - if (uri != null) { - videoPath = uri.getPath(); - } else { - videoPath = currentPicturePath; - } - Utilities.addMediaToGallery(currentPicturePath); - currentPicturePath = null; - } else { try { videoPath = Utilities.getPath(uri); } catch (Exception e) { FileLog.e("tmessages", e); } + if (videoPath == null) { + showAttachmentError(); + } + if (Build.VERSION.SDK_INT >= 16) { + if (paused) { + startVideoEdit = videoPath; + } else { + openVideoEditor(videoPath, false, false); + } + } else { + SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, replyingMessageObject); + showReplyPanel(false, null, null, null, false, true); } + } else { + SendMessagesHelper.prepareSendingPhoto(null, uri, dialog_id, replyingMessageObject, null); + } + showReplyPanel(false, null, null, null, false, true); + } else if (requestCode == 2) { + String videoPath = null; + if (data != null) { + Uri uri = data.getData(); + if (uri != null) { + videoPath = uri.getPath(); + } else { + videoPath = currentPicturePath; + } + Utilities.addMediaToGallery(currentPicturePath); + currentPicturePath = null; } if (videoPath == null && currentPicturePath != null) { File f = new File(currentPicturePath); @@ -2973,7 +2858,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (paused) { startVideoEdit = videoPath; } else { - openVideoEditor(videoPath, false); + openVideoEditor(videoPath, false, false); } } else { SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, replyingMessageObject); @@ -3018,7 +2903,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not showAttachmentError(); return; } - SendMessagesHelper.prepareSendingPhoto(null, data.getData(), dialog_id, replyingMessageObject); + SendMessagesHelper.prepareSendingPhoto(null, data.getData(), dialog_id, replyingMessageObject, null); showReplyPanel(false, null, null, null, false, true); } } @@ -3036,29 +2921,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not currentPicturePath = args.getString("path"); } - private void removeUnreadPlane(boolean reload) { + private void removeUnreadPlane() { if (unreadMessageObject != null) { - messages.remove(unreadMessageObject); forward_end_reached = true; first_unread_id = 0; last_message_id = 0; unread_to_load = 0; - unreadMessageObject = null; - if (reload) { - chatAdapter.notifyDataSetChanged(); + if (chatAdapter != null) { + chatAdapter.removeMessageObject(unreadMessageObject); + } else { + messages.remove(unreadMessageObject); } + unreadMessageObject = null; } } public boolean processSendingText(String text) { return chatActivityEnterView.processSendingText(text); } + //Open chat before sending text message shared from other app + public void setReplyText(String text) { + chatActivityEnterView.setFieldText(text); + } @SuppressWarnings("unchecked") @Override public void didReceivedNotification(int id, final Object... args) { if (id == NotificationCenter.messagesDidLoaded) { - long did = (Long) args[0]; if (did == dialog_id) { loadsCount++; @@ -3214,9 +3103,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not last_message_id = 0; first_message_id = 0; startLoadFromMessageId = 0; + chatAdapter.notifyItemChanged(chatAdapter.getItemCount() - 1); + newRowsCount--; + } + if (newRowsCount != 0) { + chatAdapter.notifyItemRangeInserted(chatAdapter.getItemCount() - 2, newRowsCount); } - - chatAdapter.notifyDataSetChanged(); loadingForward = false; } else { if (messArr.size() != count) { @@ -3237,37 +3129,44 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatAdapter.notifyDataSetChanged(); if (scrollToMessage != null) { final int yOffset = scrollToMessageMiddleScreen ? Math.max(0, (chatListView.getHeight() - scrollToMessage.getApproximateHeight()) / 2) : 0; + if (!messages.isEmpty()) { if (messages.get(messages.size() - 1) == scrollToMessage) { - chatListView.setSelectionFromTop(0, AndroidUtilities.dp(-11) + yOffset); + chatLayoutManager.scrollToPositionWithOffset(0, AndroidUtilities.dp(-11) + yOffset); } else { - chatListView.setSelectionFromTop(messages.size() - messages.indexOf(scrollToMessage), AndroidUtilities.dp(-11) + yOffset); + chatLayoutManager.scrollToPositionWithOffset(messages.size() - messages.indexOf(scrollToMessage), AndroidUtilities.dp(-11) + yOffset); } ViewTreeObserver obs = chatListView.getViewTreeObserver(); obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override - public boolean onPreDraw() { + public boolean onPreDraw() { //TODO remove it? if (!messages.isEmpty()) { if (messages.get(messages.size() - 1) == scrollToMessage) { - chatListView.setSelectionFromTop(0, AndroidUtilities.dp(-11) + yOffset); + chatLayoutManager.scrollToPositionWithOffset(0, AndroidUtilities.dp(-11) + yOffset); } else { - chatListView.setSelectionFromTop(messages.size() - messages.indexOf(scrollToMessage), AndroidUtilities.dp(-11) + yOffset); + chatLayoutManager.scrollToPositionWithOffset(messages.size() - messages.indexOf(scrollToMessage), AndroidUtilities.dp(-11) + yOffset); } } chatListView.getViewTreeObserver().removeOnPreDrawListener(this); return true; } }); + } chatListView.invalidate(); showPagedownButton(true, true); } else { moveScrollToLastMessage(); } } else { - int firstVisPos = chatListView.getLastVisiblePosition(); + if (endReached) { + chatAdapter.notifyItemRemoved(0); + } + if (newRowsCount != 0) { + int firstVisPos = chatLayoutManager.findLastVisibleItemPosition(); View firstVisView = chatListView.getChildAt(chatListView.getChildCount() - 1); int top = ((firstVisView == null) ? 0 : firstVisView.getTop()) - chatListView.getPaddingTop(); - chatAdapter.notifyDataSetChanged(); - chatListView.setSelectionFromTop(firstVisPos + newRowsCount - (endReached ? 1 : 0), top); + chatAdapter.notifyItemRangeInserted(1, newRowsCount); + chatLayoutManager.scrollToPositionWithOffset(firstVisPos + newRowsCount - (endReached ? 1 : 0), top); + } } if (paused) { @@ -3278,9 +3177,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (first) { - if (chatListView.getEmptyView() == null) { - chatListView.setEmptyView(emptyViewContainer); - } + chatListView.setEmptyView(emptyViewContainer); } } else { scrollToTopOnResume = true; @@ -3428,6 +3325,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { ReplyMessageQuery.loadReplyMessagesForMessages(arr, dialog_id); boolean markAsRead = false; + boolean unreadUpdated = true; int oldCount = messages.size(); for (MessageObject obj : arr) { if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && @@ -3443,14 +3341,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (obj.isOut()) { - removeUnreadPlane(false); + removeUnreadPlane(); hasFromMe = true; } - if (!obj.isOut() && unreadMessageObject != null) { - unread_to_load++; - } - if (obj.getId() > 0) { maxMessageId = Math.min(obj.getId(), maxMessageId); minMessageId = Math.max(obj.getId(), minMessageId); @@ -3473,12 +3367,42 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not dateObj.contentType = 4; messages.add(0, dateObj); } - if (!obj.isOut() && obj.isUnread()) { + if (!obj.isOut()) { + if (paused) { + if (!scrollToTopUnReadOnResume && unreadMessageObject != null) { + if (chatAdapter != null) { + chatAdapter.removeMessageObject(unreadMessageObject); + } else { + messages.remove(unreadMessageObject); + } + unreadMessageObject = null; + } + if (unreadMessageObject == null) { + TLRPC.Message dateMsg = new TLRPC.Message(); + dateMsg.message = ""; + dateMsg.id = 0; + MessageObject dateObj = new MessageObject(dateMsg, null, false); + dateObj.contentType = dateObj.type = 6; + messages.add(0, dateObj); + unreadMessageObject = dateObj; + scrollToMessage = unreadMessageObject; + scrollToMessageMiddleScreen = false; + unreadUpdated = false; + unread_to_load = 0; + scrollToTopUnReadOnResume = true; + } + } + if (unreadMessageObject != null) { + unread_to_load++; + unreadUpdated = true; + } + if (obj.isUnread()) { if (!paused) { obj.setIsRead(); } markAsRead = true; } + } dayArray.add(0, obj); messages.add(0, obj); if (obj.type == 10 || obj.type == 11) { @@ -3489,13 +3413,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not progressView.setVisibility(View.INVISIBLE); } if (chatAdapter != null) { - chatAdapter.notifyDataSetChanged(); + if (unreadUpdated) { + chatAdapter.updateRowWithMessageObject(unreadMessageObject); + } + if (messages.size() - oldCount != 0) { + chatAdapter.notifyItemRangeInserted(chatAdapter.getItemCount(), messages.size() - oldCount); + } } else { scrollToTopOnResume = true; } if (chatListView != null && chatAdapter != null) { - int lastVisible = chatListView.getLastVisiblePosition(); + int lastVisible = chatLayoutManager.findLastVisibleItemPosition(); if (endReached) { lastVisible++; } @@ -3617,7 +3546,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } if (updated && chatAdapter != null) { - removeUnreadPlane(false); + removeUnreadPlane(); chatAdapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.messageReceivedByServer) { @@ -3636,7 +3565,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not obj.messageOwner.id = newMsgId; obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; updateVisibleRows(); - if (mediaUpdated && chatListView.getLastVisiblePosition() >= messages.size() - 1) { + if (mediaUpdated && chatLayoutManager.findLastVisibleItemPosition() >= messages.size() - 1) { moveScrollToLastMessage(); } } @@ -3677,7 +3606,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateContactStatus(); updateSecretStatus(); } - } else if (id == NotificationCenter.messagesReadedEncrypted) { + } else if (id == NotificationCenter.messagesReadEncrypted) { int encId = (Integer) args[0]; if (currentEncryptedChat != null && currentEncryptedChat.id == encId) { int date = (Integer) args[1]; @@ -3810,13 +3739,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int idx = messages.indexOf(old); if (idx >= 0) { messages.set(idx, messageObject); + chatAdapter.notifyItemChanged(messages.size() - (!endReached ? 0 : 1) - idx); changed = true; } } } if (changed) { - chatAdapter.notifyDataSetChanged(); - if (mediaUpdated && chatListView.getLastVisiblePosition() >= messages.size() - 1) { + if (mediaUpdated && chatLayoutManager.findLastVisibleItemPosition() >= messages.size() - 1) { moveScrollToLastMessage(); } } @@ -3841,7 +3770,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (updated) { updateVisibleRows(); - if (chatListView.getLastVisiblePosition() >= messages.size() - 1) { + if (chatLayoutManager.findLastVisibleItemPosition() >= messages.size() - 1) { moveScrollToLastMessage(); } } @@ -3855,6 +3784,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } + } else if (id == NotificationCenter.messagesReadContent) { + ArrayList arrayList = (ArrayList) args[0]; + boolean updated = false; + for (Integer mid : arrayList) { + MessageObject currentMessage = messagesDict.get(mid); + if (currentMessage != null) { + currentMessage.setContentIsRead(); + updated = true; + } + } + if (updated) { + updateVisibleRows(); + } } } @@ -3932,10 +3874,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); } - if (chatAdapter != null) { - chatAdapter.notifyDataSetChanged(); - } - checkActionBarMenu(); if (replyImageLocation != null && replyImageView != null) { replyImageView.setImage(replyImageLocation, "50_50", (Drawable) null); @@ -3946,7 +3884,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (scrollToTopUnReadOnResume && scrollToMessage != null) { if (chatListView != null) { final int yOffset = scrollToMessageMiddleScreen ? Math.max(0, (chatListView.getHeight() - scrollToMessage.getApproximateHeight()) / 2) : 0; - chatListView.setSelectionFromTop(messages.size() - messages.indexOf(scrollToMessage), -chatListView.getPaddingTop() - AndroidUtilities.dp(7) + yOffset); + chatLayoutManager.scrollToPositionWithOffset(messages.size() - messages.indexOf(scrollToMessage), -chatListView.getPaddingTop() - AndroidUtilities.dp(7) + yOffset); } } else { moveScrollToLastMessage(); @@ -3968,6 +3906,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not readWhenResume = false; MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).getId(), readWithMid, 0, readWithDate, true, false); } + if (wasPaused) { + wasPaused = false; + if (chatAdapter != null) { + chatAdapter.notifyDataSetChanged(); + } + } fixLayout(true); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); @@ -3983,7 +3927,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not byte[] bytes = Base64.decode(lastReplyMessage, Base64.DEFAULT); if (bytes != null) { SerializedData data = new SerializedData(bytes); - TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message != null) { replyingMessageObject = new MessageObject(message, MessagesController.getInstance().getUsers(), false); showReplyPanel(true, replyingMessageObject, null, null, false, false); @@ -4005,7 +3949,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - openVideoEditor(startVideoEdit, false); + openVideoEditor(startVideoEdit, false, false); startVideoEdit = null; } }); @@ -4047,6 +3991,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not menuItem.closeSubMenu(); } paused = true; + wasPaused = true; NotificationsController.getInstance().setOpennedDialogId(0); if (chatActivityEnterView != null) { chatActivityEnterView.hideEmojiPopup(); @@ -4076,7 +4021,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not editor.commit(); } - MessagesController.getInstance().cancelTyping(dialog_id); + MessagesController.getInstance().cancelTyping(0, dialog_id); if (currentEncryptedChat != null) { chatLeaveTime = System.currentTimeMillis(); @@ -4146,22 +4091,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); } - if (!resume && chatListView != null) { - final int lastPos = chatListView.getLastVisiblePosition(); - chatListView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - if (chatListView == null) { - return false; - } - chatListView.getViewTreeObserver().removeOnPreDrawListener(this); - if (lastPos >= messages.size() - 1) { - moveScrollToLastMessage(); - } - return false; - } - }); - } } @Override @@ -4344,7 +4273,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void onClick(DialogInterface dialogInterface, int i) { ArrayList ids = new ArrayList<>(); ids.add(finalSelectedObject.getId()); - removeUnreadPlane(true); + removeUnreadPlane(); ArrayList random_ids = null; if (currentEncryptedChat != null && finalSelectedObject.messageOwner.random_id != 0 && finalSelectedObject.type != 10) { random_ids = new ArrayList<>(); @@ -4656,38 +4585,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (AndroidUtilities.isTablet()) { actionBar.hideActionMode(); } - } + updateVisibleRows(); } } - -// the function "forwardSelectedMessages" was replaced with "openProfileWithUsername" - // FADTODO - private void forwardSelectedMessages(long did, boolean fromMyName) { - if (forwaringMessage != null) { - if (QuoteForward) { - if (forwaringMessage.messageOwner.id > 0) { - SendMessagesHelper.getInstance().sendMessage(forwaringMessage, did); - } - } else { - SendMessagesHelper.getInstance().processForwardFromMyName(forwaringMessage, did); - } - forwaringMessage = null; - } else { - ArrayList ids = new ArrayList<>(selectedMessagesIds.keySet()); - Collections.sort(ids); - for (Integer id : ids) { - if (QuoteForward) { - if (id > 0) { - SendMessagesHelper.getInstance().sendMessage(selectedMessagesIds.get(id), did); - } - } else { - SendMessagesHelper.getInstance().processForwardFromMyName(selectedMessagesIds.get(id), did); - } - } - selectedMessagesCanCopyIds.clear(); - selectedMessagesIds.clear(); - actionBar.hideActionMode(); - } } @Override @@ -4862,26 +4762,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return 0; } - private class ChatAdapter extends BaseFragmentAdapter { + public class ChatActivityAdapter extends RecyclerView.Adapter { private Context mContext; - public ChatAdapter(Context context) { + public ChatActivityAdapter(Context context) { mContext = context; } - @Override - public boolean areAllItemsEnabled() { - return true; + private class Holder extends RecyclerView.ViewHolder { + + public Holder(View itemView) { + super(itemView); + } } @Override - public boolean isEnabled(int i) { - return true; - } - - @Override - public int getCount() { + public int getItemCount() { int count = messages.size(); if (count != 0) { if (!endReached) { @@ -4894,64 +4791,41 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return count; } - @Override - public Object getItem(int i) { - return null; - } - @Override public long getItemId(int i) { - return i; + return RecyclerExListView.NO_ID; } @Override - public boolean hasStableIds() { - return true; - } - - @Override - public View getView(int i, View view, ViewGroup viewGroup) { - int offset = 1; - if ((!endReached || !forward_end_reached) && messages.size() != 0) { - if (!endReached) { - offset = 0; - } - if (i == 0 && !endReached || !forward_end_reached && i == (messages.size() + 1 - offset)) { - View progressBar = null; - if (view == null) { - LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.chat_loading_layout, viewGroup, false); - progressBar = view.findViewById(R.id.progressLayout); - if (ApplicationLoader.isCustomTheme()) { - progressBar.setBackgroundResource(R.drawable.system_loader2); - } else { - progressBar.setBackgroundResource(R.drawable.system_loader1); - } - } else { - progressBar = view.findViewById(R.id.progressLayout); - } - progressBar.setVisibility(loadsCount > 1 ? View.VISIBLE : View.INVISIBLE); - - return view; - } - } - final MessageObject message = messages.get(messages.size() - i - offset); - int type = message.contentType; - if (view == null) { - if (type == 0) { + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = null; + if (viewType == 0) { + if (!chatMessageCellsCache.isEmpty()) { + view = chatMessageCellsCache.get(0); + chatMessageCellsCache.remove(0); + } else { view = new ChatMessageCell(mContext); } - if (type == 1) { + } else if (viewType == 1) { + if (!chatMediaCellsCache.isEmpty()) { + view = chatMediaCellsCache.get(0); + chatMediaCellsCache.remove(0); + } else { view = new ChatMediaCell(mContext); - } else if (type == 2) { - view = new ChatAudioCell(mContext); - } else if (type == 3) { - view = new ChatContactCell(mContext); - } else if (type == 6) { + } + } else if (viewType == 2) { + view = new ChatAudioCell(mContext); + } else if (viewType == 3) { + view = new ChatContactCell(mContext); + } else if (viewType == 4) { + view = new ChatActionCell(mContext); + } else if (viewType == 5) { + LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + view = li.inflate(R.layout.chat_loading_layout, parent, false); + view.findViewById(R.id.progressLayout).setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_loader2 : R.drawable.system_loader1); + } else if (viewType == 6) { LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.chat_unread_layout, viewGroup, false); - } else if (type == 4) { - view = new ChatActionCell(mContext); + view = li.inflate(R.layout.chat_unread_layout, parent, false); } if (view instanceof ChatBaseCell) { @@ -5176,8 +5050,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); } + + return new Holder(view); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + int viewType = holder.getItemViewType(); + if (viewType == 5) { + holder.itemView.findViewById(R.id.progressLayout).setVisibility(loadsCount > 1 ? View.VISIBLE : View.INVISIBLE); + return; } + MessageObject message = messages.get(messages.size() - position - (!endReached ? 0 : 1)); + View view = holder.itemView; + + int type = message.contentType; + boolean selected = false; boolean disableSelection = false; if (actionBar.isActionModeShowed()) { @@ -5204,48 +5093,63 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else if (view instanceof ChatActionCell) { ChatActionCell actionCell = (ChatActionCell) view; actionCell.setMessageObject(message); - } - if (type == 6) { + } else if (type == 6) { TextView messageTextView = (TextView) view.findViewById(R.id.chat_message_text); messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load)); } - - return view; } @Override - public int getItemViewType(int i) { + public int getItemViewType(int position) { int offset = 1; if (!endReached && messages.size() != 0) { offset = 0; - if (i == 0) { + if (position == 0) { return 5; } } - if (!forward_end_reached && i == (messages.size() + 1 - offset)) { + if (!forward_end_reached && position == (messages.size() + 1 - offset)) { return 5; } - MessageObject message = messages.get(messages.size() - i - offset); + MessageObject message = messages.get(messages.size() - position - offset); return message.contentType; } @Override - public int getViewTypeCount() { - return 7; + public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { + if (holder.itemView instanceof ChatBaseCell) { + ChatBaseCell baseCell = (ChatBaseCell) holder.itemView; + baseCell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && baseCell.getMessageObject().getId() == highlightMessageId); + } + if (holder.itemView instanceof ChatMessageCell) { + final ChatMessageCell messageCell = (ChatMessageCell) holder.itemView; + messageCell.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + messageCell.getViewTreeObserver().removeOnPreDrawListener(this); + messageCell.getLocalVisibleRect(scrollRect); + messageCell.setVisiblePart(scrollRect.top, scrollRect.bottom - scrollRect.top); + return true; + } + }); + } + } + + public void updateRowWithMessageObject(MessageObject messageObject) { + int index = messages.indexOf(messageObject); + if (index == -1) { + return; + } + notifyItemChanged(messages.size() - (!endReached ? 0 : 1) - index); } - @Override - public boolean isEmpty() { - int count = messages.size(); - if (count != 0) { - if (!endReached) { - count++; - } - if (!forward_end_reached) { - count++; - } + public void removeMessageObject(MessageObject messageObject) { + int index = messages.indexOf(messageObject); + if (index == -1) { + return; } - return count == 0; + messages.remove(index); + notifyItemRemoved(messages.size() - (!endReached ? 0 : 1) - index); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java index 5a96cb4b..d8c30f25 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java @@ -9,7 +9,6 @@ package org.telegram.ui.Components; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.Rect; @@ -21,11 +20,11 @@ import android.text.StaticLayout; import android.text.TextPaint; import org.telegram.android.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; -import org.telegram.messenger.ApplicationLoader; import java.util.Locale; @@ -76,6 +75,7 @@ public class AvatarDrawable extends Drawable { private boolean drawBrodcast; private boolean drawPhoto; private boolean smallStyle; + private StringBuilder stringBuilder = new StringBuilder(5); private int radius; public AvatarDrawable() { @@ -240,9 +240,9 @@ public class AvatarDrawable extends Drawable { lastName = null; } - String text = ""; + stringBuilder.setLength(0); if (firstName != null && firstName.length() > 0) { - text += firstName.substring(0, 1); + stringBuilder.append(firstName.substring(0, 1)); } if (lastName != null && lastName.length() > 0) { String lastch = null; @@ -253,27 +253,25 @@ public class AvatarDrawable extends Drawable { lastch = lastName.substring(a, a + 1); } if (Build.VERSION.SDK_INT >= 16) { - text += "\u200C" + lastch; - } else { - text += lastch; - } + stringBuilder.append("\u200C"); + } + stringBuilder.append(lastch); } else if (firstName != null && firstName.length() > 0) { for (int a = firstName.length() - 1; a >= 0; a--) { if (firstName.charAt(a) == ' ') { if (a != firstName.length() - 1 && firstName.charAt(a + 1) != ' ') { if (Build.VERSION.SDK_INT >= 16) { - text += "\u200C" + firstName.substring(a + 1, a + 2); - } else { - text += firstName.substring(a + 1, a + 2); + stringBuilder.append("\u200C"); } + stringBuilder.append(firstName.substring(a + 1, a + 2)); break; } } } } - if (text.length() > 0) { - text = text.toUpperCase(); + if (stringBuilder.length() > 0) { + String text = stringBuilder.toString().toUpperCase(); try { textLayout = new StaticLayout(text, (smallStyle ? namePaintSmall : namePaint), AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (textLayout.getLineCount() > 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java index 872ea924..f9737953 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java @@ -74,10 +74,10 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg } public void openGallery() { - PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true); + PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true, null); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override - public void didSelectPhotos(ArrayList photos, ArrayList webPhotos) { + public void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos) { if (!photos.isEmpty()) { Bitmap bitmap = ImageLoader.loadBitmap(photos.get(0), null, 800, 800, true); processBitmap(bitmap); @@ -94,6 +94,11 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg FileLog.e("tmessages", e); } } + + @Override + public boolean didSelectVideo(String path) { + return true; + } }); parentFragment.presentFragment(fragment); } @@ -143,7 +148,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg FileLog.e("tmessages", e); } final ArrayList arrayList = new ArrayList<>(); - arrayList.add(new MediaController.PhotoEntry(0, 0, 0, currentPicturePath, orientation)); + arrayList.add(new MediaController.PhotoEntry(0, 0, 0, currentPicturePath, orientation, false)); PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 1, new PhotoViewer.EmptyPhotoViewerProvider() { @Override public void sendButtonPressed(int index) { @@ -157,7 +162,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg Bitmap bitmap = ImageLoader.loadBitmap(path, null, 800, 800, true); processBitmap(bitmap); } - }); + }, null); Utilities.addMediaToGallery(currentPicturePath); currentPicturePath = null; } else if (requestCode == 14) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java index 156bab8d..3d991dde 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java @@ -23,6 +23,8 @@ import org.telegram.messenger.TLRPC; public class BackupImageView extends View { private ImageReceiver imageReceiver; + private int width = -1; + private int height = -1; public BackupImageView(Context context) { super(context); @@ -102,15 +104,30 @@ public class BackupImageView extends View { return imageReceiver; } + public void setSize(int w, int h) { + width = w; + height = h; + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - imageReceiver.clearImage(); - } + imageReceiver.onDetachedFromWindow(); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + imageReceiver.onAttachedToWindow(); + } @Override protected void onDraw(Canvas canvas) { - imageReceiver.setImageCoords(0, 0, getWidth(), getHeight()); + if (width != -1 && height != -1) { + imageReceiver.setImageCoords((getWidth() - width) / 2, (getHeight() - height) / 2, width, height); + } else { + imageReceiver.setImageCoords(0, 0, getWidth(), getHeight()); + } imageReceiver.draw(canvas); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 62005691..d1d46eba 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -14,7 +14,6 @@ import android.content.SharedPreferences; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.media.AudioManager; -import android.os.Build; import android.os.PowerManager; import android.text.Editable; import android.text.TextWatcher; @@ -25,6 +24,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.inputmethod.EditorInfo; @@ -33,10 +33,13 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; -import android.widget.RelativeLayout; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.Emoji; import org.telegram.android.LocaleController; import org.telegram.android.MediaController; @@ -51,12 +54,6 @@ import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; - -import java.lang.reflect.Field; public class ChatActivityEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate { @@ -83,6 +80,12 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private LinearLayout textFieldContainer; private View topView; + private int framesDroped; + + private int keyboardTransitionState; + private boolean showKeyboardOnEmojiButton; + private ViewTreeObserver.OnPreDrawListener onPreDrawListener; + private PowerManager.WakeLock mWakeLock; private AnimatorSetProxy runningAnimation; private AnimatorSetProxy runningAnimation2; @@ -100,6 +103,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private float distCanMove = AndroidUtilities.dp(80); private boolean recordingAudio; private boolean forceShowSendButton; + private boolean allowStickers; private Activity parentActivity; private BaseFragment parentFragment; @@ -107,7 +111,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private boolean ignoreTextChange; private MessageObject replyingMessageObject; private TLRPC.WebPage messageWebPage; - private boolean messageWebPageSearch; + private boolean messageWebPageSearch = true; private ChatActivityEnterViewDelegate delegate; private float topViewAnimation; @@ -138,14 +142,39 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); sendByEnter = preferences.getBoolean("send_by_enter", false); + parent.getViewTreeObserver().addOnPreDrawListener(onPreDrawListener = new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + if (keyboardTransitionState == 1) { + if (keyboardVisible || framesDroped >= 60) { + showEmojiPopup(false, false); + keyboardTransitionState = 0; + } else { + openKeyboard(); + } + framesDroped++; + return false; + } else if (keyboardTransitionState == 2) { + if (!keyboardVisible || framesDroped >= 60) { + int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight; + sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight); + keyboardTransitionState = 0; + } + framesDroped++; + return false; + } + return true; + } + }); + textFieldContainer = new LinearLayout(context); textFieldContainer.setBackgroundColor(0xffffffff); textFieldContainer.setOrientation(LinearLayout.HORIZONTAL); addView(textFieldContainer); LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); layoutParams2.gravity = Gravity.LEFT | Gravity.TOP; - layoutParams2.width = LayoutParams.MATCH_PARENT; - layoutParams2.height = LayoutParams.WRAP_CONTENT; + layoutParams2.width = LayoutHelper.MATCH_PARENT; + layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.topMargin = AndroidUtilities.dp(2); textFieldContainer.setLayoutParams(layoutParams2); @@ -153,7 +182,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat textFieldContainer.addView(frameLayout); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = 0; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.weight = 1; frameLayout.setLayoutParams(layoutParams); @@ -175,7 +204,16 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat emojiButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - showEmojiPopup(emojiPopup == null || !emojiPopup.isShowing()); + if (showKeyboardOnEmojiButton) { + setKeyboardTransitionState(1); + int selection = messageEditText.getSelectionStart(); + MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0); + messageEditText.onTouchEvent(event); + event.recycle(); + messageEditText.setSelection(selection); + } else { + showEmojiPopup(emojiPopup == null || !emojiPopup.isShowing(), true); + } } }); @@ -194,8 +232,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat messageEditText.setHintTextColor(0xffb2b2b2); frameLayout.addView(messageEditText); layoutParams1 = (FrameLayout.LayoutParams) messageEditText.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.gravity = Gravity.BOTTOM; layoutParams1.leftMargin = AndroidUtilities.dp(52); layoutParams1.rightMargin = AndroidUtilities.dp(isChat ? 50 : 2); @@ -205,7 +243,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat public boolean onKey(View view, int i, KeyEvent keyEvent) { if (i == 4 && !keyboardVisible && emojiPopup != null && emojiPopup.isShowing()) { if (keyEvent.getAction() == 1) { - showEmojiPopup(false); + showEmojiPopup(false, true); } return true; } else if (i == KeyEvent.KEYCODE_ENTER && sendByEnter && keyEvent.getAction() == KeyEvent.ACTION_DOWN) { @@ -219,7 +257,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat @Override public void onClick(View view) { if (emojiPopup != null && emojiPopup.isShowing()) { - showEmojiPopup(false); + setKeyboardTransitionState(1); } } }); @@ -250,10 +288,10 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat checkSendButton(true); if (delegate != null) { - if (before > count || count > 1) { + if (count > 2 || charSequence == null || charSequence.length() == 0) { messageWebPageSearch = true; } - delegate.onTextChanged(charSequence, before > count || count > 1); + delegate.onTextChanged(charSequence, before > count + 1 || (count - before) > 2); } if (message.length() != 0 && lastTypingTimeSend < System.currentTimeMillis() - 5000 && !ignoreTextChange) { @@ -308,7 +346,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat recordPanel.setBackgroundColor(0xffffffff); frameLayout.addView(recordPanel); layoutParams1 = (FrameLayout.LayoutParams) recordPanel.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = AndroidUtilities.dp(48); layoutParams1.gravity = Gravity.BOTTOM; recordPanel.setLayoutParams(layoutParams1); @@ -317,8 +355,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat slideText.setOrientation(LinearLayout.HORIZONTAL); recordPanel.addView(slideText); layoutParams1 = (FrameLayout.LayoutParams) slideText.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.gravity = Gravity.CENTER; layoutParams1.leftMargin = AndroidUtilities.dp(30); slideText.setLayoutParams(layoutParams1); @@ -327,8 +365,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat imageView.setImageResource(R.drawable.slidearrow); slideText.addView(imageView); layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.topMargin = AndroidUtilities.dp(1); imageView.setLayoutParams(layoutParams); @@ -339,8 +377,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); slideText.addView(textView); layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.leftMargin = AndroidUtilities.dp(6); textView.setLayoutParams(layoutParams); @@ -351,8 +389,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat linearLayout.setBackgroundColor(0xffffffff); recordPanel.addView(linearLayout); layoutParams1 = (FrameLayout.LayoutParams) linearLayout.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.gravity = Gravity.CENTER_VERTICAL; linearLayout.setLayoutParams(layoutParams1); @@ -360,8 +398,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat imageView.setImageResource(R.drawable.rec); linearLayout.addView(imageView); layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.topMargin = AndroidUtilities.dp(1); imageView.setLayoutParams(layoutParams); @@ -372,8 +410,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat recordTimeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); linearLayout.addView(recordTimeText); layoutParams = (LinearLayout.LayoutParams) recordTimeText.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.leftMargin = AndroidUtilities.dp(6); recordTimeText.setLayoutParams(layoutParams); @@ -521,6 +559,26 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat textFieldContainer.setBackgroundColor(color); } + private void setKeyboardTransitionState(int state) { + if (AndroidUtilities.usingHardwareInput) { + if (state == 1) { + showEmojiPopup(false, false); + keyboardTransitionState = 0; + + } else if (state == 2) { + int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight; + sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight); + keyboardTransitionState = 0; + } + } else { + framesDroped = 0; + keyboardTransitionState = state; + if (state == 1) { + sizeNotifierRelativeLayout.setPadding(0, 0, 0, 0); + } + } + } + public void addTopView(View view, int height) { if (view == null) { return; @@ -530,7 +588,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat topView.setVisibility(GONE); needShowTopView = false; LayoutParams layoutParams = (LayoutParams) topView.getLayoutParams(); - layoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = height; layoutParams.topMargin = AndroidUtilities.dp(2); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; @@ -553,6 +611,10 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat checkSendButton(animated); } + public void setAllowStickers(boolean value) { + allowStickers = value; + } + public void showTopView(boolean animated) { if (topView == null || topViewShowed) { return; @@ -676,6 +738,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.hideEmojiKeyboard); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioRouteChanged); + sizeNotifierRelativeLayout.getViewTreeObserver().removeOnPreDrawListener(onPreDrawListener); if (mWakeLock != null) { try { mWakeLock.release(); @@ -702,6 +765,10 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat messageWebPageSearch = searchWebPages; } + public boolean isMessageWebPageSearchEnabled() { + return messageWebPageSearch; + } + private void sendMessage() { if (parentFragment != null) { String action = null; @@ -1010,7 +1077,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } } - private void showEmojiPopup(boolean show) { + private void showEmojiPopup(boolean show, boolean post) { SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int color = themePrefs.getInt("chatEditTextIconsColor", 0xffadadad); if (show) { @@ -1018,10 +1085,14 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat if (parentActivity == null) { return; } - emojiView = new EmojiView(parentActivity); + emojiView = new EmojiView(allowStickers, parentActivity); emojiView.setListener(new EmojiView.Listener() { - public void onBackspace() { - messageEditText.dispatchKeyEvent(new KeyEvent(0, 67)); + public boolean onBackspace() { + if (messageEditText.length() == 0) { + return false; + } + messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); + return true; } public void onEmojiSelected(String symbol) { @@ -1038,24 +1109,16 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat FileLog.e("tmessages", e); } } + + public void onStickerSelected(TLRPC.Document sticker) { + SendMessagesHelper.getInstance().sendSticker(sticker, dialog_id, replyingMessageObject); + if (delegate != null) { + delegate.onMessageSend(null); + } + } }); emojiPopup = new PopupWindow(emojiView); - - if (Build.VERSION.SDK_INT >= 21) { - /*emojiPopup.setAnimationStyle(0); - emojiPopup.setClippingEnabled(true); - emojiPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); - emojiPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);*/ - try { - Field field = PopupWindow.class.getDeclaredField("mWindowLayoutType"); - field.setAccessible(true); - field.set(emojiPopup, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); - } catch (Exception e) { - //ignored - } - } } - int currentHeight; if (keyboardHeight <= 0) { keyboardHeight = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).getInt("kbd_height", AndroidUtilities.dp(200)); @@ -1063,11 +1126,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat if (keyboardHeightLand <= 0) { keyboardHeightLand = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).getInt("kbd_height_land3", AndroidUtilities.dp(200)); } - if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) { - currentHeight = keyboardHeightLand; - } else { - currentHeight = keyboardHeight; - } + int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight; FileLog.e("tmessages", "show emoji with height = " + currentHeight); emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY)); if (sizeNotifierRelativeLayout != null) { @@ -1076,52 +1135,30 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), Gravity.BOTTOM | Gravity.LEFT, 0, 0); - /*if (Build.VERSION.SDK_INT < 21) { - try { - - } catch (Exception e) { - FileLog.e("tmessages", e); - return; - } - }*/ - if (!keyboardVisible) { - /*if (Build.VERSION.SDK_INT >= 21) { - try { - emojiPopup.showAsDropDown(this, 0, 0); - } catch (Exception e) { - FileLog.e("tmessages", e); - return; - } - }*/ if (sizeNotifierRelativeLayout != null) { sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight); //emojiButton.setImageResource(R.drawable.ic_msg_panel_hide); Drawable hide = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_hide); hide.setColorFilter(color, PorterDuff.Mode.SRC_IN); emojiButton.setImageDrawable(hide); + showKeyboardOnEmojiButton = false; onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom()); } return; } else { - /*if (Build.VERSION.SDK_INT >= 21) { - try { - emojiPopup.showAsDropDown(this, 0, -currentHeight - getHeight()); - emojiPopup.update(this, 0, -currentHeight - getHeight(), -1, -1); + setKeyboardTransitionState(2); AndroidUtilities.hideKeyboard(messageEditText); - } catch (Exception e) { - FileLog.e("tmessages", e); - return; - } - }*/ } //emojiButton.setImageResource(R.drawable.ic_msg_panel_kb); Drawable kb = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_kb_white); kb.setColorFilter(color, PorterDuff.Mode.MULTIPLY); emojiButton.setImageDrawable(kb); + showKeyboardOnEmojiButton = true; return; } if (emojiButton != null) { + showKeyboardOnEmojiButton = false; //emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles); Drawable emoji = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_smiles); emoji.setColorFilter(color, PorterDuff.Mode.SRC_IN); @@ -1134,21 +1171,28 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat //don't promt } } - if (sizeNotifierRelativeLayout != null) { + if (keyboardTransitionState == 0) { + if (sizeNotifierRelativeLayout != null) { + if (post) { sizeNotifierRelativeLayout.post(new Runnable() { public void run() { if (sizeNotifierRelativeLayout != null) { sizeNotifierRelativeLayout.setPadding(0, 0, 0, 0); - onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom()); + onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight()); } } }); + } else { + sizeNotifierRelativeLayout.setPadding(0, 0, 0, 0); + onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight()); + } + } } } public void hideEmojiPopup() { if (emojiPopup != null && emojiPopup.isShowing()) { - showEmojiPopup(false); + showEmojiPopup(false, true); } } @@ -1244,7 +1288,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); layoutParams.gravity = Gravity.CENTER; layoutParams.width = AndroidUtilities.dp(48); - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; view.setLayoutParams(layoutParams); } @@ -1270,13 +1314,6 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) emojiPopup.getContentView().getLayoutParams(); FileLog.e("tmessages", "update emoji height to = " + newHeight); if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) { - /*if (Build.VERSION.SDK_INT >= 21) { - if (!keyboardVisible) { - emojiPopup.update(this, 0, 0, -1, -1); - } else { - emojiPopup.update(this, 0, -newHeight - getHeight(), -1, -1); - } - }*/ layoutParams.width = AndroidUtilities.displaySize.x; layoutParams.height = newHeight; WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); @@ -1295,12 +1332,22 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat boolean oldValue = keyboardVisible; keyboardVisible = height > 0; - if (keyboardVisible && sizeNotifierRelativeLayout.getPaddingBottom() > 0) { - showEmojiPopup(false); - } else if (!keyboardVisible && keyboardVisible != oldValue && emojiPopup != null && emojiPopup.isShowing()) { - showEmojiPopup(false); + if (keyboardVisible && (sizeNotifierRelativeLayout.getPaddingBottom() > 0 || keyboardTransitionState == 1)) { + setKeyboardTransitionState(1); + } else if (keyboardTransitionState != 2 && !keyboardVisible && keyboardVisible != oldValue && emojiPopup != null && emojiPopup.isShowing()) { + showEmojiPopup(false, true); + } + if (keyboardTransitionState == 0) { + onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom()); + } + } + + public int getEmojiHeight() { + if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) { + return keyboardHeightLand; + } else { + return keyboardHeight; } - onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom()); } @Override @@ -1313,6 +1360,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat Long time = (Long) args[0] / 1000; String str = String.format("%02d:%02d", time / 60, time % 60); if (lastTimeString == null || !lastTimeString.equals(str)) { + if (time % 5 == 0) { + MessagesController.getInstance().sendTyping(dialog_id, 1, 0); + } if (recordTimeText != null) { recordTimeText.setText(str); } @@ -1323,6 +1373,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } } else if (id == NotificationCenter.recordStartError || id == NotificationCenter.recordStopped) { if (recordingAudio) { + MessagesController.getInstance().sendTyping(dialog_id, 2, 0); recordingAudio = false; updateAudioRecordIntefrace(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java index a34b7a98..95707a7f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java @@ -18,7 +18,7 @@ import android.graphics.drawable.Drawable; import android.view.View; import org.telegram.android.AndroidUtilities; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; public class CheckBox extends View { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java index 3c17e47e..ad8217f3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java @@ -18,8 +18,8 @@ import android.graphics.RectF; import android.graphics.Shader; import android.view.View; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.messenger.FileLog; -import org.telegram.ui.AnimationCompat.ViewProxy; public class ClippingImageView extends View { @@ -32,7 +32,6 @@ public class ClippingImageView extends View { private Paint paint; private Bitmap bmp; private Matrix matrix; - private onDrawListener drawListener; private boolean needRadius; private int radius; @@ -42,9 +41,8 @@ public class ClippingImageView extends View { private RectF bitmapRect; private Matrix shaderMatrix; - public interface onDrawListener { - void onDraw(); - } + private float animationProgress; + private float animationValues[][]; public ClippingImageView(Context context) { super(context); @@ -55,6 +53,29 @@ public class ClippingImageView extends View { bitmapRect = new RectF(); } + public void setAnimationValues(float[][] values) { + animationValues = values; + } + + public float getAnimationProgress() { + return animationProgress; + } + + public void setAnimationProgress(float progress) { + animationProgress = progress; + + ViewProxy.setScaleX(this, animationValues[0][0] + (animationValues[1][0] - animationValues[0][0]) * animationProgress); + ViewProxy.setScaleY(this, animationValues[0][1] + (animationValues[1][1] - animationValues[0][1]) * animationProgress); + ViewProxy.setTranslationX(this, animationValues[0][2] + (animationValues[1][2] - animationValues[0][2]) * animationProgress); + ViewProxy.setTranslationY(this, animationValues[0][3] + (animationValues[1][3] - animationValues[0][3]) * animationProgress); + setClipHorizontal((int) (animationValues[0][4] + (animationValues[1][4] - animationValues[0][4]) * animationProgress)); + setClipTop((int) (animationValues[0][5] + (animationValues[1][5] - animationValues[0][5]) * animationProgress)); + setClipBottom((int) (animationValues[0][6] + (animationValues[1][6] - animationValues[0][6]) * animationProgress)); + setRadius((int) (animationValues[0][7] + (animationValues[1][7] - animationValues[0][7]) * animationProgress)); + + invalidate(); + } + public int getClipBottom() { return clipBottom; } @@ -85,9 +106,6 @@ public class ClippingImageView extends View { } if (bmp != null) { float scaleY = ViewProxy.getScaleY(this); - if (drawListener != null && scaleY != 1) { - drawListener.onDraw(); - } canvas.save(); if (needRadius) { @@ -174,10 +192,6 @@ public class ClippingImageView extends View { invalidate(); } - public void setOnDrawListener(onDrawListener listener) { - drawListener = listener; - } - public void setNeedRadius(boolean value) { needRadius = value; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java index 262163d9..ad6abf7d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java @@ -14,7 +14,9 @@ import android.database.DataSetObserver; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.text.TextUtils; -import android.util.AttributeSet; +import android.view.Gravity; +import android.view.HapticFeedbackConstants; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; @@ -27,62 +29,193 @@ import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.Emoji; import org.telegram.android.LocaleController; +import org.telegram.android.NotificationCenter; +import org.telegram.android.query.StickersQuery; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.R; +import org.telegram.messenger.TLRPC; +import org.telegram.ui.Cells.StickerEmojiCell; import java.util.ArrayList; -public class EmojiView extends LinearLayout { +public class EmojiView extends LinearLayout implements NotificationCenter.NotificationCenterDelegate { + + public interface Listener { + boolean onBackspace(); + void onEmojiSelected(String emoji); + void onStickerSelected(TLRPC.Document sticker); + } private ArrayList adapters = new ArrayList<>(); + private StickersGridAdapter stickersGridAdapter; private int[] icons = { R.drawable.ic_emoji_recent, R.drawable.ic_emoji_smile, R.drawable.ic_emoji_flower, R.drawable.ic_emoji_bell, R.drawable.ic_emoji_car, - R.drawable.ic_emoji_symbol }; + R.drawable.ic_emoji_symbol, + R.drawable.ic_emoji_sticker}; + private Listener listener; private ViewPager pager; private FrameLayout recentsWrap; private ArrayList views = new ArrayList<>(); + private ImageView backspaceButton; + + private boolean backspacePressed; + private boolean backspaceOnce; + + public EmojiView(boolean needStickers, Context context) { + super(context); + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int bgColor = themePrefs.getInt("chatEmojiViewBGColor", 0xfff5f6f7); + int tabColor = themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x15)); + int lineColor = bgColor == 0xfff5f6f7 ? 0xffe2e5e7 : AndroidUtilities.setDarkColor(bgColor, 0x10); + setOrientation(LinearLayout.VERTICAL); + for (int i = 0; i < Emoji.data.length; i++) { + GridView gridView = new GridView(context); + if (AndroidUtilities.isTablet()) { + gridView.setColumnWidth(AndroidUtilities.dp(60)); + } else { + gridView.setColumnWidth(AndroidUtilities.dp(45)); + } + gridView.setNumColumns(-1); + views.add(gridView); + + EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); + gridView.setAdapter(emojiGridAdapter); + //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); + AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor); + adapters.add(emojiGridAdapter); + } + + if (needStickers) { + GridView gridView = new GridView(context); + gridView.setColumnWidth(AndroidUtilities.dp(72)); + gridView.setNumColumns(-1); + gridView.setPadding(0, AndroidUtilities.dp(4), 0, 0); + gridView.setClipToPadding(false); + views.add(gridView); + stickersGridAdapter = new StickersGridAdapter(context); + gridView.setAdapter(stickersGridAdapter); + //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); + AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor); + } + + //setBackgroundColor(0xfff5f6f7); + setBackgroundColor(bgColor); + + pager = new ViewPager(context); + pager.setAdapter(new EmojiPagesAdapter()); + + LinearLayout linearLayout = new LinearLayout(context); + linearLayout.setOrientation(LinearLayout.HORIZONTAL); + //linearLayout.setBackgroundColor(0xfff5f6f7); + linearLayout.setBackgroundColor(bgColor); + addView(linearLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtilities.dp(48))); + + PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(context); + tabs.setViewPager(pager); + tabs.setShouldExpand(true); + tabs.setIndicatorHeight(AndroidUtilities.dp(2)); + tabs.setUnderlineHeight(AndroidUtilities.dp(1)); + //tabs.setIndicatorColor(0xff2b96e2); + tabs.setIndicatorColor(tabColor); + //tabs.setUnderlineColor(0xffe2e5e7); + tabs.setUnderlineColor(lineColor); + linearLayout.addView(tabs, new LinearLayout.LayoutParams(0, AndroidUtilities.dp(48), 1.0f)); + + FrameLayout frameLayout = new FrameLayout(context); + linearLayout.addView(frameLayout, new LinearLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48))); + + backspaceButton = new ImageView(context) { + @Override + public boolean onTouchEvent(MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + backspacePressed = true; + backspaceOnce = false; + postBackspaceRunnable(350); + } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) { + backspacePressed = false; + if (!backspaceOnce) { + if (EmojiView.this.listener != null && EmojiView.this.listener.onBackspace()) { + backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); + } + } + } + super.onTouchEvent(event); + return true; + } + }; + backspaceButton.setImageResource(R.drawable.ic_smiles_backspace); + backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace); + backspaceButton.setScaleType(ImageView.ScaleType.CENTER); + frameLayout.addView(backspaceButton, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48))); + + View view = new View(context); + //view.setBackgroundColor(0xffe2e5e7); + view.setBackgroundColor(lineColor); + frameLayout.addView(view, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(1), Gravity.LEFT | Gravity.BOTTOM)); + + recentsWrap = new FrameLayout(context); + recentsWrap.addView(views.get(0)); + + TextView textView = new TextView(context); + textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); + textView.setTextSize(18); + textView.setTextColor(0xff888888); + textView.setGravity(Gravity.CENTER); + recentsWrap.addView(textView); + views.get(0).setEmptyView(textView); + + addView(pager); + + loadRecents(); + + if (Emoji.data[0] == null || Emoji.data[0].length == 0) { + pager.setCurrentItem(1); + } - public EmojiView(Context paramContext) { - super(paramContext); - init(); } - public EmojiView(Context paramContext, AttributeSet paramAttributeSet) { - super(paramContext, paramAttributeSet); - init(); + private void postBackspaceRunnable(final int time) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (!backspacePressed) { + return; + } + if (EmojiView.this.listener != null && EmojiView.this.listener.onBackspace()) { + backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); + } + backspaceOnce = true; + postBackspaceRunnable(Math.max(50, time - 100)); + } + }, time); } - public EmojiView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) { - super(paramContext, paramAttributeSet, paramInt); - init(); - } - - private void addToRecent(long paramLong) { - if (this.pager.getCurrentItem() == 0) { + private void addToRecent(long code) { + if (pager.getCurrentItem() == 0) { return; } - ArrayList localArrayList = new ArrayList<>(); + ArrayList recent = new ArrayList<>(); long[] currentRecent = Emoji.data[0]; boolean was = false; for (long aCurrentRecent : currentRecent) { - if (paramLong == aCurrentRecent) { - localArrayList.add(0, paramLong); + if (code == aCurrentRecent) { + recent.add(0, code); was = true; } else { - localArrayList.add(aCurrentRecent); + recent.add(aCurrentRecent); } } if (!was) { - localArrayList.add(0, paramLong); + recent.add(0, code); } - Emoji.data[0] = new long[Math.min(localArrayList.size(), 50)]; + Emoji.data[0] = new long[Math.min(recent.size(), 50)]; for (int q = 0; q < Emoji.data[0].length; q++) { - Emoji.data[0][q] = localArrayList.get(q); + Emoji.data[0][q] = recent.get(q); } adapters.get(0).data = Emoji.data[0]; adapters.get(0).notifyDataSetChanged(); @@ -95,82 +228,13 @@ public class EmojiView extends LinearLayout { if (i >= 4) { return str; } - int j = (int)(0xFFFF & paramLong >> 16 * (3 - i)); + int j = (int) (0xFFFF & paramLong >> 16 * (3 - i)); if (j != 0) { - str = str + (char)j; + str = str + (char) j; } } } - private void init() { - setOrientation(LinearLayout.VERTICAL); - for (int i = 0; i < Emoji.data.length; i++) { - GridView gridView = new GridView(getContext()); - if (AndroidUtilities.isTablet()) { - gridView.setColumnWidth(AndroidUtilities.dp(60)); - } else { - gridView.setColumnWidth(AndroidUtilities.dp(45)); - } - gridView.setNumColumns(-1); - views.add(gridView); - - EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); - gridView.setAdapter(localEmojiGridAdapter); - AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999); - adapters.add(localEmojiGridAdapter); - } - - setBackgroundColor(0xff222222); - pager = new ViewPager(getContext()); - pager.setAdapter(new EmojiPagesAdapter()); - PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); - tabs.setViewPager(pager); - tabs.setShouldExpand(true); - tabs.setIndicatorColor(0xff33b5e5); - tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f)); - tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f)); - tabs.setUnderlineColor(0x66000000); - tabs.setTabBackground(0); - LinearLayout localLinearLayout = new LinearLayout(getContext()); - localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); - localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); - ImageView localImageView = new ImageView(getContext()); - localImageView.setImageResource(R.drawable.ic_emoji_backspace); - localImageView.setScaleType(ImageView.ScaleType.CENTER); - localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); - localImageView.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - if (EmojiView.this.listener != null) { - EmojiView.this.listener.onBackspace(); - } - } - }); - localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT)); - recentsWrap = new FrameLayout(getContext()); - recentsWrap.addView(views.get(0)); - TextView localTextView = new TextView(getContext()); - localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); - localTextView.setTextSize(18.0f); - localTextView.setTextColor(-7829368); - localTextView.setGravity(17); - recentsWrap.addView(localTextView); - views.get(0).setEmptyView(localTextView); - addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f))); - addView(pager); - loadRecents(); - if (Emoji.data[0] == null || Emoji.data[0].length == 0) { - pager.setCurrentItem(1); - } - - updateTheme(tabs); - } - - private void updateTheme(PagerSlidingTabStrip tabs) { - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - setBackgroundColor(themePrefs.getInt("chatEmojiViewBGColor", 0xff222222)); - tabs.setIndicatorColor(themePrefs.getInt("chatEmojiViewTabColor",AndroidUtilities.getIntDarkerColor("themeColor",0x15)));//0xff33b5e5 - } - private void saveRecents() { ArrayList localArrayList = new ArrayList<>(); long[] arrayOfLong = Emoji.data[0]; @@ -187,25 +251,30 @@ public class EmojiView extends LinearLayout { public void loadRecents() { String str = getContext().getSharedPreferences("emoji", 0).getString("recents", ""); String[] arrayOfString = null; - if ((str != null) && (str.length() > 0)) { + if (str != null && str.length() > 0) { arrayOfString = str.split(","); Emoji.data[0] = new long[arrayOfString.length]; - } - if (arrayOfString != null) { for (int i = 0; i < arrayOfString.length; i++) { Emoji.data[0][i] = Long.parseLong(arrayOfString[i]); } + } else { + Emoji.data[0] = new long[]{0x00000000D83DDE02L, 0x00000000D83DDE18L, 0x0000000000002764L, 0x00000000D83DDE0DL, 0x00000000D83DDE0AL, 0x00000000D83DDE01L, + 0x00000000D83DDC4DL, 0x000000000000263AL, 0x00000000D83DDE14L, 0x00000000D83DDE04L, 0x00000000D83DDE2DL, 0x00000000D83DDC8BL, + 0x00000000D83DDE12L, 0x00000000D83DDE33L, 0x00000000D83DDE1CL, 0x00000000D83DDE48L, 0x00000000D83DDE09L, 0x00000000D83DDE03L, + 0x00000000D83DDE22L, 0x00000000D83DDE1DL, 0x00000000D83DDE31L, 0x00000000D83DDE21L, 0x00000000D83DDE0FL, 0x00000000D83DDE1EL, + 0x00000000D83DDE05L, 0x00000000D83DDE1AL, 0x00000000D83DDE4AL, 0x00000000D83DDE0CL, 0x00000000D83DDE00L, 0x00000000D83DDE0BL, + 0x00000000D83DDE06L, 0x00000000D83DDC4CL, 0x00000000D83DDE10L, 0x00000000D83DDE15L}; + } adapters.get(0).data = Emoji.data[0]; adapters.get(0).notifyDataSetChanged(); } + + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY)); } - public void onMeasure(int paramInt1, int paramInt2) { - super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(paramInt1), MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(paramInt2), MeasureSpec.EXACTLY)); - } - - public void setListener(Listener paramListener) { - this.listener = paramListener; + public void setListener(Listener value) { + listener = value; } public void invalidateViews() { @@ -216,6 +285,78 @@ public class EmojiView extends LinearLayout { } } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (stickersGridAdapter != null) { + NotificationCenter.getInstance().addObserver(this, NotificationCenter.stickersDidLoaded); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (stickersGridAdapter != null) { + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.stickersDidLoaded); + } + } + + @Override + public void didReceivedNotification(int id, Object... args) { + if (id == NotificationCenter.stickersDidLoaded) { + stickersGridAdapter.notifyDataSetChanged(); + } + } + + private class StickersGridAdapter extends BaseAdapter { + + Context context; + + public StickersGridAdapter(Context context) { + this.context = context; + StickersQuery.checkStickers(); + } + + public int getCount() { + return StickersQuery.getStickers().size(); + } + + public Object getItem(int i) { + return StickersQuery.getStickers().get(i); + } + + public long getItemId(int i) { + return StickersQuery.getStickers().get(i).id; + } + + public View getView(int i, View view, ViewGroup viewGroup) { + if (view == null) { + view = new StickerEmojiCell(context) { + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(82), MeasureSpec.EXACTLY)); + } + }; + view.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (listener != null) { + listener.onStickerSelected(((StickerEmojiCell) v).getSticker()); + } + } + }); + } + ((StickerEmojiCell) view).setSticker(StickersQuery.getStickers().get(i)); + return view; + } + + @Override + public void unregisterDataSetObserver(DataSetObserver observer) { + if (observer != null) { + super.unregisterDataSetObserver(observer); + } + } + } + private class EmojiGridAdapter extends BaseAdapter { long[] data; @@ -309,9 +450,4 @@ public class EmojiView extends LinearLayout { } } } - - public interface Listener { - void onBackspace(); - void onEmojiSelected(String paramString); - } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java index 542623e9..cd169b3f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java @@ -87,8 +87,8 @@ public class FrameLayoutFixed extends FrameLayout { child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin); childState |= getMeasuredStateFixed(child); if (measureMatchParentChildren) { - if (lp.width == LayoutParams.MATCH_PARENT || - lp.height == LayoutParams.MATCH_PARENT) { + if (lp.width == LayoutHelper.MATCH_PARENT || + lp.height == LayoutHelper.MATCH_PARENT) { mMatchParentChildren.add(child); } } @@ -122,7 +122,7 @@ public class FrameLayoutFixed extends FrameLayout { int childWidthMeasureSpec; int childHeightMeasureSpec; - if (lp.width == LayoutParams.MATCH_PARENT) { + if (lp.width == LayoutHelper.MATCH_PARENT) { childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - lp.leftMargin - lp.rightMargin, @@ -134,7 +134,7 @@ public class FrameLayoutFixed extends FrameLayout { lp.width); } - if (lp.height == LayoutParams.MATCH_PARENT) { + if (lp.height == LayoutHelper.MATCH_PARENT) { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() - getPaddingTop() - getPaddingBottom() - lp.topMargin - lp.bottomMargin, diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/HorizontalListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/HorizontalListView.java index 38728e89..093f4abb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/HorizontalListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/HorizontalListView.java @@ -7,9 +7,6 @@ */ package org.telegram.ui.Components; -import java.util.HashMap; -import java.util.LinkedList; - import android.annotation.SuppressLint; import android.content.Context; import android.database.DataSetObserver; @@ -23,6 +20,9 @@ import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.Scroller; +import java.util.HashMap; +import java.util.LinkedList; + public class HorizontalListView extends AdapterView { public boolean mAlwaysOverrideTouch = true; @@ -126,7 +126,7 @@ public class HorizontalListView extends AdapterView { private void addAndMeasureChild(final View child, int viewPos) { LayoutParams params = child.getLayoutParams(); if (params == null) { - params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); + params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT); } addViewInLayout(child, viewPos, params, true); child.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LayoutListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LayoutListView.java deleted file mode 100644 index 1ed6f83b..00000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LayoutListView.java +++ /dev/null @@ -1,90 +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.Components; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.widget.ListView; - -public class LayoutListView extends ListView { - - public interface OnInterceptTouchEventListener { - boolean onInterceptTouchEvent(MotionEvent event); - } - - private OnInterceptTouchEventListener onInterceptTouchEventListener; - private int height = -1; - private int forceTop = Integer.MIN_VALUE; - - public LayoutListView(Context context) { - super(context); - } - - public LayoutListView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LayoutListView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setOnInterceptTouchEventListener(OnInterceptTouchEventListener listener) { - onInterceptTouchEventListener = listener; - } - - public void setForceTop(int value) { - forceTop = value; - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - if (onInterceptTouchEventListener != null) { - return onInterceptTouchEventListener.onInterceptTouchEvent(ev) || super.onInterceptTouchEvent(ev); - } - return super.onInterceptTouchEvent(ev); - } - - @SuppressLint("DrawAllocation") - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - View v = getChildAt(getChildCount() - 1); - int scrollTo = getLastVisiblePosition(); - if (v != null && height > 0 && changed && ((bottom - top) < height)) { - int lastTop = forceTop == Integer.MIN_VALUE ? (bottom - top) - (height - v.getTop()) - getPaddingTop() : forceTop; - forceTop = Integer.MIN_VALUE; - setSelectionFromTop(scrollTo, lastTop); - super.onLayout(changed, left, top, right, bottom); - -// post(new Runnable() { -// @Override -// public void run() { -// try { -// setSelectionFromTop(scrollTo, lastTop); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } -// }); - } else { - if (forceTop != Integer.MIN_VALUE) { - setSelectionFromTop(scrollTo, forceTop); - forceTop = Integer.MIN_VALUE; - } - try { - super.onLayout(changed, left, top, right, bottom); - } catch (Exception e) { - e.printStackTrace(); - } - } - height = (bottom - top); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java index 33b34963..a4e1c804 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java @@ -8,31 +8,26 @@ package org.telegram.ui.Components; -import java.util.Locale; - -import android.annotation.SuppressLint; import android.content.Context; +import android.content.SharedPreferences; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; -import android.graphics.Typeface; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.os.Build; -import android.os.Parcel; -import android.os.Parcelable; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; -import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.Gravity; import android.view.View; import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.widget.FrameLayout; import android.widget.HorizontalScrollView; -import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.TextView; +import org.telegram.android.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.R; public class PagerSlidingTabStrip extends HorizontalScrollView { @@ -60,73 +55,41 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { private int underlineColor = 0x1A000000; private boolean shouldExpand = false; - private boolean textAllCaps = true; - private int scrollOffset = 52; - private int indicatorHeight = 8; - private int underlineHeight = 2; - private int dividerPadding = 12; - private int tabPadding = 24; - - private int tabTextSize = 12; - private int tabTextColor = 0xFF666666; - private Typeface tabTypeface = null; - private int tabTypefaceStyle = Typeface.BOLD; + private int scrollOffset = AndroidUtilities.dp(52); + private int indicatorHeight = AndroidUtilities.dp(8); + private int underlineHeight = AndroidUtilities.dp(2); + private int dividerPadding = AndroidUtilities.dp(12); + private int tabPadding = AndroidUtilities.dp(24); private int lastScrollX = 0; - private int tabBackgroundResId = R.drawable.background_tab; - - private Locale locale; - public PagerSlidingTabStrip(Context context) { - this(context, null); - } - - public PagerSlidingTabStrip(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); + super(context); setFillViewport(true); setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); - tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); + tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); - scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); - indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); - underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); - dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); - tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); - tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); - rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); - defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); - - if (locale == null) { - locale = getResources().getConfiguration().locale; - } + defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutHelper.MATCH_PARENT); } public void setViewPager(ViewPager pager) { this.pager = pager; - if (pager.getAdapter() == null) { throw new IllegalStateException("ViewPager does not have adapter instance."); } - pager.setOnPageChangeListener(pageListener); - notifyDataSetChanged(); } @@ -135,128 +98,80 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { } public void notifyDataSetChanged() { - tabsContainer.removeAllViews(); - tabCount = pager.getAdapter().getCount(); - for (int i = 0; i < tabCount; i++) { - if (pager.getAdapter() instanceof IconTabProvider) { addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i)); - } else { - addTextTab(i, pager.getAdapter().getPageTitle(i).toString()); } - } - updateTabStyles(); - getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { - - @SuppressWarnings("deprecation") - @SuppressLint("NewApi") @Override public void onGlobalLayout() { - if (Build.VERSION.SDK_INT < 16) { getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { getViewTreeObserver().removeOnGlobalLayoutListener(this); } - currentPosition = pager.getCurrentItem(); scrollToChild(currentPosition, 0); } }); - - updateExpanded(); - - } - - private void addTextTab(final int position, String title) { - - TextView tab = new TextView(getContext()); - tab.setText(title); - tab.setFocusable(true); - tab.setGravity(Gravity.CENTER); - tab.setSingleLine(); - - tab.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - pager.setCurrentItem(position); - } - }); - - tabsContainer.addView(tab); - } private void addIconTab(final int position, int resId) { - - ImageButton tab = new ImageButton(getContext()); + ImageView tab = new ImageView(getContext()); tab.setFocusable(true); - tab.setImageResource(resId); - + paintTabIcons(position); + //tab.setImageResource(resId); + tab.setImageDrawable(getResources().getDrawable(resId));//Plus + tab.setScaleType(ImageView.ScaleType.CENTER); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); - tabsContainer.addView(tab); tab.setSelected(position == currentPosition); } + //Plus + private int[] icons = { + R.drawable.ic_smiles_recent_active, + R.drawable.ic_smiles_smile_active, + R.drawable.ic_smiles_flower_active, + R.drawable.ic_smiles_bell_active, + R.drawable.ic_smiles_car_active, + R.drawable.ic_smiles_grid_active, + R.drawable.ic_smiles_sticker_active}; - private void updateExpanded() { - - } + private void paintTabIcons(int position){ + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int tabColor = themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x15)); + Drawable icon = getResources().getDrawable(icons[position]); + icon.setColorFilter(tabColor, PorterDuff.Mode.SRC_IN); + }// private void updateTabStyles() { - for (int i = 0; i < tabCount; i++) { - View v = tabsContainer.getChildAt(i); - v.setLayoutParams(defaultTabLayoutParams); - v.setBackgroundResource(tabBackgroundResId); if (shouldExpand) { v.setPadding(0, 0, 0, 0); v.setLayoutParams(new LinearLayout.LayoutParams(-1, -1, 1.0F)); } else { v.setPadding(tabPadding, 0, tabPadding, 0); } - - if (v instanceof TextView) { - - TextView tab = (TextView) v; - tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); - tab.setTypeface(tabTypeface, tabTypefaceStyle); - tab.setTextColor(tabTextColor); - - // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a - // pre-ICS-build - if (textAllCaps) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - tab.setAllCaps(true); - } else { - tab.setText(tab.getText().toString().toUpperCase(locale)); - } - } - } } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - if (!shouldExpand || MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED) { return; } - int myWidth = getMeasuredWidth(); tabsContainer.measure(MeasureSpec.EXACTLY | myWidth, heightMeasureSpec); } @@ -265,13 +180,10 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { if (tabCount == 0) { return; } - int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset; - if (position > 0 || offset > 0) { newScrollX -= scrollOffset; } - if (newScrollX != lastScrollX) { lastScrollX = newScrollX; scrollTo(newScrollX, 0); @@ -288,9 +200,9 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { final int height = getHeight(); - // draw indicator line - - rectPaint.setColor(indicatorColor); + // draw underline + rectPaint.setColor(underlineColor); + canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); @@ -308,26 +220,19 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } + // draw indicator line + rectPaint.setColor(indicatorColor); canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); - - // draw underline - - rectPaint.setColor(underlineColor); - canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); } private class PageListener implements OnPageChangeListener { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - currentPosition = position; currentPositionOffset = positionOffset; - scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth())); - invalidate(); - if (delegatePageListener != null) { delegatePageListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } @@ -338,7 +243,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { if (state == ViewPager.SCROLL_STATE_IDLE) { scrollToChild(pager.getCurrentItem(), 0); } - if (delegatePageListener != null) { delegatePageListener.onPageScrollStateChanged(state); } @@ -353,7 +257,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { tabsContainer.getChildAt(a).setSelected(a == position); } } - } public void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4) { @@ -440,7 +343,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { public boolean getShouldExpand() { return shouldExpand; } - +/* public boolean isTextAllCaps() { return textAllCaps; } @@ -485,7 +388,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { public int getTabBackground() { return tabBackgroundResId; } - +*/ public void setTabPaddingLeftRight(int paddingPx) { this.tabPadding = paddingPx; updateTabStyles(); @@ -494,51 +397,4 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { public int getTabPaddingLeftRight() { return tabPadding; } - - @Override - public void onRestoreInstanceState(Parcelable state) { - SavedState savedState = (SavedState) state; - super.onRestoreInstanceState(savedState.getSuperState()); - currentPosition = savedState.currentPosition; - requestLayout(); - } - - @Override - public Parcelable onSaveInstanceState() { - Parcelable superState = super.onSaveInstanceState(); - SavedState savedState = new SavedState(superState); - savedState.currentPosition = currentPosition; - return savedState; - } - - static class SavedState extends BaseSavedState { - int currentPosition; - - public SavedState(Parcelable superState) { - super(superState); - } - - private SavedState(Parcel in) { - super(in); - currentPosition = in.readInt(); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeInt(currentPosition); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public SavedState createFromParcel(Parcel in) { - return new SavedState(in); - } - - @Override - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java index 3a027d93..26939afd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java @@ -38,10 +38,13 @@ import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.LocaleController; import org.telegram.android.NotificationCenter; import org.telegram.messenger.ApplicationLoader; @@ -49,10 +52,6 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; import java.util.ArrayList; import java.util.Locale; @@ -424,15 +423,15 @@ public class PasscodeView extends FrameLayout { backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); @@ -458,8 +457,8 @@ public class PasscodeView extends FrameLayout { passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); @@ -467,8 +466,8 @@ public class PasscodeView extends FrameLayout { passwordEditText2 = new AnimatingTextView(context); passwordFrameLayout.addView(passwordEditText2); layoutParams = (FrameLayout.LayoutParams) passwordEditText2.getLayoutParams(); - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); @@ -488,8 +487,8 @@ public class PasscodeView extends FrameLayout { AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); @@ -571,7 +570,7 @@ public class PasscodeView extends FrameLayout { lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); @@ -581,8 +580,8 @@ public class PasscodeView extends FrameLayout { numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java index da9ac066..94d94025 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java @@ -18,8 +18,6 @@ import android.opengl.GLES20; import android.opengl.GLUtils; import android.os.Build; import android.os.Looper; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; import android.util.TypedValue; import android.view.Gravity; import android.view.MotionEvent; @@ -31,15 +29,17 @@ import android.widget.ImageView; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.LocaleController; +import org.telegram.android.support.widget.LinearLayoutManager; +import org.telegram.android.support.widget.RecyclerView; import org.telegram.messenger.DispatchQueue; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.Utilities; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Cells.PhotoEditToolCell; import java.nio.ByteBuffer; @@ -1333,8 +1333,8 @@ public class PhotoFilterView extends FrameLayout { addView(textureView); textureView.setVisibility(INVISIBLE); LayoutParams layoutParams = (LayoutParams) textureView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textureView.setLayoutParams(layoutParams); textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() { @@ -1380,8 +1380,8 @@ public class PhotoFilterView extends FrameLayout { blurControl.setVisibility(INVISIBLE); addView(blurControl); layoutParams = (LayoutParams) blurControl.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.LEFT | Gravity.TOP; blurControl.setLayoutParams(layoutParams); blurControl.setDelegate(new PhotoFilterBlurControl.PhotoFilterLinearBlurControlDelegate() { @@ -1400,7 +1400,7 @@ public class PhotoFilterView extends FrameLayout { toolsView = new FrameLayout(context); addView(toolsView); layoutParams = (LayoutParams) toolsView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(126); layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM; toolsView.setLayoutParams(layoutParams); @@ -1409,7 +1409,7 @@ public class PhotoFilterView extends FrameLayout { frameLayout.setBackgroundColor(0xff1a1a1a); toolsView.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(48); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); @@ -1424,8 +1424,8 @@ public class PhotoFilterView extends FrameLayout { cancelTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); frameLayout.addView(cancelTextView); layoutParams = (LayoutParams) cancelTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; cancelTextView.setLayoutParams(layoutParams); @@ -1439,8 +1439,8 @@ public class PhotoFilterView extends FrameLayout { doneTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); frameLayout.addView(doneTextView); layoutParams = (LayoutParams) doneTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.RIGHT; doneTextView.setLayoutParams(layoutParams); @@ -1455,7 +1455,7 @@ public class PhotoFilterView extends FrameLayout { recyclerListView.setAdapter(toolsAdapter = new ToolsAdapter(context)); toolsView.addView(recyclerListView); layoutParams = (FrameLayout.LayoutParams) recyclerListView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(60); layoutParams.gravity = Gravity.LEFT | Gravity.TOP; recyclerListView.setLayoutParams(layoutParams); @@ -1516,7 +1516,7 @@ public class PhotoFilterView extends FrameLayout { editView.setVisibility(GONE); addView(editView); layoutParams = (LayoutParams) editView.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(126); layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM; editView.setLayoutParams(layoutParams); @@ -1525,7 +1525,7 @@ public class PhotoFilterView extends FrameLayout { frameLayout.setBackgroundColor(0xff1a1a1a); editView.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); - layoutParams.width = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(48); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); @@ -1536,8 +1536,8 @@ public class PhotoFilterView extends FrameLayout { imageView.setPadding(AndroidUtilities.dp(22), 0, AndroidUtilities.dp(22), 0); frameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; imageView.setLayoutParams(layoutParams); imageView.setOnClickListener(new OnClickListener() { @@ -1579,8 +1579,8 @@ public class PhotoFilterView extends FrameLayout { imageView.setPadding(AndroidUtilities.dp(22), AndroidUtilities.dp(1), AndroidUtilities.dp(22), 0); frameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.RIGHT; imageView.setLayoutParams(layoutParams); imageView.setOnClickListener(new OnClickListener() { @@ -1597,8 +1597,8 @@ public class PhotoFilterView extends FrameLayout { blurTextView.setText(LocaleController.getString("Blur", R.string.Blur)); frameLayout.addView(blurTextView); layoutParams = (LayoutParams) blurTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(9); blurTextView.setLayoutParams(layoutParams); @@ -1608,8 +1608,8 @@ public class PhotoFilterView extends FrameLayout { paramTextView.setTextColor(0xff808080); frameLayout.addView(paramTextView); layoutParams = (LayoutParams) paramTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(26); paramTextView.setLayoutParams(layoutParams); @@ -1619,8 +1619,8 @@ public class PhotoFilterView extends FrameLayout { valueTextView.setTextColor(0xffffffff); frameLayout.addView(valueTextView); layoutParams = (LayoutParams) valueTextView.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(3); valueTextView.setLayoutParams(layoutParams); @@ -1667,7 +1667,7 @@ public class PhotoFilterView extends FrameLayout { layoutParams.width = AndroidUtilities.dp(498); layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; } else { - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.LEFT | Gravity.TOP; } valueSeekBar.setLayoutParams(layoutParams); @@ -1966,7 +1966,7 @@ public class PhotoFilterView extends FrameLayout { layoutParams.width = total; layoutParams.leftMargin = (viewWidth - total) / 2; } else { - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = 0; } recyclerListView.setLayoutParams(layoutParams); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPickerBottomLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPickerBottomLayout.java index fb6db0a0..67c72c12 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPickerBottomLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPickerBottomLayout.java @@ -41,8 +41,8 @@ public class PhotoPickerBottomLayout extends FrameLayout { cancelButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); addView(cancelButton); LayoutParams layoutParams = (LayoutParams) cancelButton.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; cancelButton.setLayoutParams(layoutParams); @@ -52,8 +52,8 @@ public class PhotoPickerBottomLayout extends FrameLayout { doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0); addView(doneButton); layoutParams = (LayoutParams) doneButton.getLayoutParams(); - layoutParams.width = LayoutParams.WRAP_CONTENT; - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.RIGHT; doneButton.setLayoutParams(layoutParams); @@ -67,7 +67,7 @@ public class PhotoPickerBottomLayout extends FrameLayout { doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), AndroidUtilities.dp(1)); doneButton.addView(doneButtonBadgeTextView); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) doneButtonBadgeTextView.getLayoutParams(); - layoutParams1.width = LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; layoutParams1.height = AndroidUtilities.dp(23); layoutParams1.rightMargin = AndroidUtilities.dp(10); layoutParams1.gravity = Gravity.CENTER_VERTICAL; @@ -82,9 +82,9 @@ public class PhotoPickerBottomLayout extends FrameLayout { doneButtonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); doneButton.addView(doneButtonTextView); layoutParams1 = (LinearLayout.LayoutParams) doneButtonTextView.getLayoutParams(); - layoutParams1.width = LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; layoutParams1.gravity = Gravity.CENTER_VERTICAL; - layoutParams1.height = LayoutParams.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; doneButtonTextView.setLayoutParams(layoutParams1); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java index 3d32ec5e..86f9036f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java @@ -20,9 +20,10 @@ import android.view.SoundEffectConstants; import org.telegram.android.AndroidUtilities; import org.telegram.android.ImageLoader; import org.telegram.android.MediaController; +import org.telegram.android.MessageObject; +import org.telegram.android.MessagesController; import org.telegram.messenger.FileLoader; import org.telegram.messenger.R; -import org.telegram.android.MessageObject; import org.telegram.ui.Cells.BaseCell; import java.io.File; @@ -58,23 +59,23 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, super(context); if (backgroundMediaDrawableIn == null) { backgroundMediaDrawableIn = getResources().getDrawable(R.drawable.msg_in_photo); - statesDrawable[0][0] = getResources().getDrawable(R.drawable.play1); - statesDrawable[0][1] = getResources().getDrawable(R.drawable.play1_pressed); - statesDrawable[1][0] = getResources().getDrawable(R.drawable.pause1); - statesDrawable[1][1] = getResources().getDrawable(R.drawable.pause1_pressed); - statesDrawable[2][0] = getResources().getDrawable(R.drawable.audioload1); - statesDrawable[2][1] = getResources().getDrawable(R.drawable.audioload1_pressed); - statesDrawable[3][0] = getResources().getDrawable(R.drawable.audiocancel1); - statesDrawable[3][1] = getResources().getDrawable(R.drawable.audiocancel1_pressed); + statesDrawable[0][0] = getResources().getDrawable(R.drawable.play_w2); + statesDrawable[0][1] = getResources().getDrawable(R.drawable.play_w2_pressed); + statesDrawable[1][0] = getResources().getDrawable(R.drawable.pause_w2); + statesDrawable[1][1] = getResources().getDrawable(R.drawable.pause_w2_pressed); + statesDrawable[2][0] = getResources().getDrawable(R.drawable.download_g); + statesDrawable[2][1] = getResources().getDrawable(R.drawable.download_g_pressed); + statesDrawable[3][0] = getResources().getDrawable(R.drawable.pause_g); + statesDrawable[3][1] = getResources().getDrawable(R.drawable.pause_g_pressed); - statesDrawable[4][0] = getResources().getDrawable(R.drawable.play2); - statesDrawable[4][1] = getResources().getDrawable(R.drawable.play2_pressed); - statesDrawable[5][0] = getResources().getDrawable(R.drawable.pause2); - statesDrawable[5][1] = getResources().getDrawable(R.drawable.pause2_pressed); - statesDrawable[6][0] = getResources().getDrawable(R.drawable.audioload2); - statesDrawable[6][1] = getResources().getDrawable(R.drawable.audioload2_pressed); - statesDrawable[7][0] = getResources().getDrawable(R.drawable.audiocancel2); - statesDrawable[7][1] = getResources().getDrawable(R.drawable.audiocancel2_pressed); + statesDrawable[4][0] = getResources().getDrawable(R.drawable.play_w); + statesDrawable[4][1] = getResources().getDrawable(R.drawable.play_w_pressed); + statesDrawable[5][0] = getResources().getDrawable(R.drawable.pause_w); + statesDrawable[5][1] = getResources().getDrawable(R.drawable.pause_w_pressed); + statesDrawable[6][0] = getResources().getDrawable(R.drawable.download_b); + statesDrawable[6][1] = getResources().getDrawable(R.drawable.download_b_pressed); + statesDrawable[7][0] = getResources().getDrawable(R.drawable.pause_b); + statesDrawable[7][1] = getResources().getDrawable(R.drawable.pause_b_pressed); timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); timePaint.setTextSize(AndroidUtilities.dp(16)); @@ -122,13 +123,13 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, return; } - seekBarX = AndroidUtilities.dp(40); + seekBarX = AndroidUtilities.dp(54); buttonX = AndroidUtilities.dp(10); timeX = getMeasuredWidth() - timeWidth - AndroidUtilities.dp(16); - seekBar.width = getMeasuredWidth() - AndroidUtilities.dp(56) - timeWidth; + seekBar.width = getMeasuredWidth() - AndroidUtilities.dp(70) - timeWidth; seekBar.height = AndroidUtilities.dp(30); - progressView.width = getMeasuredWidth() - AndroidUtilities.dp(80) - timeWidth; + progressView.width = getMeasuredWidth() - AndroidUtilities.dp(94) - timeWidth; progressView.height = AndroidUtilities.dp(30); seekBarY = AndroidUtilities.dp(13); buttonY = AndroidUtilities.dp(10); @@ -234,6 +235,10 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, private void didPressedButton() { if (buttonState == 0) { boolean result = MediaController.getInstance().playAudio(currentMessageObject); + if (!currentMessageObject.isOut() && currentMessageObject.isContentUnread()) { + MessagesController.getInstance().markMessageContentAsRead(currentMessageObject.getId()); + currentMessageObject.setContentIsRead(); + } if (result) { buttonState = 1; invalidate(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java index 08eea19d..95c0345f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java @@ -9,12 +9,14 @@ package org.telegram.ui.Components; import android.content.Context; -import android.support.v7.widget.RecyclerView; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; +import org.telegram.android.support.widget.RecyclerView; +import org.telegram.messenger.FileLog; + public class RecyclerListView extends RecyclerView { public interface OnItemClickListener { @@ -82,6 +84,15 @@ public class RecyclerListView extends RecyclerView { return super.onInterceptTouchEvent(e); } + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + try { + super.onLayout(changed, l, t, r, b); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + @Override public void stopScroll() { try { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java index 54ec83b9..8802e850 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java @@ -77,7 +77,6 @@ public class SizeNotifierRelativeLayout extends RelativeLayout { this.getWindowVisibleDisplayFrame(rect); keyboardHeight = usableViewHeight - (rect.bottom - rect.top); final boolean isWidthGreater = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y; - FileLog.e("tmessages", "isWidthGreater = " + isWidthGreater + " height = " + keyboardHeight); post(new Runnable() { @Override public void run() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java index 4c01ff27..1ba3e974 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java @@ -12,7 +12,6 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Typeface; -import android.util.AttributeSet; import android.util.TypedValue; import android.view.Gravity; import android.view.View; @@ -41,33 +40,15 @@ public class SlidingTabView extends LinearLayout { private float startAnimationX = 0; private DecelerateInterpolator interpolator; - private void init() { + public SlidingTabView(Context context) { + super(context); setOrientation(HORIZONTAL); setWeightSum(100); paint.setColor(0xffffffff); + setWillNotDraw(false); interpolator = new DecelerateInterpolator(); } - public SlidingTabView(Context context) { - super(context); - init(); - } - - public SlidingTabView(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - public SlidingTabView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(); - } - - public SlidingTabView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - init(); - } - public void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title); @@ -87,7 +68,7 @@ public class SlidingTabView extends LinearLayout { }); addView(tab); LayoutParams layoutParams = (LayoutParams)tab.getLayoutParams(); - layoutParams.height = LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = 0; layoutParams.weight = 50; tab.setLayoutParams(layoutParams); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java index 4dbbdab2..756aa9c2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java @@ -31,9 +31,9 @@ import android.view.ViewConfiguration; import android.widget.CompoundButton; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; import org.telegram.android.LocaleController; import org.telegram.messenger.R; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; public class Switch extends CompoundButton { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java index 393482f8..d644d7d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java @@ -17,6 +17,7 @@ import android.view.animation.DecelerateInterpolator; import org.telegram.android.AndroidUtilities; public class TypingDotsDrawable extends Drawable { + private boolean isChat = false; private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); private float[] scales = new float[3]; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java index e2db7ba6..a4122ab8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java @@ -41,6 +41,7 @@ import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; +import org.telegram.ui.Components.LayoutHelper; public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { @@ -129,8 +130,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent layoutParams.topMargin = AndroidUtilities.dp(24); layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; frameLayout.setLayoutParams(layoutParams); avatarImage = new BackupImageView(context); @@ -153,8 +154,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); frameLayout.addView(nameTextView); layoutParams3 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams3.width = LayoutHelper.WRAP_CONTENT; + layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80); layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0); layoutParams3.topMargin = AndroidUtilities.dp(3); @@ -171,8 +172,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); frameLayout.addView(onlineTextView); layoutParams3 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams3.width = LayoutHelper.WRAP_CONTENT; + layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80); layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0); layoutParams3.topMargin = AndroidUtilities.dp(32); @@ -197,7 +198,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; firstNameField.setLayoutParams(layoutParams); firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override @@ -229,7 +230,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; lastNameField.setLayoutParams(layoutParams); lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index 6626b192..1af9ee85 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -12,6 +12,9 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -38,6 +41,7 @@ import org.telegram.android.MessagesController; import org.telegram.android.MessagesStorage; import org.telegram.android.NotificationCenter; import org.telegram.android.SecretChatHelper; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; @@ -49,6 +53,7 @@ import org.telegram.ui.Adapters.BaseSectionsAdapter; import org.telegram.ui.Adapters.ContactsAdapter; import org.telegram.ui.Adapters.SearchAdapter; import org.telegram.ui.Cells.UserCell; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LetterSectionsListView; import java.util.ArrayList; @@ -69,6 +74,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter private boolean returnAsResult; private boolean createSecretChat; private boolean creatingChat = false; + private int chat_id; private String selectAlertString = null; private HashMap ignoreUsers; private boolean allowUsernameSearch = true; @@ -97,6 +103,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter createSecretChat = arguments.getBoolean("createSecretChat", false); selectAlertString = arguments.getString("selectAlertString"); allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true); + chat_id = arguments.getInt("chat_id", 0); } else { needPhonebook = true; } @@ -121,8 +128,11 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter searching = false; searchWas = false; - - actionBar.setBackButtonImage(R.drawable.ic_ab_back); + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + //actionBar.setBackButtonImage(R.drawable.ic_ab_back); + Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back); + back.setColorFilter(themePrefs.getInt("contactsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + actionBar.setBackButtonDrawable(back); actionBar.setAllowOverlayTitle(true); if (destroyAfterSelect) { if (returnAsResult) { @@ -148,7 +158,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter }); ActionBarMenu menu = actionBar.createMenu(); - ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { + //ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { + Drawable search = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_search); + ActionBarMenuItem item = menu.addItem(0, search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { searching = true; @@ -195,9 +207,13 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter } }); item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); + item.getSearchField().setTextColor(themePrefs.getInt("contactsHeaderTitleColor", 0xffffffff)); + Drawable clear = getParentActivity().getResources().getDrawable(R.drawable.ic_close_white); + clear.setColorFilter(AndroidUtilities.getIntDef("contactsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + item.getClearButton().setImageDrawable(clear); searchListViewAdapter = new SearchAdapter(context, ignoreUsers, allowUsernameSearch); - listViewAdapter = new ContactsAdapter(context, onlyUsers, needPhonebook, ignoreUsers); + listViewAdapter = new ContactsAdapter(context, onlyUsers, needPhonebook, ignoreUsers, chat_id != 0); fragmentView = new FrameLayout(context); @@ -206,8 +222,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter emptyTextLayout.setOrientation(LinearLayout.VERTICAL); ((FrameLayout) fragmentView).addView(emptyTextLayout); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; emptyTextLayout.setLayoutParams(layoutParams); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @@ -224,16 +240,16 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); emptyTextLayout.addView(emptyTextView); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; emptyTextView.setLayoutParams(layoutParams1); FrameLayout frameLayout = new FrameLayout(context); emptyTextLayout.addView(frameLayout); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; frameLayout.setLayoutParams(layoutParams1); @@ -251,8 +267,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter } ((FrameLayout) fragmentView).addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -290,7 +306,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter if (row < 0 || section < 0) { return; } - if (!onlyUsers && section == 0) { + if ((!onlyUsers || chat_id != 0) && section == 0) { if (needPhonebook) { if (row == 0) { try { @@ -302,6 +318,10 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter FileLog.e("tmessages", e); } } + } else if (chat_id != 0) { + if (row == 0) { + presentFragment(new GroupInviteActivity(chat_id)); + } } else { if (row == 0) { if (!MessagesController.isFeatureEnabled("chat_create", ContactsActivity.this)) { @@ -446,13 +466,26 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter listViewAdapter.notifyDataSetChanged(); } updateTheme(); + + } private void updateTheme(){ - actionBar.setBackgroundColor(AndroidUtilities.getIntDef("contactsHeaderColor", AndroidUtilities.getIntColor("themeColor"))); + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor); + actionBar.setBackgroundColor(themePrefs.getInt("contactsHeaderColor", def)); + actionBar.setTitleColor(themePrefs.getInt("contactsHeaderTitleColor", 0xffffffff)); + Drawable search = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_search); + search.setColorFilter(themePrefs.getInt("contactsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + + //Drawable clear = getParentActivity().getResources().getDrawable(R.drawable.ic_close_white); + //clear.setColorFilter(AndroidUtilities.getIntDef("contactsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + //Drawable lock = getParentActivity().getResources().getDrawable(R.drawable.lock_close); + //lock.setColorFilter(themePrefs.getInt("contactsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + //lock = getParentActivity().getResources().getDrawable(R.drawable.lock_open); + //lock.setColorFilter(themePrefs.getInt("contactsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); } - @Override public void onPause() { super.onPause(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java index aa838efd..bb419af7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java @@ -32,6 +32,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.CountryAdapter; import org.telegram.ui.Adapters.CountryAdapter.Country; import org.telegram.ui.Adapters.CountrySearchAdapter; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LetterSectionsListView; public class CountrySelectActivity extends BaseFragment { @@ -134,8 +135,8 @@ public class CountrySelectActivity extends BaseFragment { emptyTextLayout.setOrientation(LinearLayout.VERTICAL); ((FrameLayout) fragmentView).addView(emptyTextLayout); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; emptyTextLayout.setLayoutParams(layoutParams); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @@ -152,16 +153,16 @@ public class CountrySelectActivity extends BaseFragment { emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult)); emptyTextLayout.addView(emptyTextView); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; emptyTextView.setLayoutParams(layoutParams1); FrameLayout frameLayout = new FrameLayout(context); emptyTextLayout.addView(frameLayout); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; frameLayout.setLayoutParams(layoutParams1); @@ -179,8 +180,8 @@ public class CountrySelectActivity extends BaseFragment { } ((FrameLayout) fragmentView).addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index 839b5d3b..a56fef8d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -29,6 +29,8 @@ import android.widget.ListView; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; import org.telegram.android.LocaleController; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; @@ -37,9 +39,8 @@ import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; import org.telegram.ui.Cells.SharedDocumentCell; +import org.telegram.ui.Components.LayoutHelper; import java.io.BufferedReader; import java.io.File; @@ -123,8 +124,8 @@ public class DocumentSelectActivity extends BaseFragment { } catch (Exception e) { FileLog.e("tmessages", e); } - super.onFragmentDestroy(); fileFilter = "*"; + super.onFragmentDestroy(); } @Override @@ -191,7 +192,7 @@ public class DocumentSelectActivity extends BaseFragment { LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams(); layoutParams.weight = 1; layoutParams.width = 0; - layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; selectedMessagesCountTextView.setLayoutParams(layoutParams); actionModeViews.add(actionMode.addItem(done, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index e6043110..e4be3c0b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -55,6 +55,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.ContactsAdapter; import org.telegram.ui.Adapters.SearchAdapter; import org.telegram.ui.Cells.UserCell; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LetterSectionsListView; import java.util.ArrayList; @@ -188,7 +189,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen searchListViewAdapter = new SearchAdapter(context, null, false); searchListViewAdapter.setCheckedMap(selectedContacts); searchListViewAdapter.setUseUserCell(true); - listViewAdapter = new ContactsAdapter(context, true, false, null); + listViewAdapter = new ContactsAdapter(context, true, false, null, false); listViewAdapter.setCheckedMap(selectedContacts); fragmentView = new LinearLayout(context); @@ -198,8 +199,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen FrameLayout frameLayout = new FrameLayout(context); linearLayout.addView(frameLayout); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.TOP; frameLayout.setLayoutParams(layoutParams); @@ -221,8 +222,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen AndroidUtilities.clearCursorDrawable(userSelectEditText); frameLayout.addView(userSelectEditText); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) userSelectEditText.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.leftMargin = AndroidUtilities.dp(10); layoutParams1.rightMargin = AndroidUtilities.dp(10); layoutParams1.gravity = Gravity.TOP; @@ -327,8 +328,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen emptyTextLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(emptyTextLayout); layoutParams = (LinearLayout.LayoutParams) emptyTextLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; emptyTextLayout.setLayoutParams(layoutParams); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @Override @@ -344,16 +345,16 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); emptyTextLayout.addView(emptyTextView); layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.weight = 0.5f; emptyTextView.setLayoutParams(layoutParams); FrameLayout frameLayout2 = new FrameLayout(context); emptyTextLayout.addView(frameLayout2); layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.weight = 0.5f; frameLayout2.setLayoutParams(layoutParams); @@ -371,8 +372,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen } linearLayout.addView(listView); layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java index 9499d8a2..ad9f24cf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java @@ -47,6 +47,7 @@ import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarUpdater; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; import java.util.concurrent.Semaphore; @@ -203,8 +204,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati FrameLayout frameLayout = new FrameLayoutFixed(context); linearLayout.addView(frameLayout); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); @@ -276,8 +277,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati nameTextView.setTextColor(0xff212121); frameLayout.addView(nameTextView); layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(96); layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(96) : AndroidUtilities.dp(16); layoutParams1.gravity = Gravity.CENTER_VERTICAL; @@ -313,8 +314,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati listView.setAdapter(listAdapter = new ListAdapter(context)); linearLayout.addView(listView); layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); return fragmentView; @@ -369,6 +370,12 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati } } + @Override + public void onOpenAnimationEnd() { + nameTextView.requestFocus(); + AndroidUtilities.showKeyboard(nameTextView); + } + @Override public void didReceivedNotification(int id, final Object... args) { if (id == NotificationCenter.updateInterfaces) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java index 494c4128..9e0eadfc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -35,6 +35,7 @@ import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.TextSettingsCell; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; import java.util.Timer; @@ -113,8 +114,8 @@ public class LanguageSelectActivity extends BaseFragment { emptyTextLayout.setOrientation(LinearLayout.VERTICAL); ((FrameLayout) fragmentView).addView(emptyTextLayout); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; emptyTextLayout.setLayoutParams(layoutParams); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @@ -131,16 +132,16 @@ public class LanguageSelectActivity extends BaseFragment { emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult)); emptyTextLayout.addView(emptyTextView); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; emptyTextView.setLayoutParams(layoutParams1); FrameLayout frameLayout = new FrameLayout(context); emptyTextLayout.addView(frameLayout); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; frameLayout.setLayoutParams(layoutParams1); @@ -152,8 +153,8 @@ public class LanguageSelectActivity extends BaseFragment { listView.setAdapter(listAdapter); ((FrameLayout) fragmentView).addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java index b2c6096b..fcc8ace2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java @@ -46,6 +46,7 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.HeaderCell; import org.telegram.ui.Cells.TextInfoPrivacyCell; import org.telegram.ui.Cells.TextSettingsCell; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; @@ -154,8 +155,8 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java index a0ce4a77..b4d4c93d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java @@ -35,6 +35,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.TextInfoCell; import org.telegram.ui.Cells.UserCell; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; @@ -126,8 +127,8 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); frameLayout.addView(emptyTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; emptyTextView.setLayoutParams(layoutParams); emptyTextView.setOnTouchListener(new View.OnTouchListener() { @@ -148,8 +149,8 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC } frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 4dfecf4a..97233003 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -9,6 +9,7 @@ package org.telegram.ui; import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.ContentResolver; import android.content.DialogInterface; @@ -58,6 +59,7 @@ import org.telegram.ui.ActionBar.ActionBarLayout; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.DrawerLayoutContainer; import org.telegram.ui.Adapters.DrawerLayoutAdapter; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PasscodeView; import java.io.BufferedReader; @@ -88,9 +90,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa private FrameLayout shadowTablet; private FrameLayout shadowTabletSide; private ImageView backgroundTablet; - private DrawerLayoutContainer drawerLayoutContainer; + protected DrawerLayoutContainer drawerLayoutContainer; private DrawerLayoutAdapter drawerLayoutAdapter; private PasscodeView passcodeView; + private AlertDialog visibleDialog; private Intent passcodeSaveIntent; private boolean passcodeSaveIntentIsNew; @@ -154,8 +157,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa RelativeLayout launchLayout = new RelativeLayout(this); drawerLayoutContainer.addView(launchLayout); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; launchLayout.setLayoutParams(layoutParams1); backgroundTablet = new ImageView(this); @@ -163,21 +166,21 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa backgroundTablet.setImageResource(R.drawable.cats); launchLayout.addView(backgroundTablet); RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet.getLayoutParams(); - relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; backgroundTablet.setLayoutParams(relativeLayoutParams); launchLayout.addView(actionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); - relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; actionBarLayout.setLayoutParams(relativeLayoutParams); rightActionBarLayout = new ActionBarLayout(this); launchLayout.addView(rightActionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams)rightActionBarLayout.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(320); - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; rightActionBarLayout.setLayoutParams(relativeLayoutParams); rightActionBarLayout.init(rightFragmentsStack); rightActionBarLayout.setDelegate(this); @@ -187,7 +190,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa launchLayout.addView(shadowTabletSide); relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(1); - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; shadowTabletSide.setLayoutParams(relativeLayoutParams); shadowTablet = new FrameLayout(this); @@ -195,8 +198,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa shadowTablet.setBackgroundColor(0x7F000000); launchLayout.addView(shadowTablet); relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams(); - relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; shadowTablet.setLayoutParams(relativeLayoutParams); shadowTablet.setOnTouchListener(new View.OnTouchListener() { @Override @@ -258,7 +261,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)listView.getLayoutParams(); Point screenSize = AndroidUtilities.getRealScreenSize(); layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56); - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setPadding(0, 0, 0, 0); listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); listView.setDivider(null); @@ -349,8 +352,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa passcodeView = new PasscodeView(this); drawerLayoutContainer.addView(passcodeView); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) passcodeView.getLayoutParams(); - layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams1.width = LayoutHelper.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; passcodeView.setLayoutParams(layoutParams1); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this); @@ -694,6 +697,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa Uri data = intent.getData(); if (data != null) { String username = null; + String group = null; String scheme = data.getScheme(); if (scheme != null) { if ((scheme.equals("http") || scheme.equals("https"))) { @@ -701,68 +705,29 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa if (host.equals("telegram.me")) { String path = data.getPath(); if (path != null && path.length() >= 6) { - username = path.substring(1); + path = path.substring(1); + if (path.startsWith("joinchat/")) { + group = path.replace("joinchat/", ""); + } else { + username = path; + } } } } else if (scheme.equals("tg")) { - String url = data.toString().toLowerCase(); + String url = data.toString(); if (url.startsWith("tg:resolve") || url.startsWith("tg://resolve")) { url = url.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve", "tg://telegram.org"); data = Uri.parse(url); username = data.getQueryParameter("domain"); - } - } - } - if (username != null) { - final ProgressDialog progressDialog = new ProgressDialog(this); - progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); - progressDialog.setCanceledOnTouchOutside(false); - progressDialog.setCancelable(false); - - TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername(); - req.username = username; - final long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { - @Override - public void run(final TLObject response, final TLRPC.TL_error error) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (!LaunchActivity.this.isFinishing()) { - try { - progressDialog.dismiss(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - if (error == null && actionBarLayout != null) { - TLRPC.User user = (TLRPC.User) response; - MessagesController.getInstance().putUser(user, false); - ArrayList users = new ArrayList<>(); - users.add(user); - MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); - Bundle args = new Bundle(); - args.putInt("user_id", user.id); - ChatActivity fragment = new ChatActivity(args); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); - actionBarLayout.presentFragment(fragment, false, true, true); - } - } - } - }); - } - }); - - progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - ConnectionsManager.getInstance().cancelRpc(reqId, true); - try { - dialog.dismiss(); - } catch (Exception e) { - FileLog.e("tmessages", e); + } else if (url.startsWith("tg:join") || url.startsWith("tg://join")) { + url = url.replace("tg:join", "tg://telegram.org").replace("tg://join", "tg://telegram.org"); + data = Uri.parse(url); + group = data.getQueryParameter("invite"); } } - }); - progressDialog.show(); + } + if (username != null || group != null) { + runLinkRequest(username, group, 0); } else { try { Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null); @@ -918,6 +883,189 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa return false; } + private void runLinkRequest(final String username, final String group, final int state) { + final ProgressDialog progressDialog = new ProgressDialog(this); + progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); + progressDialog.setCanceledOnTouchOutside(false); + progressDialog.setCancelable(false); + long requestId = 0; + + if (username != null) { + TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername(); + req.username = username; + requestId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(final TLObject response, final TLRPC.TL_error error) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (!LaunchActivity.this.isFinishing()) { + try { + progressDialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + if (error == null && actionBarLayout != null) { + TLRPC.User user = (TLRPC.User) response; + MessagesController.getInstance().putUser(user, false); + ArrayList users = new ArrayList<>(); + users.add(user); + MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); + Bundle args = new Bundle(); + args.putInt("user_id", user.id); + ChatActivity fragment = new ChatActivity(args); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); + actionBarLayout.presentFragment(fragment, false, true, true); + } + } + } + }); + } + }); + } else if (group != null) { + if (state == 0) { + final TLRPC.TL_messages_checkChatInvite req = new TLRPC.TL_messages_checkChatInvite(); + req.hash = group; + requestId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(final TLObject response, final TLRPC.TL_error error) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (!LaunchActivity.this.isFinishing()) { + try { + progressDialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + if (error == null && actionBarLayout != null) { + TLRPC.ChatInvite invite = (TLRPC.ChatInvite) response; + if (invite.chat != null && !invite.chat.left) { + MessagesController.getInstance().putChat(invite.chat, false); + ArrayList chats = new ArrayList<>(); + chats.add(invite.chat); + MessagesStorage.getInstance().putUsersAndChats(null, chats, false, true); + Bundle args = new Bundle(); + args.putInt("chat_id", invite.chat.id); + ChatActivity fragment = new ChatActivity(args); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); + actionBarLayout.presentFragment(fragment, false, true, true); + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setMessage(LocaleController.formatString("JoinToGroup", R.string.JoinToGroup, invite.chat != null ? invite.chat.title : invite.title)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + runLinkRequest(username, group, 1); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showAlertDialog(builder); + } + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + showAlertDialog(builder); + } + } + } + }); + } + }); + } else if (state == 1) { + TLRPC.TL_messages_importChatInvite req = new TLRPC.TL_messages_importChatInvite(); + req.hash = group; + ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(final TLObject response, final TLRPC.TL_error error) { + if (error == null) { + TLRPC.Updates updates = (TLRPC.Updates) response; + MessagesController.getInstance().processUpdates(updates, false); + } + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (!LaunchActivity.this.isFinishing()) { + try { + progressDialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + if (error == null) { + if (actionBarLayout != null) { + TLRPC.Updates updates = (TLRPC.Updates) response; + if (!updates.chats.isEmpty()) { + MessagesController.getInstance().putUsers(updates.users, false); + MessagesController.getInstance().putChats(updates.chats, false); + Bundle args = new Bundle(); + args.putInt("chat_id", updates.chats.get(0).id); + ChatActivity fragment = new ChatActivity(args); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); + actionBarLayout.presentFragment(fragment, false, true, true); + } + } + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + if (error.text.equals("USERS_TOO_MUCH")) { + builder.setMessage(LocaleController.getString("JoinToGroupErrorFull", R.string.JoinToGroupErrorFull)); + } else { + builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist)); + } + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + showAlertDialog(builder); + } + } + } + }); + } + }); + } + } + + final long reqId = requestId; + progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + ConnectionsManager.getInstance().cancelRpc(reqId, true); + try { + dialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + progressDialog.show(); + } + + public AlertDialog showAlertDialog(AlertDialog.Builder builder) { + try { + if (visibleDialog != null) { + visibleDialog.dismiss(); + visibleDialog = null; + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + try { + visibleDialog = builder.show(); + visibleDialog.setCanceledOnTouchOutside(true); + visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + visibleDialog = null; + } + }); + return visibleDialog; + } catch (Exception e) { + FileLog.e("tmessages", e); + } + return null; + } + @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); @@ -960,7 +1108,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1); } - if (!fragment.openVideoEditor(videoPath, true)) { + if (!fragment.openVideoEditor(videoPath, true, false)) { if (!AndroidUtilities.isTablet()) { messageFragment.finishFragment(true); } @@ -970,13 +1118,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, null); } } else { - actionBarLayout.presentFragment(fragment, true); - if (sendingText != null) { - fragment.processSendingText(sendingText); + SendMessagesHelper.prepareSendingText(sendingText, dialog_id); + //fragment.setReplyText(sendingText);//Always open chat before sending text message shared from other app } + actionBarLayout.presentFragment(fragment, true); if (photoPathsArray != null) { - SendMessagesHelper.prepareSendingPhotos(null, photoPathsArray, dialog_id, null); + SendMessagesHelper.prepareSendingPhotos(null, photoPathsArray, dialog_id, null, null); } if (documentsPathsArray != null || documentsUrisArray != null) { SendMessagesHelper.prepareSendingDocuments(documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, documentsMimeType, dialog_id, null); @@ -1043,7 +1191,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); relativeLayoutParams.width = leftWidth; - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; actionBarLayout.setLayoutParams(relativeLayoutParams); relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams(); @@ -1052,7 +1200,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa relativeLayoutParams = (RelativeLayout.LayoutParams) rightActionBarLayout.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.displaySize.x - leftWidth; - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; relativeLayoutParams.leftMargin = leftWidth; rightActionBarLayout.setLayoutParams(relativeLayoutParams); @@ -1074,8 +1222,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa tabletFullSize = true; relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); - relativeLayoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; - relativeLayoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT; + relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; + relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; actionBarLayout.setLayoutParams(relativeLayoutParams); shadowTabletSide.setVisibility(View.GONE); @@ -1156,6 +1304,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa protected void onDestroy() { PhotoViewer.getInstance().destroyPhotoViewer(); SecretPhotoViewer.getInstance().destroyPhotoViewer(); + try { + if (visibleDialog != null) { + visibleDialog.dismiss(); + visibleDialog = null; + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } super.onDestroy(); onFinish(); } @@ -1178,6 +1334,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa ApplicationLoader.mainInterfacePaused = false; ConnectionsManager.getInstance().setAppPaused(false, false); updateCurrentConnectionState(); + if (PhotoViewer.getInstance().isVisible()) { + PhotoViewer.getInstance().onResume(); + } } @Override @@ -1438,7 +1597,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) { if (AndroidUtilities.isTablet()) { - drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true); + drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true); if (fragment instanceof MessagesActivity) { MessagesActivity messagesActivity = (MessagesActivity)fragment; if (messagesActivity.isMainDialogList() && layout != actionBarLayout) { @@ -1519,7 +1678,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } return true; } else { - drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity), false); + drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity), false); return true; } } @@ -1527,7 +1686,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) { if (AndroidUtilities.isTablet()) { - drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true); + drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true); if (fragment instanceof MessagesActivity) { MessagesActivity messagesActivity = (MessagesActivity)fragment; if (messagesActivity.isMainDialogList() && layout != actionBarLayout) { @@ -1584,7 +1743,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } return true; } else { - drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity), false); + drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof CountrySelectActivity), false); return true; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java index 21004481..4a67d317 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java @@ -8,11 +8,31 @@ package org.telegram.ui; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; +import android.animation.StateListAnimator; import android.content.Context; +import android.content.Intent; +import android.graphics.Outline; import android.location.Location; import android.location.LocationManager; +import android.net.Uri; +import android.os.Build; +import android.text.TextUtils; +import android.util.TypedValue; +import android.view.Gravity; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; +import android.view.ViewOutlineProvider; +import android.view.WindowManager; +import android.widget.AbsListView; +import android.widget.AdapterView; +import android.widget.EditText; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.TextView; import com.google.android.gms.maps.CameraUpdate; @@ -21,8 +41,8 @@ import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.MapsInitializer; import com.google.android.gms.maps.model.BitmapDescriptorFactory; +import com.google.android.gms.maps.model.CircleOptions; import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import org.telegram.android.AndroidUtilities; @@ -39,33 +59,67 @@ import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Adapters.BaseLocationAdapter; +import org.telegram.ui.Adapters.LocationActivityAdapter; +import org.telegram.ui.Adapters.LocationActivitySearchAdapter; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; +import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.MapPlaceholderDrawable; +import java.util.ArrayList; import java.util.List; +import java.util.Locale; public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { private GoogleMap googleMap; private TextView distanceTextView; - private Marker userMarker; - private Location myLocation; - private Location userLocation; - private MessageObject messageObject; private BackupImageView avatarImageView; private TextView nameTextView; + private MapView mapView; + private FrameLayout mapViewClip; + private LocationActivityAdapter adapter; + private ListView listView; + private ListView searchListView; + private LocationActivitySearchAdapter searchAdapter; + private LinearLayout emptyTextLayout; + private ImageView markerImageView; + private ImageView markerXImageView; + private ImageView locationButton; + + private AnimatorSet animatorSet; + + private boolean searching; + private boolean searchWas; + + private boolean wasResults; + + private Location myLocation; + private Location userLocation; + private int markerTop; + + private MessageObject messageObject; private boolean userLocationMoved = false; private boolean firstWas = false; - private MapView mapView; + private CircleOptions circleOptions; private LocationActivityDelegate delegate; - private final static int map_to_my_location = 1; + private int overScrollHeight = AndroidUtilities.displaySize.x - AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(66); + private int halfHeight; + + private final static int share = 1; private final static int map_list_menu_map = 2; private final static int map_list_menu_satellite = 3; private final static int map_list_menu_hybrid = 4; public interface LocationActivityDelegate { - void didSelectLocation(double latitude, double longitude); + void didSelectLocation(TLRPC.MessageMedia location); + } + + @Override + public boolean needAddActionBar() { + return messageObject != null; } @Override @@ -87,16 +141,20 @@ public class LocationActivity extends BaseFragment implements NotificationCenter if (mapView != null) { mapView.onDestroy(); } + if (adapter != null) { + adapter.destroy(); + } + if (searchAdapter != null) { + searchAdapter.destroy(); + } } @Override public View createView(Context context, LayoutInflater inflater) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); - if (messageObject != null) { - actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); - } else { - actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation)); + if (AndroidUtilities.isTablet()) { + actionBar.setOccupyStatusBar(false); } actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @@ -116,52 +174,428 @@ public class LocationActivity extends BaseFragment implements NotificationCenter if (googleMap != null) { googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); } - } else if (id == map_to_my_location) { - if (myLocation != null) { - LatLng latLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude()); - if (googleMap != null) { - CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); - googleMap.animateCamera(position); - } + } else if (id == share) { + try { + double lat = messageObject.messageOwner.media.geo.lat; + double lon = messageObject.messageOwner.media.geo._long; + getParentActivity().startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:" + lat + "," + lon + "?q=" + lat + "," + lon))); + } catch (Exception e) { + FileLog.e("tmessages", e); } } } }); ActionBarMenu menu = actionBar.createMenu(); - menu.addItem(map_to_my_location, R.drawable.ic_ab_location); + if (messageObject != null) { + if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) { + actionBar.setTitle(messageObject.messageOwner.media.title); + if (messageObject.messageOwner.media.address != null && messageObject.messageOwner.media.address.length() > 0) { + actionBar.setSubtitle(messageObject.messageOwner.media.address); + } + } else { + actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); + } + menu.addItem(share, R.drawable.share); + } else { + actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation)); + + ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { + @Override + public void onSearchExpand() { + searching = true; + listView.setVisibility(View.GONE); + mapViewClip.setVisibility(View.GONE); + searchListView.setVisibility(View.VISIBLE); + searchListView.setEmptyView(emptyTextLayout); + } + + @Override + public boolean onSearchCollapse() { + searching = false; + searchWas = false; + searchListView.setEmptyView(null); + listView.setVisibility(View.VISIBLE); + mapViewClip.setVisibility(View.VISIBLE); + searchListView.setVisibility(View.GONE); + emptyTextLayout.setVisibility(View.GONE); + searchAdapter.searchDelayed(null, null); + return true; + } + + @Override + public void onTextChanged(EditText editText) { + if (searchAdapter == null) { + return; + } + String text = editText.getText().toString(); + if (text.length() != 0) { + searchWas = true; + } + searchAdapter.searchDelayed(text, userLocation); + } + }); + item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); + } ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); item.addSubItem(map_list_menu_map, LocaleController.getString("Map", R.string.Map), 0); item.addSubItem(map_list_menu_satellite, LocaleController.getString("Satellite", R.string.Satellite), 0); item.addSubItem(map_list_menu_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), 0); + fragmentView = new FrameLayout(context) { + private boolean first = true; + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + if (changed) { + fixLayoutInternal(first); + first = false; + } + } + }; + FrameLayout frameLayout = (FrameLayout) fragmentView; + + locationButton = new ImageView(context); + locationButton.setBackgroundResource(R.drawable.floating_user_states); + locationButton.setImageResource(R.drawable.myloc_on); + locationButton.setScaleType(ImageView.ScaleType.CENTER); + if (Build.VERSION.SDK_INT >= 21) { + StateListAnimator animator = new StateListAnimator(); + animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(locationButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200)); + animator.addState(new int[]{}, ObjectAnimator.ofFloat(locationButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200)); + locationButton.setStateListAnimator(animator); + locationButton.setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56)); + } + }); + } if (messageObject != null) { - fragmentView = inflater.inflate(R.layout.location_view_layout, null, false); + mapView = new MapView(context); + frameLayout.setBackgroundDrawable(new MapPlaceholderDrawable()); + mapView.onCreate(null); + try { + MapsInitializer.initialize(context); + googleMap = mapView.getMap(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + FrameLayout bottomView = new FrameLayout(context); + bottomView.setBackgroundResource(R.drawable.location_panel); + frameLayout.addView(bottomView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 60, Gravity.LEFT | Gravity.BOTTOM)); + bottomView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (userLocation != null) { + LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); + if (googleMap != null) { + CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); + googleMap.animateCamera(position); + } + } + } + }); + + avatarImageView = new BackupImageView(context); + avatarImageView.setRoundRadius(AndroidUtilities.dp(20)); + bottomView.addView(avatarImageView, LayoutHelper.createFrame(40, 40, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 12, 12, LocaleController.isRTL ? 12 : 0, 0)); + + nameTextView = new TextView(context); + nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + nameTextView.setTextColor(0xff212121); + nameTextView.setMaxLines(1); + nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + nameTextView.setEllipsize(TextUtils.TruncateAt.END); + nameTextView.setSingleLine(true); + nameTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + bottomView.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 12 : 72, 10, LocaleController.isRTL ? 72 : 12, 0)); + + distanceTextView = new TextView(context); + distanceTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + distanceTextView.setTextColor(0xff2f8cc9); + distanceTextView.setMaxLines(1); + distanceTextView.setEllipsize(TextUtils.TruncateAt.END); + distanceTextView.setSingleLine(true); + distanceTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + bottomView.addView(distanceTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 12 : 72, 33, LocaleController.isRTL ? 72 : 12, 0)); + + userLocation = new Location("network"); + userLocation.setLatitude(messageObject.messageOwner.media.geo.lat); + userLocation.setLongitude(messageObject.messageOwner.media.geo._long); + if (googleMap != null) { + LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); + try { + googleMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin))); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); + googleMap.moveCamera(position); + } + + ImageView routeButton = new ImageView(context); + routeButton.setBackgroundResource(R.drawable.floating_states); + routeButton.setImageResource(R.drawable.navigate); + routeButton.setScaleType(ImageView.ScaleType.CENTER); + if (Build.VERSION.SDK_INT >= 21) { + StateListAnimator animator = new StateListAnimator(); + animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(routeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200)); + animator.addState(new int[]{}, ObjectAnimator.ofFloat(routeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200)); + routeButton.setStateListAnimator(animator); + routeButton.setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56)); + } + }); + } + frameLayout.addView(routeButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 28)); + routeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (myLocation != null) { + try { + Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", myLocation.getLatitude(), myLocation.getLongitude(), messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long))); + getParentActivity().startActivity(intent); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } + }); + + frameLayout.addView(locationButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 100)); + locationButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (myLocation != null && googleMap != null) { + googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()), googleMap.getMaxZoomLevel() - 8)); + } + } + }); } else { - fragmentView = inflater.inflate(R.layout.location_attach_layout, null, false); - } + searchWas = false; + searching = false; + mapViewClip = new FrameLayout(context); + mapViewClip.setBackgroundDrawable(new MapPlaceholderDrawable()); + if (adapter != null) { + adapter.destroy(); + } + if (searchAdapter != null) { + searchAdapter.destroy(); + } - avatarImageView = (BackupImageView) fragmentView.findViewById(R.id.location_avatar_view); - if (avatarImageView != null) { - avatarImageView.setRoundRadius(AndroidUtilities.dp(32)); - } - nameTextView = (TextView) fragmentView.findViewById(R.id.location_name_label); - distanceTextView = (TextView) fragmentView.findViewById(R.id.location_distance_label); - View bottomView = fragmentView.findViewById(R.id.location_bottom_view); - TextView sendButton = (TextView) fragmentView.findViewById(R.id.location_send_button); - if (sendButton != null) { - sendButton.setText(LocaleController.getString("SendLocation", R.string.SendLocation).toUpperCase()); - sendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - } + listView = new ListView(context); + listView.setAdapter(adapter = new LocationActivityAdapter(context)); + listView.setVerticalScrollBarEnabled(false); + listView.setDividerHeight(0); + listView.setDivider(null); + frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP)); + listView.setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { - mapView = (MapView) fragmentView.findViewById(R.id.map_view); - mapView.onCreate(null); - try { - MapsInitializer.initialize(context); - googleMap = mapView.getMap(); - } catch (Exception e) { - FileLog.e("tmessages", e); + } + + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { + if (totalItemCount == 0) { + return; + } + updateClipView(firstVisibleItem); + } + }); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + if (position == 1) { + if (delegate != null && userLocation != null) { + TLRPC.TL_messageMediaGeo location = new TLRPC.TL_messageMediaGeo(); + location.geo = new TLRPC.TL_geoPoint(); + location.geo.lat = userLocation.getLatitude(); + location.geo._long = userLocation.getLongitude(); + delegate.didSelectLocation(location); + } + finishFragment(); + } else { + TLRPC.TL_messageMediaVenue object = adapter.getItem(position); + if (object != null && delegate != null) { + delegate.didSelectLocation(object); + } + finishFragment(); + } + } + }); + adapter.setDelegate(new BaseLocationAdapter.BaseLocationAdapterDelegate() { + @Override + public void didLoadedSearchResult(ArrayList places) { + if (!wasResults && !places.isEmpty()) { + wasResults = true; + } + } + }); + adapter.setOverScrollHeight(overScrollHeight); + + frameLayout.addView(mapViewClip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP)); + + mapView = new MapView(context) { + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + if (Build.VERSION.SDK_INT >= 11) { + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + if (animatorSet != null) { + animatorSet.cancel(); + } + animatorSet = new AnimatorSet(); + animatorSet.setDuration(200); + animatorSet.playTogether( + ObjectAnimator.ofFloat(markerImageView, "translationY", markerTop + -AndroidUtilities.dp(10)), + ObjectAnimator.ofFloat(markerXImageView, "alpha", 1.0f)); + animatorSet.start(); + } else if (ev.getAction() == MotionEvent.ACTION_UP) { + if (animatorSet != null) { + animatorSet.cancel(); + } + animatorSet = new AnimatorSet(); + animatorSet.setDuration(200); + animatorSet.playTogether( + ObjectAnimator.ofFloat(markerImageView, "translationY", markerTop), + ObjectAnimator.ofFloat(markerXImageView, "alpha", 0.0f)); + animatorSet.start(); + } + } + if (ev.getAction() == MotionEvent.ACTION_MOVE) { + if (!userLocationMoved) { + if (Build.VERSION.SDK_INT >= 11) { + AnimatorSet animatorSet = new AnimatorSet(); + animatorSet.setDuration(200); + animatorSet.play(ObjectAnimator.ofFloat(locationButton, "alpha", 1.0f)); + animatorSet.start(); + } else { + locationButton.setVisibility(VISIBLE); + } + userLocationMoved = true; + } + if (googleMap != null && userLocation != null) { + userLocation.setLatitude(googleMap.getCameraPosition().target.latitude); + userLocation.setLongitude(googleMap.getCameraPosition().target.longitude); + } + adapter.setCustomLocation(userLocation); + } + return super.onInterceptTouchEvent(ev); + } + }; + mapView.onCreate(null); + try { + MapsInitializer.initialize(context); + googleMap = mapView.getMap(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + View shadow = new View(context); + shadow.setBackgroundResource(R.drawable.header_shadow_reverse); + mapViewClip.addView(shadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(3), Gravity.LEFT | Gravity.BOTTOM)); + + markerImageView = new ImageView(context); + markerImageView.setImageResource(R.drawable.map_pin); + mapViewClip.addView(markerImageView, LayoutHelper.createFrame(24, 42, Gravity.TOP | Gravity.CENTER_HORIZONTAL)); + + if (Build.VERSION.SDK_INT >= 11) { + markerXImageView = new ImageView(context); + markerXImageView.setAlpha(0.0f); + markerXImageView.setImageResource(R.drawable.place_x); + mapViewClip.addView(markerXImageView, LayoutHelper.createFrame(14, 14, Gravity.TOP | Gravity.CENTER_HORIZONTAL)); + } + + mapViewClip.addView(locationButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14)); + locationButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (myLocation != null && googleMap != null) { + if (Build.VERSION.SDK_INT >= 11) { + AnimatorSet animatorSet = new AnimatorSet(); + animatorSet.setDuration(200); + animatorSet.play(ObjectAnimator.ofFloat(locationButton, "alpha", 0.0f)); + animatorSet.start(); + } else { + locationButton.setVisibility(View.INVISIBLE); + } + adapter.setCustomLocation(null); + userLocationMoved = false; + googleMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()))); + } + } + }); + if (Build.VERSION.SDK_INT >= 11) { + locationButton.setAlpha(0.0f); + } else { + locationButton.setVisibility(View.INVISIBLE); + } + + emptyTextLayout = new LinearLayout(context); + emptyTextLayout.setVisibility(View.GONE); + emptyTextLayout.setOrientation(LinearLayout.VERTICAL); + frameLayout.addView(emptyTextLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP)); + emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return true; + } + }); + + TextView emptyTextView = new TextView(context); + emptyTextView.setTextColor(0xff808080); + emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); + emptyTextView.setGravity(Gravity.CENTER); + emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult)); + emptyTextLayout.addView(emptyTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f)); + + FrameLayout frameLayoutEmpty = new FrameLayout(context); + emptyTextLayout.addView(frameLayoutEmpty, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f)); + + searchListView = new ListView(context); + searchListView.setVisibility(View.GONE); + searchListView.setDividerHeight(0); + searchListView.setDivider(null); + searchListView.setAdapter(searchAdapter = new LocationActivitySearchAdapter(context)); + frameLayout.addView(searchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP)); + searchListView.setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + if (scrollState == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) { + AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); + } + } + + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { + + } + }); + searchListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + TLRPC.TL_messageMediaVenue object = searchAdapter.getItem(position); + if (object != null && delegate != null) { + delegate.didSelectLocation(object); + } + finishFragment(); + } + }); + + if (googleMap != null) { + userLocation = new Location("network"); + userLocation.setLatitude(20.659322); + userLocation.setLongitude(-11.406250); + } + + frameLayout.addView(actionBar); } if (googleMap != null) { @@ -175,74 +609,129 @@ public class LocationActivity extends BaseFragment implements NotificationCenter positionMarker(location); } }); - myLocation = getLastLocation(); - - if (sendButton != null) { - userLocation = new Location("network"); - userLocation.setLatitude(20.659322); - userLocation.setLongitude(-11.406250); - LatLng latLng = new LatLng(20.659322, -11.406250); - userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)).draggable(true)); - - sendButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (delegate != null) { - delegate.didSelectLocation(userLocation.getLatitude(), userLocation.getLongitude()); - } - finishFragment(); - } - }); - - googleMap.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() { - @Override - public void onMarkerDragStart(Marker marker) { - } - - @Override - public void onMarkerDrag(Marker marker) { - userLocationMoved = true; - } - - @Override - public void onMarkerDragEnd(Marker marker) { - LatLng latLng = marker.getPosition(); - userLocation.setLatitude(latLng.latitude); - userLocation.setLongitude(latLng.longitude); - } - }); - } - - if (bottomView != null) { - bottomView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (userLocation != null) { - LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); - CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); - googleMap.animateCamera(position); - } - } - }); - } - - if (messageObject != null) { - userLocation = new Location("network"); - userLocation.setLatitude(messageObject.messageOwner.media.geo.lat); - userLocation.setLongitude(messageObject.messageOwner.media.geo._long); - LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); - userMarker = googleMap.addMarker(new MarkerOptions().position(latLng). - icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin))); - CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); - googleMap.moveCamera(position); - } - - positionMarker(myLocation); + positionMarker(myLocation = getLastLocation()); } return fragmentView; } + @Override + public void onOpenAnimationEnd() { + if (mapViewClip != null) { + mapViewClip.addView(mapView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, overScrollHeight + AndroidUtilities.dp(10), Gravity.TOP | Gravity.LEFT)); + updateClipView(listView.getFirstVisiblePosition()); + } else { + ((FrameLayout) fragmentView).addView(mapView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); + } + } + + private void updateClipView(int firstVisibleItem) { + int height = 0; + int top = 0; + View child = listView.getChildAt(0); + if (child != null) { + if (firstVisibleItem == 0) { + top = child.getTop(); + height = overScrollHeight + (top < 0 ? top : 0); + halfHeight = (top < 0 ? top : 0) / 2; + } + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mapViewClip.getLayoutParams(); + if (layoutParams != null) { + if (height <= 0) { + if (mapView.getVisibility() == View.VISIBLE) { + mapView.setVisibility(View.INVISIBLE); + mapViewClip.setVisibility(View.INVISIBLE); + } + } else { + if (mapView.getVisibility() == View.INVISIBLE) { + mapView.setVisibility(View.VISIBLE); + mapViewClip.setVisibility(View.VISIBLE); + } + } + if (Build.VERSION.SDK_INT >= 11) { + mapViewClip.setTranslationY(Math.min(0, top)); + mapView.setTranslationY(Math.max(0, -top / 2)); + markerImageView.setTranslationY(markerTop = -top - AndroidUtilities.dp(42) + height / 2); + markerXImageView.setTranslationY(-top - AndroidUtilities.dp(7) + height / 2); + + if (googleMap != null) { + layoutParams = (FrameLayout.LayoutParams) mapView.getLayoutParams(); + if (layoutParams != null && layoutParams.height != overScrollHeight + AndroidUtilities.dp(10)) { + layoutParams.height = overScrollHeight + AndroidUtilities.dp(10); + googleMap.setPadding(0, 0, 0, AndroidUtilities.dp(10)); + mapView.setLayoutParams(layoutParams); + } + } + } else { + markerTop = 0; + layoutParams.height = height; + mapViewClip.setLayoutParams(layoutParams); + + layoutParams = (FrameLayout.LayoutParams) markerImageView.getLayoutParams(); + layoutParams.topMargin = height / 2 - AndroidUtilities.dp(42); + markerImageView.setLayoutParams(layoutParams); + + if (googleMap != null) { + layoutParams = (FrameLayout.LayoutParams) mapView.getLayoutParams(); + if (layoutParams != null) { + layoutParams.topMargin = halfHeight; + layoutParams.height = overScrollHeight + AndroidUtilities.dp(10); + googleMap.setPadding(0, 0, 0, AndroidUtilities.dp(10)); + mapView.setLayoutParams(layoutParams); + } + } + } + } + } + } + + private void fixLayoutInternal(final boolean resume) { + if (listView != null) { + int height = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight(); + int viewHeight = fragmentView.getMeasuredHeight(); + if (viewHeight == 0) { + return; + } + overScrollHeight = viewHeight - AndroidUtilities.dp(66) - height; + + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); + layoutParams.topMargin = height; + listView.setLayoutParams(layoutParams); + layoutParams = (FrameLayout.LayoutParams) mapViewClip.getLayoutParams(); + layoutParams.topMargin = height; + layoutParams.height = overScrollHeight; + mapViewClip.setLayoutParams(layoutParams); + layoutParams = (FrameLayout.LayoutParams) searchListView.getLayoutParams(); + layoutParams.topMargin = height; + searchListView.setLayoutParams(layoutParams); + + adapter.setOverScrollHeight(overScrollHeight); + layoutParams = (FrameLayout.LayoutParams) mapView.getLayoutParams(); + if (layoutParams != null) { + layoutParams.height = overScrollHeight + AndroidUtilities.dp(10); + if (googleMap != null) { + googleMap.setPadding(0, 0, 0, AndroidUtilities.dp(10)); + } + mapView.setLayoutParams(layoutParams); + } + adapter.notifyDataSetChanged(); + + if (resume) { + listView.setSelectionFromTop(0, -(int) (AndroidUtilities.dp(56) * 2.5f + AndroidUtilities.dp(36 + 66))); + updateClipView(listView.getFirstVisiblePosition()); + listView.post(new Runnable() { + @Override + public void run() { + listView.setSelectionFromTop(0, -(int) (AndroidUtilities.dp(56) * 2.5f + AndroidUtilities.dp(36 + 66))); + updateClipView(listView.getFirstVisiblePosition()); + } + }); + } else { + updateClipView(listView.getFirstVisiblePosition()); + } + } + } + private Location getLastLocation() { LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE); List providers = lm.getProviders(true); @@ -280,7 +769,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter if (location == null) { return; } - myLocation = location; + myLocation = new Location(location); if (messageObject != null) { if (userLocation != null && distanceTextView != null) { float distance = location.distanceTo(userLocation); @@ -290,11 +779,14 @@ public class LocationActivity extends BaseFragment implements NotificationCenter distanceTextView.setText(String.format("%.2f %s", distance / 1000.0f, LocaleController.getString("KMetersAway", R.string.KMetersAway))); } } - } else { - if (!userLocationMoved && googleMap != null) { - userLocation = location; - LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); - userMarker.setPosition(latLng); + } else if (googleMap != null) { + LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); + if (adapter != null) { + adapter.searchGooglePlacesWithQuery(null, myLocation); + adapter.setGpsLocation(myLocation); + } + if (!userLocationMoved) { + userLocation = new Location(location); if (firstWas) { CameraUpdate position = CameraUpdateFactory.newLatLng(latLng); googleMap.animateCamera(position); @@ -338,10 +830,14 @@ public class LocationActivity extends BaseFragment implements NotificationCenter @Override public void onResume() { super.onResume(); + if (!AndroidUtilities.isTablet()) { + getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + } if (mapView != null) { mapView.onResume(); } updateUserData(); + fixLayoutInternal(true); } @Override @@ -355,4 +851,10 @@ public class LocationActivity extends BaseFragment implements NotificationCenter public void setDelegate(LocationActivityDelegate delegate) { this.delegate = delegate; } + + private void updateSearchInterface() { + if (adapter != null) { + adapter.notifyDataSetChanged(); + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index 5493a700..1177fb7d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -39,6 +39,8 @@ import android.widget.ProgressBar; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; import org.telegram.android.LocaleController; import org.telegram.android.MessageObject; import org.telegram.android.MessagesController; @@ -60,14 +62,13 @@ import org.telegram.ui.ActionBar.ActionBarPopupWindow; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.BaseSectionsAdapter; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; import org.telegram.ui.Cells.GreySectionCell; import org.telegram.ui.Cells.LoadingCell; import org.telegram.ui.Cells.SharedDocumentCell; import org.telegram.ui.Cells.SharedMediaSectionCell; import org.telegram.ui.Cells.SharedPhotoVideoCell; import org.telegram.ui.Components.BackupImageView; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.SectionsListView; import java.io.File; @@ -377,8 +378,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No dropDownContainer.addSubItem(files_item, LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle), 0); actionBar.addView(dropDownContainer); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; @@ -403,8 +404,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); dropDownContainer.addView(dropDown); layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.gravity = Gravity.CENTER_VERTICAL; dropDown.setLayoutParams(layoutParams); @@ -431,7 +432,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams(); layoutParams1.weight = 1; layoutParams1.width = 0; - layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams1.height = LayoutHelper.MATCH_PARENT; selectedMessagesCountTextView.setLayoutParams(layoutParams1); if ((int) dialog_id != 0) { @@ -453,8 +454,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No listView.setClipToPadding(false); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -518,8 +519,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No emptyView.setBackgroundColor(0xfff0f0f0); frameLayout.addView(emptyView); layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; emptyView.setLayoutParams(layoutParams); emptyView.setOnTouchListener(new View.OnTouchListener() { @Override @@ -531,8 +532,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No emptyImageView = new ImageView(context); emptyView.addView(emptyImageView); layoutParams1 = (LinearLayout.LayoutParams) emptyImageView.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; emptyImageView.setLayoutParams(layoutParams1); emptyTextView = new TextView(context); @@ -543,8 +544,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No emptyView.addView(emptyTextView); layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); layoutParams1.topMargin = AndroidUtilities.dp(24); - layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; layoutParams1.gravity = Gravity.CENTER; emptyTextView.setLayoutParams(layoutParams1); @@ -555,15 +556,15 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No progressView.setBackgroundColor(0xfff0f0f0); frameLayout.addView(progressView); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; progressView.setLayoutParams(layoutParams); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams1 = (LinearLayout.LayoutParams) progressBar.getLayoutParams(); - layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT; - layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT; + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; progressBar.setLayoutParams(layoutParams1); switchToCurrentSelectedMode(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java index 13a3ad88..12550c84 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java @@ -38,6 +38,8 @@ import android.widget.ListView; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.ContactsController; import org.telegram.android.LocaleController; import org.telegram.android.MessageObject; @@ -57,10 +59,9 @@ import org.telegram.ui.ActionBar.MenuDrawable; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.DialogsAdapter; import org.telegram.ui.Adapters.DialogsSearchAdapter; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Cells.DialogCell; import org.telegram.ui.Cells.UserCell; +import org.telegram.ui.Components.ResourceLoader; import java.util.ArrayList; @@ -163,6 +164,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter public View createView(Context context, LayoutInflater inflater) { searching = false; searchWas = false; + + ResourceLoader.loadRecources(context); + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); ActionBarMenu menu = actionBar.createMenu(); if (!onlySelect && searchString == null) { @@ -252,6 +256,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter }); item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); item.getSearchField().setTextColor(themePrefs.getInt("chatsHeaderTitleColor", 0xffffffff)); + Drawable clear = getParentActivity().getResources().getDrawable(R.drawable.ic_close_white); + clear.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + item.getClearButton().setImageDrawable(clear); if (onlySelect) { //actionBar.setBackButtonImage(R.drawable.ic_ab_back); Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back); @@ -669,6 +676,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter lock.setColorFilter(themePrefs.getInt("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); lock = getParentActivity().getResources().getDrawable(R.drawable.lock_open); lock.setColorFilter(themePrefs.getInt("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + Drawable clear = getParentActivity().getResources().getDrawable(R.drawable.ic_close_white); + clear.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); + } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java index 5024538c..9de61ac7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java @@ -48,6 +48,7 @@ import org.telegram.ui.Cells.TextCheckCell; import org.telegram.ui.Cells.TextColorCell; import org.telegram.ui.Cells.TextDetailSettingsCell; import org.telegram.ui.Components.ColorPickerView; +import org.telegram.ui.Components.LayoutHelper; public class NotificationsSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { private ListView listView; @@ -178,8 +179,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif listView.setVerticalScrollBarEnabled(false); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setAdapter(new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java index f5cad11a..769ee0da 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java @@ -37,7 +37,6 @@ import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; import android.widget.EditText; import android.widget.FrameLayout; -import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -58,6 +57,7 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.TextCheckCell; import org.telegram.ui.Cells.TextInfoPrivacyCell; import org.telegram.ui.Cells.TextSettingsCell; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.NumberPicker; public class PasscodeActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { @@ -156,8 +156,8 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); frameLayout.addView(titleTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams); @@ -184,7 +184,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter layoutParams.leftMargin = AndroidUtilities.dp(40); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.rightMargin = AndroidUtilities.dp(40); - layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override @@ -257,8 +257,8 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0); actionBar.addView(dropDownContainer); layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; @@ -283,8 +283,8 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); dropDownContainer.addView(dropDown); layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.bottomMargin = AndroidUtilities.dp(1); @@ -304,8 +304,8 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); @@ -528,7 +528,6 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter UserConfig.passcodeHash = Utilities.MD5(firstPassword); UserConfig.passcodeType = currentPasswordType; UserConfig.saveConfig(false); - //TODO show alert finishFragment(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.didSetPasscode); passwordEditText.clearFocus(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java index fa330b1d..ec34ead5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java @@ -10,8 +10,10 @@ package org.telegram.ui; import android.app.Activity; import android.content.Context; +import android.content.res.Configuration; import android.graphics.drawable.ColorDrawable; import android.os.Build; +import android.text.TextUtils; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -34,10 +36,12 @@ import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.R; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; +import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.PhotoPickerAlbumsCell; import org.telegram.ui.Cells.PhotoPickerSearchCell; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PhotoPickerBottomLayout; import java.util.ArrayList; @@ -46,11 +50,13 @@ import java.util.HashMap; public class PhotoAlbumPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public interface PhotoAlbumPickerActivityDelegate { - void didSelectPhotos(ArrayList photos, ArrayList webPhotos); + void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos); + boolean didSelectVideo(String path); void startPhotoSelectActivity(); } private ArrayList albumsSorted = null; + private ArrayList videoAlbumsSorted = null; private HashMap selectedPhotos = new HashMap<>(); private HashMap selectedWebPhotos = new HashMap<>(); private HashMap recentImagesWebKeys = new HashMap<>(); @@ -64,20 +70,32 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati private ListAdapter listAdapter; private FrameLayout progressView; private TextView emptyView; + private TextView dropDown; + private ActionBarMenuItem dropDownContainer; private PhotoPickerBottomLayout photoPickerBottomLayout; private boolean sendPressed = false; private boolean singlePhoto = false; + private int selectedMode; + private ChatActivity chatActivity; private PhotoAlbumPickerActivityDelegate delegate; - public PhotoAlbumPickerActivity(boolean onlyOnePhoto) { + private final static int item_photos = 2; + private final static int item_video = 3; + + public static String imageFilter = "*"; + + public PhotoAlbumPickerActivity(boolean singlePhoto, ChatActivity chatActivity) { super(); - singlePhoto = onlyOnePhoto; + this.chatActivity = chatActivity; + this.singlePhoto = singlePhoto; } @Override public boolean onFragmentCreate() { loading = true; + MediaController.iFilter = imageFilter; + if(!imageFilter.equals("*"))singlePhoto = true; MediaController.loadGalleryPhotosAlbums(classGuid); NotificationCenter.getInstance().addObserver(this, NotificationCenter.albumsDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.recentImagesDidLoaded); @@ -90,6 +108,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati NotificationCenter.getInstance().removeObserver(this, NotificationCenter.albumsDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recentImagesDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); + imageFilter = "*"; super.onFragmentDestroy(); } @@ -99,7 +118,6 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati actionBar.setBackgroundColor(0xff333333); actionBar.setItemsBackground(R.drawable.bar_selector_picker); actionBar.setBackButtonImage(R.drawable.ic_ab_back); - actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { @@ -115,6 +133,22 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati finishFragment(false); delegate.startPhotoSelectActivity(); } + } else if (id == item_photos) { + if (selectedMode == 0) { + return; + } + selectedMode = 0; + dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos)); + emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); + listAdapter.notifyDataSetChanged(); + } else if (id == item_video) { + if (selectedMode == 1) { + return; + } + selectedMode = 1; + dropDown.setText(LocaleController.getString("PickerVideo", R.string.PickerVideo)); + emptyView.setText(LocaleController.getString("NoVideo", R.string.NoVideo)); + listAdapter.notifyDataSetChanged(); } } }); @@ -127,6 +161,51 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(0xff000000); + if (!singlePhoto) { + selectedMode = 0; + + dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector_picker); + dropDownContainer.setSubMenuOpenSide(1); + dropDownContainer.addSubItem(item_photos, LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0); + dropDownContainer.addSubItem(item_video, LocaleController.getString("PickerVideo", R.string.PickerVideo), 0); + actionBar.addView(dropDownContainer); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); + layoutParams.height = LayoutHelper.MATCH_PARENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.rightMargin = AndroidUtilities.dp(40); + layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; + dropDownContainer.setLayoutParams(layoutParams); + dropDownContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dropDownContainer.toggleSubMenu(); + } + }); + + dropDown = new TextView(context); + dropDown.setGravity(Gravity.LEFT); + dropDown.setSingleLine(true); + dropDown.setLines(1); + dropDown.setMaxLines(1); + dropDown.setEllipsize(TextUtils.TruncateAt.END); + dropDown.setTextColor(0xffffffff); + dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0); + dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4)); + dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); + dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos)); + dropDownContainer.addView(dropDown); + layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; + layoutParams.leftMargin = AndroidUtilities.dp(16); + layoutParams.gravity = Gravity.CENTER_VERTICAL; + dropDown.setLayoutParams(layoutParams); + } else { + actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + } + listView = new ListView(context); listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4)); listView.setClipToPadding(false); @@ -139,8 +218,8 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati listView.setScrollingCacheEnabled(false); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.bottomMargin = AndroidUtilities.dp(48); listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); @@ -154,8 +233,8 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); frameLayout.addView(emptyView); layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.bottomMargin = AndroidUtilities.dp(48); emptyView.setLayoutParams(layoutParams); emptyView.setOnTouchListener(new View.OnTouchListener() { @@ -169,23 +248,23 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati progressView.setVisibility(View.GONE); frameLayout.addView(progressView); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.bottomMargin = AndroidUtilities.dp(48); progressView.setLayoutParams(layoutParams); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressView.setLayoutParams(layoutParams); photoPickerBottomLayout = new PhotoPickerBottomLayout(context); frameLayout.addView(photoPickerBottomLayout); layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(48); layoutParams.gravity = Gravity.BOTTOM; photoPickerBottomLayout.setLayoutParams(layoutParams); @@ -237,6 +316,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati int guid = (Integer) args[0]; if (classGuid == guid) { albumsSorted = (ArrayList) args[1]; + videoAlbumsSorted = (ArrayList) args[3]; if (progressView != null) { progressView.setVisibility(View.GONE); } @@ -278,12 +358,15 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati } sendPressed = true; ArrayList photos = new ArrayList<>(); + ArrayList captions = new ArrayList<>(); for (HashMap.Entry entry : selectedPhotos.entrySet()) { MediaController.PhotoEntry photoEntry = entry.getValue(); if (photoEntry.imagePath != null) { photos.add(photoEntry.imagePath); + captions.add(photoEntry.caption != null ? photoEntry.caption.toString() : null); } else if (photoEntry.path != null) { photos.add(photoEntry.path); + captions.add(photoEntry.caption != null ? photoEntry.caption.toString() : null); } } ArrayList webPhotos = new ArrayList<>(); @@ -293,6 +376,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati MediaController.SearchImage searchImage = entry.getValue(); if (searchImage.imagePath != null) { photos.add(searchImage.imagePath); + captions.add(searchImage.caption != null ? searchImage.caption.toString() : null); } else { webPhotos.add(searchImage); } @@ -325,7 +409,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati MessagesStorage.getInstance().putWebRecent(recentGifImages); } - delegate.didSelectPhotos(photos, webPhotos); + delegate.didSelectPhotos(photos, captions, webPhotos); } private void fixLayout() { @@ -348,6 +432,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati if (getParentActivity() == null) { return; } + WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); int rotation = manager.getDefaultDisplay().getRotation(); columnsCount = 2; @@ -355,6 +440,20 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati columnsCount = 4; } listAdapter.notifyDataSetChanged(); + + if (dropDownContainer != null) { + if (!AndroidUtilities.isTablet()) { + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); + layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); + dropDownContainer.setLayoutParams(layoutParams); + } + + if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + dropDown.setTextSize(18); + } else { + dropDown.setTextSize(20); + } + } } private void openPhotoPicker(MediaController.AlbumEntry albumEntry, int type) { @@ -366,7 +465,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati recentImages = recentGifImages; } } - PhotoPickerActivity fragment = new PhotoPickerActivity(type, albumEntry, selectedPhotos, selectedWebPhotos, recentImages, singlePhoto); + PhotoPickerActivity fragment = new PhotoPickerActivity(type, albumEntry, selectedPhotos, selectedWebPhotos, recentImages, singlePhoto, chatActivity); fragment.setDelegate(new PhotoPickerActivity.PhotoPickerActivityDelegate() { @Override public void selectedPhotosChanged() { @@ -382,6 +481,12 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati sendSelectedPhotos(); } } + + @Override + public boolean didSelectVideo(String path) { + removeSelfFromStack(); + return delegate.didSelectVideo(path); + } }); presentFragment(fragment); } @@ -405,10 +510,14 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati @Override public int getCount() { + if (singlePhoto || selectedMode == 0) { if (singlePhoto) { return albumsSorted != null ? (int) Math.ceil(albumsSorted.size() / (float) columnsCount) : 0; } return 1 + (albumsSorted != null ? (int) Math.ceil(albumsSorted.size() / (float) columnsCount) : 0); + } else { + return (videoAlbumsSorted != null ? (int) Math.ceil(videoAlbumsSorted.size() / (float) columnsCount) : 0); + } } @Override @@ -446,17 +555,26 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati photoPickerAlbumsCell.setAlbumsCount(columnsCount); for (int a = 0; a < columnsCount; a++) { int index; - if (singlePhoto) { + if (singlePhoto || selectedMode == 1) { index = i * columnsCount + a; } else { index = (i - 1) * columnsCount + a; } + if (singlePhoto || selectedMode == 0) { if (index < albumsSorted.size()) { MediaController.AlbumEntry albumEntry = albumsSorted.get(index); photoPickerAlbumsCell.setAlbum(a, albumEntry); } else { photoPickerAlbumsCell.setAlbum(a, null); } + } else { + if (index < videoAlbumsSorted.size()) { + MediaController.AlbumEntry albumEntry = videoAlbumsSorted.get(index); + photoPickerAlbumsCell.setAlbum(a, albumEntry); + } else { + photoPickerAlbumsCell.setAlbum(a, null); + } + } } photoPickerAlbumsCell.requestLayout(); } else if (type == 1) { @@ -475,7 +593,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati @Override public int getItemViewType(int i) { - if (singlePhoto) { + if (singlePhoto || selectedMode == 1) { return 0; } if (i == 0) { @@ -486,7 +604,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati @Override public int getViewTypeCount() { - if (singlePhoto) { + if (singlePhoto || selectedMode == 1) { return 1; } return 2; @@ -494,7 +612,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati @Override public boolean isEmpty() { - return false; + return getCount() == 0; } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java index cf6b43b1..a215bc91 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java @@ -29,6 +29,7 @@ import org.telegram.messenger.R; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Components.LayoutHelper; import java.io.File; @@ -461,7 +462,7 @@ public class PhotoCropActivity extends BaseFragment { fragmentView = view = new PhotoCropView(context); ((PhotoCropView) fragmentView).freeform = getArguments().getBoolean("freeform", false); - fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); + fragmentView.setLayoutParams(new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); return fragmentView; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java index 333a106d..bce6fd22 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -51,6 +51,7 @@ import org.telegram.messenger.BuildVars; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; +import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; @@ -59,6 +60,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.PhotoPickerPhotoCell; import org.telegram.ui.Components.BackupImageView; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PhotoPickerBottomLayout; import java.net.URLEncoder; @@ -72,6 +74,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen public interface PhotoPickerActivityDelegate { void selectedPhotosChanged(); void actionButtonPressed(boolean canceled); + boolean didSelectVideo(String path); } private RequestQueue requestQueue; @@ -102,10 +105,11 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen private int itemWidth = 100; private boolean sendPressed; private boolean singlePhoto; + private ChatActivity chatActivity; private PhotoPickerActivityDelegate delegate; - public PhotoPickerActivity(int type, MediaController.AlbumEntry selectedAlbum, HashMap selectedPhotos, HashMap selectedWebPhotos, ArrayList recentImages, boolean onlyOnePhoto) { + public PhotoPickerActivity(int type, MediaController.AlbumEntry selectedAlbum, HashMap selectedPhotos, HashMap selectedWebPhotos, ArrayList recentImages, boolean onlyOnePhoto, ChatActivity chatActivity) { super(); this.selectedAlbum = selectedAlbum; this.selectedPhotos = selectedPhotos; @@ -113,6 +117,10 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen this.type = type; this.recentImages = recentImages; this.singlePhoto = onlyOnePhoto; + this.chatActivity = chatActivity; + if (selectedAlbum != null && selectedAlbum.isVideo) { + singlePhoto = true; + } } @Override @@ -256,8 +264,8 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen listView.setSelector(R.drawable.list_selector); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48); listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); @@ -265,6 +273,14 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { + if (selectedAlbum != null && selectedAlbum.isVideo) { + if (i < 0 || i >= selectedAlbum.photos.size()) { + return; + } + if (delegate.didSelectVideo(selectedAlbum.photos.get(i).path)) { + finishFragment(); + } + } else { ArrayList arrayList = null; if (selectedAlbum != null) { arrayList = (ArrayList) selectedAlbum.photos; @@ -279,7 +295,8 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen return; } PhotoViewer.getInstance().setParentActivity(getParentActivity()); - PhotoViewer.getInstance().openPhotoForSelect(arrayList, i, singlePhoto ? 1 : 0, PhotoPickerActivity.this); + PhotoViewer.getInstance().openPhotoForSelect(arrayList, i, singlePhoto ? 1 : 0, PhotoPickerActivity.this, chatActivity); + } } }); @@ -326,8 +343,8 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } frameLayout.addView(emptyView); layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48); emptyView.setLayoutParams(layoutParams); emptyView.setOnTouchListener(new View.OnTouchListener() { @@ -362,16 +379,16 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen progressView.setVisibility(View.GONE); frameLayout.addView(progressView); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48); progressView.setLayoutParams(layoutParams); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressBar.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressBar.setLayoutParams(layoutParams); @@ -381,7 +398,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen photoPickerBottomLayout = new PhotoPickerBottomLayout(context); frameLayout.addView(photoPickerBottomLayout); layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(48); layoutParams.gravity = Gravity.BOTTOM; photoPickerBottomLayout.setLayoutParams(layoutParams); @@ -501,7 +518,11 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen cell.photoImage.setImage(photoEntry.thumbPath, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); } else if (photoEntry.path != null) { cell.photoImage.setOrientation(photoEntry.orientation, true); + if (photoEntry.isVideo) { + cell.photoImage.setImage("vthumb://" + photoEntry.imageId + ":" + photoEntry.path, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); + } else { cell.photoImage.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); + } } else { cell.photoImage.setImageResource(R.drawable.nophotos); } @@ -777,7 +798,10 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen if (nextSearchBingString != null) { url = nextSearchBingString; } else { - url = String.format(Locale.US, "https://api.datamarket.azure.com/Bing/Search/v1/Image?Query='%s'&$skip=%d&$top=%d&$format=json&Adult='Off'", URLEncoder.encode(query, "UTF-8"), offset, count); + boolean adult = false; + String phone = UserConfig.getCurrentUser().phone; + adult = phone.startsWith("44") || phone.startsWith("49") || phone.startsWith("43") || phone.startsWith("31") || phone.startsWith("1"); + url = String.format(Locale.US, "https://api.datamarket.azure.com/Bing/Search/v1/Image?Query='%s'&$skip=%d&$top=%d&$format=json%s", URLEncoder.encode(query, "UTF-8"), offset, count, adult ? "" : "&Adult='Off'"); } JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener() { @@ -1028,7 +1052,11 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen imageView.setImage(photoEntry.thumbPath, null, mContext.getResources().getDrawable(R.drawable.nophotos)); } else if (photoEntry.path != null) { imageView.setOrientation(photoEntry.orientation, true); + if (photoEntry.isVideo) { + imageView.setImage("vthumb://" + photoEntry.imageId + ":" + photoEntry.path, null, mContext.getResources().getDrawable(R.drawable.nophotos)); + } else { imageView.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, mContext.getResources().getDrawable(R.drawable.nophotos)); + } } else { imageView.setImageResource(R.drawable.nophotos); } @@ -1051,7 +1079,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen cell.checkBox.setChecked(selectedWebPhotos.containsKey(photoEntry.id), false); showing = PhotoViewer.getInstance().isShowingImage(photoEntry.thumbUrl); } - imageView.getImageReceiver().setVisible(!showing, false); + imageView.getImageReceiver().setVisible(!showing, true); cell.checkBox.setVisibility(singlePhoto || showing ? View.GONE : View.VISIBLE); } else if (viewType == 1) { if (view == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 79bd4d4c..cab90f99 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -30,51 +30,58 @@ import android.text.TextUtils; import android.util.TypedValue; import android.view.GestureDetector; import android.view.Gravity; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.Surface; import android.view.VelocityTracker; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.animation.DecelerateInterpolator; +import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.ListView; +import android.widget.RelativeLayout; import android.widget.Scroller; import android.widget.TextView; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.android.AnimationCompat.AnimatorSetProxy; +import org.telegram.android.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.ContactsController; import org.telegram.android.ImageLoader; +import org.telegram.android.ImageReceiver; +import org.telegram.android.LocaleController; +import org.telegram.android.MediaController; +import org.telegram.android.MessageObject; +import org.telegram.android.MessagesController; import org.telegram.android.MessagesStorage; +import org.telegram.android.NotificationCenter; import org.telegram.android.query.SharedMediaQuery; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; -import org.telegram.android.LocaleController; -import org.telegram.android.MediaController; -import org.telegram.android.MessagesController; -import org.telegram.android.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; -import org.telegram.android.MessageObject; import org.telegram.messenger.Utilities; -import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy; -import org.telegram.ui.AnimationCompat.AnimatorSetProxy; -import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; +import org.telegram.ui.Adapters.MentionsAdapter; import org.telegram.ui.Components.CheckBox; import org.telegram.ui.Components.ClippingImageView; -import org.telegram.android.ImageReceiver; import org.telegram.ui.Components.GifDrawable; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PhotoCropView; import org.telegram.ui.Components.PhotoFilterView; import org.telegram.ui.Components.PhotoPickerBottomLayout; +import org.telegram.ui.Components.PhotoViewerCaptionEnterView; +import org.telegram.ui.Components.SizeNotifierRelativeLayoutPhoto; import java.io.File; import java.lang.ref.WeakReference; @@ -88,14 +95,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private int classGuid; private PhotoViewerProvider placeProvider; - private boolean isVisible = false; + private boolean isVisible; private Activity parentActivity; private ActionBar actionBar; private boolean isActionBarVisible = true; - private static Drawable[] progressDrawables = null; + private static Drawable[] progressDrawables; private WindowManager.LayoutParams windowLayoutParams; private FrameLayoutDrawer containerView; @@ -106,7 +113,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private TextView dateTextView; private ActionBarMenuItem menuItem; private ImageView shareButton; - private ColorDrawable backgroundDrawable = new ColorDrawable(0xff000000); + private BackgroundDrawable backgroundDrawable = new BackgroundDrawable(0xff000000); private CheckBox checkImageView; private PhotoPickerBottomLayout pickerView; private PhotoPickerBottomLayout editorDoneLayout; @@ -114,12 +121,27 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private GifDrawable gifDrawable; private ActionBarMenuItem cropItem; private ActionBarMenuItem tuneItem; + private ActionBarMenuItem captionItem; + private ActionBarMenuItem captionDoneItem; private AnimatorSetProxy currentActionBarAnimation; private PhotoCropView photoCropView; private PhotoFilterView photoFilterView; - private AlertDialog visibleDialog = null; + private AlertDialog visibleDialog; + private TextView captionTextView; + private TextView captionTextViewOld; + private TextView captionTextViewNew; + private PhotoViewerCaptionEnterView captionEditText; private boolean canShowBottom = true; private int sendPhotoType = 0; + private boolean needCaptionLayout; + + private float animationValues[][] = new float[2][8]; + + private ChatActivity parentChatActivity; + private MentionsAdapter mentionsAdapter; + private ListView mentionListView; + private AnimatorSetProxy mentionListAnimation; + private boolean allowMentions; private int animationInProgress = 0; private long transitionAnimationStartTime = 0; @@ -128,6 +150,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private PlaceProviderObject hideAfterAnimation; private boolean disableShowCheck = false; + private String lastTitle; + private int currentEditMode; private ImageReceiver leftImage = new ImageReceiver(); @@ -161,6 +185,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private float animationValue; private long animationStartTime; private AnimatorSetProxy imageMoveAnimation; + private AnimatorSetProxy changeModeAnimation; private GestureDetector gestureDetector; private DecelerateInterpolator interpolator = new DecelerateInterpolator(1.5f); private float pinchStartDistance = 0; @@ -204,10 +229,43 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private final static int gallery_menu_crop = 4; private final static int gallery_menu_delete = 6; private final static int gallery_menu_tune = 7; + private final static int gallery_menu_caption = 8; + private final static int gallery_menu_caption_done = 9; private final static int PAGE_SPACING = AndroidUtilities.dp(30); - private static class RadialProgressView { + private static DecelerateInterpolator decelerateInterpolator = null; + private static Paint progressPaint = null; + + private class BackgroundDrawable extends ColorDrawable { + + private Runnable drawRunnable; + + public BackgroundDrawable(int color) { + super(color); + } + + @Override + public void setAlpha(int alpha) { + if (parentActivity instanceof LaunchActivity) { + ((LaunchActivity) parentActivity).drawerLayoutContainer.setAllowDrawContent(!isVisible || alpha != 255); + } + super.setAlpha(alpha); + } + + @Override + public void draw(Canvas canvas) { + super.draw(canvas); + if (getAlpha() != 0) { + if (drawRunnable != null) { + drawRunnable.run(); + drawRunnable = null; + } + } + } + } + + private class RadialProgressView { private long lastUpdateTime = 0; private float radOffset = 0; @@ -224,9 +282,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private float alpha = 1.0f; private float scale = 1.0f; - private static DecelerateInterpolator decelerateInterpolator = null; - private static Paint progressPaint = null; - public RadialProgressView(Context context, View parentView) { if (decelerateInterpolator == null) { decelerateInterpolator = new DecelerateInterpolator(1.5f); @@ -302,8 +357,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public void onDraw(Canvas canvas) { int sizeScaled = (int) (size * scale); - int x = (canvas.getWidth() - sizeScaled) / 2; - int y = (canvas.getHeight() - sizeScaled) / 2; + int x = (getContainerViewWidth() - sizeScaled) / 2; + int y = (getContainerViewHeight() - sizeScaled) / 2; if (previousBackgroundState >= 0 && previousBackgroundState < 4) { Drawable drawable = progressDrawables[previousBackgroundState]; @@ -428,6 +483,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } private class FrameLayoutTouchListener extends FrameLayout { + + private boolean attachedToWindow; + private Runnable attachRunnable; + public FrameLayoutTouchListener(Context context) { super(context); } @@ -442,9 +501,21 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat super.onLayout(changed, left, top, right, bottom); getInstance().onLayout(changed, left, top, right, bottom); } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + attachedToWindow = true; + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + attachedToWindow = false; + } } - private class FrameLayoutDrawer extends FrameLayout { + private class FrameLayoutDrawer extends SizeNotifierRelativeLayoutPhoto { public FrameLayoutDrawer(Context context) { super(context); setWillNotDraw(false); @@ -454,6 +525,27 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat protected void onDraw(Canvas canvas) { getInstance().onDraw(canvas); } + + @Override + protected boolean drawChild(Canvas canvas, View child, long drawingTime) { + if ((child == captionEditText || child == pickerView || child == captionTextView || child == mentionListView)) { + int state = captionEditText.getKeyboardTransitionState(); + if (!(state == 0 || state == 1 || state == 2)) { + if (child == captionTextView) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (captionTextView != null) { + captionTextView.invalidate(); + } + } + }, 50); + } + return false; + } + } + return super.drawChild(canvas, child, drawingTime); + } } private static volatile PhotoViewer Instance = null; @@ -668,10 +760,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } } + } else if (id == NotificationCenter.emojiDidLoaded) { + if (captionTextView != null) { + captionTextView.invalidate(); + } } } - public void setParentActivity(Activity activity) { + public void setParentActivity(final Activity activity) { if (parentActivity == activity) { return; } @@ -687,21 +783,30 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat scroller = new Scroller(activity); - windowView = new FrameLayoutTouchListener(activity); + windowView = new FrameLayoutTouchListener(activity) { + @Override + public boolean dispatchKeyEventPreIme(KeyEvent event) { + if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { + if (captionEditText.isEmojiPopupShowing() || captionEditText.isKeyboardVisible()) { + closeCaptionEnter(false); + return false; + } + PhotoViewer.getInstance().closePhoto(true, false); + return true; + } + return super.dispatchKeyEventPreIme(event); + } + }; windowView.setBackgroundDrawable(backgroundDrawable); windowView.setFocusable(false); - animatingImageView = new ClippingImageView(windowView.getContext()); - windowView.addView(animatingImageView); + animatingImageView = new ClippingImageView(activity); + animatingImageView.setAnimationValues(animationValues); + windowView.addView(animatingImageView, LayoutHelper.createFrame(40, 40)); containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); - windowView.addView(containerView); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - containerView.setLayoutParams(layoutParams); + windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; @@ -717,15 +822,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat actionBar.setItemsBackground(R.drawable.bar_selector_white); actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); - containerView.addView(actionBar); - layoutParams = (FrameLayout.LayoutParams) actionBar.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - actionBar.setLayoutParams(layoutParams); + containerView.addView(actionBar, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { + if (needCaptionLayout && (captionEditText.isEmojiPopupShowing() || captionEditText.isKeyboardVisible())) { + closeCaptionEnter(false); + return; + } closePhoto(true, false); } else if (id == gallery_menu_save) { File f = null; @@ -875,6 +981,22 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showAlertDialog(builder); + } else if (id == gallery_menu_caption) { + if (imageMoveAnimation != null || changeModeAnimation != null) { + return; + } + cropItem.setVisibility(View.GONE); + tuneItem.setVisibility(View.GONE); + captionItem.setVisibility(View.GONE); + checkImageView.setVisibility(View.GONE); + captionDoneItem.setVisibility(View.VISIBLE); + pickerView.setVisibility(View.GONE); + captionTextView.setVisibility(View.INVISIBLE); + captionEditText.openKeyboard(); + lastTitle = actionBar.getTitle(); + actionBar.setTitle(LocaleController.getString("PhotoCaption", R.string.PhotoCaption)); + } else if (id == gallery_menu_caption_done) { + closeCaptionEnter(true); } } @@ -903,17 +1025,36 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat menuItem.addSubItem(gallery_menu_save, LocaleController.getString("SaveToGallery", R.string.SaveToGallery), 0); menuItem.addSubItem(gallery_menu_delete, LocaleController.getString("Delete", R.string.Delete), 0); + captionDoneItem = menu.addItemWithWidth(gallery_menu_caption_done, R.drawable.ic_done, AndroidUtilities.dp(56)); + captionItem = menu.addItemWithWidth(gallery_menu_caption, R.drawable.photo_text, AndroidUtilities.dp(56)); cropItem = menu.addItemWithWidth(gallery_menu_crop, R.drawable.photo_crop, AndroidUtilities.dp(56)); - tuneItem = menu.addItemWithWidth(gallery_menu_tune, R.drawable.tune, AndroidUtilities.dp(56)); + tuneItem = menu.addItemWithWidth(gallery_menu_tune, R.drawable.photo_tools, AndroidUtilities.dp(56)); - bottomLayout = new FrameLayout(containerView.getContext()); - containerView.addView(bottomLayout); - layoutParams = (FrameLayout.LayoutParams) bottomLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = AndroidUtilities.dp(48); - layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; - bottomLayout.setLayoutParams(layoutParams); + bottomLayout = new FrameLayout(parentActivity); bottomLayout.setBackgroundColor(0x7f000000); + containerView.addView(bottomLayout, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM)); + + captionTextViewOld = new TextView(parentActivity); + captionTextViewOld.setMaxLines(10); + captionTextViewOld.setBackgroundColor(0x7f000000); + captionTextViewOld.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(8), AndroidUtilities.dp(16), AndroidUtilities.dp(8)); + captionTextViewOld.setLinkTextColor(0xffffffff); + captionTextViewOld.setTextColor(0xffffffff); + captionTextViewOld.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); + captionTextViewOld.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + captionTextViewOld.setVisibility(View.INVISIBLE); + containerView.addView(captionTextViewOld, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 48, RelativeLayout.ALIGN_PARENT_BOTTOM)); + + captionTextView = captionTextViewNew = new TextView(parentActivity); + captionTextViewNew.setMaxLines(10); + captionTextViewNew.setBackgroundColor(0x7f000000); + captionTextViewNew.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(8), AndroidUtilities.dp(16), AndroidUtilities.dp(8)); + captionTextViewNew.setLinkTextColor(0xffffffff); + captionTextViewNew.setTextColor(0xffffffff); + captionTextViewNew.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); + captionTextViewNew.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + captionTextViewNew.setVisibility(View.INVISIBLE); + containerView.addView(captionTextViewNew, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 48, RelativeLayout.ALIGN_PARENT_BOTTOM)); radialProgressViews[0] = new RadialProgressView(containerView.getContext(), containerView); radialProgressViews[0].setBackgroundState(0, false); @@ -926,12 +1067,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat shareButton.setImageResource(R.drawable.share); shareButton.setScaleType(ImageView.ScaleType.CENTER); shareButton.setBackgroundResource(R.drawable.bar_selector_white); - bottomLayout.addView(shareButton); - layoutParams = (FrameLayout.LayoutParams) shareButton.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(50); - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.gravity = Gravity.TOP | Gravity.RIGHT; - shareButton.setLayoutParams(layoutParams); + bottomLayout.addView(shareButton, LayoutHelper.createFrame(50, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT)); shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -978,15 +1114,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat nameTextView.setEllipsize(TextUtils.TruncateAt.END); nameTextView.setTextColor(0xffffffff); nameTextView.setGravity(Gravity.LEFT); - bottomLayout.addView(nameTextView); - layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - layoutParams.leftMargin = AndroidUtilities.dp(16); - layoutParams.rightMargin = AndroidUtilities.dp(50); - layoutParams.topMargin = AndroidUtilities.dp(5); - nameTextView.setLayoutParams(layoutParams); + bottomLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 16, 5, 60, 0)); dateTextView = new TextView(containerView.getContext()); dateTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); @@ -996,24 +1124,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat dateTextView.setTextColor(0xffffffff); dateTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); dateTextView.setGravity(Gravity.LEFT); - bottomLayout.addView(dateTextView); - layoutParams = (FrameLayout.LayoutParams) dateTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - layoutParams.leftMargin = AndroidUtilities.dp(16); - layoutParams.rightMargin = AndroidUtilities.dp(50); - layoutParams.topMargin = AndroidUtilities.dp(25); - dateTextView.setLayoutParams(layoutParams); + bottomLayout.addView(dateTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 16, 25, 50, 0)); pickerView = new PhotoPickerBottomLayout(parentActivity); pickerView.setBackgroundColor(0x7f000000); - containerView.addView(pickerView); - layoutParams = (FrameLayout.LayoutParams) pickerView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = AndroidUtilities.dp(48); - layoutParams.gravity = Gravity.BOTTOM; - pickerView.setLayoutParams(layoutParams); + containerView.addView(pickerView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM)); pickerView.cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -1037,12 +1152,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat editorDoneLayout.setBackgroundColor(0x7f000000); editorDoneLayout.updateSelectedCount(0, false); editorDoneLayout.setVisibility(View.GONE); - containerView.addView(editorDoneLayout); - layoutParams = (FrameLayout.LayoutParams) editorDoneLayout.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = AndroidUtilities.dp(48); - layoutParams.gravity = Gravity.BOTTOM; - editorDoneLayout.setLayoutParams(layoutParams); + containerView.addView(editorDoneLayout, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM)); editorDoneLayout.cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -1057,6 +1167,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public void onClick(View view) { if (currentEditMode == 1) { photoCropView.cancelAnimationRunnable(); + if (imageMoveAnimation != null) { + return; + } } applyCurrentEditMode(); switchToEditMode(0); @@ -1067,29 +1180,22 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat gestureDetector.setOnDoubleTapListener(this); centerImage.setParentView(containerView); + centerImage.setCrossfadeAlpha((byte) 2); leftImage.setParentView(containerView); + leftImage.setCrossfadeAlpha((byte) 2); rightImage.setParentView(containerView); + rightImage.setCrossfadeAlpha((byte) 2); + + WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); + int rotation = manager.getDefaultDisplay().getRotation(); checkImageView = new CheckBox(containerView.getContext(), R.drawable.selectphoto_large); checkImageView.setDrawBackground(true); checkImageView.setSize(45); checkImageView.setCheckOffset(AndroidUtilities.dp(1)); checkImageView.setColor(0xff3ccaef); - containerView.addView(checkImageView); checkImageView.setVisibility(View.GONE); - layoutParams = (FrameLayout.LayoutParams) checkImageView.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(45); - layoutParams.height = AndroidUtilities.dp(45); - layoutParams.gravity = Gravity.RIGHT; - layoutParams.rightMargin = AndroidUtilities.dp(10); - WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); - int rotation = manager.getDefaultDisplay().getRotation(); - if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { - layoutParams.topMargin = AndroidUtilities.dp(58); - } else { - layoutParams.topMargin = AndroidUtilities.dp(68); - } - checkImageView.setLayoutParams(layoutParams); + containerView.addView(checkImageView, LayoutHelper.createRelative(45, 45, 0, rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90 ? 58 : 68, 10, 0, RelativeLayout.ALIGN_PARENT_RIGHT)); checkImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1100,6 +1206,220 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } }); + + captionEditText = new PhotoViewerCaptionEnterView(parentActivity, windowView, containerView); + captionEditText.setId(1000); + captionEditText.setDelegate(new PhotoViewerCaptionEnterView.PhotoViewerCaptionEnterViewDelegate() { + @Override + public void onCaptionEnter() { + closeCaptionEnter(true); + } + + @Override + public void onTextChanged(CharSequence text, boolean bigChange) { + if (mentionsAdapter != null && captionEditText != null && parentChatActivity != null && text != null) { + mentionsAdapter.searchUsernameOrHashtag(text.toString(), captionEditText.getCursorPosition(), parentChatActivity.messages); + } + } + + @Override + public void onWindowSizeChanged(int size) { + int height = AndroidUtilities.dp(36 * Math.min(3, mentionsAdapter.getCount()) + (mentionsAdapter.getCount() > 3 ? 18 : 0)); + if (size - AndroidUtilities.getCurrentActionBarHeight() * 2 < height) { + allowMentions = false; + if (mentionListView != null && mentionListView.getVisibility() == View.VISIBLE) { + mentionListView.clearAnimation(); + mentionListView.setVisibility(View.INVISIBLE); + } + } else { + allowMentions = true; + if (mentionListView != null && mentionListView.getVisibility() == View.INVISIBLE) { + mentionListView.clearAnimation(); + mentionListView.setVisibility(View.VISIBLE); + } + } + } + }); + containerView.addView(captionEditText, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, -400, RelativeLayout.ALIGN_PARENT_BOTTOM)); + + mentionListView = new ListView(parentActivity); + mentionListView.setBackgroundColor(0x7f000000); + mentionListView.setVisibility(View.GONE); + mentionListView.setClipToPadding(true); + mentionListView.setDividerHeight(0); + mentionListView.setDivider(null); + if (Build.VERSION.SDK_INT > 8) { + mentionListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); + } + containerView.addView(mentionListView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 110, 0, -110, 0, 0, RelativeLayout.ALIGN_TOP, 1000)); + + mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(parentActivity, true, new MentionsAdapter.MentionsAdapterDelegate() { + @Override + public void needChangePanelVisibility(boolean show) { + if (show) { + RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) mentionListView.getLayoutParams(); + int height = 36 * Math.min(3, mentionsAdapter.getCount()) + (mentionsAdapter.getCount() > 3 ? 18 : 0); + layoutParams3.height = AndroidUtilities.dp(height); + layoutParams3.topMargin = -AndroidUtilities.dp(height); + mentionListView.setLayoutParams(layoutParams3); + + if (mentionListAnimation != null) { + mentionListAnimation.cancel(); + mentionListAnimation = null; + } + + if (mentionListView.getVisibility() == View.VISIBLE) { + ViewProxy.setAlpha(mentionListView, 1.0f); + return; + } + if (allowMentions) { + mentionListView.setVisibility(View.VISIBLE); + mentionListAnimation = new AnimatorSetProxy(); + mentionListAnimation.playTogether( + ObjectAnimatorProxy.ofFloat(mentionListView, "alpha", 0.0f, 1.0f) + ); + mentionListAnimation.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { + mentionListView.clearAnimation(); + mentionListAnimation = null; + } + } + }); + mentionListAnimation.setDuration(200); + mentionListAnimation.start(); + } else { + ViewProxy.setAlpha(mentionListView, 1.0f); + mentionListView.clearAnimation(); + mentionListView.setVisibility(View.INVISIBLE); + } + } else { + if (mentionListAnimation != null) { + mentionListAnimation.cancel(); + mentionListAnimation = null; + } + + if (mentionListView.getVisibility() == View.GONE) { + return; + } + if (allowMentions) { + mentionListAnimation = new AnimatorSetProxy(); + mentionListAnimation.playTogether( + ObjectAnimatorProxy.ofFloat(mentionListView, "alpha", 0.0f) + ); + mentionListAnimation.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { + mentionListView.clearAnimation(); + mentionListView.setVisibility(View.GONE); + mentionListAnimation = null; + } + } + }); + mentionListAnimation.setDuration(200); + mentionListAnimation.start(); + } else { + mentionListView.clearAnimation(); + mentionListView.setVisibility(View.GONE); + } + } + } + })); + + mentionListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + Object object = mentionsAdapter.getItem(position); + int start = mentionsAdapter.getResultStartPosition(); + int len = mentionsAdapter.getResultLength(); + if (object instanceof TLRPC.User) { + TLRPC.User user = (TLRPC.User) object; + if (user != null) { + captionEditText.replaceWithText(start, len, "@" + user.username + " "); + } + } else if (object instanceof String) { + captionEditText.replaceWithText(start, len, object + " "); + } + } + }); + + mentionListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { + @Override + public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + Object object = mentionsAdapter.getItem(position); + if (object instanceof String) { + AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setMessage(LocaleController.getString("ClearSearch", R.string.ClearSearch)); + builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + mentionsAdapter.clearRecentHashtags(); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showAlertDialog(builder); + return true; + } + return false; + } + }); + } + + private void updateCaptionTextForCurrentPhoto(Object object) { + CharSequence caption = null; + if (object instanceof MediaController.PhotoEntry) { + caption = ((MediaController.PhotoEntry) object).caption; + } else if (object instanceof MediaController.SearchImage) { + caption = ((MediaController.SearchImage) object).caption; + } + if (caption == null || caption.length() == 0) { + captionEditText.setFieldText(""); + } else { + captionEditText.setFieldText(caption); + } + } + + private void closeCaptionEnter(boolean apply) { + Object object = imagesArrLocals.get(currentIndex); + if (apply) { + if (object instanceof MediaController.PhotoEntry) { + ((MediaController.PhotoEntry) object).caption = captionEditText.getFieldCharSequence(); + } else if (object instanceof MediaController.SearchImage) { + ((MediaController.SearchImage) object).caption = captionEditText.getFieldCharSequence(); + } + + if (captionEditText.getFieldCharSequence().length() != 0 && !placeProvider.isPhotoChecked(currentIndex)) { + placeProvider.setPhotoChecked(currentIndex); + checkImageView.setChecked(placeProvider.isPhotoChecked(currentIndex), true); + updateSelectedCount(); + } + } + cropItem.setVisibility(View.VISIBLE); + captionItem.setVisibility(View.VISIBLE); + if (Build.VERSION.SDK_INT >= 16) { + tuneItem.setVisibility(View.VISIBLE); + } + if (sendPhotoType == 0) { + checkImageView.setVisibility(View.VISIBLE); + } + captionDoneItem.setVisibility(View.GONE); + pickerView.setVisibility(View.VISIBLE); + + if (lastTitle != null) { + actionBar.setTitle(lastTitle); + lastTitle = null; + } + + updateCaptionTextForCurrentPhoto(object); + setCurrentCaption(captionEditText.getFieldCharSequence()); + if (captionEditText.isEmojiPopupShowing()) { + captionEditText.hideEmojiPopup(); + } else { + captionEditText.closeKeyboard(); + } } private void showAlertDialog(AlertDialog.Builder builder) { @@ -1179,7 +1499,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } private void switchToEditMode(final int mode) { - if (currentEditMode == mode || centerImage.getBitmap() == null || imageMoveAnimation != null || radialProgressViews[0].backgroundState != -1) { + if (currentEditMode == mode || centerImage.getBitmap() == null || changeModeAnimation != null || imageMoveAnimation != null || radialProgressViews[0].backgroundState != -1) { return; } if (mode == 0) { @@ -1255,6 +1575,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ArrayList arrayList = new ArrayList<>(); arrayList.add(ObjectAnimatorProxy.ofFloat(pickerView, "translationY", 0)); arrayList.add(ObjectAnimatorProxy.ofFloat(actionBar, "translationY", 0)); + if (needCaptionLayout) { + arrayList.add(ObjectAnimatorProxy.ofFloat(captionTextView, "translationY", 0)); + } if (sendPhotoType == 0) { arrayList.add(ObjectAnimatorProxy.ofFloat(checkImageView, "alpha", 1)); } @@ -1265,6 +1588,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public void onAnimationStart(Object animation) { pickerView.setVisibility(View.VISIBLE); actionBar.setVisibility(View.VISIBLE); + if (needCaptionLayout) { + captionTextView.setVisibility(captionTextView.getTag() != null ? View.VISIBLE : View.INVISIBLE); + } if (sendPhotoType == 0) { checkImageView.setVisibility(View.VISIBLE); } @@ -1274,6 +1600,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public void onAnimationEnd(Object animation) { pickerView.clearAnimation(); actionBar.clearAnimation(); + if (needCaptionLayout) { + captionTextView.clearAnimation(); + } if (sendPhotoType == 0) { checkImageView.clearAnimation(); } @@ -1287,12 +1616,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (photoCropView == null) { photoCropView = new PhotoCropView(parentActivity); photoCropView.setVisibility(View.GONE); - containerView.addView(photoCropView); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) photoCropView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.bottomMargin = AndroidUtilities.dp(48); - photoCropView.setLayoutParams(layoutParams); + containerView.addView(photoCropView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 0, 48)); photoCropView.setDelegate(new PhotoCropView.PhotoCropViewDelegate() { @Override public void needMoveImageTo(float x, float y, float s, boolean animated) { @@ -1309,22 +1633,30 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } editorDoneLayout.doneButtonTextView.setText(LocaleController.getString("Crop", R.string.Crop)); - AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + changeModeAnimation = new AnimatorSetProxy(); ArrayList arrayList = new ArrayList<>(); - arrayList.add(ObjectAnimatorProxy.ofFloat(pickerView, "translationY", 0, AndroidUtilities.dp(48))); + arrayList.add(ObjectAnimatorProxy.ofFloat(pickerView, "translationY", 0, AndroidUtilities.dp(96))); arrayList.add(ObjectAnimatorProxy.ofFloat(actionBar, "translationY", 0, -actionBar.getHeight())); + if (needCaptionLayout) { + arrayList.add(ObjectAnimatorProxy.ofFloat(captionTextView, "translationY", 0, AndroidUtilities.dp(96))); + } if (sendPhotoType == 0) { arrayList.add(ObjectAnimatorProxy.ofFloat(checkImageView, "alpha", 1, 0)); } - animatorSet.playTogether(arrayList); - animatorSet.setDuration(200); - animatorSet.addListener(new AnimatorListenerAdapterProxy() { + changeModeAnimation.playTogether(arrayList); + changeModeAnimation.setDuration(200); + changeModeAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { + changeModeAnimation = null; pickerView.clearAnimation(); actionBar.clearAnimation(); pickerView.setVisibility(View.GONE); actionBar.setVisibility(View.GONE); + if (needCaptionLayout) { + captionTextView.clearAnimation(); + captionTextView.setVisibility(View.INVISIBLE); + } if (sendPhotoType == 0) { checkImageView.clearAnimation(); checkImageView.setVisibility(View.GONE); @@ -1383,15 +1715,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat imageMoveAnimation.start(); } }); - animatorSet.start(); + changeModeAnimation.start(); } else if (mode == 2) { if (photoFilterView == null) { photoFilterView = new PhotoFilterView(parentActivity, centerImage.getBitmap(), centerImage.getOrientation()); - containerView.addView(photoFilterView); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) photoFilterView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; - photoFilterView.setLayoutParams(layoutParams); + containerView.addView(photoFilterView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); photoFilterView.getDoneTextView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1426,22 +1754,30 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ViewProxy.setTranslationY(photoFilterView.getToolsView(), AndroidUtilities.dp(126)); } - AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + changeModeAnimation = new AnimatorSetProxy(); ArrayList arrayList = new ArrayList<>(); - arrayList.add(ObjectAnimatorProxy.ofFloat(pickerView, "translationY", 0, AndroidUtilities.dp(48))); + arrayList.add(ObjectAnimatorProxy.ofFloat(pickerView, "translationY", 0, AndroidUtilities.dp(96))); arrayList.add(ObjectAnimatorProxy.ofFloat(actionBar, "translationY", 0, -actionBar.getHeight())); + if (needCaptionLayout) { + arrayList.add(ObjectAnimatorProxy.ofFloat(captionTextView, "translationY", 0, AndroidUtilities.dp(96))); + } if (sendPhotoType == 0) { arrayList.add(ObjectAnimatorProxy.ofFloat(checkImageView, "alpha", 1, 0)); } - animatorSet.playTogether(arrayList); - animatorSet.setDuration(200); - animatorSet.addListener(new AnimatorListenerAdapterProxy() { + changeModeAnimation.playTogether(arrayList); + changeModeAnimation.setDuration(200); + changeModeAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { + changeModeAnimation = null; pickerView.clearAnimation(); actionBar.clearAnimation(); pickerView.setVisibility(View.GONE); actionBar.setVisibility(View.GONE); + if (needCaptionLayout) { + captionTextView.clearAnimation(); + captionTextView.setVisibility(View.INVISIBLE); + } if (sendPhotoType == 0) { checkImageView.clearAnimation(); checkImageView.setVisibility(View.GONE); @@ -1497,28 +1833,17 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat imageMoveAnimation.start(); } }); - animatorSet.start(); + changeModeAnimation.start(); } - /*Bundle args = new Bundle(); - Bitmap bitmap = centerImage.getBitmap(); - String key = centerImage.getKey(); - if (bitmap == null) { - args.putString("photoPath", currentPathObject); - } - MediaController.PhotoEntry object = - args.putInt("id", object.imageId); - args.putBoolean("freeformCrop", true); - args.putBoolean("onlyCrop", true); - PhotoEditorActivity fragment = new PhotoEditorActivity(args, bitmap, key); - fragment.setDelegate((PhotoCropActivity.PhotoEditActivityDelegate) placeProvider); - ((LaunchActivity) parentActivity).presentFragment(fragment, false, true); - closePhoto(false);*/ } private void toggleCheckImageView(boolean show) { AnimatorSetProxy animatorSet = new AnimatorSetProxy(); ArrayList arrayList = new ArrayList<>(); arrayList.add(ObjectAnimatorProxy.ofFloat(pickerView, "alpha", show ? 1.0f : 0.0f)); + if (needCaptionLayout) { + arrayList.add(ObjectAnimatorProxy.ofFloat(captionTextView, "alpha", show ? 1.0f : 0.0f)); + } if (sendPhotoType == 0) { arrayList.add(ObjectAnimatorProxy.ofFloat(checkImageView, "alpha", show ? 1.0f : 0.0f)); } @@ -1532,6 +1857,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat actionBar.setVisibility(View.VISIBLE); if (canShowBottom) { bottomLayout.setVisibility(View.VISIBLE); + if (captionTextView.getTag() != null) { + captionTextView.setVisibility(View.VISIBLE); + } } } isActionBarVisible = show; @@ -1539,11 +1867,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat bottomLayout.setEnabled(show); if (animated) { + ArrayList arrayList = new ArrayList<>(); + arrayList.add(ObjectAnimatorProxy.ofFloat(actionBar, "alpha", show ? 1.0f : 0.0f)); + arrayList.add(ObjectAnimatorProxy.ofFloat(bottomLayout, "alpha", show ? 1.0f : 0.0f)); + if (captionTextView.getTag() != null) { + arrayList.add(ObjectAnimatorProxy.ofFloat(captionTextView, "alpha", show ? 1.0f : 0.0f)); + } currentActionBarAnimation = new AnimatorSetProxy(); - currentActionBarAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(actionBar, "alpha", show ? 1.0f : 0.0f), - ObjectAnimatorProxy.ofFloat(bottomLayout, "alpha", show ? 1.0f : 0.0f) - ); + currentActionBarAnimation.playTogether(arrayList); if (!show) { currentActionBarAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override @@ -1553,6 +1884,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (canShowBottom) { bottomLayout.clearAnimation(); bottomLayout.setVisibility(View.GONE); + if (captionTextView.getTag() != null) { + captionTextView.clearAnimation(); + captionTextView.setVisibility(View.INVISIBLE); + } } currentActionBarAnimation = null; } @@ -1565,11 +1900,18 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else { ViewProxy.setAlpha(actionBar, show ? 1.0f : 0.0f); ViewProxy.setAlpha(bottomLayout, show ? 1.0f : 0.0f); + if (captionTextView.getTag() != null) { + ViewProxy.setAlpha(captionTextView, show ? 1.0f : 0.0f); + } if (!show) { actionBar.setVisibility(View.GONE); if (canShowBottom) { bottomLayout.clearAnimation(); bottomLayout.setVisibility(View.GONE); + if (captionTextView.getTag() != null) { + captionTextView.clearAnimation(); + captionTextView.setVisibility(View.INVISIBLE); + } } } } @@ -1756,6 +2098,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat loadingMoreImages = false; cacheEndReached = false; opennedFromMedia = false; + needCaptionLayout = false; canShowBottom = true; imagesArr.clear(); imagesArrLocations.clear(); @@ -1766,6 +2109,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat imagesArrTemp.clear(); imagesByIdsTemp.clear(); currentUserAvatarLocation = null; + containerView.setPadding(0, 0, 0, 0); currentThumb = object != null ? object.thumb : null; menuItem.setVisibility(View.VISIBLE); bottomLayout.setVisibility(View.VISIBLE); @@ -1782,7 +2126,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat pickerView.setVisibility(View.GONE); cropItem.setVisibility(View.GONE); tuneItem.setVisibility(View.GONE); + captionItem.setVisibility(View.GONE); + captionDoneItem.setVisibility(View.GONE); + captionEditText.clearAnimation(); + captionEditText.setVisibility(View.GONE); + mentionListView.setVisibility(View.GONE); editorDoneLayout.setVisibility(View.GONE); + captionTextView.setTag(null); + captionTextView.setVisibility(View.INVISIBLE); if (photoCropView != null) { photoCropView.clearAnimation(); photoCropView.setVisibility(View.GONE); @@ -1874,6 +2225,19 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat canShowBottom = false; Object obj = imagesArrLocals.get(index); cropItem.setVisibility(obj instanceof MediaController.PhotoEntry || obj instanceof MediaController.SearchImage && ((MediaController.SearchImage) obj).type == 0 ? View.VISIBLE : View.GONE); + if (parentChatActivity != null && parentChatActivity.currentEncryptedChat == null) { + mentionsAdapter.setChatInfo(parentChatActivity.info); + mentionsAdapter.setNeedUsernames(parentChatActivity.currentChat != null); + captionItem.setVisibility(cropItem.getVisibility()); + captionEditText.setVisibility(cropItem.getVisibility()); + needCaptionLayout = captionItem.getVisibility() == View.VISIBLE; + if (needCaptionLayout) { + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) captionEditText.getLayoutParams(); + layoutParams.bottomMargin = -AndroidUtilities.dp(400); + captionEditText.setLayoutParams(layoutParams); + captionEditText.onCreate(); + } + } if (Build.VERSION.SDK_INT >= 16) { tuneItem.setVisibility(cropItem.getVisibility()); } @@ -1931,6 +2295,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else { dateTextView.setText(dateString); } + CharSequence caption = currentMessageObject.caption; + setCurrentCaption(caption); if (totalImagesCount != 0 && !needSearchImageInArr) { if (opennedFromMedia) { @@ -1983,11 +2349,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return; } boolean fromCamera = false; + CharSequence caption = null; if (object instanceof MediaController.PhotoEntry) { currentPathObject = ((MediaController.PhotoEntry) object).path; fromCamera = ((MediaController.PhotoEntry) object).bucketId == 0 && ((MediaController.PhotoEntry) object).dateTaken == 0 && imagesArrLocals.size() == 1; + caption = ((MediaController.PhotoEntry) object).caption; } else if (object instanceof MediaController.SearchImage) { currentPathObject = ((MediaController.SearchImage) object).imageUrl; + caption = ((MediaController.SearchImage) object).caption; } if (fromCamera) { actionBar.setTitle(LocaleController.getString("AttachPhoto", R.string.AttachPhoto)); @@ -1997,6 +2366,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (sendPhotoType == 0) { checkImageView.setChecked(placeProvider.isPhotoChecked(currentIndex), false); } + + setCurrentCaption(caption); + updateCaptionTextForCurrentPhoto(object); } @@ -2026,6 +2398,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animateToScale = 1; animationStartTime = 0; imageMoveAnimation = null; + changeModeAnimation = null; pinchStartDistance = 0; pinchStartScale = 1; @@ -2086,6 +2459,33 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat createGifForCurrentImage(); } + private void setCurrentCaption(final CharSequence caption) { + if (caption != null && caption.length() > 0) { + captionTextView = captionTextViewOld; + captionTextViewOld = captionTextViewNew; + captionTextViewNew = captionTextView; + + captionItem.setIcon(R.drawable.photo_text2); + CharSequence oldText = captionTextView.getText(); + captionTextView.setTag(caption); + captionTextView.setText(caption); + ViewProxy.setAlpha(captionTextView, bottomLayout.getVisibility() == View.VISIBLE || pickerView.getVisibility() == View.VISIBLE ? 1.0f : 0.0f); + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + captionTextViewOld.setTag(null); + captionTextViewOld.setVisibility(View.INVISIBLE); + captionTextViewNew.setVisibility(bottomLayout.getVisibility() == View.VISIBLE || pickerView.getVisibility() == View.VISIBLE ? View.VISIBLE : View.INVISIBLE); + } + }); + } else { + captionItem.setIcon(R.drawable.photo_text); + captionTextView.setTag(null); + captionTextView.clearAnimation(); + captionTextView.setVisibility(View.INVISIBLE); + } + } + private void createGifForCurrentImage() { if (gifDrawable != null) { gifDrawable.recycle(); @@ -2269,23 +2669,23 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } public void openPhoto(final MessageObject messageObject, final PhotoViewerProvider provider) { - openPhoto(messageObject, null, null, null, 0, provider); + openPhoto(messageObject, null, null, null, 0, provider, null); } public void openPhoto(final TLRPC.FileLocation fileLocation, final PhotoViewerProvider provider) { - openPhoto(null, fileLocation, null, null, 0, provider); + openPhoto(null, fileLocation, null, null, 0, provider, null); } public void openPhoto(final ArrayList messages, final int index, final PhotoViewerProvider provider) { - openPhoto(messages.get(index), null, messages, null, index, provider); + openPhoto(messages.get(index), null, messages, null, index, provider, null); } - public void openPhotoForSelect(final ArrayList photos, final int index, int type, final PhotoViewerProvider provider) { + public void openPhotoForSelect(final ArrayList photos, final int index, int type, final PhotoViewerProvider provider, ChatActivity chatActivity) { sendPhotoType = type; if (pickerView != null) { pickerView.doneButtonTextView.setText(sendPhotoType == 1 ? LocaleController.getString("Set", R.string.Set).toUpperCase() : LocaleController.getString("Send", R.string.Send).toUpperCase()); } - openPhoto(null, null, null, photos, index, provider); + openPhoto(null, null, null, photos, index, provider, chatActivity); } private boolean checkAnimation() { @@ -2301,7 +2701,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return animationInProgress != 0; } - public void openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList messages, final ArrayList photos, final int index, final PhotoViewerProvider provider) { + public void openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList messages, final ArrayList photos, final int index, final PhotoViewerProvider provider, ChatActivity chatActivity) { if (parentActivity == null || isVisible || provider == null && checkAnimation() || messageObject == null && fileLocation == null && messages == null && photos == null) { return; } @@ -2311,21 +2711,37 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return; } - try { - WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); - wm.removeView(windowView); - } catch (Exception e) { - //don't promt + WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); + if (windowView.attachedToWindow) { + try { + wm.removeView(windowView); + } catch (Exception e) { + //don't promt + } } - WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); try { + if (photos != null) { + windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; + windowLayoutParams.flags = 0; + windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN; + windowView.setFocusable(true); + containerView.setFocusable(true); + } else { + windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; + windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED; + windowView.setFocusable(false); + containerView.setFocusable(false); + } wm.addView(windowView, windowLayoutParams); } catch (Exception e) { FileLog.e("tmessages", e); return; } + parentChatActivity = chatActivity; + actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); @@ -2333,6 +2749,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.userPhotosLoaded); + NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); placeProvider = provider; @@ -2341,7 +2758,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } isVisible = true; - backgroundDrawable.setAlpha(255); toggleActionBar(true, false); if (object != null) { @@ -2349,8 +2765,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animationInProgress = 1; onPhotoShow(messageObject, fileLocation, messages, photos, index, object); - AndroidUtilities.lockOrientation(parentActivity); - final Rect drawRegion = object.imageReceiver.getDrawRegion(); int orientation = object.imageReceiver.getOrientation(); @@ -2372,96 +2786,115 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat layoutParams.height = drawRegion.bottom - drawRegion.top; animatingImageView.setLayoutParams(layoutParams); - containerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; + float scaleY = (float) (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight) / layoutParams.height; + float scale = scaleX > scaleY ? scaleY : scaleX; + float width = layoutParams.width * scale; + float height = layoutParams.height * scale; + float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f; + float yPos = (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - height) / 2.0f; + int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX()); + int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY()); + + int coords2[] = new int[2]; + object.parentView.getLocationInWindow(coords2); + int clipTop = coords2[1] - AndroidUtilities.statusBarHeight - (object.viewY + drawRegion.top); + if (clipTop < 0) { + clipTop = 0; + } + int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight); + if (clipBottom < 0) { + clipBottom = 0; + } + clipTop = Math.max(clipTop, clipVertical); + clipBottom = Math.max(clipBottom, clipVertical); + + animationValues[0][0] = ViewProxy.getScaleX(animatingImageView); + animationValues[0][1] = ViewProxy.getScaleY(animatingImageView); + animationValues[0][2] = ViewProxy.getTranslationX(animatingImageView); + animationValues[0][3] = ViewProxy.getTranslationY(animatingImageView); + animationValues[0][4] = clipHorizontal; + animationValues[0][5] = clipTop; + animationValues[0][6] = clipBottom; + animationValues[0][7] = animatingImageView.getRadius(); + + animationValues[1][0] = scale; + animationValues[1][1] = scale; + animationValues[1][2] = xPos; + animationValues[1][3] = yPos; + animationValues[1][4] = 0; + animationValues[1][5] = 0; + animationValues[1][6] = 0; + animationValues[1][7] = 0; + + animatingImageView.setAnimationProgress(0); + backgroundDrawable.setAlpha(0); + ViewProxy.setAlpha(containerView, 0); + + final AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + animatorSet.playTogether( + ObjectAnimatorProxy.ofFloat(animatingImageView, "animationProgress", 0.0f, 1.0f), + ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", 0, 255), + ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f) + ); + + animationEndRunnable = new Runnable() { @Override - public boolean onPreDraw() { - containerView.getViewTreeObserver().removeOnPreDrawListener(this); - - float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; - float scaleY = (float) (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight) / layoutParams.height; - float scale = scaleX > scaleY ? scaleY : scaleX; - float width = layoutParams.width * scale; - float height = layoutParams.height * scale; - float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f; - float yPos = (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - height) / 2.0f; - int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX()); - int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY()); - - int coords2[] = new int[2]; - object.parentView.getLocationInWindow(coords2); - int clipTop = coords2[1] - AndroidUtilities.statusBarHeight - (object.viewY + drawRegion.top); - if (clipTop < 0) { - clipTop = 0; + public void run() { + if (containerView == null) { + return; } - int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight); - if (clipBottom < 0) { - clipBottom = 0; + animationInProgress = 0; + transitionAnimationStartTime = 0; + setImages(); + containerView.invalidate(); + animatingImageView.setVisibility(View.GONE); + if (showAfterAnimation != null) { + showAfterAnimation.imageReceiver.setVisible(true, true); } - clipTop = Math.max(clipTop, clipVertical); - clipBottom = Math.max(clipBottom, clipVertical); + if (hideAfterAnimation != null) { + hideAfterAnimation.imageReceiver.setVisible(false, true); + } + } + }; - AnimatorSetProxy animatorSet = new AnimatorSetProxy(); - animatorSet.playTogether( - ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleX", scale), - ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleY", scale), - ObjectAnimatorProxy.ofFloat(animatingImageView, "translationX", xPos), - ObjectAnimatorProxy.ofFloat(animatingImageView, "translationY", yPos), - ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", 0, 255), - ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal, 0), - ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop, 0), - ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom, 0), - ObjectAnimatorProxy.ofInt(animatingImageView, "radius", 0), - ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f) - ); - - animationEndRunnable = new Runnable() { + animatorSet.setDuration(200); + animatorSet.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - animationInProgress = 0; - setImages(); - transitionAnimationStartTime = 0; - containerView.invalidate(); - animatingImageView.setVisibility(View.GONE); - AndroidUtilities.unlockOrientation(parentActivity); - if (showAfterAnimation != null) { - showAfterAnimation.imageReceiver.setVisible(true, true); - } - if (hideAfterAnimation != null) { - hideAfterAnimation.imageReceiver.setVisible(false, true); - } - } - }; - - animatorSet.setDuration(200); - animatorSet.addListener(new AnimatorListenerAdapterProxy() { - @Override - public void onAnimationEnd(Object animation) { if (animationEndRunnable != null) { animationEndRunnable.run(); animationEndRunnable = null; } } - - @Override - public void onAnimationCancel(Object animation) { - onAnimationEnd(animation); - } }); - transitionAnimationStartTime = System.currentTimeMillis(); - animatorSet.start(); + } - animatingImageView.setOnDrawListener(new ClippingImageView.onDrawListener() { - @Override - public void onDraw() { - disableShowCheck = false; - animatingImageView.setOnDrawListener(null); - object.imageReceiver.setVisible(false, true); - } - }); - return true; + @Override + public void onAnimationCancel(Object animation) { + onAnimationEnd(animation); } }); + transitionAnimationStartTime = System.currentTimeMillis(); + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + animatorSet.start(); + } + }); + + backgroundDrawable.drawRunnable = new Runnable() { + @Override + public void run() { + disableShowCheck = false; + object.imageReceiver.setVisible(false, true); + } + }; } else { + backgroundDrawable.setAlpha(255); ViewProxy.setAlpha(containerView, 1.0f); onPhotoShow(messageObject, fileLocation, messages, photos, index, object); } @@ -2500,12 +2933,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return; } + captionEditText.onDestroy(); + parentChatActivity = null; NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.userPhotosLoaded); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); ConnectionsManager.getInstance().cancelRpcsForClassGuid(classGuid); isActionBarVisible = false; @@ -2519,8 +2955,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex); if (animated) { - AndroidUtilities.lockOrientation(parentActivity); - animationInProgress = 1; int visibility = animatingImageView.getVisibility(); animatingImageView.setVisibility(View.VISIBLE); @@ -2576,16 +3010,27 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat clipTop = Math.max(clipTop, clipVertical); clipBottom = Math.max(clipBottom, clipVertical); + animationValues[0][0] = ViewProxy.getScaleX(animatingImageView); + animationValues[0][1] = ViewProxy.getScaleY(animatingImageView); + animationValues[0][2] = ViewProxy.getTranslationX(animatingImageView); + animationValues[0][3] = ViewProxy.getTranslationY(animatingImageView); + animationValues[0][4] = 0; + animationValues[0][5] = 0; + animationValues[0][6] = 0; + animationValues[0][7] = 0; + + animationValues[1][0] = 1; + animationValues[1][1] = 1; + animationValues[1][2] = object.viewX + drawRegion.left; + animationValues[1][3] = object.viewY + drawRegion.top; + animationValues[1][4] = clipHorizontal; + animationValues[1][5] = clipTop; + animationValues[1][6] = clipBottom; + animationValues[1][7] = object.radius; + animatorSet.playTogether( - ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleX", 1), - ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleY", 1), - ObjectAnimatorProxy.ofFloat(animatingImageView, "translationX", object.viewX + drawRegion.left), - ObjectAnimatorProxy.ofFloat(animatingImageView, "translationY", object.viewY + drawRegion.top), + ObjectAnimatorProxy.ofFloat(animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", 0), - ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal), - ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop), - ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom), - ObjectAnimatorProxy.ofInt(animatingImageView, "radius", object.radius), ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f) ); } else { @@ -2600,7 +3045,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animationEndRunnable = new Runnable() { @Override public void run() { - AndroidUtilities.unlockOrientation(parentActivity); animationInProgress = 0; onPhotoClosed(object); } @@ -2610,10 +3054,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animationEndRunnable != null) { - animationEndRunnable.run(); - animationEndRunnable = null; - } + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (animationEndRunnable != null) { + animationEndRunnable.run(); + animationEndRunnable = null; + } + } + }); } @Override @@ -2635,6 +3084,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animationEndRunnable = new Runnable() { @Override public void run() { + if (containerView == null) { + return; + } animationInProgress = 0; onPhotoClosed(object); ViewProxy.setScaleX(containerView, 1.0f); @@ -2670,6 +3122,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } catch (Exception e) { FileLog.e("tmessages", e); } + if (captionEditText != null) { + captionEditText.onDestroy(); + } Instance = null; } @@ -2716,6 +3171,24 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } + private void redraw(final int count) { + if (count < 6) { + if (containerView != null) { + containerView.invalidate(); + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + redraw(count + 1); + } + }, 100); + } + } + } + + public void onResume() { + redraw(0); //workaround for camera bug + } + public boolean isVisible() { return isVisible && placeProvider != null; } @@ -2774,7 +3247,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } private int getContainerViewHeight(int mode) { - int height = containerView.getHeight(); + //int height = containerView.getHeight(); + int height = AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight; if (mode == 1) { height -= AndroidUtilities.dp(76); } else if (mode == 2) { @@ -2785,9 +3259,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private boolean onTouchEvent(MotionEvent ev) { if (animationInProgress != 0 || animationStartTime != 0) { - if (animationStartTime == 0) { - AndroidUtilities.unlockOrientation(parentActivity); - } return false; } @@ -2807,6 +3278,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } + if (captionEditText.isEmojiPopupShowing() || captionEditText.isKeyboardVisible()) { + return true; + } + if (currentEditMode == 0 && ev.getPointerCount() == 1 && gestureDetector.onTouchEvent(ev)) { if (doubleTap) { doubleTap = false; @@ -2843,7 +3318,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat dragY = moveStartY = ev.getY(); draggingDown = false; canDragDown = true; - AndroidUtilities.lockOrientation(parentActivity); if (velocityTracker != null) { velocityTracker.clear(); } @@ -3000,8 +3474,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat moveToY = maxY; } animateTo(scale, moveToX, moveToY, false); - } else { - AndroidUtilities.unlockOrientation(parentActivity); } } return false; @@ -3048,7 +3520,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private void animateTo(float newScale, float newTx, float newTy, boolean isZoom, int duration) { if (scale == newScale && translationX == newTx && translationY == newTy) { - AndroidUtilities.unlockOrientation(parentActivity); return; } zoomAnimation = isZoom; @@ -3066,12 +3537,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat @Override public void onAnimationEnd(Object animation) { imageMoveAnimation = null; - AndroidUtilities.unlockOrientation(parentActivity); containerView.invalidate(); } }); imageMoveAnimation.start(); - AndroidUtilities.lockOrientation(parentActivity); } public void setAnimationValue(float value) { @@ -3122,7 +3591,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat photoCropView.setAnimationProgress(1); } updateMinMax(scale); - AndroidUtilities.unlockOrientation(parentActivity); zoomAnimation = false; } if (!scroller.isFinished()) { @@ -3298,20 +3766,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat updateMinMax(scale); if (checkImageView != null) { - checkImageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + checkImageView.post(new Runnable() { @Override - public boolean onPreDraw() { - checkImageView.getViewTreeObserver().removeOnPreDrawListener(this); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) checkImageView.getLayoutParams(); + public void run() { + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) checkImageView.getLayoutParams(); WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); int rotation = manager.getDefaultDisplay().getRotation(); - if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { - layoutParams.topMargin = AndroidUtilities.dp(58); - } else { - layoutParams.topMargin = AndroidUtilities.dp(68); - } + layoutParams.topMargin = AndroidUtilities.dp(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90 ? 58 : 68); checkImageView.setLayoutParams(layoutParams); - return false; } }); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java index 1e728b7f..c038a2b7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java @@ -52,7 +52,9 @@ import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.ChatActivityEnterView; import org.telegram.ui.Components.FrameLayoutFixed; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PopupAudioView; +import org.telegram.ui.Components.RecordStatusDrawable; import org.telegram.ui.Components.SizeNotifierRelativeLayout; import org.telegram.ui.Components.TypingDotsDrawable; @@ -78,6 +80,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC private ArrayList audioViews = new ArrayList<>(); private VelocityTracker velocityTracker = null; private TypingDotsDrawable typingDotsDrawable; + private RecordStatusDrawable recordStatusDrawable; private int classGuid; private TLRPC.User currentUser; @@ -159,6 +162,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); typingDotsDrawable = new TypingDotsDrawable(); + recordStatusDrawable = new RecordStatusDrawable(); SizeNotifierRelativeLayout contentView = new SizeNotifierRelativeLayout(this); setContentView(contentView); @@ -167,15 +171,15 @@ public class PopupNotificationActivity extends Activity implements NotificationC RelativeLayout relativeLayout = new RelativeLayout(this); contentView.addView(relativeLayout); RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = RelativeLayout.LayoutParams.MATCH_PARENT; + layoutParams3.width = LayoutHelper.MATCH_PARENT; + layoutParams3.height = LayoutHelper.MATCH_PARENT; relativeLayout.setLayoutParams(layoutParams3); RelativeLayout popupContainer = new RelativeLayout(this); popupContainer.setBackgroundColor(0xffffffff); relativeLayout.addView(popupContainer); layoutParams3 = (RelativeLayout.LayoutParams) popupContainer.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; + layoutParams3.width = LayoutHelper.MATCH_PARENT; layoutParams3.height = AndroidUtilities.dp(240); layoutParams3.leftMargin = AndroidUtilities.dp(12); layoutParams3.rightMargin = AndroidUtilities.dp(12); @@ -188,8 +192,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false); popupContainer.addView(chatActivityEnterView); layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams(); - layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; - layoutParams3.height = RelativeLayout.LayoutParams.WRAP_CONTENT; + layoutParams3.width = LayoutHelper.MATCH_PARENT; + layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); chatActivityEnterView.setLayoutParams(layoutParams3); chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() { @@ -214,7 +218,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC @Override public void needSendTyping() { if (currentMessageObject != null) { - MessagesController.getInstance().sendTyping(currentMessageObject.getDialogId(), classGuid); + MessagesController.getInstance().sendTyping(currentMessageObject.getDialogId(), 0, classGuid); } } @@ -257,8 +261,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); actionBar.addView(avatarContainer); FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams(); - layoutParams2.height = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.height = LayoutHelper.MATCH_PARENT; + layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.rightMargin = AndroidUtilities.dp(48); layoutParams2.leftMargin = AndroidUtilities.dp(60); layoutParams2.gravity = Gravity.TOP | Gravity.LEFT; @@ -284,8 +288,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); avatarContainer.addView(nameTextView); layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.width = LayoutHelper.WRAP_CONTENT; + layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.leftMargin = AndroidUtilities.dp(54); layoutParams2.bottomMargin = AndroidUtilities.dp(22); layoutParams2.gravity = Gravity.BOTTOM; @@ -301,8 +305,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC onlineTextView.setGravity(Gravity.LEFT); avatarContainer.addView(onlineTextView); layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams2.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams2.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams2.width = LayoutHelper.WRAP_CONTENT; + layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.leftMargin = AndroidUtilities.dp(54); layoutParams2.bottomMargin = AndroidUtilities.dp(4); layoutParams2.gravity = Gravity.BOTTOM; @@ -956,9 +960,18 @@ public class PopupNotificationActivity extends Activity implements NotificationC } if (start) { try { + Integer type = MessagesController.getInstance().printingStringsTypes.get(currentMessageObject.getDialogId()); + if (type == 0) { onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null); onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); typingDotsDrawable.start(); + recordStatusDrawable.stop(); + } else if (type == 1) { + onlineTextView.setCompoundDrawablesWithIntrinsicBounds(recordStatusDrawable, null, null, null); + onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); + recordStatusDrawable.start(); + typingDotsDrawable.stop(); + } } catch (Exception e) { FileLog.e("tmessages", e); } @@ -966,6 +979,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); onlineTextView.setCompoundDrawablePadding(0); typingDotsDrawable.stop(); + recordStatusDrawable.stop(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java index 08c10cb9..47642be9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java @@ -41,6 +41,7 @@ import org.telegram.ui.Cells.HeaderCell; import org.telegram.ui.Cells.TextCheckCell; import org.telegram.ui.Cells.TextInfoPrivacyCell; import org.telegram.ui.Cells.TextSettingsCell; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; @@ -122,8 +123,8 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index e76a32aa..411e9263 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -40,6 +40,7 @@ import android.widget.TextView; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.ContactsController; import org.telegram.android.LocaleController; import org.telegram.android.MessageObject; @@ -61,7 +62,7 @@ import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.AnimationCompat.ViewProxy; +import org.telegram.ui.Cells.AddMemberCell; import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.EmptyCell; import org.telegram.ui.Cells.ShadowSectionCell; @@ -72,6 +73,7 @@ import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarUpdater; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.IdenticonDrawable; +import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; import java.util.Collections; @@ -128,6 +130,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. private int sectionRow; private int membersSectionRow; private int membersEndRow; + private int addMemberRow; private int rowCount = 0; public ProfileActivity(Bundle args) { @@ -301,29 +304,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showAlertDialog(builder); } else if (id == add_member) { - Bundle args = new Bundle(); - args.putBoolean("onlyUsers", true); - args.putBoolean("destroyAfterSelect", true); - args.putBoolean("returnAsResult", true); - //args.putBoolean("allowUsernameSearch", false); - if (chat_id > 0) { - args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup)); - } - ContactsActivity fragment = new ContactsActivity(args); - fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() { - @Override - public void didSelectContact(TLRPC.User user, String param) { - MessagesController.getInstance().addUserToChat(chat_id, user, info, param != null ? Utilities.parseInt(param) : 0); - } - }); - if (info != null) { - HashMap users = new HashMap<>(); - for (TLRPC.TL_chatParticipant p : info.participants) { - users.put(p.user_id, null); - } - fragment.setIgnoreUsers(users); - } - presentFragment(fragment); + openAddMember(); } else if (id == leave_group) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit)); @@ -392,8 +373,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); actionBar.addView(nameTextView); layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); layoutParams.bottomMargin = AndroidUtilities.dp(51); @@ -411,8 +392,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); actionBar.addView(onlineTextView); layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); layoutParams.bottomMargin = AndroidUtilities.dp(30); @@ -426,8 +407,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(user_id != 0 ? 5 : chat_id)); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); @@ -515,6 +496,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. Bundle args = new Bundle(); args.putInt("user_id", user_id); presentFragment(new ProfileActivity(args)); + } else if (i == addMemberRow) { + openAddMember(); } } }); @@ -596,8 +579,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. }); } layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); @@ -688,6 +671,35 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } } + private void openAddMember() { + Bundle args = new Bundle(); + args.putBoolean("onlyUsers", true); + args.putBoolean("destroyAfterSelect", true); + args.putBoolean("returnAsResult", true); + if (info != null && info.admin_id == UserConfig.getClientUserId()) { + args.putInt("chat_id", currentChat.id); + } + //args.putBoolean("allowUsernameSearch", false); + if (chat_id > 0) { + args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup)); + } + ContactsActivity fragment = new ContactsActivity(args); + fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() { + @Override + public void didSelectContact(TLRPC.User user, String param) { + MessagesController.getInstance().addUserToChat(chat_id, user, info, param != null ? Utilities.parseInt(param) : 0); + } + }); + if (info != null) { + HashMap users = new HashMap<>(); + for (TLRPC.TL_chatParticipant p : info.participants) { + users.put(p.user_id, null); + } + fragment.setIgnoreUsers(users); + } + presentFragment(fragment); + } + private void checkListViewScroll() { if (listView.getChildCount() == 0) { return; @@ -1097,16 +1109,18 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. rowCount += info.participants.size(); membersEndRow = rowCount; int maxCount = chat_id > 0 ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount; + addMemberRow = rowCount++; } else { membersEndRow = -1; membersSectionRow = -1; emptyRowChat2 = -1; + addMemberRow = -1; } } } private void updateProfileData() { - if (avatarImage == null) { + if (avatarImage == null || nameTextView == null) { return; } updateTheme(); @@ -1138,6 +1152,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id); if (chat != null) { currentChat = chat; + } else { + chat = currentChat; } nameTextView.setText(chat.title); @@ -1269,7 +1285,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (user_id != 0) { return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == startSecretChatRow; } else if (chat_id != 0) { - return i == settingsNotificationsRow || i == sharedMediaRow || i > emptyRowChat2 && i < membersEndRow; + return i == settingsNotificationsRow || i == sharedMediaRow || i > emptyRowChat2 && i < membersEndRow || i == addMemberRow; } return false; } @@ -1304,11 +1320,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. view = new EmptyCell(mContext); } if (i == overscrollRow) { - ((EmptyCell) view).setHeight(88); + ((EmptyCell) view).setHeight(AndroidUtilities.dp(88)); } else if (i == emptyRowChat || i == emptyRowChat2) { - ((EmptyCell) view).setHeight(8); + ((EmptyCell) view).setHeight(AndroidUtilities.dp(8)); } else { - ((EmptyCell) view).setHeight(36); + ((EmptyCell) view).setHeight(AndroidUtilities.dp(36)); } } else if (type == 1) { if (view == null) { @@ -1404,6 +1420,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. view = new ShadowSectionCell(mContext); } view.setBackgroundColor(themePrefs.getInt("profileRowColor", 0xffffffff)); + } else if (type == 6) { + if (view == null) { + view = new AddMemberCell(mContext); + } } viewGroup.setBackgroundColor(themePrefs.getInt("profileRowColor", 0xffffffff)); return view; @@ -1423,13 +1443,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return 4; } else if (i == membersSectionRow) { return 5; + } else if (i == addMemberRow) { + return 6; } return 0; } @Override public int getViewTypeCount() { - return 6; + return 7; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java index 49069147..15fe7e95 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java @@ -20,14 +20,16 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.provider.Settings; +import android.util.TypedValue; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.ListView; -import android.widget.Spinner; +import android.widget.TextView; import org.telegram.android.AndroidUtilities; import org.telegram.android.LocaleController; @@ -47,6 +49,7 @@ import org.telegram.ui.Cells.TextColorCell; import org.telegram.ui.Cells.TextDetailSettingsCell; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.ColorPickerView; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.NumberPicker; public class ProfileNotificationsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { @@ -58,8 +61,8 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi private int settingsVibrateRow; private int settingsSoundRow; private int settingsPriorityRow; - private int settingsSmartNotifyRow; private int settingsLedRow; + private int smartRow; private int rowCount = 0; public ProfileNotificationsActivity(Bundle args) { @@ -70,12 +73,6 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi @Override public boolean onFragmentCreate() { settingsNotificationsRow = rowCount++; - if (dialog_id < 0) { - settingsSmartNotifyRow = rowCount++; - } - else { - settingsSmartNotifyRow = -1; - } settingsVibrateRow = rowCount++; settingsSoundRow = rowCount++; if (Build.VERSION.SDK_INT >= 21) { @@ -83,6 +80,12 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi } else { settingsPriorityRow = -1; } + int lower_id = (int) dialog_id; + if (lower_id < 0) { + smartRow = rowCount++; + } else { + smartRow = 1; + } settingsLedRow = rowCount++; NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated); return super.onFragmentCreate(); @@ -117,9 +120,9 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi listView.setVerticalScrollBarEnabled(false); AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5)); frameLayout.addView(listView); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + final FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setAdapter(new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -164,8 +167,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - //Smart Notifications - /*builder.setItems(new CharSequence[] { + builder.setItems(new CharSequence[]{ LocaleController.getString("Default", R.string.Default), LocaleController.getString("Enabled", R.string.Enabled), LocaleController.getString("NotificationsDisabled", R.string.NotificationsDisabled) @@ -189,69 +191,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi } NotificationsController.updateServerNotificationsSettings(dialog_id); } - });*/ - if (dialog_id < 0) { - builder.setItems(new CharSequence[]{ - LocaleController.getString("Default", R.string.Default), - LocaleController.getString("Enabled", R.string.Enabled), - LocaleController.getString("NotificationsDisabled", R.string.NotificationsDisabled), - LocaleController.getString("Smart Notification", R.string.SmartNotification) - }, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - if (which == 3) { - which = 4; //Leave space for "Mute group for D duration" - editor.putBoolean("smart_notify_" + dialog_id, true); - } else { - editor.putBoolean("smart_notify_" + dialog_id, false); - } - editor.putInt("notify2_" + dialog_id, which); - MessagesStorage.getInstance().setDialogFlags(dialog_id, which == 2 ? 1 : 0); - editor.commit(); - TLRPC.TL_dialog tl_dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id); - if (tl_dialog != null) { - tl_dialog.notify_settings = new TLRPC.TL_peerNotifySettings(); - if (which == 2) { - tl_dialog.notify_settings.mute_until = Integer.MAX_VALUE; - } - } - if (listView != null) { - listView.invalidateViews(); - } - NotificationsController.updateServerNotificationsSettings(dialog_id); - } - }); - } - else { - builder.setItems(new CharSequence[]{ - LocaleController.getString("Default", R.string.Default), - LocaleController.getString("Enabled", R.string.Enabled), - LocaleController.getString("NotificationsDisabled", R.string.NotificationsDisabled), - }, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - editor.putInt("notify2_" + dialog_id, which); - MessagesStorage.getInstance().setDialogFlags(dialog_id, which == 2 ? 1 : 0); - editor.commit(); - TLRPC.TL_dialog tl_dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id); - if (tl_dialog != null) { - tl_dialog.notify_settings = new TLRPC.TL_peerNotifySettings(); - if (which == 2) { - tl_dialog.notify_settings.mute_until = Integer.MAX_VALUE; - } - } - if (listView != null) { - listView.invalidateViews(); - } - NotificationsController.updateServerNotificationsSettings(dialog_id); - } - }); - } - // + }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showAlertDialog(builder); } else if (i == settingsSoundRow) { @@ -362,74 +302,122 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showAlertDialog(builder); + } else if (i == smartRow) { + if (getParentActivity() == null) { + return; } - //Smart Notifications - else if (i == settingsSmartNotifyRow) { - if (getParentActivity() == null) { - return; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + int notifyMaxCount = preferences.getInt("smart_max_count_" + dialog_id, 2); + int notifyDelay = preferences.getInt("smart_delay_" + dialog_id, 3 * 60); + if (notifyMaxCount == 0) { + notifyMaxCount = 2; + } + + LinearLayout linearLayout = new LinearLayout(getParentActivity()); + linearLayout.setOrientation(LinearLayout.VERTICAL); + + LinearLayout linearLayout2 = new LinearLayout(getParentActivity()); + linearLayout2.setOrientation(LinearLayout.HORIZONTAL); + linearLayout.addView(linearLayout2); + LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) linearLayout2.getLayoutParams(); + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; + layoutParams1.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; + linearLayout2.setLayoutParams(layoutParams1); + + TextView textView = new TextView(getParentActivity()); + textView.setText(LocaleController.getString("SmartNotificationsSoundAtMost", R.string.SmartNotificationsSoundAtMost)); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); + linearLayout2.addView(textView); + layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams(); + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; + layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; + textView.setLayoutParams(layoutParams1); + + final NumberPicker numberPickerTimes = new NumberPicker(getParentActivity()); + numberPickerTimes.setMinValue(1); + numberPickerTimes.setMaxValue(10); + numberPickerTimes.setValue(notifyMaxCount); + linearLayout2.addView(numberPickerTimes); + layoutParams1 = (LinearLayout.LayoutParams) numberPickerTimes.getLayoutParams(); + layoutParams1.width = AndroidUtilities.dp(50); + numberPickerTimes.setLayoutParams(layoutParams1); + + textView = new TextView(getParentActivity()); + textView.setText(LocaleController.getString("SmartNotificationsTimes", R.string.SmartNotificationsTimes)); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); + linearLayout2.addView(textView); + layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams(); + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; + layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; + textView.setLayoutParams(layoutParams1); + + linearLayout2 = new LinearLayout(getParentActivity()); + linearLayout2.setOrientation(LinearLayout.HORIZONTAL); + linearLayout.addView(linearLayout2); + layoutParams1 = (LinearLayout.LayoutParams) linearLayout2.getLayoutParams(); + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; + layoutParams1.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; + linearLayout2.setLayoutParams(layoutParams1); + + textView = new TextView(getParentActivity()); + textView.setText(LocaleController.getString("SmartNotificationsWithin", R.string.SmartNotificationsWithin)); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); + linearLayout2.addView(textView); + layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams(); + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; + layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; + textView.setLayoutParams(layoutParams1); + + final NumberPicker numberPickerMinutes = new NumberPicker(getParentActivity()); + numberPickerMinutes.setMinValue(1); + numberPickerMinutes.setMaxValue(10); + numberPickerMinutes.setValue(notifyDelay / 60); + linearLayout2.addView(numberPickerMinutes); + layoutParams1 = (LinearLayout.LayoutParams) numberPickerMinutes.getLayoutParams(); + layoutParams1.width = AndroidUtilities.dp(50); + numberPickerMinutes.setLayoutParams(layoutParams1); + + textView = new TextView(getParentActivity()); + textView.setText(LocaleController.getString("SmartNotificationsMinutes", R.string.SmartNotificationsMinutes)); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); + linearLayout2.addView(textView); + layoutParams1 = (LinearLayout.LayoutParams) textView.getLayoutParams(); + layoutParams1.width = LayoutHelper.WRAP_CONTENT; + layoutParams1.height = LayoutHelper.WRAP_CONTENT; + layoutParams1.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; + textView.setLayoutParams(layoutParams1); + + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("SmartNotifications", R.string.SmartNotifications)); + builder.setView(linearLayout); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + preferences.edit().putInt("smart_max_count_" + dialog_id, numberPickerTimes.getValue()).commit(); + preferences.edit().putInt("smart_delay_" + dialog_id, numberPickerMinutes.getValue() * 60).commit(); + if (listView != null) { + listView.invalidateViews(); + } } - - LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.settings_smart_notify, null, false); - - String[] timeUnits = { - LocaleController.getString("Seconds", R.string.TimeUnitSeconds), - LocaleController.getString("Minutes", R.string.TimeUnitMinutes), - LocaleController.getString("Hours", R.string.TimeUnitHours), - LocaleController.getString("Days", R.string.TimeUnitDays) - }; - final Spinner timeframeUnitSpinner = (Spinner) view.findViewById(R.id.timeframeunitSpinner); - ArrayAdapter adapter = new ArrayAdapter (li.getContext(), android.R.layout.simple_spinner_item, timeUnits); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - timeframeUnitSpinner.setAdapter(adapter); - - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - - final NumberPicker maxcountNumberPicker = (NumberPicker) view.findViewById(R.id.maxcountNumberPicker); - maxcountNumberPicker.setMinValue(1); - maxcountNumberPicker.setMaxValue(10); - maxcountNumberPicker.setValue(preferences.getInt ("smart_notify_max_count_" + dialog_id, 1)); - - final NumberPicker timeframeNumberPicker = (NumberPicker) view.findViewById(R.id.timeframeNumberPicker); - timeframeNumberPicker.setMinValue(1); - timeframeNumberPicker.setMaxValue(100); - - long timeframe = preferences.getLong("smart_notify_timeframe_" + dialog_id, 1); - long multiplier = (timeframe % 86400L == 0L) ? 86400L : ((timeframe % 3600L == 0L) ? 3600L : ((timeframe % 60L == 0L) ? 60L : 1L)); - timeframe = timeframe / multiplier; - timeframeUnitSpinner.setSelection((multiplier == 1L) ? 0 : ((multiplier == 60L) ? 1 : (multiplier == 3600L) ? 2 : 3)); - timeframeNumberPicker.setValue((int)timeframe); - - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setTitle(LocaleController.getString("Smart Notification", R.string.SmartNotification)); - builder.setView(view); - builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int which) { - final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - int unit = timeframeUnitSpinner.getSelectedItemPosition(); - long multiplier = (unit == 0) ? 1L : ((unit == 1) ? 60L : ((unit == 2) ? 3600L : 86400L)); - editor.putInt("smart_notify_max_count_" + dialog_id, maxcountNumberPicker.getValue()); - editor.putLong("smart_notify_timeframe_" + dialog_id, timeframeNumberPicker.getValue() * multiplier); - editor.commit(); + }); + builder.setNegativeButton(LocaleController.getString("SmartNotificationsDisabled", R.string.SmartNotificationsDisabled), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + preferences.edit().putInt("smart_max_count_" + dialog_id, 0).commit(); + if (listView != null) { listView.invalidateViews(); } - }); - builder.setNegativeButton(LocaleController.getString("Default", R.string.Default), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - editor.putInt("smart_notify_max_count_" + dialog_id, 1); - editor.putLong("smart_notify_timeframe_" + dialog_id, 1); - editor.commit(); - listView.invalidateViews(); - } - }); - showAlertDialog(builder); - } - // + } + }); + showAlertDialog(builder); + } } }); @@ -489,23 +477,11 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi @Override public boolean areAllItemsEnabled() { - //return true; - //Smart Notifications - return false; - // + return true; } @Override public boolean isEnabled(int i) { - //Smart Notifications - if (i < 0) - return false; - if (i == settingsSmartNotifyRow) { - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); - if (!preferences.getBoolean("smart_notify_" + dialog_id, false)) - return false; - } - // return true; } @@ -582,11 +558,6 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("NotificationsDisabled", R.string.NotificationsDisabled), true); } } - //Smart Notifications - else if (value == 4) { - textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("Smart Notification", R.string.SmartNotification), true); - } - // } else if (i == settingsSoundRow) { String value = preferences.getString("sound_" + dialog_id, LocaleController.getString("SoundDefault", R.string.SoundDefault)); if (value.equals("NoSound")) { @@ -604,37 +575,17 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi } else if (value == 3) { textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("SettingsDefault", R.string.SettingsDefault), true); } - } - //Smart Notifications - else if (i == settingsSmartNotifyRow) { - String value = LocaleController.getString("Disabled", R.string.Disabled); - if (preferences.getBoolean("smart_notify_" + dialog_id, false)) { - long timeframe = preferences.getLong("smart_notify_timeframe_" + dialog_id, 1); - long multiplier = (timeframe % 86400L == 0L) ? 86400L : ((timeframe % 3600L == 0L) ? 3600L : ((timeframe % 60L == 0L) ? 60L : 1L)); - timeframe = timeframe / multiplier; - String[] timeUnits = { - LocaleController.getString("Seconds", R.string.TimeUnitSeconds), - LocaleController.getString("Minutes", R.string.TimeUnitMinutes), - LocaleController.getString("Hours", R.string.TimeUnitHours), - LocaleController.getString("Days", R.string.TimeUnitDays) - }; - value = LocaleController.getString("Sound at most", R.string.settings_smart_notify_begin); - value += " "; - value += preferences.getInt("smart_notify_max_count_" + dialog_id, 1); - value += " "; - value += preferences.getInt("smart_notify_max_count_" + dialog_id, 1) == 1 ? LocaleController.getString("time", R.string.settings_smart_notify_mid11) : LocaleController.getString("time(s)", R.string.settings_smart_notify_mid1); - value += " "; - value += LocaleController.getString("within", R.string.settings_smart_notify_mid2); - value += " "; - value += timeframe; - value += " "; - value += timeUnits [((multiplier == 1L)? 0: (multiplier == 60L)? 1 : (multiplier == 3600L)? 2 : 3)]; - //value += " "; - //value += LocaleController.getString(".", R.string.settings_smart_notify_end); + } else if (i == smartRow) { + int notifyMaxCount = preferences.getInt("smart_max_count_" + dialog_id, 2); + int notifyDelay = preferences.getInt("smart_delay_" + dialog_id, 3 * 60); + if (notifyMaxCount == 0) { + textCell.setTextAndValue(LocaleController.getString("SmartNotifications", R.string.SmartNotifications), LocaleController.getString("SmartNotificationsDisabled", R.string.SmartNotificationsDisabled), true); + } else { + String times = LocaleController.formatPluralString("Times", notifyMaxCount); + String minutes = LocaleController.formatPluralString("Minutes", notifyDelay / 60); + textCell.setTextAndValue(LocaleController.getString("SmartNotifications", R.string.SmartNotifications), LocaleController.formatString("SmartNotificationsInfo", R.string.SmartNotificationsInfo, times, minutes), true); } - textCell.setTextAndValue(LocaleController.getString("Smart Notification", R.string.SmartNotification), value, true); } - // } else if (type == 1) { if (view == null) { view = new TextColorCell(mContext); @@ -659,7 +610,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi @Override public int getItemViewType(int i) { - if (i == settingsNotificationsRow || i == settingsVibrateRow || i == settingsSoundRow || i == settingsPriorityRow) { + if (i == settingsNotificationsRow || i == settingsVibrateRow || i == settingsSoundRow || i == settingsPriorityRow || i == smartRow) { return 0; } else if (i == settingsLedRow) { return 1; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java index ee5928a7..682d366b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java @@ -39,6 +39,7 @@ import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.TLRPC; +import org.telegram.ui.Components.LayoutHelper; import java.io.File; import java.util.ArrayList; @@ -213,8 +214,8 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD containerView.setFocusable(false); windowView.addView(containerView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)containerView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; containerView.setLayoutParams(layoutParams); containerView.setOnTouchListener(new View.OnTouchListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index 0bd7b455..76b112ff 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -47,6 +47,7 @@ import android.widget.Toast; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.android.AndroidUtilities; +import org.telegram.android.AnimationCompat.ViewProxy; import org.telegram.android.ContactsController; import org.telegram.android.LocaleController; import org.telegram.android.MediaController; @@ -63,7 +64,6 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.RPCRequest; import org.telegram.messenger.SerializedData; -import org.telegram.messenger.TLClassStore; import org.telegram.messenger.TLObject; import org.telegram.messenger.TLRPC; import org.telegram.messenger.UserConfig; @@ -72,17 +72,18 @@ import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; -import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.Cells.EmptyCell; import org.telegram.ui.Cells.HeaderCell; import org.telegram.ui.Cells.ShadowSectionCell; import org.telegram.ui.Cells.TextCheckCell; import org.telegram.ui.Cells.TextDetailSettingsCell; import org.telegram.ui.Cells.TextInfoCell; +import org.telegram.ui.Cells.TextInfoPrivacyCell; import org.telegram.ui.Cells.TextSettingsCell; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarUpdater; import org.telegram.ui.Components.BackupImageView; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.NumberPicker; import java.io.File; @@ -135,6 +136,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter private int rowCount; private int disableMessageClickRow; private int showAndroidEmojiRow; + private int keepOriginalFilenameRow; + private int keepOriginalFilenameDetailRow; private final static int edit_name = 1; private final static int logout = 2; @@ -239,6 +242,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter wifiDownloadRow = rowCount++; roamingDownloadRow = rowCount++; saveToGalleryRow = rowCount++; + keepOriginalFilenameRow = rowCount++; + keepOriginalFilenameDetailRow = rowCount++; messagesSectionRow = rowCount++; messagesSectionRow2 = rowCount++; textSizeRow = rowCount++; @@ -366,8 +371,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); actionBar.addView(nameTextView); layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); layoutParams.bottomMargin = AndroidUtilities.dp(51); @@ -377,7 +382,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter onlineTextView = new TextView(context); //onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(5)); onlineTextView.setTextColor(AndroidUtilities.getIntDarkerColor("themeColor",-0x40)); - onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); onlineTextView.setLines(1); onlineTextView.setMaxLines(1); @@ -386,8 +390,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); actionBar.addView(onlineTextView); layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); layoutParams.bottomMargin = AndroidUtilities.dp(30); @@ -401,8 +405,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5)); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; - layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; + layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); @@ -635,6 +639,16 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter presentFragment(new ChangeUsernameActivity()); } else if (i == numberRow) { presentFragment(new ChangePhoneHelpActivity()); + } else if (i == keepOriginalFilenameRow) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + boolean keep = preferences.getBoolean("keepOriginalFilename", false); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("keepOriginalFilename", !keep); + editor.commit(); + ApplicationLoader.KEEP_ORIGINAL_FILENAME = !keep; + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(!keep); + } } } }); @@ -659,8 +673,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } frameLayout.addView(writeButton); layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; - layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT; + layoutParams.width = LayoutHelper.WRAP_CONTENT; + layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); @@ -731,10 +745,14 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } } }); - + //setDarkTheme(); return fragmentView; } + private void setDarkTheme(){ + listView.setBackgroundColor(0xff212121); + } + @Override protected void onDialogDismiss() { MediaController.getInstance().checkAutodownloadSettings(); @@ -812,7 +830,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter byte[] datacentersBytes = Base64.decode(userString, Base64.DEFAULT); if (datacentersBytes != null) { SerializedData data = new SerializedData(datacentersBytes); - supportUser = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); + supportUser = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); if (supportUser != null && supportUser.id == 333000) { supportUser = null; } @@ -1076,7 +1094,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow || i == numberRow || i == showAndroidEmojiRow || i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == privacyRow || i == wifiDownloadRow || i == disableMessageClickRow || i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow || - i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow; + i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow || i == keepOriginalFilenameRow; } @Override @@ -1107,9 +1125,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter view = new EmptyCell(mContext); } if (i == overscrollRow) { - ((EmptyCell) view).setHeight(88); + ((EmptyCell) view).setHeight(AndroidUtilities.dp(88)); } else { - ((EmptyCell) view).setHeight(16); + ((EmptyCell) view).setHeight(AndroidUtilities.dp(16)); } } else if (type == 1) { if (view == null) { @@ -1171,7 +1189,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } else if (i == disableMessageClickRow) { textCell.setTextAndCheck(LocaleController.getString("DisableMessageClick", R.string.DisableMessageClick), preferences.getBoolean("disableMessageClick", false), false); } else if (i == saveToGalleryRow) { - textCell.setTextAndCheck(LocaleController.getString("SaveToGallerySettings", R.string.SaveToGallerySettings), MediaController.getInstance().canSaveToGallery(), false); + textCell.setTextAndCheck(LocaleController.getString("SaveToGallerySettings", R.string.SaveToGallerySettings), MediaController.getInstance().canSaveToGallery(), true); + } else if (i == keepOriginalFilenameRow) { + textCell.setTextAndCheck(LocaleController.getString("KeepOriginalFilename", R.string.KeepOriginalFilename), ApplicationLoader.KEEP_ORIGINAL_FILENAME, false); } else if (i == showAndroidEmojiRow) { textCell.setTextAndCheck(LocaleController.getString("ShowAndroidEmoji", R.string.ShowAndroidEmoji), ApplicationLoader.SHOW_ANDROID_EMOJI, true); } @@ -1265,6 +1285,14 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } textCell.setTextAndValue(value, LocaleController.getString("Username", R.string.Username), false); } + } else if (type == 7) { + if (view == null) { + view = new TextInfoPrivacyCell(mContext); + } + if (i == keepOriginalFilenameDetailRow) { + ((TextInfoPrivacyCell) view).setText(LocaleController.getString("KeepOriginalFilenameHelp", R.string.KeepOriginalFilenameHelp)); + view.setBackgroundResource(R.drawable.greydivider_bottom); + } } return view; } @@ -1275,7 +1303,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter return 0; } if (i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow) { return 1; - } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow || i == disableMessageClickRow || i == showAndroidEmojiRow) { + } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow || i == disableMessageClickRow || i == showAndroidEmojiRow || i == keepOriginalFilenameRow ) { return 3; } else if (i == notificationRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == privacyRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow || i == textSizeRow || i == languageRow || i == contactsSortRow) { return 2; @@ -1283,6 +1311,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter return 5; } else if (i == wifiDownloadRow || i == mobileDownloadRow || i == roamingDownloadRow || i == numberRow || i == usernameRow) { return 6; + } else if (i == keepOriginalFilenameDetailRow) { + return 7; } else if (i == settingsSectionRow2 || i == messagesSectionRow2 || i == supportSectionRow2 || i == numberSectionRow || i == mediaDownloadSection2) { return 4; } else { @@ -1292,7 +1322,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter @Override public int getViewTypeCount() { - return 7; + return 8; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java index d4345b80..96fea0e2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java @@ -424,7 +424,7 @@ public class ThemingActivity extends BaseFragment { editor.putInt("chatRBubbleColor", AndroidUtilities.getDefBubbleColor()); editor.putInt("chatStatusColor", AndroidUtilities.setDarkColor(i, -0x40)); editor.putInt("chatRTimeColor", AndroidUtilities.setDarkColor(i, 0x15)); - editor.putInt("chatEmojiViewTabColor", AndroidUtilities.setDarkColor(i, 0x15)); + editor.putInt("chatEmojiViewTabColor", AndroidUtilities.setDarkColor(i, -0x15)); editor.putInt("chatChecksColor", i); editor.putInt("chatSendIconColor", i); editor.putInt("chatMemberColor", AndroidUtilities.setDarkColor(i, 0x15)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java index 096ee461..cd3d9ce1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java @@ -83,6 +83,10 @@ public class ThemingChatActivity extends BaseFragment { private int memberColorRow; private int forwardNameColorRow; private int avatarRadiusRow; + private int bubblesRow; + private int avatarSizeRow; + private int avatarAlignTopRow; + private int avatarMarginLeftRow; private int rowCount; @@ -106,7 +110,10 @@ public class ThemingChatActivity extends BaseFragment { rowsSectionRow = rowCount++; rowsSection2Row = rowCount++; - avatarRadiusRow = rowCount++; + avatarRadiusRow = rowCount++; + avatarSizeRow = rowCount++; + avatarMarginLeftRow = rowCount++; + avatarAlignTopRow = rowCount++; textSizeRow = rowCount++; rTextColorRow = rowCount++; rLinkColorRow = rowCount++; @@ -121,6 +128,7 @@ public class ThemingChatActivity extends BaseFragment { dateSizeRow = rowCount++; dateColorRow = rowCount++; + bubblesRow = rowCount++; rBubbleColorRow = rowCount++; lBubbleColorRow = rowCount++; dateBubbleColorRow = rowCount++; @@ -224,6 +232,17 @@ public class ThemingChatActivity extends BaseFragment { if (listView != null) { listView.invalidateViews(); } + } else if (i == avatarAlignTopRow) { + boolean b = themePrefs.getBoolean( key, true); + SharedPreferences.Editor editor = themePrefs.edit(); + editor.putBoolean( key, !b); + editor.commit(); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(!b); + } + if (listView != null) { + listView.invalidateViews(); + } } else if (i == memberColorRow) { if (getParentActivity() == null) { return; @@ -529,7 +548,7 @@ public class ThemingChatActivity extends BaseFragment { commitInt("chatEmojiViewBGColor", color); } - },themePrefs.getInt("chatEmojiViewBGColor", 0xff222222), CENTER, 0, true); + },themePrefs.getInt("chatEmojiViewBGColor", 0xfff5f6f7), CENTER, 0, true); colorDialog.show(); } else if (i == emojiViewTabColorRow) { @@ -547,7 +566,7 @@ public class ThemingChatActivity extends BaseFragment { commitInt("chatEmojiViewTabColor", color); } - },themePrefs.getInt("chatEmojiViewTabColor", darkColor), CENTER, 0, true); + },themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor",-0x15)), CENTER, 0, true); colorDialog.show(); } else if (i == statusColorRow) { @@ -614,6 +633,48 @@ public class ThemingChatActivity extends BaseFragment { } }); showAlertDialog(builder); + } else if (i == avatarSizeRow) { + if (getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AvatarSize", R.string.AvatarSize)); + final NumberPicker numberPicker = new NumberPicker(getParentActivity()); + final int currentValue = themePrefs.getInt( key, 42); + numberPicker.setMinValue(1); + numberPicker.setMaxValue(56); + numberPicker.setValue(currentValue); + builder.setView(numberPicker); + builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (numberPicker.getValue() != currentValue) { + commitInt( key, numberPicker.getValue()); + } + } + }); + showAlertDialog(builder); + } else if (i == avatarMarginLeftRow) { + if (getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AvatarMarginLeft", R.string.AvatarMarginLeft)); + final NumberPicker numberPicker = new NumberPicker(getParentActivity()); + final int currentValue = themePrefs.getInt( key, 6); + numberPicker.setMinValue(0); + numberPicker.setMaxValue(12); + numberPicker.setValue(currentValue); + builder.setView(numberPicker); + builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (numberPicker.getValue() != currentValue) { + commitInt( key, numberPicker.getValue()); + } + } + }); + showAlertDialog(builder); } else if (i == nameSizeRow) { if (getParentActivity() == null) { return; @@ -745,6 +806,8 @@ public class ThemingChatActivity extends BaseFragment { } }); showAlertDialog(builder); + } else if (i == bubblesRow) { + presentFragment(new ImageListActivity()); } } }); @@ -879,7 +942,7 @@ public class ThemingChatActivity extends BaseFragment { return false; } }); - listView.setAdapter(listAdapter); + //listView.setAdapter(listAdapter); //actionBar.setBackgroundColor(AndroidUtilities.getIntColor("themeColor")); } @@ -897,8 +960,8 @@ public class ThemingChatActivity extends BaseFragment { @Override public boolean isEnabled(int i) { - return i == headerColorRow || i == muteColorRow || i == headerIconsColorRow || i == rBubbleColorRow || i == lBubbleColorRow || - i == avatarRadiusRow || i == nameColorRow || i == nameSizeRow || i == statusColorRow || i == statusSizeRow || + return i == headerColorRow || i == muteColorRow || i == headerIconsColorRow || i == rBubbleColorRow || i == lBubbleColorRow || i == bubblesRow || + i == avatarRadiusRow || i == avatarSizeRow || i == avatarMarginLeftRow || i == avatarAlignTopRow || i == nameColorRow || i == nameSizeRow || i == statusColorRow || i == statusSizeRow || i == textSizeRow || i == timeSizeRow || i == dateColorRow || i == dateSizeRow || i == dateBubbleColorRow || i == rTextColorRow || i == rLinkColorRow || i == lTextColorRow || i == lLinkColorRow || i == rTimeColorRow|| i == lTimeColorRow || i == checksColorRow || i == memberColorCheckRow || AndroidUtilities.getBoolPref("chatMemberColorCheck") && i == memberColorRow || i == forwardNameColorRow || i == editTextSizeRow || i == editTextColorRow || i == editTextIconsColorRow || i == sendColorRow || i == editTextBGColorRow || @@ -954,6 +1017,14 @@ public class ThemingChatActivity extends BaseFragment { textCell.setTag("chatAvatarRadius"); int size = themePrefs.getInt("chatAvatarRadius", AndroidUtilities.isTablet() ? 35 : 32); textCell.setTextAndValue(LocaleController.getString("AvatarRadius", R.string.AvatarRadius), String.format("%d", size), true); + } else if (i == avatarSizeRow) { + textCell.setTag("chatAvatarSize"); + int size = themePrefs.getInt("chatAvatarSize", AndroidUtilities.isTablet() ? 45 : 42); + textCell.setTextAndValue(LocaleController.getString("AvatarSize", R.string.AvatarSize), String.format("%d", size), true); + } else if (i == avatarMarginLeftRow) { + textCell.setTag("chatAvatarMarginLeft"); + int size = themePrefs.getInt("chatAvatarMarginLeft", 6); + textCell.setTextAndValue(LocaleController.getString("AvatarMarginLeft", R.string.AvatarMarginLeft), String.format("%d", size), true); } else if (i == nameSizeRow) { int size = themePrefs.getInt("chatNameSize", AndroidUtilities.isTablet() ? 20 : 18); textCell.setTextAndValue(LocaleController.getString("NameSize", R.string.NameSize), String.format("%d", size), true); @@ -972,6 +1043,9 @@ public class ThemingChatActivity extends BaseFragment { } else if (i == editTextSizeRow) { int size = themePrefs.getInt("chatEditTextSize", AndroidUtilities.isTablet() ? 20 : 18); textCell.setTextAndValue(LocaleController.getString("EditTextSize", R.string.EditTextSize), String.format("%d", size), true); + } else if (i == bubblesRow) { + String bStyle = themePrefs.getString("chatBubbleStyle", ImageListActivity.getBubbleName(0)); + textCell.setTextAndValue(LocaleController.getString("BubbleStyle", R.string.BubbleStyle), bStyle, true); } } else if (type == 4) { if (view == null) { @@ -981,6 +1055,9 @@ public class ThemingChatActivity extends BaseFragment { if (i == memberColorCheckRow) { textCell.setTag("chatMemberColorCheck"); textCell.setTextAndCheck(LocaleController.getString("SetMemberColor", R.string.SetMemberColor), themePrefs.getBoolean("chatMemberColorCheck", false), false); + } else if (i == avatarAlignTopRow) { + textCell.setTag("chatAvatarAlignTop"); + textCell.setTextAndCheck(LocaleController.getString("AvatarAlignTop", R.string.AvatarAlignTop), themePrefs.getBoolean("chatAvatarAlignTop", false), true); } } else if (type == 3){ @@ -1045,9 +1122,9 @@ public class ThemingChatActivity extends BaseFragment { textCell.setTag("chatEditTextIconsColor"); textCell.setTextAndColor(LocaleController.getString("EditTextIconsColor", R.string.EditTextIconsColor), themePrefs.getInt("chatEditTextIconsColor", 0xffadadad), true); } else if (i == emojiViewBGColorRow) { - textCell.setTextAndColor(LocaleController.getString("EmojiViewBGColor", R.string.EmojiViewBGColor), themePrefs.getInt("chatEmojiViewBGColor", 0xff222222), true); + textCell.setTextAndColor(LocaleController.getString("EmojiViewBGColor", R.string.EmojiViewBGColor), themePrefs.getInt("chatEmojiViewBGColor", 0xfff5f6f7), true); } else if (i == emojiViewTabColorRow) { - textCell.setTextAndColor(LocaleController.getString("EmojiViewTabColor", R.string.EmojiViewTabColor), themePrefs.getInt("chatEmojiViewTabColor", darkColor), true); + textCell.setTextAndColor(LocaleController.getString("EmojiViewTabColor", R.string.EmojiViewTabColor), themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor",-0x15)), true); } } return view; @@ -1061,7 +1138,7 @@ public class ThemingChatActivity extends BaseFragment { else if ( i == headerSection2Row || i == rowsSection2Row ) { return 1; } - else if ( i == avatarRadiusRow || i == nameSizeRow || i == statusSizeRow || i == textSizeRow || i == timeSizeRow || i == dateSizeRow || i == editTextSizeRow) { + else if ( i == avatarRadiusRow || i == avatarSizeRow || i == avatarMarginLeftRow || i == nameSizeRow || i == statusSizeRow || i == textSizeRow || i == timeSizeRow || i == dateSizeRow || i == editTextSizeRow || i == bubblesRow) { return 2; } @@ -1071,7 +1148,7 @@ public class ThemingChatActivity extends BaseFragment { i == sendColorRow || i == editTextColorRow || i == editTextBGColorRow || i == editTextIconsColorRow || i == emojiViewBGColorRow || i == emojiViewTabColorRow) { return 3; - } else if (i == memberColorCheckRow) { + } else if (i == memberColorCheckRow || i == avatarAlignTopRow) { return 4; } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java index 00a81129..17b1f277 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java @@ -79,6 +79,11 @@ public class ThemingChatsActivity extends BaseFragment { private int countBGColorRow; private int floatingPencilColorRow; private int floatingBGColorRow; + private int avatarSizeRow; + private int avatarMarginLeftRow; + private int unknownNameColorRow; + private int groupNameColorRow; + private int groupNameSizeRow; private int rowCount; @@ -100,9 +105,14 @@ public class ThemingChatsActivity extends BaseFragment { rowColorRow = rowCount++; dividerColorRow = rowCount++; - avatarRadiusRow = rowCount++; + avatarRadiusRow = rowCount++; + avatarSizeRow = rowCount++; + avatarMarginLeftRow = rowCount++; nameColorRow = rowCount++; + unknownNameColorRow = rowCount++; nameSizeRow = rowCount++; + groupNameColorRow = rowCount++; + groupNameSizeRow = rowCount++; muteColorRow = rowCount++; checksColorRow = rowCount++; @@ -296,7 +306,37 @@ public class ThemingChatsActivity extends BaseFragment { commitInt( key, color); } - },themePrefs.getInt( key, 0xff000000), CENTER, 0, false); + },themePrefs.getInt( key, 0xff212121), CENTER, 0, false); + + colorDialog.show(); + } else if (i == groupNameColorRow) { + if (getParentActivity() == null) { + return; + } + LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + li.inflate(R.layout.colordialog, null, false); + ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { + @Override + public void colorChanged(int color) { + commitInt( key, color); + } + + },themePrefs.getInt( key, themePrefs.getInt("chatsNameColor", 0xff212121)), CENTER, 0, false); + + colorDialog.show(); + } else if (i == unknownNameColorRow) { + if (getParentActivity() == null) { + return; + } + LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + li.inflate(R.layout.colordialog, null, false); + ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { + @Override + public void colorChanged(int color) { + commitInt( key, color); + } + + },themePrefs.getInt( key, themePrefs.getInt("chatsNameColor", 0xff212121)), CENTER, 0, false); colorDialog.show(); } else if (i == muteColorRow) { @@ -436,6 +476,52 @@ public class ThemingChatsActivity extends BaseFragment { } }); + showAlertDialog(builder); + } else if (i == avatarSizeRow) { + if (getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AvatarSize", R.string.AvatarSize)); + final NumberPicker numberPicker = new NumberPicker(getParentActivity()); + final int currentValue = themePrefs.getInt( key, 52); + numberPicker.setMinValue(1); + numberPicker.setMaxValue(72); + numberPicker.setValue(currentValue); + builder.setView(numberPicker); + + builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (numberPicker.getValue() != currentValue) { + commitInt( key, numberPicker.getValue()); + } + } + }); + + showAlertDialog(builder); + } else if (i == avatarMarginLeftRow) { + if (getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AvatarMarginLeft", R.string.AvatarMarginLeft)); + final NumberPicker numberPicker = new NumberPicker(getParentActivity()); + final int currentValue = themePrefs.getInt( key, AndroidUtilities.isTablet() ? 13 : 9); + numberPicker.setMinValue(0); + numberPicker.setMaxValue(18); + numberPicker.setValue(currentValue); + builder.setView(numberPicker); + + builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (numberPicker.getValue() != currentValue) { + commitInt( key, numberPicker.getValue()); + } + } + }); + showAlertDialog(builder); } else if (i == nameSizeRow) { if (getParentActivity() == null) { @@ -463,6 +549,28 @@ public class ThemingChatsActivity extends BaseFragment { //btn.setTextColor(0xff0000ff); showAlertDialog(builder); + } else if (i == groupNameSizeRow) { + if (getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("GroupNameSize", R.string.GroupNameSize)); + final NumberPicker numberPicker = new NumberPicker(getParentActivity()); + final int currentValue = themePrefs.getInt( key, themePrefs.getInt("chatsNameSize", 17)); + numberPicker.setMinValue(12); + numberPicker.setMaxValue(30); + numberPicker.setValue(currentValue); + builder.setView(numberPicker); + builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (numberPicker.getValue() != currentValue) { + commitInt( key, numberPicker.getValue()); + } + } + }).create(); + showAlertDialog(builder); + } else if (i == messageSizeRow) { if (getParentActivity() == null) { return; @@ -521,7 +629,7 @@ public class ThemingChatsActivity extends BaseFragment { @Override public void onClick(DialogInterface dialog, int which) { if (numberPicker.getValue() != currentValue) { - commitInt( key, numberPicker.getValue()); + commitInt(key, numberPicker.getValue()); } } }); @@ -647,8 +755,8 @@ public class ThemingChatsActivity extends BaseFragment { @Override public boolean isEnabled(int i) { return i == headerColorRow || i == headerTitleColorRow || i == headerIconsColorRow || i == headerTitleRow || - i == rowColorRow || i == dividerColorRow || i == avatarRadiusRow || - i == nameColorRow || i == muteColorRow || i == checksColorRow || i == nameSizeRow || i == messageColorRow || i == memberColorRow || i == typingColorRow || i == messageSizeRow || + i == rowColorRow || i == dividerColorRow || i == avatarRadiusRow || i == avatarSizeRow || i == avatarMarginLeftRow || + i == nameColorRow || i == groupNameColorRow || i == unknownNameColorRow || i == muteColorRow || i == checksColorRow || i == nameSizeRow || i == groupNameSizeRow || i == messageColorRow || i == memberColorRow || i == typingColorRow || i == messageSizeRow || i == timeColorRow || i == timeSizeRow || i == countColorRow || i == countSizeRow || i == countBGColorRow || i == floatingPencilColorRow || i == floatingBGColorRow; } @@ -701,10 +809,22 @@ public class ThemingChatsActivity extends BaseFragment { textCell.setTag("chatsAvatarRadius"); int size = themePrefs.getInt("chatsAvatarRadius", AndroidUtilities.isTablet() ? 35 : 32); textCell.setTextAndValue(LocaleController.getString("AvatarRadius", R.string.AvatarRadius), String.format("%d", size), true); + } else if (i == avatarSizeRow) { + textCell.setTag("chatsAvatarSize"); + int size = themePrefs.getInt("chatsAvatarSize", AndroidUtilities.isTablet() ? 55 : 52); + textCell.setTextAndValue(LocaleController.getString("AvatarSize", R.string.AvatarSize), String.format("%d", size), true); + } else if (i == avatarMarginLeftRow) { + textCell.setTag("chatsAvatarMarginLeft"); + int size = themePrefs.getInt("chatsAvatarMarginLeft", AndroidUtilities.isTablet() ? 13 : 9); + textCell.setTextAndValue(LocaleController.getString("AvatarMarginLeft", R.string.AvatarMarginLeft), String.format("%d", size), true); } else if (i == nameSizeRow) { textCell.setTag("chatsNameSize"); int size = themePrefs.getInt("chatsNameSize", AndroidUtilities.isTablet() ? 19 : 17); textCell.setTextAndValue(LocaleController.getString("NameSize", R.string.NameSize), String.format("%d", size), true); + } else if (i == groupNameSizeRow) { + textCell.setTag("chatsGroupNameSize"); + int size = themePrefs.getInt("chatsGroupNameSize", themePrefs.getInt("chatsNameSize", AndroidUtilities.isTablet() ? 19 : 17)); + textCell.setTextAndValue(LocaleController.getString("GroupNameSize", R.string.GroupNameSize), String.format("%d", size), true); } else if (i == messageSizeRow) { textCell.setTag("chatsMessageSize"); int size = themePrefs.getInt("chatsMessageSize", AndroidUtilities.isTablet() ? 18 : 16); @@ -743,7 +863,13 @@ public class ThemingChatsActivity extends BaseFragment { textCell.setTextAndColor(LocaleController.getString("DividerColor", R.string.DividerColor), themePrefs.getInt("chatsDividerColor", 0xffdcdcdc), true); } else if (i == nameColorRow) { textCell.setTag("chatsNameColor"); - textCell.setTextAndColor(LocaleController.getString("NameColor", R.string.NameColor), themePrefs.getInt("chatsNameColor", 0xff000000), true); + textCell.setTextAndColor(LocaleController.getString("NameColor", R.string.NameColor), themePrefs.getInt("chatsNameColor", 0xff212121), true); + } else if (i == groupNameColorRow) { + textCell.setTag("chatsGroupNameColor"); + textCell.setTextAndColor(LocaleController.getString("GroupNameColor", R.string.GroupNameColor), themePrefs.getInt("chatsGroupNameColor", themePrefs.getInt("chatsNameColor", 0xff212121)), true); + } else if (i == unknownNameColorRow) { + textCell.setTag("chatsUnknownNameColor"); + textCell.setTextAndColor(LocaleController.getString("UnknownNameColor", R.string.UnknownNameColor), themePrefs.getInt("chatsUnknownNameColor", themePrefs.getInt("chatsNameColor", 0xff212121)), true); } else if (i == muteColorRow) { textCell.setTag("chatsMuteColor"); textCell.setTextAndColor(LocaleController.getString("MuteColor", R.string.MuteColor), themePrefs.getInt("chatsMuteColor", 0xffa8a8a8), true); @@ -806,15 +932,15 @@ public class ThemingChatsActivity extends BaseFragment { text = "-"; } if (value == 0) { - textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), LocaleController.getString("AppName", R.string.AppName), false); + textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), LocaleController.getString("AppName", R.string.AppName), true); } else if (value == 1) { - textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), LocaleController.getString("ShortAppName", R.string.ShortAppName), false); + textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), LocaleController.getString("ShortAppName", R.string.ShortAppName), true); } else if (value == 2) { - textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), ContactsController.formatName(user.first_name, user.last_name), false); + textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), ContactsController.formatName(user.first_name, user.last_name), true); } else if (value == 3) { - textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), text, false); + textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), text, true); } else if (value == 4) { - textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), "", false); + textCell.setTextAndValue(LocaleController.getString("HeaderTitle", R.string.HeaderTitle), "", true); } } } @@ -827,10 +953,10 @@ public class ThemingChatsActivity extends BaseFragment { return 0; } else if ( i == headerSection2Row || i == rowsSection2Row ) { return 1; - } else if ( i == avatarRadiusRow || i == nameSizeRow || i == messageSizeRow || i == timeSizeRow || i == countSizeRow ) { + } else if ( i == avatarRadiusRow || i == avatarSizeRow || i == avatarMarginLeftRow || i == nameSizeRow || i == groupNameSizeRow || i == messageSizeRow || i == timeSizeRow || i == countSizeRow ) { return 2; } else if ( i == headerColorRow || i == headerTitleColorRow || i == headerIconsColorRow || - i == rowColorRow || i == dividerColorRow || i == nameColorRow || i == muteColorRow || i == checksColorRow || i == messageColorRow || i == memberColorRow || i == typingColorRow || i == timeColorRow || i == countColorRow || + i == rowColorRow || i == dividerColorRow || i == nameColorRow || i == groupNameColorRow || i == unknownNameColorRow || i == muteColorRow || i == checksColorRow || i == messageColorRow || i == memberColorRow || i == typingColorRow || i == timeColorRow || i == countColorRow || i == countBGColorRow || i == floatingPencilColorRow || i == floatingBGColorRow) { return 3; }/* else if (i == usernameTitleRow) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java index e0ecda6f..aa3d555f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java @@ -46,6 +46,9 @@ public class ThemingContactsActivity extends BaseFragment { private int headerSection2Row; private int headerColorRow; + private int headerTitleColorRow; + private int headerIconsColorRow; + private int rowsSectionRow; private int rowsSection2Row; private int rowColorRow; @@ -67,6 +70,8 @@ public class ThemingContactsActivity extends BaseFragment { rowCount = 0; headerSection2Row = rowCount++; headerColorRow = rowCount++; + headerTitleColorRow = rowCount++; + headerIconsColorRow = rowCount++; rowsSectionRow = rowCount++; rowsSection2Row = rowCount++; @@ -138,9 +143,7 @@ public class ThemingContactsActivity extends BaseFragment { } LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - view = li.inflate(R.layout.colordialog, null, false); - + li.inflate(R.layout.colordialog, null, false); ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { @Override public void colorChanged(int color) { @@ -148,17 +151,39 @@ public class ThemingContactsActivity extends BaseFragment { } },themePrefs.getInt("contactsHeaderColor", AndroidUtilities.getIntColor("themeColor")), CENTER, 0, false); - + colorDialog.show(); + } else if (i == headerTitleColorRow) { + if (getParentActivity() == null) { + return; + } + LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + li.inflate(R.layout.colordialog, null, false); + ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { + @Override + public void colorChanged(int color) { + commitInt( "contactsHeaderTitleColor", color); + } + },themePrefs.getInt( "contactsHeaderTitleColor", 0xffffffff), CENTER, 0, false); + colorDialog.show(); + } else if (i == headerIconsColorRow) { + if (getParentActivity() == null) { + return; + } + LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + li.inflate(R.layout.colordialog, null, false); + ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { + @Override + public void colorChanged(int color) { + commitInt( "contactsHeaderIconsColor", color); + } + },themePrefs.getInt( "contactsHeaderIconsColor", 0xffffffff), CENTER, 0, false); colorDialog.show(); } else if (i == rowColorRow) { if (getParentActivity() == null) { return; } - LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - view = li.inflate(R.layout.colordialog, null, false); - + li.inflate(R.layout.colordialog, null, false); ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { @Override public void colorChanged(int color) { @@ -166,17 +191,13 @@ public class ThemingContactsActivity extends BaseFragment { } },themePrefs.getInt("contactsRowColor", 0xffffffff), CENTER, 0, false); - colorDialog.show(); } else if (i == nameColorRow) { if (getParentActivity() == null) { return; } - LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - view = li.inflate(R.layout.colordialog, null, false); - + li.inflate(R.layout.colordialog, null, false); ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { @Override public void colorChanged(int color) { @@ -184,14 +205,13 @@ public class ThemingContactsActivity extends BaseFragment { } },themePrefs.getInt("contactsNameColor", 0xff000000), CENTER, 0, false); - colorDialog.show(); } else if (i == statusColorRow) { if (getParentActivity() == null) { return; } LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.colordialog, null, false); + li.inflate(R.layout.colordialog, null, false); ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { @Override public void colorChanged(int color) { @@ -199,20 +219,18 @@ public class ThemingContactsActivity extends BaseFragment { } },themePrefs.getInt("contactsStatusColor", 0xffa8a8a8), CENTER, 0, false); - colorDialog.show(); } else if (i == onlineColorRow) { if (getParentActivity() == null) { return; } LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.colordialog, null, false); + li.inflate(R.layout.colordialog, null, false); ColorSelectorDialog colorDialog = new ColorSelectorDialog(getParentActivity(), new OnColorChangedListener() { @Override public void colorChanged(int color) { commitInt("contactsOnlineColor", color); } - },themePrefs.getInt("contactsOnlineColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15)), CENTER, 0, false); colorDialog.show(); } else if (i == avatarRadiusRow) { @@ -290,6 +308,10 @@ public class ThemingContactsActivity extends BaseFragment { } if (i == headerColorRow) { resetInt("contactsHeaderColor"); + } else if (i == headerTitleColorRow) { + resetInt("contactsHeaderTitleColor"); + } else if (i == headerIconsColorRow) { + resetInt("contactsHeaderIconsColor"); } else if (i == rowColorRow) { resetInt("contactsRowColor"); } else if (i == avatarRadiusRow) { @@ -386,7 +408,7 @@ public class ThemingContactsActivity extends BaseFragment { @Override public boolean isEnabled(int i) { - return i == headerColorRow || i == rowColorRow || i == avatarRadiusRow || i == nameColorRow || i == nameSizeRow || i == statusColorRow || i == statusSizeRow || + return i == headerColorRow || i == headerTitleColorRow || i == headerIconsColorRow || i == rowColorRow || i == avatarRadiusRow || i == nameColorRow || i == nameSizeRow || i == statusColorRow || i == statusSizeRow || i == onlineColorRow ; } @@ -456,6 +478,10 @@ public class ThemingContactsActivity extends BaseFragment { if (i == headerColorRow) { textCell.setTextAndColor(LocaleController.getString("HeaderColor", R.string.HeaderColor), themePrefs.getInt("contactsHeaderColor", AndroidUtilities.getIntColor("themeColor")), true); + } else if (i == headerTitleColorRow) { + textCell.setTextAndColor(LocaleController.getString("HeaderTitleColor", R.string.HeaderTitleColor), themePrefs.getInt("contactsHeaderTitleColor", 0xffffffff), true); + } else if (i == headerIconsColorRow) { + textCell.setTextAndColor(LocaleController.getString("HeaderIconsColor", R.string.HeaderIconsColor), themePrefs.getInt("contactsHeaderIconsColor", 0xffffffff), true); } else if (i == rowColorRow) { textCell.setTextAndColor(LocaleController.getString("RowColor", R.string.RowColor), themePrefs.getInt("contactsRowColor", 0xffffffff), true); } else if (i == nameColorRow) { @@ -481,7 +507,7 @@ public class ThemingContactsActivity extends BaseFragment { return 2; } - else if ( i == headerColorRow || i == rowColorRow || i == nameColorRow || i == statusColorRow || i == onlineColorRow) { + else if ( i == headerColorRow || i == headerTitleColorRow || i == headerIconsColorRow || i == rowColorRow || i == nameColorRow || i == statusColorRow || i == onlineColorRow) { return 3; } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java index 7121d0a4..1c794ab9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java @@ -51,6 +51,7 @@ import org.telegram.messenger.Utilities; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.VideoSeekBarView; import org.telegram.ui.Components.VideoTimelineView; @@ -611,7 +612,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) videoContainerView.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(16); layoutParams.bottomMargin = AndroidUtilities.dp(260 + (compressVideo.getVisibility() == View.VISIBLE ? 20 : 0)); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = 0; videoContainerView.setLayoutParams(layoutParams); @@ -619,12 +620,12 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur layoutParams.topMargin = 0; layoutParams.leftMargin = 0; layoutParams.bottomMargin = AndroidUtilities.dp(150 + (compressVideo.getVisibility() == View.VISIBLE ? 20 : 0)); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.BOTTOM; controlView.setLayoutParams(layoutParams); layoutParams = (FrameLayout.LayoutParams) textContainerView.getLayoutParams(); - layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; + layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.rightMargin = AndroidUtilities.dp(16); layoutParams.bottomMargin = AndroidUtilities.dp(16); diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel1.png b/TMessagesProj/src/main/res/drawable-hdpi/audiocancel1.png deleted file mode 100755 index 7f5b6896..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel1_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/audiocancel1_pressed.png deleted file mode 100755 index 8963b712..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel2.png b/TMessagesProj/src/main/res/drawable-hdpi/audiocancel2.png deleted file mode 100755 index aad25e8e..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel2_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/audiocancel2_pressed.png deleted file mode 100755 index 9bdc31ef..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audiocancel2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audioload1.png b/TMessagesProj/src/main/res/drawable-hdpi/audioload1.png deleted file mode 100755 index 1eecb03d..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audioload1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audioload1_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/audioload1_pressed.png deleted file mode 100755 index 854fe27a..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audioload1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audioload2.png b/TMessagesProj/src/main/res/drawable-hdpi/audioload2.png deleted file mode 100755 index 9dc1787a..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audioload2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/audioload2_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/audioload2_pressed.png deleted file mode 100755 index feab040a..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/audioload2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bg_emoji_bs.9.png b/TMessagesProj/src/main/res/drawable-hdpi/bg_emoji_bs.9.png deleted file mode 100644 index a90f085c..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/bg_emoji_bs.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge_white.9.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge_white.9.png deleted file mode 100644 index bfb893a5..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge_white.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_check_white.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_check_white.png deleted file mode 100644 index 6fdce764..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_check_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_halfcheck_white.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_halfcheck_white.png deleted file mode 100644 index 76576b61..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_halfcheck_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_location.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_location.png deleted file mode 100755 index 9f11eace..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_location.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace.png index 91730395..50c5312f 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace_active.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace_active.png index 2fa81879..b02ed7c2 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace_active.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_backspace_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell.png index d018c173..a7a2cffb 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell_active.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell_active.png index 98c7f66c..14cc9aed 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell_active.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_bell_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car.png index 449b32b4..b8fa468a 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car_active.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car_active.png index 3f03ef73..7436b560 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car_active.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_car_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower.png index 8f190cb4..b70bcd45 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower_active.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower_active.png index ca9dd974..bd783f40 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower_active.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_flower_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid.png index ed02b9a1..f311de53 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid_active.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid_active.png index 4b1f8686..2d020da1 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid_active.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_grid_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent.png index 6d032d62..3208bcec 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent_active.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent_active.png index 756df919..bbf721b8 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent_active.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_recent_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile.png index 70ee89c2..2d98101f 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile_active.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile_active.png index 078f863b..d37ab098 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile_active.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_smiles_smile_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/list_broadcast_white.png b/TMessagesProj/src/main/res/drawable-hdpi/list_broadcast_white.png deleted file mode 100644 index 6e354f3c..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/list_broadcast_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/list_group_white.png b/TMessagesProj/src/main/res/drawable-hdpi/list_group_white.png deleted file mode 100644 index a9cfa9bb..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/list_group_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/list_secret_white.png b/TMessagesProj/src/main/res/drawable-hdpi/list_secret_white.png deleted file mode 100644 index e2615cea..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/list_secret_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause1.png b/TMessagesProj/src/main/res/drawable-hdpi/pause1.png deleted file mode 100755 index 30e945f3..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause1_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/pause1_pressed.png deleted file mode 100755 index 0053b7b0..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause2.png b/TMessagesProj/src/main/res/drawable-hdpi/pause2.png deleted file mode 100755 index f96f878e..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause2_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/pause2_pressed.png deleted file mode 100755 index c3bca631..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photo_crop.png b/TMessagesProj/src/main/res/drawable-hdpi/photo_crop.png index facaf39e..aa78fee8 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/photo_crop.png and b/TMessagesProj/src/main/res/drawable-hdpi/photo_crop.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photo_edit.png b/TMessagesProj/src/main/res/drawable-hdpi/photo_edit.png deleted file mode 100644 index 8768155c..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/photo_edit.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play1.png b/TMessagesProj/src/main/res/drawable-hdpi/play1.png deleted file mode 100755 index 8bb953bc..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play1_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/play1_pressed.png deleted file mode 100755 index d5d22025..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play2.png b/TMessagesProj/src/main/res/drawable-hdpi/play2.png deleted file mode 100755 index 775a87a6..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play2_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/play2_pressed.png deleted file mode 100755 index 08e69198..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/selector_orange_gradient.xml b/TMessagesProj/src/main/res/drawable-hdpi/selector_orange_gradient.xml deleted file mode 100644 index 8d11da8d..00000000 --- a/TMessagesProj/src/main/res/drawable-hdpi/selector_orange_gradient.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-hdpi/tune.png b/TMessagesProj/src/main/res/drawable-hdpi/tune.png deleted file mode 100644 index ab404e6a..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/tune.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel1.png b/TMessagesProj/src/main/res/drawable-mdpi/audiocancel1.png deleted file mode 100755 index 3ec69979..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel1_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/audiocancel1_pressed.png deleted file mode 100755 index 81b12fca..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel2.png b/TMessagesProj/src/main/res/drawable-mdpi/audiocancel2.png deleted file mode 100755 index f626dd95..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel2_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/audiocancel2_pressed.png deleted file mode 100755 index 2129a26c..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audiocancel2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audioload1.png b/TMessagesProj/src/main/res/drawable-mdpi/audioload1.png deleted file mode 100755 index e06d062f..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audioload1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audioload1_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/audioload1_pressed.png deleted file mode 100755 index 96774c41..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audioload1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audioload2.png b/TMessagesProj/src/main/res/drawable-mdpi/audioload2.png deleted file mode 100755 index cad0562f..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audioload2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/audioload2_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/audioload2_pressed.png deleted file mode 100755 index b1c3c6c0..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/audioload2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bg_emoji_bs.9.png b/TMessagesProj/src/main/res/drawable-mdpi/bg_emoji_bs.9.png deleted file mode 100644 index 1d6f546b..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/bg_emoji_bs.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge_white.9.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge_white.9.png deleted file mode 100644 index 2391e2ba..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge_white.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_check_white.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_check_white.png deleted file mode 100644 index 6880468f..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_check_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_halfcheck_white.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_halfcheck_white.png deleted file mode 100644 index ec0e2099..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_halfcheck_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_location.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_location.png deleted file mode 100755 index 19fc6d1c..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_location.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace.png index 76076a60..d63ba596 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace_active.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace_active.png index 23bbc4b8..45140c69 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace_active.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_backspace_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell.png index 1242d7dc..8807b989 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell_active.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell_active.png index 647f8453..6536bc7b 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell_active.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_bell_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car.png index 4c9d24fc..e52411af 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car_active.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car_active.png index f52038ef..360b8e85 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car_active.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_car_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower.png index aece4176..867f5b3f 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower_active.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower_active.png index 26026ef5..53c890bc 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower_active.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_flower_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid.png index 3d8934c0..84420661 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid_active.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid_active.png index 6bea9c24..92657666 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid_active.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_grid_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent.png index 41d6f8a2..d306da4f 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent_active.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent_active.png index 0f8caad5..c208b675 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent_active.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_recent_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile.png index 9b7c59f8..eb7c383d 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile_active.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile_active.png index f6217695..1de2e16a 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile_active.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_smiles_smile_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/list_broadcast_white.png b/TMessagesProj/src/main/res/drawable-mdpi/list_broadcast_white.png deleted file mode 100644 index 73811338..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/list_broadcast_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/list_group_white.png b/TMessagesProj/src/main/res/drawable-mdpi/list_group_white.png deleted file mode 100644 index 5b856c54..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/list_group_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/list_secret_white.png b/TMessagesProj/src/main/res/drawable-mdpi/list_secret_white.png deleted file mode 100644 index 371e8ff0..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/list_secret_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause1.png b/TMessagesProj/src/main/res/drawable-mdpi/pause1.png deleted file mode 100755 index 35570d84..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause1_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/pause1_pressed.png deleted file mode 100755 index 557cac12..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause2.png b/TMessagesProj/src/main/res/drawable-mdpi/pause2.png deleted file mode 100755 index 50f4366d..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause2_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/pause2_pressed.png deleted file mode 100755 index 50305fea..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photo_crop.png b/TMessagesProj/src/main/res/drawable-mdpi/photo_crop.png index 103f1c26..9133959b 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/photo_crop.png and b/TMessagesProj/src/main/res/drawable-mdpi/photo_crop.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photo_edit.png b/TMessagesProj/src/main/res/drawable-mdpi/photo_edit.png deleted file mode 100644 index 437baede..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/photo_edit.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play1.png b/TMessagesProj/src/main/res/drawable-mdpi/play1.png deleted file mode 100755 index 25cee312..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play1_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/play1_pressed.png deleted file mode 100755 index 124eb247..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play2.png b/TMessagesProj/src/main/res/drawable-mdpi/play2.png deleted file mode 100755 index 9d5a7c90..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play2_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/play2_pressed.png deleted file mode 100755 index 52ce6337..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/tune.png b/TMessagesProj/src/main/res/drawable-mdpi/tune.png deleted file mode 100644 index 633d4b02..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/tune.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel1.png b/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel1.png deleted file mode 100755 index 9a589b40..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel1_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel1_pressed.png deleted file mode 100755 index 40588216..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel2.png b/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel2.png deleted file mode 100755 index 8af79528..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel2_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel2_pressed.png deleted file mode 100755 index b5ca6b6e..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audiocancel2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audioload1.png b/TMessagesProj/src/main/res/drawable-xhdpi/audioload1.png deleted file mode 100755 index 48db9f06..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audioload1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audioload1_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/audioload1_pressed.png deleted file mode 100755 index 48db9f06..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audioload1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audioload2.png b/TMessagesProj/src/main/res/drawable-xhdpi/audioload2.png deleted file mode 100755 index 02dbe77b..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audioload2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/audioload2_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/audioload2_pressed.png deleted file mode 100755 index 434cc9d2..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/audioload2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bg_emoji_bs.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/bg_emoji_bs.9.png deleted file mode 100644 index 54c8f9ac..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/bg_emoji_bs.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge_white.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge_white.9.png deleted file mode 100644 index 8dba389e..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge_white.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_check_white.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_check_white.png deleted file mode 100644 index 4e55d2f3..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_check_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_halfcheck_white.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_halfcheck_white.png deleted file mode 100644 index e2a475fa..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_halfcheck_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_location.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_location.png deleted file mode 100755 index ebc61a53..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_location.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace.png index 561f125e..3d4d64c1 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace_active.png index 204a9ee4..6f76811c 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace_active.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_backspace_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell.png index d299db86..faad8989 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell_active.png index 075fc5fa..ebdb0c9e 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell_active.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_bell_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car.png index 0c8519f1..5d312c39 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car_active.png index 3bae05c0..152f0c1b 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car_active.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_car_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower.png index c5643d4f..c9e2a36a 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower_active.png index fc5082c7..d9565480 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower_active.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_flower_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid.png index 550d0016..aae876d0 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid_active.png index 4d3758fc..ea933847 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid_active.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_grid_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent.png index 69f4c19a..aa1b12a7 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent_active.png index 9b270fc3..950176fd 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent_active.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_recent_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile.png index e367ee69..0f94a602 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile_active.png index cc7b338e..6b883ef6 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile_active.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_smiles_smile_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/list_broadcast_white.png b/TMessagesProj/src/main/res/drawable-xhdpi/list_broadcast_white.png deleted file mode 100644 index 02e98068..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/list_broadcast_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/list_group_white.png b/TMessagesProj/src/main/res/drawable-xhdpi/list_group_white.png deleted file mode 100644 index 7b648b2d..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/list_group_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/list_secret_white.png b/TMessagesProj/src/main/res/drawable-xhdpi/list_secret_white.png deleted file mode 100644 index 70e46939..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/list_secret_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause1.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause1.png deleted file mode 100755 index 5a0abe48..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause1_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause1_pressed.png deleted file mode 100755 index 799a2314..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause2.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause2.png deleted file mode 100755 index 973b1675..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause2_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause2_pressed.png deleted file mode 100755 index 09e75bb8..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photo_crop.png b/TMessagesProj/src/main/res/drawable-xhdpi/photo_crop.png index d69c3c12..312b5654 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/photo_crop.png and b/TMessagesProj/src/main/res/drawable-xhdpi/photo_crop.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photo_edit.png b/TMessagesProj/src/main/res/drawable-xhdpi/photo_edit.png deleted file mode 100644 index 33176600..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/photo_edit.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play1.png b/TMessagesProj/src/main/res/drawable-xhdpi/play1.png deleted file mode 100755 index 442474da..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play1_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/play1_pressed.png deleted file mode 100755 index 9391b98f..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play2.png b/TMessagesProj/src/main/res/drawable-xhdpi/play2.png deleted file mode 100755 index a2bf525b..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play2_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/play2_pressed.png deleted file mode 100755 index 164ff9e1..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/tune.png b/TMessagesProj/src/main/res/drawable-xhdpi/tune.png deleted file mode 100644 index c6d6b9c7..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/tune.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel1.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel1.png deleted file mode 100755 index c7f705a6..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel1_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel1_pressed.png deleted file mode 100755 index ba16d325..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel2.png deleted file mode 100755 index ff6cb681..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel2_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel2_pressed.png deleted file mode 100755 index cc9f56b1..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audiocancel2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload1.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audioload1.png deleted file mode 100755 index 15b9c021..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload1_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audioload1_pressed.png deleted file mode 100755 index 3465e6e6..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audioload2.png deleted file mode 100755 index 4699e159..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload2_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/audioload2_pressed.png deleted file mode 100755 index c206870f..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/audioload2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge_white.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge_white.9.png deleted file mode 100644 index 7774832c..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge_white.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_check_white.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_check_white.png deleted file mode 100644 index 0560c926..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_check_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_halfcheck_white.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_halfcheck_white.png deleted file mode 100644 index 8da07186..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_halfcheck_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/docload_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/docload_g.png index 6b5f8bc4..5da89c78 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/docload_g.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/docload_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_location.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_location.png deleted file mode 100755 index 814bc8bd..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_location.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace.png index 83d82261..8580a8b6 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace_active.png index 6a190023..eb046dea 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace_active.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_backspace_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell.png index e155c18e..bcd04f99 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell_active.png index 34be89d5..701047dc 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell_active.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_bell_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car.png index 9b5299f1..430ef934 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car_active.png index 03b0b765..8568ffb2 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car_active.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_car_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower.png index 0843eb94..63ba2bce 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower_active.png index ed10b136..852144ab 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower_active.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_flower_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid.png index 73e324c4..c701d312 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid_active.png index de877ff8..dc60847b 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid_active.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_grid_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent.png index 9f377826..d08b38cd 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent_active.png index 232d5254..34fe4ff4 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent_active.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_recent_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile.png index c473c122..0e8515a1 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile_active.png index 1981d0c7..36dff761 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile_active.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_smiles_smile_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/list_broadcast_white.png b/TMessagesProj/src/main/res/drawable-xxhdpi/list_broadcast_white.png deleted file mode 100644 index c1a16839..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/list_broadcast_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/list_group_white.png b/TMessagesProj/src/main/res/drawable-xxhdpi/list_group_white.png deleted file mode 100644 index 85db5a9a..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/list_group_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/list_secret_white.png b/TMessagesProj/src/main/res/drawable-xxhdpi/list_secret_white.png deleted file mode 100644 index 5f970753..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/list_secret_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause1.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause1.png deleted file mode 100755 index 9293c448..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause1_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause1_pressed.png deleted file mode 100755 index e86f91f9..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause2.png deleted file mode 100755 index d18cf420..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause2_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause2_pressed.png deleted file mode 100755 index f7259a31..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_crop.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photo_crop.png index 460fdb38..1276ad18 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_crop.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/photo_crop.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_edit.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photo_edit.png deleted file mode 100644 index 6df74a5b..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_edit.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play1.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play1.png deleted file mode 100755 index 1c0924fd..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play1_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play1_pressed.png deleted file mode 100755 index 51642f67..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play2.png deleted file mode 100755 index d34c3037..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play2_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play2_pressed.png deleted file mode 100755 index cff0cf08..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/tune.png b/TMessagesProj/src/main/res/drawable-xxhdpi/tune.png deleted file mode 100644 index eda3e5a3..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/tune.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable/background_tab.xml b/TMessagesProj/src/main/res/drawable/background_tab.xml deleted file mode 100755 index 885cf036..00000000 --- a/TMessagesProj/src/main/res/drawable/background_tab.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml b/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml index 0346dc27..41ea5b77 100644 --- a/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml +++ b/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml @@ -1,10 +1,11 @@ - - - - + + + + + + diff --git a/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml b/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml index 5c3d5716..17b59fd6 100644 --- a/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml +++ b/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml @@ -2,15 +2,12 @@ + android:exitFadeDuration="300"> + android:drawable="@drawable/ic_smiles_bell_active"> + android:drawable="@drawable/ic_smiles_bell"> diff --git a/TMessagesProj/src/main/res/layout-ar/location_view_layout.xml b/TMessagesProj/src/main/res/layout-ar/location_view_layout.xml deleted file mode 100644 index a39c6a5e..00000000 --- a/TMessagesProj/src/main/res/layout-ar/location_view_layout.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - \ 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 index 9576e591..9c9329f6 100644 --- a/TMessagesProj/src/main/res/layout/document_select_layout.xml +++ b/TMessagesProj/src/main/res/layout/document_select_layout.xml @@ -4,8 +4,8 @@ android:layout_height="match_parent"> - + android:layout_width="match_parent" + android:layout_height="match_parent"> - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/location_view_layout.xml b/TMessagesProj/src/main/res/layout/location_view_layout.xml deleted file mode 100644 index d89e26eb..00000000 --- a/TMessagesProj/src/main/res/layout/location_view_layout.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/popup_count_layout.xml b/TMessagesProj/src/main/res/layout/popup_count_layout.xml index 1593006a..6011dc4c 100644 --- a/TMessagesProj/src/main/res/layout/popup_count_layout.xml +++ b/TMessagesProj/src/main/res/layout/popup_count_layout.xml @@ -5,7 +5,7 @@ + android:layout_width="match_parent" + android:layout_height="match_parent"> @@ -19,7 +19,7 @@ android:layout_marginBottom="52dp"/> %1$s يقوم بإرسال صورة... %1$s يقوم بإرسال مقطع مرئي... %1$s يقوم بإرسال ملف... + جاري تسجيل المقطع الصوتي... + جاري إرسال الصورة... + جاري إرسال المقطع المرئي... + جاري إرسال الملف... هل يوجد لديك سؤال\nحول تيليجرام؟ التقط صورة صورة @@ -157,6 +161,7 @@ %1$s قام بالتسجيل في تيليجرام! %1$s,\nتم تسجيل الدخول لحسابك من جهاز جديد يوم %2$s\n\nالجهاز: %3$s\nالموقع: %4$s\n\nإذا لم يكن أنت من سجل الدخول، يمكنك الذهاب للإعدادات ثم تسجيل الخروج من كافة الأجهزة الأخرى. كما يمكنك تفعيل التحقق بخطوتين إذا رغبت بذلك عن طريق إعدادات الخصوصية.\n\nشكرًا,\nفريق عمل تيليجرام %1$s قام بتغيير صورته الشخصية + %1$s قام بالدخول للمجموعة %2$s باستخدام رابط الدعوة الرد الرد على %1$s الرد على %1$s @@ -182,6 +187,19 @@ أدخل اسم للمجموعة اسم المجموعة %1$d/%2$d عضو + هل ترغب في الدخول للمجموعة \'%1$s\'؟ + المعذرة، هذه المجموعة ممتلئة. + المعذرة، هذه المجموعة غير موجودة. + تم نسخ الرابط إلى الحافظة + قم بدعوة للمجموعة باستخدام رابط + رابط دعوة + هل أنت متأكد من رغبتك في إلغاء رابط الدعوة؟ إذا قمت بذلك، لن يستطيع أحد من استخدامه للدخول للمجموعة. + رابط الدعوة السابق لا يعمل الآن. سيتم إنشاء رابط جديد. + إلغاء + إلغاء الرابط + نسخ الرابط + شارك الرابط + أي شخص يمتلك تيليجرام على جهازه سيسطيع الدخول لمجموعتك باستخدام الرابط التالي. عدد الوسائط المشتركة الإعدادات @@ -311,6 +329,13 @@ إيقاف الأصوات داخل المحادثات افتراضي + إشعارات ذكية + تعطيل + أعلى صوت %1$s خلال %2$s + أعلى صوت + الأوقات + خلال + دقائق الأجهزة المسجّل دخول منها الجهاز الحالي @@ -350,15 +375,20 @@ هجين متر يبعد كيلومتر يبعد - أرسل موقعك - مشاركة الموقع + أرسل مكانك الحالي + أرسل المكان المختار + المكان + دقيق لدرجة %1$s + أو اختر مكان عرض كافة الوسائط حفظ في الجهاز %1$d من %2$d الألبوم جميع الصور + كافة المقاطع المرئية لا توجد صور حتى الآن + لا يوجد مقاطع مرئية بعد فضلًا، قم بتنزيل الوسائط أولًا لا توجد صور حديثة لا يوجد صور متحركة حديثة @@ -388,6 +418,11 @@ تجاهل التغييرات؟ هل ترغب في مسح سجل البحث؟ مسح + صور + مقطع مرئي + أضف تعليق... + تعليق الصورة + تعليق المقطع المرئي التحقق بخطوتين تعيين كلمة مرور إضافية @@ -497,6 +532,8 @@ موافق قطع + لقد قمت بالدخول للمجموعة باستخدام رابط الدعوة + un1 قام بالدخول للمجموعة باستخدام رابط الدعوة un1 أزال un2 غادر المجموعة العضو un1 un1 قام بإضافة un2 @@ -664,6 +701,18 @@ %1$d مستخدمون %1$d مستخدم %1$d مستخدم + %1$d مرات + %1$d مرة + %1$d مرة + %1$d مرة + %1$d مرة + %1$d مرة + %1$d أمتار + %1$d متر + %1$d متر + %1$d متر + %1$d متر + %1$d متر %1$d رسالة معاد توجيهها الرسالة المعاد توجيهها @@ -730,6 +779,9 @@ HH:mm h:mm a %1$s الساعة %2$s + + تم تحديث تيليجرام نسخة الأندرويد. الجديد في النسخة ٢.٨:\n\n- روابط الدعوة للمجموعات\n- الإشعارات الذكية\n- خيار الملصقات في قائمة الإموجي\n- التعليقات للصور\n- الأماكن في خدمة المواقع\n- وضعية \"مسموع\" في الرسائل الصوتية\n- شرح متطور لحالة الطرف الآخر: يرسل صورة، يسجل مقطع صوتي، إلخ\n- تطوير التحريك والحركات داخل التطبيق ليكون أسهل وأسرع + 523 تلغرام للاندرويد Theming diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index c99e1191..81121e5d 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -40,7 +40,7 @@ Aktualisiere… Neuer Geheimer Chat Warte, bis %s online geht… - Geheimen Chat beendet + Geheimer Chat beendet Tausche Schlüssel aus… %s ist deinem geheimen Chat beigetreten. Du bist dem geheimen Chat beigetreten. @@ -89,6 +89,10 @@ %1$s schickt Bild... %1$s schickt Video... %1$s schickt Datei... + nimmt etwas auf... + schickt Bild... + schickt Video... + schickt Datei... Hast du eine Frage\nzu Telegram? Foto aufnehmen Galerie @@ -101,7 +105,7 @@ Keine aktuellen Nachricht Nachricht - Meine Telefonnummer teilen + Meine Nummer teilen Zu Kontakten hinzufügen %s hat dich zu einem\nEnde-zu-Ende verschlüsselten\nGeheimen Chat eingeladen. Du hast %s zu einem\nEnde-zu-Ende verschlüsselten\nGeheimen Chat eingeladen. @@ -155,8 +159,9 @@ %1$s hat dich aus der Gruppe %2$s entfernt %1$s hat die Gruppe %2$s verlassen %1$s benutzt jetzt Telegram! - %1$s,\nWir haben eine Anmeldung von einem neuen Gerät am %2$s festgestellt.\n\nGerät: %3$s\nStandort: %4$s\n\nWenn du das nicht selbst gewesen bist, melde alle anderen Sitzungen in den Telegram Einstellungen unverzüglich ab.\n\nBeachte unsere zweistufige Bestätigung, welche du in den Telegram Einstellungen unter Privatsphäre und Sicherheit optional aktivieren kannst.\n\nDein Telegram Team + %1$s,\nWir haben eine Anmeldung von einem neuen Gerät am %2$s festgestellt.\n\nGerät: %3$s\nStandort: %4$s\n\nWenn du das nicht selbst gewesen bist, melde die entsprechende Sitzung in den Telegram Einstellungen unter Privatsphäre und Sicherheit - Sitzungen unverzüglich ab.\n\nKennst du schon unsere zweistufige Bestätigung? Diese kannst du in den Telegram Einstellungen unter Privatsphäre und Sicherheit optional aktivieren.\n\nDein Telegram Team %1$s hat das Profilbild geändert + %1$s ist per Einladungslink der Gruppe %2$s beigetreten Antworten %1$s antworten %1$s antworten @@ -182,6 +187,19 @@ Gruppenname Gruppenname %1$d/%2$d Mitglieder + Möchtest du der Gruppe \"%1$s\" beitreten? + Leider ist diese Gruppe schon voll. + Leider gibt es diese Gruppe nicht. + Link in die Zwischenablage kopiert + Per Link zur Gruppe einladen + Einladungslink + Bist du sicher, dass du diesen Link widerrufen willst? Dadurch kann ihn niemand mehr nutzen. + Der vorige Link ist nun inaktiv. Ein neuer Einladungslink wurde gerade erstellt. + Widerrufen + Link widerrufen + Link kopieren + Link teilen + Jeder, der Telegram installiert hat, kann anhand dieses Links in deine Gruppe. Geteilte Medien Einstellungen @@ -218,7 +236,7 @@ Ein Benutzername benötigt mindestens 5 Zeichen. Ein Benutzername darf maximal 32 Zeichen haben. Benutzernamen dürfen leider nicht mit einer Zahl anfangen. - Wähle einen für jeden sichtbaren Benutzernamen, wenn du von anderen bei ]]>Plus Messenger]]> gefunden werden willst — ohne, dass sie deine Nummer kennen müssen.
]]>Erlaubt sind ]]>a-z]]>, ]]>0-9]]> und Unterstriche. Die Mindestlänge beträgt ]]>5]]> Zeichen.
+ Wähle einen öffentlichen Benutzernamen, wenn du von anderen bei ]]>Plus Messenger]]> gefunden werden willst — ohne, dass sie deine Nummer kennen müssen.
]]>Erlaubt sind ]]>a-z]]>, ]]>0-9]]> und Unterstriche. Die Mindestlänge beträgt ]]>5]]> Zeichen.
Prüfe Benutzername... %1$s ist verfügbar. Keiner @@ -311,9 +329,16 @@ Aus In-Chat Töne Standard + Intelligente Benachrichtigungen + Deaktiviert + Höchstens %1$s innerhalb %2$s + Höchstens + Mal + innerhalb von + Minuten Sitzungen - Aktuelle Sitzung + Aktuelles Gerät Keine anderen Geräte Du kannst dich von jedem Handy, Tablet und Computer bei Telegram mit derselben Telefonnummer anmelden. Alles wird immer sofort synchronisiert. Andere Geräte @@ -350,15 +375,20 @@ Hybrid m entfernt km entfernt - Standort senden - Teile Standort + Meinen Standort senden + Diesen Standort senden + Standort + Auf %1$s genau + Oder wähle einen Ort Zeige alle Medien In der Galerie speichern %1$d von %2$d Galerie Alle Fotos + Alle Videos Noch keine Fotos + Noch keine Videos Medien bitte zuerst herunterladen Suchverlauf Suchverlauf @@ -388,6 +418,11 @@ Änderungen verwerfen? Suchverlauf löschen? Löschen + Bilder + Video + Beschriftung... + Bildbeschriftung + Videobeschriftung Zweistufige Bestätigung Zusätzliches Kennwort festlegen @@ -497,6 +532,8 @@ OK SCHNEIDEN + Du bist der Gruppe per Link beigetreten + un1 ist der Gruppe per Link beigetreten un1 hat un2 aus der Gruppe entfernt un1 hat die Gruppe verlassen un1 hat un2 hinzugefügt @@ -664,6 +701,18 @@ %1$d Nutzer %1$d Nutzer %1$d Nutzer + %1$d Mal + %1$d Mal + %1$d Mal + %1$d Mal + %1$d Mal + %1$d Mal + %1$d Meter + %1$d Meter + %1$d Meter + %1$d Meter + %1$d Meter + %1$d Meter %1$d angehängten Nachrichten Angehängte Nachricht @@ -730,18 +779,13 @@ HH:mm h:mm a %1$s um %2$s + + Plus Messenger für Android wurde aktualisiert. Neu in 2.8:\n\n- Einladungslinks für Gruppenchats\n- Intelligente Benachrichtigungen\n- Sticker Tab im Emojimenü\n- Beschriftungen für Bilder\n- Orte in der Umgebung im Standortmenü\n- \'Angehört\'-Status Sprachnachrichten\n- Erweiterterte \'schreibt gerade\' Status: schickt Bild, nimmt Audio auf, etc.\n- Verbesserter Bildlauf und flüssige Animationen + 523 - - Intelligente Benachrichtigung - Sekunde(n) - Minute(n) - Stunde(n) - Tag(e) - maximale Laustärke - mal - Zeit - innerhalb von - + + \n\nNeu in 2.8.1.3:\n\n- Sprechblasenform ändern\n- Option in den Einstellungen um Dateien mit Original Dateinamen zu speichern\n- Option um Sticker aus der Galerie im Chat zu senden\n- Profilbildgröße im Chat und Chatübersicht ändern\n- Profilbild Randabstand links im Chat und Chatübersicht ändern\n- Profilbild im Gruppenchat nach oben\n- Gruppenname Farbe und Größe in der Chatübersicht\n- Kontaktname Farbe mit unbekannter Nummer ändern\n- Fehlerbeseitigungen + Plus Messenger für Android Theming Ungültiger Hex Code! @@ -834,10 +878,20 @@ Kopfzeilentitel Weiterleiten ohne Hinweis mit Klick Pop-up deaktivieren - Gruppe/Kontakt Profilübersicht + Gruppenkontakt Profile Benutzerdefinerten Hintergrund ausblenden - Linkfarbe rechts - Linkfarbe Links + Linkfarbe rechte Sprechblase + Linkfarbe linke Sprechblase Theme angewendet! Klicken Sie auf OK, um die Anwendung neu zu starten + Google Emoji anzeigen + Sprechblasenform + original Dateinamen speichern + Statt Zahlen wird Dateiname_Datum gespeichert. + Profilbildgröße Gruppenchat + Profilbild Gruppenchat nach oben + Profilbild Randabstand Gruppenchat + Gruppenname Farbe + Gruppenname Größe + Name Farbe (unbekannte Nummer) \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index e736eb96..0b0eb5e9 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -89,6 +89,10 @@ %1$s está enviando una foto... %1$s está enviando un vídeo... %1$s está enviando un archivo... + grabando audio... + enviando foto... + enviando vídeo... + enviando archivo... ¿Tienes preguntas\nsobre Telegram? Hacer foto Galería @@ -157,6 +161,7 @@ ¡%1$s se unió a Telegram! %1$s,\nDetectamos un inicio de sesión en tu cuenta desde un nuevo dispositivo, el %2$s\n\nDispositivo: %3$s\nUbicación: %4$s\n\nSi no eras tú, puedes ir a Ajustes - Privacidad y seguridad - Cerrar todas las otras sesiones.\n\nSi crees que alguien ha iniciado la sesión sin tu consentimiento, puedes activar la verificación en dos pasos, en los ajustes de privacidad y seguridad.\n\nAtentamente,\nEl equipo de Telegram %1$s actualizó su foto de perfil + %1$s se unió al grupo %2$s con un enlace de invitación Responder Responder a %1$s Responder a %1$s @@ -182,8 +187,21 @@ Nombre del grupo Nombre del grupo %1$d/%2$d miembros + ¿Quieres unirte al grupo \'%1$s\'? + Lo sentimos. Este grupo está lleno. + Lo sentimos. Este grupo no existe. + Enlace copiado al portapapeles + Invitar al grupo con un enlace + Enlace de invitación + ¿Quieres anular este enlace? Una vez hecho, nadie podrá usarlo para unirse al grupo. + El enlace de invitación anterior está inactivo. Ha sido creado uno nuevo. + Anular + Anular enlace + Copiar enlace + Compartir enlace + Cualquiera que tenga Telegram instalado podrá unirse a tu grupo siguiendo este enlace. - Multimedia compartida + Todos los archivos Ajustes Añadir miembro Eliminar y dejar el grupo @@ -211,15 +229,15 @@ Información Teléfono - Apodo - Tu apodo - Lo siento, este apodo ya está ocupado. - Lo siento, este apodo es inválido. - Un apodo debe tener al menos 5 caracteres. - El apodo no debe exceder los 32 caracteres. - Lo siento, un apodo no puede comenzar con un número. - Puedes elegir un apodo en ]]>Plus Messenger]]>. Si lo haces, otras personas te podrán encontrar por ese apodo y contactarte sin saber tu número de teléfono.
]]>Puedes usar ]]>a–z]]>, ]]>0–9]]> y guiones bajos. La longitud mínima es de ]]>5]]> caracteres.
- Verificando apodo... + Alias + Tu alias + Lo siento, este alias ya está ocupado. + Lo siento, este alias es inválido. + Un alias debe tener al menos 5 caracteres. + El alias no debe exceder los 32 caracteres. + Lo siento, un alias no puede comenzar con un número. + Puedes elegir un alias en ]]>Plus Messenger]]>. Si lo haces, otras personas te podrán encontrar por ese alias y contactarte sin saber tu número de teléfono.
]]>Puedes usar ]]>a–z]]>, ]]>0–9]]> y guiones bajos. La longitud mínima es de ]]>5]]> caracteres.
+ Verificando alias... %1$s está disponible. Ninguno Ocurrió un error. @@ -311,6 +329,13 @@ Apagado Sonidos en el chat Por defecto + Notificaciones inteligentes + Desactivadas + Sonar como máximo %1$s en %2$s + Sonar como máximo + veces + en + minutos Sesiones activas Sesión actual @@ -350,15 +375,20 @@ Híbrido m de distancia km de distancia - Enviar ubicación + Enviar tu ubicación actual + Enviar la ubicación seleccionada Ubicación + Exacto a %1$s + O ELIGE UN LUGAR Ir a Multimedia Guardar en galería %1$d de %2$d Galería Todas las fotos + Todos los vídeos Aún sin fotos + Sin vídeos aún Por favor, primero descarga la multimedia No hay fotos recientes No hay GIF recientes @@ -388,6 +418,11 @@ ¿Descartar cambios? ¿Quieres borrar el historial de búsqueda? Borrar + Fotos + Vídeo + Añadir un comentario... + Comentario de foto + Comentario de vídeo Verificación en dos pasos Poner contraseña adicional @@ -497,6 +532,8 @@ OK RECORTAR + Te uniste al grupo con un enlace de invitación + un1 se unió al grupo con un enlace de invitación un1 expulsó a un2 un1 dejó el grupo un1 añadió a un2 @@ -664,6 +701,18 @@ %1$d usuarios %1$d usuarios %1$d usuarios + %1$d veces + %1$d vez + %1$d veces + %1$d veces + %1$d veces + %1$d veces + %1$d metros + %1$d metro + %1$d metros + %1$d metros + %1$d metros + %1$d metros %1$d mensajes adjuntos Mensaje adjunto @@ -730,24 +779,17 @@ HH:mm h:mm a %1$s a las %2$s + + Plus Messenger para Android ha sido actualizada. Novedades en la versión 2.8:\n\n- Enlaces de invitación para chats grupales\n- Notificaciones inteligentes\n- Pestaña de stickers en el menú de emojis\n- Comentarios en las fotos\n- Lugares y direcciones en las ubicaciones\n- Estado \'escuchado\' para los mensajes de voz\n- Estado \'escribiendo\' avanzado: enviando foto, grabando audio, etc.\n- Deslizamiento y animaciones mejoradas para una experiencia fluiiiiiiiiiiiiiiiiiida + 523 - - Notificación inteligente - segundo(s) - minuto(s) - hora(s) - día(s) - Suena máximo - veces - vez - cada - + \n\nNovedades en 2.8.1.3:\n\n- Nuevo MOD para cambiar estilo de bocadillos (3 estilos nuevos)\n- Opción para guardar automáticamente ficheros usando nombre original\n- Nueva opción para enviar sticker directamente desde la galería\n- Nuevo MOD para cambiar tamaño de avatares en pantalla principal y chat\n- Nuevo MOD para ajustar margen izquierdo de avatares en pantalla principal y chat\n- Opción para ajustar avatares arriba del bocadillo en vez de abajo en chat\n- Nuevos MODs para cambiar color y tamaño de nombre de grupo en pantalla principal\n- Nuevo MOD para cambiar color de nombre de contacto con número desconocido en pantalla principal\n- Solución de errores Plus Messenger para Android Tematización ¡Color hexadecimal inválido! Color de tema Restablecer tema - Deshacer todos los cambios del tema actual + Deshacer todos los cambios del tema actual ¡Ajustes de tema restablecidos a valores por defecto! General Pantallas @@ -841,4 +883,13 @@ ¡Tema aplicado! Pulsa OK para reiniciar la aplicación Muestra emoticonos del teléfono + Estilo de globo de diálogo + Mantener nombre de archivo original + En lugar de solo números los archivos se guardarán usando el formato nombre_fecha + Tamaño de avatar + Alinear avatar arriba + Margen izquierdo de avatar + Color de nombre de grupo + Tamaño de nombre de grupo + Color de nombre (nº desconocido) \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index 09fff834..4579201c 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -89,6 +89,10 @@ %1$s sta inviando una foto... %1$s sta inviando un video... %1$s sta inviando un file... + registrando un audio... + inviando una foto... + inviando un video... + inviando un file... Hai una domanda\nsu Telegram? Scatta una foto Galleria @@ -157,6 +161,7 @@ %1$s ha iniziato a usare Telegram! %1$s,\nAbbiamo rilevato un accesso al tuo account da un nuovo dispositivo il %2$s\n\nDispositivo: %3$s\nPosizione: %4$s\n\nSe non sei stato tu, puoi andare su Impostazioni - Privacy e Sicurezza - Sessioni - Termina tutte le sessioni.\n\nSe pensi che qualcuno si sia collegato al tuo account contro il tuo volere, ti raccomandiamo di attivare la verifica in due passaggi nelle impostazioni di Privacy e Sicurezza.\n\nGrazie,\nil team di Telegram %1$s ha aggiornato la foto del profilo + %1$s si è unito al gruppo %2$s tramite link di invito Rispondi Rispondi a %1$s Rispondi a %1$s @@ -182,6 +187,19 @@ Immetti il nome del gruppo Nome gruppo %1$d/%2$d membri + Vuoi unirti al gruppo \'%1$s\'? + Ci spiace, questo gruppo è già pieno. + Ci spiace, sembra che questo gruppo non esista. + Link copiato negli appunti + Invita nel gruppo tramite link + Link di invito + Sei sicuro di voler revocare questo link? Una volta fatto, nessuno potrà unirsi al gruppo utilizzandolo. + Il precedente link di invito è inattivo. Ne è appena stato creato uno nuovo. + Revoca + Revoca link + Copia link + Condividi link + Chiunque abbia Telegram installato, sarà in grado di aggiungersi al tuo gruppo aprendo il link. Media condivisi Impostazioni @@ -311,6 +329,13 @@ No Suoni in-chat Predefinito + Notifiche intelligenti + Disabilitate + Suona al massimo %1$s in %2$s + Suona al massimo + volte + in + minuti Sessioni attive Sessione corrente @@ -350,15 +375,20 @@ Ibrido m di distanza km di distanza - Invia posizione - Condividi posizione + Invia la tua posizione attuale + Invia la posizione selezionata + Posizione + Precisione di %1$s + O SELEZIONA UN LUOGO Mostra tutti i file media Salva nella galleria %1$d di %2$d Galleria Tutte le foto + Tutti i video Ancora nessuna foto + Nessun video Scarica prima il file Nessuna foto recente Nessuna GIF recente @@ -388,6 +418,11 @@ Annullare le modifiche? Cancellare la cronologia di ricerca? Pulisci + Foto + Video + Aggiungi una didascalia... + Didascalia foto + Didascalia video Verifica in due passaggi Imposta password aggiuntiva @@ -497,6 +532,8 @@ OK RITAGLIA + Ti sei unito al gruppo tramite link di invito + un1 si è unito al gruppo tramite link di invito un1 ha espulso un2 un1 ha lasciato il gruppo un1 ha aggiunto un2 @@ -664,6 +701,18 @@ %1$d utenti %1$d utenti %1$d utenti + %1$d volte + %1$d volta + %1$d volte + %1$d volte + %1$d volte + %1$d volte + %1$d metri + %1$d metro + %1$d metri + %1$d metri + %1$d metri + %1$d metri %1$d messaggi inoltrati Messaggio inoltrato @@ -730,18 +779,13 @@ HH:mm h:mm a %1$s alle %2$s - - - Notifica intelligente - secondo(i) - minuto(i) - ora(e) - giorno(i) - Suona massimo - volte - volta - entro - + + Plus Messenger per Android si è aggiornato. Nuovo nella versione 2.8:\n\n- Invita nei gruppi tramite link\n- Notifiche intelligenti\n- Pannello degli sticker nella lista emoji\n- Luoghi e direzioni nelle posizioni\n- Stato \'ascoltato\' per i messaggi vocali\n- Stato di scrittura \'avanzato\': inviando una foto, registrando un audio, etc\n- Animazioni e scorrimento migliorati per un\'esperienza rapidissimaaaa + 523 + + + \n\nNovità nella 2.8.1.3:\n\n- Nuova MOD per cambiare lo stile delle nuvolette\n- Aggiunta opzione nelle impostazioni per salvare i file usando il nome di origine\n- Aggiunta opzione nella chat per inviare gli sticker dalla galleria\n- Nuova MOD per cambiare la dimensione dell\'avatar nella schermata principale e della chat\n- Nuova MOD per cambiare il margine sinistro dell\'avatar nella schermata principale e della chat\n- Opzione per allineare l\'avatar all\'intestazione invece che al fondo nella schermata della chat\n- Nuove MOD per cambiare il colore del nome del gruppo e la dimensione nella schermata principale\n- Nuova MOD per cambiare il colore del nome del contatto con numero sconosciuto\n- Correzioni bug + Plus Messenger per Android Personalizzazione Codice del colore esadecimale non valido! @@ -834,10 +878,20 @@ Titolo dell\'intestazione Inoltra senza citare Disabilita il pop-up al click - Schermata Gruppo/Profilo del contatto + Gruppo/Profilo del contatto Nascondi sfondo personalizzato Colore dei link del testo a destra Colore dei link del testo a sinistra Tema applicato! Premi OK per riavviare l\'app + Mostra emoji del telefono + Stile a bolla + Mantieni il nome originale del file + I file verranno salvati usando il formato nome_data anziché solo il numero + Dimensione avatar + Allinea l\'avatar in cima + Margine a sinistra dell\'avatar + Colore del nome del gruppo + Dimensione del nome del gruppo + Colore del nome (numero sconosciuto) \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-ko/strings.xml b/TMessagesProj/src/main/res/values-ko/strings.xml index 69019f6e..091cf72e 100644 --- a/TMessagesProj/src/main/res/values-ko/strings.xml +++ b/TMessagesProj/src/main/res/values-ko/strings.xml @@ -89,6 +89,10 @@ %1$s님이 사진 보내는 중... %1$s님이 동영상 보내는 중... %1$s님이 파일 보내는 중... + 음성메시지 녹음 중... + 사진 전송 중.. + 동영상 전송 중.. + 파일 전송 중... 텔레그램에 관해\n궁금한 사항이 있나요? 사진 촬영 앨범 @@ -157,6 +161,7 @@ %1$s님이 텔레그램에 가입했습니다! %1$s님,\n%2$s에 새 기기에서 회원님의 계정 로그인이 감지되었습니다. \n\n기기: %3$s\n위치: %4$s\n\n본인의 접속이 아니라면 \'설정\' 창에서 \'모든 세션 종료\' 기능을 실행하세요.\n\n만약 강제접속 의심이 되신다면 2단계 인증을 설정 - 개인정보 및 보안에서 설정할 수 있습니다.\n\n감사합니다.\n텔레그램 팀 %1$s님이 프로필 사진을 변경했습니다 + 초대링크를 타고 %1$s님께서 %2$s 그룹에 참여하셨습니다. 답장 %1$s 그룹에 답장하기 %1$s님에게 답장하기 @@ -182,6 +187,19 @@ 그룹 이름 입력 그룹 이름 대화상대 %1$d/%2$d + \'%1$s\' 그룹에 참여하시겠습니까? + 죄송합니다, 그룹방의 인원이 최대치입니다. + 죄송합니다, 그룹방이 더이상 존재하지 않습니다. + 클립보드로 링크가 복사되었습니다. + 링크를 통하여 그룹방에 초대하기 + 초대링크 + 초대링크를 폐지하시겠습니까? 진행하실 경우 해당 링크로 그룹방에 참여할 수 없게 됩니다. + 기존 초대링크는 비활성화 되었습니다. 새로운 링크가 생성되었습니다. + 폐지하기 + 링크 폐지 + 링크 복사 + 링크 공유 + 텔레그램이 설치된 분들은 링크를 타고 그룹방에 참여가 가능합니다. 공유한 미디어 설정 @@ -311,6 +329,13 @@ 채팅중 소리 설정 기본값 + 스마트 알림 + 비활성화됨 + 최대 %1$s번, %2$s번 이내 알림 + 알림 최대치 + + 이내 + 활성화된 세션 현재 세션 @@ -350,15 +375,20 @@ 혼합 m 떨어짐 km 떨어짐 - 위치 보내기 - 위치 공유 + 현재 위치 전송 + 선택한 위치 전송 + 위치 + %1$s 반경 내 정확함 + 혹은 위치를 선택 모든 미디어 보기 앨범에 저장 %1$d / %2$d 앨범 모든 사진 + 모든 동영상 사진이 없습니다. + 동영상이 아직 없음 사진/동영상을 먼저 다운로드하세요 최근 사진 없음 최근에 검색한 GIF @@ -388,6 +418,11 @@ 변경을 취소하시겠습니까? 검색기록을 지우시겠습니까? 지우기 + 사진 + 동영상 + 설명 추가... + 사진 설명 + 동영상 설명 2단계 인증 개별 비밀번호 설정 @@ -497,6 +532,8 @@ 확인 자르기 + 초대링크를 타고 그룹에 참여하였습니다. + 초대링크를 타고 그룹에 un1님이 참여하였습니다. un1님이 un2님을 추방했습니다 un1님이 퇴장했습니다 un1님이 un2님을 초대했습니다 @@ -664,6 +701,18 @@ %1$d명의 대화상대 %1$d명의 대화상대 %1$d명의 대화상대 + %1$d 번 + %1$d 번 + %1$d 번 + %1$d 번 + %1$d 번 + %1$d 번 + %1$d 미터 + %1$d 미터 + %1$d 미터 + %1$d 미터 + %1$d 미터 + %1$d 미터 %1$d 개의 전달된 메시지 전달된 메시지 @@ -730,4 +779,7 @@ HH:mm a h:mm %1$s %2$s + + 텔레그램 안드로이드가 업데이트 되었습니다. 새로운 버전 2.8:\n\n-그룹방 초대링크 기능\n-스마트 알림\n-이모티콘 스티커탭\n-사진 설명 기능\n-위치에 장소 및 안내 기능\n-음성 메시지 \'청취확인\' 기능\n-\'입력 중\' 확장 : 사진 보내는중, 녹음 중등\n-부드러운 스크롤링 및 애니메이션 향상 + 523 \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index f87fc6af..d83731ba 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -89,6 +89,10 @@ %1$s verstuurt een foto %1$s verstuurt een video %1$s verstuurt een bestand + geluid opnemen + foto versturen + video versturen + bestand versturen Heb je een vraag\nover Telegram? Foto maken Galerij @@ -157,6 +161,7 @@ %1$s heeft nu Telegram! %1$s,\nEr is op je account ingelogd vanaf een nieuw apparaat op %2$s\n\nApparaat: %3$s\nLocatie: %4$s\n\nAls jij dit niet was, kun je die sessie beëindigen via Instellingen - Privacy en veiligheid - Sessies.\n\nAls je dat denkt dat iemand anders zonder jouw toestemming is ingelogd kun je twee-staps-verificatie activeren via instellingen - privacy en veiligheid .\n\nBedankt,\nHet Telegram-team %1$s heeft zijn/haar profielfoto gewijzigd + %1$s neemt deel aan de groep %2$s via uitnodigingslink Antwoord Antwoord op %1$s Antwoord op %1$s @@ -182,6 +187,19 @@ Groepsnaam Groepsnaam %1$d/%2$d deelnemers + Wil je deelnemen aan de groep \'%1$s\'? + Sorry, deze groep is al vol. + Sorry, deze groep bestaat niet. + Link gekopieerd naar klembord. + Uitnodigingslink sturen + Uitnodigingslink + Deze link echt intrekken? Na intrekken kan niemand meer lid worden met de oude link. + De oude link is nu inactief. Een nieuwe link is aangemaakt. + Intrekken + Link intrekken + Link kopiëren + Link delen + Andere Telegram-gebruikers kunnen aan je groep deelnemen door deze link te openen. Gedeelde media Instellingen @@ -311,6 +329,13 @@ Uit Chatgeluiden Standaard + Slimme meldingen + Uitgeschakeld + Geluid maximaal %1$s per %2$s + Geluid maximaal + keer + binnen + minuten Actieve sessies Huidige sessie @@ -350,15 +375,20 @@ Hybride m hiervandaan km hiervandaan - Locatie versturen - Locatie delen + Huidige locatie sturen + Geselecteerde locatie sturen + Locatie + Nauwkeurig tot op %1$s + OF KIES EEN PLEK Alle media weergeven Opslaan in galerij %1$d van %2$d Galerij Alle foto\'s + Alle video\'s Nog geen foto\'s + Nog geen video\'s Download media eerst Niets recents Niets recents @@ -388,6 +418,11 @@ Wijzigingen negeren? Zoekgeschiedenis wissen? Wissen + Foto\'s + Video + Onderschrift toevoegen + Foto-onderschrift + Video-onderschrift Twee-staps-verificatie Extra wachtwoord instellen @@ -497,6 +532,8 @@ OK BIJSNIJDEN + Je neemt deel aan de groep via uitnodigingslink + un1 neemt deel aan de groep via uitnodigingslink un1 heeft un2 verwijderd un1 heeft de groep verlaten un1 heeft un2 toegevoegd @@ -664,6 +701,18 @@ %1$d gebruikers %1$d gebruikers %1$d gebruikers + %1$d keer + %1$d keer + %1$d keer + %1$d keer + %1$d keer + %1$d keer + %1$d meter + %1$d meter + %1$d meter + %1$d meter + %1$d meter + %1$d meter Bijlage: %1$d berichten Bijlage: 1 bericht @@ -730,20 +779,12 @@ HH:mm h:mm a %1$s om %2$s + + Plus Messenger voor Android is geüpdatet. Nieuw in versie 2.8:\n\n- Uitnodigingslinks voor groepchats\n- Slimme meldingen\n- Stickerstab in emojimenu\n- Onderschriften voor foto\'s\n- Plekken en routebeschrijvingen op locaties\n- \'Beluistered\'-status voor spraakberichten\n- Geadvanceerde \'aan het typen\'-status: verstuurt een foto, audio opnemen, etc.\n- Scrollen en animaties verbeterd voor een soepele ervaring + 523 - - Slimme melding - seconde(n) - minute(n) - uur - dag(en) - Geluid bij de meeste - tijden - tijd - binnen - Plus Messenger voor Android - Uiterlijk + Thema\'s Ongeldige kleurhexcode! Themakleur Thema-instellingen herstellen @@ -752,15 +793,15 @@ Algemeen Schermen Hoofdscherm - Chatgesprek-scherm - Contactpersonen-scherm - Banier + Chatscherm + Contactenscherm + Kop Rijen Chatlijst Chatslijst - Contactpersonenlijst - Banierkleur - Naamkleur + Contactenlijst + Kopkleur + Kleur van naam Naamgrootte Berichtkleur Berichtgrootte @@ -779,8 +820,8 @@ Kleur van datumballon Rechtertekstkleur Linkertekstkleur - Rechtertekstkleur - Rechtertijdskleur + Rechtertijdskleur + Linkertijdskleur Tijdgrootte Kleur van tekstinvoer Grootte van tekstinvoer @@ -791,17 +832,17 @@ Muziek Thema opslaan Sla uw thema op in de Telegram/Thema\'s-map - Het thema is opgeslagen! + Thema opgeslagen! %1$s is opgeslagen naar %2$s Het thema is nog niet gecreëerd. Pas eerst een MOD toe. De voorkeuren zijn hersteld vanaf de SD-kaart Er is geen voorkeurenbestand aangetroffen in %s - Er is geen SD-kaart gevonden. + Geen SD-kaart gevonden. Vul een naam in Thema\'s Thema toepassen XML-thema uit lokale map toepassen - Gebruikerskleur + Lidkleur Kleur van tikken Kleur van gedempt Logbestanden versturen @@ -819,25 +860,35 @@ Naamgrootte Telefoonkleur Telefoongrootte - Kleur van gebruikersafbeelding + Profielfotokleur Kleur van optiespictogram Optiekleur Optiegrootte Versiekleur Versiegrootte - Kleur van baniertitel - Kleur van banierpictogrammen + Kleur van koptitel + Kleur van koppictogrammen Scheidingskleur - Radius van gebruikersafbeelding - Gebruikerskleur instellen + Profielfotostraal + Lidkleur instellen Doorstuurnaamkleur - Baniertitel + Koptitel Doorsturen zonder citeren Pop-up bij klikken uitschakelen - Groeps-/contactpersoonprofielscherm + Groeps-/contactpersoonprofiel Aangepaste achtergrond verbergen Rechterlinkkleur Linkerlinkkleur - Het thema is toegepast! + Thema toegepast! Druk op OK om de applicatie te herstarten + Telefoonemoji + Bubbelstijl + Originele bestandsnaam behouden + In plaats van alleen nummers worden bestanden opgeslagen onder een naam_datum-bestandsnaam + Profielfotogrootte + Profielfoto naar boven uitlijnen + Linkermarge van profielfoto + Kleur van groepsnaam + Grootte van groepsnaam + Naamkleur (onbekend nummer) \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 25ca9a5b..8d9ddec6 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -85,10 +85,14 @@ escrevendo... está escrevendo... estão escrevendo... - %1$s está gravando uma mensagem... + %1$s está gravando um áudio... %1$s está enviando uma foto... %1$s está enviando um vídeo... %1$s está enviando um arquivo... + gravando áudio... + enviando foto... + enviando vídeo... + enviando arquivo... Tem alguma dúvida\nsobre o Telegram? Tirar foto Galeria @@ -157,6 +161,7 @@ %1$s entrou para o Telegram! %1$s,\nNós detectamos que alguém acessou a sua conta a partir de um novo aparelho em %2$s\n\nAparelho: %3$s\nLocalização: %4$s\n\nSe não foi você, você pode ir em Configurações - Provacidade e Segurança - Sessões, e terminar aquela sessão.\n\nSe você acha que alguém acessou a sua conta contra a sua vontade, você pode habilitar a verificação em duas etapas nas configurações de Privacidade e Segurança.\n\nAtenciosamente,\nEquipe Telegram %1$s atualizou a foto do perfil + %1$s entrou para o grupo %2$s via link de convite Responder Responder para %1$s Responder para %1$s @@ -164,7 +169,7 @@ Selecionar Contato Ainda não há contatos - Ei, vamos mudar para o Telegram: http://goo.gl/jnmjnZ + Ei, vamos mudar para o Plus Messenger: http://goo.gl/jnmjnZ às ontem às online @@ -182,6 +187,19 @@ Digite o nome do grupo Nome do grupo %1$d/%2$d membros + Você deseja entrar no grupo \'%1$s\'? + Desculpe, este grupo já está lotado. + Desculpe, este grupo não existe. + Link copiado para área de transferência + Convidar para o Grupo via Link + Link de Convite + Você tem certeza que deseja desativar o link? Uma vez feito, ninguém conseguirá entrar no grupo usando-o. + Este link de convite está inativo. Um novo link foi gerado. + Desativar + Desativar Link + Copiar Link + Compartilhar Link + Qualquer um com Telegram instalado poderá entrar no seu grupo abrindo este link. Mídia compartilhada Configurações @@ -311,6 +329,13 @@ Desativado Sons no Chat Padrão + Notificações Inteligentes + Desativado + Tocar no máximo %1$s a cada %2$s + Tocar no máximo + vezes + a cada + minutos Sessões Ativas Sessão atual @@ -350,15 +375,20 @@ Híbrido m de distância km de distância - Enviar Localização - Compartilhar Localização + Enviar sua localização atual + Enviar localização selecionada + Localização + Precisão de %1$s + OU ESCOLHA UM LUGAR Mostrar todas as mídias Salvar na galeria %1$d de %2$d Galeria Todas as Fotos + Todos os Vídeos Ainda não há fotos + Nenhum vídeo ainda Baixar o vídeo primeiro Nenhuma foto recente Nenhum GIF recente @@ -388,6 +418,11 @@ Descartar mudanças? Limpar histórico de busca? Limpar + Fotos + Vídeo + Adicionar legenda... + Legenda da Foto + Legenda do Vídeo Verificação em duas etapas Configurar senha adicional @@ -424,7 +459,7 @@ O código de recuperação foi enviado para o e-mail fornecido: \n\n%1$s Por favor, verifique o seu e-mail e digite aqui o código de 6 dígitos recebido. Está tendo problemas para acessar seu e-mail %1$s? - Se você não puder acessar o seu e-mail, as suas únicas opções são são lembrar a senha ou apagar a sua conta. + Se você não puder acessar o seu e-mail, as suas únicas opções são lembrar a senha ou apagar a sua conta. APAGAR MINHA CONTA Se você prosseguir e apagar a sua conta, você perderá todos os seus chats e mensagens, assim como todas as suas mídias e arquivos compartilhados. Aviso @@ -497,6 +532,8 @@ OK CORTAR + Você entrou para o grupo via link de convite + un1 entrou para o grupo via link de convite un1 removeu un2 un1 saiu do grupo un1 adicionou un2 @@ -520,7 +557,7 @@ Localização Contato Arquivo - Sticker + Adesivo Áudio Você Você realizou uma captura da tela! @@ -664,6 +701,18 @@ %1$d usuários %1$d usuários %1$d usuários + %1$d vezes + %1$d vez + %1$d vezes + %1$d vezes + %1$d vezes + %1$d vezes + %1$d metros + %1$d metro + %1$d metros + %1$d metros + %1$d metros + %1$d metros %1$d mensagens encaminhadas Mensagem encaminhada @@ -730,18 +779,13 @@ HH:mm h:mm a %1$s às %2$s + + Plus Messenger para Android atualizado: Novidades na versão 2.8:\n\n- Link de convite para chats em grupo\n- Notificações inteligentes\n- Botão para stickers no menu de emojis\n- Legendas para fotos\n- Lugares e direções nas localizações\n- Status \'ouvido\' para mensagens de voz\n- Status \'escrevendo\' avançado: enviando foto, gravando áudio, etc.\n- Melhorias nas animações de rolagem para uma leeeeeeeve experiência + 523 - - Notificação Inteligente - segundo(s) - minutos(s) - hora(s) - dia(s) - Notificar no máximo - vezes - vez - em - + + \n\nNovidades da versão 2.8.1.3:\n\n- Novo MOD para alterar o estilo das bolhas\n- Adicionada a opção nas Configurações para salvar os arquivos com o nome original\n- Adicionada opção para enviar adesivos da Galeria\n- Novo MOD para alterar o tamanho dos avatares nas telas de conversa e lista\n- Novo MOD para alterar a margem esquerda nas telas principais e de conversa\n- Opção para alinhar o avatar no topo das bolhas na tela de conversas\n- Novos MODs para alterar as cores dos nomes de grupo e tamanho na tela principal\n- Novo MOD para alterar a cor de nome de contatos desconhecidos na tela principal\n- Correções de bugs + Plus Messenger para Android Personalização Código de cor hexadecimal inválido! @@ -793,7 +837,7 @@ Salvar seu tema na pasta Telegram/Themes Tema Salvo! %1$s salvo em %2$s - O tema ainda não criado. Por favor, aplique algum MOD primeiro + O tema ainda não foi criado. Por favor, aplique algum MOD primeiro Preferências restauradas a partir do cartão SD Nenhum arquivo de preferências encontrado em %s Nenhum cartão SD foi encontrado. @@ -828,9 +872,9 @@ Cor do Título do Cabeçalho Cor dos Ícones do Cabeçalho Cor das Linhas Divisórias - Diâmetro do Avatar + Arredondamento do Avatar Definir Cor do Membro - Cor do Nome em Encaminhamentos + Cor do Nome ao Encaminhar Título do Cabeçalho Encaminhar sem mencionar Desativar Pop-up ao Clicar @@ -840,4 +884,14 @@ Cor do Link Esquerdo Tema aplicado! Clique em OK para reiniciar o app + Usar Emojis Nativos + Estilo das Bolhas + Manter Nome de Arquivo Original + Ao invés de apenas números, os arquivos serão salvos no formato nome_data + Tamanho do Avatar + Alinhar Avatar ao Topo + Margem Esquerda do Avatar + Cor do Nome do Grupo + Tamanho do Nome do Grupo + Cor do Nome (Número Desconhecido) \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index 2f8c40e2..8b528674 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -85,10 +85,14 @@ escrevendo... está escrevendo... estão escrevendo... - %1$s está gravando uma mensagem... + %1$s está gravando um áudio... %1$s está enviando uma foto... %1$s está enviando um vídeo... %1$s está enviando um arquivo... + gravando áudio... + enviando foto... + enviando vídeo... + enviando arquivo... Tem alguma dúvida\nsobre o Telegram? Tirar foto Galeria @@ -157,6 +161,7 @@ %1$s entrou para o Telegram! %1$s,\nNós detectamos que alguém acessou a sua conta a partir de um novo aparelho em %2$s\n\nAparelho: %3$s\nLocalização: %4$s\n\nSe não foi você, você pode ir em Configurações - Provacidade e Segurança - Sessões, e terminar aquela sessão.\n\nSe você acha que alguém acessou a sua conta contra a sua vontade, você pode habilitar a verificação em duas etapas nas configurações de Privacidade e Segurança.\n\nAtenciosamente,\nEquipe Telegram %1$s atualizou a foto do perfil + %1$s entrou para o grupo %2$s via link de convite Responder Responder para %1$s Responder para %1$s @@ -182,6 +187,19 @@ Digite o nome do grupo Nome do grupo %1$d/%2$d membros + Você deseja entrar no grupo \'%1$s\'? + Desculpe, este grupo já está lotado. + Desculpe, este grupo não existe. + Link copiado para área de transferência + Convidar para o Grupo via Link + Link de Convite + Você tem certeza que deseja desativar o link? Uma vez feito, ninguém conseguirá entrar no grupo usando-o. + Este link de convite está inativo. Um novo link foi gerado. + Desativar + Desativar Link + Copiar Link + Compartilhar Link + Qualquer um com Telegram instalado poderá entrar no seu grupo abrindo este link. Mídia compartilhada Configurações @@ -311,6 +329,13 @@ Desativado Sons no Chat Padrão + Notificações Inteligentes + Desativado + Tocar no máximo %1$s a cada %2$s + Tocar no máximo + vezes + a cada + minutos Sessões Ativas Sessão atual @@ -350,15 +375,20 @@ Híbrido m de distância km de distância - Enviar Localização - Compartilhar Localização + Enviar sua localização atual + Enviar localização selecionada + Localização + Precisão de %1$s + OU ESCOLHA UM LUGAR Mostrar todas as mídias Salvar na galeria %1$d de %2$d Galeria Todas as Fotos + Todos os Vídeos Ainda não há fotos + Nenhum vídeo ainda Baixar o vídeo primeiro Nenhuma foto recente Nenhum GIF recente @@ -388,6 +418,11 @@ Descartar mudanças? Limpar histórico de busca? Limpar + Fotos + Vídeo + Adicionar legenda... + Legenda da Foto + Legenda do Vídeo Verificação em duas etapas Configurar senha adicional @@ -424,7 +459,7 @@ O código de recuperação foi enviado para o e-mail fornecido: \n\n%1$s Por favor, verifique o seu e-mail e digite aqui o código de 6 dígitos recebido. Está tendo problemas para acessar seu e-mail %1$s? - Se você não puder acessar o seu e-mail, as suas únicas opções são são lembrar a senha ou apagar a sua conta. + Se você não puder acessar o seu e-mail, as suas únicas opções são lembrar a senha ou apagar a sua conta. APAGAR MINHA CONTA Se você prosseguir e apagar a sua conta, você perderá todos os seus chats e mensagens, assim como todas as suas mídias e arquivos compartilhados. Aviso @@ -497,6 +532,8 @@ OK CORTAR + Você entrou para o grupo via link de convite + un1 entrou para o grupo via link de convite un1 removeu un2 un1 saiu do grupo un1 adicionou un2 @@ -664,6 +701,18 @@ %1$d usuários %1$d usuários %1$d usuários + %1$d vezes + %1$d vez + %1$d vezes + %1$d vezes + %1$d vezes + %1$d vezes + %1$d metros + %1$d metro + %1$d metros + %1$d metros + %1$d metros + %1$d metros %1$d mensagens encaminhadas Mensagem encaminhada @@ -730,8 +779,11 @@ HH:mm h:mm a %1$s às %2$s + + Plus Messengerpara Android atualizado: Novidades na versão 2.8:\n\n- Link de convite para chats em grupo\n- Notificações inteligentes\n- Botão para stickers no menu de emojis\n- Legendas para fotos\n- Lugares e direções nas localizações\n- Status \'ouvido\' para mensagens de voz\n- Status \'escrevendo\' avançado: enviando foto, gravando áudio, etc.\n- Melhorias nas animações de rolagem para uma leeeeeeeve experiência + 523 - + + --> Plus Messenger para Android Temas O código hexadecimal da cor é inválido! @@ -760,18 +812,18 @@ Lista de Conversas Lista de Contactos Cor do Cabeçalho - Cor do Nome do Contato - Tamanho do Nome do Contato - Cor das Mensagens - Tamanho das Mensagens + Cor do Nome + Tamanho do Nome + Cor da Mensagem + Tamanho da Mensagem Cor da Data/Hora Tamanho da Data/Hora Cor da Contagem Tamanho da Contagem Cor da Linha Cor de fundo da Contagem - Cor do Status - Tamanho do Status + Cor do Estado + Tamanho do Estado Cor da Bolha Direita Cor da Bolha Esquerda Cor da Data @@ -787,27 +839,27 @@ Cor de Fundo do Texto de Entrada Cor de Fundo do Emoji Cor da Tab dos Emoji - Cor do Status Online + Cor do Estado On-line Música Guardar Tema - Guarda o teu tema na pasta Telegram/Themes + Guarde o seu tema na pasta Telegram/Themes Tema guardado! %1$s guardado em %2$s - O tema ainda não foi criado. Por favor, primeiro aplique algum MOD + O tema ainda não foi criado. Por favor, aplique primeiro qualquer MOD. Preferências restauradas do cartão SD - Nenhum ficheiro de preferências encontrado em %s + Não foi encontrado nenhum ficheiro de preferências em %s Não foi encontrado nenhum cartão SD. - Introduzo Nome + Inserir Nome Temas Aplicar Tema - Aplicar tema .xml a partir de um ficheiro local + Aplicar tema xml a partir de uma pasta local Cor do Membro Cor de Ticks - Cor de Silênciar + Cor de Silenciar Enviar Registos Não existem registos - Enviar Ícon - Ocultar do menu o número de telemóvel + Enviar Ícone + Ocultar o número de telemóvel do menu Cor do Lápis Flutuante Cor de Fundo do Botão Flutuante Comunidade G+ @@ -835,4 +887,15 @@ Encaminhar sem citação Desativar a janela ao clicar Ecrã de Perfil do Grupo/Contacto + Ocultar fundo personalizado + Cor da hiperligação direita + Cor da hiperligação esquerda + Tema aplicado! + Clique em \'Aceitar\' para reiniciar a app. + Mostrar emoji de telemóvel + Manter nome de ficheiro original + Em vez de serem usados apenas números, os ficheiros serão guardados usando o formato name_date + Tamanho do Avatar + Alinhar avatar no topo + Avatar na margem esquerda \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values/colors.xml b/TMessagesProj/src/main/res/values/colors.xml index 5a6a9da1..cced77f4 100755 --- a/TMessagesProj/src/main/res/values/colors.xml +++ b/TMessagesProj/src/main/res/values/colors.xml @@ -1,6 +1,5 @@ - #6633B5E5 #dcdcdc #ff009688 diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index fc206504..64c8ad83 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -90,6 +90,10 @@ %1$s is sending photo... %1$s is sending video... %1$s is sending file... + recording audio... + sending photo... + sending video... + sending file... Got a question\nabout Telegram? Take photo Gallery @@ -158,6 +162,7 @@ %1$s joined Telegram! %1$s,\nWe detected a login into your account from a new device on %2$s\n\nDevice: %3$s\nLocation: %4$s\n\nIf this wasn\'t you, you can go to Settings - Privacy and Security - Sessions and terminate that session.\n\nIf you think that somebody logged in to your account against your will, you can enable two-step verification in Privacy and Security settings.\n\nSincerely,\nThe Telegram Team %1$s updated profile photo + %1$s joined to the group %2$s via invite link Reply Reply to %1$s Reply to %1$s @@ -183,6 +188,19 @@ Enter group name Group name %1$d/%2$d members + Do you want to join the group \'%1$s\'? + Sorry, this group is already full. + Sorry, this group does not seem to exist. + Link copied to clipboard + Invite to Group via Link + Invite Link + Are you sure you want to revoke this link? Once you do, no one will be able to join the group using it. + The previous invite link is now inactive. A new link has been generated. + Revoke + Revoke Link + Copy Link + Share Link + Anyone who has Telegram installed will be able to join your group by following this link. Shared Media Settings @@ -312,6 +330,13 @@ Off In-Chat Sounds Default + Smart Notifications + Disabled + Sound at most %1$s within %2$s + Sound at most + times + within + minutes Active Sessions Current session @@ -351,15 +376,20 @@ Hybrid m away km away - Send Location - Share Location + Send your current location + Send selected location + Location + Accurate to %1$s + OR CHOOSE A PLACE Show all media Save to gallery %1$d of %2$d Gallery All Photos + All Videos No photos yet + No videos yet Please download media first No recent photos No recent GIFs @@ -389,6 +419,11 @@ Discard changes? Clear search history? Clear + Photos + Video + Add a caption... + Photo Caption + Video Caption Two-Step Verification Set Additional Password @@ -498,6 +533,8 @@ OK CROP + You joined the group via invite link + un1 joined the group via invite link un1 removed un2 un1 left group un1 added un2 @@ -665,6 +702,18 @@ %1$d users %1$d users %1$d users + %1$d times + %1$d time + %1$d times + %1$d times + %1$d times + %1$d times + %1$d meters + %1$d meter + %1$d meters + %1$d meters + %1$d meters + %1$d meters %1$d forwarded messages Forwarded message @@ -731,18 +780,11 @@ HH:mm h:mm a %1$s at %2$s + + Plus Messenger for Android has been updated. New in version 2.8:\n\n- Places and directions in locations\n- Smart notifications\n- Invite links for group chats\n- Stickers tab in emoji menu\n- Captions for photos\n- \'Listened\' status for voice messages\n- Advanced \'typing\' status: sending photo, recording audio, etc.\n- Improved scrolling and animations for a smooooooooth experience + 523 - - Smart notification - second(s) - minute(s) - hour(s) - day(s) - Sound at most - times - time - within - + \n\nNew in 2.8.1.3:\n\n- New MOD to change bubbles style (3 new styles, more will come)\n- Added option in Settings to save files using original file name\n- Added option in chat to send sticker directly from gallery\n- New MOD to change avatar size in main and chat screen\n- New MOD to change avatar left margin in main and chat screen\n- Option to align avatar to top instead of bottom in chat screen\n- New MODs to change group name color and size in main screen\n- New MOD to change contact name color with unknown number\n- Bug fixes Plus Messenger for Android Theming Invalid color hex code! @@ -835,11 +877,20 @@ Header title Forward without quoting Disable pop-up on click - Group/Contact Profile screen + Group/Contact Profile Hide custom background Right link color Left link color Theme applied! Click OK to restart app Show phone emoji + Bubble style + Keep original filename + Instead of just numbers files will be saved using name_date format + Avatar size + Align avatar to top + Avatar left margin + Group name color + Group name size + Name color (unknown number) \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values/styles.xml b/TMessagesProj/src/main/res/values/styles.xml index c03a566c..ae16acf9 100644 --- a/TMessagesProj/src/main/res/values/styles.xml +++ b/TMessagesProj/src/main/res/values/styles.xml @@ -78,5 +78,4 @@ @null false - diff --git a/TMessagesProj/src/main/res/xml/auth.xml b/TMessagesProj/src/main/res/xml/auth.xml index 7856d0c8..cc285409 100644 --- a/TMessagesProj/src/main/res/xml/auth.xml +++ b/TMessagesProj/src/main/res/xml/auth.xml @@ -1,7 +1,7 @@ \ No newline at end of file + android:accountType="org.telegram.messenger"/> \ No newline at end of file