Update to 8.4.3

This commit is contained in:
xaxtix 2022-01-10 05:27:47 +03:00
parent c1c2ebaf46
commit ad6629f6fc
47 changed files with 1806 additions and 923 deletions

View File

@ -300,7 +300,7 @@ android {
}
}
defaultConfig.versionCode = 2522
defaultConfig.versionCode = 2531
applicationVariants.all { variant ->
variant.outputs.all { output ->
@ -319,7 +319,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.4.1"
versionName "8.4.3"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -34,6 +34,7 @@ dialogTextLink=-14057020
chat_status=-2627597
windowBackgroundWhiteBlueHeader=-14380330
chat_messagePanelVoiceBackground=-10374934
switchTrackBlueChecked=-12940870
chat_topPanelLine=-11949852
chat_outInstantSelected=-14770977
chat_outSentCheck=-14967834
@ -80,8 +81,8 @@ dialogTextGray4=-7565423
chat_attachContactText=-2121728
chat_searchPanelIcons=-12937244
windowBackgroundWhiteLinkText=-13990712
chat_outVenueInfoText=-9396792
chat_outContactPhoneText=-9396792
chat_outVenueInfoText=-8216913
chat_outContactPhoneText=-8612185
chat_inAudioTitleText=-15061445
chat_messageLinkIn=-16090691
chat_inBubbleSelected=-1509892
@ -92,7 +93,7 @@ chat_outSiteNameText=-14515511
dialogTextGray=-7565423
chat_messageLinkOut=-16155709
avatar_backgroundArchived=-4998207
chat_outFileInfoSelectedText=-9396792
chat_outFileInfoSelectedText=-8674358
chat_outAudioDurationSelectedText=-8674358
avatar_backgroundArchivedHidden=-10832396
statisticChartLine_orange=-1853657
@ -105,7 +106,7 @@ chat_outReplyLine=-13133085
chat_inAudioSeekbarFill=-10572824
chat_inContactBackground=-431707662
progressCircle=-14375188
chat_outVenueInfoSelectedText=-9396792
chat_outVenueInfoSelectedText=-8674358
chats_menuItemIcon=-7433063
wallpaperFileOffset=-1
chat_outBubbleShadow=-16699318
@ -130,8 +131,8 @@ chat_outBubbleSelected=-2690305
chat_inFileNameText=-15654091
statisticChartLine_blue=-13467675
chat_inInstantSelected=-14707230
chat_outFileInfoText=-9396792
chat_outContactPhoneSelectedText=-9396792
chat_outFileInfoText=-7953740
chat_outContactPhoneSelectedText=-9725764
chat_wallpaper=-11300655
chat_outMenuSelected=-7026959
chat_outLoaderPhotoSelected=-263935502
@ -142,14 +143,14 @@ avatar_actionBarSelectorBlue=-12091735
switchTrackChecked=-11424793
chat_inLoader=-431707662
chat_outPreviewInstantSelectedText=-14514998
chat_outTimeText=-143614520
chat_outTimeText=-141776195
chat_attachAudioText=-2209977
chat_outBubble=-1641732
chat_attachHideBackground=-4866356
chats_menuItemText=-12632257
chat_outReplyNameText=-14382642
chats_menuTopBackgroundCats=-10906430
chat_outReplyMediaMessageText=-9396792
chat_outReplyMediaMessageText=-7558467
actionBarTabSelector=-12554340
chat_outLoaderPhotoIcon=-263935502
chat_attachFileText=-15423260
@ -178,9 +179,9 @@ chats_actionPressedBackground=-11166764
chat_replyPanelName=-13397538
windowBackgroundWhiteValueText=-13003565
chat_outAudioDurationText=-7558467
chat_outMenu=-5782571
chat_outMenu=-5716778
statisticChartActiveLine=335544320
chat_outReplyMediaMessageSelectedText=-9396792
chat_outReplyMediaMessageSelectedText=-8674357
chats_attachMessage=-14843710
chat_outSentClock=-594761027
chat_searchPanelText=-12609056

View File

@ -36,6 +36,7 @@ chat_inMediaIcon=-1
actionBarDefaultArchived=-13748149
avatar_subtitleInProfileViolet=-7628894
chat_messagePanelCancelInlineBot=-8549479
voipgroup_topPanelGray=-10521727
dialogSearchBackground=-14010037
chat_outAudioSeekbarFill=-7944965
chat_botKeyboardButtonBackgroundPressed=-12956574
@ -373,6 +374,7 @@ chat_outReplyMediaMessageText=-7357217
chat_textSelectBackground=1516415459
chat_messagePanelVoiceDelete=-1
chat_inAudioProgress=-1
chat_inReactionButtonTextSelected=-1
chats_date=-9207925
chat_messagePanelText=-1
actionBarTabSelector=926307434
@ -431,6 +433,7 @@ chat_outReplyMessageText=-1
chat_recordedVoiceDot=-1221292
chat_messagePanelBackground=-14602949
chat_inLoaderPhotoSelected=-14925725
chat_inReactionButtonText=-1
chat_inVoiceSeekbarFill=-10177041
graySection=-15459033
chat_outAudioSeekbar=-429551165
@ -462,4 +465,3 @@ chat_outSentClock=-8213557
dialogBackgroundGray=-14932431
chat_searchPanelText=-8796932
chat_inContactIcon=-1
voipgroup_topPanelGray=-10521727

View File

@ -393,6 +393,7 @@ chat_outReplyMediaMessageText=-7023626
chat_textSelectBackground=1516415459
chat_messagePanelVoiceDelete=-1
chat_inAudioProgress=-1
chat_inReactionButtonTextSelected=-1
chats_date=-8882056
chat_messagePanelText=-1
actionBarTabSelector=827876202
@ -456,6 +457,7 @@ chat_recordedVoiceDot=-1221292
chat_messagePanelBackground=-14803425
chat_wallpaper_gradient_to=-15790320
chat_inLoaderPhotoSelected=-14925725
chat_inReactionButtonText=-1
chats_messageArchived=-8224126
chat_inVoiceSeekbarFill=-10177041
graySection=-16053492

View File

@ -427,6 +427,7 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
view.setTranslationX(-deltaX);
}
mPendingMoves.add(moveInfo);
checkIsRunning();
return true;
}
@ -655,6 +656,7 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
}
mPendingMoves.add(moveInfo);
checkIsRunning();
return true;
}
@ -926,6 +928,7 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
newHolder.itemView.setAlpha(0);
}
mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
checkIsRunning();
return true;
}

View File

@ -210,6 +210,7 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
public boolean animateRemove(final RecyclerView.ViewHolder holder, ItemHolderInfo info) {
resetAnimation(holder);
mPendingRemovals.add(holder);
checkIsRunning();
return true;
}
@ -247,6 +248,7 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
resetAnimation(holder);
holder.itemView.setAlpha(0);
mPendingAdditions.add(holder);
checkIsRunning();
return true;
}
@ -296,6 +298,7 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
view.setTranslationY(-deltaY);
}
mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
checkIsRunning();
return true;
}
@ -380,6 +383,7 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
newHolder.itemView.setAlpha(0);
}
mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
checkIsRunning();
return true;
}
@ -734,4 +738,8 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
public void setTranslationInterpolator(Interpolator translationInterpolator) {
this.translationInterpolator = translationInterpolator;
}
public void checkIsRunning() {
}
}

View File

@ -129,6 +129,9 @@ public class GridLayoutManagerFixed extends GridLayoutManager {
int backupPosition = layoutState.mCurrentPosition;
for (int a = layoutState.mCurrentPosition; a > startPosition; a--) {
View view = layoutState.next(recycler);
if (view == null) {
continue;
}
additionalViews.add(view);
if (a != backupPosition) {
calculateItemDecorationsForChild(view, mDecorInsets);

View File

@ -39,6 +39,7 @@ import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
@ -95,6 +96,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.android.internal.telephony.ITelephony;
import com.google.android.exoplayer2.util.Log;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
import com.google.android.gms.tasks.Task;

View File

@ -20,8 +20,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2526;
public static String BUILD_VERSION_STRING = "8.4.2";
public static int BUILD_VERSION = 2531;
public static String BUILD_VERSION_STRING = "8.4.3";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View File

@ -14,7 +14,6 @@ import android.util.Base64;
import androidx.collection.LongSparseArray;
import com.google.android.exoplayer2.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
@ -1114,7 +1113,7 @@ public class GcmPushListenerService extends FirebaseMessagingService {
}
}
private String getReactedText(String loc_key, String[] args) {
private String getReactedText(String loc_key, Object[] args) {
switch (loc_key) {
case "REACT_TEXT": {
return LocaleController.formatString("PushReactText", R.string.PushReactText, args);

View File

@ -14,8 +14,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
@ -859,7 +857,7 @@ public class ImageLoader {
if (args.length >= 3 && "pcache".equals(args[2])) {
precache = true;
} else {
precache = SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_HIGH;
precache = !cacheImage.filter.contains("nolimit") && SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_HIGH;
}
}

View File

@ -27,6 +27,8 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import androidx.annotation.Keep;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AnimatedFileDrawable;
@ -34,8 +36,6 @@ import org.telegram.ui.Components.LoadingStickerDrawable;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RecyclableDrawable;
import androidx.annotation.Keep;
import java.util.ArrayList;
public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate {
@ -263,6 +263,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
private boolean centerRotation;
private ImageReceiverDelegate delegate;
private float currentAlpha;
private float previousAlpha = 1f;
private long lastUpdateAlphaTime;
private byte crossfadeAlpha = 1;
private boolean manualAlphaAnimator;
@ -360,7 +361,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (strippedBitmap != null) {
setImage(ImageLocation.getForUserOrChat(object, ImageLocation.TYPE_SMALL), "50_50", strippedBitmap, null, parentObject, 0);
} else if (hasStripped) {
setImage(ImageLocation.getForUserOrChat(object, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(object, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, parentObject, 0);
setImage(ImageLocation.getForUserOrChat(object, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(object, ImageLocation.TYPE_STRIPPED), "50_50_b", avatarDrawable, parentObject, 0);
} else {
setImage(ImageLocation.getForUserOrChat(object, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, null, parentObject, 0);
}
@ -578,6 +579,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
updateDrawableRadius(staticThumbDrawable);
}
currentAlpha = 1.0f;
previousAlpha = 1f;
if (staticThumbDrawable instanceof SvgHelper.SvgDrawable) {
((SvgHelper.SvgDrawable) staticThumbDrawable).setParent(this);
@ -746,6 +748,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
currentSize = 0;
currentCacheType = 0;
currentAlpha = 1;
previousAlpha = 1f;
if (setImageBackup != null) {
setImageBackup.clear();
@ -1335,6 +1338,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
currentAlpha += dt / (float) crossfadeDuration;
if (currentAlpha > 1) {
currentAlpha = 1;
previousAlpha = 1f;
if (crossfadeImage != null) {
recycleBitmap(null, 2);
crossfadeShader = null;
@ -1410,6 +1414,9 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
if (drawable != null) {
if (crossfadeAlpha != 0) {
if (previousAlpha != 1f && (drawable == currentImageDrawable || drawable == currentMediaDrawable) && staticThumbDrawable != null) {
drawDrawable(canvas, staticThumbDrawable, (int) (overrideAlpha * 255), shaderToUse, orientation);
}
if (crossfadeWithThumb && animationNotReady) {
drawDrawable(canvas, drawable, (int) (overrideAlpha * 255), shaderToUse, orientation);
} else {
@ -1443,7 +1450,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (thumbDrawable instanceof SvgHelper.SvgDrawable || thumbDrawable instanceof Emoji.EmojiDrawable) {
alpha = (int) (overrideAlpha * 255 * (1.0f - currentAlpha));
} else {
alpha = (int) (overrideAlpha * 255);
alpha = (int) (overrideAlpha * previousAlpha * 255);
}
drawDrawable(canvas, thumbDrawable, alpha, thumbShaderToUse, thumbOrientation);
if (alpha != 255 && thumbDrawable instanceof Emoji.EmojiDrawable) {
@ -2077,7 +2084,8 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} else if (currentImageDrawable instanceof RLottieDrawable) {
allowCorssfade = staticThumbDrawable instanceof LoadingStickerDrawable || staticThumbDrawable instanceof SvgHelper.SvgDrawable || staticThumbDrawable instanceof Emoji.EmojiDrawable;
}
if (allowCorssfade && (currentThumbDrawable == null && staticThumbDrawable == null || currentAlpha == 1.0f || forceCrossfade)) {
if (allowCorssfade && (currentThumbDrawable != null || staticThumbDrawable != null || forceCrossfade)) {
previousAlpha = currentAlpha;
currentAlpha = 0.0f;
lastUpdateAlphaTime = System.currentTimeMillis();
crossfadeWithThumb = crossfadeImage != null || currentThumbDrawable != null || staticThumbDrawable != null;
@ -2101,6 +2109,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
boolean allowCorssfade = true;
if (!memCache && !forcePreview || forceCrossfade) {
if (currentThumbDrawable == null && staticThumbDrawable == null || currentAlpha == 1.0f || forceCrossfade) {
previousAlpha = currentAlpha;
currentAlpha = 0.0f;
lastUpdateAlphaTime = System.currentTimeMillis();
crossfadeWithThumb = crossfadeImage != null || currentThumbDrawable != null || staticThumbDrawable != null;
@ -2139,7 +2148,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} else {
currentAlpha = 0.0f;
lastUpdateAlphaTime = System.currentTimeMillis();
crossfadeWithThumb = staticThumbDrawable != null && currentImageKey == null && currentMediaKey == null;
crossfadeWithThumb = staticThumbDrawable != null;
}
} else {
currentAlpha = 1.0f;

View File

@ -414,10 +414,10 @@ public class LocaleController {
}
return languagesDict.get(key.toLowerCase().replace("-", "_"));
}
public LocaleInfo getLanguageByPlural(String plural) {
public LocaleInfo getBuiltinLanguageByPlural(String plural) {
Collection<LocaleInfo> values = languagesDict.values();
for (LocaleInfo l : values)
if (l.pluralLangCode != null && l.pluralLangCode.equals(plural))
if (l.pathToFile != null && l.pathToFile.equals("remote") && l.pluralLangCode != null && l.pluralLangCode.equals(plural))
return l;
return null;
}

View File

@ -10,7 +10,6 @@ package org.telegram.messenger;
import android.app.Activity;
import android.content.Context;
import android.content.Entity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ShortcutManager;
@ -355,9 +354,15 @@ public class MediaDataController extends BaseController {
ImageReceiver imageReceiver = new ImageReceiver();
TLRPC.TL_availableReaction reaction = reactions.get(i);
imageReceiver.setImage(ImageLocation.getForDocument(reaction.activate_animation), null, null, null, 0, 1);
imageReceiver.setImage(ImageLocation.getForDocument(reaction.appear_animation), null, null, null, 0, 1);
ImageLoader.getInstance().loadImageForImageReceiver(imageReceiver);
imageReceiver = new ImageReceiver();
imageReceiver.setImage(ImageLocation.getForDocument(reaction.appear_animation), "60_60_nolimit", null, null, 0, 1);
ImageLoader.getInstance().loadImageForImageReceiver(imageReceiver);
imageReceiver = new ImageReceiver();
imageReceiver.setImage(ImageLocation.getForDocument(reaction.static_icon), null, null, null, 0, 1);
ImageLoader.getInstance().loadImageForImageReceiver(imageReceiver);
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.reactionsDidLoad);
});
@ -4589,23 +4594,31 @@ public class MediaDataController extends BaseController {
}
}
public static void addTextStyleRuns(TLRPC.DraftMessage msg, Spannable text) {
addTextStyleRuns(msg.entities, msg.message, text);
public static void addTextStyleRuns(MessageObject msg, Spannable text) {
addTextStyleRuns(msg.messageOwner.entities, msg.messageText, text, -1);
}
public static void addTextStyleRuns(MessageObject msg, Spannable text) {
addTextStyleRuns(msg.messageOwner.entities, msg.messageText, text);
public static void addTextStyleRuns(TLRPC.DraftMessage msg, Spannable text, int allowedFlags) {
addTextStyleRuns(msg.entities, msg.message, text, allowedFlags);
}
public static void addTextStyleRuns(MessageObject msg, Spannable text, int allowedFlags) {
addTextStyleRuns(msg.messageOwner.entities, msg.messageText, text, allowedFlags);
}
public static void addTextStyleRuns(ArrayList<TLRPC.MessageEntity> entities, CharSequence messageText, Spannable text) {
addTextStyleRuns(entities, messageText, text, -1);
}
public static void addTextStyleRuns(ArrayList<TLRPC.MessageEntity> entities, CharSequence messageText, Spannable text, int allowedFlags) {
for (TextStyleSpan prevSpan : text.getSpans(0, text.length(), TextStyleSpan.class))
text.removeSpan(prevSpan);
for (TextStyleSpan.TextStyleRun run : MediaDataController.getTextStyleRuns(entities, messageText)) {
for (TextStyleSpan.TextStyleRun run : MediaDataController.getTextStyleRuns(entities, messageText, allowedFlags)) {
MediaDataController.addStyleToText(new TextStyleSpan(run), run.start, run.end, text, true);
}
}
public static ArrayList<TextStyleSpan.TextStyleRun> getTextStyleRuns(ArrayList<TLRPC.MessageEntity> entities, CharSequence text) {
public static ArrayList<TextStyleSpan.TextStyleRun> getTextStyleRuns(ArrayList<TLRPC.MessageEntity> entities, CharSequence text, int allowedFlags) {
ArrayList<TextStyleSpan.TextStyleRun> runs = new ArrayList<>();
ArrayList<TLRPC.MessageEntity> entitiesCopy = new ArrayList<>(entities);
@ -4654,6 +4667,8 @@ public class MediaDataController extends BaseController {
newRun.urlEntity = entity;
}
newRun.flags &= allowedFlags;
for (int b = 0, N2 = runs.size(); b < N2; b++) {
TextStyleSpan.TextStyleRun run = runs.get(b);

View File

@ -98,9 +98,9 @@ public class MessageObject {
public CharSequence caption;
public MessageObject replyMessageObject;
public int type = 1000;
public boolean reactionsVisibleOnScreen;
public long reactionsLastCheckTime;
public String customName;
public boolean reactionsChanged;
private int isRoundVideoCached;
public long eventId;
public int contentType;
@ -6275,6 +6275,7 @@ public class MessageObject {
}
}
}
reactionsChanged = true;
return false;
}
@ -6308,6 +6309,7 @@ public class MessageObject {
action.user_id = UserConfig.getInstance(currentAccount).getClientUserId();
action.reaction = reaction;
}
reactionsChanged = true;
return true;
}
}

View File

@ -28,8 +28,6 @@ import android.util.SparseIntArray;
import androidx.collection.LongSparseArray;
import androidx.core.app.NotificationManagerCompat;
import com.google.android.exoplayer2.util.Log;
import org.telegram.SQLite.SQLiteCursor;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.messenger.support.LongSparseLongArray;
@ -136,10 +134,6 @@ public class MessagesController extends BaseController implements NotificationCe
private int pollsToCheckSize;
private long lastViewsCheckTime;
private LongSparseArray<SparseArray<MessageObject>> reactionsToCheck = new LongSparseArray<>();
private long lastReactionsCheckTime;
private LongSparseArray<List<Integer>> reactionsTempDialogs = new LongSparseArray<>();
public ArrayList<DialogFilter> dialogFilters = new ArrayList<>();
public SparseArray<DialogFilter> dialogFiltersById = new SparseArray<>();
private boolean loadingSuggestedFilters;
@ -2610,7 +2604,6 @@ public class MessagesController extends BaseController implements NotificationCe
channelViewsToSend.clear();
pollsToCheck.clear();
pollsToCheckSize = 0;
reactionsToCheck.clear();
dialogsServerOnly.clear();
dialogsForward.clear();
allDialogs.clear();
@ -2842,12 +2835,6 @@ public class MessagesController extends BaseController implements NotificationCe
object.pollVisibleOnScreen = false;
}
}
array = reactionsToCheck.get(dialogId);
if (array != null) {
for (int i = 0; i < array.size(); i++) {
array.valueAt(i).reactionsVisibleOnScreen = false;
}
}
}
}
Utilities.stageQueue.postRunnable(() -> {
@ -5399,57 +5386,6 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
int currentServerTime = getConnectionsManager().getCurrentTime();
if (Math.abs(System.currentTimeMillis() - lastReactionsCheckTime) >= 15000) {
lastReactionsCheckTime = System.currentTimeMillis();
if (reactionsToCheck.size() > 0) {
AndroidUtilities.runOnUIThread(() -> {
long time = SystemClock.elapsedRealtime();
for (int a = 0, N = reactionsToCheck.size(); a < N; a++) {
SparseArray<MessageObject> array = reactionsToCheck.valueAt(a);
if (array == null) {
continue;
}
reactionsTempDialogs.clear();
for (int b = 0, N2 = array.size(); b < N2; b++) {
MessageObject messageObject = array.valueAt(b);
List<Integer> ids = reactionsTempDialogs.get(messageObject.getDialogId());
if (ids == null) {
reactionsTempDialogs.put(messageObject.getDialogId(), ids = new ArrayList<>());
}
ids.add(messageObject.getId());
int timeout = 15000;
if (Math.abs(time - messageObject.reactionsLastCheckTime) < timeout) {
if (!messageObject.reactionsVisibleOnScreen) {
array.remove(messageObject.getId());
N2--;
b--;
}
} else {
messageObject.reactionsLastCheckTime = time;
}
}
if (array.size() == 0) {
reactionsToCheck.remove(reactionsToCheck.keyAt(a));
N--;
a--;
}
}
for (int i = 0; i < reactionsTempDialogs.size(); i++) {
TLRPC.TL_messages_getMessagesReactions req = new TLRPC.TL_messages_getMessagesReactions();
req.peer = getInputPeer(reactionsTempDialogs.keyAt(i));
req.id.addAll(reactionsTempDialogs.valueAt(i));
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.Updates updates = (TLRPC.Updates) response;
processUpdates(updates, false);
}
});
}
});
}
}
if (Math.abs(System.currentTimeMillis() - lastViewsCheckTime) >= 5000) {
lastViewsCheckTime = System.currentTimeMillis();
if (channelViewsToSend.size() != 0) {
@ -8607,26 +8543,22 @@ public class MessagesController extends BaseController implements NotificationCe
});
}
public void addToReactionsQueue(long dialogId, ArrayList<MessageObject> visibleObjects) {
SparseArray<MessageObject> array = reactionsToCheck.get(dialogId);
if (array == null) {
reactionsToCheck.put(dialogId, array = new SparseArray<>());
public void loadReactionsForMessages(long dialogId, ArrayList<MessageObject> visibleObjects) {
if (visibleObjects.isEmpty()) {
return;
}
for (int a = 0, N = array.size(); a < N; a++) {
MessageObject object = array.valueAt(a);
object.reactionsVisibleOnScreen = false;
TLRPC.TL_messages_getMessagesReactions req = new TLRPC.TL_messages_getMessagesReactions();
req.peer = getInputPeer(dialogId);
for (int i = 0; i < visibleObjects.size(); i++) {
MessageObject messageObject = visibleObjects.get(i);
req.id.add(messageObject.getId());
}
int time = getConnectionsManager().getCurrentTime();
for (int a = 0, N = visibleObjects.size(); a < N; a++) {
MessageObject messageObject = visibleObjects.get(a);
int id = messageObject.getId();
MessageObject object = array.get(id);
if (object != null) {
object.reactionsVisibleOnScreen = true;
} else {
array.put(id, messageObject);
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.Updates updates = (TLRPC.Updates) response;
processUpdates(updates, false);
}
}
});
}
public void addToPollsQueue(long dialogId, ArrayList<MessageObject> visibleObjects) {
@ -14044,7 +13976,7 @@ public class MessagesController extends BaseController implements NotificationCe
return info.messages;
}
TLRPC.Chat chat = getChat(-dialogId);
if (!ChatObject.isChannel(chat) || chat.megagroup || chat.gigagroup) {
if (!ChatObject.isChannel(chat)) {
return null;
}
info = new SponsoredMessagesInfo();
@ -14926,7 +14858,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
public void markSponsoredAsRead(long dialog_id, MessageObject object) {
sponsoredMessages.remove(dialog_id);
// sponsoredMessages.remove(dialog_id);
}
public void deleteMessagesRange(long dialogId, long channelId, int minDate, int maxDate, boolean forAll, Runnable callback) {

View File

@ -2663,8 +2663,13 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
return;
}
TLRPC.TL_messages_sendReaction req = new TLRPC.TL_messages_sendReaction();
req.peer = getMessagesController().getInputPeer(messageObject.getDialogId());
req.msg_id = messageObject.getId();
if (messageObject.messageOwner.isThreadMessage) {
req.peer = getMessagesController().getInputPeer(messageObject.getFromChatId());
req.msg_id = messageObject.messageOwner.fwd_from.saved_from_msg_id;
} else {
req.peer = getMessagesController().getInputPeer(messageObject.getDialogId());
req.msg_id = messageObject.getId();
}
if (reaction != null) {
req.reaction = reaction.toString();
req.flags |= 1;

View File

@ -485,6 +485,14 @@ public class TLRPC {
photo_big = new TL_fileLocationToBeDeprecated();
photo_big.volume_id = -photo_id;
photo_big.local_id = 'c';
if (stripped_thumb != null && Build.VERSION.SDK_INT >= 21) {
try {
strippedBitmap = new BitmapDrawable(ImageLoader.getStrippedPhotoBitmap(stripped_thumb, "b"));
} catch (Throwable e) {
FileLog.e(e);
}
}
}
public void serializeToStream(AbstractSerializedData stream) {
@ -30395,6 +30403,14 @@ public class TLRPC {
photo_big = new TL_fileLocationToBeDeprecated();
photo_big.volume_id = -photo_id;
photo_big.local_id = 'c';
if (stripped_thumb != null && Build.VERSION.SDK_INT >= 21) {
try {
strippedBitmap = new BitmapDrawable(ImageLoader.getStrippedPhotoBitmap(stripped_thumb, "b"));
} catch (Throwable e) {
FileLog.e(e);
}
}
}
public void serializeToStream(AbstractSerializedData stream) {
@ -54106,6 +54122,7 @@ public class TLRPC {
if ((flags & 33554432) != 0) {
stream.writeInt32(ttl_period);
}
writeAttachPath(stream);
}
}

View File

@ -22,6 +22,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@ -35,6 +36,8 @@ import android.widget.ScrollView;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.NotificationCenter;

View File

@ -65,6 +65,8 @@ import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.core.graphics.ColorUtils;
import com.google.android.exoplayer2.util.Log;
import org.json.JSONArray;
import org.json.JSONObject;
import org.telegram.messenger.AndroidUtilities;
@ -7525,7 +7527,9 @@ public class Theme {
try {
String[] wallpaperLink = new String[1];
HashMap<String, Integer> colors = getThemeFileValues(new File(pathToFile), null, wallpaperLink);
checkIsDark(colors, accent.parentTheme);
if (accent != null) {
checkIsDark(colors, accent.parentTheme);
}
Integer wallpaperFileOffset = colors.get("wallpaperFileOffset");
Bitmap bitmap = Bitmaps.createBitmap(560, 678, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);

View File

@ -8,6 +8,11 @@
package org.telegram.ui;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_BOTTOM;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_LEFT;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_RIGHT;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_TOP;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@ -169,11 +174,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_BOTTOM;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_LEFT;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_RIGHT;
import static org.telegram.messenger.MessageObject.POSITION_FLAG_TOP;
public class ArticleViewer implements NotificationCenter.NotificationCenterDelegate {
private Activity parentActivity;
@ -5954,7 +5954,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
currentBlock = block;
parentBlock = null;
currentDocument = parentAdapter.getDocumentWithId(currentBlock.video_id);
isGif = MessageObject.isGifDocument(currentDocument)/* && currentBlock.autoplay*/;
isGif = MessageObject.isVideoDocument(currentDocument) || MessageObject.isGifDocument(currentDocument)/* && currentBlock.autoplay*/;
isFirst = first;
channelCell.setVisibility(INVISIBLE);
updateButtonState(false);

View File

@ -129,7 +129,6 @@ import org.telegram.ui.Components.SeekBar;
import org.telegram.ui.Components.SeekBarAccessibilityDelegate;
import org.telegram.ui.Components.SeekBarWaveform;
import org.telegram.ui.Components.SlotsDrawable;
import org.telegram.ui.Components.spoilers.SpoilerEffect;
import org.telegram.ui.Components.StaticLayoutEx;
import org.telegram.ui.Components.TextStyleSpan;
import org.telegram.ui.Components.TimerParticles;
@ -139,6 +138,7 @@ import org.telegram.ui.Components.URLSpanBrowser;
import org.telegram.ui.Components.URLSpanMono;
import org.telegram.ui.Components.URLSpanNoUnderline;
import org.telegram.ui.Components.VideoForwardDrawable;
import org.telegram.ui.Components.spoilers.SpoilerEffect;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.PinchToZoomHelper;
import org.telegram.ui.SecretMediaViewer;
@ -155,11 +155,14 @@ import java.util.concurrent.atomic.AtomicReference;
public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate, ImageReceiver.ImageReceiverDelegate, DownloadController.FileDownloadProgressListener, TextSelectionHelper.SelectableView, NotificationCenter.NotificationCenterDelegate {
public boolean clipToGroupBounds;
public RadialProgress2 getRadialProgress() {
return radialProgress;
}
boolean enterTransitionInPorgress;
public void setEnterTransitionInProgress(boolean b) {
enterTransitionInPorgress = b;
invalidate();
@ -241,6 +244,15 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
public void setScrimReaction(String scrimViewReaction) {
reactionsLayoutInBubble.setScrimReaction(scrimViewReaction);
}
public void drawScrimReaction(Canvas canvas, String scrimViewReaction) {
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChangeProgress, scrimViewReaction);
}
public interface ChatMessageCellDelegate {
default void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
}
@ -1123,7 +1135,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
x -= textX - (block.isRtl() ? currentMessageObject.textXOffset : 0);
y -= block.textYOffset;
final int line = block.textLayout.getLineForVertical(y);
final int off = block.textLayout.getOffsetForHorizontal(line, x);
final int off = block.charactersOffset + block.textLayout.getOffsetForHorizontal(line, x);
final float left = block.textLayout.getLineLeft(line);
if (left <= x && left + block.textLayout.getLineWidth(line) >= x) {
@ -1147,6 +1159,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
try {
LinkPath path = obtainNewUrlPath(false);
int[] pos = getRealSpanStartAndEnd(buffer, pressedLink);
pos[0] -= block.charactersOffset;
pos[1] -= block.charactersOffset;
path.setCurrentLayout(block.textLayout, pos[0], 0);
block.textLayout.getSelectionPath(pos[0], pos[1], path);
if (pos[1] >= block.charactersEnd) {
@ -1163,8 +1177,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
path = obtainNewUrlPath(false);
path.setCurrentLayout(nextBlock.textLayout, 0, nextBlock.textYOffset - block.textYOffset);
nextBlock.textLayout.getSelectionPath(0, pos[1], path);
if (pos[1] < nextBlock.charactersEnd - 1) {
int p1 = pos[1] + block.charactersOffset - nextBlock.charactersOffset;
nextBlock.textLayout.getSelectionPath(0, p1, path);
if (p1 < nextBlock.charactersEnd - 1) {
break;
}
}
@ -1184,9 +1199,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
path = obtainNewUrlPath(false);
offsetY -= nextBlock.height;
path.setCurrentLayout(nextBlock.textLayout, pos[0], offsetY);
nextBlock.textLayout.getSelectionPath(pos[0], pos[1], path);
if (pos[0] > nextBlock.charactersOffset) {
int p0 = pos[0] + block.charactersOffset - nextBlock.charactersOffset;
int p1 = pos[1] + block.charactersOffset - nextBlock.charactersOffset;
path.setCurrentLayout(nextBlock.textLayout, p0, offsetY);
nextBlock.textLayout.getSelectionPath(p0, p1, path);
if (p0 > nextBlock.charactersOffset) {
break;
}
}
@ -1896,7 +1913,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
currentMessageObject.audioProgress = p;
updatePlayingMessageProgress();
} if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
}
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
if (roundSeekbarTouched != 0) {
if (event.getAction() == MotionEvent.ACTION_UP) {
float localX = x - photoImage.getCenterX();
@ -2137,7 +2155,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (hasCaptionLayout() && x >= captionX && y >= captionY && x <= captionX + captionLayout.getWidth() && y <= captionY + captionLayout.getHeight()) {
for (SpoilerEffect eff : captionSpoilers) {
if (eff.getBounds().contains((int)(x - captionX), (int)(y - captionY))) {
if (eff.getBounds().contains((int) (x - captionX), (int) (y - captionY))) {
spoilerPressed = eff;
isCaptionSpoilerPressed = true;
return true;
@ -2166,7 +2184,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
float rad = (float) Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
isSpoilerRevealing = true;
spoilerPressed.setOnRippleEndCallback(()->post(()->{
spoilerPressed.setOnRippleEndCallback(() -> post(() -> {
isSpoilerRevealing = false;
getMessageObject().isSpoilersRevealed = true;
if (isCaptionSpoilerPressed) {
@ -2198,7 +2216,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
ChatMessageCell cell = (ChatMessageCell) ch;
if (cell.getMessageObject() != null && cell.getMessageObject().getReplyMsgId() == getMessageObject().getId()) {
if (!cell.replySpoilers.isEmpty()) {
cell.replySpoilers.get(0).setOnRippleEndCallback(()->post(()->{
cell.replySpoilers.get(0).setOnRippleEndCallback(() -> post(() -> {
cell.getMessageObject().replyMessageObject.isSpoilersRevealed = true;
cell.replySpoilers.clear();
cell.invalidate();
@ -2599,7 +2617,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
return false;
}
return reactionsLayoutInBubble.chekTouchEvent(event);
return reactionsLayoutInBubble.chekTouchEvent(event);
}
@ -2841,7 +2859,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
this.parentViewTopOffset = parentOffset;
parentHeight = parent;
}
if (currentMessageObject != null && (hasGradientService() && currentMessageObject.shouldDrawWithoutBackground() || drawSideButton != 0 || !botButtons.isEmpty()) ) {
if (currentMessageObject != null && (hasGradientService() && currentMessageObject.shouldDrawWithoutBackground() || drawSideButton != 0 || !botButtons.isEmpty())) {
invalidate();
}
@ -3580,16 +3598,21 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
photoImage.setMediaStartEndTime(-1, -1);
boolean canChangeRadius = true;
if (currentPosition == null || ((currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) != 0)) {
if (currentPosition != null) {
reactionsLayoutInBubble.setMessage(groupedMessages.findPrimaryMessageObject(), !messageObject.shouldDrawReactionsInLayout(), resourcesProvider);
if (messageIdChanged || messageObject.reactionsChanged) {
messageObject.reactionsChanged = false;
if (currentPosition == null || ((currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) != 0)) {
if (currentPosition != null) {
reactionsLayoutInBubble.setMessage(groupedMessages.findPrimaryMessageObject(), !messageObject.shouldDrawReactionsInLayout(), resourcesProvider);
} else {
reactionsLayoutInBubble.setMessage(messageObject, !messageObject.shouldDrawReactionsInLayout(), resourcesProvider);
}
} else {
reactionsLayoutInBubble.setMessage(messageObject, !messageObject.shouldDrawReactionsInLayout(), resourcesProvider);
reactionsLayoutInBubble.setMessage(null, false, resourcesProvider);
}
} else {
reactionsLayoutInBubble.setMessage(null, false, resourcesProvider);
}
if (messageChanged) {
firstVisibleBlockNum = 0;
lastVisibleBlockNum = 0;
@ -3895,11 +3918,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
backgroundWidth = reactionsLayoutInBubble.width;
}
if ((hasLinkPreview || hasInvoicePreview) && !drawInstantView) {
reactionsLayoutInBubble.totalHeight += AndroidUtilities.dp(6);
reactionsLayoutInBubble.positionOffsetY += AndroidUtilities.dp(3);
}
totalHeight += reactionsLayoutInBubble.totalHeight;
if ((hasLinkPreview || hasInvoicePreview) && !drawInstantView) {
reactionsLayoutInBubble.totalHeight += AndroidUtilities.dp(6);
reactionsLayoutInBubble.positionOffsetY += AndroidUtilities.dp(3);
}
totalHeight += reactionsLayoutInBubble.totalHeight;
}
}
if (drawPinnedTop) {
@ -4515,7 +4538,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
currentPhotoFilterThumb = String.format(Locale.US, "%d_%d_b", w, h);
if (webDocument != null) {
/*TODO*/photoImage.setImage(ImageLocation.getForWebFile(webDocument), currentPhotoFilter, null, null, webDocument.size, null, messageObject, 1);
/*TODO*/
photoImage.setImage(ImageLocation.getForWebFile(webDocument), currentPhotoFilter, null, null, webDocument.size, null, messageObject, 1);
} else {
if (documentAttachType == DOCUMENT_ATTACH_TYPE_WALLPAPER) {
if (messageObject.mediaExists) {
@ -4548,13 +4572,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
photoImage.setAllowDecodeSingleFrame(true);
photoImage.setAllowStartAnimation(true);
photoImage.startAnimation();
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(documentAttach), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, documentAttach.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(documentAttach), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, documentAttach.size, null, messageObject, 0);
autoPlayingMedia = true;
} else {
if (currentPhotoObjectThumb != null) {
/*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
} else {
/*TODO*/photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoObject instanceof TLRPC.TL_photoStrippedSize || "s".equals(currentPhotoObject.type) ? currentPhotoFilterThumb : currentPhotoFilter, 0, null, messageObject, 0);
/*TODO*/
photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoObject instanceof TLRPC.TL_photoStrippedSize || "s".equals(currentPhotoObject.type) ? currentPhotoFilterThumb : currentPhotoFilter, 0, null, messageObject, 0);
}
}
} else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND) {
@ -4572,23 +4599,28 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
autoPlayingMedia = true;
TLRPC.VideoSize videoSize = MessageObject.getDocumentVideoThumb(document);
if (!messageObject.mediaExists && videoSize != null && (currentPhotoObject == null || currentPhotoObjectThumb == null)) {
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? filter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? filter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
} else {
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
}
} else {
/*TODO*/photoImage.setImage(null, null, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, 0, null, currentMessageObject, 0);
/*TODO*/
photoImage.setImage(null, null, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, 0, null, currentMessageObject, 0);
}
} else {
boolean photoExist = messageObject.mediaExists;
String fileName = FileLoader.getAttachFileName(currentPhotoObject);
if (hasGamePreview || photoExist || DownloadController.getInstance(currentAccount).canDownloadMedia(currentMessageObject) || FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
photoNotSet = false;
/*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
} else {
photoNotSet = true;
if (currentPhotoObjectThumb != null) {
/*TODO*/photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), String.format(Locale.US, "%d_%d_b", w, h), 0, null, messageObject, 0);
/*TODO*/
photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), String.format(Locale.US, "%d_%d_b", w, h), 0, null, messageObject, 0);
} else {
photoImage.setImageBitmap((Drawable) null);
}
@ -5285,7 +5317,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
if (!reactionsLayoutInBubble.isSmall && !reactionsLayoutInBubble.isEmpty) {
// reactionsLayoutInBubble.positionOffsetY += AndroidUtilities.dp(12);
if (captionLayout != null && currentPosition != null && currentMessagesGroup != null && currentMessagesGroup.isDocuments) {
reactionsLayoutInBubble.positionOffsetY += AndroidUtilities.dp(10);
}
reactionsLayoutInBubble.totalHeight = reactionsLayoutInBubble.height + AndroidUtilities.dp(8);
measureTime(messageObject);
int timeLeft = backgroundWidth - reactionsLayoutInBubble.lastLineX - AndroidUtilities.dp(24);
@ -5850,7 +5884,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
minCaptionWidth = (int) (Math.min(getParentWidth(), AndroidUtilities.displaySize.y) * 0.65f);
}
if (!messageObject.needDrawBluredPreview() && (currentCaption != null || (!reactionsLayoutInBubble.isEmpty && !reactionsLayoutInBubble.isSmall) && photoWidth < minCaptionWidth)) {
if (!messageObject.needDrawBluredPreview() && (currentCaption != null || (!reactionsLayoutInBubble.isEmpty && !reactionsLayoutInBubble.isSmall)) && photoWidth < minCaptionWidth) {
widthForCaption = minCaptionWidth;
fixPhotoWidth = true;
} else {
@ -6024,13 +6058,15 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
TLRPC.Document document = messageObject.getDocument();
if (currentMessageObject.videoEditedInfo != null && currentMessageObject.videoEditedInfo.canAutoPlaySourceVideo()) {
/*TODO*/photoImage.setImage(ImageLocation.getForPath(currentMessageObject.videoEditedInfo.originalPath), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForPath(currentMessageObject.videoEditedInfo.originalPath), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0);
photoImage.setMediaStartEndTime(currentMessageObject.videoEditedInfo.startTime / 1000, currentMessageObject.videoEditedInfo.endTime / 1000);
} else {
if (!messageIdChanged && !dataChanged) {
photoImage.setCrossfadeWithOldImage(true);
}
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0);
}
} else if (messageObject.type == MessageObject.TYPE_PHOTO) {
if (messageObject.useCustomPhoto) {
@ -6081,45 +6117,55 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
photoImage.setCrossfadeDuration(250);
}
if (localFile == 0 && videoSize != null && (currentPhotoObject == null || currentPhotoObjectThumb == null)) {
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
} else {
if (isRoundVideo && !messageIdChanged && photoImage.hasStaticThumb()) {
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, null, null, photoImage.getStaticThumb(), document.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, null, null, photoImage.getStaticThumb(), document.size, null, messageObject, 0);
} else {
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
}
}
} else if (localFile == 1) {
/*TODO*/photoImage.setImage(ImageLocation.getForPath(messageObject.isSendError() ? null : messageObject.messageOwner.attachPath), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, 0, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForPath(messageObject.isSendError() ? null : messageObject.messageOwner.attachPath), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, 0, null, messageObject, 0);
} else {
if (videoSize != null && (currentPhotoObject == null || currentPhotoObjectThumb == null)) {
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
} else {
/*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0);
}
}
} else {
if (messageObject.videoEditedInfo != null && messageObject.type == MessageObject.TYPE_ROUND_VIDEO && !currentMessageObject.needDrawBluredPreview()) {
/*TODO*/photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
photoImage.setMediaStartEndTime(currentMessageObject.videoEditedInfo.startTime / 1000, currentMessageObject.videoEditedInfo.endTime / 1000);
} else {
if (!messageIdChanged && !currentMessageObject.needDrawBluredPreview()) {
photoImage.setCrossfadeWithOldImage(true);
photoImage.setCrossfadeDuration(250);
}
/*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0);
}
}
} else {
if (messageObject.videoEditedInfo != null && messageObject.type == MessageObject.TYPE_ROUND_VIDEO && !currentMessageObject.needDrawBluredPreview()) {
/*TODO*/photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
photoImage.setMediaStartEndTime(currentMessageObject.videoEditedInfo.startTime / 1000, currentMessageObject.videoEditedInfo.endTime / 1000);
} else {
if (!messageIdChanged && !currentMessageObject.needDrawBluredPreview()) {
photoImage.setCrossfadeWithOldImage(true);
photoImage.setCrossfadeDuration(250);
}
/*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
/*TODO*/
photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
}
}
}
@ -6275,7 +6321,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
FileLog.e(e);
}
if (messageObject.type == MessageObject.TYPE_PHOTO || messageObject.type == MessageObject.TYPE_VIDEO) {
if (messageObject.type == MessageObject.TYPE_PHOTO || messageObject.type == MessageObject.TYPE_VIDEO) {
totalHeight += AndroidUtilities.dp(6);
}
@ -7313,6 +7359,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
str = LocaleController.getString("InstantView", R.string.InstantView);
}
if (currentMessageObject.isSponsored()) {
int buttonWidth = (int) (Theme.chat_instantViewPaint.measureText(str) + AndroidUtilities.dp(10 + 24 + 10 + 31));
if (backgroundWidth < buttonWidth) {
backgroundWidth = buttonWidth;
}
}
int mWidth = backgroundWidth - AndroidUtilities.dp(10 + 24 + 10 + 31);
instantViewLayout = new StaticLayout(TextUtils.ellipsize(str, Theme.chat_instantViewPaint, mWidth, TextUtils.TruncateAt.END), Theme.chat_instantViewPaint, mWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (drawInstantViewType == 8) {
@ -7398,6 +7450,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
int lastSize;
@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
@ -7638,7 +7691,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
invalidate();
}
} else if (!drawPause && roundToPauseProgress != 0f){
} else if (!drawPause && roundToPauseProgress != 0f) {
roundToPauseProgress -= 16 / 150f;
if (roundToPauseProgress < 0) {
roundToPauseProgress = 0f;
@ -7654,7 +7707,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
invalidate();
}
} else if (!drawTouchedSeekbar && roundToPauseProgress2 != 0f){
} else if (!drawTouchedSeekbar && roundToPauseProgress2 != 0f) {
roundToPauseProgress2 -= 16 / 150f;
if (roundToPauseProgress2 < 0) {
roundToPauseProgress2 = 0f;
@ -8072,7 +8125,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
toSeekBarProgress = 1f;
}
invalidate();
} else if (!showSeekbar && toSeekBarProgress != 0){
} else if (!showSeekbar && toSeekBarProgress != 0) {
toSeekBarProgress -= 16f / 100f;
if (toSeekBarProgress < 0) {
toSeekBarProgress = 0;
@ -8184,7 +8237,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
updateCaptionLayout();
}
updateReactionLayoutPosition();
if (!currentMessageObject.preview && (currentPosition == null || currentMessagesGroup != null && currentMessagesGroup.isDocuments) && !transitionParams.animateBackgroundBoundsInner && !(enterTransitionInPorgress && currentMessageObject.isVoice())) {
if (!currentMessageObject.preview && (currentPosition == null || (currentMessagesGroup != null && currentMessagesGroup.isDocuments && (currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) == 0)) && !transitionParams.animateBackgroundBoundsInner && !(enterTransitionInPorgress && currentMessageObject.isVoice())) {
drawCaptionLayout(canvas, false, 1f);
}
@ -8521,7 +8574,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
int size = AndroidUtilities.dp(48);
buttonX = this.buttonX = (int) (photoImage.getImageX() + (photoImage.getImageWidth() - size) / 2.0f);
buttonY = this.buttonY = (int) (photoImage.getImageY() + (photoImage.getImageHeight() - size) / 2.0f);
radialProgress.setProgressRect((int) buttonX, (int ) buttonY, (int) buttonX + size, (int) buttonY + size);
radialProgress.setProgressRect((int) buttonX, (int) buttonY, (int) buttonX + size, (int) buttonY + size);
}
if (delegate == null || delegate.getPinchToZoomHelper() == null || !delegate.getPinchToZoomHelper().isInOverlayModeFor(this)) {
if (alpha != 1f) {
@ -9740,7 +9793,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (setCurrentDiceValue(!memCache && !currentMessageObject.wasUnread)) {
return;
}
if (!thumb && !currentMessageObject.mediaExists && !currentMessageObject.attachPathExists && (currentMessageObject.type == 0 && (documentAttachType == DOCUMENT_ATTACH_TYPE_WALLPAPER || documentAttachType == DOCUMENT_ATTACH_TYPE_NONE || documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) || currentMessageObject.type == MessageObject.TYPE_PHOTO)){
if (!thumb && !currentMessageObject.mediaExists && !currentMessageObject.attachPathExists && (currentMessageObject.type == 0 && (documentAttachType == DOCUMENT_ATTACH_TYPE_WALLPAPER || documentAttachType == DOCUMENT_ATTACH_TYPE_NONE || documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) || currentMessageObject.type == MessageObject.TYPE_PHOTO)) {
currentMessageObject.mediaExists = true;
updateButtonState(false, true, false);
}
@ -10660,7 +10713,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
public boolean isDrawPinnedBottom() {
return mediaBackground || drawPinnedBottom;
boolean forceMediaByGroup = currentPosition != null && (currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) == 0 && currentMessagesGroup.isDocuments;
return mediaBackground || drawPinnedBottom || forceMediaByGroup;
}
public void drawCheckBox(Canvas canvas) {
@ -10719,6 +10773,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
float transitionYOffsetForDrawables;
public void setDrawableBoundsInner(Drawable drawable, int x, int y, int w, int h) {
if (drawable != null) {
transitionYOffsetForDrawables = (y + h + transitionParams.deltaBottom) - ((int) (y + h + transitionParams.deltaBottom));
@ -10853,73 +10908,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
canvas.restore();
}
if (!transitionParams.animateBackgroundBoundsInner) {
if (!transitionParams.transitionBotButtons.isEmpty()) {
drawBotButtons(canvas, transitionParams.transitionBotButtons, 1f - transitionParams.animateChangeProgress);
}
if (!botButtons.isEmpty()) {
drawBotButtons(canvas, botButtons, transitionParams.animateChangeProgress);
}
}
if (drawSideButton != 0) {
if (currentMessageObject.isOutOwner()) {
sideStartX = getCurrentBackgroundLeft() - AndroidUtilities.dp(8 + 32);
if (currentMessagesGroup != null) {
sideStartX += currentMessagesGroup.transitionParams.offsetLeft - animationOffsetX;
}
} else {
sideStartX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(8);
if (currentMessagesGroup != null) {
sideStartX += currentMessagesGroup.transitionParams.offsetRight - animationOffsetX;
}
}
sideStartY = layoutHeight - AndroidUtilities.dp(41) + transitionParams.deltaBottom;
if (currentMessagesGroup != null) {
sideStartY += currentMessagesGroup.transitionParams.offsetBottom;
if (currentMessagesGroup.transitionParams.backgroundChangeBounds) {
sideStartY -= getTranslationY();
}
}
if (!currentMessageObject.isOutOwner() && isRoundVideo && isAvatarVisible) {
float offsetSize = (AndroidUtilities.roundPlayingMessageSize - AndroidUtilities.roundMessageSize) * 0.7f;
float offsetX = isPlayingRound ? offsetSize : 0;
if (transitionParams.animatePlayingRound) {
offsetX = (isPlayingRound ? transitionParams.animateChangeProgress : (1f - transitionParams.animateChangeProgress)) * offsetSize;
}
sideStartX -= offsetX;
}
if (drawSideButton == 3) {
if (!(enterTransitionInPorgress && !currentMessageObject.isVoice())) {
drawCommentButton(canvas, 1f);
}
} else {
rect.set(sideStartX, sideStartY, sideStartX + AndroidUtilities.dp(32), sideStartY + AndroidUtilities.dp(32));
applyServiceShaderMatrix(getMeasuredWidth(), backgroundHeight, getX(), viewTop);
canvas.drawRoundRect(rect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), getThemedPaint(sideButtonPressed ? Theme.key_paint_chatActionBackgroundSelected : Theme.key_paint_chatActionBackground));
if (hasGradientService()) {
canvas.drawRoundRect(rect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), Theme.chat_actionBackgroundGradientDarkenPaint);
}
if (drawSideButton == 2) {
Drawable goIconDrawable = getThemedDrawable(Theme.key_drawable_goIcon);
if (currentMessageObject.isOutOwner()) {
setDrawableBounds(goIconDrawable, sideStartX + AndroidUtilities.dp(10), sideStartY + AndroidUtilities.dp(9));
canvas.save();
canvas.scale(-1, 1, goIconDrawable.getBounds().centerX(), goIconDrawable.getBounds().centerY());
} else {
setDrawableBounds(goIconDrawable, sideStartX + AndroidUtilities.dp(12), sideStartY + AndroidUtilities.dp(9));
}
goIconDrawable.draw(canvas);
if (currentMessageObject.isOutOwner()) {
canvas.restore();
}
} else {
Drawable drawable = getThemedDrawable(Theme.key_drawable_shareIcon);
setDrawableBounds(drawable, sideStartX + AndroidUtilities.dp(8), sideStartY + AndroidUtilities.dp(9));
drawable.draw(canvas);
}
}
if (!clipToGroupBounds) {
drawOutboundsContent(canvas);
}
if (replyNameLayout != null) {
@ -11399,12 +11389,74 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
public void drawOutboundsContent(Canvas canvas) {
if (transitionParams.animateBackgroundWidth) {
if (!transitionParams.transitionBotButtons.isEmpty()) {
drawBotButtons(canvas, transitionParams.transitionBotButtons, 1f - transitionParams.animateChangeProgress);
if (!transitionParams.transitionBotButtons.isEmpty() && transitionParams.animateBotButtonsChanged) {
drawBotButtons(canvas, transitionParams.transitionBotButtons, 1f - transitionParams.animateChangeProgress);
}
if (!botButtons.isEmpty()) {
drawBotButtons(canvas, botButtons, transitionParams.animateBotButtonsChanged ? transitionParams.animateChangeProgress : 1f);
}
drawSideButton(canvas);
}
private void drawSideButton(Canvas canvas) {
if (drawSideButton != 0) {
if (currentMessageObject.isOutOwner()) {
sideStartX = getCurrentBackgroundLeft() - AndroidUtilities.dp(8 + 32);
if (currentMessagesGroup != null) {
sideStartX += currentMessagesGroup.transitionParams.offsetLeft - animationOffsetX;
}
} else {
sideStartX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(8);
if (currentMessagesGroup != null) {
sideStartX += currentMessagesGroup.transitionParams.offsetRight - animationOffsetX;
}
}
if (!botButtons.isEmpty()) {
drawBotButtons(canvas, botButtons, transitionParams.animateChangeProgress);
sideStartY = layoutHeight - AndroidUtilities.dp(41) + transitionParams.deltaBottom;
if (currentMessagesGroup != null) {
sideStartY += currentMessagesGroup.transitionParams.offsetBottom;
if (currentMessagesGroup.transitionParams.backgroundChangeBounds) {
sideStartY -= getTranslationY();
}
}
if (!currentMessageObject.isOutOwner() && isRoundVideo && isAvatarVisible) {
float offsetSize = (AndroidUtilities.roundPlayingMessageSize - AndroidUtilities.roundMessageSize) * 0.7f;
float offsetX = isPlayingRound ? offsetSize : 0;
if (transitionParams.animatePlayingRound) {
offsetX = (isPlayingRound ? transitionParams.animateChangeProgress : (1f - transitionParams.animateChangeProgress)) * offsetSize;
}
sideStartX -= offsetX;
}
if (drawSideButton == 3) {
if (!(enterTransitionInPorgress && !currentMessageObject.isVoice())) {
drawCommentButton(canvas, 1f);
}
} else {
rect.set(sideStartX, sideStartY, sideStartX + AndroidUtilities.dp(32), sideStartY + AndroidUtilities.dp(32));
applyServiceShaderMatrix(getMeasuredWidth(), backgroundHeight, getX(), viewTop);
canvas.drawRoundRect(rect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), getThemedPaint(sideButtonPressed ? Theme.key_paint_chatActionBackgroundSelected : Theme.key_paint_chatActionBackground));
if (hasGradientService()) {
canvas.drawRoundRect(rect, AndroidUtilities.dp(16), AndroidUtilities.dp(16), Theme.chat_actionBackgroundGradientDarkenPaint);
}
if (drawSideButton == 2) {
Drawable goIconDrawable = getThemedDrawable(Theme.key_drawable_goIcon);
if (currentMessageObject.isOutOwner()) {
setDrawableBounds(goIconDrawable, sideStartX + AndroidUtilities.dp(10), sideStartY + AndroidUtilities.dp(9));
canvas.save();
canvas.scale(-1, 1, goIconDrawable.getBounds().centerX(), goIconDrawable.getBounds().centerY());
} else {
setDrawableBounds(goIconDrawable, sideStartX + AndroidUtilities.dp(12), sideStartY + AndroidUtilities.dp(9));
}
goIconDrawable.draw(canvas);
if (currentMessageObject.isOutOwner()) {
canvas.restore();
}
} else {
Drawable drawable = getThemedDrawable(Theme.key_drawable_shareIcon);
setDrawableBounds(drawable, sideStartX + AndroidUtilities.dp(8), sideStartY + AndroidUtilities.dp(9));
drawable.draw(canvas);
}
}
}
}
@ -11449,7 +11501,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
int additionalTop = 0;
if (currentPosition != null) {
if ((currentPosition.flags & MessageObject.POSITION_FLAG_TOP) == 0) {
additionalTop -= AndroidUtilities.dp( 3);
additionalTop -= AndroidUtilities.dp(3);
}
}
return additionalTop + (drawPinnedTop ? 0 : AndroidUtilities.dp(1));
@ -11730,7 +11782,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
forwardNameXLocal = transitionParams.animateForwardNameX;
}
if (currentMessageObject.isOutOwner() && currentMessageObject.type == MessageObject.TYPE_ROUND_VIDEO && transitionParams.animatePlayingRound || isPlayingRound) {
forwardNameXLocal -= AndroidUtilities.dp (78) * (isPlayingRound ? transitionParams.animateChangeProgress : (1f - transitionParams.animateChangeProgress));
forwardNameXLocal -= AndroidUtilities.dp(78) * (isPlayingRound ? transitionParams.animateChangeProgress : (1f - transitionParams.animateChangeProgress));
}
forwardNameY = AndroidUtilities.dp(12);
@ -12055,16 +12107,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
drawCaptionLayout(canvas, captionLayout, selectionOnly, alpha);
}
if ((currentPosition == null || ((currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) != 0 && (currentPosition.flags & MessageObject.POSITION_FLAG_LEFT) != 0)) && !reactionsLayoutInBubble.isSmall) {
if (!selectionOnly && (currentPosition == null || ((currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) != 0 && (currentPosition.flags & MessageObject.POSITION_FLAG_LEFT) != 0)) && !reactionsLayoutInBubble.isSmall) {
if (reactionsLayoutInBubble.drawServiceShaderBackground) {
applyServiceShaderMatrix(getMeasuredWidth(), backgroundHeight, getX(), viewTop);
}
if (reactionsLayoutInBubble.drawServiceShaderBackground || !transitionParams.animateBackgroundBoundsInner || currentPosition != null) {
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChange ? transitionParams.animateChangeProgress : 1f);
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChange ? transitionParams.animateChangeProgress : 1f, null);
} else {
canvas.save();
canvas.clipRect(0, 0, getMeasuredWidth(), getBackgroundDrawableBottom() + transitionParams.deltaBottom);
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChange ? transitionParams.animateChangeProgress : 1f);
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChange ? transitionParams.animateChangeProgress : 1f, null);
canvas.restore();
}
@ -12328,6 +12380,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
float captionY = this.captionY;
float captionX = this.captionX;
if (transitionParams.animateBackgroundBoundsInner) {
if (transitionParams.transformGroupToSingleMessage) {
captionY -= getTranslationY();
@ -12340,23 +12393,22 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
int restore = Integer.MIN_VALUE;
if (renderingAlpha != 1.0f) {
rect.set(captionX, captionY, captionX + captionLayout.getWidth(), captionY + captionLayout.getHeight());
rect.set(captionX, captionY, captionX + captionLayout.getWidth(), captionY + captionLayout.getHeight());
restore = canvas.saveLayerAlpha(rect, (int) (255 * renderingAlpha), Canvas.ALL_SAVE_FLAG);
}
if (transitionParams.animateBackgroundBoundsInner && currentBackgroundDrawable != null && currentMessagesGroup == null) {
Rect r = currentBackgroundDrawable.getBounds();
if (currentMessageObject.isOutOwner() && !mediaBackground && !pinnedBottom) {
canvas.clipRect(
r.left + AndroidUtilities.dp(4), r.top + AndroidUtilities.dp(4),
r.right - AndroidUtilities.dp(10), r.bottom - AndroidUtilities.dp(4)
getBackgroundDrawableLeft() + transitionParams.deltaLeft + AndroidUtilities.dp(4), getBackgroundDrawableTop() + transitionParams.deltaTop + AndroidUtilities.dp(4),
getBackgroundDrawableRight() + transitionParams.deltaRight - AndroidUtilities.dp(10), getBackgroundDrawableBottom() + transitionParams.deltaBottom - AndroidUtilities.dp(4)
);
} else {
canvas.clipRect(
r.left + AndroidUtilities.dp(4), r.top + AndroidUtilities.dp(4),
r.right - AndroidUtilities.dp(4), r.bottom - AndroidUtilities.dp(4)
getBackgroundDrawableLeft() + transitionParams.deltaLeft + AndroidUtilities.dp(4), getBackgroundDrawableTop() + transitionParams.deltaTop + AndroidUtilities.dp(4),
getBackgroundDrawableRight() + transitionParams.deltaRight - AndroidUtilities.dp(4), getBackgroundDrawableBottom() + transitionParams.deltaBottom - AndroidUtilities.dp(4)
);
}
}
@ -12418,7 +12470,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
boolean drawSelectionBackground = i == 1;
if (i == 1) {
curentAplha *= currentSelectedBackgroundAlpha;
} else if (!shouldDrawTimeOnMedia()){
} else if (!shouldDrawTimeOnMedia()) {
curentAplha *= (1f - currentSelectedBackgroundAlpha);
}
if (transitionParams.animateShouldDrawTimeOnMedia && transitionParams.animateChangeProgress != 1f) {
@ -12501,7 +12553,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (transitionParams.animateBackgroundBoundsInner) {
timeX += animationOffsetX;
timeTitleTimeX += animationOffsetX;
}
if (reactionsLayoutInBubble.isSmall) {
if (transitionParams.animateBackgroundBoundsInner && transitionParams.deltaRight != 0) {
@ -12510,6 +12561,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
timeTitleTimeX += reactionsLayoutInBubble.getCurrentWidth(transitionParams.animateChangeProgress);
}
}
if (transitionParams.animateEditedEnter) {
timeTitleTimeX -= transitionParams.animateEditedWidthDiff * (1f - transitionParams.animateChangeProgress);
}
int timeYOffset;
if (shouldDrawTimeOnMedia()) {
@ -12550,11 +12604,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
float additionalX = -timeLayout.getLineLeft(0);
if (reactionsLayoutInBubble.isSmall) {
updateReactionLayoutPosition();
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChangeProgress);
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChangeProgress, null);
}
if (ChatObject.isChannel(currentChat) && !currentChat.megagroup || (currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0 || repliesLayout != null || isPinned) {
additionalX += this.timeWidth - timeLayout.getLineWidth(0);
if (reactionsLayoutInBubble.isSmall && !reactionsLayoutInBubble.isEmpty) {
additionalX -= reactionsLayoutInBubble.width;
}
int currentStatus = transitionParams.createStatusDrawableParams();
if (transitionParams.lastStatusDrawableParams >= 0 && transitionParams.lastStatusDrawableParams != currentStatus && !statusDrawableAnimationInProgress) {
@ -12597,7 +12654,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
transitionParams.lastStatusDrawableParams = transitionParams.createStatusDrawableParams();
if (drawClock && fromParent && getParent() != null) {
((View)getParent()).invalidate();
((View) getParent()).invalidate();
}
}
@ -12618,7 +12675,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
float additionalX = -timeLayout.getLineLeft(0);
if (reactionsLayoutInBubble.isSmall) {
updateReactionLayoutPosition();
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChangeProgress);
reactionsLayoutInBubble.draw(canvas, transitionParams.animateChangeProgress, null);
}
if (ChatObject.isChannel(currentChat) && !currentChat.megagroup || (currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0 || (repliesLayout != null || transitionParams.animateReplies) || (isPinned || transitionParams.animatePinned)) {
additionalX += this.timeWidth - timeLayout.getLineWidth(0);
@ -12666,7 +12723,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
transitionParams.lastStatusDrawableParams = transitionParams.createStatusDrawableParams();
if (drawClock && fromParent && getParent() != null) {
((View)getParent()).invalidate();
((View) getParent()).invalidate();
}
}
@ -12727,7 +12784,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (!outDrawClock && !isBroadcast && !outIsBroadcast && outDrawCheck2 && drawCheck2 && !outDrawCheck1 && drawCheck1) {
drawStatusDrawable(canvas, drawCheck1, drawCheck2, drawClock, drawError, isBroadcast, alpha, bigRadius, timeYOffset, layoutHeight, statusDrawableProgress, true, drawSelectionBackground);
} else {
drawStatusDrawable(canvas, outDrawCheck1, outDrawCheck2, outDrawClock, outDrawError, outIsBroadcast, alpha, bigRadius, timeYOffset, layoutHeight,1f - statusDrawableProgress, false, drawSelectionBackground);
drawStatusDrawable(canvas, outDrawCheck1, outDrawCheck2, outDrawClock, outDrawError, outIsBroadcast, alpha, bigRadius, timeYOffset, layoutHeight, 1f - statusDrawableProgress, false, drawSelectionBackground);
drawStatusDrawable(canvas, drawCheck1, drawCheck2, drawClock, drawError, isBroadcast, alpha, bigRadius, timeYOffset, layoutHeight, statusDrawableProgress, false, drawSelectionBackground);
}
} else {
@ -12760,7 +12817,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
return;
}
statusDrawableProgress = 0f;
statusDrawableAnimator = ValueAnimator.ofFloat(0,1f);
statusDrawableAnimator = ValueAnimator.ofFloat(0, 1f);
if (moveCheckTransition) {
statusDrawableAnimator.setDuration(220);
} else {
@ -12808,7 +12865,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
clockDrawable.setColor(clockColor);
float timeY = shouldDrawTimeOnMedia() ? photoImage.getImageY2() + additionalTimeOffsetY - AndroidUtilities.dp(9.0f) : layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9.5f : 8.5f) + timeYOffset;
setDrawableBounds(clockDrawable, timeX + (currentMessageObject.scheduled ? 0 : AndroidUtilities.dp(11)), timeY - clockDrawable.getIntrinsicHeight());
setDrawableBounds(clockDrawable, timeX + (currentMessageObject.scheduled ? 0 : AndroidUtilities.dp(11)), timeY - clockDrawable.getIntrinsicHeight());
clockDrawable.setAlpha((int) (255 * alpha));
if (useScale) {
canvas.save();
@ -13170,7 +13227,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
canvas.translate(AndroidUtilities.dp(4) * (1f - progress), 0);
}
drawable = getThemedDrawable(drawSelectionBackground ? Theme.key_drawable_msgOutCheckReadSelected : Theme.key_drawable_msgOutCheckRead);
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(22.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight() + timeYOffset);
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(22.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight() + timeYOffset);
} else {
drawable = getThemedDrawable(drawSelectionBackground ? Theme.key_drawable_msgOutCheckSelected : Theme.key_drawable_msgOutCheck);
setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(18.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight() + timeYOffset);
@ -13343,7 +13400,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
imageW = 0;
}
if (drawLoadingProgress && loadingProgressLayout != null){
if (drawLoadingProgress && loadingProgressLayout != null) {
imageW = 0;
infoW = (int) loadingProgressLayout.getLineWidth(0);
} else {
@ -13471,7 +13528,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
StaticLayout docTitleLayout = this.docTitleLayout;
StaticLayout infoLayout = this.infoLayout;
float alpha = 1f;
if (transitionParams.animateLocationIsExpired){
if (transitionParams.animateLocationIsExpired) {
progress = transitionParams.lastDrawLocationExpireProgress;
text = transitionParams.lastDrawLocationExpireText;
docTitleLayout = transitionParams.lastDrawDocTitleLayout;
@ -14945,7 +15002,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) {
sendAccessibilityEventForVirtualView(virtualViewId, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
} else if (action == AccessibilityNodeInfo.ACTION_CLICK) {
if (virtualViewId >= LINK_CAPTION_IDS_START) {
if (virtualViewId >= LINK_CAPTION_IDS_START) {
ClickableSpan link = getLinkById(virtualViewId, true);
if (link != null) {
delegate.didPressUrl(ChatMessageCell.this, link, false);
@ -14998,16 +15055,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
delegate.didPressReplyMessage(ChatMessageCell.this, currentMessageObject.getReplyMsgId());
}
} else if (virtualViewId == FORWARD) {
if (delegate != null) {
if (currentForwardChannel != null) {
delegate.didPressChannelAvatar(ChatMessageCell.this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY);
} else if (currentForwardUser != null) {
delegate.didPressUserAvatar(ChatMessageCell.this, currentForwardUser, lastTouchX, lastTouchY);
} else if (currentForwardName != null) {
delegate.didPressHiddenForward(ChatMessageCell.this);
}
}
} else if (virtualViewId == COMMENT) {
if (delegate != null) {
if (currentForwardChannel != null) {
delegate.didPressChannelAvatar(ChatMessageCell.this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY);
} else if (currentForwardUser != null) {
delegate.didPressUserAvatar(ChatMessageCell.this, currentForwardUser, lastTouchX, lastTouchY);
} else if (currentForwardName != null) {
delegate.didPressHiddenForward(ChatMessageCell.this);
}
}
} else if (virtualViewId == COMMENT) {
if (delegate != null) {
if (isRepliesChat) {
delegate.didPressSideButton(ChatMessageCell.this);
@ -15211,6 +15268,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private StaticLayout animateTimeLayout;
private int animateTimeWidth;
private int lastTimeWidth;
private int animateEditedWidthDiff;
private boolean lastDrawingEdited;
boolean animateReplaceCaptionLayout;
@ -15264,6 +15322,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
float lastForwardNameX;
int animateForwardNameWidth;
int lastForwardNameWidth;
boolean animateBotButtonsChanged;
public void recordDrawingState() {
wasDraw = true;
@ -15283,10 +15342,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
lastDrawingCaptionY = captionY;
lastDrawingCaptionLayout = captionLayout;
if (!botButtons.isEmpty()) {
lastDrawBotButtons.clear();
lastDrawBotButtons.addAll(botButtons);
}
lastDrawBotButtons.clear();
lastDrawBotButtons.addAll(botButtons);
if (commentLayout != null) {
lastCommentsCount = getRepliesCount();
@ -15384,13 +15441,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
spannableStringBuilder.append(text.substring(editedStr.length()));
spannableStringBuilder.setSpan(new EmptyStubSpan(), 0, editedStr.length(), 0);
animateTimeLayout = new StaticLayout(spannableStringBuilder, Theme.chat_timePaint, timeTextWidth + AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
animateEditedWidthDiff = timeWidth - lastTimeWidth;
} else {
animateEditedWidthDiff = 0;
animateEditedLayout = null;
animateTimeLayout = lastTimeLayout;
}
animateEditedEnter = true;
animateTimeWidth = lastTimeWidth;
animateFromTimeX = lastTimeX;
shouldAnimateTimeX = true;
changed = true;
}
}
@ -15421,7 +15481,22 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
if (!lastDrawBotButtons.isEmpty() || !botButtons.isEmpty()) {
transitionBotButtons.addAll(lastDrawBotButtons);
if (lastDrawBotButtons.size() != botButtons.size()) {
animateBotButtonsChanged = true;
}
if (!animateBotButtonsChanged) {
for (int i = 0; i < botButtons.size(); i++) {
BotButton button1 = botButtons.get(i);
BotButton button2 = lastDrawBotButtons.get(i);
if (button1.x != button2.x || button1.width != button2.width) {
animateBotButtonsChanged = true;
break;
}
}
}
if (animateBotButtonsChanged) {
transitionBotButtons.addAll(lastDrawBotButtons);
}
}
if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {

View File

@ -68,12 +68,12 @@ import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.StaticLayoutEx;
import org.telegram.ui.Components.StatusDrawable;
import org.telegram.ui.Components.SwipeGestureSettingsView;
import org.telegram.ui.Components.TextStyleSpan;
import org.telegram.ui.Components.TypefaceSpan;
import org.telegram.ui.Components.URLSpanNoUnderline;
import org.telegram.ui.Components.URLSpanNoUnderlineBold;
import org.telegram.ui.Components.spoilers.SpoilerEffect;
import org.telegram.ui.DialogsActivity;
import org.telegram.ui.Components.SwipeGestureSettingsView;
import java.util.ArrayList;
import java.util.List;
@ -955,7 +955,7 @@ public class DialogCell extends BaseCell {
mess = mess.substring(0, 150);
}
Spannable messSpan = new SpannableStringBuilder(mess);
MediaDataController.addTextStyleRuns(draftMessage, messSpan);
MediaDataController.addTextStyleRuns(draftMessage, messSpan, TextStyleSpan.FLAG_STYLE_SPOILER);
SpannableStringBuilder stringBuilder = AndroidUtilities.formatSpannable(messageFormat, AndroidUtilities.replaceNewLines(messSpan), messageNameString);
if (!useForceThreeLines && !SharedConfig.useThreeLinesLayout) {
@ -1089,7 +1089,7 @@ public class DialogCell extends BaseCell {
emoji = "\uD83D\uDCCE ";
}
SpannableStringBuilder msgBuilder = new SpannableStringBuilder(mess);
MediaDataController.addTextStyleRuns(message.messageOwner.entities, message.caption, msgBuilder);
MediaDataController.addTextStyleRuns(message.messageOwner.entities, message.caption, msgBuilder, TextStyleSpan.FLAG_STYLE_SPOILER);
stringBuilder = AndroidUtilities.formatSpannable(messageFormat, new SpannableStringBuilder(emoji).append(AndroidUtilities.replaceNewLines(msgBuilder)), messageNameString);
} else if (message.messageOwner.media != null && !message.isMediaEmpty()) {
currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex];
@ -1148,7 +1148,7 @@ public class DialogCell extends BaseCell {
mess = AndroidUtilities.replaceNewLines(mess);
}
mess = new SpannableStringBuilder(mess);
MediaDataController.addTextStyleRuns(message, (Spannable) mess);
MediaDataController.addTextStyleRuns(message, (Spannable) mess, TextStyleSpan.FLAG_STYLE_SPOILER);
stringBuilder = AndroidUtilities.formatSpannable(messageFormat, mess, messageNameString);
} else {
stringBuilder = SpannableStringBuilder.valueOf("");
@ -1218,7 +1218,7 @@ public class DialogCell extends BaseCell {
messageString = emoji + str;
} else {
SpannableStringBuilder msgBuilder = new SpannableStringBuilder(message.caption);
MediaDataController.addTextStyleRuns(message.messageOwner.entities, message.caption, msgBuilder);
MediaDataController.addTextStyleRuns(message.messageOwner.entities, message.caption, msgBuilder, TextStyleSpan.FLAG_STYLE_SPOILER);
messageString = new SpannableStringBuilder(emoji).append(msgBuilder);
}
} else {
@ -1241,7 +1241,7 @@ public class DialogCell extends BaseCell {
messageString = AndroidUtilities.ellipsizeCenterEnd(messageString, message.highlightedWords.get(0), w, currentMessagePaint, 130).toString();
} else {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(msgText);
MediaDataController.addTextStyleRuns(message, stringBuilder);
MediaDataController.addTextStyleRuns(message, stringBuilder, TextStyleSpan.FLAG_STYLE_SPOILER);
messageString = stringBuilder;
}
AndroidUtilities.highlightText(messageString, message.highlightedWords, resourcesProvider);
@ -2497,11 +2497,6 @@ public class DialogCell extends BaseCell {
swipeMessageTextLayout.draw(canvas);
canvas.restore();
}
// if (width / 2 < AndroidUtilities.dp(40)) {
// canvas.drawText(swipeMessage, getMeasuredWidth() - AndroidUtilities.dp(43) - width / 2, AndroidUtilities.dp(useForceThreeLines || SharedConfig.useThreeLinesLayout ? 62 : 59), Theme.dialogs_archiveTextPaint);
// }
canvas.restore();
} else if (translationDrawable != null) {
translationDrawable.stop();

View File

@ -61,6 +61,7 @@ import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.util.Property;
import android.util.SparseArray;
import android.util.SparseIntArray;
@ -92,8 +93,6 @@ import androidx.collection.LongSparseArray;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.graphics.ColorUtils;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
import androidx.recyclerview.widget.ChatListItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.GridLayoutManagerFixed;
@ -670,6 +669,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private Paint scrimPaint;
private View scrimView;
private String scrimViewReaction;
private int popupAnimationIndex = -1;
private AnimatorSet scrimAnimatorSet;
private ActionBarPopupWindow scrimPopupWindow;
@ -859,6 +859,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private PinchToZoomHelper pinchToZoomHelper;
private EmojiAnimationsOverlay emojiAnimationsOverlay;
public float drawingChatLisViewYoffset;
public void deleteHistory(int dateSelectedStart, int dateSelectedEnd, boolean forAll) {
chatAdapter.frozenMessages.clear();
@ -3121,7 +3122,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
if (scrimView != null) {
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), scrimPaint);
if (scrimViewReaction == null) {
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), scrimPaint);
}
float listTop = chatListView.getY() + chatListViewPaddingTop - chatListViewPaddingVisibleOffset - AndroidUtilities.dp(4);
MessageObject.GroupedMessages scrimGroup;
if (scrimView instanceof ChatMessageCell) {
@ -3129,9 +3132,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
scrimGroup = null;
}
boolean groupedBackgroundWasDraw = false;
int count = chatListView.getChildCount();
for (int num = 0; num < count; num++) {
View child = chatListView.getChildAt(num);
@ -3193,10 +3194,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
invalidate();
}
float viewClipLeft = Math.max(chatListView.getLeft(), chatListView.getLeft() + child.getX());
float viewClipTop = Math.max(listTop, chatListView.getTop() + child.getY());
float viewClipRight = Math.min(chatListView.getRight(), chatListView.getLeft() + child.getX() + child.getMeasuredWidth());
float viewClipBottom = Math.min(chatListView.getY() + chatListView.getMeasuredHeight(), chatListView.getY() + child.getY() + child.getMeasuredHeight());
float viewClipLeft = chatListView.getLeft();
float viewClipTop = listTop;
float viewClipRight = chatListView.getRight();
float viewClipBottom = chatListView.getY() + chatListView.getMeasuredHeight();
if (cell == null || !cell.getTransitionParams().animateBackgroundBoundsInner) {
viewClipLeft = Math.max(viewClipLeft, chatListView.getLeft() + child.getX());
viewClipTop = Math.max(viewClipTop, chatListView.getTop() + child.getY());
viewClipRight = Math.min(viewClipRight, chatListView.getLeft() + child.getX() + child.getMeasuredWidth());
viewClipBottom = Math.min(viewClipBottom, chatListView.getY() + child.getY() + child.getMeasuredHeight());
}
if (viewClipTop < viewClipBottom) {
if (child.getAlpha() != 1f) {
@ -3206,6 +3214,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (cell != null) {
cell.setInvalidatesParent(true);
cell.setScrimReaction(scrimViewReaction);
}
canvas.clipRect(viewClipLeft, viewClipTop, viewClipRight, viewClipBottom);
canvas.translate(chatListView.getLeft() + child.getX(), chatListView.getY() + child.getY());
@ -3217,6 +3226,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (cell != null) {
cell.setInvalidatesParent(false);
cell.setScrimReaction(null);
}
}
@ -3233,6 +3243,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
drawCaptionAfter.add(cell);
}
}
if (scrimViewReaction != null && cell != null) {
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), scrimPaint);
if (viewClipTop < viewClipBottom) {
if (child.getAlpha() != 1f) {
canvas.saveLayerAlpha(viewClipLeft, viewClipTop, viewClipRight, viewClipBottom, (int) (255 * child.getAlpha()), Canvas.ALL_SAVE_FLAG);
} else {
canvas.save();
}
canvas.clipRect(viewClipLeft, viewClipTop, viewClipRight, viewClipBottom);
canvas.translate(chatListView.getLeft() + child.getX(), chatListView.getY() + child.getY());
cell.drawScrimReaction(canvas, scrimViewReaction);
canvas.restore();
}
}
}
int size = drawTimeAfter.size();
@ -4301,7 +4326,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (pullingDownAnimateProgress != 0) {
transitionOffset = (chatListView.getMeasuredHeight() - pullingDownOffset) * pullingDownAnimateProgress;
}
canvas.translate(0, -pullingDownOffset - transitionOffset);
canvas.translate(0, drawingChatLisViewYoffset = -pullingDownOffset - transitionOffset);
drawChatBackgroundElements(canvas);
super.dispatchDraw(canvas);
canvas.restore();
@ -4611,11 +4636,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
b - AndroidUtilities.dp(4)
);
}
result = super.drawChild(canvas, child, drawingTime);
if (cell != null && clipToGroupBounds) {
cell.clipToGroupBounds = true;
result = super.drawChild(canvas, child, drawingTime);
cell.clipToGroupBounds = false;
} else {
result = super.drawChild(canvas, child, drawingTime);
}
if (clipToGroupBounds) {
canvas.restore();
}
if (cell != null && cell.getTransitionParams().animateBackgroundBoundsInner) {
if (cell != null && clipToGroupBounds) {
canvas.save();
canvas.translate(cell.getX(), cell.getY());
cell.drawOutboundsContent(canvas);
@ -5055,6 +5086,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Runnable finishRunnable;
@Override
public void checkIsRunning() {
if (scrollAnimationIndex == -1) {
scrollAnimationIndex = getNotificationCenter().setAnimationInProgress(scrollAnimationIndex, allowedNotificationsDuringChatListAnimations, false);
}
}
@Override
public void onAnimationStart() {
if (scrollAnimationIndex == -1) {
@ -5297,6 +5335,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
pullingDownOffset += dy * k;
ReactionsEffectOverlay.onScrolled((int) (dy * k));
chatListView.invalidate();
}
if (pullingDownOffset == 0) {
@ -8126,7 +8165,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
topBottom[1] = chatListView.getBottom();
topBottom[0] = chatListView.getTop() + chatListViewPaddingTop - AndroidUtilities.dp(4);
});
emojiAnimationsOverlay = new EmojiAnimationsOverlay(ChatActivity.this, contentView, chatListView, currentAccount, dialog_id, threadMessageId);
return fragmentView;
}
@ -11219,12 +11257,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatListView != null && !messages.isEmpty() && !pinchToZoomHelper.isInOverlayMode()) {
int position = 0;
if (skipSponsored) {
while (position < messages.size()) {
if (!messages.get(position).isSponsored()) {
break;
}
position++;
}
position += getSponsoredMessagesCount();
}
chatLayoutManager.scrollToPositionWithOffset(position, 0);
chatListView.stopScroll();
@ -11518,14 +11551,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int maxUnreadDate = Integer.MIN_VALUE;
int recyclerChatViewHeight = (contentView.getHeightWithKeyboard() - (inPreviewMode ? 0 : AndroidUtilities.dp(48)) - chatListView.getTop());
pollsToCheck.clear();
reactionsToCheck.clear();
float cilpTop = chatListViewPaddingTop;
float clipTop = chatListViewPaddingTop;
long currentTime = System.currentTimeMillis();
int maxAdapterPosition = -1;
int minAdapterPosition = -1;
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
MessageObject messageObject = null;
int adapterPosition = chatListView.getChildAdapterPosition(view);
if (adapterPosition >= 0) {
if (adapterPosition > maxAdapterPosition || maxAdapterPosition == -1) {
maxAdapterPosition = adapterPosition;
}
if (adapterPosition < minAdapterPosition || minAdapterPosition == -1) {
minAdapterPosition = adapterPosition;
}
}
int top = (int) view.getY();
int bottom = top + view.getMeasuredHeight();
if (bottom <= cilpTop - chatListViewPaddingVisibleOffset || top > chatListView.getMeasuredHeight()) {
if (bottom <= clipTop - chatListViewPaddingVisibleOffset || top > chatListView.getMeasuredHeight()) {
continue;
}
@ -11602,11 +11646,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messageObject.type == MessageObject.TYPE_POLL && messageObject.getId() > 0) {
pollsToCheck.add(messageObject);
}
if (messageObject.getId() > 0 && messageObject.messageOwner.action == null) {
reactionsToCheck.add(messageObject);
}
}
if (bottom <= cilpTop) {
if (bottom <= clipTop) {
if (view instanceof ChatActionCell && messageObject.isDateObject) {
view.setAlpha(0);
}
@ -11668,7 +11709,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
getMessagesController().addToPollsQueue(dialog_id, pollsToCheck);
getMessagesController().addToReactionsQueue(dialog_id, reactionsToCheck);
if (maxAdapterPosition >= 0 && minAdapterPosition >= 0) {
int from = minAdapterPosition - chatAdapter.messagesStartRow - 10;
int to = maxAdapterPosition - chatAdapter.messagesStartRow + 10;
if (from < 0) {
from = 0;
}
if (to > messages.size()) {
to = messages.size();
}
reactionsToCheck.clear();
for (int i = from; i < to; i++) {
MessageObject messageObject = messages.get(i);
if (threadMessageObject != messageObject && messageObject.getId() > 0 && messageObject.messageOwner.action == null && (currentTime - messageObject.reactionsLastCheckTime) > 15000L) {
messageObject.reactionsLastCheckTime = currentTime;
reactionsToCheck.add(messageObject);
}
}
getMessagesController().loadReactionsForMessages(dialog_id, reactionsToCheck);
}
if (videoPlayerContainer != null) {
if (!foundTextureViewMessage) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
@ -11700,7 +11759,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
currentFloatingTopIsNotMessage = !(minChild instanceof ChatMessageCell || minChild instanceof ChatActionCell);
if (minDateChild != null) {
boolean showFloatingView = false;
if (minDateChild.getY() > cilpTop || currentFloatingTopIsNotMessage) {
if (minDateChild.getY() > clipTop || currentFloatingTopIsNotMessage) {
if (minDateChild.getAlpha() != 1.0f) {
minDateChild.setAlpha(1.0f);
}
@ -11724,7 +11783,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
showFloatingView = true;
}
float offset = minDateChild.getY() + minDateChild.getMeasuredHeight() - cilpTop;
float offset = minDateChild.getY() + minDateChild.getMeasuredHeight() - clipTop;
if (offset > floatingDateView.getMeasuredHeight() && offset < floatingDateView.getMeasuredHeight() * 2) {
if (chatListView.getChildAdapterPosition(minDateChild) == chatAdapter.messagesStartRow + messages.size() - 1) {
showFloatingView = false;
@ -15424,7 +15483,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MessageObject messageObject = messagesDict[did == dialog_id ? 0 : 1].get(msgId);
if (messageObject != null) {
MessageObject.updateReactions(messageObject.messageOwner, (TLRPC.TL_messageReactions) args[2]);
chatAdapter.notifyDataSetChanged(true);
messageObject.forceUpdate = true;
messageObject.reactionsChanged = true;
updateMessageAnimated(messageObject, true);
}
}
} else if (id == NotificationCenter.didVerifyMessagesStickers) {
@ -16194,7 +16255,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean sponsoredMessagesAdded;
private void addSponsoredMessages(boolean animated) {
if (sponsoredMessagesAdded || chatMode != 0 || !ChatObject.isChannel(currentChat) || currentChat.megagroup || currentChat.gigagroup || !forwardEndReached[0]) {
if (sponsoredMessagesAdded || chatMode != 0 || !ChatObject.isChannel(currentChat) || !forwardEndReached[0]) {
return;
}
ArrayList<MessageObject> arrayList = getMessagesController().getSponsoredMessages(dialog_id);
@ -16925,6 +16986,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (placeToPaste > messages.size()) {
placeToPaste = messages.size();
}
int sponsoredMessagesCount = getSponsoredMessagesCount();
if (!isAd && placeToPaste < sponsoredMessagesCount) {
placeToPaste = sponsoredMessagesCount;
}
if (dayArray == null) {
dayArray = new ArrayList<>();
messagesByDays.put(obj.dateKey, dayArray);
@ -17072,7 +17138,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
scrollToTopOnResume = true;
} else {
forceScrollToTop = true;
moveScrollToLastMessage(false);
moveScrollToLastMessage(true);
}
}
} else {
@ -17085,6 +17151,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
canShowPagedownButton = true;
updatePagedownButtonVisibility(true);
}
} else {
if (child != null) {
chatLayoutManager.scrollToPositionWithOffset(lastVisible + 1, chatListView.getMeasuredHeight() - child.getBottom() - chatListView.getPaddingBottom());
}
}
if (newMentionsCount != 0 && mentiondownButtonCounter != null) {
mentiondownButtonCounter.setVisibility(View.VISIBLE);
@ -17129,6 +17199,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateReplyMessageHeader(true);
}
private int getSponsoredMessagesCount() {
int sponsoredMessagesCount = 0;
while (sponsoredMessagesCount < messages.size()) {
if (!messages.get(sponsoredMessagesCount).isSponsored()) {
break;
}
sponsoredMessagesCount++;
}
return sponsoredMessagesCount;
}
private void processDeletedMessages(ArrayList<Integer> markAsDeletedMessages, long channelId) {
ArrayList<Integer> removedIndexes = new ArrayList<>();
int loadIndex = 0;
@ -19768,6 +19849,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (scrimPopupWindow != null) {
scrimPopupWindow.dismiss();
scrimView = null;
scrimViewReaction = null;
}
if (!AndroidUtilities.isTablet()) {
@ -20103,7 +20185,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(OPTION_EDIT);
icons.add(R.drawable.msg_edit);
}
if (!selectedObject.isOutOwner() && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
if (selectedObject != null && selectedObject.contentType == 0 && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
items.add(LocaleController.getString("TranslateMessage", R.string.TranslateMessage));
options.add(29);
icons.add(R.drawable.msg_translate);
@ -20367,7 +20449,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(102);
icons.add(R.drawable.msg_schedule);
}
if (!selectedObject.isOutOwner() && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
if (selectedObject != null && selectedObject.contentType == 0 && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
items.add(LocaleController.getString("TranslateMessage", R.string.TranslateMessage));
options.add(29);
icons.add(R.drawable.msg_translate);
@ -20488,11 +20570,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
final AtomicBoolean waitForLangDetection = new AtomicBoolean(false);
final AtomicReference<Runnable> onLangDetectionDone = new AtomicReference(null);
Rect rect = new Rect();
List<TLRPC.TL_availableReaction> availableReacts = getMediaDataController().getEnabledReactionsList();
boolean isReactionsViewAvailable = !isSecretChat() && !isInScheduleMode() && currentUser == null && message.hasReactions() && (!ChatObject.isChannel(currentChat) || currentChat.megagroup) && !availableReacts.isEmpty() && message.messageOwner.reactions.can_see_list;
boolean isReactionsAvailable = !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !chatInfo.available_reactions.isEmpty() || (chatInfo == null && !ChatObject.isChannel(currentChat)) || currentUser != null) && !availableReacts.isEmpty();
boolean isReactionsAvailable;
boolean needLoadReactionsChat = false;
if (message.isForwardedChannelPost()) {
TLRPC.ChatFull chatInfo = getMessagesController().getChatFull(-message.getFromChatId());
if (chatInfo == null) {
isReactionsAvailable = true;
needLoadReactionsChat = true;
} else {
isReactionsAvailable = !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !chatInfo.available_reactions.isEmpty()) && !availableReacts.isEmpty();
}
} else {
isReactionsAvailable = !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !chatInfo.available_reactions.isEmpty() || (chatInfo == null && !ChatObject.isChannel(currentChat)) || currentUser != null) && !availableReacts.isEmpty();
}
boolean showMessageSeen = !isReactionsViewAvailable && !isInScheduleMode() && currentChat != null && message.isOutOwner() && message.isSent() && !message.isEditing() && !message.isSending() && !message.isSendError() && !message.isContentUnread() && !message.isUnread() && (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - message.messageOwner.date < getMessagesController().chatReadMarkExpirePeriod) && (ChatObject.isMegagroup(currentChat) || !ChatObject.isChannel(currentChat)) && chatInfo != null && chatInfo.participants_count < getMessagesController().chatReadMarkSizeThreshold && !(message.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByRequest) && (v instanceof ChatMessageCell);
int flags = 0;
@ -20500,9 +20597,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
flags |= ActionBarPopupWindow.ActionBarPopupWindowLayout.FLAG_USE_SWIPEBACK;
}
final AtomicBoolean waitForLangDetection = new AtomicBoolean(false);
final AtomicReference<Runnable> onLangDetectionDone = new AtomicReference(null);
ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity(), R.drawable.popup_fixed_alert, themeDelegate, flags);
popupLayout.setMinimumWidth(AndroidUtilities.dp(200));
Rect backgroundPaddings = new Rect();
@ -20866,6 +20960,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
processSelectedOption(options.get(i));
scrimView = null;
scrimViewReaction = null;
contentView.invalidate();
chatListView.invalidate();
if (scrimPopupWindow != null) {
@ -20876,6 +20971,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
// "Translate" button
String toLang = LocaleController.getInstance().getCurrentLocale().getLanguage();
final CharSequence finalMessageText = messageText;
TranslateAlert.OnLinkPress onLinkPress = (link) -> {
didPressMessageUrl(link, false, selectedObject, v instanceof ChatMessageCell ? (ChatMessageCell) v : null);
};
if (LanguageDetector.hasSupport()) {
final String[] fromLang = { null };
cell.setVisibility(View.GONE);
@ -20895,7 +20993,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
},
(Exception e) -> {
FileLog.e(e);
Log.e("mlkit", "failed to detect language in message");
e.printStackTrace();
waitForLangDetection.set(false);
if (onLangDetectionDone.get() != null) {
onLangDetectionDone.get().run();
@ -20907,9 +21006,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
return;
}
boolean noForwards = currentChat != null && currentChat.noforwards;
TranslateAlert.showAlert(getParentActivity(), this, fromLang[0], toLang, finalMessageText, noForwards);
TranslateAlert.showAlert(getParentActivity(), this, fromLang[0], toLang, finalMessageText, currentChat != null && currentChat.noforwards, onLinkPress);
scrimView = null;
scrimViewReaction = null;
contentView.invalidate();
chatListView.invalidate();
if (scrimPopupWindow != null) {
@ -20927,9 +21026,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
return;
}
boolean noForwards = currentChat != null && currentChat.noforwards;
TranslateAlert.showAlert(getParentActivity(), this, "und", toLang, finalMessageText, noForwards);
TranslateAlert.showAlert(getParentActivity(), this, "und", toLang, finalMessageText, currentChat != null && currentChat.noforwards, onLinkPress);
scrimView = null;
scrimViewReaction = null;
contentView.invalidate();
chatListView.invalidate();
if (scrimPopupWindow != null) {
@ -20948,6 +21047,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
return super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
boolean b = super.dispatchTouchEvent(ev);
if (ev.getAction() == MotionEvent.ACTION_DOWN && !b && scrimPopupWindow != null) {
scrimPopupWindow.dismiss();
}
return b;
}
};
scrimPopupContainerLayout.setOnTouchListener(new View.OnTouchListener() {
@ -20973,48 +21081,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
ReactionsContainerLayout reactionsLayout = new ReactionsContainerLayout(contentView.getContext(), getResourceProvider());
ReactionsContainerLayout reactionsLayout = new ReactionsContainerLayout(contentView.getContext(), currentAccount, getResourceProvider());
if (isReactionsAvailable) {
int pad = 22;
int sPad = 24;
reactionsLayout.setPadding(AndroidUtilities.dp(4) + (LocaleController.isRTL ? 0 : sPad), AndroidUtilities.dp(4), AndroidUtilities.dp(4) + (LocaleController.isRTL ? sPad : 0), AndroidUtilities.dp(pad));
List<TLRPC.TL_availableReaction> l;
if (chatInfo != null) {
l = new ArrayList<>(chatInfo.available_reactions.size());
for (String s : chatInfo.available_reactions) {
for (TLRPC.TL_availableReaction a : getMediaDataController().getEnabledReactionsList()) {
if (a.reaction.equals(s)) {
l.add(a);
break;
}
}
}
} else {
l = getMediaDataController().getEnabledReactionsList();
}
reactionsLayout.setReactionsList(l);
reactionsLayout.setDelegate((rView, reaction) -> {
selectReaction(primaryMessage, reactionsLayout, 0, 0, reaction, false);
});
LinearLayout.LayoutParams params = LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 52 + pad, Gravity.RIGHT, 0, 0, 0, -20);
int size = params.height - reactionsLayout.getPaddingTop() - reactionsLayout.getPaddingBottom();
if (size * l.size() < AndroidUtilities.dp(200))
params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
scrimPopupContainerLayout.addView(reactionsLayout, params);
scrimPopupContainerLayout.reactionsLayout = reactionsLayout;
reactionsLayout.setMessage(message, chatInfo);
reactionsLayout.setTransitionProgress(0);
if (popupLayout.getSwipeBack() != null) {
popupLayout.getSwipeBack().setOnSwipeBackProgressListener((layout, toProgress, progress) -> {
if (toProgress == 0) {
reactionsLayout.setTransitionProgress(0);
reactionsLayout.setAlpha(1f);
new SpringAnimation(reactionsLayout, ReactionsContainerLayout.TRANSITION_PROGRESS_VALUE)
.setSpring(new SpringForce().setFinalPosition(100)
.setStiffness(240)
.setDampingRatio(0.7f))
.start();
reactionsLayout.startEnterAnimation();
} else if (toProgress == 1)
reactionsLayout.setAlpha(1f - progress);
});
@ -21022,7 +21108,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
boolean showNoForwards = getMessagesController().isChatNoForwards(currentChat) && message.messageOwner.action == null && message.isSent() && !message.isEditing() && chatMode != MODE_SCHEDULED;
scrimPopupContainerLayout.addView(popupLayout, LayoutHelper.createLinearRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, isReactionsAvailable ? 16 : 0, 0, isReactionsAvailable ? 36 : 0, 0));
scrimPopupContainerLayout.addView(popupLayout, LayoutHelper.createLinearRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT, isReactionsAvailable ? 16 : 0, 0, isReactionsAvailable ? 36 : 0, 0));
scrimPopupContainerLayout.popupWindowLayout = popupLayout;
if (showNoForwards) {
popupLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
@ -21040,7 +21126,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
FrameLayout fl = new FrameLayout(contentView.getContext());
fl.setBackground(shadowDrawable2);
fl.addView(tv, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 11, 11, 11, 11));
scrimPopupContainerLayout.addView(fl, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
scrimPopupContainerLayout.addView(fl, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT, isReactionsAvailable ? 16 : 0, -8, isReactionsAvailable ? 36 : 0, 0));
}
scrimPopupWindow = new ActionBarPopupWindow(scrimPopupContainerLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
@ -21077,6 +21163,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void onAnimationEnd(Animator animation) {
scrimView = null;
scrimViewReaction = null;
contentView.invalidate();
chatListView.invalidate();
}
@ -21114,7 +21201,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
popupX += location[0];
}
int totalHeight = contentView.getHeight();
int height = scrimPopupContainerLayout.getMeasuredHeight();
int height = scrimPopupContainerLayout.getMeasuredHeight() + AndroidUtilities.dp(48);
int keyboardHeight = contentView.measureKeyboardHeight();
if (keyboardHeight > AndroidUtilities.dp(20)) {
totalHeight += keyboardHeight;
@ -21133,23 +21220,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
popupY = inBubbleMode ? 0 : AndroidUtilities.statusBarHeight;
}
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, scrimPopupX = popupX, scrimPopupY = popupY);
if (isReactionsAvailable) {
reactionsLayout.setTransitionProgress(0);
new SpringAnimation(reactionsLayout, ReactionsContainerLayout.TRANSITION_PROGRESS_VALUE)
.setSpring(new SpringForce().setFinalPosition(100)
.setStiffness(240)
.setDampingRatio(0.7f))
.start();
}
final int finalPopupX = scrimPopupX = popupX;
final int finalPopupY = scrimPopupY = popupY;
Runnable showMenu = () -> scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, finalPopupX, finalPopupY);
Runnable showMenu = () -> {
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, finalPopupX, finalPopupY);
if (isReactionsAvailable) {
reactionsLayout.startEnterAnimation();
}
};
if (waitForLangDetection.get()) {
onLangDetectionDone.set(showMenu);
} else {
} else
showMenu.run();
}
chatListView.stopScroll();
chatLayoutManager.setCanScrollVertically(false);
scrimView = v;
@ -21284,7 +21366,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}, 50);
});
} else {
updateMessageAnimated(primaryMessage);
updateMessageAnimated(primaryMessage, true);
ReactionsEffectOverlay.startAnimation();
}
@ -21297,7 +21379,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
//updateReactionRunnable.run();
if (fromDoubleTap) {
updateMessageAnimated(primaryMessage);
updateMessageAnimated(primaryMessage, true);
updateReactionRunnable.run();
}
AndroidUtilities.runOnUIThread(updateReactionRunnable, 50);
@ -21306,7 +21388,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@SuppressLint("NotifyDataSetChanged")
private void updateMessageAnimated(MessageObject message) {
private void updateMessageAnimated(MessageObject message, boolean updateReactions) {
if (chatAdapter == null) {
return;
}
@ -21318,6 +21400,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
for (int i = 0; i < group.messages.size(); i++) {
group.messages.get(i).forceUpdate = true;
if (updateReactions) {
group.messages.get(i).reactionsChanged = true;
}
}
chatAdapter.notifyDataSetChanged(true);
} else {
@ -22689,6 +22774,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (originalMessage != null && originalMessage.messageOwner.replies != null && chatActivity.threadMessageObject.messageOwner.replies != null) {
originalMessage.messageOwner.replies.replies = chatActivity.threadMessageObject.messageOwner.replies.replies;
}
if (originalMessage != null && originalMessage.messageOwner.reactions != null) {
chatActivity.threadMessageObject.messageOwner.reactions = originalMessage.messageOwner.reactions;
}
presentFragment(chatActivity);
if (isKeyboardVisible() && !chatActivity.hideKeyboardOnShow()) {
chatActivity.chatActivityEnterView.getEditField().requestFocus();
@ -23870,7 +23958,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (h == 0) {
h = AndroidUtilities.dp(ReactedUsersListView.VISIBLE_ITEMS * ReactedUsersListView.ITEM_HEIGHT_DP);
}
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(h, MeasureSpec.AT_MOST));
}
};
@ -23882,12 +23969,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
shadowDrawable2.getPadding(backgroundPaddings);
scrimPopupContainerLayout.setBackground(shadowDrawable2);
int totalHeight = contentView.getHeight();
int height = scrimPopupContainerLayout.getMeasuredHeight();
int keyboardHeight = contentView.measureKeyboardHeight();
if (keyboardHeight > AndroidUtilities.dp(20)) {
totalHeight += keyboardHeight;
}
ReactionsLayoutInBubble.ReactionButton button = cell.getReactionButton(reaction.reaction);
if (button == null) {
return;
@ -23896,7 +23978,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
float left = cell.reactionsLayoutInBubble.x + button.x;
int[] loc = new int[2];
cell.getLocationInWindow(loc);
int finalTotalHeight = totalHeight;
scrimPopupContainerLayout.addView(new ReactedUsersListView(getParentActivity(), themeDelegate, currentAccount, cell.getPrimaryMessageObject(), reaction, false)
.setOnProfileSelectedListener((view1, userId) -> {
Bundle args = new Bundle();
@ -23906,19 +23987,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (scrimPopupWindow != null) {
scrimPopupWindow.dismiss();
}
}).setOnHeightChangedListener((view1, newHeight) -> {
// float delta = Math.max(0, loc[1] + bottom - scrimPopupY + backgroundPaddings.top);
// int h = scrimPopupContainerLayout.getHeight();
// ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(240);
// anim.setInterpolator(CubicBezierInterpolator.DEFAULT);
// anim.addUpdateListener(animation -> {
// float val = (float) animation.getAnimatedValue();
// float f = Math.min(delta * val, finalTotalHeight - newHeight);
// scrimPopupContainerLayout.setTranslationY(f);
// scrimPopupWindow.setHeight((int) (h + f));
// });
// anim.start();
}), LayoutHelper.createFrame(200, LayoutHelper.WRAP_CONTENT));
}), LayoutHelper.createFrame(240, LayoutHelper.WRAP_CONTENT));
scrimPopupWindow = new ActionBarPopupWindow(scrimPopupContainerLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
@Override
@ -23954,6 +24023,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void onAnimationEnd(Animator animation) {
scrimView = null;
scrimViewReaction = null;
contentView.invalidate();
chatListView.invalidate();
}
@ -23975,6 +24045,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
int totalHeight = contentView.getHeight();
int height = scrimPopupContainerLayout.getMeasuredHeight();
int keyboardHeight = contentView.measureKeyboardHeight();
if (keyboardHeight > AndroidUtilities.dp(20)) {
totalHeight += keyboardHeight;
}
int popupX = (int) (left - AndroidUtilities.dp(28));
popupX = Math.max(AndroidUtilities.dp(6), Math.min(chatListView.getMeasuredWidth() - AndroidUtilities.dp(6) - scrimPopupContainerLayout.getMeasuredWidth(), popupX));
if (AndroidUtilities.isTablet()) {
@ -23984,14 +24061,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
int popupY;
if (height < totalHeight) {
popupY = (int) (chatListView.getY() + cell.getY() + cell.getHeight());
if (height - backgroundPaddings.top - backgroundPaddings.bottom > AndroidUtilities.dp(240)) {
popupY += AndroidUtilities.dp(240) - height;
}
if (popupY < chatListView.getY() + AndroidUtilities.dp(24)) {
popupY = (int) (chatListView.getY() + AndroidUtilities.dp(24));
} else if (popupY > totalHeight - height - AndroidUtilities.dp(8)) {
popupY = totalHeight - height - AndroidUtilities.dp(8);
if (height < totalHeight / 2f && chatListView.getY() + cell.getY() + cell.reactionsLayoutInBubble.y + button.y > totalHeight / 2f) {
popupY = (int) (chatListView.getY() + cell.getY() + cell.reactionsLayoutInBubble.y + button.y - height);
} else {
popupY = (int) (chatListView.getY() + cell.getY() + cell.reactionsLayoutInBubble.y + button.y + button.height);
}
} else {
popupY = inBubbleMode ? 0 : AndroidUtilities.statusBarHeight;
@ -24001,6 +24074,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatListView.stopScroll();
chatLayoutManager.setCanScrollVertically(false);
scrimView = cell;
scrimViewReaction = reaction.reaction;
cell.setInvalidatesParent(true);
restartSticker(cell);
contentView.invalidate();
@ -26534,6 +26608,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Theme.applyTheme(activeTheme, false, isDark);
} else {
if (ApplicationLoader.applicationContext != null) {
Theme.createChatResources(ApplicationLoader.applicationContext, false);
}
currentColors = chatTheme.createColors(currentAccount, isDark ? 1 : 0);
backgroundDrawable = getBackgroundDrawableFromTheme(chatTheme, prevPhase);

View File

@ -106,23 +106,7 @@ public class ChatReactionsEditActivity extends BaseFragment implements Notificat
enableReactionsCell.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
enableReactionsCell.setAnimatingToThumbInsteadOfTouch(true);
enableReactionsCell.setOnClickListener(v -> {
boolean c = !enableReactionsCell.isChecked();
enableReactionsCell.setChecked(c);
int clr = Theme.getColor(c ? Theme.key_windowBackgroundChecked : Theme.key_windowBackgroundUnchecked);
if (c) {
enableReactionsCell.setBackgroundColorAnimated(c, clr);
} else {
enableReactionsCell.setBackgroundColorAnimatedReverse(clr);
}
if (c) {
for (TLRPC.TL_availableReaction a : availableReactions) {
chatReactions.add(a.reaction);
}
listAdapter.notifyItemRangeInserted(1, 1 + availableReactions.size());
} else {
chatReactions.clear();
listAdapter.notifyItemRangeRemoved(1, 1 + availableReactions.size());
}
setCheckedEnableReactionCell(!enableReactionsCell.isChecked());
});
ll.addView(enableReactionsCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
@ -185,8 +169,14 @@ public class ChatReactionsEditActivity extends BaseFragment implements Notificat
AvailableReactionCell cell = (AvailableReactionCell) view;
TLRPC.TL_availableReaction react = availableReactions.get(position - 2);
boolean nc = !chatReactions.contains(react.reaction);
if (nc) chatReactions.add(react.reaction);
else chatReactions.remove(react.reaction);
if (nc) {
chatReactions.add(react.reaction);
} else {
chatReactions.remove(react.reaction);
if (chatReactions.isEmpty()) {
setCheckedEnableReactionCell(false);
}
}
cell.setChecked(nc, true);
});
@ -198,6 +188,28 @@ public class ChatReactionsEditActivity extends BaseFragment implements Notificat
return contentView;
}
private void setCheckedEnableReactionCell(boolean c) {
if (enableReactionsCell.isChecked() == c) {
return;
}
enableReactionsCell.setChecked(c);
int clr = Theme.getColor(c ? Theme.key_windowBackgroundChecked : Theme.key_windowBackgroundUnchecked);
if (c) {
enableReactionsCell.setBackgroundColorAnimated(c, clr);
} else {
enableReactionsCell.setBackgroundColorAnimatedReverse(clr);
}
if (c) {
for (TLRPC.TL_availableReaction a : availableReactions) {
chatReactions.add(a.reaction);
}
listAdapter.notifyItemRangeInserted(1, 1 + availableReactions.size());
} else {
chatReactions.clear();
listAdapter.notifyItemRangeRemoved(1, 1 + availableReactions.size());
}
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();

View File

@ -4,11 +4,12 @@ import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.ui.ActionBar.ActionBarPopupWindow;
public class ChatScrimPopupContainerLayout extends LinearLayout {
public View reactionsLayout;
public ReactionsContainerLayout reactionsLayout;
public ActionBarPopupWindow.ActionBarPopupWindowLayout popupWindowLayout;
public ChatScrimPopupContainerLayout(Context context) {
@ -18,9 +19,25 @@ public class ChatScrimPopupContainerLayout extends LinearLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (reactionsLayout != null && popupWindowLayout != null && popupWindowLayout.getSwipeBack() != null && reactionsLayout.getLayoutParams().width != LayoutHelper.WRAP_CONTENT) {
if (reactionsLayout != null && popupWindowLayout != null) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int widthDiff = popupWindowLayout.getSwipeBack().getMeasuredWidth() - popupWindowLayout.getSwipeBack().getChildAt(0).getMeasuredWidth();
int reactionsLayoutTotalWidth = reactionsLayout.getTotalWidth();
View menuContainer = popupWindowLayout.getSwipeBack() != null ? popupWindowLayout.getSwipeBack().getChildAt(0) : popupWindowLayout.getChildAt(0);
int maxReactionsLayoutWidth = menuContainer.getMeasuredWidth() + AndroidUtilities.dp(16) + AndroidUtilities.dp(16) + AndroidUtilities.dp(36);
if (reactionsLayoutTotalWidth > maxReactionsLayoutWidth) {
int maxFullCount = ((maxReactionsLayoutWidth - AndroidUtilities.dp(16)) / AndroidUtilities.dp(36)) + 1;
int newWidth = maxFullCount * AndroidUtilities.dp(36) + AndroidUtilities.dp(16) - AndroidUtilities.dp(8);
if (newWidth > reactionsLayoutTotalWidth || maxFullCount == reactionsLayout.getItemsCount()) {
newWidth = reactionsLayoutTotalWidth;
}
reactionsLayout.getLayoutParams().width = newWidth;
} else {
reactionsLayout.getLayoutParams().width = LayoutHelper.WRAP_CONTENT;
}
int widthDiff = 0;
if (popupWindowLayout.getSwipeBack() != null) {
widthDiff = popupWindowLayout.getSwipeBack().getMeasuredWidth() - popupWindowLayout.getSwipeBack().getChildAt(0).getMeasuredWidth();
}
((LayoutParams)reactionsLayout.getLayoutParams()).rightMargin = widthDiff;
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
} else {

View File

@ -132,7 +132,7 @@ public class ChatThemeBottomSheet extends BottomSheet implements NotificationCen
}
setupLightDarkTheme(!forceDark);
});
rootLayout.addView(darkThemeView, LayoutHelper.createFrame(44, 44, Gravity.TOP | Gravity.END, 0, 0, 7, 0));
rootLayout.addView(darkThemeView, LayoutHelper.createFrame(44, 44, Gravity.TOP | Gravity.END, 0, -2, 7, 0));
forceDark = !Theme.getActiveTheme().isDark();
setForceDark(Theme.getActiveTheme().isDark(), false);

View File

@ -72,6 +72,7 @@ public class CounterView extends View {
private final static int ANIMATION_TYPE_IN = 0;
private final static int ANIMATION_TYPE_OUT = 1;
private final static int ANIMATION_TYPE_REPLACE = 2;
public boolean shortFormat;
int animationType = -1;
@ -180,14 +181,14 @@ public class CounterView extends View {
}
return;
}
String newStr = String.valueOf(count);
String newStr = getStringOfCCount(count);
countWidth = Math.max(AndroidUtilities.dp(12), (int) Math.ceil(textPaint.measureText(newStr)));
countLayout = new StaticLayout(newStr, textPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
if (parent != null) {
parent.invalidate();
}
}
String newStr = String.valueOf(count);
String newStr = getStringOfCCount(count);
if (animated) {
if (countAnimator != null) {
@ -231,7 +232,7 @@ public class CounterView extends View {
countAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
}
if (countLayout != null) {
String oldStr = String.valueOf(currentCount);
String oldStr = getStringOfCCount(currentCount);
if (oldStr.length() == newStr.length()) {
SpannableStringBuilder oldSpannableStr = new SpannableStringBuilder(oldStr);
@ -269,6 +270,13 @@ public class CounterView extends View {
}
}
private String getStringOfCCount(int count) {
if (shortFormat) {
return AndroidUtilities.formatWholeNumber(count, 0);
}
return String.valueOf(count);
}
public void draw(Canvas canvas) {
if (type != TYPE_CHAT_PULLING_DOWN && type != TYPE_CHAT_REACTIONS) {
int textColor = getThemedColor(textColorKey);

View File

@ -505,10 +505,10 @@ public class FlickerLoadingView extends View {
} else if (getViewType() == REACTED_TYPE) {
int k = 0;
while (h <= getMeasuredHeight()) {
int r = AndroidUtilities.dp(16);
canvas.drawCircle(checkRtl(paddingLeft + AndroidUtilities.dp(13) + r), h + AndroidUtilities.dp(24), r, paint);
int r = AndroidUtilities.dp(18);
canvas.drawCircle(checkRtl(paddingLeft + AndroidUtilities.dp(8) + r), h + AndroidUtilities.dp(24), r, paint);
rectF.set(paddingLeft + AndroidUtilities.dp(53), h + AndroidUtilities.dp(20), getWidth() - AndroidUtilities.dp(53), h + AndroidUtilities.dp(28));
rectF.set(paddingLeft + AndroidUtilities.dp(58), h + AndroidUtilities.dp(20), getWidth() - AndroidUtilities.dp(53), h + AndroidUtilities.dp(28));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(8), AndroidUtilities.dp(8), paint);

View File

@ -98,6 +98,7 @@ public class MotionBackgroundDrawable extends Drawable {
private ColorFilter patternColorFilter;
private int roundRadius;
private float patternAlpha = 1f;
private float backgroundAlpha = 1f;
private int alpha = 255;
private ColorFilter legacyBitmapColorFilter;
@ -422,6 +423,10 @@ public class MotionBackgroundDrawable extends Drawable {
this.patternAlpha = alpha;
invalidateParent();
}
public void setBackgroundAlpha(float alpha) {
this.backgroundAlpha = alpha;
invalidateParent();
}
@Override
public void setBounds(int left, int top, int right, int bottom) {
@ -459,6 +464,192 @@ public class MotionBackgroundDrawable extends Drawable {
}
}
public void drawBackground(Canvas canvas) {
android.graphics.Rect bounds = getBounds();
canvas.save();
float tr = patternBitmap != null ? bounds.top : translationY;
int bitmapWidth = currentBitmap.getWidth();
int bitmapHeight = currentBitmap.getHeight();
float w = bounds.width();
float h = bounds.height();
float maxScale = Math.max(w / bitmapWidth, h / bitmapHeight);
float width = bitmapWidth * maxScale;
float height = bitmapHeight * maxScale;
float x = (w - width) / 2;
float y = (h - height) / 2;
if (isPreview) {
x += bounds.left;
y += bounds.top;
canvas.clipRect(bounds.left, bounds.top, bounds.right, bounds.bottom);
}
if (intensity < 0) {
canvas.drawColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (alpha * backgroundAlpha)));
} else {
if (roundRadius != 0) {
matrix.reset();
matrix.setTranslate(x, y);
float scaleW = (currentBitmap.getWidth() / (float) bounds.width());
float scaleH = (currentBitmap.getHeight() / (float) bounds.height());
float scale = 1.0f / Math.min(scaleW, scaleH);
matrix.preScale(scale, scale);
bitmapShader.setLocalMatrix(matrix);
rect.set(bounds.left, bounds.top, bounds.right, bounds.bottom);
int wasAlpha = paint.getAlpha();
paint.setAlpha((int) (wasAlpha * backgroundAlpha));
canvas.drawRoundRect(rect, roundRadius, roundRadius, paint);
paint.setAlpha(wasAlpha);
} else {
canvas.translate(0, tr);
if (gradientDrawable != null) {
gradientDrawable.setBounds((int) x, (int) y, (int) (x + width), (int) (y + height));
gradientDrawable.setAlpha((int) (255 * backgroundAlpha));
gradientDrawable.draw(canvas);
} else {
rect.set(x, y, x + width, y + height);
Paint bitmapPaint = overrideBitmapPaint != null ? overrideBitmapPaint : paint;
int wasAlpha = bitmapPaint.getAlpha();
bitmapPaint.setAlpha((int) (wasAlpha * backgroundAlpha));
canvas.drawBitmap(currentBitmap, null, rect, bitmapPaint);
bitmapPaint.setAlpha(wasAlpha);
}
}
}
canvas.restore();
updateAnimation();
}
public void drawPattern(Canvas canvas) {
android.graphics.Rect bounds = getBounds();
canvas.save();
float tr = patternBitmap != null ? bounds.top : translationY;
int bitmapWidth = currentBitmap.getWidth();
int bitmapHeight = currentBitmap.getHeight();
float w = bounds.width();
float h = bounds.height();
float maxScale = Math.max(w / bitmapWidth, h / bitmapHeight);
float width = bitmapWidth * maxScale;
float height = bitmapHeight * maxScale;
float x = (w - width) / 2;
float y = (h - height) / 2;
if (isPreview) {
x += bounds.left;
y += bounds.top;
canvas.clipRect(bounds.left, bounds.top, bounds.right, bounds.bottom);
}
if (intensity < 0) {
if (patternBitmap != null) {
if (useLegacyBitmap) {
if (errorWhileGenerateLegacyBitmap) {
bitmapWidth = patternBitmap.getWidth();
bitmapHeight = patternBitmap.getHeight();
maxScale = Math.max(w / bitmapWidth, h / bitmapHeight);
width = bitmapWidth * maxScale;
height = bitmapHeight * maxScale;
x = (w - width) / 2;
y = (h - height) / 2;
rect.set(x, y, x + width, y + height);
int averageColor = AndroidUtilities.getAverageColor(colors[2], AndroidUtilities.getAverageColor(colors[0], colors[1]));
if (colors[3] != 0) {
averageColor = AndroidUtilities.getAverageColor(colors[3], averageColor);
}
if (legacyBitmapColorFilter == null || averageColor != legacyBitmapColor) {
legacyBitmapColor = averageColor;
legacyBitmapColorFilter = new PorterDuffColorFilter(averageColor, PorterDuff.Mode.SRC_IN);
}
paint2.setColorFilter(legacyBitmapColorFilter);
paint2.setAlpha((int) ((Math.abs(intensity) / 100f) * alpha * patternAlpha));
canvas.translate(0, tr);
canvas.drawBitmap(patternBitmap, null, rect, paint2);
} else if (legacyBitmap != null) {
if (invalidateLegacy) {
rect.set(0, 0, legacyBitmap.getWidth(), legacyBitmap.getHeight());
int oldAlpha = paint.getAlpha();
paint.setAlpha(255);
legacyCanvas.drawBitmap(currentBitmap, null, rect, paint);
paint.setAlpha(oldAlpha);
bitmapWidth = patternBitmap.getWidth();
bitmapHeight = patternBitmap.getHeight();
maxScale = Math.max(w / bitmapWidth, h / bitmapHeight);
width = bitmapWidth * maxScale;
height = bitmapHeight * maxScale;
x = (w - width) / 2;
y = (h - height) / 2;
rect.set(x, y, x + width, y + height);
paint2.setColorFilter(null);
paint2.setAlpha((int) ((Math.abs(intensity) / 100f) * 255));
legacyCanvas.save();
legacyCanvas.scale(legacyBitmapScale, legacyBitmapScale);
legacyCanvas.drawBitmap(patternBitmap, null, rect, paint2);
legacyCanvas.restore();
invalidateLegacy = false;
}
rect.set(bounds.left, bounds.top, bounds.right, bounds.bottom);
if (legacyBitmap2 != null && posAnimationProgress != 1f) {
paint.setAlpha((int) (alpha * patternAlpha * (1f - posAnimationProgress)));
canvas.drawBitmap(legacyBitmap2, null, rect, paint);
paint.setAlpha((int) (alpha * patternAlpha * posAnimationProgress));
canvas.drawBitmap(legacyBitmap, null, rect, paint);
paint.setAlpha(alpha);
} else {
canvas.drawBitmap(legacyBitmap, null, rect, paint);
}
}
} else {
if (matrix == null) {
matrix = new Matrix();
}
matrix.reset();
matrix.setTranslate(x, y + tr);
float scaleW = (currentBitmap.getWidth() / (float) bounds.width());
float scaleH = (currentBitmap.getHeight() / (float) bounds.height());
float scale = 1.0f / Math.min(scaleW, scaleH);
matrix.preScale(scale, scale);
bitmapShader.setLocalMatrix(matrix);
matrix.reset();
bitmapWidth = patternBitmap.getWidth();
bitmapHeight = patternBitmap.getHeight();
maxScale = Math.max(w / bitmapWidth, h / bitmapHeight);
width = bitmapWidth * maxScale;
height = bitmapHeight * maxScale;
x = (w - width) / 2;
y = (h - height) / 2;
matrix.setTranslate(x, y + tr);
matrix.preScale(maxScale, maxScale);
gradientShader.setLocalMatrix(matrix);
paint2.setColorFilter(null);
paint2.setAlpha((int) ((Math.abs(intensity) / 100f) * alpha * patternAlpha));
rect.set(bounds.left, bounds.top, bounds.right, bounds.bottom);
canvas.drawRoundRect(rect, roundRadius, roundRadius, paint2);
}
}
} else {
if (patternBitmap != null) {
bitmapWidth = patternBitmap.getWidth();
bitmapHeight = patternBitmap.getHeight();
maxScale = Math.max(w / bitmapWidth, h / bitmapHeight);
width = bitmapWidth * maxScale;
height = bitmapHeight * maxScale;
x = (w - width) / 2;
y = (h - height) / 2;
rect.set(x, y, x + width, y + height);
paint2.setColorFilter(patternColorFilter);
paint2.setAlpha((int) ((Math.abs(intensity) / 100f) * alpha * patternAlpha));
canvas.drawBitmap(patternBitmap, null, rect, paint2);
}
}
canvas.restore();
updateAnimation();
}
@Override
public void draw(Canvas canvas) {
android.graphics.Rect bounds = getBounds();
@ -479,7 +670,7 @@ public class MotionBackgroundDrawable extends Drawable {
canvas.clipRect(bounds.left, bounds.top, bounds.right, bounds.bottom);
}
if (intensity < 0) {
canvas.drawColor(ColorUtils.setAlphaComponent(Color.BLACK, alpha));
canvas.drawColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (alpha * backgroundAlpha)));
if (patternBitmap != null) {
if (useLegacyBitmap) {
if (errorWhileGenerateLegacyBitmap) {
@ -587,10 +778,15 @@ public class MotionBackgroundDrawable extends Drawable {
canvas.translate(0, tr);
if (gradientDrawable != null) {
gradientDrawable.setBounds((int) x, (int) y, (int) (x + width), (int) (y + height));
gradientDrawable.setAlpha((int) (255 * backgroundAlpha));
gradientDrawable.draw(canvas);
} else {
rect.set(x, y, x + width, y + height);
canvas.drawBitmap(currentBitmap, null, rect, overrideBitmapPaint != null ? overrideBitmapPaint : paint);
Paint bitmapPaint = overrideBitmapPaint != null ? overrideBitmapPaint : paint;
int wasAlpha = bitmapPaint.getAlpha();
bitmapPaint.setAlpha((int) (wasAlpha * backgroundAlpha));
canvas.drawBitmap(currentBitmap, null, rect, bitmapPaint);
bitmapPaint.setAlpha(wasAlpha);
}
}

View File

@ -194,18 +194,18 @@ public class PopupSwipeBackLayout extends FrameLayout {
if (processTouchEvent(ev))
return true;
int act = ev.getActionMasked();
if (act == MotionEvent.ACTION_DOWN && !mRect.contains(ev.getX(), ev.getY())) {
callOnClick();
return true;
}
if (currentForegroundIndex < 0 || currentForegroundIndex >= getChildCount()) {
return super.dispatchTouchEvent(ev);
}
View bv = getChildAt(0);
View fv = getChildAt(currentForegroundIndex);
int act = ev.getActionMasked();
if (act == MotionEvent.ACTION_DOWN && (ev.getX() > (bv.getMeasuredWidth() + (fv.getMeasuredWidth() - bv.getMeasuredWidth()) * transitionProgress) ||
ev.getY() > (bv.getMeasuredHeight() + ((overrideForegroundHeight != 0 ? overrideForegroundHeight : fv.getMeasuredHeight()) - bv.getMeasuredHeight()) * transitionProgress))) {
callOnClick();
return true;
}
boolean b = (transitionProgress > 0.5f ? fv : bv).dispatchTouchEvent(ev);
if (!b && act == MotionEvent.ACTION_DOWN) {
@ -345,7 +345,6 @@ public class PopupSwipeBackLayout extends FrameLayout {
}
}
int s = canvas.save();
mPath.rewind();
int rad = AndroidUtilities.dp(6);

View File

@ -22,6 +22,8 @@ import android.text.TextUtils;
import android.view.HapticFeedbackConstants;
import android.view.View;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.DispatchQueuePool;
@ -164,6 +166,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
if (cacheGenerateTask == null) {
return;
}
createCache(nativePtr, width, height);
uiHandler.post(uiRunnableCacheFinished);
});
@ -358,12 +361,14 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
this(file, w, h, precache, limitFps, null, 0);
}
File file;
public RLottieDrawable(File file, int w, int h, boolean precache, boolean limitFps, int[] colorReplacement, int fitzModifier) {
width = w;
height = h;
shouldLimitFps = limitFps;
getPaint().setFlags(Paint.FILTER_BITMAP_FLAG);
this.file = file;
nativePtr = create(file.getAbsolutePath(), null, w, h, metaData, precache, colorReplacement, shouldLimitFps, fitzModifier);
if (precache && lottieCacheGenerateQueue == null) {
lottieCacheGenerateQueue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
@ -809,7 +814,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
}
public void setCurrentFrame(int frame, boolean async, boolean resetFrame) {
if (frame < 0 || frame > metaData[0]) {
if (frame < 0 || frame > metaData[0] || currentFrame == frame) {
return;
}
currentFrame = frame;

View File

@ -5,6 +5,8 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.text.TextUtils;
import android.util.LongSparseArray;
import android.util.TypedValue;
@ -24,6 +26,7 @@ import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.UserObject;
import org.telegram.tgnet.ConnectionsManager;
@ -75,6 +78,9 @@ public class ReactedUsersListView extends FrameLayout {
listView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
listView.setClipToPadding(false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
listView.setVerticalScrollbarThumbDrawable(new ColorDrawable(Theme.getColor(Theme.key_listSelector)));
}
listView.setAdapter(adapter = new RecyclerView.Adapter() {
@NonNull
@Override
@ -163,6 +169,7 @@ public class ReactedUsersListView extends FrameLayout {
TLRPC.TL_messages_messageReactionsList l = (TLRPC.TL_messages_messageReactionsList) response;
for (TLRPC.User u : l.users) {
MessagesController.getInstance(currentAccount).putUser(u, false);
users.put(u.id, u);
}
@ -172,10 +179,11 @@ public class ReactedUsersListView extends FrameLayout {
newReactions.addAll(userReactions);
newReactions.addAll(l.reactions);
if (onlySeenNow)
if (onlySeenNow) {
Collections.sort(newReactions, (o1, o2) -> Integer.compare(o1.reaction != null ? 1 : 0, o2.reaction != null ? 1 : 0));
}
AndroidUtilities.runOnUIThread(()->{
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getInstance(currentAccount).doOnIdle(() -> {
userReactions = newReactions;
if (onlySeenNow) {
onlySeenNow = false;
@ -206,7 +214,7 @@ public class ReactedUsersListView extends FrameLayout {
if (offset == null)
canLoadMore = false;
isLoading = false;
});
}));
} else isLoading = false;
}, ConnectionsManager.RequestFlagInvokeAfter);
}
@ -247,7 +255,7 @@ public class ReactedUsersListView extends FrameLayout {
titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
titleView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
titleView.setEllipsize(TextUtils.TruncateAt.END);
addView(titleView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 65, 0, 44, 0));
addView(titleView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 58, 0, 44, 0));
reactView = new BackupImageView(context);
addView(reactView, LayoutHelper.createFrameRelatively(24, 24, Gravity.END | Gravity.CENTER_VERTICAL, 0, 0, 12, 0));

View File

@ -2,6 +2,7 @@ package org.telegram.ui.Components;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
@ -16,6 +17,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DocumentObject;
@ -39,13 +41,17 @@ public class ReactionTabHolderView extends FrameLayout {
private TextView counterView;
private float outlineProgress;
Drawable drawable;
public ReactionTabHolderView(@NonNull Context context) {
super(context);
View overlaySelectorView = new View(context);
overlaySelectorView.setBackground(Theme.createSimpleSelectorRoundRectDrawable((int) radius, Color.TRANSPARENT, Theme.getColor(Theme.key_chat_inReactionButtonTextSelected)));
addView(overlaySelectorView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
iconView = new ImageView(context);
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.msg_reactions_filled).mutate();
drawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_avatar_nameInMessageBlue), PorterDuff.Mode.MULTIPLY));
drawable = ContextCompat.getDrawable(context, R.drawable.msg_reactions_filled).mutate();
iconView.setImageDrawable(drawable);
addView(iconView, LayoutHelper.createFrameRelatively(24, 24, Gravity.START | Gravity.CENTER_VERTICAL, 8, 0, 8, 0));
@ -58,20 +64,24 @@ public class ReactionTabHolderView extends FrameLayout {
outlinePaint.setStyle(Paint.Style.STROKE);
outlinePaint.setStrokeWidth(AndroidUtilities.dp(1));
outlinePaint.setColor(Theme.getColor(Theme.key_avatar_nameInMessageBlue));
bgPaint.setColor(Theme.getColor(Theme.key_avatar_nameInMessageBlue));
bgPaint.setAlpha(0x10);
View overlaySelectorView = new View(context);
overlaySelectorView.setBackground(Theme.getSelectorDrawable(bgPaint.getColor(), false));
addView(overlaySelectorView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
setWillNotDraw(false);
setOutlineProgress(outlineProgress);
}
public void setOutlineProgress(float outlineProgress) {
this.outlineProgress = outlineProgress;
int backgroundSelectedColor = Theme.getColor(Theme.key_chat_inReactionButtonBackground);
int backgroundColor = ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_chat_inReactionButtonBackground), 0x10);
int textSelectedColor = Theme.getColor(Theme.key_chat_inReactionButtonTextSelected);
int textColor = Theme.getColor(Theme.key_chat_inReactionButtonText);
int textFinalColor = ColorUtils.blendARGB(textColor, textSelectedColor, outlineProgress);
bgPaint.setColor(ColorUtils.blendARGB(backgroundColor, backgroundSelectedColor, outlineProgress));
counterView.setTextColor(textFinalColor);
drawable.setColorFilter(new PorterDuffColorFilter(textFinalColor, PorterDuff.Mode.MULTIPLY));
invalidate();
}
@ -97,19 +107,14 @@ public class ReactionTabHolderView extends FrameLayout {
@Override
protected void dispatchDraw(Canvas canvas) {
int s = canvas.save();
path.rewind();
rect.set(0, 0, getWidth(), getHeight());
path.addRoundRect(rect, radius, radius, Path.Direction.CW);
canvas.clipPath(path);
canvas.drawRoundRect(rect, radius, radius, bgPaint);
super.dispatchDraw(canvas);
outlinePaint.setAlpha((int) (outlineProgress * 0xFF));
float w = outlinePaint.getStrokeWidth();
rect.set(w, w, getWidth() - w, getHeight() - w);
canvas.drawRoundRect(rect, radius, radius, outlinePaint);
canvas.restoreToCount(s);
// outlinePaint.setAlpha((int) (outlineProgress * 0xFF));
// float w = outlinePaint.getStrokeWidth();
// rect.set(w, w, getWidth() - w, getHeight() - w);
// canvas.drawRoundRect(rect, radius, radius, outlinePaint);
}
}

View File

@ -10,6 +10,7 @@ import android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessagesController;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Cells.ChatMessageCell;
@ -24,6 +25,7 @@ public class ReactionsEffectOverlay {
private final AnimationView effectImageView;
private final AnimationView emojiImageView;
private final AnimationView emojiStaticImageView;
private final FrameLayout container;
boolean animateIn;
float animateInProgress;
@ -53,6 +55,7 @@ public class ReactionsEffectOverlay {
this.reaction = reaction;
ReactionsLayoutInBubble.ReactionButton reactionButton = cell.getReactionButton(reaction);
float fromX, fromY, fromHeight, fromWidth;
ChatActivity chatActivity = (fragment instanceof ChatActivity) ? (ChatActivity) fragment : null;
if (reactionsLayout != null) {
for (int i = 0; i < reactionsLayout.recyclerListView.getChildCount(); i++) {
if (((ReactionsContainerLayout.ReactionHolderView) reactionsLayout.recyclerListView.getChildAt(i)).currentReaction.reaction.equals(reaction)) {
@ -141,6 +144,9 @@ public class ReactionsEffectOverlay {
toX += reactionButton.x + reactionButton.imageReceiver.getImageX();
toY += reactionButton.y + reactionButton.imageReceiver.getImageY();
}
if (chatActivity != null) {
toY += chatActivity.drawingChatLisViewYoffset;
}
lastDrawnToX = toX;
lastDrawnToY = toY;
@ -164,6 +170,7 @@ public class ReactionsEffectOverlay {
}
float animateInProgressX, animateInProgressY;
float animateOutProgress = CubicBezierInterpolator.DEFAULT.getInterpolation(ReactionsEffectOverlay.this.animateOutProgress);
if (fromHolder) {
animateInProgressX = CubicBezierInterpolator.EASE_OUT_QUINT.getInterpolation(animateInProgress);
animateInProgressY = CubicBezierInterpolator.DEFAULT.getInterpolation(animateInProgress);
@ -187,6 +194,8 @@ public class ReactionsEffectOverlay {
effectImageView.setTranslationX(x);
effectImageView.setTranslationY(y);
effectImageView.setAlpha((1f - animateOutProgress));
effectImageView.setScaleX(scale);
effectImageView.setScaleY(scale);
if (animateOutProgress != 0) {
scale = scale * (1f - animateOutProgress) + toScale * animateOutProgress;
@ -194,6 +203,9 @@ public class ReactionsEffectOverlay {
y = y * (1f - animateOutProgress) + toY * animateOutProgress;
}
emojiStaticImageView.setAlpha(animateOutProgress > 0.7f ? (animateOutProgress - 0.7f) / 0.3f : 0);
//emojiImageView.setAlpha(animateOutProgress < 0.5f ? 1f - (animateOutProgress / 0.5f) : 0f);
container.setTranslationX(x);
container.setTranslationY(y);
@ -214,10 +226,10 @@ public class ReactionsEffectOverlay {
}
if (wasScrolled || (emojiImageView.wasPlaying && emojiImageView.getImageReceiver().getLottieAnimation() != null && !emojiImageView.getImageReceiver().getLottieAnimation().isRunning())) {
if (animateOutProgress != 1f) {
animateOutProgress += 16f / 220f;
if (animateOutProgress > 1f) {
animateOutProgress = 1f;
if (ReactionsEffectOverlay.this.animateOutProgress != 1f) {
ReactionsEffectOverlay.this.animateOutProgress += 16f / 220f;
if (ReactionsEffectOverlay.this.animateOutProgress > 1f) {
ReactionsEffectOverlay.this.animateOutProgress = 1f;
currentOverlay = null;
cell.invalidate();
if (cell.getCurrentMessagesGroup() != null && cell.getParent() != null) {
@ -239,6 +251,7 @@ public class ReactionsEffectOverlay {
};
effectImageView = new AnimationView(context);
emojiImageView = new AnimationView(context);
emojiStaticImageView = new AnimationView(context);
TLRPC.TL_availableReaction availableReaction = MediaDataController.getInstance(currentAccount).getReactionsMap().get(reaction);
if (availableReaction != null) {
TLRPC.Document document = availableReaction.effect_animation;
@ -274,6 +287,15 @@ public class ReactionsEffectOverlay {
((FrameLayout.LayoutParams) emojiImageView.getLayoutParams()).topMargin = topOffset;
((FrameLayout.LayoutParams) emojiImageView.getLayoutParams()).leftMargin = leftOffset;
emojiStaticImageView.getImageReceiver().setImage(ImageLocation.getForDocument(availableReaction.static_icon), "40_40", null, "webp", availableReaction, 1);
container.addView(emojiStaticImageView);
emojiStaticImageView.getLayoutParams().width = emojiSize;
emojiStaticImageView.getLayoutParams().height = emojiSize;
((FrameLayout.LayoutParams) emojiStaticImageView.getLayoutParams()).topMargin = topOffset;
((FrameLayout.LayoutParams) emojiStaticImageView.getLayoutParams()).leftMargin = leftOffset;
windowView.addView(container);
container.getLayoutParams().width = size;
container.getLayoutParams().height = size;
@ -298,6 +320,10 @@ public class ReactionsEffectOverlay {
if (cell == null) {
return;
}
boolean animationEnabled = MessagesController.getGlobalMainSettings().getBoolean("view_animations", true);
if (!animationEnabled) {
return;
}
ReactionsEffectOverlay reactionsEffectOverlay = new ReactionsEffectOverlay(baseFragment.getParentActivity(), baseFragment, reactionsLayout, cell, x, y, reaction, currentAccount);
currentOverlay = reactionsEffectOverlay;

View File

@ -67,6 +67,7 @@ public class ReactionsLayoutInBubble {
ChatMessageCell parentView;
MessageObject messageObject;
Theme.ResourcesProvider resourcesProvider;
private String scrimViewReaction;
int availableWidth;
private int lastDrawnWidth;
@ -125,6 +126,9 @@ public class ReactionsLayoutInBubble {
reactionButtons.add(new ReactionButton(reactionCount));
reactionButtons.get(0).isSelected = false;
reactionButtons.get(1).isSelected = true;
reactionButtons.get(0).realCount = 1;
reactionButtons.get(1).realCount = 1;
reactionButtons.get(1).key = reactionButtons.get(1).key + "_";
break;
}
if (isSmall && i == 2) {
@ -135,8 +139,10 @@ public class ReactionsLayoutInBubble {
}
}
}
comparator.currentAccount = currentAccount;
Collections.sort(reactionButtons, comparator);
if (!isSmall) {
comparator.currentAccount = currentAccount;
Collections.sort(reactionButtons, comparator);
}
}
isEmpty = reactionButtons.isEmpty();
}
@ -190,7 +196,7 @@ public class ReactionsLayoutInBubble {
drawServiceShaderBackground = false;
}
public void draw(Canvas canvas, float animationProgress) {
public void draw(Canvas canvas, float animationProgress, String drawOnlyReaction) {
if (isEmpty && outButtons.isEmpty()) {
return;
}
@ -207,6 +213,9 @@ public class ReactionsLayoutInBubble {
canvas.translate(totalX, totalY);
for (int i = 0; i < reactionButtons.size(); i++) {
ReactionButton reactionButton = reactionButtons.get(i);
if (reactionButton.reaction.equals(scrimViewReaction) || (drawOnlyReaction != null && !reactionButton.reaction.equals(drawOnlyReaction))) {
continue;
}
canvas.save();
float x = reactionButton.x;
float y = reactionButton.y;
@ -221,7 +230,7 @@ public class ReactionsLayoutInBubble {
alpha = animationProgress;
canvas.scale(s, s, reactionButton.width / 2f, reactionButton.height / 2f);
}
reactionButton.draw(canvas, reactionButton.animationType == ANIMATION_TYPE_IN ? 1f : animationProgress, alpha);
reactionButton.draw(canvas, reactionButton.animationType == ANIMATION_TYPE_MOVE ? animationProgress : 1f, alpha, drawOnlyReaction != null);
canvas.restore();
}
@ -231,7 +240,7 @@ public class ReactionsLayoutInBubble {
canvas.translate(reactionButton.x, reactionButton.y);
float s = 0.5f + 0.5f * (1f - animationProgress);
canvas.scale(s, s, reactionButton.width / 2f, reactionButton.height / 2f);
outButtons.get(i).draw(canvas, 1f, (1f - animationProgress));
outButtons.get(i).draw(canvas, 1f, (1f - animationProgress), false);
canvas.restore();
}
canvas.restore();
@ -240,7 +249,7 @@ public class ReactionsLayoutInBubble {
public void recordDrawingState() {
lastDrawingReactionButtons.clear();
for (int i = 0; i < reactionButtons.size(); i++) {
lastDrawingReactionButtons.put(reactionButtons.get(i).reaction, reactionButtons.get(i));
lastDrawingReactionButtons.put(reactionButtons.get(i).key, reactionButtons.get(i));
}
wasDrawn = !isEmpty;
lastDrawnX = x;
@ -249,6 +258,9 @@ public class ReactionsLayoutInBubble {
}
public boolean animateChange() {
if (messageObject == null) {
return false;
}
boolean changed = false;
lastDrawingReactionButtonsTmp.clear();
for (int i = 0; i < outButtons.size(); i++) {
@ -258,12 +270,13 @@ public class ReactionsLayoutInBubble {
lastDrawingReactionButtonsTmp.putAll(lastDrawingReactionButtons);
for (int i = 0; i < reactionButtons.size(); i++) {
ReactionButton button = reactionButtons.get(i);
ReactionButton lastButton = lastDrawingReactionButtonsTmp.remove(button.reaction);
ReactionButton lastButton = lastDrawingReactionButtonsTmp.remove(button.key);
if (lastButton != null) {
if (button.animateFromX != lastButton.x || button.animateFromY != lastButton.y || button.animateFromWidth != lastButton.width || button.count != lastButton.count || button.backgroundColor != lastButton.backgroundColor) {
if (button.x != lastButton.x || button.y != lastButton.y || button.width != lastButton.width || button.count != lastButton.count || button.backgroundColor != lastButton.backgroundColor) {
button.animateFromX = lastButton.x;
button.animateFromY = lastButton.y;
button.animateFromWidth = lastButton.width;
button.fromTextColor = lastButton.lastDrawnTextColor;
button.fromBackgroundColor = lastButton.lastDrawnBackgroundColor;
button.animationType = ANIMATION_TYPE_MOVE;
@ -328,9 +341,19 @@ public class ReactionsLayoutInBubble {
}
public ReactionButton getReactionButton(String reaction) {
if (isSmall) {
ReactionButton button = lastDrawingReactionButtons.get(reaction + "_");
if (button != null) {
return button;
}
}
return lastDrawingReactionButtons.get(reaction);
}
public void setScrimReaction(String scrimViewReaction) {
this.scrimViewReaction = scrimViewReaction;
}
public class ReactionButton {
private final TLRPC.TL_reactionCount reactionCount;
@ -343,14 +366,17 @@ public class ReactionsLayoutInBubble {
public int realCount;
public boolean drawImage = true;
public boolean lastImageDrawn;
public boolean wasDrawn;
public String key;
String countText;
String reaction;
int count;
public int x;
public int y;
int width;
int height;
public int width;
public int height;
ImageReceiver imageReceiver = new ImageReceiver();
CounterView.CounterDrawable counterDrawable = new CounterView.CounterDrawable(parentView, false, null);
int backgroundColor;
@ -369,10 +395,12 @@ public class ReactionsLayoutInBubble {
this.reaction = reactionCount.reaction;
this.count = reactionCount.count;
this.realCount = reactionCount.count;
this.key = this.reaction;
countText = Integer.toString(reactionCount.count);
imageReceiver.setParentView(parentView);
isSelected = reactionCount.chosen;
counterDrawable.updateVisibility = false;
counterDrawable.shortFormat = true;
if (reactionCount.chosen) {
backgroundColor = Theme.getColor(messageObject.isOutOwner() ? Theme.key_chat_outReactionButtonBackground : Theme.key_chat_inReactionButtonBackground, resourcesProvider);
textColor = Theme.getColor(messageObject.isOutOwner() ? Theme.key_chat_outReactionButtonTextSelected : Theme.key_chat_inReactionButtonTextSelected, resourcesProvider);
@ -402,20 +430,17 @@ public class ReactionsLayoutInBubble {
counterDrawable.gravity = Gravity.LEFT;
}
public void draw(Canvas canvas, float progress, float alpha) {
public void draw(Canvas canvas, float progress, float alpha, boolean drawOverlayScrim) {
wasDrawn = true;
if (isSmall) {
imageReceiver.setAlpha(alpha);
imageReceiver.setImageCoords(0, 0, AndroidUtilities.dp(14), AndroidUtilities.dp(14));
drawImage(canvas);
return;
}
if (drawServiceShaderBackground) {
textPaint.setColor(lastDrawnTextColor = ColorUtils.blendARGB(fromTextColor, serviceTextColor, progress));
paint.setColor(lastDrawnBackgroundColor = ColorUtils.blendARGB(fromBackgroundColor, serviceBackgroundColor, progress));
} else {
textPaint.setColor(lastDrawnTextColor = ColorUtils.blendARGB(fromTextColor, textColor, progress));
paint.setColor(lastDrawnBackgroundColor = ColorUtils.blendARGB(fromBackgroundColor, backgroundColor, progress));
}
updateColors(progress);
textPaint.setColor(lastDrawnTextColor);
paint.setColor(lastDrawnBackgroundColor);
if (alpha != 1f) {
textPaint.setAlpha((int) (textPaint.getAlpha() * alpha));
@ -443,6 +468,12 @@ public class ReactionsLayoutInBubble {
paint1.setAlpha(oldAlpha);
paint2.setAlpha(oldAlpha2);
}
if (!drawServiceShaderBackground && drawOverlayScrim) {
Theme.MessageDrawable messageBackground = parentView.getCurrentBackgroundDrawable(false);
if (messageBackground != null) {
canvas.drawRoundRect(AndroidUtilities.rectTmp, rad, rad, messageBackground.getPaint());
}
}
canvas.drawRoundRect(AndroidUtilities.rectTmp, rad, rad, paint);
imageReceiver.setImageCoords(AndroidUtilities.dp(8), (height - AndroidUtilities.dp(20)) / 2f, AndroidUtilities.dp(20), AndroidUtilities.dp(20));
@ -464,6 +495,16 @@ public class ReactionsLayoutInBubble {
}
}
private void updateColors(float progress) {
if (drawServiceShaderBackground) {
lastDrawnTextColor = ColorUtils.blendARGB(fromTextColor, serviceTextColor, progress);
lastDrawnBackgroundColor = ColorUtils.blendARGB(fromBackgroundColor, serviceBackgroundColor, progress);
} else {
lastDrawnTextColor = ColorUtils.blendARGB(fromTextColor, textColor, progress);
lastDrawnBackgroundColor = ColorUtils.blendARGB(fromBackgroundColor, backgroundColor, progress);
}
}
private void drawImage(Canvas canvas) {
if (drawImage && ((realCount > 1 || !ReactionsEffectOverlay.isPlaying(messageObject.getId(), messageObject.getGroupId(), reaction)) || !isSelected)) {
imageReceiver.draw(canvas);
@ -497,8 +538,6 @@ public class ReactionsLayoutInBubble {
}
}
public void attach() {
if (imageReceiver != null) {
imageReceiver.onAttachedToWindow();
@ -517,7 +556,6 @@ public class ReactionsLayoutInBubble {
}
}
}
static int attachedCount;
float lastX;
float lastY;
@ -526,7 +564,7 @@ public class ReactionsLayoutInBubble {
Runnable longPressRunnable;
public boolean chekTouchEvent(MotionEvent event) {
if (isEmpty || messageObject == null || messageObject.messageOwner == null || messageObject.messageOwner.reactions == null) {
if (isEmpty || isSmall || messageObject == null || messageObject.messageOwner == null || messageObject.messageOwner.reactions == null) {
return false;
}
float x = event.getX() - this.x;
@ -538,16 +576,18 @@ public class ReactionsLayoutInBubble {
lastX = event.getX();
lastY = event.getY();
lastSelectedButton = reactionButtons.get(i);
if (longPressRunnable != null && messageObject.messageOwner.reactions.can_see_list) {
if (longPressRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(longPressRunnable);
longPressRunnable = null;
}
final ReactionButton selectedButtonFinal = lastSelectedButton;
AndroidUtilities.runOnUIThread(longPressRunnable = () -> {
parentView.getDelegate().didPressReaction(parentView, selectedButtonFinal.reactionCount, true);
longPressRunnable = null;
}, ViewConfiguration.getLongPressTimeout());
if (messageObject.messageOwner.reactions.can_see_list) {
AndroidUtilities.runOnUIThread(longPressRunnable = () -> {
parentView.getDelegate().didPressReaction(parentView, selectedButtonFinal.reactionCount, true);
longPressRunnable = null;
}, ViewConfiguration.getLongPressTimeout());
}
pressed = true;
break;
}

View File

@ -2,6 +2,7 @@ package org.telegram.ui.Components;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
@ -17,15 +18,16 @@ import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.util.Property;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.util.Consumer;
import androidx.dynamicanimation.animation.FloatPropertyCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -33,7 +35,12 @@ import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DocumentObject;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.SvgHelper;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
@ -44,16 +51,16 @@ import java.util.HashSet;
import java.util.List;
import java.util.Random;
public class ReactionsContainerLayout extends FrameLayout {
public final static FloatPropertyCompat<ReactionsContainerLayout> TRANSITION_PROGRESS_VALUE = new FloatPropertyCompat<ReactionsContainerLayout>("transitionProgress") {
public class ReactionsContainerLayout extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {
public final static Property<ReactionsContainerLayout, Float> TRANSITION_PROGRESS_VALUE = new Property<ReactionsContainerLayout, Float>(Float.class, "transitionProgress") {
@Override
public float getValue(ReactionsContainerLayout object) {
return object.transitionProgress * 100f;
public Float get(ReactionsContainerLayout reactionsContainerLayout) {
return reactionsContainerLayout.transitionProgress ;
}
@Override
public void setValue(ReactionsContainerLayout object, float value) {
object.setTransitionProgress(value / 100f);
public void set(ReactionsContainerLayout object, Float value) {
object.setTransitionProgress(value);
}
};
@ -76,6 +83,9 @@ public class ReactionsContainerLayout extends FrameLayout {
private float bigCircleRadius = AndroidUtilities.dp(8);
private float smallCircleRadius = bigCircleRadius / 2;
private int bigCircleOffset = AndroidUtilities.dp(36);
private MessageObject messageObject;
private int currentAccount;
private long waitingLoadingChatId;
private List<TLRPC.TL_availableReaction> reactionsList = Collections.emptyList();
@ -88,13 +98,17 @@ public class ReactionsContainerLayout extends FrameLayout {
private Rect shadowPad = new Rect();
private Drawable shadow;
private final boolean animationEnabled;
private List<String> triggeredReactions = new ArrayList<>();
Theme.ResourcesProvider resourcesProvider;
public ReactionsContainerLayout(@NonNull Context context, Theme.ResourcesProvider resourcesProvider) {
public ReactionsContainerLayout(@NonNull Context context, int currentAccount, Theme.ResourcesProvider resourcesProvider) {
super(context);
this.resourcesProvider = resourcesProvider;
this.currentAccount = currentAccount;
animationEnabled = MessagesController.getGlobalMainSettings().getBoolean("view_animations", true) && SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW;
shadow = ContextCompat.getDrawable(context, R.drawable.reactions_bubble_shadow).mutate();
shadowPad.left = shadowPad.top = shadowPad.right = shadowPad.bottom = AndroidUtilities.dp(7);
@ -206,9 +220,14 @@ public class ReactionsContainerLayout extends FrameLayout {
}
@SuppressLint("NotifyDataSetChanged")
public void setReactionsList(List<TLRPC.TL_availableReaction> reactionsList) {
private void setReactionsList(List<TLRPC.TL_availableReaction> reactionsList) {
this.reactionsList = reactionsList;
int size = getLayoutParams().height - getPaddingTop() - getPaddingBottom();
if (size * reactionsList.size() < AndroidUtilities.dp(200)) {
getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
listAdapter.notifyDataSetChanged();
}
HashSet<View> lastVisibleViews = new HashSet<>();
@ -222,13 +241,18 @@ public class ReactionsContainerLayout extends FrameLayout {
if (transitionProgress != 0) {
int delay = 0;
for (int i = 0; i < recyclerListView.getChildCount(); i++) {
View view = recyclerListView.getChildAt(i);
if (view.getX() + view.getMeasuredWidth() > 0 && view.getX() < getWidth()) {
ReactionHolderView view = (ReactionHolderView) recyclerListView.getChildAt(i);
if (view.backupImageView.getImageReceiver().getLottieAnimation() == null) {
continue;
}
if (view.getX() + view.getMeasuredWidth() / 2f > 0 && view.getX() + view.getMeasuredWidth() / 2f < recyclerListView.getWidth()) {
if (!lastVisibleViewsTmp.contains(view)) {
((ReactionHolderView) view).play(delay);
delay += 50;
view.play(delay);
delay += 30;
}
lastVisibleViews.add(view);
} else if (!view.isEnter) {
view.resetAnimation();
}
}
}
@ -335,6 +359,51 @@ public class ReactionsContainerLayout extends FrameLayout {
invalidate();
}
public void setMessage(MessageObject message, TLRPC.ChatFull chatFull) {
this.messageObject = message;
TLRPC.ChatFull reactionsChat = chatFull;
List<TLRPC.TL_availableReaction> l;
if (message.isForwardedChannelPost()) {
reactionsChat = MessagesController.getInstance(currentAccount).getChatFull(-message.getFromChatId());
if (reactionsChat == null) {
waitingLoadingChatId = -message.getFromChatId();
MessagesController.getInstance(currentAccount).loadFullChat(-message.getFromChatId(), 0, true);
setVisibility(View.INVISIBLE);
return;
}
}
if (reactionsChat != null) {
l = new ArrayList<>(reactionsChat.available_reactions.size());
for (String s : reactionsChat.available_reactions) {
for (TLRPC.TL_availableReaction a : MediaDataController.getInstance(currentAccount).getEnabledReactionsList()) {
if (a.reaction.equals(s)) {
l.add(a);
break;
}
}
}
} else {
l = MediaDataController.getInstance(currentAccount).getEnabledReactionsList();
}
setReactionsList(l);
}
public void startEnterAnimation() {
setTransitionProgress(0);
setAlpha(1f);
ObjectAnimator animator = ObjectAnimator.ofFloat(this, ReactionsContainerLayout.TRANSITION_PROGRESS_VALUE, 0f, 1f).setDuration(400);
animator.setInterpolator(new OvershootInterpolator(1.004f));
animator.start();
}
public int getTotalWidth() {
return AndroidUtilities.dp(36) * reactionsList.size() + AndroidUtilities.dp(16);
}
public int getItemsCount() {
return reactionsList.size();
}
private final class LeftRightShadowsListener extends RecyclerView.OnScrollListener {
private boolean leftVisible, rightVisible;
private ValueAnimator leftAnimator, rightAnimator;
@ -383,11 +452,12 @@ public class ReactionsContainerLayout extends FrameLayout {
public final class ReactionHolderView extends FrameLayout {
public BackupImageView backupImageView;
public TLRPC.TL_availableReaction currentReaction;
private boolean isEnter;
Runnable playRunnable = new Runnable() {
@Override
public void run() {
if (backupImageView.getImageReceiver().getLottieAnimation() != null && !backupImageView.getImageReceiver().getLottieAnimation().isRunning()) {
if (backupImageView.getImageReceiver().getLottieAnimation() != null && !backupImageView.getImageReceiver().getLottieAnimation().isRunning() && !backupImageView.getImageReceiver().getLottieAnimation().isGeneratingCache()) {
backupImageView.getImageReceiver().getLottieAnimation().start();
}
}
@ -396,37 +466,100 @@ public class ReactionsContainerLayout extends FrameLayout {
ReactionHolderView(Context context) {
super(context);
backupImageView = new BackupImageView(context);
backupImageView = new BackupImageView(context) {
@Override
public void invalidate() {
super.invalidate();
ReactionsContainerLayout.this.invalidate();
}
};
backupImageView.getImageReceiver().setAutoRepeat(0);
backupImageView.getImageReceiver().setAllowStartLottieAnimation(false);
addView(backupImageView, LayoutHelper.createFrame(34, 34, Gravity.CENTER));
}
private void setReaction(TLRPC.TL_availableReaction react) {
if (currentReaction != null && currentReaction.reaction.equals(react.reaction)) {
return;
}
resetAnimation();
currentReaction = react;
SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(currentReaction.appear_animation, Theme.key_windowBackgroundGray, 1.0f);
backupImageView.getImageReceiver().setImage(ImageLocation.getForDocument(currentReaction.appear_animation), "80_80_nolimit", null, null, svgThumb, 0, "tgs", react, 0);
SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(currentReaction.activate_animation, Theme.key_windowBackgroundGray, 1.0f);
backupImageView.getImageReceiver().setImage(ImageLocation.getForDocument(currentReaction.appear_animation), "60_60_nolimit", null, null, svgThumb, 0, "tgs", react, 0);
}
public void play(int delay) {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
resetAnimation();
}
public boolean play(int delay) {
if (!animationEnabled) {
resetAnimation();
isEnter = true;
return false;
}
AndroidUtilities.cancelRunOnUIThread(playRunnable);
if (backupImageView.getImageReceiver().getLottieAnimation() != null) {
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(0, false);
if (backupImageView.getImageReceiver().getLottieAnimation() != null && !backupImageView.getImageReceiver().getLottieAnimation().isGeneratingCache() && !isEnter) {
isEnter = true;
if (delay == 0) {
backupImageView.getImageReceiver().getLottieAnimation().stop();
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(0, false);
playRunnable.run();
} else {
backupImageView.getImageReceiver().getLottieAnimation().stop();
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(0, false);
AndroidUtilities.runOnUIThread(playRunnable, delay);
}
return true;
}
if (backupImageView.getImageReceiver().getLottieAnimation() != null && isEnter && !backupImageView.getImageReceiver().getLottieAnimation().isRunning() && !backupImageView.getImageReceiver().getLottieAnimation().isGeneratingCache()) {
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(backupImageView.getImageReceiver().getLottieAnimation().getFramesCount() - 1, false);
}
return false;
}
public void resetAnimation() {
AndroidUtilities.cancelRunOnUIThread(playRunnable);
if (backupImageView.getImageReceiver().getLottieAnimation() != null && !backupImageView.getImageReceiver().getLottieAnimation().isGeneratingCache()) {
backupImageView.getImageReceiver().getLottieAnimation().stop();
if (animationEnabled) {
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(0, false, true);
} else {
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(backupImageView.getImageReceiver().getLottieAnimation().getFramesCount() - 1, false, true);
}
}
isEnter = false;
}
}
public interface ReactionsContainerDelegate {
void onReactionClicked(View v, TLRPC.TL_availableReaction reaction);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatInfoDidLoad);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.chatInfoDidLoad);
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.chatInfoDidLoad) {
TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0];
if (chatFull.id == waitingLoadingChatId && getVisibility() != View.VISIBLE && !chatFull.available_reactions.isEmpty()) {
setMessage(messageObject, null);
setVisibility(View.VISIBLE);
startEnterAnimation();
}
}
}
}

View File

@ -13,7 +13,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.drawable.Drawable;
@ -26,7 +25,6 @@ import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.transition.TransitionValues;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
@ -52,10 +50,7 @@ import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
public class ScrollSlidingTabStrip extends HorizontalScrollView {
@ -648,7 +643,7 @@ public class ScrollSlidingTabStrip extends HorizontalScrollView {
}
if (sticker instanceof TLRPC.Document) {
// String.format(Locale.US, "%d_%d_nr_%s" + messageObject.emojiAnimatedStickerColor, w, h, messageObject.toString());
tabView.imageView.setImage(ImageLocation.getForDocument((TLRPC.Document) sticker), "36_36", thumbDrawable, null);
tabView.imageView.setImage(ImageLocation.getForDocument((TLRPC.Document) sticker), "36_36_nolimit", thumbDrawable, null);
} else {
tabView.imageView.setImageDrawable(thumbDrawable);
}

View File

@ -100,6 +100,7 @@ public class TextStyleSpan extends MetricAffectingSpan {
public final static int FLAG_STYLE_SPOILER = 256;
public final static int FLAG_STYLE_SPOILER_REVEALED = 512;
public TextStyleSpan(TextStyleRun run) {
this(run, 0, 0);
}

View File

@ -477,8 +477,10 @@ public class ThemeSmallPreviewView extends FrameLayout implements NotificationCe
if (backupImageView.getImageReceiver().getLottieAnimation() != null) {
AndroidUtilities.cancelRunOnUIThread(animationCancelRunnable);
backupImageView.setVisibility(View.VISIBLE);
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(0, false);
backupImageView.getImageReceiver().getLottieAnimation().start();
if (!backupImageView.getImageReceiver().getLottieAnimation().isRunning) {
backupImageView.getImageReceiver().getLottieAnimation().setCurrentFrame(0, true);
backupImageView.getImageReceiver().getLottieAnimation().start();
}
backupImageView.animate().scaleX(2f).scaleY(2f).setDuration(300).setInterpolator(AndroidUtilities.overshootInterpolator).start();
AndroidUtilities.runOnUIThread(animationCancelRunnable = () -> {

View File

@ -13,6 +13,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
@ -31,6 +32,11 @@ import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.LanguageCell;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
@ -54,6 +60,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.Timer;
public class LanguageSelectActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {

View File

@ -220,7 +220,7 @@ public class MessageSeenView extends FrameLayout {
titleView.setText(ContactsController.formatName(users.get(0).first_name, users.get(0).last_name));
} else {
if (peerIds.size() == 0) {
titleView.setText(LocaleController.getString(LocaleController.getString("NobodyViewed", R.string.NobodyViewed)));
titleView.setText(LocaleController.getString("NobodyViewed", R.string.NobodyViewed));
} else {
titleView.setText(LocaleController.formatPluralString(isVoice ? "MessagePlayed" : "MessageSeen", peerIds.size()));
}

View File

@ -1131,7 +1131,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
public void onAnimationEnd(Animator animation) {
if (isIndicatorVisible) {
if (searchItem != null) {
searchItem.setVisibility(GONE);
searchItem.setClickable(false);
}
if (editItemVisible) {
editItem.setVisibility(GONE);
@ -1150,7 +1150,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onAnimationStart(Animator animation) {
if (searchItem != null && !expanded) {
searchItem.setVisibility(VISIBLE);
searchItem.setClickable(true);
}
if (editItemVisible) {
editItem.setVisibility(VISIBLE);
@ -3150,7 +3150,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_profile_actionBackground), Theme.getColor(Theme.key_profile_actionPressedBackground)),
0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
writeButton.setBackgroundDrawable(combinedDrawable);
writeButton.setBackground(combinedDrawable);
if (userId != 0) {
if (imageUpdater != null) {
cameraDrawable = new RLottieDrawable(R.raw.camera_outline, "" + R.raw.camera_outline, AndroidUtilities.dp(56), AndroidUtilities.dp(56), false, null);
@ -3233,9 +3233,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (searchItem != null) {
searchItem.setAlpha(1.0f - value);
searchItem.setScaleY(1.0f - value);
searchItem.setVisibility(searchItem.getAlpha() == 0f ? View.GONE : View.VISIBLE);
if (qrItem != null && searchItem.getVisibility() == View.VISIBLE) {
searchItem.setVisibility(View.VISIBLE);
searchItem.setClickable(searchItem.getAlpha() > .5f);
if (qrItem != null) {
float translation = AndroidUtilities.dp(48) * value;
// if (searchItem.getVisibility() == View.VISIBLE)
// translation += AndroidUtilities.dp(48);
qrItem.setTranslationX(translation);
avatarsViewPagerIndicatorView.setTranslationX(translation - AndroidUtilities.dp(48));
}
@ -4320,8 +4323,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
qrItemAnimation.start();
} else {
qrItem.setAlpha(setQrVisible ? 1.0f : 0.0f);
qrItem.setTranslationX(setQrVisible ? 0f : AndroidUtilities.dp(48f));
avatarsViewPagerIndicatorView.setTranslationX(setQrVisible ? 0f : -AndroidUtilities.dp(48f));
float translation = AndroidUtilities.dp(48) * qrItem.getAlpha();
qrItem.setTranslationX(translation);
avatarsViewPagerIndicatorView.setTranslationX(translation - AndroidUtilities.dp(48));
}
}
}
@ -6089,7 +6093,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
if (qrItem != null) {
qrItem.setVisibility(isQrNeedVisible() ? View.VISIBLE : View.GONE);
qrItem.setVisibility(searchTransitionProgress > 0.5f && isQrNeedVisible() ? View.VISIBLE : View.GONE);
}
}
@ -8242,6 +8246,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
}
@Override
protected void onBecomeFullyVisible() {
super.onBecomeFullyVisible();
try {
Drawable shadowDrawable = fragmentView.getContext().getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable,
Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_profile_actionBackground), Theme.getColor(Theme.key_profile_actionPressedBackground)),
0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
writeButton.setBackground(combinedDrawable);
} catch (Exception e) {}
}
private boolean isQrNeedVisible() {
return !TextUtils.isEmpty(getUserConfig().getCurrentUser().username);
}

View File

@ -2,6 +2,8 @@ package org.telegram.ui;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
@ -23,18 +25,21 @@ import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
@ -73,6 +78,7 @@ import org.telegram.ui.Cells.SettingsSearchCell;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.ChatThemeBottomSheet;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.Easings;
import org.telegram.ui.Components.FlickerLoadingView;
import org.telegram.ui.Components.HideViewAfterAnimation;
@ -239,10 +245,15 @@ public class QrActivity extends BaseFragment {
protected void onDraw(Canvas canvas) {
if (prevMotionDrawable != null) {
prevMotionDrawable.setBounds(0, 0, getWidth(), getHeight());
prevMotionDrawable.draw(canvas);
}
currMotionDrawable.setBounds(0, 0, getWidth(), getHeight());
currMotionDrawable.draw(canvas);
if (prevMotionDrawable != null)
prevMotionDrawable.drawBackground(canvas);
currMotionDrawable.drawBackground(canvas);
if (prevMotionDrawable != null)
prevMotionDrawable.drawPattern(canvas);
currMotionDrawable.drawPattern(canvas);
super.onDraw(canvas);
}
};
@ -481,6 +492,34 @@ public class QrActivity extends BaseFragment {
}
}
@Override
protected AnimatorSet onCustomTransitionAnimation(boolean isOpen, Runnable callback) {
if (isOpen) {
fragmentView.setAlpha(0f);
fragmentView.setTranslationX(AndroidUtilities.dp(48));
}
AnimatorSet animator = new AnimatorSet();
animator.playTogether(
ObjectAnimator.ofFloat(fragmentView, View.TRANSLATION_X, isOpen ? 0 : AndroidUtilities.dp(48)),
ObjectAnimator.ofFloat(fragmentView, View.ALPHA, isOpen ? 1f : 0f)
);
if (!isOpen)
animator.setInterpolator(new DecelerateInterpolator(1.5f));
else
animator.setInterpolator(CubicBezierInterpolator.EASE_IN);
animator.setDuration(isOpen ? 200 : 150);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
if (callback != null)
callback.run();
}
});
animator.start();
return animator;
}
private void onItemSelected(EmojiThemes newTheme, int position, boolean withAnimation) {
selectedPosition = position;
final EmojiThemes prevTheme = currentTheme;
@ -488,8 +527,16 @@ public class QrActivity extends BaseFragment {
currentTheme = newTheme;
EmojiThemes.ThemeItem themeItem = currentTheme.getThemeItem(isDarkTheme ? 1 : 0);
float duration = 1f;
if (patternAlphaAnimator != null) {
// from = (float) patternAlphaAnimator.getAnimatedValue();
duration *= Math.max(.5f, 1f - (float) patternAlphaAnimator.getAnimatedValue());
patternAlphaAnimator.cancel();
}
prevMotionDrawable = currMotionDrawable;
prevMotionDrawable.setIndeterminateAnimation(false);
prevMotionDrawable.setAlpha(255);
currMotionDrawable = new MotionBackgroundDrawable();
currMotionDrawable.setCallback(backgroundView);
@ -497,18 +544,21 @@ public class QrActivity extends BaseFragment {
currMotionDrawable.setParentView(backgroundView);
currMotionDrawable.setPatternAlpha(1f);
currMotionDrawable.setIndeterminateAnimation(true);
currMotionDrawable.posAnimationProgress = prevMotionDrawable.posAnimationProgress;
if (prevMotionDrawable != null)
currMotionDrawable.posAnimationProgress = prevMotionDrawable.posAnimationProgress;
qrView.setPosAnimationProgress(currMotionDrawable.posAnimationProgress);
TLRPC.WallPaper wallPaper = currentTheme.getWallpaper(isDarkTheme ? 1 : 0);
if (wallPaper != null) {
currMotionDrawable.setPatternBitmap(wallPaper.settings.intensity);
final long startedLoading = SystemClock.elapsedRealtime();
currentTheme.loadWallpaper(isDarkTheme ? 1 : 0, pair -> {
if (pair != null && currentTheme.getTlTheme(isDarkTheme ? 1 : 0) != null) {
final long themeId = pair.first;
final Bitmap bitmap = pair.second;
if (themeId == currentTheme.getTlTheme(isDarkTheme ? 1 : 0).id && bitmap != null) {
onPatternLoaded(bitmap, currMotionDrawable.getIntensity(), withAnimation);
long elapsed = SystemClock.elapsedRealtime() - startedLoading;
onPatternLoaded(bitmap, currMotionDrawable.getIntensity(), elapsed > 150);
}
}
});
@ -517,22 +567,20 @@ public class QrActivity extends BaseFragment {
}
currMotionDrawable.setPatternColorFilter(currMotionDrawable.getPatternColor());
float from = 0;
if (patternAlphaAnimator != null) {
from = (float) patternAlphaAnimator.getAnimatedValue();
patternAlphaAnimator.cancel();
}
int[] newQrColors = qrColorsMap.get(newTheme.emoji + (isDarkTheme ? "n" : "d"));
if (withAnimation) {
currMotionDrawable.setAlpha(0);
patternAlphaAnimator = ValueAnimator.ofFloat(from, 1f);
currMotionDrawable.setAlpha(255);
currMotionDrawable.setBackgroundAlpha(0f);
patternAlphaAnimator = ValueAnimator.ofFloat(0f, 1f);
patternAlphaAnimator.addUpdateListener(animation -> {
float progress = (float) animation.getAnimatedValue();
if (prevMotionDrawable != null) {
prevMotionDrawable.setBackgroundAlpha(1f);
prevMotionDrawable.setPatternAlpha(1f - progress);
}
currMotionDrawable.setAlpha((int) (255f * progress));
currMotionDrawable.setBackgroundAlpha(progress);
currMotionDrawable.setPatternAlpha(progress);
// currMotionDrawable.setAlpha((int) (255f * progress));
if (newQrColors != null) {
int color1 = ColorUtils.blendARGB(prevQrColors[0], newQrColors[0], progress);
int color2 = ColorUtils.blendARGB(prevQrColors[1], newQrColors[1], progress);
@ -551,9 +599,25 @@ public class QrActivity extends BaseFragment {
}
prevMotionDrawable = null;
patternAlphaAnimator = null;
currMotionDrawable.setBackgroundAlpha(1f);
currMotionDrawable.setPatternAlpha(1f);
}
@Override
public void onAnimationCancel(Animator animation) {
super.onAnimationCancel(animation);
float progress = (float) ((ValueAnimator) animation).getAnimatedValue();
if (newQrColors != null) {
int color1 = ColorUtils.blendARGB(prevQrColors[0], newQrColors[0], progress);
int color2 = ColorUtils.blendARGB(prevQrColors[1], newQrColors[1], progress);
int color3 = ColorUtils.blendARGB(prevQrColors[2], newQrColors[2], progress);
int color4 = ColorUtils.blendARGB(prevQrColors[3], newQrColors[3], progress);
int[] colors = new int[] { color1, color2, color3, color4 };
System.arraycopy(colors, 0, prevQrColors, 0, 4);
}
}
});
patternAlphaAnimator.setDuration(250);
patternAlphaAnimator.setDuration((int) (250 * duration));
patternAlphaAnimator.start();
} else {
if (newQrColors != null) {
@ -569,7 +633,7 @@ public class QrActivity extends BaseFragment {
animationSettings.applyTheme = false;
animationSettings.onlyTopFragment = true;
animationSettings.resourcesProvider = getResourceProvider();
animationSettings.duration = 250;
animationSettings.duration = (int) (250 * duration);
if (withAnimation) {
resourcesProvider.initColors(prevTheme, isCurrentThemeDark);
} else {
@ -991,8 +1055,9 @@ public class QrActivity extends BaseFragment {
}
setupLightDarkTheme(!forceDark);
});
darkThemeView.setAlpha(0f);
darkThemeView.setVisibility(View.INVISIBLE);
rootLayout.addView(darkThemeView, LayoutHelper.createFrame(44, 44, Gravity.TOP | Gravity.END, 0, 0, 7, 0));
rootLayout.addView(darkThemeView, LayoutHelper.createFrame(44, 44, Gravity.TOP | Gravity.END, 0, -2, 7, 0));
forceDark = !Theme.getActiveTheme().isDark();
setForceDark(Theme.getActiveTheme().isDark(), false);
@ -1068,6 +1133,8 @@ public class QrActivity extends BaseFragment {
}
public void onDataLoaded() {
darkThemeView.setAlpha(0f);
darkThemeView.animate().alpha(1f).setDuration(150).start();
darkThemeView.setVisibility(View.VISIBLE);
progressView.animate().alpha(0f).setListener(new HideViewAfterAnimation(progressView)).setDuration(150).start();
recyclerView.setAlpha(0f);

View File

@ -1022,7 +1022,6 @@
<string name="DeleteReportSpam">Report spam</string>
<string name="TranslateMessage">Translate</string>
<string name="AutomaticTranslation">Automatic Translation</string>
<string name="TranslateMore">Translate more...</string>
<string name="CloseTranslation">Close Translation</string>
<string name="TranslationFailedAlert1">Translation failed. Try again later.</string>
<string name="TranslationFailedAlert2">Translation failed.</string>

View File

@ -5,8 +5,8 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.google.gms:google-services:4.3.10'
}
}
repositories {