Merge official v8.5.1

This commit is contained in:
luvletter2333 2022-02-04 11:38:30 +08:00
commit be79f8f6de
14 changed files with 170 additions and 70 deletions

View File

@ -10,8 +10,8 @@ if (System.getenv("DEBUG_BUILD") == "true") {
verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1").trim()
}
def officialVer = "8.4.4"
def officialCode = 2538
def officialVer = "8.5.1"
def officialCode = 2551
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
@ -317,6 +317,7 @@ android {
}
}
<<<<<<< HEAD
tasks.all { task ->
if (((task.name.endsWith("Ndk") || task.name.startsWith("generateJsonModel") || task.name.startsWith("externalNativeBuild"))) && !(task.name.contains("Debug") || task.name.contains("Foss") || task.name.contains("Fdroid"))) {
task.enabled = false
@ -328,6 +329,9 @@ android {
enabled = false
}
}
=======
defaultConfig.versionCode = 2551
>>>>>>> official/master
applicationVariants.all { variant ->
variant.outputs.all { output ->
@ -335,6 +339,30 @@ android {
}
}
<<<<<<< HEAD
=======
variantFilter { variant ->
def names = variant.flavors*.name
if (variant.buildType.name != "release" && !names.contains("afat")) {
setIgnore(true)
}
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.5.1"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
externalNativeBuild {
cmake {
version '3.10.2'
arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-16', "-j=16"
}
}
}
>>>>>>> official/master
}
def okHttpVersion = "5.0.0-alpha.2"

View File

@ -1151,6 +1151,11 @@ extern "C" JNIEXPORT void JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
}
}
uint32_t premultiply_channel_value(const uint32_t pixel, const uint8_t offset, const float normalizedAlpha) {
auto multipliedValue = ((pixel >> offset) & 0xFF) * normalizedAlpha;
return ((uint32_t)std::min(multipliedValue, 255.0f)) << offset;
}
static inline void writeFrameToBitmap(JNIEnv *env, VideoInfo *info, jintArray data, jobject bitmap, jint stride) {
jint *dataArr = env->GetIntArrayElements(data, 0);
int32_t wantedWidth;
@ -1174,15 +1179,15 @@ static inline void writeFrameToBitmap(JNIEnv *env, VideoInfo *info, jintArray da
void *pixels;
if (AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0) {
if (info->sws_ctx == nullptr) {
if (info->frame->format > AV_PIX_FMT_NONE && info->frame->format < AV_PIX_FMT_NB) {
if (info->frame->format > AV_PIX_FMT_NONE && info->frame->format < AV_PIX_FMT_NB && !info->frame->format == AV_PIX_FMT_YUVA420P) {
info->sws_ctx = sws_getContext(info->frame->width, info->frame->height, (AVPixelFormat) info->frame->format, bitmapWidth, bitmapHeight, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL);
} else if (info->video_dec_ctx->pix_fmt > AV_PIX_FMT_NONE && info->video_dec_ctx->pix_fmt < AV_PIX_FMT_NB) {
} else if (info->video_dec_ctx->pix_fmt > AV_PIX_FMT_NONE && info->video_dec_ctx->pix_fmt < AV_PIX_FMT_NB && !info->frame->format == AV_PIX_FMT_YUVA420P) {
info->sws_ctx = sws_getContext(info->video_dec_ctx->width, info->video_dec_ctx->height, info->video_dec_ctx->pix_fmt, bitmapWidth, bitmapHeight, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL);
}
}
if (info->sws_ctx == nullptr || ((intptr_t) pixels) % 16 != 0) {
if (info->frame->format == AV_PIX_FMT_YUVA420P) {
libyuv::I420AlphaToARGBMatrix(info->frame->data[0], info->frame->linesize[0], info->frame->data[2], info->frame->linesize[2], info->frame->data[1], info->frame->linesize[1], info->frame->data[3], info->frame->linesize[3], (uint8_t *) pixels, bitmapWidth * 4, &libyuv::kYvuI601Constants, bitmapWidth, bitmapHeight, 50);
libyuv::I420AlphaToARGBMatrix(info->frame->data[0], info->frame->linesize[0], info->frame->data[2], info->frame->linesize[2], info->frame->data[1], info->frame->linesize[1], info->frame->data[3], info->frame->linesize[3], (uint8_t *) pixels, bitmapWidth * 4, &libyuv::kYvuI601Constants, bitmapWidth, bitmapHeight, 1);
} else if (info->frame->format == AV_PIX_FMT_YUV444P) {
libyuv::H444ToARGB(info->frame->data[0], info->frame->linesize[0], info->frame->data[2], info->frame->linesize[2], info->frame->data[1], info->frame->linesize[1], (uint8_t *) pixels, bitmapWidth * 4, bitmapWidth, bitmapHeight);
} else if (info->frame->format == AV_PIX_FMT_YUV420P || info->frame->format == AV_PIX_FMT_YUVJ420P) {
@ -1200,17 +1205,6 @@ static inline void writeFrameToBitmap(JNIEnv *env, VideoInfo *info, jintArray da
info->dst_linesize[0] = stride;
sws_scale(info->sws_ctx, info->frame->data, info->frame->linesize, 0,
info->frame->height, dst_data, info->dst_linesize);
if (info->frame->format == AV_PIX_FMT_YUVA420P) {
auto pixelArr = ((uint32_t *) pixels);
for (int i = 0; i < bitmapWidth; i++) {
for (int j = 0; j < bitmapHeight; j++) {
int a = RGB8888_A(pixelArr[j * bitmapWidth + i]);
if (a < 125) {
pixelArr[j * bitmapWidth + i] = 0;
}
}
}
}
}
}
AndroidBitmap_unlockPixels(env, bitmap);

View File

@ -211,7 +211,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
private Drawable currentMediaDrawable;
private BitmapShader mediaShader;
private boolean useRoundForThumb;
private boolean useRoundForThumb = true;
private Drawable staticThumbDrawable;
@ -277,6 +277,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
private int animateFromIsPressed;
private String uniqKeyPrefix;
private ArrayList<Runnable> loadingOperations = new ArrayList<>();
private boolean attachedToWindow;
public ImageReceiver() {
this(null);
@ -576,16 +577,12 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
legacyBitmap.recycle();
legacyBitmap = null;
}
if (useRoundForThumb && staticThumbDrawable != null) {
updateDrawableRadius(staticThumbDrawable);
}
currentAlpha = 1.0f;
previousAlpha = 1f;
if (staticThumbDrawable instanceof SvgHelper.SvgDrawable) {
((SvgHelper.SvgDrawable) staticThumbDrawable).setParent(this);
}
updateDrawableRadius(staticThumbDrawable);
if (delegate != null) {
delegate.didSetImage(this, currentImageDrawable != null || currentThumbDrawable != null || staticThumbDrawable != null || currentMediaDrawable != null, currentImageDrawable == null && currentMediaDrawable == null, false);
@ -711,6 +708,9 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (bitmap instanceof AnimatedFileDrawable) {
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) bitmap;
fileDrawable.setParentView(parentView);
if (attachedToWindow) {
fileDrawable.addParent(parentView);
}
fileDrawable.setUseSharedQueue(useSharedAnimationQueue || fileDrawable.isWebmSticker);
if (allowStartAnimation && currentOpenedLayerFlags == 0) {
fileDrawable.start();
@ -845,6 +845,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
public void onDetachedFromWindow() {
attachedToWindow = false;
if (currentImageLocation != null || currentMediaLocation != null || currentThumbLocation != null || staticThumbDrawable != null) {
if (setImageBackup == null) {
setImageBackup = new SetImageBackup();
@ -873,6 +874,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (isPressed == 0) {
pressedProgress = 0f;
}
AnimatedFileDrawable animatedFileDrawable = getAnimation();
if (animatedFileDrawable != null) {
animatedFileDrawable.removeParent(parentView);
}
}
private boolean setBackupImage() {
@ -892,6 +898,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
public boolean onAttachedToWindow() {
attachedToWindow = true;
currentOpenedLayerFlags = NotificationCenter.getGlobalInstance().getCurrentHeavyOperationFlags();
currentOpenedLayerFlags &= ~currentLayerNum;
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReplacedPhotoInMemCache);
@ -905,6 +912,9 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
lottieDrawable.start();
}
AnimatedFileDrawable animatedFileDrawable = getAnimation();
if (animatedFileDrawable != null && parentView != null) {
animatedFileDrawable.addParent(parentView);
}
if (animatedFileDrawable != null && allowStartAnimation && currentOpenedLayerFlags == 0) {
animatedFileDrawable.start();
if (parentView != null) {
@ -1422,6 +1432,9 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
orientation = imageOrientation;
} else if (staticThumbDrawable instanceof BitmapDrawable) {
drawable = staticThumbDrawable;
if (useRoundForThumb && thumbShader == null) {
updateDrawableRadius(staticThumbDrawable);
}
shaderToUse = thumbShader;
orientation = thumbOrientation;
} else if (currentThumbDrawable != null) {
@ -1433,7 +1446,10 @@ 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 (useRoundForThumb && thumbShader == null) {
updateDrawableRadius(staticThumbDrawable);
}
drawDrawable(canvas, staticThumbDrawable, (int) (overrideAlpha * 255), thumbShader, orientation);
}
if (crossfadeWithThumb && animationNotReady) {
drawDrawable(canvas, drawable, (int) (overrideAlpha * 255), shaderToUse, orientation);
@ -1450,11 +1466,17 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
thumbShaderToUse = thumbShader;
} else if (staticThumbDrawable != null) {
thumbDrawable = staticThumbDrawable;
if (useRoundForThumb && thumbShader == null) {
updateDrawableRadius(staticThumbDrawable);
}
thumbShaderToUse = thumbShader;
}
} else if (drawable == currentThumbDrawable || drawable == crossfadeImage) {
if (staticThumbDrawable != null) {
thumbDrawable = staticThumbDrawable;
if (useRoundForThumb && thumbShader == null) {
updateDrawableRadius(staticThumbDrawable);
}
thumbShaderToUse = thumbShader;
}
} else if (drawable == staticThumbDrawable) {
@ -1904,12 +1926,10 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (currentMediaDrawable != null && mediaShader == null) {
updateDrawableRadius(currentMediaDrawable);
}
if (thumbShader == null) {
if (currentThumbDrawable != null) {
updateDrawableRadius(currentThumbDrawable);
} else if (staticThumbDrawable != null) {
updateDrawableRadius(staticThumbDrawable);
}
if (currentThumbDrawable != null) {
updateDrawableRadius(currentThumbDrawable);
} else if (staticThumbDrawable != null) {
updateDrawableRadius(staticThumbDrawable);
}
}
}
@ -2203,6 +2223,9 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (drawable instanceof AnimatedFileDrawable) {
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) drawable;
fileDrawable.setUseSharedQueue(useSharedAnimationQueue);
if (attachedToWindow) {
fileDrawable.addParent(parentView);
}
if (allowStartAnimation && currentOpenedLayerFlags == 0) {
fileDrawable.start();
}
@ -2266,6 +2289,10 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
RLottieDrawable lottieDrawable = (RLottieDrawable) image;
lottieDrawable.removeParentView(parentView);
}
if (image instanceof AnimatedFileDrawable) {
AnimatedFileDrawable lottieDrawable = (AnimatedFileDrawable) image;
lottieDrawable.removeParent(parentView);
}
if (key != null && (newKey == null || !newKey.equals(key)) && image != null) {
if (image instanceof RLottieDrawable) {
RLottieDrawable fileDrawable = (RLottieDrawable) image;

View File

@ -5040,12 +5040,16 @@ public class MessageObject {
return FileLoader.getDocumentFileName(getDocument());
}
public static boolean isVideoSticker(TLRPC.Document document) {
public static boolean isWebM(TLRPC.Document document) {
return document != null && "video/webm".equals(document.mime_type);
}
public static boolean isVideoSticker(TLRPC.Document document) {
return document != null && isVideoStickerDocument(document);
}
public boolean isVideoSticker() {
return getDocument() != null && "video/webm".equals(getDocument().mime_type);
return getDocument() != null && isVideoStickerDocument(getDocument());
}
public static boolean isStickerDocument(TLRPC.Document document) {
@ -5060,6 +5064,18 @@ public class MessageObject {
return false;
}
public static boolean isVideoStickerDocument(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
return "video/webm".equals(document.mime_type);
}
}
}
return false;
}
public static boolean isStickerHasSet(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {

View File

@ -386,7 +386,7 @@ public class MessagesController extends BaseController implements NotificationCe
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
int messageId = 0;
if (error != null && !res.messages.isEmpty()) {
if (error != null && res != null && res.messages != null && !res.messages.isEmpty()) {
messageId = res.messages.get(0).id;
}
int finalMessageId = messageId;

View File

@ -1004,6 +1004,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
contactAvatarDrawable = new AvatarDrawable();
photoImage = new ImageReceiver(this);
photoImage.setUseRoundForThumbDrawable(true);
photoImage.setDelegate(this);
radialProgress = new RadialProgress2(this, resourcesProvider);
videoRadialProgress = new RadialProgress2(this, resourcesProvider);
@ -4637,7 +4638,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
photoImage.setImage(ImageLocation.getForDocument(documentAttach), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, currentPhotoObjectThumbStripped, documentAttach.size, null, messageObject, 0);
autoPlayingMedia = true;
} else {
if (currentPhotoObjectThumb != null) {
if (currentPhotoObjectThumb != null || currentPhotoObjectThumbStripped != null) {
photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, currentPhotoObjectThumbStripped, 0, null, messageObject, 0);
} else {
photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoObject instanceof TLRPC.TL_photoStrippedSize || "s".equals(currentPhotoObject.type) ? currentPhotoFilterThumb : currentPhotoFilter, currentPhotoObjectThumbStripped, 0, null, messageObject, 0);
@ -4673,7 +4674,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, currentPhotoObjectThumbStripped, 0, null, messageObject, 0);
} else {
photoNotSet = true;
if (currentPhotoObjectThumb != null) {
if (currentPhotoObjectThumb != null || currentPhotoObjectThumbStripped != null) {
photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), String.format(Locale.US, "%d_%d_b", w, h), currentPhotoObjectThumbStripped, 0, null, messageObject, 0);
} else {
photoImage.setImageBitmap((Drawable) null);
@ -6215,7 +6216,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, currentPhotoObjectThumbStripped, currentPhotoObject.size, null, currentMessageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
} else {
photoNotSet = true;
if (currentPhotoObjectThumb != null) {
if (currentPhotoObjectThumb != null || currentPhotoObjectThumbStripped != null) {
photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, currentPhotoObjectThumbStripped, 0, null, currentMessageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0);
} else {
photoImage.setImageBitmap((Drawable) null);

View File

@ -29,14 +29,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.collection.LongSparseArray;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.ChatListItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.URLSpan;
@ -55,6 +47,13 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.collection.LongSparseArray;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.ChatListItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import org.telegram.messenger.AndroidUtilities;
@ -694,6 +693,8 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
childTop -= AndroidUtilities.dp(24) - (actionBar.getVisibility() == VISIBLE ? actionBar.getMeasuredHeight() / 2 : 0);
} else if (child == actionBar) {
childTop -= getPaddingTop();
} else if (child == backgroundView) {
childTop = 0;
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
}

View File

@ -1524,7 +1524,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return false;
}
ChatMessageCell cell = (ChatMessageCell) view;
return !cell.getMessageObject().isSending() && !cell.getMessageObject().isEditing() && cell.getMessageObject().type != 16 && !actionBar.isActionModeShowed() && !isSecretChat() && !isInScheduleMode();
return !cell.getMessageObject().isSending() && !cell.getMessageObject().isEditing() && cell.getMessageObject().type != 16 && !actionBar.isActionModeShowed() && !isSecretChat() && !isInScheduleMode() && !cell.getMessageObject().isSponsored();
}
@Override
@ -1541,7 +1541,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MessageObject primaryMessage = cell.getPrimaryMessageObject();
ReactionsEffectOverlay.removeCurrent(false);
TLRPC.TL_availableReaction reaction = getMediaDataController().getReactionsMap().get(getMediaDataController().getDoubleTapReaction());
if (reaction == null) {
if (reaction == null || cell.getMessageObject().isSponsored()) {
return;
}
boolean available = dialog_id >= 0;
@ -7451,8 +7451,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
undoView.showWithAction(0, Math.abs(value - 1.0f) > 0.001f ? UndoView.ACTION_PLAYBACK_SPEED_ENABLED : UndoView.ACTION_PLAYBACK_SPEED_DISABLED, value, null, null);
}
}
};
contentView.addView(fragmentLocationContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
contentView.addView(fragmentContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));

View File

@ -125,13 +125,15 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
private View parentView;
private ArrayList<View> secondParentViews = new ArrayList<>();
private ArrayList<View> parents = new ArrayList<>();
private AnimatedFileDrawableStream stream;
private boolean useSharedQueue;
private boolean invalidatePath = true;
private boolean invalidateTaskIsRunning;
private static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(16, new ThreadPoolExecutor.DiscardPolicy());
private static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(8, new ThreadPoolExecutor.DiscardPolicy());
protected final Runnable mInvalidateTask = () -> {
invalidateTaskIsRunning = false;
@ -244,14 +246,7 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
destroyDecoder(nativePtr);
nativePtr = 0;
}
if (renderingHeight > 0 && renderingWidth > 0 && metaData[0] > 0 && metaData[1] > 0) {
scaleFactor = Math.max(renderingWidth / (float) metaData[0], renderingHeight / (float) metaData[1]);
if (isWebmSticker || scaleFactor <= 0 || scaleFactor > 0.7) {
scaleFactor = 1;
}
} else {
scaleFactor = 1f;
}
updateScaleFactor();
decoderCreated = true;
}
try {
@ -281,10 +276,12 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
}
if (backgroundBitmap != null) {
lastFrameDecodeTime = System.currentTimeMillis();
if (getVideoFrame(nativePtr, backgroundBitmap, metaData, backgroundBitmap.getRowBytes(), false, startTime, endTime) == 0) {
AndroidUtilities.runOnUIThread(uiRunnableNoFrame);
return;
}
if (seekWas) {
lastTimeStamp = metaData[3];
}
@ -302,6 +299,17 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
}
};
private void updateScaleFactor() {
if (!isWebmSticker && renderingHeight > 0 && renderingWidth > 0 && metaData[0] > 0 && metaData[1] > 0) {
scaleFactor = Math.max(renderingWidth / (float) metaData[0], renderingHeight / (float) metaData[1]);
if (scaleFactor <= 0 || scaleFactor > 0.7) {
scaleFactor = 1;
}
} else {
scaleFactor = 1f;
}
}
private final Runnable mStartTask = () -> {
if (!secondParentViews.isEmpty()) {
for (int a = 0, N = secondParentViews.size(); a < N; a++) {
@ -337,14 +345,7 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
destroyDecoder(nativePtr);
nativePtr = 0;
}
if (renderingHeight > 0 && renderingWidth > 0 && metaData[0] > 0 && metaData[1] > 0) {
scaleFactor = Math.max(renderingWidth / (float) metaData[0], renderingHeight / (float) metaData[1]);
if (isWebmSticker || scaleFactor <= 0 || scaleFactor > 0.7) {
scaleFactor = 1f;
}
} else {
scaleFactor = 1f;
}
updateScaleFactor();
decoderCreated = true;
}
if (seekTo != 0) {
@ -386,6 +387,19 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
parentView = view;
}
public void addParent(View view) {
if (!parents.contains(view)) {
parents.add(view);
if (isRunning) {
scheduleNextGetFrame();
}
}
}
public void removeParent(View view) {
parents.remove(view);
}
public void setInvalidateParentViewWithSecond(boolean value) {
invalidateParentViewWithSecond = value;
}
@ -550,7 +564,7 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
}
private void scheduleNextGetFrame() {
if (loadFrameTask != null || nativePtr == 0 && decoderCreated || destroyWhenDone || !isRunning && (!decodeSingleFrame || decodeSingleFrame && singleFrameDecoded)) {
if (loadFrameTask != null || nativePtr == 0 && decoderCreated || destroyWhenDone || !isRunning && (!decodeSingleFrame || decodeSingleFrame && singleFrameDecoded) || parents.size() == 0) {
return;
}
long ms = 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.view.View;
import android.widget.FrameLayout;
@ -16,7 +17,7 @@ public class ChatBlurredFrameLayout extends FrameLayout {
ChatActivity chatActivity;
protected Paint backgroundPaint;
public int backgroundColor;
public int backgroundColor = Color.TRANSPARENT;
public int backgroundPaddingBottom;
public int backgroundPaddingTop;
public boolean isTopView = true;
@ -29,7 +30,7 @@ public class ChatBlurredFrameLayout extends FrameLayout {
@Override
protected void dispatchDraw(Canvas canvas) {
if (SharedConfig.chatBlurEnabled() && chatActivity != null && drawBlur) {
if (SharedConfig.chatBlurEnabled() && chatActivity != null && drawBlur && backgroundColor != Color.TRANSPARENT) {
if (backgroundPaint == null) {
backgroundPaint = new Paint();
}

View File

@ -76,6 +76,7 @@ import org.telegram.messenger.Emoji;
import org.telegram.messenger.EmojiData;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LocaleController;
@ -4081,7 +4082,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
if (svgThumb != null) {
svgThumb.overrideWidthAndHeight(512, 512);
}
if (object == null) {
if (object == null || MessageObject.isVideoSticker(document)) {
object = document;
}
@ -4099,7 +4100,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
if (imageLocation == null) {
return;
}
if (object instanceof TLRPC.Document && MessageObject.isAnimatedStickerDocument(document, true)) {
if (object instanceof TLRPC.Document && (MessageObject.isAnimatedStickerDocument(document, true) || MessageObject.isVideoSticker(document))) {
if (svgThumb != null) {
imageView.setImage(ImageLocation.getForDocument(document), "30_30", svgThumb, 0, set);
} else {

View File

@ -17,6 +17,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
@ -939,6 +940,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
muteDrawable.setCurrentFrame(muteDrawable.getCustomEndFrame() - 1, false, true);
muteButton.invalidate();
frameLayout.setBackground(null);
frameLayout.setBackgroundColor(Color.TRANSPARENT);
importingImageView.setVisibility(GONE);
importingImageView.stopAnimation();
Theme.getFragmentContextViewWavesDrawable().addParent(this);

View File

@ -277,7 +277,11 @@ public class ReactedUsersListView extends FrameLayout {
if (r != null) {
SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(r.static_icon.thumbs, Theme.key_windowBackgroundGray, 1.0f);
reactView.setImage(ImageLocation.getForDocument(r.static_icon), "50_50", "webp", svgThumb, r);
} else {
reactView.setImageDrawable(null);
}
} else {
reactView.setImageDrawable(null);
}
}

View File

@ -661,7 +661,7 @@ public class ContentPreviewViewer {
public void setParentActivity(Activity activity) {
currentAccount = UserConfig.selectedAccount;
centerImage.setCurrentAccount(currentAccount);
centerImage.setLayerNum(7);
centerImage.setLayerNum(Integer.MAX_VALUE);
if (parentActivity == activity) {
return;
}
@ -680,7 +680,19 @@ public class ContentPreviewViewer {
});
}
containerView = new FrameLayoutDrawer(activity);
containerView = new FrameLayoutDrawer(activity) {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
centerImage.onAttachedToWindow();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
centerImage.onDetachedFromWindow();
}
};
containerView.setFocusable(false);
windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
containerView.setOnTouchListener((v, event) -> {
@ -990,4 +1002,5 @@ public class ContentPreviewViewer {
Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null;
return color != null ? color : Theme.getColor(key);
}
}