update to 12.2.5 (6307)

This commit is contained in:
Arseny271
2025-12-08 20:42:50 +04:00
Unverified
parent 20ed157cf6
commit ef93bc4cc9
15 changed files with 112 additions and 316 deletions
@@ -9,105 +9,11 @@
package org.telegram.messenger;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
public class Bitmaps {
private static volatile Matrix sScaleMatrix;
private static final ThreadLocal<byte[]> jpegData = new ThreadLocal<byte[]>() {
@Override
protected byte[] initialValue() {
return new byte[]{
(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xdb, (byte) 0x00, (byte) 0x43, (byte) 0x00,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xc0, (byte) 0x00, (byte) 0x11, (byte) 0x08, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x22, (byte) 0x00,
(byte) 0x02, (byte) 0x11, (byte) 0x00, (byte) 0x03, (byte) 0x11, (byte) 0x00, (byte) 0xff,
(byte) 0xc4, (byte) 0x00, (byte) 0x1f, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x05,
(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
(byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0xff, (byte) 0xc4, (byte) 0x00,
(byte) 0xb5, (byte) 0x10, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x03,
(byte) 0x02, (byte) 0x04, (byte) 0x03, (byte) 0x05, (byte) 0x05, (byte) 0x04, (byte) 0x04,
(byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x7d, (byte) 0x01, (byte) 0x02, (byte) 0x03,
(byte) 0x00, (byte) 0x04, (byte) 0x11, (byte) 0x05, (byte) 0x12, (byte) 0x21, (byte) 0x31,
(byte) 0x41, (byte) 0x06, (byte) 0x13, (byte) 0x51, (byte) 0x61, (byte) 0x07, (byte) 0x22,
(byte) 0x71, (byte) 0x14, (byte) 0x32, (byte) 0x81, (byte) 0x91, (byte) 0xa1, (byte) 0x08,
(byte) 0x23, (byte) 0x42, (byte) 0xb1, (byte) 0xc1, (byte) 0x15, (byte) 0x52, (byte) 0xd1,
(byte) 0xf0, (byte) 0x24, (byte) 0x33, (byte) 0x62, (byte) 0x72, (byte) 0x82, (byte) 0x09,
(byte) 0x0a, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x25,
(byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x34, (byte) 0x35,
(byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x43, (byte) 0x44,
(byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x53,
(byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a,
(byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69,
(byte) 0x6a, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78,
(byte) 0x79, (byte) 0x7a, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87,
(byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95,
(byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0xa2, (byte) 0xa3,
(byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa,
(byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8,
(byte) 0xb9, (byte) 0xba, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6,
(byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4,
(byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xe1,
(byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8,
(byte) 0xe9, (byte) 0xea, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5,
(byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xff, (byte) 0xc4,
(byte) 0x00, (byte) 0x1f, (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x01,
(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
(byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08,
(byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0xff, (byte) 0xc4, (byte) 0x00, (byte) 0xb5,
(byte) 0x11, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x02, (byte) 0x04, (byte) 0x04,
(byte) 0x03, (byte) 0x04, (byte) 0x07, (byte) 0x05, (byte) 0x04, (byte) 0x04, (byte) 0x00,
(byte) 0x01, (byte) 0x02, (byte) 0x77, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
(byte) 0x11, (byte) 0x04, (byte) 0x05, (byte) 0x21, (byte) 0x31, (byte) 0x06, (byte) 0x12,
(byte) 0x41, (byte) 0x51, (byte) 0x07, (byte) 0x61, (byte) 0x71, (byte) 0x13, (byte) 0x22,
(byte) 0x32, (byte) 0x81, (byte) 0x08, (byte) 0x14, (byte) 0x42, (byte) 0x91, (byte) 0xa1,
(byte) 0xb1, (byte) 0xc1, (byte) 0x09, (byte) 0x23, (byte) 0x33, (byte) 0x52, (byte) 0xf0,
(byte) 0x15, (byte) 0x62, (byte) 0x72, (byte) 0xd1, (byte) 0x0a, (byte) 0x16, (byte) 0x24,
(byte) 0x34, (byte) 0xe1, (byte) 0x25, (byte) 0xf1, (byte) 0x17, (byte) 0x18, (byte) 0x19,
(byte) 0x1a, (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x35,
(byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x43, (byte) 0x44,
(byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x53,
(byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a,
(byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69,
(byte) 0x6a, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78,
(byte) 0x79, (byte) 0x7a, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86,
(byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x92, (byte) 0x93, (byte) 0x94,
(byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0xa2,
(byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9,
(byte) 0xaa, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7,
(byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5,
(byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xd2, (byte) 0xd3,
(byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda,
(byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8,
(byte) 0xe9, (byte) 0xea, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6,
(byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xff, (byte) 0xda, (byte) 0x00,
(byte) 0x0c, (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x11, (byte) 0x03,
(byte) 0x11, (byte) 0x00, (byte) 0x3f, (byte) 0x00, (byte) 0x8e, (byte) 0x8a, (byte) 0x28,
(byte) 0xa0, (byte) 0x0f, (byte) 0xff, (byte) 0xd9
};
}
};
protected static byte[] header = new byte[]{
(byte) 0xFF, (byte) 0xD8, (byte) 0xFF, (byte) 0xE0, (byte) 0x00, (byte) 0x10, (byte) 0x4A,
(byte) 0x46, (byte) 0x49, (byte) 0x46, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00,
@@ -207,123 +113,15 @@ public class Bitmaps {
public static Bitmap createBitmap(int width, int height, Bitmap.Config config) {
Bitmap bitmap;
if (Build.VERSION.SDK_INT < 21) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = true;
options.inPreferredConfig = config;
options.inPurgeable = true;
options.inSampleSize = 1;
options.inMutable = true;
byte[] array = jpegData.get();
array[76] = (byte) (height >> 8);
array[77] = (byte) (height & 0x00ff);
array[78] = (byte) (width >> 8);
array[79] = (byte) (width & 0x00ff);
bitmap = BitmapFactory.decodeByteArray(array, 0, array.length, options);
Utilities.pinBitmap(bitmap);
bitmap.setHasAlpha(true);
bitmap.eraseColor(0);
} else {
bitmap = Bitmap.createBitmap(width, height, config);
}
bitmap = Bitmap.createBitmap(width, height, config);
if (config == Bitmap.Config.ARGB_8888 || config == Bitmap.Config.ARGB_4444) {
bitmap.eraseColor(Color.TRANSPARENT);
}
return bitmap;
}
private static void checkXYSign(int x, int y) {
if (x < 0) {
throw new IllegalArgumentException("x must be >= 0");
}
if (y < 0) {
throw new IllegalArgumentException("y must be >= 0");
}
}
private static void checkWidthHeight(int width, int height) {
if (width <= 0) {
throw new IllegalArgumentException("width must be > 0");
}
if (height <= 0) {
throw new IllegalArgumentException("height must be > 0");
}
}
public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter) {
if (Build.VERSION.SDK_INT >= 21) {
return Bitmap.createBitmap(source, x, y, width, height, m, filter);
}
checkXYSign(x, y);
checkWidthHeight(width, height);
if (x + width > source.getWidth()) {
throw new IllegalArgumentException("x + width must be <= bitmap.width()");
}
if (y + height > source.getHeight()) {
throw new IllegalArgumentException("y + height must be <= bitmap.height()");
}
if (!source.isMutable() && x == 0 && y == 0 && width == source.getWidth() && height == source.getHeight() && (m == null || m.isIdentity())) {
return source;
}
int neww = width;
int newh = height;
Canvas canvas = new Canvas();
Bitmap bitmap;
Paint paint;
Rect srcR = new Rect(x, y, x + width, y + height);
RectF dstR = new RectF(0, 0, width, height);
Bitmap.Config newConfig = Bitmap.Config.ARGB_8888;
final Bitmap.Config config = source.getConfig();
if (config != null) {
switch (config) {
case RGB_565:
newConfig = Bitmap.Config.ARGB_8888;
break;
case ALPHA_8:
newConfig = Bitmap.Config.ALPHA_8;
break;
case ARGB_4444:
case ARGB_8888:
default:
newConfig = Bitmap.Config.ARGB_8888;
break;
}
}
if (m == null || m.isIdentity()) {
bitmap = createBitmap(neww, newh, newConfig);
paint = null;
} else {
final boolean transformed = !m.rectStaysRect();
RectF deviceR = new RectF();
m.mapRect(deviceR, dstR);
neww = Math.round(deviceR.width());
newh = Math.round(deviceR.height());
bitmap = createBitmap(neww, newh, transformed ? Bitmap.Config.ARGB_8888 : newConfig);
canvas.translate(-deviceR.left, -deviceR.top);
canvas.concat(m);
paint = new Paint();
paint.setFilterBitmap(filter);
if (transformed) {
paint.setAntiAlias(true);
}
}
bitmap.setDensity(source.getDensity());
bitmap.setHasAlpha(source.hasAlpha());
if (Build.VERSION.SDK_INT >= 19) {
bitmap.setPremultiplied(source.isPremultiplied());
}
canvas.setBitmap(bitmap);
canvas.drawBitmap(source, srcR, dstR, paint);
try {
canvas.setBitmap(null);
} catch (Exception e) {
//don't promt, this will crash on 2.x
}
return bitmap;
return Bitmap.createBitmap(source, x, y, width, height, m, filter);
}
public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height) {
@@ -331,28 +129,6 @@ public class Bitmaps {
}
public static Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) {
if (Build.VERSION.SDK_INT >= 21) {
return Bitmap.createScaledBitmap(src, dstWidth, dstHeight, filter);
}
Matrix m;
synchronized (Bitmap.class) {
m = sScaleMatrix;
sScaleMatrix = null;
}
if (m == null) {
m = new Matrix();
}
final int width = src.getWidth();
final int height = src.getHeight();
final float sx = dstWidth / (float) width;
final float sy = dstHeight / (float) height;
m.setScale(sx, sy);
Bitmap b = createBitmap(src, 0, 0, width, height, m, filter);
synchronized (Bitmap.class) {
if (sScaleMatrix == null) {
sScaleMatrix = m;
}
}
return b;
return Bitmap.createScaledBitmap(src, dstWidth, dstHeight, filter);
}
}
@@ -384,6 +384,7 @@ public class Theme {
if (backgroundHeight != currentBackgroundHeight || crosfadeFromBitmapShader == null || currentColor != color || currentGradientColor1 != gradientColor1 || currentGradientColor2 != gradientColor2 || currentGradientColor3 != gradientColor3 || currentAnimateGradient != animatedGradient) {
if (crosfadeFromBitmap == null) {
crosfadeFromBitmap = Bitmap.createBitmap(60, 80, Bitmap.Config.ARGB_8888);
crosfadeFromBitmap.setHasAlpha(false);
crosfadeFromBitmapShader = new BitmapShader(crosfadeFromBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
}
if (motionBackground[num] == null) {
@@ -138,6 +138,7 @@ import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BotForumHelper;
import org.telegram.messenger.BotInlineKeyboard;
import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChannelBoostsController;
import org.telegram.messenger.ChatMessageSharedResources;
@@ -2466,23 +2467,25 @@ public class ChatActivity extends BaseFragment implements
scrollableViewNoiseSuppressor = new DownscaleScrollableNoiseSuppressor();
recommendedAdditionalSizeY = dp(48);
glassBackgroundSourceRenderNode = new BlurredBackgroundSourceRenderNode(navbarContentSourceWallpaper);
glassBackgroundSourceFrostedRenderNode = new BlurredBackgroundSourceRenderNode(navbarContentSourceWallpaper);
navbarContentSourceMessages = new BlurredBackgroundSourceRenderNode(null);
navbarContentSourceMessagesDrawable = navbarContentSourceMessages.createDrawable();
navbarContentSourceWallpaperAndMessagesRenderNode = new BlurredBackgroundSourceRenderNode(null);
glassBackgroundDrawableFactory = new BlurredBackgroundDrawableViewFactory(glassBackgroundSourceRenderNode);
glassBackgroundDrawableFactory.setLiquidGlassEffectAllowed(LiteMode.isEnabled(LiteMode.FLAG_LIQUID_GLASS));
glassBackgroundDrawableFactoryFrosted = new BlurredBackgroundDrawableViewFactory(glassBackgroundSourceFrostedRenderNode);
glassBackgroundDrawableFactoryFrosted.setLiquidGlassEffectAllowed(LiteMode.isEnabled(LiteMode.FLAG_LIQUID_GLASS));
if (LiteMode.isEnabled(LiteMode.FLAG_LIQUID_GLASS)) {
glassBackgroundSourceRenderNode = new BlurredBackgroundSourceRenderNode(navbarContentSourceWallpaper);
glassBackgroundDrawableFactory = new BlurredBackgroundDrawableViewFactory(glassBackgroundSourceRenderNode);
glassBackgroundDrawableFactory.setLiquidGlassEffectAllowed(LiteMode.isEnabled(LiteMode.FLAG_LIQUID_GLASS));
navbarContentSourceWallpaperAndMessagesRenderNode = null;
navbarContentDrawableFactory = new BlurredBackgroundDrawableViewFactory(navbarContentSourceWallpaper);
} else {
glassBackgroundSourceRenderNode = null;
glassBackgroundDrawableFactory = glassBackgroundDrawableFactoryFrosted;
navbarContentSourceWallpaperAndMessagesRenderNode = new BlurredBackgroundSourceRenderNode(null);
navbarContentDrawableFactory = new BlurredBackgroundDrawableViewFactory(navbarContentSourceWallpaperAndMessagesRenderNode);
}
} else {
@@ -4551,6 +4554,7 @@ public class ChatActivity extends BaseFragment implements
if (textSelectionHelper != null && textSelectionHelper.isInSelectionMode()) {
textSelectionHelper.invalidate();
}
invalidateClipRectForBackgroundAndChatList();
isSkeletonVisible();
}
@@ -8716,6 +8720,7 @@ public class ChatActivity extends BaseFragment implements
checkUi_BlurHeight();
checkUi_emptyContainerPosition();
checkUi_chatListViewPaddings();
invalidateClipRectForBackgroundAndChatList();
final boolean inAppInputVisible = windowInsetsStateHolder.inAppViewIsVisible();
if (lastInAppInputVisible != inAppInputVisible) {
@@ -44293,4 +44298,29 @@ public class ChatActivity extends BaseFragment implements
fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignored) {};
}
private final Rect clipBoundsTmp = new Rect();
private void invalidateClipRectForBackgroundAndChatList() {
if (contentView == null) {
return;
}
final int topClip = ActionBar.getCurrentActionBarHeight() + windowInsetsStateHolder.getInsets(WindowInsetsCompat.Type.statusBars()).top;
final int bottomClip = (int) Math.max(0,
windowInsetsStateHolder.getAnimatedImeBottomInset() * windowInsetsStateHolder.getAnimatedKeyboardVisibility() - dp(29));
if (contentView.backgroundView != null) {
clipBoundsTmp.set(0, topClip, contentView.getMeasuredWidth(), contentView.getMeasuredHeight() - bottomClip);
contentView.backgroundView.setClipBounds(clipBoundsTmp);
}
if (chatListView != null) {
clipBoundsTmp.set(0, topClip, contentView.getMeasuredWidth(), contentView.getMeasuredHeight() - bottomClip);
clipBoundsTmp.offset(0, -chatListView.getTop());
chatListView.setClipBounds(clipBoundsTmp);
}
if (chatInputViewsContainer != null && chatInputViewsContainer.getFadeView() != null) {
clipBoundsTmp.set(0, 0, contentView.getMeasuredWidth(), contentView.getMeasuredHeight() - bottomClip);
// chatInputViewsContainer.getFadeView().setClipBounds(clipBoundsTmp);
}
}
}
@@ -161,12 +161,15 @@ public class MotionBackgroundDrawable extends Drawable {
@SuppressLint("NewApi")
private void init() {
currentBitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
currentBitmap.setHasAlpha(false);
for (int i = 0; i < ANIMATION_CACHE_BITMAPS_COUNT; i++) {
gradientToBitmap[i] = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
gradientToBitmap[i].setHasAlpha(false);
}
gradientCanvas = new Canvas(currentBitmap);
gradientFromBitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
gradientFromBitmap.setHasAlpha(false);
gradientFromCanvas = new Canvas(gradientFromBitmap);
Utilities.generateGradient(currentBitmap, true, phase, interpolator.getInterpolation(posAnimationProgress), currentBitmap.getWidth(), currentBitmap.getHeight(), currentBitmap.getRowBytes(), colors);
@@ -17,8 +17,6 @@ public class ScaleStateListAnimator {
return;
}
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
AnimatorSet pressedAnimator = new AnimatorSet();
pressedAnimator.playTogether(
ObjectAnimator.ofFloat(view, View.SCALE_X, 1f - scale),
@@ -36,7 +36,7 @@ public class DownscaleScrollableNoiseSuppressor {
final int frostedDownscale;
if (LiteMode.isEnabled(LiteMode.FLAG_LIQUID_GLASS)) {
final float glassRadius = downscaleRadius(dpf2(1.66f), 2);
final float glassRadius = downscaleRadius(dpf2(1.66f), 3);
renderNodesForGlass = new DownscaledRenderNode(1);
renderNodesForGlass.setScale(2, 2);
@@ -49,11 +49,11 @@ public class DownscaleScrollableNoiseSuppressor {
renderNodesForGlass = null;
int performance = SharedConfig.getDevicePerformanceClass();
if (performance == SharedConfig.PERFORMANCE_CLASS_HIGH) {
frostedDownscale = 4;
} else if (performance == SharedConfig.PERFORMANCE_CLASS_AVERAGE) {
frostedDownscale = 6;
} else {
} else if (performance == SharedConfig.PERFORMANCE_CLASS_AVERAGE) {
frostedDownscale = 8;
} else {
frostedDownscale = 10;
}
}
@@ -1,11 +1,9 @@
package org.telegram.ui.Components.blur3;
import static org.telegram.messenger.AndroidUtilities.dp;
import android.graphics.Color;
import android.graphics.RenderEffect;
import android.graphics.RenderNode;
import android.graphics.RuntimeShader;
import android.os.Build;
import androidx.annotation.RequiresApi;
@@ -36,6 +34,7 @@ public class LiquidGlassEffect {
private float thickness;
private float intensity;
private float index;
private int foregroundColor;
public void update(
float left, float top, float right, float bottom,
@@ -43,7 +42,8 @@ public class LiquidGlassEffect {
float thickness,
float intensity,
float index
float index,
int foregroundColor
) {
float resolutionX = node.getWidth();
float resolutionY = node.getHeight();
@@ -77,8 +77,16 @@ public class LiquidGlassEffect {
Math.abs(this.radiusLeftBottom - radiusLeftBottom) > 0.1f ||
Math.abs(this.thickness - thickness) > 0.1f ||
Math.abs(this.intensity - intensity) > 0.1f ||
Math.abs(this.index - index) > 0.1f
Math.abs(this.index - index) > 0.1f ||
this.foregroundColor != foregroundColor
) {
this.foregroundColor = foregroundColor;
final float a = Color.alpha(foregroundColor) / 255f;
final float r = Color.red(foregroundColor) / 255f * a;
final float g = Color.green(foregroundColor) / 255f * a;
final float b = Color.blue(foregroundColor) / 255f * a;
shader.setFloatUniform("resolution", this.resolutionX = resolutionX, this.resolutionY = resolutionY);
shader.setFloatUniform("center", this.centerX = centerX, this.centerY = centerY);
shader.setFloatUniform("size", this.sizeX = sizeX, this.sizeY = sizeY);
@@ -86,6 +94,7 @@ public class LiquidGlassEffect {
shader.setFloatUniform("thickness", this.thickness = thickness);
shader.setFloatUniform("refract_intensity", this.intensity = intensity);
shader.setFloatUniform("refract_index", this.index = index);
shader.setFloatUniform("foreground_color_premultiplied", r, g, b, a);
node.setRenderEffect(effect = RenderEffect.createRuntimeShaderEffect(shader, "img"));
}
}
@@ -237,6 +237,21 @@ public abstract class BlurredBackgroundDrawable extends Drawable {
strokePathBottom.close();
}
public void drawShadows(Canvas canvas, Paint paint, boolean useInAppKeyboardOptimization) {
if (useInAppKeyboardOptimization) {
final float bottom = MathUtils.clamp(boundsWithPadding.top + radii[0] * 2,
boundsWithPadding.top, boundsWithPadding.bottom);
canvas.save();
canvas.clipRect(bounds.left, bounds.top, bounds.right, bottom);
canvas.drawRoundRect(boundsWithPadding.left, boundsWithPadding.top,
boundsWithPadding.right, bottom, radii[0], radii[0], paint);
canvas.restore();
} else {
draw(canvas, paint);
}
}
public void draw(Canvas canvas, Paint paint) {
if (radiiAreSame) {
canvas.drawRoundRect(
@@ -433,21 +448,23 @@ public abstract class BlurredBackgroundDrawable extends Drawable {
private final Paint backgroundBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint backgroundBitmapFill = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint backgroundBitmapShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint shadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Matrix bitmapShaderMatrix = new Matrix();
private final WeakReference<Bitmap> bitmapInShader = new WeakReference<>(null);
private @Nullable BitmapShader bitmapShader;
{
backgroundBitmapShadowPaint.setColor(0);
shadowPaint.setColor(0);
backgroundBitmapPaint.setFilterBitmap(true);
}
private void drawSourceColor(Canvas canvas, BlurredBackgroundSourceColor source) {
final int backgroundColor = Theme.multAlpha(ColorUtils.compositeColors(this.backgroundColor, source.getColor()), alpha / 255f);
final int shadowColor = Theme.multAlpha(this.shadowColor, alpha / 255f);
if (Color.alpha(shadowColor) > 0 && alpha == 255) {
shadowPaint.setShadowLayer(dpf2(1), 0f, dpf2(1 / 3f), shadowColor);
boundProps.drawShadows(canvas, shadowPaint, inAppKeyboardOptimization);
}
backgroundColorPaint.setShadowLayer(dpf2(1), 0f, dpf2(1 / 3f), shadowColor);
backgroundColorPaint.setColor(backgroundColor);
boundProps.draw(canvas, backgroundColorPaint);
@@ -469,8 +486,8 @@ public abstract class BlurredBackgroundDrawable extends Drawable {
}
if (Color.alpha(shadowColor) > 0 && alpha == 255) {
backgroundBitmapShadowPaint.setShadowLayer(dpf2(1), 0f, dpf2(1 / 3f), shadowColor);
boundProps.draw(canvas, backgroundBitmapShadowPaint);
shadowPaint.setShadowLayer(dpf2(1), 0f, dpf2(1 / 3f), shadowColor);
boundProps.drawShadows(canvas, shadowPaint, inAppKeyboardOptimization);
}
if (bitmapShader != null && newBitmap != null && !newBitmap.isRecycled() && alpha > 0) {
@@ -3,14 +3,11 @@ package org.telegram.ui.Components.blur3.drawable;
import static org.telegram.messenger.AndroidUtilities.dp;
import static org.telegram.messenger.AndroidUtilities.dpf2;
import android.graphics.BlendMode;
import android.graphics.BlendModeColorFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RenderEffect;
import android.graphics.RenderNode;
import android.os.Build;
@@ -18,7 +15,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.math.MathUtils;
import org.telegram.messenger.LiteMode;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.blur3.LiquidGlassEffect;
import org.telegram.ui.Components.blur3.source.BlurredBackgroundSource;
@@ -35,7 +31,6 @@ public class BlurredBackgroundDrawableRenderNode extends BlurredBackgroundDrawab
private final RenderNode renderNodeStroke;
private final Paint paintShadow = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint paintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint paintStrokeTop = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint paintStrokeBottom = new Paint(Paint.ANTI_ALIAS_FLAG);
@@ -70,6 +65,8 @@ public class BlurredBackgroundDrawableRenderNode extends BlurredBackgroundDrawab
@Override
protected void onBoundPropsChanged() {
super.onBoundPropsChanged();
paintStrokeTop.setStrokeWidth(boundProps.strokeWidthTop);
paintStrokeBottom.setStrokeWidth(boundProps.strokeWidthBottom);
@@ -92,9 +89,13 @@ public class BlurredBackgroundDrawableRenderNode extends BlurredBackgroundDrawab
@Override
protected void onSourceOffsetChange(float sourceOffsetX, float sourceOffsetY) {
super.onSourceOffsetChange(sourceOffsetX, sourceOffsetY);
renderNodeInvalidated = true;
}
public boolean hasDisplayList() {
return renderNode.hasDisplayList();
}
private void updateDisplayList() {
final float offsetX = sourceOffsetX;
@@ -111,7 +112,8 @@ public class BlurredBackgroundDrawableRenderNode extends BlurredBackgroundDrawab
boundProps.shaderRadii[0], boundProps.shaderRadii[2], boundProps.shaderRadii[4], boundProps.shaderRadii[6],
boundProps.liquidThickness <= 0 ? dp(11) : boundProps.liquidThickness,
boundProps.liquidIntensity,
boundProps.liquidIndex
boundProps.liquidIndex,
backgroundColor
);
}
source.draw(c,
@@ -141,8 +143,8 @@ public class BlurredBackgroundDrawableRenderNode extends BlurredBackgroundDrawab
c = renderNode.beginRecording();
c.drawRenderNode(renderNodeFill);
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.S || liquidGlassEffect != null) && backgroundColor != 0) {
c.drawPaint(paintFill);
if (liquidGlassEffect == null && Color.alpha(backgroundColor) != 0) {
c.drawColor(backgroundColor);
}
if (hasStroke) {
c.drawRenderNode(renderNodeStroke);
@@ -150,27 +152,11 @@ public class BlurredBackgroundDrawableRenderNode extends BlurredBackgroundDrawab
renderNode.endRecording();
}
private int lastBackgroundColor;
@Override
public void updateColors() {
super.updateColors();
if (lastBackgroundColor != backgroundColor) {
lastBackgroundColor = backgroundColor;
if (liquidGlassEffect == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (Color.alpha(backgroundColor) != 0) {
renderNodeFill.setRenderEffect(RenderEffect.createColorFilterEffect(
new BlendModeColorFilter(backgroundColor, BlendMode.SRC_OVER)));
} else {
renderNodeFill.setRenderEffect(null);
}
}
}
paintShadow.setShadowLayer(dpf2(1), 0f, dpf2(1 / 3f), shadowColor);
paintFill.setColor(Theme.multAlpha(backgroundColor, boundProps.fillAlpha));
paintStrokeTop.setColor(strokeColorTop);
paintStrokeBottom.setColor(strokeColorBottom);
@@ -195,34 +181,7 @@ public class BlurredBackgroundDrawableRenderNode extends BlurredBackgroundDrawab
int color = Theme.multAlpha(shadowColor, renderNode.getAlpha());
if (Color.alpha(color) != 0) {
paintShadow.setShadowLayer(dpf2(1), 0f, dpf2(1 / 3f), color);
if (inAppKeyboardOptimization) {
canvas.drawRoundRect(
boundProps.boundsWithPadding.left,
boundProps.boundsWithPadding.top,
boundProps.boundsWithPadding.right,
MathUtils.clamp(
boundProps.boundsWithPadding.top + boundProps.radii[0] * 2,
boundProps.boundsWithPadding.top,
boundProps.boundsWithPadding.bottom
),
boundProps.radii[0],
boundProps.radii[0],
paintShadow
);
} else if (boundProps.radiiAreSame) {
canvas.drawRoundRect(
boundProps.boundsWithPadding.left,
boundProps.boundsWithPadding.top,
boundProps.boundsWithPadding.right,
boundProps.boundsWithPadding.bottom,
boundProps.radii[0],
boundProps.radii[0],
paintShadow
);
} else {
canvas.drawPath(boundProps.path, paintShadow);
}
boundProps.drawShadows(canvas, paintShadow, inAppKeyboardOptimization);
}
canvas.save();
@@ -1,8 +1,6 @@
package org.telegram.ui.Components.blur3.source;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.RectF;
import org.telegram.ui.Components.blur3.drawable.BlurredBackgroundDrawable;
@@ -10,12 +8,4 @@ public interface BlurredBackgroundSource {
BlurredBackgroundDrawable createDrawable();
void draw(Canvas canvas, float left, float top, float right, float bottom);
default void draw(Canvas canvas, Rect rect) {
draw(canvas, rect.left, rect.top, rect.right, rect.bottom);
}
default void draw(Canvas canvas, RectF rect) {
draw(canvas, rect.left, rect.top, rect.right, rect.bottom);
}
}
@@ -93,7 +93,9 @@ public class WallpaperBitmapProvider {
}
final float scale = Math.max(bitmap.getWidth() / 90f, bitmap.getHeight() / 120f);
return Utilities.stackBlurBitmapWithScaleFactor(bitmap, scale);
final Bitmap result = Utilities.stackBlurBitmapWithScaleFactor(bitmap, scale);
result.setHasAlpha(false);
return result;
}
private static int averageBottomColor(Bitmap bitmap) {
@@ -445,6 +445,10 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements
ssb.append(formatNumber(auction.auctionStateActive.gifts_left, ','));
giftsLeftCell.infoView.setText(ssb, animated);
nextRoundCell.titleView.setText(getString(
auction.auctionStateActive.current_round == auction.auctionStateActive.total_rounds ?
R.string.Gift2AuctionBidInfoUntilEndRound : R.string.Gift2AuctionBidInfoUntilNextRound
));
final int topBidders = Math.min(topBidderCells.length, auction.auctionStateActive.top_bidders.size());
if (topBidders > 0) {
@@ -7,6 +7,7 @@ uniform float4 radius;
uniform float thickness;
uniform float refract_index;
uniform float refract_intensity;
uniform float4 foreground_color_premultiplied;
half sdfRect(half2 p, half4 r) {
r.xy = (p.x > 0.0) ? r.xy : r.zw;
@@ -15,6 +16,11 @@ half sdfRect(half2 p, half4 r) {
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r.x;
}
half4 srcOver(half4 src, half4 dst) {
half3 outRGB = (src.rgb + dst.rgb * (1.0 - src.a));
return half4(outRGB, 1.0);
}
half4 main(in float2 fragCoord) {
half2 p = fragCoord - center;
half sd = sdfRect(p, radius);
@@ -35,5 +41,5 @@ half4 main(in float2 fragCoord) {
uv += refract_vec.xy * refract_length * refract_intensity;
}
return img.eval(uv);
return srcOver(half4(foreground_color_premultiplied), img.eval(uv));
}
@@ -8611,6 +8611,7 @@
<string name="Gift2AuctionBidInfoMinimumBid">minimum bid</string>
<string name="Gift2AuctionBidInfoUntilNextRound">until next round</string>
<string name="Gift2AuctionBidInfoUntilEndRound">last round</string>
<string name="Gift2AuctionBidInfoLeft">left</string>
<string name="Gift2AuctionAlreadyParticipateTitle">Auction</string>
<string name="Gift2AuctionAlreadyParticipate">You are already participating in an auction for **%s**. You can only participate in one auction. Win the current round or wait until you are removed from the list of participants.</string>
+2 -2
View File
@@ -13,8 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Mar 12 05:53:50 MSK 2016
APP_VERSION_CODE=6304
APP_VERSION_NAME=12.2.4
APP_VERSION_CODE=6307
APP_VERSION_NAME=12.2.5
APP_PACKAGE=org.telegram.messenger
IS_PRIVATE=false
RELEASE_KEY_PASSWORD=android