Update to 6.2.0 (1988)

(cherry picked from commit feba57ced0)
This commit is contained in:
DrKLO 2020-06-06 14:07:06 +08:00 committed by 世界
parent 2fe194e9b9
commit 3c94320b99
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
18 changed files with 256 additions and 91 deletions

View File

@ -1238,6 +1238,16 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
mState.mStructureChanged = true;
}
public void prepareForFastScroll() {
stopScroll();
removeAndRecycleViews();
mAdapterHelper.reset();
mRecycler.onAdapterChanged(mAdapter, mAdapter, false);
mState.mStructureChanged = true;
mChildHelper.removeAllViewsUnfiltered();
mRecycler.updateViewCacheSize();
}
/**
* Retrieves the previously set adapter or null if no adapter is set.
*
@ -1562,7 +1572,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
if (state == mScrollState) {
return;
}
if (DEBUG) {
if (false) {
Log.d(TAG, "setting scroll state to " + state + " from " + mScrollState,
new Exception());
}

View File

@ -257,8 +257,22 @@ public class FileRefController extends BaseController {
return;
}
String cacheKey = locationKey;
if (parentObject instanceof String) {
String string = (String) parentObject;
if ("wallpaper".equals(string)) {
cacheKey = "wallpaper";
} else if (string.startsWith("gif")) {
cacheKey = "gif";
} else if ("recent".equals(string)) {
cacheKey = "recent";
} else if ("fav".equals(string)) {
cacheKey = "fav";
}
}
cleanupCache();
CachedResult cachedResult = getCachedResponse(locationKey);
CachedResult cachedResult = getCachedResponse(cacheKey);
if (cachedResult != null) {
if (!onRequestComplete(locationKey, parentKey, cachedResult.response, false)) {
responseCache.remove(locationKey);
@ -575,6 +589,16 @@ public class FileRefController extends BaseController {
private boolean onRequestComplete(String locationKey, String parentKey, TLObject response, boolean cache) {
boolean found = false;
String cacheKey = parentKey;
if (response instanceof TLRPC.TL_account_wallPapers) {
cacheKey = "wallpaper";
} else if (response instanceof TLRPC.TL_messages_savedGifs) {
cacheKey = "gif";
} else if (response instanceof TLRPC.TL_messages_recentStickers) {
cacheKey = "recent";
} else if (response instanceof TLRPC.TL_messages_favedStickers) {
cacheKey = "fav";
}
if (parentKey != null) {
ArrayList<Requester> arrayList = parentRequester.get(parentKey);
if (arrayList != null) {
@ -588,7 +612,7 @@ public class FileRefController extends BaseController {
}
}
if (found) {
putReponseToCache(parentKey, response);
putReponseToCache(cacheKey, response);
}
parentRequester.remove(parentKey);
}
@ -600,6 +624,7 @@ public class FileRefController extends BaseController {
if (arrayList == null) {
return found;
}
cacheKey = locationKey;
for (int q = 0, N = arrayList.size(); q < N; q++) {
Requester requester = arrayList.get(q);
if (requester.completed) {
@ -793,7 +818,7 @@ public class FileRefController extends BaseController {
}
locationRequester.remove(locationKey);
if (found) {
putReponseToCache(locationKey, response);
putReponseToCache(cacheKey, response);
}
return found;
}

View File

@ -128,8 +128,8 @@ public class MediaDataController extends BaseController {
public static final int TYPE_FEATURED = 3;
public static final int TYPE_EMOJI = 4;
private ArrayList<TLRPC.TL_messages_stickerSet>[] stickerSets = new ArrayList[]{new ArrayList<>(), new ArrayList<>(), new ArrayList(0), new ArrayList(), new ArrayList()};
private LongSparseArray<TLRPC.Document>[] stickersByIds = new LongSparseArray[]{new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray(), new LongSparseArray(), new LongSparseArray()};
private ArrayList<TLRPC.TL_messages_stickerSet>[] stickerSets = new ArrayList[]{new ArrayList<>(), new ArrayList<>(), new ArrayList<>(0), new ArrayList<>(), new ArrayList<>()};
private LongSparseArray<TLRPC.Document>[] stickersByIds = new LongSparseArray[]{new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>()};
private LongSparseArray<TLRPC.TL_messages_stickerSet> stickerSetsById = new LongSparseArray<>();
private LongSparseArray<TLRPC.TL_messages_stickerSet> installedStickerSetsById = new LongSparseArray<>();
private LongSparseArray<TLRPC.TL_messages_stickerSet> groupStickerSets = new LongSparseArray<>();
@ -683,7 +683,7 @@ public class MediaDataController extends BaseController {
return value != null ? value : "";
}
private static int calcDocumentsHash(ArrayList<TLRPC.Document> arrayList) {
public static int calcDocumentsHash(ArrayList<TLRPC.Document> arrayList) {
if (arrayList == null) {
return 0;
}
@ -5079,7 +5079,7 @@ public class MediaDataController extends BaseController {
}
ArrayList<String> recentEmoji = new ArrayList<>(Emoji.recentEmoji);
getMessagesStorage().getStorageQueue().postRunnable(() -> {
ArrayList<KeywordResult> result = new ArrayList();
ArrayList<KeywordResult> result = new ArrayList<>();
HashMap<String, Boolean> resultMap = new HashMap<>();
String alias = null;
try {

View File

@ -9378,7 +9378,7 @@ public class MessagesController extends BaseController implements NotificationCe
dialog.pinnedNum = 0;
}
sortDialogs(null);
if (!pin && dialogs.get(dialogs.size() - 1) == dialog && !dialogsEndReached.get(folderId)) {
if (!pin && !dialogs.isEmpty() && dialogs.get(dialogs.size() - 1) == dialog && !dialogsEndReached.get(folderId)) {
dialogs.remove(dialogs.size() - 1);
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);

View File

@ -356,7 +356,7 @@ public class NotificationCenter {
ArrayList<NotificationCenterDelegate> objects = observers.get(id);
if (objects != null && !objects.isEmpty()) {
for (int a = 0; a < objects.size(); a++) {
NotificationCenterDelegate obj = objects.get(a);;
NotificationCenterDelegate obj = objects.get(a);
obj.didReceivedNotification(id, currentAccount, args);
}
}

View File

@ -470,7 +470,10 @@ public class DrawerLayoutContainer extends FrameLayout {
}
inLayout = false;
} else {
AndroidUtilities.displaySize.y = heightSize - AndroidUtilities.statusBarHeight;
int newSize = heightSize - AndroidUtilities.statusBarHeight;
if (newSize > 0 && newSize < 4096) {
AndroidUtilities.displaySize.y = newSize;
}
}
final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21;

View File

@ -13,6 +13,7 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.SystemClock;
@ -23,13 +24,16 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.ReplacementSpan;
import android.view.HapticFeedbackConstants;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.ImageLocation;
@ -61,6 +65,34 @@ import java.util.ArrayList;
public class DialogCell extends BaseCell {
public static class FixedWidthSize extends ReplacementSpan {
private int width;
public FixedWidthSize(int w) {
width = w;
}
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
if (fm == null) {
fm = paint.getFontMetricsInt();
}
if (fm != null) {
int h = fm.descent - fm.ascent;
fm.bottom = fm.descent = 1 - h;
fm.top = fm.ascent = -1;
}
return width;
}
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
}
}
public static class CustomDialog {
public String name;
public String message;
@ -116,6 +148,12 @@ public class DialogCell extends BaseCell {
private float currentRevealBounceProgress;
private float archiveBackgroundProgress;
private static String[] newLine = new String[]{"\n"};
private static String[] space = new String[]{" "};
private boolean hasMessageThumb;
private ImageReceiver thumbImage = new ImageReceiver(this);
private ImageReceiver avatarImage = new ImageReceiver(this);
private AvatarDrawable avatarDrawable = new AvatarDrawable();
private boolean animatingArchiveAvatar;
@ -223,6 +261,7 @@ public class DialogCell extends BaseCell {
Theme.createDialogsResources(context);
avatarImage.setRoundRadius(AndroidUtilities.dp(28));
thumbImage.setRoundRadius(AndroidUtilities.dp(2));
useForceThreeLines = forceThreeLines;
if (needCheck) {
@ -308,6 +347,7 @@ public class DialogCell extends BaseCell {
attachedToWindow = false;
reorderIconProgress = drawPin && drawReorder ? 1.0f : 0.0f;
avatarImage.onDetachedFromWindow();
thumbImage.onDetachedFromWindow();
if (translationDrawable != null) {
translationDrawable.stop();
translationDrawable.setProgress(0.0f);
@ -321,6 +361,7 @@ public class DialogCell extends BaseCell {
protected void onAttachedToWindow() {
super.onAttachedToWindow();
avatarImage.onAttachedToWindow();
thumbImage.onAttachedToWindow();
resetPinnedArchiveState();
}
@ -420,6 +461,7 @@ public class DialogCell extends BaseCell {
}
public void buildLayout() {
int thumbSize;
if (useForceThreeLines || SharedConfig.useThreeLinesLayout) {
Theme.dialogs_namePaint[1].setTextSize(AndroidUtilities.dp(16));
Theme.dialogs_nameEncryptedPaint[1].setTextSize(AndroidUtilities.dp(16));
@ -428,6 +470,7 @@ public class DialogCell extends BaseCell {
Theme.dialogs_messagePaint[1].setColor(Theme.dialogs_messagePaint[1].linkColor = Theme.getColor(Theme.key_chats_message_threeLines));
paintIndex = 1;
thumbSize = 18;
} else {
Theme.dialogs_namePaint[0].setTextSize(AndroidUtilities.dp(17));
Theme.dialogs_nameEncryptedPaint[0].setTextSize(AndroidUtilities.dp(17));
@ -436,6 +479,7 @@ public class DialogCell extends BaseCell {
Theme.dialogs_messagePaint[0].setColor(Theme.dialogs_messagePaint[0].linkColor = Theme.getColor(Theme.key_chats_message));
paintIndex = 0;
thumbSize = 19;
}
currentDialogFolderDialogsCount = 0;
@ -459,6 +503,8 @@ public class DialogCell extends BaseCell {
drawVerified = false;
drawScam = false;
drawPinBackground = false;
hasMessageThumb = false;
int offsetName = 0;
boolean showChecks = !UserObject.isUserSelf(user) && !useMeForMyMessages;
boolean drawTime = true;
@ -585,14 +631,12 @@ public class DialogCell extends BaseCell {
if (customDialog.sent) {
drawCheck1 = true;
drawCheck2 = true;
drawClock = false;
drawError = false;
} else {
drawCheck1 = false;
drawCheck2 = false;
drawClock = false;
drawError = false;
}
drawClock = false;
drawError = false;
nameString = customDialog.name;
} else {
if (useForceThreeLines || SharedConfig.useThreeLinesLayout) {
@ -800,6 +844,20 @@ public class DialogCell extends BaseCell {
}
currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex];
} else {
boolean needEmoji = true;
if (BuildVars.DEBUG_VERSION && encryptedChat == null && !message.needDrawBluredPreview() && (message.isPhoto() || message.isNewGif() || message.isVideo())) {
TLRPC.PhotoSize smallThumb = FileLoader.getClosestPhotoSizeWithSize(message.photoThumbs, 40);
TLRPC.PhotoSize bigThumb = FileLoader.getClosestPhotoSizeWithSize(message.photoThumbs, AndroidUtilities.getPhotoSize());
if (smallThumb == bigThumb) {
bigThumb = null;
}
if (smallThumb != null) {
hasMessageThumb = true;
//TODO respect autodownload settings?
thumbImage.setImage(ImageLocation.getForObject(bigThumb, message.photoThumbsObject), "20_20", ImageLocation.getForObject(smallThumb, message.photoThumbsObject), "20_20", null, message, 0);
needEmoji = false;
}
}
if (chat != null && chat.id > 0 && fromChat == null) {
if (message.isOutOwner()) {
messageNameString = LocaleController.getString("FromYou", R.string.FromYou);
@ -826,7 +884,9 @@ public class DialogCell extends BaseCell {
mess = mess.substring(0, 150);
}
String emoji;
if (message.isVideo()) {
if (!needEmoji) {
emoji = "";
} else if (message.isVideo()) {
emoji = "\uD83D\uDCF9 ";
} else if (message.isVoice()) {
emoji = "\uD83C\uDFA4 ";
@ -879,14 +939,25 @@ public class DialogCell extends BaseCell {
} else {
stringBuilder = SpannableStringBuilder.valueOf("");
}
int thumbInsertIndex = 0;
if (!useForceThreeLines && !SharedConfig.useThreeLinesLayout || currentDialogFolderId != 0 && stringBuilder.length() > 0) {
try {
stringBuilder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chats_nameMessage)), 0, messageNameString.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chats_nameMessage)), 0, thumbInsertIndex = messageNameString.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
offsetName = thumbInsertIndex;
} catch (Exception e) {
FileLog.e(e);
}
}
messageString = Emoji.replaceEmoji(stringBuilder, Theme.dialogs_messagePaint[paintIndex].getFontMetricsInt(), AndroidUtilities.dp(20), false);
if (hasMessageThumb) {
if (!(messageString instanceof SpannableStringBuilder)) {
messageString = new SpannableStringBuilder(messageString);
}
checkMessage = false;
SpannableStringBuilder builder = (SpannableStringBuilder) messageString;
builder.insert(thumbInsertIndex, " ");
builder.setSpan(new FixedWidthSize(AndroidUtilities.dp(thumbSize + 6)), thumbInsertIndex, thumbInsertIndex + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
} else {
if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && message.messageOwner.media.photo instanceof TLRPC.TL_photoEmpty && message.messageOwner.media.ttl_seconds != 0) {
messageString = LocaleController.getString("AttachPhotoExpired", R.string.AttachPhotoExpired);
@ -894,7 +965,9 @@ public class DialogCell extends BaseCell {
messageString = LocaleController.getString("AttachVideoExpired", R.string.AttachVideoExpired);
} else if (message.caption != null) {
String emoji;
if (message.isVideo()) {
if (!needEmoji) {
emoji = "";
} else if (message.isVideo()) {
emoji = "\uD83D\uDCF9 ";
} else if (message.isVoice()) {
emoji = "\uD83C\uDFA4 ";
@ -921,6 +994,20 @@ public class DialogCell extends BaseCell {
currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex];
}
}
if (hasMessageThumb) {
if (messageString.length() > 150) {
messageString = messageString.subSequence(0, 150);
}
messageString = TextUtils.replace(messageString, newLine, space);
if (!(messageString instanceof SpannableStringBuilder)) {
messageString = new SpannableStringBuilder(messageString);
}
checkMessage = false;
SpannableStringBuilder builder = (SpannableStringBuilder) messageString;
builder.insert(0, " ");
builder.setSpan(new FixedWidthSize(AndroidUtilities.dp(thumbSize + 6)), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Emoji.replaceEmoji(builder, Theme.dialogs_messagePaint[paintIndex].getFontMetricsInt(), AndroidUtilities.dp(17), false);
}
}
}
if (currentDialogFolderId != 0) {
@ -1023,6 +1110,7 @@ public class DialogCell extends BaseCell {
}
if (!TextUtils.isEmpty(messagesController.promoPsaMessage)) {
messageString = messagesController.promoPsaMessage;
hasMessageThumb = false;
}
}
}
@ -1147,6 +1235,7 @@ public class DialogCell extends BaseCell {
int messageWidth;
int avatarLeft;
int avatarTop;
int thumbLeft;
if (useForceThreeLines || SharedConfig.useThreeLinesLayout) {
avatarTop = AndroidUtilities.dp(11);
messageNameTop = AndroidUtilities.dp(32);
@ -1157,14 +1246,17 @@ public class DialogCell extends BaseCell {
checkDrawTop = AndroidUtilities.dp(13);
messageWidth = getMeasuredWidth() - AndroidUtilities.dp(72 + 21);
if (!LocaleController.isRTL) {
messageLeft = messageNameLeft = AndroidUtilities.dp(72 + 6);
avatarLeft = AndroidUtilities.dp(10);
} else {
if (LocaleController.isRTL) {
messageLeft = messageNameLeft = AndroidUtilities.dp(16);
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(66);
thumbLeft = avatarLeft - AndroidUtilities.dp(13 + 18);
} else {
messageLeft = messageNameLeft = AndroidUtilities.dp(72 + 6);
avatarLeft = AndroidUtilities.dp(10);
thumbLeft = avatarLeft + AndroidUtilities.dp(56 + 13);
}
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
thumbImage.setImageCoords(thumbLeft, avatarTop + AndroidUtilities.dp(31), AndroidUtilities.dp(18), AndroidUtilities.dp(18));
} else {
avatarTop = AndroidUtilities.dp(9);
messageNameTop = AndroidUtilities.dp(31);
@ -1175,14 +1267,17 @@ public class DialogCell extends BaseCell {
checkDrawTop = AndroidUtilities.dp(17);
messageWidth = getMeasuredWidth() - AndroidUtilities.dp(72 + 23);
if (!LocaleController.isRTL) {
messageLeft = messageNameLeft = AndroidUtilities.dp(72 + 4);
avatarLeft = AndroidUtilities.dp(10);
} else {
if (LocaleController.isRTL) {
messageLeft = messageNameLeft = AndroidUtilities.dp(22);
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(64);
thumbLeft = avatarLeft - AndroidUtilities.dp(11 + thumbSize);
} else {
messageLeft = messageNameLeft = AndroidUtilities.dp(72 + 4);
avatarLeft = AndroidUtilities.dp(10);
thumbLeft = avatarLeft + AndroidUtilities.dp(56 + 11);
}
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(54), AndroidUtilities.dp(54));
thumbImage.setImageCoords(thumbLeft, avatarTop + AndroidUtilities.dp(30), AndroidUtilities.dp(thumbSize), AndroidUtilities.dp(thumbSize));
}
if (drawPin) {
if (!LocaleController.isRTL) {
@ -1272,10 +1367,12 @@ public class DialogCell extends BaseCell {
FileLog.e(e);
}
messageTop = AndroidUtilities.dp(32 + 19);
thumbImage.setImageY(avatarTop + AndroidUtilities.dp(40));
} else {
messageNameLayout = null;
if (useForceThreeLines || SharedConfig.useThreeLinesLayout) {
messageTop = AndroidUtilities.dp(32);
thumbImage.setImageY(avatarTop + AndroidUtilities.dp(21));
} else {
messageTop = AndroidUtilities.dp(39);
}
@ -1293,8 +1390,14 @@ public class DialogCell extends BaseCell {
messageStringFinal = messageString;
}
if (useForceThreeLines || SharedConfig.useThreeLinesLayout) {
if (hasMessageThumb && messageNameString != null) {
messageWidth += AndroidUtilities.dp(4);
}
messageLayout = StaticLayoutEx.createStaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, AndroidUtilities.dp(1), false, TextUtils.TruncateAt.END, messageWidth, messageNameString != null ? 1 : 2);
} else {
if (hasMessageThumb) {
messageWidth += AndroidUtilities.dp(4);
}
messageLayout = new StaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
} catch (Exception e) {
@ -1375,6 +1478,23 @@ public class DialogCell extends BaseCell {
messageNameLeft -= messageNameLayout.getLineLeft(0);
}
}
if (messageLayout != null && hasMessageThumb) {
try {
int textLen = messageLayout.getText().length();
if (offsetName >= textLen) {
offsetName = textLen - 1;
}
float x1 = messageLayout.getPrimaryHorizontal(offsetName);
float x2 = messageLayout.getPrimaryHorizontal(offsetName + 1);
int offset = (int) Math.ceil(Math.min(x1, x2));
if (offset != 0) {
offset += AndroidUtilities.dp(3);
}
thumbImage.setImageX(messageLeft + offset);
} catch (Exception e) {
FileLog.e(e);
}
}
}
public boolean isPointInsideAvatar(float x, float y) {
@ -1486,6 +1606,7 @@ public class DialogCell extends BaseCell {
dialogMuted = customDialog.muted;
avatarDrawable.setInfo(customDialog.id, customDialog.name, null);
avatarImage.setImage(null, "50_50", avatarDrawable, null, 0);
thumbImage.setImageBitmap((BitmapDrawable) null);
} else {
if (isDialogCell) {
TLRPC.Dialog dialog = MessagesController.getInstance(currentAccount).dialogs_dict.get(currentDialogId);
@ -2063,6 +2184,10 @@ public class DialogCell extends BaseCell {
avatarImage.draw(canvas);
}
if (hasMessageThumb) {
thumbImage.draw(canvas);
}
if (animatingArchiveAvatar) {
canvas.restore();
}

View File

@ -11504,8 +11504,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
canShowPagedownButton = false;
updatePagedownButtonVisibility(true);
showMentionDownButton(false, true);
removeUnreadPlane(true);
if (updated && chatAdapter != null) {
removeUnreadPlane(true);
chatAdapter.notifyDataSetChanged();
}
} else if (id == NotificationCenter.messagesDeleted) {
@ -11566,7 +11566,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
addToSelectedMessages(obj, false, updatedSelectedLast = (a == size - 1));
}
MessageObject removed = messages.remove(index);
removedIndexes.add(chatAdapter.messagesStartRow + index);
if (chatAdapter != null) {
removedIndexes.add(chatAdapter.messagesStartRow + index);
}
if (removed.getGroupId() != 0) {
MessageObject.GroupedMessages groupedMessages = groupedMessagesMap.get(removed.getGroupId());
if (groupedMessages != null) {
@ -11589,7 +11591,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messagesByDays.remove(obj.dateKey);
if (index >= 0 && index < messages.size()) {
messages.remove(index);
removedIndexes.add(chatAdapter.messagesStartRow + index);
if (chatAdapter != null) {
removedIndexes.add(chatAdapter.messagesStartRow + index);
}
}
}
}
@ -11664,22 +11668,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updatePagedownButtonVisibility(true);
showMentionDownButton(false, true);
}
if (chatAdapter != null) {
if (updated) {
int count = removedIndexes.size();
for (int a = 0; a < count; a++) {
if (updated) {
if (chatAdapter != null) {
for (int a = 0, N = removedIndexes.size(); a < N; a++) {
chatAdapter.notifyItemRemoved(removedIndexes.get(a));
}
updateVisibleRows();
} else {
first_unread_id = 0;
last_message_id = 0;
createUnreadMessageAfterId = 0;
removeMessageObject(unreadMessageObject);
unreadMessageObject = null;
if (pagedownButtonCounter != null) {
pagedownButtonCounter.setVisibility(View.INVISIBLE);
}
}
updateVisibleRows();
} else {
first_unread_id = 0;
last_message_id = 0;
createUnreadMessageAfterId = 0;
removeMessageObject(unreadMessageObject);
unreadMessageObject = null;
if (pagedownButtonCounter != null) {
pagedownButtonCounter.setVisibility(View.INVISIBLE);
}
}
if (updateScheduled) {
@ -12881,7 +12884,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (dayArr.isEmpty()) {
messagesByDays.remove(old.dateKey);
messages.remove(index);
chatAdapter.notifyItemRemoved(chatAdapter.messagesStartRow);
chatAdapter.notifyItemRemoved(chatAdapter.messagesStartRow + index);
}
}
}

View File

@ -144,6 +144,10 @@ public class AudioVisualizerDrawable {
float enterProgress = current[7];
float radiusProgress = current[6] * current[0];
if (enterProgress == 0 && radiusProgress == 0) {
return;
}
// float idleProgress = radiusProgress > 0.4f ? 0 : (1f - radiusProgress / 0.4f);
for (int i = 0; i < 3; i++) {

View File

@ -141,7 +141,7 @@ public class BlurBehindDrawable {
behindView.draw(blurCanvas[i]);
}
if (i == ADJUST_PAN_TRANSLATION_CONTENT) {
if (backDrawable != null && i == ADJUST_PAN_TRANSLATION_CONTENT) {
Rect oldBounds = backDrawable.getBounds();
backDrawable.setBounds(0, 0, behindView.getMeasuredWidth(), behindView.getMeasuredHeight());
backDrawable.draw(blurCanvas[i]);

View File

@ -3404,11 +3404,13 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
private void updateRecentGifs() {
final boolean wasEmpty = recentGifs.isEmpty();
int prevHash = MediaDataController.calcDocumentsHash(recentGifs);
recentGifs = MediaDataController.getInstance(currentAccount).getRecentGifs();
int newHash = MediaDataController.calcDocumentsHash(recentGifs);
if (gifTabs != null && wasEmpty && !recentGifs.isEmpty() || !wasEmpty && recentGifs.isEmpty()) {
updateGifTabs();
}
if (gifAdapter != null) {
if (prevHash != newHash && gifAdapter != null) {
gifAdapter.notifyDataSetChanged();
}
}

View File

@ -10,6 +10,7 @@ import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildVars;
import org.telegram.ui.Cells.ChatMessageCell;
@ -74,7 +75,7 @@ public class RecyclerAnimationScrollHelper {
oldStableIds.clear();
for (int i = 0; i < n; i++) {
View child = recyclerView.getChildAt(0);
View child = recyclerView.getChildAt(i);
oldViews.add(child);
int childPosition = layoutManager.getPosition(child);
positionToOldView.put(childPosition, child);
@ -88,12 +89,9 @@ public class RecyclerAnimationScrollHelper {
if (child instanceof ChatMessageCell) {
((ChatMessageCell) child).setAnimationRunning(true, true);
}
layoutManager.removeAndRecycleView(child, recyclerView.mRecycler);
}
recyclerView.mRecycler.clear();
recyclerView.getRecycledViewPool().clear();
recyclerView.prepareForFastScroll();
AnimatableAdapter animatableAdapter = null;
if (adapter instanceof AnimatableAdapter) {
@ -162,9 +160,9 @@ public class RecyclerAnimationScrollHelper {
if (bot > oldH) oldH = bot;
if (topl < oldT) oldT = topl;
if (view.getParent() == null) {
recyclerView.addView(view);
layoutManager.ignoreView(view);
}
if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).setAnimationRunning(true, true);
@ -179,8 +177,6 @@ public class RecyclerAnimationScrollHelper {
scrollLength = finalHeight + (scrollDown ? -top : bottom - recyclerView.getHeight());
}
if (animator != null) {
animator.removeAllListeners();
animator.cancel();
@ -229,6 +225,7 @@ public class RecyclerAnimationScrollHelper {
((ChatMessageCell) view).setAnimationRunning(false, true);
}
view.setTranslationY(0);
layoutManager.stopIgnoringView(view);
recyclerView.removeView(view);
}
@ -242,6 +239,10 @@ public class RecyclerAnimationScrollHelper {
if (recyclerView.mChildHelper.getHiddenChildCount() != 0) {
throw new RuntimeException("hidden child count must be 0");
}
if (recyclerView.getCachedChildCount() != 0) {
throw new RuntimeException("recycler cached child count must be 0");
}
}
int n = recyclerView.getChildCount();

View File

@ -502,7 +502,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} else if (view instanceof ContextLinkCell) {
ContextLinkCell cell = (ContextLinkCell) view;
MessageObject message = (MessageObject) cell.getParentObject();
if (message.getId() == messageObject.getId()) {
if (message != null && messageObject != null && message.getId() == messageObject.getId()) {
imageReceiver = cell.getPhotoImage();
cell.getLocationInWindow(coords);
}

View File

@ -614,7 +614,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
stickerImageView = new BackupImageView(context);
stickerImageView.setAspectFit(true);
stickerImageView.setLayerNum(5);
stickerImageView.setLayerNum(7);
stickerPreviewLayout.addView(stickerImageView);
stickerEmojiTextView = new TextView(context);
@ -1062,7 +1062,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
super.onMeasure(MeasureSpec.makeMeasureSpec(itemSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(82), MeasureSpec.EXACTLY));
}
};
cell.getImageView().setLayerNum(5);
cell.getImageView().setLayerNum(7);
view = cell;
break;
case 1:

View File

@ -25,7 +25,7 @@ import org.telegram.ui.ActionBar.ThemeDescription;
import java.util.ArrayList;
public class TrendingStickersAlert extends BottomSheet implements TrendingStickersLayout.AlertDelegate {
public class TrendingStickersAlert extends BottomSheet {
private final int topOffset = AndroidUtilities.dp(12);
@ -45,7 +45,6 @@ public class TrendingStickersAlert extends BottomSheet implements TrendingSticke
useSmoothKeyboard = true;
layout = trendingStickersLayout;
layout.setAlertDelegate(this);
layout.setParentFragment(parentFragment);
layout.setOnScrollListener(new RecyclerListView.OnScrollListener() {
@ -86,7 +85,6 @@ public class TrendingStickersAlert extends BottomSheet implements TrendingSticke
setHeavyOperationsEnabled(true);
}
@Override
public void setHeavyOperationsEnabled(boolean enabled) {
NotificationCenter.getGlobalInstance().postNotificationName(enabled ? NotificationCenter.startAllHeavyOperations : NotificationCenter.stopAllHeavyOperations, 2);
}

View File

@ -79,10 +79,6 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
}
}
public interface AlertDelegate {
void setHeavyOperationsEnabled(boolean enabled);
}
private final int currentAccount = UserConfig.selectedAccount;
private final Delegate delegate;
@ -100,7 +96,6 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
private BaseFragment parentFragment;
private RecyclerListView.OnScrollListener onScrollListener;
private AlertDelegate alertDelegate;
private int topOffset;
private boolean motionEventCatchedByListView;
@ -361,23 +356,7 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
} else {
stickersAlertDelegate = null;
}
final StickersAlert stickersAlert = new StickersAlert(getContext(), parentFragment, inputStickerSet, null, stickersAlertDelegate) {
@Override
public void show() {
super.show();
if (alertDelegate != null) {
alertDelegate.setHeavyOperationsEnabled(true);
}
}
@Override
public void dismiss() {
super.dismiss();
if (alertDelegate != null) {
alertDelegate.setHeavyOperationsEnabled(false);
}
}
};
final StickersAlert stickersAlert = new StickersAlert(getContext(), parentFragment, inputStickerSet, null, stickersAlertDelegate);
stickersAlert.setShowTooltipWhenToggle(false);
stickersAlert.setInstallDelegate(new StickersAlert.StickersAlertInstallDelegate() {
@Override
@ -434,10 +413,6 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
this.onScrollListener = onScrollListener;
}
public void setAlertDelegate(AlertDelegate alertDelegate) {
this.alertDelegate = alertDelegate;
}
public void setParentFragment(BaseFragment parentFragment) {
this.parentFragment = parentFragment;
}

View File

@ -655,13 +655,14 @@ public class VideoPlayer implements ExoPlayer.EventListener, SimpleExoPlayer.Vid
private class VisualizerBufferSink implements TeeAudioProcessor.AudioBufferSink {
private final int BUFFER_SIZE = 1024;
private final int MAX_BUFFER_SIZE = BUFFER_SIZE * 8;
FourierTransform.FFT fft = new FourierTransform.FFT(BUFFER_SIZE, 48000);
float[] real = new float[BUFFER_SIZE];
ByteBuffer byteBuffer;
int position = 0;
public VisualizerBufferSink() {
byteBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE * 8);
byteBuffer = ByteBuffer.allocateDirect(MAX_BUFFER_SIZE);
byteBuffer.position(0);
}
@ -694,11 +695,22 @@ public class VideoPlayer implements ExoPlayer.EventListener, SimpleExoPlayer.Vid
return;
}
byteBuffer.put(buffer);
position += buffer.limit();
int len = buffer.limit();
if (len > MAX_BUFFER_SIZE) {
audioUpdateHandler.removeCallbacksAndMessages(null);
audioVisualizerDelegate.onVisualizerUpdate(false, true, null);
return;
// len = MAX_BUFFER_SIZE;
// byte[] bytes = new byte[BUFFER_SIZE];
// buffer.get(bytes);
// byteBuffer.put(bytes, 0, BUFFER_SIZE);
} else {
byteBuffer.put(buffer);
}
position += len;
if (position >= BUFFER_SIZE) {
int len = BUFFER_SIZE;
len = BUFFER_SIZE;
byteBuffer.position(0);
for (int i = 0; i < len; i++) {
real[i] = (byteBuffer.getShort()) / 32768.0F;

View File

@ -2886,8 +2886,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
heightSize = AndroidUtilities.displaySize.y;
}
heightSize += AndroidUtilities.statusBarHeight;
} else {
int insetBottom = insets.getStableInsetBottom();
if (insetBottom >= 0 && AndroidUtilities.statusBarHeight >= 0) {
int newSize = heightSize - AndroidUtilities.statusBarHeight - insets.getStableInsetBottom();
if (newSize > 0 && newSize < 4096) {
AndroidUtilities.displaySize.y = newSize;
}
}
}
AndroidUtilities.displaySize.y = heightSize - AndroidUtilities.statusBarHeight - insets.getStableInsetBottom();
heightSize -= insets.getSystemWindowInsetBottom();
} else {
if (heightSize > AndroidUtilities.displaySize.y) {