From d52de1a40a5e81736e7c100ca73e20226eed73d9 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Fri, 1 Jan 2021 08:38:45 +0400 Subject: [PATCH] Update to 7.3.1 (2206) --- TMessagesProj/build.gradle | 2 +- .../SQLite/SQLitePreparedStatement.java | 12 +- .../org/telegram/messenger/BuildVars.java | 2 +- .../telegram/messenger/DocumentObject.java | 3 + .../org/telegram/messenger/FileLoader.java | 6 +- .../org/telegram/messenger/ImageReceiver.java | 15 +- .../org/telegram/messenger/MessageObject.java | 15 +- .../messenger/MessagesController.java | 48 +++--- .../telegram/messenger/MessagesStorage.java | 1 + .../org/telegram/messenger/SharedConfig.java | 2 +- .../org/telegram/messenger/SvgHelper.java | 10 ++ .../main/java/org/telegram/tgnet/TLRPC.java | 134 ++++++++-------- .../org/telegram/ui/ActionBar/ActionBar.java | 78 ++++++++-- .../ui/ActionBar/ActionBarLayout.java | 11 +- .../telegram/ui/Cells/ChatMessageCell.java | 12 +- .../telegram/ui/Cells/ContextLinkCell.java | 15 +- .../org/telegram/ui/Cells/DialogCell.java | 33 ++-- .../telegram/ui/Cells/DrawerProfileCell.java | 13 +- .../ui/Cells/SharedPhotoVideoCell.java | 4 +- .../java/org/telegram/ui/ChatActivity.java | 14 +- .../ui/Components/BulletinFactory.java | 6 +- .../ui/Components/ChatAvatarContainer.java | 4 + .../ui/Components/FilterTabsView.java | 15 +- .../ui/Components/FragmentContextView.java | 2 +- .../PhotoViewerCaptionEnterView.java | 1 + .../telegram/ui/Components/SeekBarView.java | 1 - .../telegram/ui/Components/StickersAlert.java | 1 - .../java/org/telegram/ui/DialogsActivity.java | 8 +- .../org/telegram/ui/PaymentFormActivity.java | 146 +++++++++--------- .../java/org/telegram/ui/PhotoViewer.java | 3 + .../java/org/telegram/ui/ProfileActivity.java | 21 ++- .../webrtc/voiceengine/WebRtcAudioTrack.java | 2 +- TMessagesProj/src/main/res/values/strings.xml | 2 + 33 files changed, 407 insertions(+), 235 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 4ff19657f..594941617 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -290,7 +290,7 @@ android { } } - defaultConfig.versionCode = 2199 + defaultConfig.versionCode = 2206 applicationVariants.all { variant -> variant.outputs.all { output -> diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java index 5d0171d62..3ada48885 100755 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java @@ -34,10 +34,12 @@ public class SQLitePreparedStatement { if (BuildVars.LOGS_ENABLED) { query = sql; startTime = SystemClock.elapsedRealtime(); - /*if (hashMap == null) { - hashMap = new HashMap<>(); - } - hashMap.put(this, sql);*/ + /*if (BuildVars.DEBUG_PRIVATE_VERSION) { + if (hashMap == null) { + hashMap = new HashMap<>(); + } + hashMap.put(this, sql); + }*/ } } @@ -108,7 +110,7 @@ public class SQLitePreparedStatement { } } try { - /*if (BuildVars.DEBUG_VERSION) { + /*if (BuildVars.DEBUG_PRIVATE_VERSION) { hashMap.remove(this); }*/ isFinalized = true; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index d766334ef..23221774d 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -18,7 +18,7 @@ public class BuildVars { public static boolean LOGS_ENABLED = false; public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; - public static int BUILD_VERSION = 2199; + public static int BUILD_VERSION = 2206; public static String BUILD_VERSION_STRING = "7.3.0"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/DocumentObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/DocumentObject.java index 130d10cda..69f9519c3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/DocumentObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/DocumentObject.java @@ -70,6 +70,9 @@ public class DocumentObject { } public static SvgHelper.SvgDrawable getSvgThumb(TLRPC.Document document, String colorKey, float alpha, float zoom) { + if (document == null) { + return null; + } SvgHelper.SvgDrawable pathThumb = null; for (int b = 0, N2 = document.thumbs.size(); b < N2; b++) { TLRPC.PhotoSize size = document.thumbs.get(b); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index 29a26edc2..b1ff398c6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -1029,6 +1029,10 @@ public class FileLoader extends BaseController { } public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList sizes, int side, boolean byMinSide) { + return getClosestPhotoSizeWithSize(sizes, side, byMinSide, null); + } + + public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList sizes, int side, boolean byMinSide, TLRPC.PhotoSize toIgnore) { if (sizes == null || sizes.isEmpty()) { return null; } @@ -1036,7 +1040,7 @@ public class FileLoader extends BaseController { TLRPC.PhotoSize closestObject = null; for (int a = 0; a < sizes.size(); a++) { TLRPC.PhotoSize obj = sizes.get(a); - if (obj == null || obj instanceof TLRPC.TL_photoSizeEmpty || obj instanceof TLRPC.TL_photoPathSize) { + if (obj == null || obj == toIgnore || obj instanceof TLRPC.TL_photoSizeEmpty || obj instanceof TLRPC.TL_photoPathSize) { continue; } if (byMinSide) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java index 071afd27a..30b0665ef 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java @@ -1068,7 +1068,20 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } } } else { - drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); + if (isAspectFit) { + int bitmapW = drawable.getIntrinsicWidth(); + int bitmapH = drawable.getIntrinsicHeight(); + float realImageW = imageW - sideClip * 2; + float realImageH = imageH - sideClip * 2; + float scaleW = imageW == 0 ? 1.0f : (bitmapW / realImageW); + float scaleH = imageH == 0 ? 1.0f : (bitmapH / realImageH); + float scale = Math.max(scaleW, scaleH); + bitmapW /= scale; + bitmapH /= scale; + drawRegion.set(imageX + (imageW - bitmapW) / 2.0f, imageY + (imageH - bitmapH) / 2.0f, imageX + (imageW + bitmapW) / 2.0f, imageY + (imageH + bitmapH) / 2.0f); + } else { + drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); + } drawable.setBounds((int) drawRegion.left, (int) drawRegion.top, (int) drawRegion.right, (int) drawRegion.bottom); if (isVisible) { try { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index e203a4c8c..4d0e86e03 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -943,6 +943,9 @@ public class MessageObject { } else { emojiAnimatedStickerColor = ""; } + if (!TextUtils.isEmpty(emojiAnimatedStickerColor) && index + 2 < messageText.length()) { + emoji = emoji.toString() + messageText.subSequence(index + 2, messageText.length()).toString(); + } if (TextUtils.isEmpty(emojiAnimatedStickerColor) || EmojiData.emojiColoredMap.contains(emoji.toString())) { emojiAnimatedSticker = MediaDataController.getInstance(currentAccount).getEmojiAnimatedSticker(emoji); } @@ -3082,7 +3085,7 @@ public class MessageObject { } } } - if (photo.dc_id != 0) { + if (photo.dc_id != 0 && photoThumbs != null) { for (int a = 0, N = photoThumbs.size(); a < N; a++) { TLRPC.FileLocation location = photoThumbs.get(a).location; if (location == null) { @@ -3423,12 +3426,6 @@ public class MessageObject { boolean hasEntities; if (messageOwner.send_state != MESSAGE_SEND_STATE_SENT) { hasEntities = false; - for (int a = 0; a < messageOwner.entities.size(); a++) { - if (!(messageOwner.entities.get(a) instanceof TLRPC.TL_inputMessageEntityMentionName)) { - hasEntities = true; - break; - } - } } else { hasEntities = !messageOwner.entities.isEmpty(); } @@ -3918,7 +3915,7 @@ public class MessageObject { } TLRPC.Chat chat = messageOwner.peer_id != null && messageOwner.peer_id.channel_id != 0 ? getChat(null, null, messageOwner.peer_id.channel_id) : null; if (ChatObject.isChannel(chat) && chat.megagroup) { - return chat != null && chat.username != null && chat.username.length() > 0 && !(messageOwner.media instanceof TLRPC.TL_messageMediaContact) && !(messageOwner.media instanceof TLRPC.TL_messageMediaGeo); + return chat.username != null && chat.username.length() > 0 && !(messageOwner.media instanceof TLRPC.TL_messageMediaContact) && !(messageOwner.media instanceof TLRPC.TL_messageMediaGeo); } } } else if (messageOwner.from_id instanceof TLRPC.TL_peerChannel || messageOwner.post) { @@ -5472,7 +5469,7 @@ public class MessageObject { message.media instanceof TLRPC.TL_messageMediaWebPage || message.media == null); } - if (chat.megagroup && message.out || !chat.megagroup && (chat.creator || chat.admin_rights != null && (chat.admin_rights.edit_messages || message.out && chat.admin_rights.post_messages)) && message.post) { + if (chat != null && chat.megagroup && message.out || chat != null && !chat.megagroup && (chat.creator || chat.admin_rights != null && (chat.admin_rights.edit_messages || message.out && chat.admin_rights.post_messages)) && message.post) { if (message.media instanceof TLRPC.TL_messageMediaPhoto || message.media instanceof TLRPC.TL_messageMediaDocument && !isStickerMessage(message) && !isAnimatedStickerMessage(message) || message.media instanceof TLRPC.TL_messageMediaEmpty || diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 0adeeba18..178262995 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -1135,7 +1135,11 @@ public class MessagesController extends BaseController implements NotificationCe allDialogs.clear(); for (int a = 0, size = dialogs_dict.size(); a < size; a++) { - allDialogs.add(dialogs_dict.valueAt(a)); + TLRPC.Dialog dialog = dialogs_dict.valueAt(a); + if (deletingDialogs.indexOfKey(dialog.id) >= 0) { + continue; + } + allDialogs.add(dialog); } sortDialogs(null); getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload); @@ -5805,15 +5809,13 @@ public class MessagesController extends BaseController implements NotificationCe ImageLoader.saveMessagesThumbs(messagesRes.messages); } boolean isInitialLoading = offset_date == 0 && max_id == 0; - boolean requestByTime; + boolean reload; if (mode == 1) { - requestByTime = ((SystemClock.elapsedRealtime() - lastScheduledServerQueryTime.get(dialogId, 0L)) > 60 * 1000); - } else if (mode == 2) { - requestByTime = false; + reload = ((SystemClock.elapsedRealtime() - lastScheduledServerQueryTime.get(dialogId, 0L)) > 60 * 1000); } else { - requestByTime = (SystemClock.elapsedRealtime() - lastServerQueryTime.get(dialogId, 0L)) > 60 * 1000; + reload = resCount == 0 && (!isInitialLoading || (SystemClock.elapsedRealtime() - lastServerQueryTime.get(dialogId, 0L)) > 60 * 1000); } - if (high_id != 1 && lower_id != 0 && isCache && (resCount == 0 && (!isInitialLoading || requestByTime))) { + if (high_id != 1 && lower_id != 0 && isCache && reload) { int hash; if (mode == 2) { hash = 0; @@ -6689,7 +6691,11 @@ public class MessagesController extends BaseController implements NotificationCe allDialogs.clear(); for (int a = 0, size = dialogs_dict.size(); a < size; a++) { - allDialogs.add(dialogs_dict.valueAt(a)); + TLRPC.Dialog dialog = dialogs_dict.valueAt(a); + if (deletingDialogs.indexOfKey(dialog.id) >= 0) { + continue; + } + allDialogs.add(dialog); } sortDialogs(null); dialogsEndReached.put(0, true); @@ -7261,7 +7267,11 @@ public class MessagesController extends BaseController implements NotificationCe allDialogs.clear(); for (int a = 0, size = dialogs_dict.size(); a < size; a++) { - allDialogs.add(dialogs_dict.valueAt(a)); + TLRPC.Dialog dialog = dialogs_dict.valueAt(a); + if (deletingDialogs.indexOfKey(dialog.id) >= 0) { + continue; + } + allDialogs.add(dialog); } sortDialogs(migrate ? chatsDict : null); @@ -7823,7 +7833,11 @@ public class MessagesController extends BaseController implements NotificationCe allDialogs.clear(); for (int a = 0, size = dialogs_dict.size(); a < size; a++) { - allDialogs.add(dialogs_dict.valueAt(a)); + TLRPC.Dialog dialog = dialogs_dict.valueAt(a); + if (deletingDialogs.indexOfKey(dialog.id) >= 0) { + continue; + } + allDialogs.add(dialog); } sortDialogs(null); getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload); @@ -10122,7 +10136,11 @@ public class MessagesController extends BaseController implements NotificationCe if (added) { allDialogs.clear(); for (int a = 0, size = dialogs_dict.size(); a < size; a++) { - allDialogs.add(dialogs_dict.valueAt(a)); + TLRPC.Dialog dialog = dialogs_dict.valueAt(a); + if (deletingDialogs.indexOfKey(dialog.id) >= 0) { + continue; + } + allDialogs.add(dialog); } } sortDialogs(null); @@ -10977,7 +10995,6 @@ public class MessagesController extends BaseController implements NotificationCe ArrayList contactsIds = null; ArrayList messageThumbs = null; - boolean checkForUsers = true; ConcurrentHashMap usersDict; ConcurrentHashMap chatsDict; if (usersArr != null) { @@ -10987,7 +11004,6 @@ public class MessagesController extends BaseController implements NotificationCe usersDict.put(user.id, user); } } else { - checkForUsers = false; usersDict = users; } if (chatsArr != null) { @@ -10997,12 +11013,8 @@ public class MessagesController extends BaseController implements NotificationCe chatsDict.put(chat.id, chat); } } else { - checkForUsers = false; chatsDict = chats; } - if (fromGetDifference) { - checkForUsers = false; - } if (usersArr != null || chatsArr != null) { AndroidUtilities.runOnUIThread(() -> { @@ -11054,7 +11066,7 @@ public class MessagesController extends BaseController implements NotificationCe putChat(chat, true); } } - if (checkForUsers) { + if (!fromGetDifference) { if (chat_id != 0) { if (chat == null) { if (BuildVars.LOGS_ENABLED) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index 7bfa1985b..0adf3454b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -4960,6 +4960,7 @@ public class MessagesStorage extends BaseController { } else { SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(mid) FROM chat_pinned_v2 WHERE uid = %d AND mid IN (%s)", dialogId, TextUtils.join(",", ids))); alreadyAdded = cursor.next() ? cursor.intValue(0) : 0; + cursor.dispose(); } SQLitePreparedStatement state = database.executeFast("REPLACE INTO chat_pinned_v2 VALUES(?, ?, ?)"); for (int a = 0, N = ids.size(); a < N; a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java index 18b7bd170..2aafd8dab 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java @@ -927,7 +927,7 @@ public class SharedConfig { } else { devicePerformanceClass = PERFORMANCE_CLASS_HIGH; } - if (BuildVars.DEBUG_VERSION) { + if (BuildVars.LOGS_ENABLED) { FileLog.d("device performance info (cpu_count = " + cpuCount + ", freq = " + maxCpuFreq + ", memoryClass = " + memoryClass + ", android version " + androidVersion + ")"); } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java index 03f1bf039..ea08a85da 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java @@ -121,6 +121,16 @@ public class SvgHelper { private float colorAlpha; private float crossfadeAlpha; + @Override + public int getIntrinsicHeight() { + return width; + } + + @Override + public int getIntrinsicWidth() { + return height; + } + @Override public void draw(Canvas canvas) { if (currentColorKey != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index 33bb0ceea..c7eaba301 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -18269,87 +18269,85 @@ public class TLRPC { } } - public static abstract class InputPaymentCredentials extends TLObject { - public int flags; - public boolean save; - public TL_dataJSON data; - public TL_dataJSON payment_token; - public String google_transaction_id; - public String id; - public byte[] tmp_password; + public static abstract class InputPaymentCredentials extends TLObject { - public static InputPaymentCredentials TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - InputPaymentCredentials result = null; - switch (constructor) { - case 0x3417d728: - result = new TL_inputPaymentCredentials(); - break; - case 0xca05d50e: - result = new TL_inputPaymentCredentialsAndroidPay(); - break; - case 0xc10eb2cf: - result = new TL_inputPaymentCredentialsSaved(); - break; - } - if (result == null && exception) { - throw new RuntimeException(String.format("can't parse magic %x in InputPaymentCredentials", constructor)); - } - if (result != null) { - result.readParams(stream, exception); - } - return result; - } - } + public int flags; + public boolean save; + public TL_dataJSON data; + public String id; + public byte[] tmp_password; + public TL_dataJSON payment_token; - public static class TL_inputPaymentCredentials extends InputPaymentCredentials { - public static int constructor = 0x3417d728; + public static InputPaymentCredentials TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { + InputPaymentCredentials result = null; + switch (constructor) { + case 0x3417d728: + result = new TL_inputPaymentCredentials(); + break; + case 0x8ac32801: + result = new TL_inputPaymentCredentialsGooglePay(); + break; + case 0xc10eb2cf: + result = new TL_inputPaymentCredentialsSaved(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in InputPaymentCredentials", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_inputPaymentCredentials extends InputPaymentCredentials { + public static int constructor = 0x3417d728; - public void readParams(AbstractSerializedData stream, boolean exception) { - flags = stream.readInt32(exception); - save = (flags & 1) != 0; - data = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception); - } + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + save = (flags & 1) != 0; + data = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception); + } - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - flags = save ? (flags | 1) : (flags &~ 1); - stream.writeInt32(flags); - data.serializeToStream(stream); - } - } + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + flags = save ? (flags | 1) : (flags &~ 1); + stream.writeInt32(flags); + data.serializeToStream(stream); + } + } - public static class TL_inputPaymentCredentialsAndroidPay extends InputPaymentCredentials { - public static int constructor = 0xca05d50e; + public static class TL_inputPaymentCredentialsGooglePay extends InputPaymentCredentials { + public static int constructor = 0x8ac32801; - public void readParams(AbstractSerializedData stream, boolean exception) { - payment_token = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception); - google_transaction_id = stream.readString(exception); - } + public void readParams(AbstractSerializedData stream, boolean exception) { + payment_token = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception); + } - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - payment_token.serializeToStream(stream); - stream.writeString(google_transaction_id); - } - } + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + payment_token.serializeToStream(stream); + } + } - public static class TL_inputPaymentCredentialsSaved extends InputPaymentCredentials { - public static int constructor = 0xc10eb2cf; + public static class TL_inputPaymentCredentialsSaved extends InputPaymentCredentials { + public static int constructor = 0xc10eb2cf; - public void readParams(AbstractSerializedData stream, boolean exception) { - id = stream.readString(exception); - tmp_password = stream.readByteArray(exception); - } + public void readParams(AbstractSerializedData stream, boolean exception) { + id = stream.readString(exception); + tmp_password = stream.readByteArray(exception); + } - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(id); - stream.writeByteArray(tmp_password); - } - } + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(id); + stream.writeByteArray(tmp_password); + } + } public static class TL_exportedMessageLink extends TLObject { public static int constructor = 0x5dab1af4; 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 7215e1000..d09823e51 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -12,6 +12,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.app.Activity; import android.content.Context; import android.content.res.Configuration; import android.graphics.Canvas; @@ -29,12 +30,16 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewPropertyAnimator; +import android.view.animation.OvershootInterpolator; import android.widget.FrameLayout; import android.widget.ImageView; +import com.google.android.exoplayer2.util.Log; + import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; +import org.telegram.messenger.SharedConfig; import org.telegram.ui.Adapters.FiltersView; import org.telegram.ui.Components.EllipsizeSpanAnimator; import org.telegram.ui.Components.FireworksEffect; @@ -59,6 +64,8 @@ public class ActionBar extends FrameLayout { private SimpleTextView[] titleTextView = new SimpleTextView[2]; private SimpleTextView subtitleTextView; private View actionModeTop; + private int actionModeColor; + private int actionBarColor; private ActionBarMenu menu; private ActionBarMenu actionMode; private String actionModeTag; @@ -208,16 +215,26 @@ public class ActionBar extends FrameLayout { canvas.clipRect(0, -getTranslationY() + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0), getMeasuredWidth(), getMeasuredHeight()); } boolean result = super.drawChild(canvas, child, drawingTime); - if (supportsHolidayImage && !titleOverlayShown && !LocaleController.isRTL && child == titleTextView[0]) { + if (supportsHolidayImage && !titleOverlayShown && !LocaleController.isRTL && (child == titleTextView[0] || child == titleTextView[1])) { Drawable drawable = Theme.getCurrentHolidayDrawable(); if (drawable != null) { - TextPaint textPaint = titleTextView[0].getTextPaint(); - textPaint.getFontMetricsInt(fontMetricsInt); - textPaint.getTextBounds((String) titleTextView[0].getText(), 0, 1, rect); - int x = titleTextView[0].getTextStartX() + Theme.getCurrentHolidayDrawableXOffset() + (rect.width() - (drawable.getIntrinsicWidth() + Theme.getCurrentHolidayDrawableXOffset())) / 2; - int y = titleTextView[0].getTextStartY() + Theme.getCurrentHolidayDrawableYOffset() + (int) Math.ceil((titleTextView[0].getTextHeight() - rect.height()) / 2.0f); - drawable.setBounds(x, y - drawable.getIntrinsicHeight(), x + drawable.getIntrinsicWidth(), y); - drawable.draw(canvas); + + SimpleTextView titleView = (SimpleTextView) child; + if (titleView.getVisibility() == View.VISIBLE && titleView.getText() instanceof String) { + TextPaint textPaint = titleView.getTextPaint(); + textPaint.getFontMetricsInt(fontMetricsInt); + textPaint.getTextBounds((String) titleView.getText(), 0, 1, rect); + int x = titleView.getTextStartX() + Theme.getCurrentHolidayDrawableXOffset() + (rect.width() - (drawable.getIntrinsicWidth() + Theme.getCurrentHolidayDrawableXOffset())) / 2; + int y = titleView.getTextStartY() + Theme.getCurrentHolidayDrawableYOffset() + (int) Math.ceil((titleView.getTextHeight() - rect.height()) / 2.0f); + drawable.setBounds(x, y - drawable.getIntrinsicHeight(), x + drawable.getIntrinsicWidth(), y); + drawable.setAlpha((int) (255 * titleView.getAlpha())); + drawable.draw(canvas); + if (overlayTitleAnimationInProgress) { + child.invalidate(); + invalidate(); + } + } + if (Theme.canStartHolidayAnimation()) { if (snowflakesEffect == null) { snowflakesEffect = new SnowflakesEffect(); @@ -433,7 +450,7 @@ public class ActionBar extends FrameLayout { actionMode = new ActionBarMenu(getContext(), this); actionMode.isActionMode = true; actionMode.setClickable(true); - actionMode.setBackgroundColor(Theme.getColor(Theme.key_actionBarActionModeDefault)); + actionMode.setBackgroundColor(actionModeColor = Theme.getColor(Theme.key_actionBarActionModeDefault)); addView(actionMode, indexOfChild(backButtonImageView)); actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) actionMode.getLayoutParams(); @@ -487,9 +504,16 @@ public class ActionBar extends FrameLayout { actionModeExtraView = extraView; actionModeShowingView = showingView; actionModeHidingViews = hidingViews; - if (occupyStatusBar && actionModeTop != null) { + if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) { animators.add(ObjectAnimator.ofFloat(actionModeTop, View.ALPHA, 0.0f, 1.0f)); } + if (SharedConfig.noStatusBar) { + if (AndroidUtilities.computePerceivedBrightness(actionModeColor) < 0.721f) { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), false); + } else { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), true); + } + } if (actionModeAnimation != null) { actionModeAnimation.cancel(); } @@ -500,7 +524,7 @@ public class ActionBar extends FrameLayout { @Override public void onAnimationStart(Animator animation) { actionMode.setVisibility(VISIBLE); - if (occupyStatusBar && actionModeTop != null) { + if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) { actionModeTop.setVisibility(VISIBLE); } } @@ -570,9 +594,16 @@ public class ActionBar extends FrameLayout { if (actionModeShowingView != null) { animators.add(ObjectAnimator.ofFloat(actionModeShowingView, View.ALPHA, 0.0f)); } - if (occupyStatusBar && actionModeTop != null) { + if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) { animators.add(ObjectAnimator.ofFloat(actionModeTop, View.ALPHA, 0.0f)); } + if (SharedConfig.noStatusBar) { + if (AndroidUtilities.computePerceivedBrightness(actionBarColor) < 0.721f) { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), false); + } else { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), true); + } + } if (actionModeAnimation != null) { actionModeAnimation.cancel(); } @@ -585,7 +616,7 @@ public class ActionBar extends FrameLayout { if (actionModeAnimation != null && actionModeAnimation.equals(animation)) { actionModeAnimation = null; actionMode.setVisibility(INVISIBLE); - if (occupyStatusBar && actionModeTop != null) { + if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) { actionModeTop.setVisibility(INVISIBLE); } if (actionModeExtraView != null) { @@ -649,10 +680,15 @@ public class ActionBar extends FrameLayout { public void setActionModeColor(int color) { if (actionMode != null) { - actionMode.setBackgroundColor(color); + actionMode.setBackgroundColor(actionModeColor = color); } } + @Override + public void setBackgroundColor(int color) { + super.setBackgroundColor(actionBarColor = color); + } + public boolean isActionModeShowed() { return actionMode != null && actionModeVisible; } @@ -1172,12 +1208,26 @@ public class ActionBar extends FrameLayout { protected void onAttachedToWindow() { super.onAttachedToWindow(); ellipsizeSpanAnimator.onAttachedToWindow(); + if (SharedConfig.noStatusBar && actionModeVisible) { + if (AndroidUtilities.computePerceivedBrightness(actionModeColor) < 0.721f) { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), false); + } else { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), true); + } + } } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); ellipsizeSpanAnimator.onDetachedFromWindow(); + if (SharedConfig.noStatusBar && actionModeVisible) { + if (AndroidUtilities.computePerceivedBrightness(actionBarColor) < 0.721f) { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), false); + } else { + AndroidUtilities.setLightStatusBar(((Activity) getContext()).getWindow(), true); + } + } } public ActionBarMenu getActionMode() { 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 776a32d5b..8321193b7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -821,7 +821,16 @@ public class ActionBarLayout extends FrameLayout { ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent(); if (parent != null) { fragment.onRemoveFromParent(); - parent.removeViewInLayout(fragment.fragmentView); + try { + parent.removeViewInLayout(fragment.fragmentView); + } catch (Exception e) { + FileLog.e(e); + try { + parent.removeView(fragment.fragmentView); + } catch (Exception e2) { + FileLog.e(e2); + } + } } } if (fragment.actionBar != null && fragment.actionBar.shouldAddToContainer()) { 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 ec503a0ba..c05de6e3c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -4438,6 +4438,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } else if (o1.decimal < o2.decimal) { return 1; } + if (o1.decimal == o2.decimal) { + if (o1.percent > o2.percent) { + return 1; + } else if (o1.percent < o2.percent) { + return -1; + } + } return 0; }); for (int a = 0, N = Math.min(restPercent, sortedPollButtons.size()); a < N; a++) { @@ -4847,7 +4854,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate maxPhotoWidth = photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); } else { if (currentPhotoObject != null && (messageObject.type == MessageObject.TYPE_PHOTO || messageObject.type == MessageObject.TYPE_VIDEO || messageObject.type == 8) && currentPhotoObject.w >= currentPhotoObject.h) { - maxPhotoWidth = photoWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp((drawAvatar ? 116 : 64) + (checkNeedDrawShareButton(messageObject) ? 10 : 0)); + maxPhotoWidth = photoWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(64 + (checkNeedDrawShareButton(messageObject) ? 10 : 0)); useFullWidth = true; } else { maxPhotoWidth = photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); @@ -4857,7 +4864,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate photoHeight = photoWidth + AndroidUtilities.dp(100); if (!useFullWidth) { if (messageObject.type != 5 && checkNeedDrawShareButton(messageObject)) { - maxPhotoWidth -= AndroidUtilities.dp(20); photoWidth -= AndroidUtilities.dp(20); } if (photoWidth > AndroidUtilities.getPhotoSize()) { @@ -4983,7 +4989,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } availableTimeWidth = firstLineWidth - AndroidUtilities.dp(35); } else { - availableTimeWidth = maxPhotoWidth - AndroidUtilities.dp(14); + availableTimeWidth = photoWidth - AndroidUtilities.dp(14); } if (messageObject.type == MessageObject.TYPE_ROUND_VIDEO) { availableTimeWidth -= Math.ceil(Theme.chat_audioTimePaint.measureText("00:00")) + AndroidUtilities.dp(26); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java index 784e1dff1..a2a663ab5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java @@ -28,6 +28,7 @@ import android.view.animation.AccelerateInterpolator; import android.widget.FrameLayout; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.DocumentObject; import org.telegram.messenger.DownloadController; import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLoader; @@ -40,6 +41,7 @@ import org.telegram.messenger.MediaController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; +import org.telegram.messenger.SvgHelper; import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; import org.telegram.messenger.WebFile; @@ -341,11 +343,20 @@ public class ContextLinkCell extends FrameLayout implements DownloadController.F } } else { if (currentPhotoObject != null) { + SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(documentAttach, Theme.key_windowBackgroundGray, 1.0f); if (MessageObject.canAutoplayAnimatedSticker(documentAttach)) { - linkImageView.setImage(ImageLocation.getForDocument(documentAttach), "80_80", ImageLocation.getForDocument(currentPhotoObject, documentAttach), currentPhotoFilterThumb, currentPhotoObject.size, null, parentObject, 0); + if (svgThumb != null) { + linkImageView.setImage(ImageLocation.getForDocument(documentAttach), "80_80", svgThumb, currentPhotoObject.size, ext, parentObject, 0); + } else { + linkImageView.setImage(ImageLocation.getForDocument(documentAttach), "80_80", ImageLocation.getForDocument(currentPhotoObject, documentAttach), currentPhotoFilterThumb, currentPhotoObject.size, ext, parentObject, 0); + } } else { if (documentAttach != null) { - linkImageView.setImage(ImageLocation.getForDocument(currentPhotoObject, documentAttach), currentPhotoFilter, ImageLocation.getForPhoto(currentPhotoObjectThumb, photoAttach), currentPhotoFilterThumb, currentPhotoObject.size, ext, parentObject, 0); + if (svgThumb != null) { + linkImageView.setImage(ImageLocation.getForDocument(currentPhotoObject, documentAttach), currentPhotoFilter, svgThumb, currentPhotoObject.size, ext, parentObject, 0); + } else { + linkImageView.setImage(ImageLocation.getForDocument(currentPhotoObject, documentAttach), currentPhotoFilter, ImageLocation.getForPhoto(currentPhotoObjectThumb, photoAttach), currentPhotoFilterThumb, currentPhotoObject.size, ext, parentObject, 0); + } } else { linkImageView.setImage(ImageLocation.getForPhoto(currentPhotoObject, photoAttach), currentPhotoFilter, ImageLocation.getForPhoto(currentPhotoObjectThumb, photoAttach), currentPhotoFilterThumb, currentPhotoObject.size, ext, parentObject, 0); } 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 c80706e50..f17f02e60 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -267,6 +267,7 @@ public class DialogCell extends BaseCell { private boolean statusDrawableAnimationInProgress; private ValueAnimator statusDrawableAnimator; long lastDialogChangedTime; + private int statusDrawableLeft; public static class BounceInterpolator implements Interpolator { @@ -841,12 +842,8 @@ public class DialogCell extends BaseCell { startPadding = statusDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3); } SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && LocaleController.isRTL && (int) currentDialogId < 0) { - spannableStringBuilder.append(TextUtils.replace(printingString, new String[]{"..."}, new String[]{""})).append(" "); - spannableStringBuilder.setSpan(new FixedWidthSpan(startPadding), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0); - } else { - spannableStringBuilder.append(" ").append(TextUtils.replace(printingString, new String[]{"..."}, new String[]{""})).setSpan(new FixedWidthSpan(startPadding), 0, 1, 0); - } + spannableStringBuilder.append(" ").append(TextUtils.replace(printingString, new String[]{"..."}, new String[]{""})).setSpan(new FixedWidthSpan(startPadding), 0, 1, 0); + messageString = spannableStringBuilder; currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex]; checkMessage = false; @@ -1683,6 +1680,15 @@ public class DialogCell extends BaseCell { FileLog.e(e); } } + if (messageLayout != null && printingStringType >= 0) { + float x1 = messageLayout.getPrimaryHorizontal(0); + float x2 = messageLayout.getPrimaryHorizontal(1); + if (x1 < x2) { + statusDrawableLeft = (int) (messageLeft + x1); + } else { + statusDrawableLeft = (int) (messageLeft + x2 + AndroidUtilities.dp(3)); + } + } } private void drawCheckStatus(Canvas canvas, boolean drawClock, boolean drawCheck1, boolean drawCheck2, boolean moveCheck, float alpha) { @@ -2435,14 +2441,13 @@ public class DialogCell extends BaseCell { StatusDrawable statusDrawable = Theme.getChatStatusDrawable(printingStringType); if (statusDrawable != null) { canvas.save(); - int left = (LocaleController.isRTL || messageLayout.isRtlCharAt(0)) ? getMeasuredWidth() - AndroidUtilities.dp(72) - statusDrawable.getIntrinsicWidth() : messageLeft; if (printingStringType == 1 || printingStringType == 4) { - canvas.translate(left, messageTop + (printingStringType == 1 ? AndroidUtilities.dp(1) : 0)); + canvas.translate(statusDrawableLeft, messageTop + (printingStringType == 1 ? AndroidUtilities.dp(1) : 0)); } else { - canvas.translate(left, messageTop + (AndroidUtilities.dp(18) - statusDrawable.getIntrinsicHeight()) / 2f); + canvas.translate(statusDrawableLeft, messageTop + (AndroidUtilities.dp(18) - statusDrawable.getIntrinsicHeight()) / 2f); } statusDrawable.draw(canvas); - invalidate(left, messageTop, left + statusDrawable.getIntrinsicWidth(), messageTop + statusDrawable.getIntrinsicHeight()); + invalidate(statusDrawableLeft, messageTop, statusDrawableLeft + statusDrawable.getIntrinsicWidth(), messageTop + statusDrawable.getIntrinsicHeight()); canvas.restore(); } } @@ -2965,8 +2970,12 @@ public class DialogCell extends BaseCell { @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); - info.addAction(AccessibilityNodeInfo.ACTION_CLICK); - info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK); + if (currentDialogFolderId != 0 && archiveHidden) { + info.setVisibleToUser(false); + } else { + info.addAction(AccessibilityNodeInfo.ACTION_CLICK); + info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK); + } } @Override 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 6b1becbaf..b3b5eba75 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java @@ -26,6 +26,7 @@ import android.os.Build; import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; +import android.view.accessibility.AccessibilityNodeInfo; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -116,7 +117,17 @@ public class DrawerProfileCell extends FrameLayout { sunDrawable.setCurrentFrame(36); } sunDrawable.setPlayInDirectionOfCustomEndFrame(true); - darkThemeView = new RLottieImageView(context); + darkThemeView = new RLottieImageView(context) { + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + if (sunDrawable.getCustomEndFrame() == 0) { + info.setText(LocaleController.getString("AccDescrSwitchToNightTheme", R.string.AccDescrSwitchToNightTheme)); + } else { + info.setText(LocaleController.getString("AccDescrSwitchToDayTheme", R.string.AccDescrSwitchToDayTheme)); + } + } + }; sunDrawable.beginApplyLayerColors(); int color = Theme.getColor(Theme.key_chats_menuName); sunDrawable.setLayerColor("Sunny.**", color); 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 53704514e..42ff187fe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java @@ -192,13 +192,13 @@ public class SharedPhotoVideoCell extends FrameLayout { } } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) { videoInfoContainer.setVisibility(INVISIBLE); - TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320); TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 50); + TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320, false, currentPhotoObjectThumb); if (messageObject.mediaExists || DownloadController.getInstance(currentAccount).canDownloadMedia(messageObject)) { if (currentPhotoObject == currentPhotoObjectThumb) { currentPhotoObjectThumb = null; } - imageView.getImageReceiver().setImage(ImageLocation.getForObject(currentPhotoObject, messageObject.photoThumbsObject), "100_100", ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", currentPhotoObject.size, null, messageObject, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 1); + imageView.getImageReceiver().setImage(ImageLocation.getForObject(currentPhotoObject, messageObject.photoThumbsObject), "100_100", ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", currentPhotoObject != null ? currentPhotoObject.size : 0, null, messageObject, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 1); } else { imageView.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, null, 0, messageObject); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 059d22b8e..8fedbb7dc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -6971,6 +6971,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, dialog_id, ids, false, null, null, 0, 0, true); } + if (pinBulletin != null) { + pinBulletin.hide(); + } showPinBulletin = true; int tag = ++pinBullerinTag; int oldTotalPinnedCount = getPinnedMessagesCount(); @@ -9842,7 +9845,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (view instanceof ChatMessageCell) { ChatMessageCell messageCell = (ChatMessageCell) view; messageObject = messageCell.getMessageObject(); - if (messageObject.getId() > maxVisibleId) { + if (messageObject.getDialogId() == dialog_id && messageObject.getId() > maxVisibleId) { maxVisibleId = messageObject.getId(); maxVisibleMessageObject = messageObject; } @@ -9873,7 +9876,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else if (view instanceof ChatActionCell) { messageObject = ((ChatActionCell) view).getMessageObject(); - if (messageObject != null) { + if (messageObject != null && messageObject.getDialogId() == dialog_id && messageObject.getId() > maxVisibleId) { maxVisibleId = Math.max(maxVisibleId, messageObject.getId()); } } else if (view instanceof BotHelpCell) { @@ -18485,6 +18488,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (messageObject == null) { return; } + if (pinBulletin != null) { + pinBulletin.hide(false); + } ArrayList objects = new ArrayList<>(); objects.add(selectedObject); ArrayList ids = new ArrayList<>(); @@ -18747,7 +18753,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not messageObjects.add(selectedObject); } MediaController.saveFilesFromMessages(getParentActivity(), getAccountInstance(), messageObjects, (count) -> { - if (getParentActivity() == null) { + if (getParentActivity() == null || fragmentView == null) { return; } if (count > 0) { @@ -19956,7 +19962,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not args.putLong("dialog_id", dialog_id); } } - ProfileActivity fragment = new ProfileActivity(args); + ProfileActivity fragment = new ProfileActivity(args, avatarContainer.getSharedMediaPreloader()); fragment.setPlayProfileAnimation(1); fragment.setChatInfo(chatInfo); fragment.setUserInfo(userInfo); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java index 14c1ea04c..48e2a80db 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java @@ -35,15 +35,15 @@ public final class BulletinFactory { MEDIA("MediaSavedHint", Icon.SAVED_TO_GALLERY), - PHOTO_TO_DOWNLOADS("PhotoSavedToDownloadsHint", Icon.SAVED_TO_DOWNLOADS), + PHOTO_TO_DOWNLOADS("PhotoSavedToDownloadsHint", R.string.PhotoSavedToDownloadsHint, Icon.SAVED_TO_DOWNLOADS), VIDEO_TO_DOWNLOADS("VideoSavedToDownloadsHint", R.string.VideoSavedToDownloadsHint, Icon.SAVED_TO_DOWNLOADS), GIF("GifSavedToDownloadsHint", Icon.SAVED_TO_DOWNLOADS), - AUDIO("AudioSavedHint", Icon.SAVED_TO_MUSIC), + AUDIO("AudioSavedHint", R.string.AudioSavedHint, Icon.SAVED_TO_MUSIC), AUDIOS("AudiosSavedHint", Icon.SAVED_TO_MUSIC), - UNKNOWN("FileSavedHint", Icon.SAVED_TO_DOWNLOADS), + UNKNOWN("FileSavedHint", R.string.FileSavedHint, Icon.SAVED_TO_DOWNLOADS), UNKNOWNS("FilesSavedHint", Icon.SAVED_TO_DOWNLOADS); private final String localeKey; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java index 4b140cbee..a7bf924b6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java @@ -671,4 +671,8 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, LocaleController.getString("OpenProfile", R.string.OpenProfile))); } } + + public SharedMediaLayout.SharedMediaPreloader getSharedMediaPreloader() { + return sharedMediaPreloader; + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java index 14cb4a079..84bb8822b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java @@ -20,17 +20,18 @@ import android.graphics.Paint; import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; +import android.os.Build; import android.os.SystemClock; import android.text.Layout; import android.text.SpannableStringBuilder; import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; -import android.util.Log; import android.util.Property; import android.util.SparseIntArray; import android.view.View; import android.view.ViewGroup; +import android.view.accessibility.AccessibilityNodeInfo; import android.widget.FrameLayout; import android.widget.TextView; @@ -169,6 +170,7 @@ public class FilterTabsView extends FrameLayout { public void setTab(Tab tab, int position) { currentTab = tab; currentPosition = position; + setContentDescription(tab.title); requestLayout(); } @@ -550,6 +552,17 @@ public class FilterTabsView extends FrameLayout { return changed; } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + info.addAction(AccessibilityNodeInfo.ACTION_CLICK); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, LocaleController.getString("AccDescrOpenMenu2", R.string.AccDescrOpenMenu2))); + } else { + info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK); + } + } } private TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java index 5a47bf71e..35bec2ca9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java @@ -533,7 +533,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent } private void openSharingLocation(final LocationController.SharingLocationInfo info) { - if (info == null || fragment.getParentActivity() == null) { + if (info == null || !(fragment.getParentActivity() instanceof LaunchActivity)) { return; } LaunchActivity launchActivity = ((LaunchActivity) fragment.getParentActivity()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java index 568a15b48..f16d9f6f8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java @@ -201,6 +201,7 @@ public class PhotoViewerCaptionEnterView extends FrameLayout implements Notifica messageEditText.setWindowView(windowView); messageEditText.setHint(LocaleController.getString("AddCaption", R.string.AddCaption)); messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); + messageEditText.setLinkTextColor(0xff76c2f1); messageEditText.setInputType(messageEditText.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES); messageEditText.setMaxLines(4); messageEditText.setHorizontallyScrolling(false); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarView.java index a422c6625..070138408 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarView.java @@ -10,7 +10,6 @@ package org.telegram.ui.Components; import android.content.Context; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.os.Build; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java index 023fb5e0a..4df4a631f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java @@ -39,7 +39,6 @@ import android.widget.TextView; import android.widget.Toast; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.MediaDataController; import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLoader; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 7d48c6d88..179c07945 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -3069,7 +3069,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } if (!onlySelect && initialDialogsType == 0) { - blurredView = new View(context); + blurredView = new View(context) { + @Override + public void setAlpha(float alpha) { + super.setAlpha(alpha); + fragmentView.invalidate(); + } + }; blurredView.setVisibility(View.GONE); contentView.addView(blurredView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java index bbd0b514f..f2a7f031d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java @@ -60,7 +60,6 @@ import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.common.api.Status; -import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.android.gms.wallet.AutoResolveHelper; import com.google.android.gms.wallet.IsReadyToPayRequest; @@ -191,7 +190,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen private TextCheckCell checkCell1; private TextInfoPrivacyCell[] bottomCell = new TextInfoPrivacyCell[3]; private TextSettingsCell[] settingsCell = new TextSettingsCell[2]; - private FrameLayout androidPayContainer; + private FrameLayout googlePayContainer; private FrameLayout googlePayButton; private LinearLayout linearLayout2; @@ -215,6 +214,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen private boolean need_card_postcode; private boolean need_card_name; private String stripeApiKey; + private boolean initGooglePay; private TLRPC.User botUser; @@ -236,10 +236,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen private TLRPC.TL_payments_validatedRequestedInfo requestedInfo; private TLRPC.TL_shippingOption shippingOption; private TLRPC.TL_payments_validateRequestedInfo validateRequest; - private TLRPC.TL_inputPaymentCredentialsAndroidPay androidPayCredentials; - private String androidPayPublicKey; - private int androidPayBackgroundColor; - private boolean androidPayBlackTheme; + private TLRPC.TL_inputPaymentCredentialsGooglePay googlePayCredentials; + private String googlePayPublicKey; + private String googlePayCountryCode; + private JSONObject googlePayParameters; private MessageObject messageObject; private boolean donePressed; private boolean canceled; @@ -254,7 +254,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen private static final int LOAD_PAYMENT_DATA_REQUEST_CODE = 991; private interface PaymentFormActivityDelegate { - boolean didSelectNewCard(String tokenJson, String card, boolean saveCard, TLRPC.TL_inputPaymentCredentialsAndroidPay androidPay); + boolean didSelectNewCard(String tokenJson, String card, boolean saveCard, TLRPC.TL_inputPaymentCredentialsGooglePay googlePay); void onFragmentDestroyed(); void currentPasswordUpdated(TLRPC.TL_account_password password); } @@ -340,8 +340,8 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen init(form, message, step, null, null, null, null, null, false, null); } - private PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message, int step, TLRPC.TL_payments_validatedRequestedInfo validatedRequestedInfo, TLRPC.TL_shippingOption shipping, String tokenJson, String card, TLRPC.TL_payments_validateRequestedInfo request, boolean saveCard, TLRPC.TL_inputPaymentCredentialsAndroidPay androidPay) { - init(form, message, step, validatedRequestedInfo, shipping, tokenJson, card, request, saveCard, androidPay); + private PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message, int step, TLRPC.TL_payments_validatedRequestedInfo validatedRequestedInfo, TLRPC.TL_shippingOption shipping, String tokenJson, String card, TLRPC.TL_payments_validateRequestedInfo request, boolean saveCard, TLRPC.TL_inputPaymentCredentialsGooglePay googlePay) { + init(form, message, step, validatedRequestedInfo, shipping, tokenJson, card, request, saveCard, googlePay); } private void setCurrentPassword(TLRPC.TL_account_password password) { @@ -363,10 +363,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen delegate = paymentFormActivityDelegate; } - private void init(TLRPC.TL_payments_paymentForm form, MessageObject message, int step, TLRPC.TL_payments_validatedRequestedInfo validatedRequestedInfo, TLRPC.TL_shippingOption shipping, String tokenJson, String card, TLRPC.TL_payments_validateRequestedInfo request, boolean saveCard, TLRPC.TL_inputPaymentCredentialsAndroidPay androidPay) { + private void init(TLRPC.TL_payments_paymentForm form, MessageObject message, int step, TLRPC.TL_payments_validatedRequestedInfo validatedRequestedInfo, TLRPC.TL_shippingOption shipping, String tokenJson, String card, TLRPC.TL_payments_validateRequestedInfo request, boolean saveCard, TLRPC.TL_inputPaymentCredentialsGooglePay googlePay) { currentStep = step; paymentJson = tokenJson; - androidPayCredentials = androidPay; + googlePayCredentials = googlePay; requestedInfo = validatedRequestedInfo; paymentForm = form; shippingOption = shipping; @@ -973,34 +973,22 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen if (paymentForm.native_params != null) { try { JSONObject jsonObject = new JSONObject(paymentForm.native_params.data); - try { - String androidPayKey = jsonObject.getString("android_pay_public_key"); - if (!TextUtils.isEmpty(androidPayKey)) { - androidPayPublicKey = androidPayKey; - } - } catch (Exception e) { - androidPayPublicKey = null; - } - try { - androidPayBackgroundColor = jsonObject.getInt("android_pay_bgcolor") | 0xff000000; - } catch (Exception e) { - androidPayBackgroundColor = 0xffffffff; - } - try { - androidPayBlackTheme = jsonObject.getBoolean("android_pay_inverse"); - } catch (Exception e) { - androidPayBlackTheme = false; + String googlePayKey = jsonObject.optString("google_pay_public_key"); + if (!TextUtils.isEmpty(googlePayKey)) { + googlePayPublicKey = googlePayKey; } + googlePayCountryCode = jsonObject.optString("acquirer_bank_country"); + googlePayParameters = jsonObject.optJSONObject("gpay_parameters"); } catch (Exception e) { FileLog.e(e); } } if (isWebView) { - if (androidPayPublicKey != null) { - initAndroidPay(context); + if (googlePayPublicKey != null || googlePayParameters != null) { + initGooglePay(context); } - createAndroidPayButton(context); - linearLayout2.addView(androidPayContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50)); + createGooglePayButton(context); + linearLayout2.addView(googlePayContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50)); webviewLoading = true; showEditDoneProgress(true, true); @@ -1093,13 +1081,14 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen } catch (Exception e) { stripeApiKey = ""; } + initGooglePay = !jsonObject.optBoolean("google_pay_hidden", false); } catch (Exception e) { FileLog.e(e); } } - if (!TextUtils.isEmpty(stripeApiKey)) { - initAndroidPay(context); + if (initGooglePay && (!TextUtils.isEmpty(stripeApiKey) || googlePayParameters != null)) { + initGooglePay(context); } inputFields = new EditTextBoldCursor[FIELDS_COUNT_CARD]; @@ -1500,8 +1489,8 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen updateSavePaymentField(); linearLayout2.addView(bottomCell[0], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } else if (a == FIELD_CARD) { - createAndroidPayButton(context); - container.addView(androidPayContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 4, 0)); + createGooglePayButton(context); + container.addView(googlePayContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 4, 0)); } if (allowDivider) { @@ -1690,12 +1679,12 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen PaymentFormActivity activity = new PaymentFormActivity(paymentForm, messageObject, 2, requestedInfo, shippingOption, null, cardName, validateRequest, saveCardInfo, null); activity.setDelegate(new PaymentFormActivityDelegate() { @Override - public boolean didSelectNewCard(String tokenJson, String card, boolean saveCard, TLRPC.TL_inputPaymentCredentialsAndroidPay androidPay) { + public boolean didSelectNewCard(String tokenJson, String card, boolean saveCard, TLRPC.TL_inputPaymentCredentialsGooglePay googlePay) { paymentForm.saved_credentials = null; paymentJson = tokenJson; saveCardInfo = saveCard; cardName = card; - androidPayCredentials = androidPay; + googlePayCredentials = googlePay; detailSettingsCell[0].setTextAndValue(cardName, LocaleController.getString("PaymentCheckoutMethod", R.string.PaymentCheckoutMethod), true); return false; } @@ -2050,43 +2039,47 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen return fragmentView; } - private void createAndroidPayButton(Context context) { - androidPayContainer = new FrameLayout(context); - androidPayContainer.setBackgroundDrawable(Theme.getSelectorDrawable(true)); - androidPayContainer.setVisibility(View.GONE); + private void createGooglePayButton(Context context) { + googlePayContainer = new FrameLayout(context); + googlePayContainer.setBackgroundDrawable(Theme.getSelectorDrawable(true)); + googlePayContainer.setVisibility(View.GONE); googlePayButton = new FrameLayout(context); googlePayButton.setClickable(true); googlePayButton.setFocusable(true); googlePayButton.setBackgroundResource(R.drawable.googlepay_button_no_shadow_background); - if (androidPayPublicKey == null) { + if (googlePayPublicKey == null) { googlePayButton.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(2), AndroidUtilities.dp(10), AndroidUtilities.dp(2)); } else { googlePayButton.setPadding(AndroidUtilities.dp(2), AndroidUtilities.dp(2), AndroidUtilities.dp(2), AndroidUtilities.dp(2)); } - androidPayContainer.addView(googlePayButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48)); + googlePayContainer.addView(googlePayButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48)); googlePayButton.setOnClickListener(v -> { googlePayButton.setClickable(false); try { JSONObject paymentDataRequest = getBaseRequest(); JSONObject cardPaymentMethod = getBaseCardPaymentMethod(); - if (androidPayPublicKey != null) { + if (googlePayPublicKey != null && googlePayParameters == null) { cardPaymentMethod.put("tokenizationSpecification", new JSONObject() {{ put("type", "DIRECT"); put("parameters", new JSONObject() {{ put("protocolVersion", "ECv2"); - put("publicKey", androidPayPublicKey); + put("publicKey", googlePayPublicKey); }}); }}); } else { cardPaymentMethod.put("tokenizationSpecification", new JSONObject() {{ put("type", "PAYMENT_GATEWAY"); - put("parameters", new JSONObject() {{ - put("gateway", "stripe"); - put("stripe:publishableKey", stripeApiKey); - put("stripe:version", StripeApiHandler.VERSION); - }}); + if (googlePayParameters != null) { + put("parameters", googlePayParameters); + } else { + put("parameters", new JSONObject() {{ + put("gateway", "stripe"); + put("stripe:publishableKey", stripeApiKey); + put("stripe:version", StripeApiHandler.VERSION); + }}); + } }}); } @@ -2099,7 +2092,9 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen } transactionInfo.put("totalPrice", totalPriceDecimal = getTotalPriceDecimalString(arrayList)); transactionInfo.put("totalPriceStatus", "FINAL"); - transactionInfo.put("countryCode", countryName); + if (!TextUtils.isEmpty(googlePayCountryCode)) { + transactionInfo.put("countryCode", googlePayCountryCode); + } transactionInfo.put("currencyCode", paymentForm.invoice.currency); transactionInfo.put("checkoutOption", "COMPLETE_IMMEDIATE_PURCHASE"); paymentDataRequest.put("transactionInfo", transactionInfo); @@ -2120,7 +2115,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen AutoResolveHelper.resolveTask(paymentsClient.loadPaymentData(request), getParentActivity(), LOAD_PAYMENT_DATA_REQUEST_CODE); } } catch (JSONException e) { - throw new RuntimeException("The price cannot be deserialized from the JSON object."); + FileLog.e(e); } }); @@ -2307,7 +2302,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen } } - private void initAndroidPay(Context context) { + private void initGooglePay(Context context) { if (Build.VERSION.SDK_INT < 19 || getParentActivity() == null) { return; } @@ -2328,12 +2323,12 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen Task task = paymentsClient.isReadyToPay(request); task.addOnCompleteListener(getParentActivity(), - (OnCompleteListener) task1 -> { + task1 -> { if (task1.isSuccessful()) { - if (androidPayContainer != null) { - androidPayContainer.setVisibility(View.VISIBLE); + if (googlePayContainer != null) { + googlePayContainer.setVisibility(View.VISIBLE); AnimatorSet animatorSet = new AnimatorSet(); - animatorSet.playTogether(ObjectAnimator.ofFloat(androidPayContainer, View.ALPHA, 0.0f, 1.0f)); + animatorSet.playTogether(ObjectAnimator.ofFloat(googlePayContainer, View.ALPHA, 0.0f, 1.0f)); animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.setDuration(180); animatorSet.start(); @@ -2459,11 +2454,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen final String tokenizationType = tokenizationData.getString("type"); final String token = tokenizationData.getString("token"); - if (androidPayPublicKey != null) { - androidPayCredentials = new TLRPC.TL_inputPaymentCredentialsAndroidPay(); - androidPayCredentials.payment_token = new TLRPC.TL_dataJSON(); - androidPayCredentials.payment_token.data = tokenizationData.toString(); - androidPayCredentials.google_transaction_id = ""; + if (googlePayPublicKey != null || googlePayParameters != null) { + googlePayCredentials = new TLRPC.TL_inputPaymentCredentialsGooglePay(); + googlePayCredentials.payment_token = new TLRPC.TL_dataJSON(); + googlePayCredentials.payment_token.data = tokenizationData.toString(); String descriptions = paymentMethodData.optString("description"); if (!TextUtils.isEmpty(descriptions)) { cardName = descriptions; @@ -2478,7 +2472,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen } goToNextStep(); } catch (JSONException e) { - throw new RuntimeException("The selected garment cannot be parsed from the list of elements"); + FileLog.e(e); } } else { if (resultCode == AutoResolveHelper.RESULT_ERROR) { @@ -2513,7 +2507,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen } else { nextStep = 2; } - presentFragment(new PaymentFormActivity(paymentForm, messageObject, nextStep, requestedInfo, null, null, cardName, validateRequest, saveCardInfo, androidPayCredentials), isWebView); + presentFragment(new PaymentFormActivity(paymentForm, messageObject, nextStep, requestedInfo, null, null, cardName, validateRequest, saveCardInfo, googlePayCredentials), isWebView); } else if (currentStep == 1) { int nextStep; if (paymentForm.saved_credentials != null) { @@ -2531,16 +2525,16 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen } else { nextStep = 2; } - presentFragment(new PaymentFormActivity(paymentForm, messageObject, nextStep, requestedInfo, shippingOption, null, cardName, validateRequest, saveCardInfo, androidPayCredentials), isWebView); + presentFragment(new PaymentFormActivity(paymentForm, messageObject, nextStep, requestedInfo, shippingOption, null, cardName, validateRequest, saveCardInfo, googlePayCredentials), isWebView); } else if (currentStep == 2) { if (paymentForm.password_missing && saveCardInfo) { - passwordFragment = new PaymentFormActivity(paymentForm, messageObject, 6, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, androidPayCredentials); + passwordFragment = new PaymentFormActivity(paymentForm, messageObject, 6, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, googlePayCredentials); passwordFragment.setCurrentPassword(currentPassword); passwordFragment.setDelegate(new PaymentFormActivityDelegate() { @Override - public boolean didSelectNewCard(String tokenJson, String card, boolean saveCard, TLRPC.TL_inputPaymentCredentialsAndroidPay androidPay) { + public boolean didSelectNewCard(String tokenJson, String card, boolean saveCard, TLRPC.TL_inputPaymentCredentialsGooglePay googlePay) { if (delegate != null) { - delegate.didSelectNewCard(tokenJson, card, saveCard, androidPay); + delegate.didSelectNewCard(tokenJson, card, saveCard, googlePay); } if (isWebView) { removeSelfFromStack(); @@ -2561,10 +2555,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen presentFragment(passwordFragment, isWebView); } else { if (delegate != null) { - delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, androidPayCredentials); + delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, googlePayCredentials); finishFragment(); } else { - presentFragment(new PaymentFormActivity(paymentForm, messageObject, 4, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, androidPayCredentials), isWebView); + presentFragment(new PaymentFormActivity(paymentForm, messageObject, 4, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, googlePayCredentials), isWebView); } } } else if (currentStep == 3) { @@ -2574,13 +2568,13 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen } else { nextStep = 2; } - presentFragment(new PaymentFormActivity(paymentForm, messageObject, nextStep, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, androidPayCredentials), !passwordOk); + presentFragment(new PaymentFormActivity(paymentForm, messageObject, nextStep, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, googlePayCredentials), !passwordOk); } else if (currentStep == 4) { NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.paymentFinished); finishFragment(); } else if (currentStep == 6) { - if (!delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, androidPayCredentials)) { - presentFragment(new PaymentFormActivity(paymentForm, messageObject, 4, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, androidPayCredentials), true); + if (!delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, googlePayCredentials)) { + presentFragment(new PaymentFormActivity(paymentForm, messageObject, 4, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, googlePayCredentials), true); } else { finishFragment(); } @@ -3048,8 +3042,8 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen req.credentials = new TLRPC.TL_inputPaymentCredentialsSaved(); req.credentials.id = paymentForm.saved_credentials.id; req.credentials.tmp_password = UserConfig.getInstance(currentAccount).tmpPassword.tmp_password; - } else if (androidPayCredentials != null) { - req.credentials = androidPayCredentials; + } else if (googlePayCredentials != null) { + req.credentials = googlePayCredentials; } else { req.credentials = new TLRPC.TL_inputPaymentCredentials(); req.credentials.save = saveCardInfo; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 09cf6c325..ef530ad7d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -524,6 +524,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat @Override public boolean onTouchEvent(@NonNull TextView widget, @NonNull Spannable buffer, @NonNull MotionEvent event) { try { + if (!imagesArrLocals.isEmpty()) { + return false; + } int action = event.getAction(); boolean result = false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index f306618a1..629b6a3ca 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -2080,6 +2080,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } layoutManager.scrollToPositionWithOffset(pos, top - paddingTop); layout = true; + } else { + layoutManager.scrollToPositionWithOffset(0, AndroidUtilities.dp(88) - paddingTop); } if (currentPaddingTop != paddingTop || listView.getPaddingBottom() != paddingBottom) { listView.setPadding(0, paddingTop, 0, paddingBottom); @@ -6630,10 +6632,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. case 8: UserCell userCell = (UserCell) holder.itemView; TLRPC.ChatParticipant part; - if (!sortedUsers.isEmpty()) { - part = chatInfo.participants.participants.get(sortedUsers.get(position - membersStartRow)); - } else { - part = chatInfo.participants.participants.get(position - membersStartRow); + try { + if (!sortedUsers.isEmpty()) { + part = chatInfo.participants.participants.get(sortedUsers.get(position - membersStartRow)); + } else { + part = chatInfo.participants.participants.get(position - membersStartRow); + } + } catch (Exception e) { + part = null; + FileLog.e(e); } if (part != null) { String role; @@ -7362,8 +7369,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_profile_status)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_avatar_subtitleInProfileBlue)); - arrayList.add(new ThemeDescription(mediaCounterTextView.getTextView(), ThemeDescription.FLAG_TEXTCOLOR, null, null, null, themeDelegate, Theme.key_player_actionBarSubtitle)); - arrayList.add(new ThemeDescription(mediaCounterTextView.getNextTextView(), ThemeDescription.FLAG_TEXTCOLOR, null, null, null, themeDelegate, Theme.key_player_actionBarSubtitle)); + if (mediaCounterTextView != null) { + arrayList.add(new ThemeDescription(mediaCounterTextView.getTextView(), ThemeDescription.FLAG_TEXTCOLOR, null, null, null, themeDelegate, Theme.key_player_actionBarSubtitle)); + arrayList.add(new ThemeDescription(mediaCounterTextView.getNextTextView(), ThemeDescription.FLAG_TEXTCOLOR, null, null, null, themeDelegate, Theme.key_player_actionBarSubtitle)); + } arrayList.add(new ThemeDescription(topView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue)); arrayList.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector)); diff --git a/TMessagesProj/src/main/java/org/webrtc/voiceengine/WebRtcAudioTrack.java b/TMessagesProj/src/main/java/org/webrtc/voiceengine/WebRtcAudioTrack.java index 988523122..1d5888b3a 100644 --- a/TMessagesProj/src/main/java/org/webrtc/voiceengine/WebRtcAudioTrack.java +++ b/TMessagesProj/src/main/java/org/webrtc/voiceengine/WebRtcAudioTrack.java @@ -188,7 +188,7 @@ public class WebRtcAudioTrack { try { audioTrack.stop(); Logging.d(TAG, "AudioTrack.stop is done."); - } catch (IllegalStateException e) { + } catch (Exception e) { Logging.e(TAG, "AudioTrack.stop failed: " + e.getMessage()); } } diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index b02bc7158..2371dd190 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -3870,6 +3870,8 @@ Open in photo viewer %2$s by %1$s More options + Switch to night theme + Switch to day theme Play Pause Download