Update to 7.3.1 (2206)

This commit is contained in:
DrKLO 2021-01-01 08:38:45 +04:00
parent d0e2266da1
commit d52de1a40a
33 changed files with 407 additions and 235 deletions

View file

@ -290,7 +290,7 @@ android {
}
}
defaultConfig.versionCode = 2199
defaultConfig.versionCode = 2206
applicationVariants.all { variant ->
variant.outputs.all { output ->

View file

@ -34,10 +34,12 @@ public class SQLitePreparedStatement {
if (BuildVars.LOGS_ENABLED) {
query = sql;
startTime = SystemClock.elapsedRealtime();
/*if (hashMap == null) {
/*if (BuildVars.DEBUG_PRIVATE_VERSION) {
if (hashMap == null) {
hashMap = new HashMap<>();
}
hashMap.put(this, sql);*/
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;

View file

@ -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";

View file

@ -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);

View file

@ -1029,6 +1029,10 @@ public class FileLoader extends BaseController {
}
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side, boolean byMinSide) {
return getClosestPhotoSizeWithSize(sizes, side, byMinSide, null);
}
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> 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) {

View file

@ -1067,8 +1067,21 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
}
}
} else {
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 {

View file

@ -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 ||

View file

@ -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<Integer> contactsIds = null;
ArrayList<ImageLoader.MessageThumb> messageThumbs = null;
boolean checkForUsers = true;
ConcurrentHashMap<Integer, TLRPC.User> usersDict;
ConcurrentHashMap<Integer, TLRPC.Chat> 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) {

View file

@ -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++) {

View file

@ -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 + ")");
}
}

View file

@ -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) {

View file

@ -18270,13 +18270,13 @@ 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 TL_dataJSON payment_token;
public static InputPaymentCredentials TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
InputPaymentCredentials result = null;
@ -18284,8 +18284,8 @@ public class TLRPC {
case 0x3417d728:
result = new TL_inputPaymentCredentials();
break;
case 0xca05d50e:
result = new TL_inputPaymentCredentialsAndroidPay();
case 0x8ac32801:
result = new TL_inputPaymentCredentialsGooglePay();
break;
case 0xc10eb2cf:
result = new TL_inputPaymentCredentialsSaved();
@ -18319,19 +18319,17 @@ public class TLRPC {
}
}
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 serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
payment_token.serializeToStream(stream);
stream.writeString(google_transaction_id);
}
}

View file

@ -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();
SimpleTextView titleView = (SimpleTextView) child;
if (titleView.getVisibility() == View.VISIBLE && titleView.getText() instanceof String) {
TextPaint textPaint = titleView.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);
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() {

View file

@ -821,7 +821,16 @@ public class ActionBarLayout extends FrameLayout {
ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent();
if (parent != null) {
fragment.onRemoveFromParent();
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()) {

View file

@ -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);

View file

@ -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) {
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);
}

View file

@ -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);
}
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,9 +2970,13 @@ public class DialogCell extends BaseCell {
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
if (currentDialogFolderId != 0 && archiveHidden) {
info.setVisibleToUser(false);
} else {
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK);
}
}
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {

View file

@ -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);

View file

@ -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);
}

View file

@ -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<MessageObject> objects = new ArrayList<>();
objects.add(selectedObject);
ArrayList<Integer> 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);

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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());

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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));
}

View file

@ -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");
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<Boolean> task = paymentsClient.isReadyToPay(request);
task.addOnCompleteListener(getParentActivity(),
(OnCompleteListener<Boolean>) 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;

View file

@ -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;

View file

@ -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,11 +6632,16 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
case 8:
UserCell userCell = (UserCell) holder.itemView;
TLRPC.ChatParticipant part;
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;
if (part instanceof TLRPC.TL_chatChannelParticipant) {
@ -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));
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));

View file

@ -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());
}
}

View file

@ -3870,6 +3870,8 @@
<string name="AccDescrOpenInPhotoViewer">Open in photo viewer</string>
<string name="AccDescrMusicInfo">%2$s by %1$s</string>
<string name="AccDescrMoreOptions">More options</string>
<string name="AccDescrSwitchToNightTheme">Switch to night theme</string>
<string name="AccDescrSwitchToDayTheme">Switch to day theme</string>
<string name="AccActionPlay">Play</string>
<string name="AccActionPause">Pause</string>
<string name="AccActionDownload">Download</string>