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 -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->

View file

@ -34,10 +34,12 @@ public class SQLitePreparedStatement {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
query = sql; query = sql;
startTime = SystemClock.elapsedRealtime(); startTime = SystemClock.elapsedRealtime();
/*if (hashMap == null) { /*if (BuildVars.DEBUG_PRIVATE_VERSION) {
hashMap = new HashMap<>(); if (hashMap == null) {
} hashMap = new HashMap<>();
hashMap.put(this, sql);*/ }
hashMap.put(this, sql);
}*/
} }
} }
@ -108,7 +110,7 @@ public class SQLitePreparedStatement {
} }
} }
try { try {
/*if (BuildVars.DEBUG_VERSION) { /*if (BuildVars.DEBUG_PRIVATE_VERSION) {
hashMap.remove(this); hashMap.remove(this);
}*/ }*/
isFinalized = true; isFinalized = true;

View file

@ -18,7 +18,7 @@ public class BuildVars {
public static boolean LOGS_ENABLED = false; public static boolean LOGS_ENABLED = false;
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = 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 String BUILD_VERSION_STRING = "7.3.0";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; 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) { public static SvgHelper.SvgDrawable getSvgThumb(TLRPC.Document document, String colorKey, float alpha, float zoom) {
if (document == null) {
return null;
}
SvgHelper.SvgDrawable pathThumb = null; SvgHelper.SvgDrawable pathThumb = null;
for (int b = 0, N2 = document.thumbs.size(); b < N2; b++) { for (int b = 0, N2 = document.thumbs.size(); b < N2; b++) {
TLRPC.PhotoSize size = document.thumbs.get(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) { 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()) { if (sizes == null || sizes.isEmpty()) {
return null; return null;
} }
@ -1036,7 +1040,7 @@ public class FileLoader extends BaseController {
TLRPC.PhotoSize closestObject = null; TLRPC.PhotoSize closestObject = null;
for (int a = 0; a < sizes.size(); a++) { for (int a = 0; a < sizes.size(); a++) {
TLRPC.PhotoSize obj = sizes.get(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; continue;
} }
if (byMinSide) { if (byMinSide) {

View file

@ -1068,7 +1068,20 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} }
} }
} else { } 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); drawable.setBounds((int) drawRegion.left, (int) drawRegion.top, (int) drawRegion.right, (int) drawRegion.bottom);
if (isVisible) { if (isVisible) {
try { try {

View file

@ -943,6 +943,9 @@ public class MessageObject {
} else { } else {
emojiAnimatedStickerColor = ""; 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())) { if (TextUtils.isEmpty(emojiAnimatedStickerColor) || EmojiData.emojiColoredMap.contains(emoji.toString())) {
emojiAnimatedSticker = MediaDataController.getInstance(currentAccount).getEmojiAnimatedSticker(emoji); 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++) { for (int a = 0, N = photoThumbs.size(); a < N; a++) {
TLRPC.FileLocation location = photoThumbs.get(a).location; TLRPC.FileLocation location = photoThumbs.get(a).location;
if (location == null) { if (location == null) {
@ -3423,12 +3426,6 @@ public class MessageObject {
boolean hasEntities; boolean hasEntities;
if (messageOwner.send_state != MESSAGE_SEND_STATE_SENT) { if (messageOwner.send_state != MESSAGE_SEND_STATE_SENT) {
hasEntities = false; hasEntities = false;
for (int a = 0; a < messageOwner.entities.size(); a++) {
if (!(messageOwner.entities.get(a) instanceof TLRPC.TL_inputMessageEntityMentionName)) {
hasEntities = true;
break;
}
}
} else { } else {
hasEntities = !messageOwner.entities.isEmpty(); 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; 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) { 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) { } 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 instanceof TLRPC.TL_messageMediaWebPage ||
message.media == null); 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 || if (message.media instanceof TLRPC.TL_messageMediaPhoto ||
message.media instanceof TLRPC.TL_messageMediaDocument && !isStickerMessage(message) && !isAnimatedStickerMessage(message) || message.media instanceof TLRPC.TL_messageMediaDocument && !isStickerMessage(message) && !isAnimatedStickerMessage(message) ||
message.media instanceof TLRPC.TL_messageMediaEmpty || message.media instanceof TLRPC.TL_messageMediaEmpty ||

View file

@ -1135,7 +1135,11 @@ public class MessagesController extends BaseController implements NotificationCe
allDialogs.clear(); allDialogs.clear();
for (int a = 0, size = dialogs_dict.size(); a < size; a++) { 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); sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload); getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
@ -5805,15 +5809,13 @@ public class MessagesController extends BaseController implements NotificationCe
ImageLoader.saveMessagesThumbs(messagesRes.messages); ImageLoader.saveMessagesThumbs(messagesRes.messages);
} }
boolean isInitialLoading = offset_date == 0 && max_id == 0; boolean isInitialLoading = offset_date == 0 && max_id == 0;
boolean requestByTime; boolean reload;
if (mode == 1) { if (mode == 1) {
requestByTime = ((SystemClock.elapsedRealtime() - lastScheduledServerQueryTime.get(dialogId, 0L)) > 60 * 1000); reload = ((SystemClock.elapsedRealtime() - lastScheduledServerQueryTime.get(dialogId, 0L)) > 60 * 1000);
} else if (mode == 2) {
requestByTime = false;
} else { } 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; int hash;
if (mode == 2) { if (mode == 2) {
hash = 0; hash = 0;
@ -6689,7 +6691,11 @@ public class MessagesController extends BaseController implements NotificationCe
allDialogs.clear(); allDialogs.clear();
for (int a = 0, size = dialogs_dict.size(); a < size; a++) { 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); sortDialogs(null);
dialogsEndReached.put(0, true); dialogsEndReached.put(0, true);
@ -7261,7 +7267,11 @@ public class MessagesController extends BaseController implements NotificationCe
allDialogs.clear(); allDialogs.clear();
for (int a = 0, size = dialogs_dict.size(); a < size; a++) { 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); sortDialogs(migrate ? chatsDict : null);
@ -7823,7 +7833,11 @@ public class MessagesController extends BaseController implements NotificationCe
allDialogs.clear(); allDialogs.clear();
for (int a = 0, size = dialogs_dict.size(); a < size; a++) { 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); sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload); getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
@ -10122,7 +10136,11 @@ public class MessagesController extends BaseController implements NotificationCe
if (added) { if (added) {
allDialogs.clear(); allDialogs.clear();
for (int a = 0, size = dialogs_dict.size(); a < size; a++) { 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); sortDialogs(null);
@ -10977,7 +10995,6 @@ public class MessagesController extends BaseController implements NotificationCe
ArrayList<Integer> contactsIds = null; ArrayList<Integer> contactsIds = null;
ArrayList<ImageLoader.MessageThumb> messageThumbs = null; ArrayList<ImageLoader.MessageThumb> messageThumbs = null;
boolean checkForUsers = true;
ConcurrentHashMap<Integer, TLRPC.User> usersDict; ConcurrentHashMap<Integer, TLRPC.User> usersDict;
ConcurrentHashMap<Integer, TLRPC.Chat> chatsDict; ConcurrentHashMap<Integer, TLRPC.Chat> chatsDict;
if (usersArr != null) { if (usersArr != null) {
@ -10987,7 +11004,6 @@ public class MessagesController extends BaseController implements NotificationCe
usersDict.put(user.id, user); usersDict.put(user.id, user);
} }
} else { } else {
checkForUsers = false;
usersDict = users; usersDict = users;
} }
if (chatsArr != null) { if (chatsArr != null) {
@ -10997,12 +11013,8 @@ public class MessagesController extends BaseController implements NotificationCe
chatsDict.put(chat.id, chat); chatsDict.put(chat.id, chat);
} }
} else { } else {
checkForUsers = false;
chatsDict = chats; chatsDict = chats;
} }
if (fromGetDifference) {
checkForUsers = false;
}
if (usersArr != null || chatsArr != null) { if (usersArr != null || chatsArr != null) {
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
@ -11054,7 +11066,7 @@ public class MessagesController extends BaseController implements NotificationCe
putChat(chat, true); putChat(chat, true);
} }
} }
if (checkForUsers) { if (!fromGetDifference) {
if (chat_id != 0) { if (chat_id != 0) {
if (chat == null) { if (chat == null) {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {

View file

@ -4960,6 +4960,7 @@ public class MessagesStorage extends BaseController {
} else { } 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))); 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; alreadyAdded = cursor.next() ? cursor.intValue(0) : 0;
cursor.dispose();
} }
SQLitePreparedStatement state = database.executeFast("REPLACE INTO chat_pinned_v2 VALUES(?, ?, ?)"); SQLitePreparedStatement state = database.executeFast("REPLACE INTO chat_pinned_v2 VALUES(?, ?, ?)");
for (int a = 0, N = ids.size(); a < N; a++) { for (int a = 0, N = ids.size(); a < N; a++) {

View file

@ -927,7 +927,7 @@ public class SharedConfig {
} else { } else {
devicePerformanceClass = PERFORMANCE_CLASS_HIGH; 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 + ")"); 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 colorAlpha;
private float crossfadeAlpha; private float crossfadeAlpha;
@Override
public int getIntrinsicHeight() {
return width;
}
@Override
public int getIntrinsicWidth() {
return height;
}
@Override @Override
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
if (currentColorKey != null) { if (currentColorKey != null) {

View file

@ -18269,87 +18269,85 @@ public class TLRPC {
} }
} }
public static abstract class InputPaymentCredentials extends TLObject { 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 InputPaymentCredentials TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { public int flags;
InputPaymentCredentials result = null; public boolean save;
switch (constructor) { public TL_dataJSON data;
case 0x3417d728: public String id;
result = new TL_inputPaymentCredentials(); public byte[] tmp_password;
break; public TL_dataJSON payment_token;
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 static class TL_inputPaymentCredentials extends InputPaymentCredentials { public static InputPaymentCredentials TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
public static int constructor = 0x3417d728; 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) { public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception); flags = stream.readInt32(exception);
save = (flags & 1) != 0; save = (flags & 1) != 0;
data = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception); data = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception);
} }
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
flags = save ? (flags | 1) : (flags &~ 1); flags = save ? (flags | 1) : (flags &~ 1);
stream.writeInt32(flags); stream.writeInt32(flags);
data.serializeToStream(stream); data.serializeToStream(stream);
} }
} }
public static class TL_inputPaymentCredentialsAndroidPay extends InputPaymentCredentials { public static class TL_inputPaymentCredentialsGooglePay extends InputPaymentCredentials {
public static int constructor = 0xca05d50e; public static int constructor = 0x8ac32801;
public void readParams(AbstractSerializedData stream, boolean exception) { public void readParams(AbstractSerializedData stream, boolean exception) {
payment_token = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception); payment_token = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception);
google_transaction_id = stream.readString(exception); }
}
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
payment_token.serializeToStream(stream); payment_token.serializeToStream(stream);
stream.writeString(google_transaction_id); }
} }
}
public static class TL_inputPaymentCredentialsSaved extends InputPaymentCredentials { public static class TL_inputPaymentCredentialsSaved extends InputPaymentCredentials {
public static int constructor = 0xc10eb2cf; public static int constructor = 0xc10eb2cf;
public void readParams(AbstractSerializedData stream, boolean exception) { public void readParams(AbstractSerializedData stream, boolean exception) {
id = stream.readString(exception); id = stream.readString(exception);
tmp_password = stream.readByteArray(exception); tmp_password = stream.readByteArray(exception);
} }
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
stream.writeString(id); stream.writeString(id);
stream.writeByteArray(tmp_password); stream.writeByteArray(tmp_password);
} }
} }
public static class TL_exportedMessageLink extends TLObject { public static class TL_exportedMessageLink extends TLObject {
public static int constructor = 0x5dab1af4; public static int constructor = 0x5dab1af4;

View file

@ -12,6 +12,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Canvas; import android.graphics.Canvas;
@ -29,12 +30,16 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewPropertyAnimator; import android.view.ViewPropertyAnimator;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.ui.Adapters.FiltersView; import org.telegram.ui.Adapters.FiltersView;
import org.telegram.ui.Components.EllipsizeSpanAnimator; import org.telegram.ui.Components.EllipsizeSpanAnimator;
import org.telegram.ui.Components.FireworksEffect; import org.telegram.ui.Components.FireworksEffect;
@ -59,6 +64,8 @@ public class ActionBar extends FrameLayout {
private SimpleTextView[] titleTextView = new SimpleTextView[2]; private SimpleTextView[] titleTextView = new SimpleTextView[2];
private SimpleTextView subtitleTextView; private SimpleTextView subtitleTextView;
private View actionModeTop; private View actionModeTop;
private int actionModeColor;
private int actionBarColor;
private ActionBarMenu menu; private ActionBarMenu menu;
private ActionBarMenu actionMode; private ActionBarMenu actionMode;
private String actionModeTag; private String actionModeTag;
@ -208,16 +215,26 @@ public class ActionBar extends FrameLayout {
canvas.clipRect(0, -getTranslationY() + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0), getMeasuredWidth(), getMeasuredHeight()); canvas.clipRect(0, -getTranslationY() + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0), getMeasuredWidth(), getMeasuredHeight());
} }
boolean result = super.drawChild(canvas, child, drawingTime); 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(); Drawable drawable = Theme.getCurrentHolidayDrawable();
if (drawable != null) { if (drawable != null) {
TextPaint textPaint = titleTextView[0].getTextPaint();
textPaint.getFontMetricsInt(fontMetricsInt); SimpleTextView titleView = (SimpleTextView) child;
textPaint.getTextBounds((String) titleTextView[0].getText(), 0, 1, rect); if (titleView.getVisibility() == View.VISIBLE && titleView.getText() instanceof String) {
int x = titleTextView[0].getTextStartX() + Theme.getCurrentHolidayDrawableXOffset() + (rect.width() - (drawable.getIntrinsicWidth() + Theme.getCurrentHolidayDrawableXOffset())) / 2; TextPaint textPaint = titleView.getTextPaint();
int y = titleTextView[0].getTextStartY() + Theme.getCurrentHolidayDrawableYOffset() + (int) Math.ceil((titleTextView[0].getTextHeight() - rect.height()) / 2.0f); textPaint.getFontMetricsInt(fontMetricsInt);
drawable.setBounds(x, y - drawable.getIntrinsicHeight(), x + drawable.getIntrinsicWidth(), y); textPaint.getTextBounds((String) titleView.getText(), 0, 1, rect);
drawable.draw(canvas); 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 (Theme.canStartHolidayAnimation()) {
if (snowflakesEffect == null) { if (snowflakesEffect == null) {
snowflakesEffect = new SnowflakesEffect(); snowflakesEffect = new SnowflakesEffect();
@ -433,7 +450,7 @@ public class ActionBar extends FrameLayout {
actionMode = new ActionBarMenu(getContext(), this); actionMode = new ActionBarMenu(getContext(), this);
actionMode.isActionMode = true; actionMode.isActionMode = true;
actionMode.setClickable(true); actionMode.setClickable(true);
actionMode.setBackgroundColor(Theme.getColor(Theme.key_actionBarActionModeDefault)); actionMode.setBackgroundColor(actionModeColor = Theme.getColor(Theme.key_actionBarActionModeDefault));
addView(actionMode, indexOfChild(backButtonImageView)); addView(actionMode, indexOfChild(backButtonImageView));
actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0); actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) actionMode.getLayoutParams(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) actionMode.getLayoutParams();
@ -487,9 +504,16 @@ public class ActionBar extends FrameLayout {
actionModeExtraView = extraView; actionModeExtraView = extraView;
actionModeShowingView = showingView; actionModeShowingView = showingView;
actionModeHidingViews = hidingViews; actionModeHidingViews = hidingViews;
if (occupyStatusBar && actionModeTop != null) { if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
animators.add(ObjectAnimator.ofFloat(actionModeTop, View.ALPHA, 0.0f, 1.0f)); 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) { if (actionModeAnimation != null) {
actionModeAnimation.cancel(); actionModeAnimation.cancel();
} }
@ -500,7 +524,7 @@ public class ActionBar extends FrameLayout {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
actionMode.setVisibility(VISIBLE); actionMode.setVisibility(VISIBLE);
if (occupyStatusBar && actionModeTop != null) { if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
actionModeTop.setVisibility(VISIBLE); actionModeTop.setVisibility(VISIBLE);
} }
} }
@ -570,9 +594,16 @@ public class ActionBar extends FrameLayout {
if (actionModeShowingView != null) { if (actionModeShowingView != null) {
animators.add(ObjectAnimator.ofFloat(actionModeShowingView, View.ALPHA, 0.0f)); 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)); 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) { if (actionModeAnimation != null) {
actionModeAnimation.cancel(); actionModeAnimation.cancel();
} }
@ -585,7 +616,7 @@ public class ActionBar extends FrameLayout {
if (actionModeAnimation != null && actionModeAnimation.equals(animation)) { if (actionModeAnimation != null && actionModeAnimation.equals(animation)) {
actionModeAnimation = null; actionModeAnimation = null;
actionMode.setVisibility(INVISIBLE); actionMode.setVisibility(INVISIBLE);
if (occupyStatusBar && actionModeTop != null) { if (occupyStatusBar && actionModeTop != null && !SharedConfig.noStatusBar) {
actionModeTop.setVisibility(INVISIBLE); actionModeTop.setVisibility(INVISIBLE);
} }
if (actionModeExtraView != null) { if (actionModeExtraView != null) {
@ -649,10 +680,15 @@ public class ActionBar extends FrameLayout {
public void setActionModeColor(int color) { public void setActionModeColor(int color) {
if (actionMode != null) { if (actionMode != null) {
actionMode.setBackgroundColor(color); actionMode.setBackgroundColor(actionModeColor = color);
} }
} }
@Override
public void setBackgroundColor(int color) {
super.setBackgroundColor(actionBarColor = color);
}
public boolean isActionModeShowed() { public boolean isActionModeShowed() {
return actionMode != null && actionModeVisible; return actionMode != null && actionModeVisible;
} }
@ -1172,12 +1208,26 @@ public class ActionBar extends FrameLayout {
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
ellipsizeSpanAnimator.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 @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
ellipsizeSpanAnimator.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() { public ActionBarMenu getActionMode() {

View file

@ -821,7 +821,16 @@ public class ActionBarLayout extends FrameLayout {
ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent(); ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent();
if (parent != null) { if (parent != null) {
fragment.onRemoveFromParent(); 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()) { 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) { } else if (o1.decimal < o2.decimal) {
return 1; return 1;
} }
if (o1.decimal == o2.decimal) {
if (o1.percent > o2.percent) {
return 1;
} else if (o1.percent < o2.percent) {
return -1;
}
}
return 0; return 0;
}); });
for (int a = 0, N = Math.min(restPercent, sortedPollButtons.size()); a < N; a++) { 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); maxPhotoWidth = photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
} else { } else {
if (currentPhotoObject != null && (messageObject.type == MessageObject.TYPE_PHOTO || messageObject.type == MessageObject.TYPE_VIDEO || messageObject.type == 8) && currentPhotoObject.w >= currentPhotoObject.h) { 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; useFullWidth = true;
} else { } else {
maxPhotoWidth = photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); 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); photoHeight = photoWidth + AndroidUtilities.dp(100);
if (!useFullWidth) { if (!useFullWidth) {
if (messageObject.type != 5 && checkNeedDrawShareButton(messageObject)) { if (messageObject.type != 5 && checkNeedDrawShareButton(messageObject)) {
maxPhotoWidth -= AndroidUtilities.dp(20);
photoWidth -= AndroidUtilities.dp(20); photoWidth -= AndroidUtilities.dp(20);
} }
if (photoWidth > AndroidUtilities.getPhotoSize()) { if (photoWidth > AndroidUtilities.getPhotoSize()) {
@ -4983,7 +4989,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} }
availableTimeWidth = firstLineWidth - AndroidUtilities.dp(35); availableTimeWidth = firstLineWidth - AndroidUtilities.dp(35);
} else { } else {
availableTimeWidth = maxPhotoWidth - AndroidUtilities.dp(14); availableTimeWidth = photoWidth - AndroidUtilities.dp(14);
} }
if (messageObject.type == MessageObject.TYPE_ROUND_VIDEO) { if (messageObject.type == MessageObject.TYPE_ROUND_VIDEO) {
availableTimeWidth -= Math.ceil(Theme.chat_audioTimePaint.measureText("00:00")) + AndroidUtilities.dp(26); 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 android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DocumentObject;
import org.telegram.messenger.DownloadController; import org.telegram.messenger.DownloadController;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
@ -40,6 +41,7 @@ import org.telegram.messenger.MediaController;
import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.WebFile; import org.telegram.messenger.WebFile;
@ -341,11 +343,20 @@ public class ContextLinkCell extends FrameLayout implements DownloadController.F
} }
} else { } else {
if (currentPhotoObject != null) { if (currentPhotoObject != null) {
SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(documentAttach, Theme.key_windowBackgroundGray, 1.0f);
if (MessageObject.canAutoplayAnimatedSticker(documentAttach)) { 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 { } else {
if (documentAttach != null) { 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 { } else {
linkImageView.setImage(ImageLocation.getForPhoto(currentPhotoObject, photoAttach), currentPhotoFilter, ImageLocation.getForPhoto(currentPhotoObjectThumb, photoAttach), currentPhotoFilterThumb, currentPhotoObject.size, ext, parentObject, 0); 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 boolean statusDrawableAnimationInProgress;
private ValueAnimator statusDrawableAnimator; private ValueAnimator statusDrawableAnimator;
long lastDialogChangedTime; long lastDialogChangedTime;
private int statusDrawableLeft;
public static class BounceInterpolator implements Interpolator { public static class BounceInterpolator implements Interpolator {
@ -841,12 +842,8 @@ public class DialogCell extends BaseCell {
startPadding = statusDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3); startPadding = statusDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3);
} }
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && LocaleController.isRTL && (int) currentDialogId < 0) { spannableStringBuilder.append(" ").append(TextUtils.replace(printingString, new String[]{"..."}, new String[]{""})).setSpan(new FixedWidthSpan(startPadding), 0, 1, 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; messageString = spannableStringBuilder;
currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex]; currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex];
checkMessage = false; checkMessage = false;
@ -1683,6 +1680,15 @@ public class DialogCell extends BaseCell {
FileLog.e(e); 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) { 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); StatusDrawable statusDrawable = Theme.getChatStatusDrawable(printingStringType);
if (statusDrawable != null) { if (statusDrawable != null) {
canvas.save(); canvas.save();
int left = (LocaleController.isRTL || messageLayout.isRtlCharAt(0)) ? getMeasuredWidth() - AndroidUtilities.dp(72) - statusDrawable.getIntrinsicWidth() : messageLeft;
if (printingStringType == 1 || printingStringType == 4) { 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 { } else {
canvas.translate(left, messageTop + (AndroidUtilities.dp(18) - statusDrawable.getIntrinsicHeight()) / 2f); canvas.translate(statusDrawableLeft, messageTop + (AndroidUtilities.dp(18) - statusDrawable.getIntrinsicHeight()) / 2f);
} }
statusDrawable.draw(canvas); statusDrawable.draw(canvas);
invalidate(left, messageTop, left + statusDrawable.getIntrinsicWidth(), messageTop + statusDrawable.getIntrinsicHeight()); invalidate(statusDrawableLeft, messageTop, statusDrawableLeft + statusDrawable.getIntrinsicWidth(), messageTop + statusDrawable.getIntrinsicHeight());
canvas.restore(); canvas.restore();
} }
} }
@ -2965,8 +2970,12 @@ public class DialogCell extends BaseCell {
@Override @Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info);
info.addAction(AccessibilityNodeInfo.ACTION_CLICK); if (currentDialogFolderId != 0 && archiveHidden) {
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK); info.setVisibleToUser(false);
} else {
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK);
}
} }
@Override @Override

View file

@ -26,6 +26,7 @@ import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -116,7 +117,17 @@ public class DrawerProfileCell extends FrameLayout {
sunDrawable.setCurrentFrame(36); sunDrawable.setCurrentFrame(36);
} }
sunDrawable.setPlayInDirectionOfCustomEndFrame(true); 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(); sunDrawable.beginApplyLayerColors();
int color = Theme.getColor(Theme.key_chats_menuName); int color = Theme.getColor(Theme.key_chats_menuName);
sunDrawable.setLayerColor("Sunny.**", color); 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()) { } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) {
videoInfoContainer.setVisibility(INVISIBLE); videoInfoContainer.setVisibility(INVISIBLE);
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320);
TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 50); 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 (messageObject.mediaExists || DownloadController.getInstance(currentAccount).canDownloadMedia(messageObject)) {
if (currentPhotoObject == currentPhotoObjectThumb) { if (currentPhotoObject == currentPhotoObjectThumb) {
currentPhotoObjectThumb = null; 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 { } else {
imageView.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, null, 0, messageObject); 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 { } else {
getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, dialog_id, ids, false, null, null, 0, 0, true); getNotificationCenter().postNotificationName(NotificationCenter.didLoadPinnedMessages, dialog_id, ids, false, null, null, 0, 0, true);
} }
if (pinBulletin != null) {
pinBulletin.hide();
}
showPinBulletin = true; showPinBulletin = true;
int tag = ++pinBullerinTag; int tag = ++pinBullerinTag;
int oldTotalPinnedCount = getPinnedMessagesCount(); int oldTotalPinnedCount = getPinnedMessagesCount();
@ -9842,7 +9845,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (view instanceof ChatMessageCell) { if (view instanceof ChatMessageCell) {
ChatMessageCell messageCell = (ChatMessageCell) view; ChatMessageCell messageCell = (ChatMessageCell) view;
messageObject = messageCell.getMessageObject(); messageObject = messageCell.getMessageObject();
if (messageObject.getId() > maxVisibleId) { if (messageObject.getDialogId() == dialog_id && messageObject.getId() > maxVisibleId) {
maxVisibleId = messageObject.getId(); maxVisibleId = messageObject.getId();
maxVisibleMessageObject = messageObject; maxVisibleMessageObject = messageObject;
} }
@ -9873,7 +9876,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} else if (view instanceof ChatActionCell) { } else if (view instanceof ChatActionCell) {
messageObject = ((ChatActionCell) view).getMessageObject(); messageObject = ((ChatActionCell) view).getMessageObject();
if (messageObject != null) { if (messageObject != null && messageObject.getDialogId() == dialog_id && messageObject.getId() > maxVisibleId) {
maxVisibleId = Math.max(maxVisibleId, messageObject.getId()); maxVisibleId = Math.max(maxVisibleId, messageObject.getId());
} }
} else if (view instanceof BotHelpCell) { } else if (view instanceof BotHelpCell) {
@ -18485,6 +18488,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messageObject == null) { if (messageObject == null) {
return; return;
} }
if (pinBulletin != null) {
pinBulletin.hide(false);
}
ArrayList<MessageObject> objects = new ArrayList<>(); ArrayList<MessageObject> objects = new ArrayList<>();
objects.add(selectedObject); objects.add(selectedObject);
ArrayList<Integer> ids = new ArrayList<>(); ArrayList<Integer> ids = new ArrayList<>();
@ -18747,7 +18753,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messageObjects.add(selectedObject); messageObjects.add(selectedObject);
} }
MediaController.saveFilesFromMessages(getParentActivity(), getAccountInstance(), messageObjects, (count) -> { MediaController.saveFilesFromMessages(getParentActivity(), getAccountInstance(), messageObjects, (count) -> {
if (getParentActivity() == null) { if (getParentActivity() == null || fragmentView == null) {
return; return;
} }
if (count > 0) { if (count > 0) {
@ -19956,7 +19962,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putLong("dialog_id", dialog_id); args.putLong("dialog_id", dialog_id);
} }
} }
ProfileActivity fragment = new ProfileActivity(args); ProfileActivity fragment = new ProfileActivity(args, avatarContainer.getSharedMediaPreloader());
fragment.setPlayProfileAnimation(1); fragment.setPlayProfileAnimation(1);
fragment.setChatInfo(chatInfo); fragment.setChatInfo(chatInfo);
fragment.setUserInfo(userInfo); fragment.setUserInfo(userInfo);

View file

@ -35,15 +35,15 @@ public final class BulletinFactory {
MEDIA("MediaSavedHint", Icon.SAVED_TO_GALLERY), 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), VIDEO_TO_DOWNLOADS("VideoSavedToDownloadsHint", R.string.VideoSavedToDownloadsHint, Icon.SAVED_TO_DOWNLOADS),
GIF("GifSavedToDownloadsHint", 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), 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); UNKNOWNS("FilesSavedHint", Icon.SAVED_TO_DOWNLOADS);
private final String localeKey; 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))); 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.RectF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.SystemClock; import android.os.SystemClock;
import android.text.Layout; import android.text.Layout;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.Property; import android.util.Property;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
@ -169,6 +170,7 @@ public class FilterTabsView extends FrameLayout {
public void setTab(Tab tab, int position) { public void setTab(Tab tab, int position) {
currentTab = tab; currentTab = tab;
currentPosition = position; currentPosition = position;
setContentDescription(tab.title);
requestLayout(); requestLayout();
} }
@ -550,6 +552,17 @@ public class FilterTabsView extends FrameLayout {
return changed; 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); 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) { private void openSharingLocation(final LocationController.SharingLocationInfo info) {
if (info == null || fragment.getParentActivity() == null) { if (info == null || !(fragment.getParentActivity() instanceof LaunchActivity)) {
return; return;
} }
LaunchActivity launchActivity = ((LaunchActivity) fragment.getParentActivity()); LaunchActivity launchActivity = ((LaunchActivity) fragment.getParentActivity());

View file

@ -201,6 +201,7 @@ public class PhotoViewerCaptionEnterView extends FrameLayout implements Notifica
messageEditText.setWindowView(windowView); messageEditText.setWindowView(windowView);
messageEditText.setHint(LocaleController.getString("AddCaption", R.string.AddCaption)); messageEditText.setHint(LocaleController.getString("AddCaption", R.string.AddCaption));
messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
messageEditText.setLinkTextColor(0xff76c2f1);
messageEditText.setInputType(messageEditText.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES); messageEditText.setInputType(messageEditText.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
messageEditText.setMaxLines(4); messageEditText.setMaxLines(4);
messageEditText.setHorizontallyScrolling(false); messageEditText.setHorizontallyScrolling(false);

View file

@ -10,7 +10,6 @@ package org.telegram.ui.Components;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;

View file

@ -39,7 +39,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;

View file

@ -3069,7 +3069,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
if (!onlySelect && initialDialogsType == 0) { 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); blurredView.setVisibility(View.GONE);
contentView.addView(blurredView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); 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 android.widget.Toast;
import com.google.android.gms.common.api.Status; 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.tasks.Task;
import com.google.android.gms.wallet.AutoResolveHelper; import com.google.android.gms.wallet.AutoResolveHelper;
import com.google.android.gms.wallet.IsReadyToPayRequest; import com.google.android.gms.wallet.IsReadyToPayRequest;
@ -191,7 +190,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
private TextCheckCell checkCell1; private TextCheckCell checkCell1;
private TextInfoPrivacyCell[] bottomCell = new TextInfoPrivacyCell[3]; private TextInfoPrivacyCell[] bottomCell = new TextInfoPrivacyCell[3];
private TextSettingsCell[] settingsCell = new TextSettingsCell[2]; private TextSettingsCell[] settingsCell = new TextSettingsCell[2];
private FrameLayout androidPayContainer; private FrameLayout googlePayContainer;
private FrameLayout googlePayButton; private FrameLayout googlePayButton;
private LinearLayout linearLayout2; private LinearLayout linearLayout2;
@ -215,6 +214,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
private boolean need_card_postcode; private boolean need_card_postcode;
private boolean need_card_name; private boolean need_card_name;
private String stripeApiKey; private String stripeApiKey;
private boolean initGooglePay;
private TLRPC.User botUser; private TLRPC.User botUser;
@ -236,10 +236,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
private TLRPC.TL_payments_validatedRequestedInfo requestedInfo; private TLRPC.TL_payments_validatedRequestedInfo requestedInfo;
private TLRPC.TL_shippingOption shippingOption; private TLRPC.TL_shippingOption shippingOption;
private TLRPC.TL_payments_validateRequestedInfo validateRequest; private TLRPC.TL_payments_validateRequestedInfo validateRequest;
private TLRPC.TL_inputPaymentCredentialsAndroidPay androidPayCredentials; private TLRPC.TL_inputPaymentCredentialsGooglePay googlePayCredentials;
private String androidPayPublicKey; private String googlePayPublicKey;
private int androidPayBackgroundColor; private String googlePayCountryCode;
private boolean androidPayBlackTheme; private JSONObject googlePayParameters;
private MessageObject messageObject; private MessageObject messageObject;
private boolean donePressed; private boolean donePressed;
private boolean canceled; 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 static final int LOAD_PAYMENT_DATA_REQUEST_CODE = 991;
private interface PaymentFormActivityDelegate { 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 onFragmentDestroyed();
void currentPasswordUpdated(TLRPC.TL_account_password password); 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); 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) { 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, androidPay); init(form, message, step, validatedRequestedInfo, shipping, tokenJson, card, request, saveCard, googlePay);
} }
private void setCurrentPassword(TLRPC.TL_account_password password) { private void setCurrentPassword(TLRPC.TL_account_password password) {
@ -363,10 +363,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
delegate = paymentFormActivityDelegate; 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; currentStep = step;
paymentJson = tokenJson; paymentJson = tokenJson;
androidPayCredentials = androidPay; googlePayCredentials = googlePay;
requestedInfo = validatedRequestedInfo; requestedInfo = validatedRequestedInfo;
paymentForm = form; paymentForm = form;
shippingOption = shipping; shippingOption = shipping;
@ -973,34 +973,22 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
if (paymentForm.native_params != null) { if (paymentForm.native_params != null) {
try { try {
JSONObject jsonObject = new JSONObject(paymentForm.native_params.data); JSONObject jsonObject = new JSONObject(paymentForm.native_params.data);
try { String googlePayKey = jsonObject.optString("google_pay_public_key");
String androidPayKey = jsonObject.getString("android_pay_public_key"); if (!TextUtils.isEmpty(googlePayKey)) {
if (!TextUtils.isEmpty(androidPayKey)) { googlePayPublicKey = googlePayKey;
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;
} }
googlePayCountryCode = jsonObject.optString("acquirer_bank_country");
googlePayParameters = jsonObject.optJSONObject("gpay_parameters");
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
} }
if (isWebView) { if (isWebView) {
if (androidPayPublicKey != null) { if (googlePayPublicKey != null || googlePayParameters != null) {
initAndroidPay(context); initGooglePay(context);
} }
createAndroidPayButton(context); createGooglePayButton(context);
linearLayout2.addView(androidPayContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50)); linearLayout2.addView(googlePayContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
webviewLoading = true; webviewLoading = true;
showEditDoneProgress(true, true); showEditDoneProgress(true, true);
@ -1093,13 +1081,14 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
} catch (Exception e) { } catch (Exception e) {
stripeApiKey = ""; stripeApiKey = "";
} }
initGooglePay = !jsonObject.optBoolean("google_pay_hidden", false);
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
} }
if (!TextUtils.isEmpty(stripeApiKey)) { if (initGooglePay && (!TextUtils.isEmpty(stripeApiKey) || googlePayParameters != null)) {
initAndroidPay(context); initGooglePay(context);
} }
inputFields = new EditTextBoldCursor[FIELDS_COUNT_CARD]; inputFields = new EditTextBoldCursor[FIELDS_COUNT_CARD];
@ -1500,8 +1489,8 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
updateSavePaymentField(); updateSavePaymentField();
linearLayout2.addView(bottomCell[0], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayout2.addView(bottomCell[0], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
} else if (a == FIELD_CARD) { } else if (a == FIELD_CARD) {
createAndroidPayButton(context); createGooglePayButton(context);
container.addView(androidPayContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 4, 0)); container.addView(googlePayContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 4, 0));
} }
if (allowDivider) { 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); PaymentFormActivity activity = new PaymentFormActivity(paymentForm, messageObject, 2, requestedInfo, shippingOption, null, cardName, validateRequest, saveCardInfo, null);
activity.setDelegate(new PaymentFormActivityDelegate() { activity.setDelegate(new PaymentFormActivityDelegate() {
@Override @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; paymentForm.saved_credentials = null;
paymentJson = tokenJson; paymentJson = tokenJson;
saveCardInfo = saveCard; saveCardInfo = saveCard;
cardName = card; cardName = card;
androidPayCredentials = androidPay; googlePayCredentials = googlePay;
detailSettingsCell[0].setTextAndValue(cardName, LocaleController.getString("PaymentCheckoutMethod", R.string.PaymentCheckoutMethod), true); detailSettingsCell[0].setTextAndValue(cardName, LocaleController.getString("PaymentCheckoutMethod", R.string.PaymentCheckoutMethod), true);
return false; return false;
} }
@ -2050,43 +2039,47 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
return fragmentView; return fragmentView;
} }
private void createAndroidPayButton(Context context) { private void createGooglePayButton(Context context) {
androidPayContainer = new FrameLayout(context); googlePayContainer = new FrameLayout(context);
androidPayContainer.setBackgroundDrawable(Theme.getSelectorDrawable(true)); googlePayContainer.setBackgroundDrawable(Theme.getSelectorDrawable(true));
androidPayContainer.setVisibility(View.GONE); googlePayContainer.setVisibility(View.GONE);
googlePayButton = new FrameLayout(context); googlePayButton = new FrameLayout(context);
googlePayButton.setClickable(true); googlePayButton.setClickable(true);
googlePayButton.setFocusable(true); googlePayButton.setFocusable(true);
googlePayButton.setBackgroundResource(R.drawable.googlepay_button_no_shadow_background); 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)); googlePayButton.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(2), AndroidUtilities.dp(10), AndroidUtilities.dp(2));
} else { } else {
googlePayButton.setPadding(AndroidUtilities.dp(2), AndroidUtilities.dp(2), AndroidUtilities.dp(2), AndroidUtilities.dp(2)); 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.setOnClickListener(v -> {
googlePayButton.setClickable(false); googlePayButton.setClickable(false);
try { try {
JSONObject paymentDataRequest = getBaseRequest(); JSONObject paymentDataRequest = getBaseRequest();
JSONObject cardPaymentMethod = getBaseCardPaymentMethod(); JSONObject cardPaymentMethod = getBaseCardPaymentMethod();
if (androidPayPublicKey != null) { if (googlePayPublicKey != null && googlePayParameters == null) {
cardPaymentMethod.put("tokenizationSpecification", new JSONObject() {{ cardPaymentMethod.put("tokenizationSpecification", new JSONObject() {{
put("type", "DIRECT"); put("type", "DIRECT");
put("parameters", new JSONObject() {{ put("parameters", new JSONObject() {{
put("protocolVersion", "ECv2"); put("protocolVersion", "ECv2");
put("publicKey", androidPayPublicKey); put("publicKey", googlePayPublicKey);
}}); }});
}}); }});
} else { } else {
cardPaymentMethod.put("tokenizationSpecification", new JSONObject() {{ cardPaymentMethod.put("tokenizationSpecification", new JSONObject() {{
put("type", "PAYMENT_GATEWAY"); put("type", "PAYMENT_GATEWAY");
put("parameters", new JSONObject() {{ if (googlePayParameters != null) {
put("gateway", "stripe"); put("parameters", googlePayParameters);
put("stripe:publishableKey", stripeApiKey); } else {
put("stripe:version", StripeApiHandler.VERSION); 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("totalPrice", totalPriceDecimal = getTotalPriceDecimalString(arrayList));
transactionInfo.put("totalPriceStatus", "FINAL"); transactionInfo.put("totalPriceStatus", "FINAL");
transactionInfo.put("countryCode", countryName); if (!TextUtils.isEmpty(googlePayCountryCode)) {
transactionInfo.put("countryCode", googlePayCountryCode);
}
transactionInfo.put("currencyCode", paymentForm.invoice.currency); transactionInfo.put("currencyCode", paymentForm.invoice.currency);
transactionInfo.put("checkoutOption", "COMPLETE_IMMEDIATE_PURCHASE"); transactionInfo.put("checkoutOption", "COMPLETE_IMMEDIATE_PURCHASE");
paymentDataRequest.put("transactionInfo", transactionInfo); 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); AutoResolveHelper.resolveTask(paymentsClient.loadPaymentData(request), getParentActivity(), LOAD_PAYMENT_DATA_REQUEST_CODE);
} }
} catch (JSONException e) { } 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) { if (Build.VERSION.SDK_INT < 19 || getParentActivity() == null) {
return; return;
} }
@ -2328,12 +2323,12 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
Task<Boolean> task = paymentsClient.isReadyToPay(request); Task<Boolean> task = paymentsClient.isReadyToPay(request);
task.addOnCompleteListener(getParentActivity(), task.addOnCompleteListener(getParentActivity(),
(OnCompleteListener<Boolean>) task1 -> { task1 -> {
if (task1.isSuccessful()) { if (task1.isSuccessful()) {
if (androidPayContainer != null) { if (googlePayContainer != null) {
androidPayContainer.setVisibility(View.VISIBLE); googlePayContainer.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet(); 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.setInterpolator(new DecelerateInterpolator());
animatorSet.setDuration(180); animatorSet.setDuration(180);
animatorSet.start(); animatorSet.start();
@ -2459,11 +2454,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
final String tokenizationType = tokenizationData.getString("type"); final String tokenizationType = tokenizationData.getString("type");
final String token = tokenizationData.getString("token"); final String token = tokenizationData.getString("token");
if (androidPayPublicKey != null) { if (googlePayPublicKey != null || googlePayParameters != null) {
androidPayCredentials = new TLRPC.TL_inputPaymentCredentialsAndroidPay(); googlePayCredentials = new TLRPC.TL_inputPaymentCredentialsGooglePay();
androidPayCredentials.payment_token = new TLRPC.TL_dataJSON(); googlePayCredentials.payment_token = new TLRPC.TL_dataJSON();
androidPayCredentials.payment_token.data = tokenizationData.toString(); googlePayCredentials.payment_token.data = tokenizationData.toString();
androidPayCredentials.google_transaction_id = "";
String descriptions = paymentMethodData.optString("description"); String descriptions = paymentMethodData.optString("description");
if (!TextUtils.isEmpty(descriptions)) { if (!TextUtils.isEmpty(descriptions)) {
cardName = descriptions; cardName = descriptions;
@ -2478,7 +2472,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
} }
goToNextStep(); goToNextStep();
} catch (JSONException e) { } catch (JSONException e) {
throw new RuntimeException("The selected garment cannot be parsed from the list of elements"); FileLog.e(e);
} }
} else { } else {
if (resultCode == AutoResolveHelper.RESULT_ERROR) { if (resultCode == AutoResolveHelper.RESULT_ERROR) {
@ -2513,7 +2507,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
} else { } else {
nextStep = 2; 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) { } else if (currentStep == 1) {
int nextStep; int nextStep;
if (paymentForm.saved_credentials != null) { if (paymentForm.saved_credentials != null) {
@ -2531,16 +2525,16 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
} else { } else {
nextStep = 2; 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) { } else if (currentStep == 2) {
if (paymentForm.password_missing && saveCardInfo) { 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.setCurrentPassword(currentPassword);
passwordFragment.setDelegate(new PaymentFormActivityDelegate() { passwordFragment.setDelegate(new PaymentFormActivityDelegate() {
@Override @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) { if (delegate != null) {
delegate.didSelectNewCard(tokenJson, card, saveCard, androidPay); delegate.didSelectNewCard(tokenJson, card, saveCard, googlePay);
} }
if (isWebView) { if (isWebView) {
removeSelfFromStack(); removeSelfFromStack();
@ -2561,10 +2555,10 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
presentFragment(passwordFragment, isWebView); presentFragment(passwordFragment, isWebView);
} else { } else {
if (delegate != null) { if (delegate != null) {
delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, androidPayCredentials); delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, googlePayCredentials);
finishFragment(); finishFragment();
} else { } 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) { } else if (currentStep == 3) {
@ -2574,13 +2568,13 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
} else { } else {
nextStep = 2; 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) { } else if (currentStep == 4) {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.paymentFinished); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.paymentFinished);
finishFragment(); finishFragment();
} else if (currentStep == 6) { } else if (currentStep == 6) {
if (!delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, androidPayCredentials)) { if (!delegate.didSelectNewCard(paymentJson, cardName, saveCardInfo, googlePayCredentials)) {
presentFragment(new PaymentFormActivity(paymentForm, messageObject, 4, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, androidPayCredentials), true); presentFragment(new PaymentFormActivity(paymentForm, messageObject, 4, requestedInfo, shippingOption, paymentJson, cardName, validateRequest, saveCardInfo, googlePayCredentials), true);
} else { } else {
finishFragment(); finishFragment();
} }
@ -3048,8 +3042,8 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
req.credentials = new TLRPC.TL_inputPaymentCredentialsSaved(); req.credentials = new TLRPC.TL_inputPaymentCredentialsSaved();
req.credentials.id = paymentForm.saved_credentials.id; req.credentials.id = paymentForm.saved_credentials.id;
req.credentials.tmp_password = UserConfig.getInstance(currentAccount).tmpPassword.tmp_password; req.credentials.tmp_password = UserConfig.getInstance(currentAccount).tmpPassword.tmp_password;
} else if (androidPayCredentials != null) { } else if (googlePayCredentials != null) {
req.credentials = androidPayCredentials; req.credentials = googlePayCredentials;
} else { } else {
req.credentials = new TLRPC.TL_inputPaymentCredentials(); req.credentials = new TLRPC.TL_inputPaymentCredentials();
req.credentials.save = saveCardInfo; req.credentials.save = saveCardInfo;

View file

@ -524,6 +524,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
@Override @Override
public boolean onTouchEvent(@NonNull TextView widget, @NonNull Spannable buffer, @NonNull MotionEvent event) { public boolean onTouchEvent(@NonNull TextView widget, @NonNull Spannable buffer, @NonNull MotionEvent event) {
try { try {
if (!imagesArrLocals.isEmpty()) {
return false;
}
int action = event.getAction(); int action = event.getAction();
boolean result = false; boolean result = false;

View file

@ -2080,6 +2080,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
layoutManager.scrollToPositionWithOffset(pos, top - paddingTop); layoutManager.scrollToPositionWithOffset(pos, top - paddingTop);
layout = true; layout = true;
} else {
layoutManager.scrollToPositionWithOffset(0, AndroidUtilities.dp(88) - paddingTop);
} }
if (currentPaddingTop != paddingTop || listView.getPaddingBottom() != paddingBottom) { if (currentPaddingTop != paddingTop || listView.getPaddingBottom() != paddingBottom) {
listView.setPadding(0, paddingTop, 0, paddingBottom); listView.setPadding(0, paddingTop, 0, paddingBottom);
@ -6630,10 +6632,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
case 8: case 8:
UserCell userCell = (UserCell) holder.itemView; UserCell userCell = (UserCell) holder.itemView;
TLRPC.ChatParticipant part; TLRPC.ChatParticipant part;
if (!sortedUsers.isEmpty()) { try {
part = chatInfo.participants.participants.get(sortedUsers.get(position - membersStartRow)); if (!sortedUsers.isEmpty()) {
} else { part = chatInfo.participants.participants.get(sortedUsers.get(position - membersStartRow));
part = chatInfo.participants.participants.get(position - membersStartRow); } else {
part = chatInfo.participants.participants.get(position - membersStartRow);
}
} catch (Exception e) {
part = null;
FileLog.e(e);
} }
if (part != null) { if (part != null) {
String role; 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_profile_status));
arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_avatar_subtitleInProfileBlue)); 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)); if (mediaCounterTextView != null) {
arrayList.add(new ThemeDescription(mediaCounterTextView.getNextTextView(), ThemeDescription.FLAG_TEXTCOLOR, null, null, null, themeDelegate, Theme.key_player_actionBarSubtitle)); 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(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)); 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 { try {
audioTrack.stop(); audioTrack.stop();
Logging.d(TAG, "AudioTrack.stop is done."); Logging.d(TAG, "AudioTrack.stop is done.");
} catch (IllegalStateException e) { } catch (Exception e) {
Logging.e(TAG, "AudioTrack.stop failed: " + e.getMessage()); Logging.e(TAG, "AudioTrack.stop failed: " + e.getMessage());
} }
} }

View file

@ -3870,6 +3870,8 @@
<string name="AccDescrOpenInPhotoViewer">Open in photo viewer</string> <string name="AccDescrOpenInPhotoViewer">Open in photo viewer</string>
<string name="AccDescrMusicInfo">%2$s by %1$s</string> <string name="AccDescrMusicInfo">%2$s by %1$s</string>
<string name="AccDescrMoreOptions">More options</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="AccActionPlay">Play</string>
<string name="AccActionPause">Pause</string> <string name="AccActionPause">Pause</string>
<string name="AccActionDownload">Download</string> <string name="AccActionDownload">Download</string>