Merge official v8.8.4

This commit is contained in:
luvletter2333 2022-06-30 19:19:47 +08:00
commit 0a05e0476b
No known key found for this signature in database
GPG Key ID: A26A8880836E1978
35 changed files with 581 additions and 208 deletions

View File

@ -36,6 +36,7 @@ static Shape cloud_extra_mask1;
static Shape cloud_extra_mask2;
static Shape cloud_extra_mask3;
static Shape cloud_extra_mask4;
static int surfaceCreated = 0;
static Shape cloud_cover;
@ -1706,6 +1707,11 @@ JNIEXPORT void Java_org_telegram_messenger_Intro_setBackgroundColor(JNIEnv *env,
}
JNIEXPORT void Java_org_telegram_messenger_Intro_onDrawFrame(JNIEnv *env, jclass class, jint deltaMs) {
if (surfaceCreated == 0) {
glClearColor(background_color[0], background_color[1], background_color[2], background_color[3]);
glClear(GL_COLOR_BUFFER_BIT);
return;
}
time_local += (float) deltaMs / 1000;
if (current_page != prev_page) {
@ -2826,6 +2832,7 @@ JNIEXPORT void Java_org_telegram_messenger_Intro_onSurfaceCreated(JNIEnv *env, j
vec4 cloud_color = {42 / 255.0f, 180 / 255.0f, 247 / 255.0f, 1};
cloud_bg = create_rectangle(CSizeMake(160 * 2, 160 * 2), cloud_color);
surfaceCreated = 1;
}
JNIEXPORT void Java_org_telegram_messenger_Intro_onSurfaceChanged(JNIEnv *env, jclass class, int32_t a_width_px, int32_t a_height_px, float a_scale_factor, int32_t a1) {

View File

@ -28,14 +28,15 @@ uniform vec4 gradientPosition;
void main() {
vec3 vLightPosition2 = vec3(-400,400,400);
vec3 vLightPosition3 = vec3(0,200,400);
vec3 vLightPosition4 = vec3(100,-200,400);
vec3 vLightPosition4 = vec3(0,0,100);
vec3 vLightPositionNormal = vec3(100,-200,400);
vec3 vNormalW = normalize(vec3(world * vec4(vNormal, 0.0)));
vec3 vTextureNormal = normalize(texture2D(u_NormalMap, vUV + vec2(-f_xOffset, f_xOffset)).xyz * 2.0 - 1.0);
vec3 finalNormal = normalize(vNormalW + vTextureNormal);
vec3 color = texture2D(u_Texture, vUV * vec2(0.8, 0.8) + vec2(0.2 * f_xOffset, 0)).xyz;
vec3 color = texture2D(u_Texture, vUV ).xyz;
vec3 viewDirectionW = normalize(cameraPosition - modelViewVertex);
vec3 angleW = normalize(viewDirectionW + vLightPosition2);
@ -44,14 +45,14 @@ void main() {
angleW = normalize(viewDirectionW + vLightPosition4);
float specComp3 = max(0., dot(vNormalW, angleW));
specComp3 = pow(specComp3, max(1., 128.)) * spec2;
specComp3 = pow(specComp3, max(1., 30.)) * spec2;
float diffuse = max(dot(vNormalW, viewDirectionW), (1.0 - u_diffuse));
float mixValue = distance(vUV,vec2(1,0));
vec4 gradientColorFinal = vec4(mix(gradientColor1,gradientColor2,mixValue), 1.0);
angleW = normalize(viewDirectionW + vLightPosition4);
angleW = normalize(viewDirectionW + vLightPositionNormal);
float normalSpecComp = max(0., dot(finalNormal, angleW));
normalSpecComp = pow(normalSpecComp, max(1., 128.)) * normalSpec;
@ -60,7 +61,7 @@ void main() {
normalSpecComp2 = pow(normalSpecComp2, max(1., 128.)) * normalSpec;
vec4 normalSpecFinal = vec4(normalSpecColor, 0.0) * (normalSpecComp + normalSpecComp2);
vec4 specFinal = vec4(specColor, 0.0) * (specComp2 + specComp3);
vec4 specFinal = vec4(color, 0.0) * (specComp2 + specComp3);
vec4 fragColor = gradientColorFinal + specFinal + normalSpecFinal;
vec4 backgroundColor = texture2D(u_BackgroundTexture, vec2(gradientPosition.x + (gl_FragCoord.x / resolution.x) * gradientPosition.y, gradientPosition.z + (1.0 - (gl_FragCoord.y / resolution.y)) * gradientPosition.w));

View File

@ -2519,7 +2519,7 @@ public class AndroidUtilities {
}
public static void appCenterLog(Throwable e) {
}
public static boolean shouldShowClipboardToast() {

View File

@ -46,6 +46,8 @@ public class FileLoadOperation {
}
}
private static final Object lockObject = new Object();
private static class PreloadRange {
private long fileOffset;
private long length;
@ -182,7 +184,7 @@ public class FileLoadOperation {
private void updateParams() {
if (MessagesController.getInstance(currentAccount).getfileExperimentalParams) {
downloadChunkSizeBig = 1024 * 512;
downloadChunkSizeBig = 1024 * 128;
maxDownloadRequests = 8;
maxDownloadRequestsBig = 8;
} else {
@ -772,7 +774,11 @@ public class FileLoadOperation {
} else if (fileName != null && !encryptFile) {
cacheFileFinal = new File(storePath, fileName);
} else {
cacheFileFinal = new File(storePath, storeFileName);
if (!encryptFile) {
cacheFileFinal = new File(storePath, storeFileName);
} else {
cacheFileFinal = new File(storePath, fileNameFinal);
}
}
boolean finalFileExist = cacheFileFinal.exists();
if (finalFileExist && (parentObject instanceof TLRPC.TL_theme || totalBytesCount != 0 && totalBytesCount != cacheFileFinal.length())) {
@ -1255,18 +1261,20 @@ public class FileLoadOperation {
} else {
try {
if (pathSaveData != null) {
cacheFileFinal = new File(storePath, storeFileName);
int count = 1;
while (cacheFileFinal.exists()) {
int lastDotIndex = storeFileName.lastIndexOf('.');
String newFileName;
if (lastDotIndex > 0) {
newFileName = storeFileName.substring(0, lastDotIndex) + " (" + count + ")" + storeFileName.substring(lastDotIndex);
} else {
newFileName = storeFileName + " (" + count + ")";
synchronized (lockObject) {
cacheFileFinal = new File(storePath, storeFileName);
int count = 1;
while (cacheFileFinal.exists()) {
int lastDotIndex = storeFileName.lastIndexOf('.');
String newFileName;
if (lastDotIndex > 0) {
newFileName = storeFileName.substring(0, lastDotIndex) + " (" + count + ")" + storeFileName.substring(lastDotIndex);
} else {
newFileName = storeFileName + " (" + count + ")";
}
cacheFileFinal = new File(storePath, newFileName);
count++;
}
cacheFileFinal = new File(storePath, newFileName);
count++;
}
}
renameResult = cacheFileTemp.renameTo(cacheFileFinal);
@ -1292,14 +1300,15 @@ public class FileLoadOperation {
return;
}
cacheFileFinal = cacheFileTemp;
} else {
if (pathSaveData != null && cacheFileFinal.exists()) {
delegate.saveFilePath(pathSaveData, cacheFileFinal);
}
}
} else {
onFail(false, 0);
return;
}
if (pathSaveData != null && cacheFileFinal.exists()) {
delegate.saveFilePath(pathSaveData, cacheFileFinal);
}
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("finished downloading file to " + cacheFileFinal);

View File

@ -640,6 +640,9 @@ public class FileLoader extends BaseController {
}
FileLoadOperation operation = loadOperationPaths.get(fileName);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("checkFile operation fileName=" + fileName + " documentName=" + getDocumentFileName(document) + " operation=" + operation);
}
if (operation != null) {
if (cacheType != 10 && operation.isPreloadVideoOperation()) {
operation.setIsPreloadVideoOperation(false);
@ -686,7 +689,6 @@ public class FileLoader extends BaseController {
int type = MEDIA_DIR_CACHE;
long documentId = 0;
int dcId = 0;
String lastKnownPath = null;
if (secureDocument != null) {
operation = new FileLoadOperation(secureDocument);
@ -698,16 +700,24 @@ public class FileLoader extends BaseController {
type = MEDIA_DIR_IMAGE;
} else if (document != null) {
operation = new FileLoadOperation(document, parentObject);
documentId = document.id;
dcId = document.dc_id;
if (MessageObject.isVoiceDocument(document)) {
type = MEDIA_DIR_AUDIO;
} else if (MessageObject.isVideoDocument(document) || MessageObject.isGifDocument(document)) {
type = MEDIA_DIR_VIDEO;
documentId = document.id;
dcId = document.dc_id;
} else if (MessageObject.isStickerDocument(document)) {
type = MEDIA_DIR_CACHE;
documentId = document.id;
dcId = document.dc_id;
} else {
type = MEDIA_DIR_DOCUMENT;
documentId = document.id;
dcId = document.dc_id;
}
if (MessageObject.isRoundVideoDocument(document)) {
documentId = 0;
dcId = 0;
}
} else if (webDocument != null) {
operation = new FileLoadOperation(currentAccount, webDocument);
@ -844,33 +854,34 @@ public class FileLoader extends BaseController {
operation.setPriority(priority);
boolean started;
int maxCount, count;
if (queueType == QUEUE_TYPE_PRELOAD) {
int maxCount = priority > 0 ? 6 : 2;
int count = preloadingLoadOperationsCount.get(datacenterId);
maxCount = priority > 0 ? 6 : 2;
count = preloadingLoadOperationsCount.get(datacenterId);
if (started = (stream != null || count < maxCount)) {
if (operation.start(stream, streamOffset, streamPriority)) {
preloadingLoadOperationsCount.put(datacenterId, count + 1);
}
}
} else if (queueType == QUEUE_TYPE_AUDIO) {
int maxCount = priority > 0 ? 3 : 1;
int count = audioLoadOperationsCount.get(datacenterId);
maxCount = priority > 0 ? 3 : 1;
count = audioLoadOperationsCount.get(datacenterId);
if (started = (stream != null || count < maxCount)) {
if (operation.start(stream, streamOffset, streamPriority)) {
audioLoadOperationsCount.put(datacenterId, count + 1);
}
}
} else if (queueType == QUEUE_TYPE_IMAGE) {
int maxCount = priority > 0 ? 6 : 2;
int count = imageLoadOperationsCount.get(datacenterId);
maxCount = priority > 0 ? 6 : 2;
count = imageLoadOperationsCount.get(datacenterId);
if (started = (stream != null || count < maxCount)) {
if (operation.start(stream, streamOffset, streamPriority)) {
imageLoadOperationsCount.put(datacenterId, count + 1);
}
}
} else {
int maxCount = priority > 0 ? 4 : 1;
int count = fileLoadOperationsCount.get(datacenterId);
maxCount = priority > 0 ? 4 : 1;
count = fileLoadOperationsCount.get(datacenterId);
if (started = (stream != null || count < maxCount)) {
if (operation.start(stream, streamOffset, streamPriority)) {
fileLoadOperationsCount.put(datacenterId, count + 1);
@ -881,6 +892,11 @@ public class FileLoader extends BaseController {
}
}
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("loadFileInternal fileName=" + fileName + " documentName=" + getDocumentFileName(document) + " queueType=" + queueType + " maxCount=" + maxCount + " count=" + count);
}
if (!started) {
addOperationToQueue(operation, getLoadOperationQueue(datacenterId, queueType));
}
@ -906,7 +922,7 @@ public class FileLoader extends BaseController {
MessageObject messageObject = (MessageObject) parentObject;
int flag;
long dialogId = messageObject.getDialogId();
if (messageObject.isAnyKindOfSticker() || getMessagesController().isChatNoForwards(getMessagesController().getChat(-dialogId)) || messageObject.messageOwner.noforwards) {
if (messageObject.isRoundVideo() || messageObject.isVoice() || messageObject.isAnyKindOfSticker() || getMessagesController().isChatNoForwards(getMessagesController().getChat(-dialogId)) || messageObject.messageOwner.noforwards) {
return false;
}
if (dialogId >= 0) {
@ -1173,17 +1189,22 @@ public class FileLoader extends BaseController {
if (photoSize instanceof TLRPC.TL_photoStrippedSize || photoSize instanceof TLRPC.TL_photoPathSize) {
dir = null;
} else if (photoSize.location == null || photoSize.location.key != null || photoSize.location.volume_id == Integer.MIN_VALUE && photoSize.location.local_id < 0 || photoSize.size < 0) {
dir = getDirectory(MEDIA_DIR_CACHE);
dir = getDirectory(type = MEDIA_DIR_CACHE);
} else {
dir = getDirectory(MEDIA_DIR_IMAGE);
dir = getDirectory(type = MEDIA_DIR_IMAGE);
}
documentId = photoSize.location.volume_id;
dcId = photoSize.location.dc_id;
} else if (attach instanceof TLRPC.TL_videoSize) {
TLRPC.TL_videoSize videoSize = (TLRPC.TL_videoSize) attach;
if (videoSize.location == null || videoSize.location.key != null || videoSize.location.volume_id == Integer.MIN_VALUE && videoSize.location.local_id < 0 || videoSize.size < 0) {
dir = getDirectory(MEDIA_DIR_CACHE);
dir = getDirectory(type = MEDIA_DIR_CACHE);
} else {
dir = getDirectory(MEDIA_DIR_IMAGE);
dir = getDirectory(type = MEDIA_DIR_IMAGE);
}
documentId = videoSize.location.volume_id;
dcId = videoSize.location.dc_id;
} else if (attach instanceof TLRPC.FileLocation) {
TLRPC.FileLocation fileLocation = (TLRPC.FileLocation) attach;
if (fileLocation.key != null || fileLocation.volume_id == Integer.MIN_VALUE && fileLocation.local_id < 0) {
@ -1632,6 +1653,10 @@ public class FileLoader extends BaseController {
getDownloadController().clearRecentDownloadedFiles();
}
public void clearFilePaths() {
filePathDatabase.clear();
}
public static boolean checkUploadFileSize(int currentAccount, long length) {
boolean premium = AccountInstance.getInstance(currentAccount).getUserConfig().isPremium();
if (length < DEFAULT_MAX_FILE_SIZE || (length < DEFAULT_MAX_FILE_SIZE_PREMIUM && premium)) {

View File

@ -61,7 +61,7 @@ public class FilePathDatabase {
} else {
int version = database.executeInt("PRAGMA user_version");
if (BuildVars.LOGS_ENABLED) {
FileLog.d("current db version = " + version);
FileLog.d("current files db version = " + version);
}
if (version == 0) {
throw new Exception("malformed");
@ -140,6 +140,9 @@ public class FilePathDatabase {
cursor = database.queryFinalized("SELECT path FROM paths WHERE document_id = " + documentId + " AND dc_id = " + dc + " AND type = " + type);
if (cursor.next()) {
res[0] = cursor.stringValue(0);
if (BuildVars.DEBUG_VERSION) {
FileLog.d("get file path id=" + documentId + " dc=" + dc + " type=" + type + " path=" + res[0]);
}
}
cursor.dispose();
} catch (SQLiteException e) {
@ -159,6 +162,9 @@ public class FilePathDatabase {
cursor = database.queryFinalized("SELECT path FROM paths WHERE document_id = " + documentId + " AND dc_id = " + dc + " AND type = " + type);
if (cursor.next()) {
res = cursor.stringValue(0);
if (BuildVars.DEBUG_VERSION) {
FileLog.d("get file path id=" + documentId + " dc=" + dc + " type=" + type + " path=" + res);
}
}
cursor.dispose();
} catch (SQLiteException e) {
@ -170,6 +176,9 @@ public class FilePathDatabase {
public void putPath(long id, int dc, int type, String path) {
dispatchQueue.postRunnable(() -> {
if (BuildVars.DEBUG_VERSION) {
FileLog.d("put file path id=" + id + " dc=" + dc + " type=" + type + " path=" + path);
}
SQLitePreparedStatement state = null;
try {
if (path != null) {
@ -224,6 +233,16 @@ public class FilePathDatabase {
}
}
public void clear() {
dispatchQueue.postRunnable(() -> {
try {
database.executeFast("DELETE FROM paths WHERE 1").stepThis().dispose();
} catch (SQLiteException e) {
FileLog.e(e);
}
});
}
public static class PathData {
public final long id;
public final int dc;

View File

@ -1000,7 +1000,7 @@ public class ImageLoader {
boolean needInvert = false;
int orientation = 0;
File cacheFileFinal = cacheImage.finalFilePath;
boolean inEncryptedFile = cacheImage.secureDocument != null || cacheImage.encryptionKeyPath != null && cacheFileFinal != null && (cacheFileFinal.getAbsolutePath().endsWith(".enc") || cacheFileFinal.getAbsolutePath().endsWith(".64enc"));
boolean inEncryptedFile = cacheImage.secureDocument != null || cacheImage.encryptionKeyPath != null && cacheFileFinal != null && cacheFileFinal.getAbsolutePath().endsWith(".enc");
SecureDocumentKey secureDocumentKey;
byte[] secureDocumentHash;
if (cacheImage.secureDocument != null) {

View File

@ -359,20 +359,21 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (user.photo != null) {
strippedBitmap = user.photo.strippedBitmap;
hasStripped = user.photo.stripped_thumb != null;
if (MessagesController.getInstance(currentAccount).isPremiumUser(user) && user.photo.has_video && animationEnabled) {
if (animationEnabled && MessagesController.getInstance(currentAccount).isPremiumUser(user) && user.photo.has_video) {
final TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(user.id);
if (userFull == null) {
MessagesController.getInstance(currentAccount).loadFullUser(user, currentGuid, false);
}
if (userFull != null && userFull.profile_photo != null && userFull.profile_photo.video_sizes != null && !userFull.profile_photo.video_sizes.isEmpty()) {
TLRPC.VideoSize videoSize = userFull.profile_photo.video_sizes.get(0);
for (int i = 0; i < userFull.profile_photo.video_sizes.size(); i++) {
if ("p".equals(userFull.profile_photo.video_sizes.get(i).type)) {
videoSize = userFull.profile_photo.video_sizes.get(i);
break;
} else {
if (userFull.profile_photo != null && userFull.profile_photo.video_sizes != null && !userFull.profile_photo.video_sizes.isEmpty()) {
TLRPC.VideoSize videoSize = userFull.profile_photo.video_sizes.get(0);
for (int i = 0; i < userFull.profile_photo.video_sizes.size(); i++) {
if ("p".equals(userFull.profile_photo.video_sizes.get(i).type)) {
videoSize = userFull.profile_photo.video_sizes.get(i);
break;
}
}
videoLocation = ImageLocation.getForPhoto(videoSize, userFull.profile_photo);
}
videoLocation = ImageLocation.getForPhoto(videoSize, userFull.profile_photo);
}
}
}

View File

@ -107,11 +107,17 @@ public class MediaDataController extends BaseController {
public static String SHORTCUT_CATEGORY = "org.telegram.messenger.SHORTCUT_SHARE";
private static SparseArray<MediaDataController> Instance = new SparseArray<>();
private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
static {
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
lockObjects[i] = new Object();
}
}
public static MediaDataController getInstance(int num) {
MediaDataController localInstance = Instance.get(num);
if (localInstance == null) {
synchronized (MediaDataController.class) {
synchronized (lockObjects) {
localInstance = Instance.get(num);
if (localInstance == null) {
Instance.put(num, localInstance = new MediaDataController(num));

View File

@ -969,11 +969,12 @@ public class MessagesController extends BaseController implements NotificationCe
return 0;
};
private static final Object lockObject = new Object();
private static SparseArray<MessagesController> Instance = new SparseArray<>();
public static MessagesController getInstance(int num) {
MessagesController localInstance = Instance.get(num);
if (localInstance == null) {
synchronized (lockObjects[num]) {
synchronized (lockObject) {
localInstance = Instance.get(num);
if (localInstance == null) {
Instance.put(num, localInstance = new MessagesController(num));
@ -1738,6 +1739,7 @@ public class MessagesController extends BaseController implements NotificationCe
SharedPreferences.Editor editor = mainPreferences.edit();
boolean changed = false;
boolean keelAliveChanged = false;
resetAppConfig();
TLRPC.TL_jsonObject object = (TLRPC.TL_jsonObject) response;
for (int a = 0, N = object.value.size(); a < N; a++) {
TLRPC.TL_jsonObjectValue value = object.value.get(a);
@ -2524,6 +2526,11 @@ public class MessagesController extends BaseController implements NotificationCe
}));
}
private void resetAppConfig() {
getfileExperimentalParams = false;
mainPreferences.edit().remove("getfileExperimentalParams");
}
private boolean savePremiumFeaturesPreviewOrder(SharedPreferences.Editor editor, ArrayList<TLRPC.JSONValue> value) {
StringBuilder stringBuilder = new StringBuilder();
premiumFeaturesTypesToPosition.clear();
@ -9347,7 +9354,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
MessageObject oldMsg = dialogMessage.get(key);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("processDialogsUpdate oldMsg " + oldMsg + " old top_message = " + currentDialog.top_message + " new top_message = " + value.top_message);
FileLog.d("processDialogsUpdate oldMsg " + oldMsg + " old top_message = " + currentDialog.top_message + " new top_message = " + value.top_message + " unread_count =" + currentDialog.unread_count + " fromCache=" + fromCache);
FileLog.d("processDialogsUpdate oldMsgDeleted " + (oldMsg != null && oldMsg.deleted));
}
if (oldMsg == null || currentDialog.top_message > 0) {

View File

@ -89,6 +89,12 @@ public class MessagesStorage extends BaseController {
private CountDownLatch openSync = new CountDownLatch(1);
private static SparseArray<MessagesStorage> Instance = new SparseArray();
private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
static {
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
lockObjects[i] = new Object();
}
}
private final static int LAST_DB_VERSION = 98;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;
@ -97,7 +103,7 @@ public class MessagesStorage extends BaseController {
public static MessagesStorage getInstance(int num) {
MessagesStorage localInstance = Instance.get(num);
if (localInstance == null) {
synchronized (MessagesStorage.class) {
synchronized (lockObjects[num]) {
localInstance = Instance.get(num);
if (localInstance == null) {
Instance.put(num, localInstance = new MessagesStorage(num));
@ -10444,6 +10450,7 @@ public class MessagesStorage extends BaseController {
state.step();
state.dispose();
getMessagesStorage().getDatabase().commitTransaction();
data.reuse();
}
deleteFromDownloadQueue(idsToDelete, true);

View File

@ -148,11 +148,17 @@ public class NotificationsController extends BaseController {
}
private static SparseArray<NotificationsController> Instance = new SparseArray<>();
private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
static {
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
lockObjects[i] = new Object();
}
}
public static NotificationsController getInstance(int num) {
NotificationsController localInstance = Instance.get(num);
if (localInstance == null) {
synchronized (NotificationsController.class) {
synchronized (lockObjects[num]) {
localInstance = Instance.get(num);
if (localInstance == null) {
Instance.put(num, localInstance = new NotificationsController(num));

View File

@ -1213,7 +1213,7 @@ public class SharedConfig {
preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
boolean saveToGalleryLegacy = preferences.getBoolean("save_gallery", false);
if (saveToGalleryLegacy) {
if (saveToGalleryLegacy && BuildVars.NO_SCOPED_STORAGE) {
saveToGalleryFlags = SAVE_TO_GALLERY_FLAG_PEER + SAVE_TO_GALLERY_FLAG_CHANNELS + SAVE_TO_GALLERY_FLAG_GROUP;
preferences.edit().remove("save_gallery").putInt("save_gallery_flags", saveToGalleryFlags).apply();
} else {
@ -2342,7 +2342,7 @@ public class SharedConfig {
devicePerformanceClass = PERFORMANCE_CLASS_HIGH;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("device performance info (cpu_count = " + cpuCount + ", freq = " + maxCpuFreq + ", memoryClass = " + memoryClass + ", android version " + androidVersion + ")");
FileLog.d("device performance info selected_class = " + devicePerformanceClass + " (cpu_count = " + cpuCount + ", freq = " + maxCpuFreq + ", memoryClass = " + memoryClass + ", android version " + androidVersion + ")");
}
}

View File

@ -31887,6 +31887,9 @@ public class TLRPC {
case 0xdc7b1140:
result = new TL_messageEntityMentionName();
break;
case 0xd4a00ed5:
result = new TL_messageEntityCustomEmoji();
break;
}
if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in MessageEntity", constructor));
@ -60350,6 +60353,30 @@ public class TLRPC {
invoice_media.serializeToStream(stream);
}
}
public static class TL_messageEntityCustomEmoji extends MessageEntity {
public static int constructor = 0xd4a00ed5;
public int offset;
public int length;
public InputStickerSet stickerset;
public long document_id;
public void readParams(AbstractSerializedData stream, boolean exception) {
offset = stream.readInt32(exception);
length = stream.readInt32(exception);
stickerset = InputStickerSet.TLdeserialize(stream, stream.readInt32(exception), exception);
document_id = stream.readInt64(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(offset);
stream.writeInt32(length);
stickerset.serializeToStream(stream);
stream.writeInt64(document_id);
}
}
//functions
public static class Vector extends TLObject {

View File

@ -296,8 +296,12 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
Utilities.globalQueue.postRunnable(() -> {
boolean imagesCleared = false;
long clearedSize = 0;
boolean allItemsClear = true;
for (int a = 0; a < 7; a++) {
if (clearViewData[a] == null || !clearViewData[a].clear) {
if (clearViewData[a] != null) {
allItemsClear = false;
}
continue;
}
int type = -1;
@ -421,6 +425,9 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
totalDeviceFreeSize = availableBlocks * blockSize;
long finalClearedSize = clearedSize;
if (allItemsClear) {
FileLoader.getInstance(currentAccount).clearFilePaths();
}
FileLoader.getInstance(currentAccount).checkCurrentDownloadsFiles();
AndroidUtilities.runOnUIThread(() -> {

View File

@ -202,6 +202,57 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
setSpoilersSuppressed(false);
} else if (id == NotificationCenter.stopSpoilers) {
setSpoilersSuppressed(true);
} else if (id == NotificationCenter.userInfoDidLoad) {
if (currentUser != null) {
Long uid = (Long) args[0];
if (currentUser.id == uid) {
setAvatar(currentMessageObject);
}
}
}
}
private void setAvatar(MessageObject messageObject) {
if (messageObject == null) {
return;
}
if (isAvatarVisible) {
if (messageObject.customAvatarDrawable != null) {
avatarImage.setImageBitmap(messageObject.customAvatarDrawable);
} else if (currentUser != null) {
if (currentUser.photo != null) {
currentPhoto = currentUser.photo.photo_small;
} else {
currentPhoto = null;
}
avatarDrawable.setInfo(currentUser);
avatarImage.setForUserOrChat(currentUser, avatarDrawable, null, true);
} else if (currentChat != null) {
if (currentChat.photo != null) {
currentPhoto = currentChat.photo.photo_small;
} else {
currentPhoto = null;
}
avatarDrawable.setInfo(currentChat);
avatarImage.setForUserOrChat(currentChat, avatarDrawable);
} else if (messageObject != null && messageObject.isSponsored()) {
if (messageObject.sponsoredChatInvite != null && messageObject.sponsoredChatInvite.chat != null) {
avatarDrawable.setInfo(messageObject.sponsoredChatInvite.chat);
avatarImage.setForUserOrChat(messageObject.sponsoredChatInvite.chat, avatarDrawable);
} else {
avatarDrawable.setInfo(messageObject.sponsoredChatInvite);
TLRPC.Photo photo = messageObject.sponsoredChatInvite.photo;
if (photo != null) {
avatarImage.setImage(ImageLocation.getForPhoto(photo.sizes.get(0), photo), "50_50", avatarDrawable, null, null, 0);
}
}
} else {
currentPhoto = null;
avatarDrawable.setInfo(messageObject.getFromChatId(), null, null);
avatarImage.setImage(null, null, avatarDrawable, null, null, 0);
}
} else {
currentPhoto = null;
}
}
@ -3354,6 +3405,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.startSpoilers);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.stopSpoilers);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.userInfoDidLoad);
cancelShakeAnimation();
if (animationRunning) {
@ -3421,6 +3473,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.startSpoilers);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.stopSpoilers);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.userInfoDidLoad);
if (currentMessageObject != null) {
currentMessageObject.animateComments = false;
@ -3454,6 +3507,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
videoRadialProgress.onAttachedToWindow();
avatarImage.setParentView((View) getParent());
avatarImage.onAttachedToWindow();
if (currentMessageObject != null) {
setAvatar(currentMessageObject);
}
if (pollAvatarImages != null) {
for (int a = 0; a < pollAvatarImages.length; a++) {
pollAvatarImages[a].onAttachedToWindow();
@ -10713,46 +10769,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
updateCurrentUserAndChat();
if (isAvatarVisible) {
if (messageObject.customAvatarDrawable != null) {
avatarImage.setImageBitmap(messageObject.customAvatarDrawable);
} else if (currentUser != null) {
if (currentUser.photo != null) {
currentPhoto = currentUser.photo.photo_small;
} else {
currentPhoto = null;
}
avatarDrawable.setInfo(currentUser);
avatarImage.setForUserOrChat(currentUser, avatarDrawable, null, true);
} else if (currentChat != null) {
if (currentChat.photo != null) {
currentPhoto = currentChat.photo.photo_small;
} else {
currentPhoto = null;
}
avatarDrawable.setInfo(currentChat);
avatarImage.setForUserOrChat(currentChat, avatarDrawable);
} else if (messageObject != null && messageObject.isSponsored()) {
if (messageObject.sponsoredChatInvite != null && messageObject.sponsoredChatInvite.chat != null) {
avatarDrawable.setInfo(messageObject.sponsoredChatInvite.chat);
avatarImage.setForUserOrChat(messageObject.sponsoredChatInvite.chat, avatarDrawable);
} else {
avatarDrawable.setInfo(messageObject.sponsoredChatInvite);
TLRPC.Photo photo = messageObject.sponsoredChatInvite.photo;
if (photo != null) {
avatarImage.setImage(ImageLocation.getForPhoto(photo.sizes.get(0), photo), "50_50", avatarDrawable, null, null, 0);
}
}
} else {
currentPhoto = null;
avatarDrawable.setInfo(messageObject.getFromChatId(), null, null);
avatarImage.setImage(null, null, avatarDrawable, null, null, 0);
}
} else {
currentPhoto = null;
}
setAvatar(messageObject);
measureTime(messageObject);

View File

@ -32,7 +32,6 @@ import android.text.style.CharacterStyle;
import android.text.style.ClickableSpan;
import android.text.style.ReplacementSpan;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@ -2077,10 +2076,9 @@ public class DialogCell extends BaseCell {
if (isDialogCell) {
TLRPC.Dialog dialog = MessagesController.getInstance(currentAccount).dialogs_dict.get(currentDialogId);
if (dialog != null) {
if (mask == 0) {
clearingDialog = MessagesController.getInstance(currentAccount).isClearingDialog(dialog.id);
message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id);
if (message != null && NekoConfig.ignoreBlocked.Bool() && MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(message.getSenderId()) >= 0) {
clearingDialog = MessagesController.getInstance(currentAccount).isClearingDialog(dialog.id);
message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id);
if (message != null && NekoConfig.ignoreBlocked.Bool() && MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(message.getSenderId()) >= 0) {
if (MessagesController.getInstance(currentAccount).dialogMessageFromUnblocked.get(dialog.id) != null)
message = MessagesController.getInstance(currentAccount).dialogMessageFromUnblocked.get(dialog.id);
else {
@ -2110,7 +2108,7 @@ public class DialogCell extends BaseCell {
}
if (message != null) {
lastSendState = message.messageOwner.send_state;
}
}
} else {
unreadCount = 0;

View File

@ -64,7 +64,6 @@ 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;
@ -609,6 +608,7 @@ ChatActivity extends BaseFragment implements NotificationCenter.NotificationCent
private boolean allowContextBotPanel;
private boolean allowContextBotPanelSecond = true;
private AnimatorSet runningAnimation;
private int runningAnimationIndex = -1;
private MessageObject selectedObjectToEditCaption;
private MessageObject selectedObject;
@ -6874,7 +6874,7 @@ ChatActivity extends BaseFragment implements NotificationCenter.NotificationCent
reactionsMentiondownButton = new FrameLayout(context);
contentView.addView(reactionsMentiondownButton, LayoutHelper.createFrame(46, 61, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 7, 5));
mentionContainer = new MentionsContainerView(context, dialog_id, threadMessageId, contentView, themeDelegate) {
mentionContainer = new MentionsContainerView(context, dialog_id, threadMessageId, ChatActivity.this, themeDelegate) {
@Override
protected boolean canOpen() {
@ -10406,9 +10406,11 @@ ChatActivity extends BaseFragment implements NotificationCenter.NotificationCent
ObjectAnimator.ofFloat(stickersPanel, View.ALPHA, show ? 0.0f : 1.0f, show ? 1.0f : 0.0f)
);
runningAnimation.setDuration(150);
runningAnimationIndex = getNotificationCenter().setAnimationInProgress(runningAnimationIndex, null);
runningAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
getNotificationCenter().onAnimationFinish(runningAnimationIndex);
if (runningAnimation != null && runningAnimation.equals(animation)) {
if (!show) {
stickersAdapter.clearSearch();

View File

@ -146,6 +146,7 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable {
public int repeatCount;
private static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(8, new ThreadPoolExecutor.DiscardPolicy());
private static ScheduledThreadPoolExecutor generateCache = new ScheduledThreadPoolExecutor(4, new ThreadPoolExecutor.DiscardPolicy());
private Runnable uiRunnableNoFrame = new Runnable() {
@Override

View File

@ -193,8 +193,12 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
private FloatBuffer vertexBuffer;
private FloatBuffer textureBuffer;
private FloatBuffer oldTextureTextureBuffer;
private float scaleX;
private float scaleY;
private Size oldTexturePreviewSize;
private boolean flipAnimationInProgress;
private View parentView;
@ -545,7 +549,6 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
switchCameraDrawable = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(), R.drawable.avd_flip);
switchCameraButton.setImageDrawable(switchCameraDrawable);
@ -612,7 +615,11 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, final int width, final int height) {
if (cameraThread != null) {
cameraThread.surfaceWidth = width;
cameraThread.surfaceHeight = height;
cameraThread.updateScale();
}
}
@Override
@ -971,21 +978,21 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
private Size chooseOptimalSize(ArrayList<Size> previewSizes) {
ArrayList<Size> sortedSizes = new ArrayList<>();
for (int i = 0; i < previewSizes.size(); i++) {
if (Math.max(previewSizes.get(i).mHeight, previewSizes.get(i).mHeight) <= 1200 && Math.min(previewSizes.get(i).mHeight, previewSizes.get(i).mHeight) >= 320) {
if (Math.max(previewSizes.get(i).mHeight, previewSizes.get(i).mWidth) <= 1200 && Math.min(previewSizes.get(i).mHeight, previewSizes.get(i).mWidth) >= 320) {
sortedSizes.add(previewSizes.get(i));
}
}
if (sortedSizes.isEmpty() || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW) {
if (sortedSizes.isEmpty() || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_AVERAGE) {
return CameraController.chooseOptimalSize(previewSizes, 480, 270, aspectRatio);
}
Collections.sort(sortedSizes, (o1, o2) -> {
float a1 = Math.min(o1.mHeight, o1.mWidth) / (float) Math.max(o1.mHeight, o1.mWidth);
float a2 = Math.min(o2.mHeight, o2.mWidth) / (float) Math.max(o2.mHeight, o2.mWidth);
float a1 = Math.abs(1f - Math.min(o1.mHeight, o1.mWidth) / (float) Math.max(o1.mHeight, o1.mWidth));
float a2 = Math.abs(1f - Math.min(o2.mHeight, o2.mWidth) / (float) Math.max(o2.mHeight, o2.mWidth));
if (a1 < a2) {
return 1;
} else if (a1 > a2) {
return -1;
} else if (a1 > a2) {
return 1;
}
return 0;
});
@ -1131,10 +1138,20 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
private VideoRecorder videoEncoder;
private int surfaceWidth;
private int surfaceHeight;
public CameraGLThread(SurfaceTexture surface, int surfaceWidth, int surfaceHeight) {
super("CameraGLThread");
surfaceTexture = surface;
this.surfaceWidth = surfaceWidth;
this.surfaceHeight = surfaceHeight;
updateScale();
}
private void updateScale() {
int width = previewSize.getWidth();
int height = previewSize.getHeight();
@ -1142,13 +1159,19 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
width *= scale;
height *= scale;
if (width > height) {
if (width == height) {
scaleX = 1f;
scaleY = 1f;
} else if (width > height) {
scaleX = 1.0f;
scaleY = width / (float) surfaceHeight;
} else {
scaleX = height / (float) surfaceWidth;
scaleY = 1.0f;
}
FileLog.d("camera scaleX = " + scaleX + " scaleY = " + scaleY);
}
private boolean initGL() {
@ -1315,6 +1338,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
if (handler != null) {
sendMessage(handler.obtainMessage(DO_REINIT_MESSAGE), 0);
}
updateScale();
}
public void finish() {
@ -1432,6 +1456,8 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
oldCameraTexture[0] = cameraTexture[0];
cameraTextureAlpha = 0.0f;
cameraTexture[0] = 0;
oldTextureTextureBuffer = textureBuffer.duplicate();
oldTexturePreviewSize = previewSize;
}
cameraId++;
cameraReady = false;
@ -1446,6 +1472,21 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
cameraSurface = new SurfaceTexture(cameraTexture[0]);
cameraSurface.setOnFrameAvailableListener(surfaceTexture -> requestRender());
createCamera(cameraSurface);
cameraThread.updateScale();
float tX = 1.0f / scaleX / 2.0f;
float tY = 1.0f / scaleY / 2.0f;
float[] texData = {
0.5f - tX, 0.5f - tY,
0.5f + tX, 0.5f - tY,
0.5f - tX, 0.5f + tY,
0.5f + tX, 0.5f + tY
};
textureBuffer = ByteBuffer.allocateDirect(texData.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
textureBuffer.put(texData).position(0);
break;
}
case DO_SETSESSION_MESSAGE: {
@ -1620,8 +1661,8 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
private int textureMatrixHandle;
private int positionHandle;
private int textureHandle;
private int scaleXHandle;
private int scaleYHandle;
private int resolutionHandle;
private int previewSizeHandle;
private int alphaHandle;
private int zeroTimeStamps;
private Integer lastCameraId = 0;
@ -1958,25 +1999,38 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
videoLast = timestampNanos;
GLES20.glUseProgram(drawProgram);
GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 12, vertexBuffer);
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glEnableVertexAttribArray(textureHandle);
GLES20.glUniform1f(scaleXHandle, scaleX);
GLES20.glUniform1f(scaleYHandle, scaleY);
GLES20.glUniformMatrix4fv(vertexMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glEnableVertexAttribArray(textureHandle);
GLES20.glUniform2f(resolutionHandle, videoWidth, videoHeight);
if (oldCameraTexture[0] != 0) {
if (!blendEnabled) {
GLES20.glEnable(GLES20.GL_BLEND);
blendEnabled = true;
}
if (oldTexturePreviewSize != null) {
GLES20.glUniform2f(previewSizeHandle, oldTexturePreviewSize.getWidth(), oldTexturePreviewSize.getHeight());
}
GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, oldTextureTextureBuffer);
GLES20.glUniformMatrix4fv(textureMatrixHandle, 1, false, moldSTMatrix, 0);
GLES20.glUniform1f(alphaHandle, 1.0f);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, oldCameraTexture[0]);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
if (previewSize != null) {
GLES20.glUniform2f(previewSizeHandle, previewSize.getWidth(), previewSize.getHeight());
}
GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 12, vertexBuffer);
GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glUniformMatrix4fv(textureMatrixHandle, 1, false, mSTMatrix, 0);
GLES20.glUniform1f(alphaHandle, cameraTextureAlpha);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTexture[0]);
@ -2024,14 +2078,19 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
public void run() {
final TextureView textureView = InstantCameraView.this.textureView;
if (textureView != null) {
final Bitmap bitmap = textureView.getBitmap(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
AndroidUtilities.runOnUIThread(() -> {
if ((bitmap == null || bitmap.getPixel(0, 0) == 0) && keyframeThumbs.size() > 1) {
keyframeThumbs.add(keyframeThumbs.get(keyframeThumbs.size() - 1));
} else {
keyframeThumbs.add(bitmap);
}
});
try {
final Bitmap bitmap = textureView.getBitmap(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
AndroidUtilities.runOnUIThread(() -> {
if ((bitmap == null || bitmap.getPixel(0, 0) == 0) && keyframeThumbs.size() > 1) {
keyframeThumbs.add(keyframeThumbs.get(keyframeThumbs.size() - 1));
} else {
keyframeThumbs.add(bitmap);
}
});
} catch (Exception e) {
FileLog.e(e);
}
}
}
}
@ -2344,8 +2403,8 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
} else {
positionHandle = GLES20.glGetAttribLocation(drawProgram, "aPosition");
textureHandle = GLES20.glGetAttribLocation(drawProgram, "aTextureCoord");
scaleXHandle = GLES20.glGetUniformLocation(drawProgram, "scaleX");
scaleYHandle = GLES20.glGetUniformLocation(drawProgram, "scaleY");
previewSizeHandle = GLES20.glGetUniformLocation(drawProgram, "preview");
resolutionHandle = GLES20.glGetUniformLocation(drawProgram, "resolution");
alphaHandle = GLES20.glGetUniformLocation(drawProgram, "alpha");
vertexMatrixHandle = GLES20.glGetUniformLocation(drawProgram, "uMVPMatrix");
textureMatrixHandle = GLES20.glGetUniformLocation(drawProgram, "uSTMatrix");
@ -2538,18 +2597,21 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
}
private String createFragmentShader(Size previewSize) {
if (SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || Math.max(previewSize.getHeight(), previewSize.getWidth()) * 0.7f < MessagesController.getInstance(currentAccount).roundVideoSize) {
if (SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_AVERAGE || Math.max(previewSize.getHeight(), previewSize.getWidth()) * 0.7f < MessagesController.getInstance(currentAccount).roundVideoSize) {
return "#extension GL_OES_EGL_image_external : require\n" +
"precision highp float;\n" +
"varying vec2 vTextureCoord;\n" +
"uniform float scaleX;\n" +
"uniform float scaleY;\n" +
"uniform float alpha;\n" +
"uniform vec2 preview;\n" +
"uniform vec2 resolution;\n" +
"uniform samplerExternalOES sTexture;\n" +
"void main() {\n" +
" vec2 coord = vec2((vTextureCoord.x - 0.5) * scaleX, (vTextureCoord.y - 0.5) * scaleY);\n" +
" float coef = ceil(clamp(0.2601 - dot(coord, coord), 0.0, 1.0));\n" +
" vec3 color = texture2D(sTexture, vTextureCoord).rgb * coef + (1.0 - step(0.001, coef));\n" +
" vec4 textColor = texture2D(sTexture, vTextureCoord);\n" +
" vec2 coord = resolution * 0.5;\n" +
" float radius = 0.51 * resolution.x;\n" +
" float d = length(coord - gl_FragCoord.xy) - radius;\n" +
" float t = clamp(d, 0.0, 1.0);\n" +
" vec3 color = mix(textColor.rgb, vec3(1, 1, 1), t);\n" +
" gl_FragColor = vec4(color * alpha, alpha);\n" +
"}\n";
}
@ -2557,27 +2619,29 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
return "#extension GL_OES_EGL_image_external : require\n" +
"precision highp float;\n" +
"varying vec2 vTextureCoord;\n" +
"uniform float scaleX;\n" +
"uniform float scaleY;\n" +
"uniform vec2 resolution;\n" +
"uniform vec2 preview;\n" +
"uniform float alpha;\n" +
"const float kernel = 1.0;\n" +
"const float pixelSizeX = 1.0 / " + previewSize.getWidth() + ".0;\n" +
"const float pixelSizeY = 1.0 / " + previewSize.getHeight() + ".0;\n" +
"uniform samplerExternalOES sTexture;\n" +
"void main() {\n" +
" float pixelSizeX = 1.0 / preview.x;\n" +
" float pixelSizeY = 1.0 / preview.y;\n" +
" vec3 accumulation = vec3(0);\n" +
" vec3 weightsum = vec3(0);\n" +
" for (float x = -kernel; x <= kernel; x++){\n" +
" for (float y = -kernel; y <= kernel; y++){\n" +
" for (float x = -kernel; x < kernel; x++){\n" +
" for (float y = -kernel; y < kernel; y++){\n" +
" accumulation += texture2D(sTexture, vTextureCoord + vec2(x * pixelSizeX, y * pixelSizeY)).xyz;\n" +
" weightsum += 1.0;\n" +
" }\n" +
" }\n" +
" vec4 textColor = vec4(accumulation / weightsum, 1.0);\n" +
" vec2 coord = vec2((vTextureCoord.x - 0.5) * scaleX, (vTextureCoord.y - 0.5) * scaleY);\n" +
" float coef = ceil(clamp(0.2601 - dot(coord, coord), 0.0, 1.0));\n" +
" vec3 color = textColor.rgb * coef + (1.0 - step(0.001, coef));\n" +
" vec2 coord = resolution * 0.5;\n" +
" float radius = 0.51 * resolution.x;\n" +
" float d = length(coord - gl_FragCoord.xy) - radius;\n" +
" float t = clamp(d, 0.0, 1.0);\n" +
" vec3 color = mix(textColor.rgb, vec3(1, 1, 1), t);\n" +
" gl_FragColor = vec4(color * alpha, alpha);\n" +
"}\n";
}
@ -2701,6 +2765,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
}
ValueAnimator finishZoomTransition;
public void finishZoom() {
if (finishZoomTransition != null) {
return;

View File

@ -2,20 +2,15 @@ package org.telegram.ui.Components;
import static org.telegram.messenger.AndroidUtilities.dp;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.FloatValueHolder;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
@ -26,12 +21,14 @@ import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Adapters.MentionsAdapter;
import org.telegram.ui.Adapters.PaddedListAdapter;
import org.telegram.ui.Cells.AboutLinkCell;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.ContentPreviewViewer;
public class MentionsContainerView extends BlurredFrameLayout {
@ -45,12 +42,14 @@ public class MentionsContainerView extends BlurredFrameLayout {
private PaddedListAdapter paddedAdapter;
private MentionsAdapter adapter;
ChatActivity chatActivity;
private float containerTop, containerBottom, containerPadding, listViewPadding;
public MentionsContainerView(@NonNull Context context, long dialogId, int threadMessageId, SizeNotifierFrameLayout sizeNotifierFrameLayout, Theme.ResourcesProvider resourcesProvider) {
super(context, sizeNotifierFrameLayout);
this.sizeNotifierFrameLayout = sizeNotifierFrameLayout;
public MentionsContainerView(@NonNull Context context, long dialogId, int threadMessageId, ChatActivity chatActivity, Theme.ResourcesProvider resourcesProvider) {
super(context, chatActivity.contentView);
this.chatActivity = chatActivity;
this.sizeNotifierFrameLayout = chatActivity.contentView;
this.resourcesProvider = resourcesProvider;
this.drawBlur = false;
this.isTopView = false;
@ -180,7 +179,7 @@ public class MentionsContainerView extends BlurredFrameLayout {
public void onItemCountUpdate(int oldCount, int newCount) {
if (listView.getLayoutManager() != gridLayoutManager && shown) {
AndroidUtilities.cancelRunOnUIThread(updateVisibilityRunnable);
AndroidUtilities.runOnUIThread(updateVisibilityRunnable);
AndroidUtilities.runOnUIThread(updateVisibilityRunnable, chatActivity.fragmentOpened ? 0 : 100);
}
}
@ -397,7 +396,7 @@ public class MentionsContainerView extends BlurredFrameLayout {
if (listViewTranslationAnimator != null) {
listViewTranslationAnimator.cancel();
}
AndroidUtilities.runOnUIThread(updateVisibilityRunnable);
AndroidUtilities.runOnUIThread(updateVisibilityRunnable, chatActivity.fragmentOpened ? 0 : 100);
if (show) {
onOpen();
} else {
@ -410,6 +409,7 @@ public class MentionsContainerView extends BlurredFrameLayout {
}
private SpringAnimation listViewTranslationAnimator;
private int animationIndex = -1;
private boolean listViewHiding = false;
private float hideT = 0;
private boolean switchLayoutManagerOnEnd = false;
@ -451,6 +451,8 @@ public class MentionsContainerView extends BlurredFrameLayout {
updateVisibility(shown = true);
}
} else {
int account = UserConfig.selectedAccount;
animationIndex = NotificationCenter.getInstance(account).setAnimationInProgress(animationIndex, null);
listViewTranslationAnimator =
new SpringAnimation(new FloatValueHolder(fromTranslation))
.setSpring(
@ -478,6 +480,9 @@ public class MentionsContainerView extends BlurredFrameLayout {
}
});
}
listViewTranslationAnimator.addEndListener((animation, canceled, value, velocity) -> {
NotificationCenter.getInstance(account).onAnimationFinish(animationIndex);
});
listViewTranslationAnimator.start();
}
} else {

View File

@ -12,6 +12,9 @@ import android.graphics.Shader;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import org.telegram.messenger.R;
import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.Theme;
import java.io.BufferedReader;
@ -143,7 +146,26 @@ public class Star3DIcon {
GLES20.glVertexAttribPointer(0, 3, GLES20.GL_FLOAT, false, 0, mVertices);
GLES20.glEnableVertexAttribArray(0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
Bitmap bitmap = SvgHelper.getBitmap(R.raw.start_texture, 80, 80, Color.WHITE);
Utilities.stackBlurBitmap(bitmap, 3);
final int[] texture = new int[1];
GLES20.glGenTextures(1, texture, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture[0]);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();
final int[] textureDatHandle = new int[1];
GLES20.glGenTextures(1, textureDatHandle, 0);
mTextureDataHandle = textureDatHandle[0];
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureDatHandle[0]);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle);
Bitmap bitmap1 = getBitmapFromAsset(context, "flecks.png");
@ -166,6 +188,9 @@ public class Star3DIcon {
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBackgroundTextureHandle);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture[0]);
GLES20.glUniform1i(mTextureUniformHandle, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, normalMap[0]);

View File

@ -11,6 +11,7 @@ import android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.AppIconsSelectorCell;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.LayoutHelper;
@ -21,7 +22,7 @@ import java.util.List;
public class PremiumAppIconsPreviewView extends FrameLayout implements PagerHeaderView {
private List<LauncherIconController.LauncherIcon> icons = new ArrayList<>();
private AppIconsSelectorCell.AdaptiveIconImageView topIcon, bottomLeftIcon, bottomRightIcon;
private AdaptiveIconImageView topIcon, bottomLeftIcon, bottomRightIcon;
boolean isEmpty;
public PremiumAppIconsPreviewView(Context context) {
@ -42,27 +43,16 @@ public class PremiumAppIconsPreviewView extends FrameLayout implements PagerHead
return;
}
topIcon = newIconView(context, icons.get(0));
bottomLeftIcon = newIconView(context, icons.get(1));
bottomRightIcon = newIconView(context, icons.get(2));
topIcon = newIconView(context, 0);
bottomLeftIcon = newIconView(context, 1);
bottomRightIcon = newIconView(context, 2);
setClipChildren(false);
}
private AppIconsSelectorCell.AdaptiveIconImageView newIconView(Context ctx, LauncherIconController.LauncherIcon icon) {
AppIconsSelectorCell.AdaptiveIconImageView iconImageView = new AppIconsSelectorCell.AdaptiveIconImageView(ctx) {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private AdaptiveIconImageView newIconView(Context ctx, int i) {
LauncherIconController.LauncherIcon icon = icons.get(i);
{
paint.setColor(Color.WHITE);
}
@Override
public void draw(Canvas canvas) {
AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight());
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(AppIconsSelectorCell.ICONS_ROUND_RADIUS), AndroidUtilities.dp(AppIconsSelectorCell.ICONS_ROUND_RADIUS), paint);
super.draw(canvas);
}
};
AdaptiveIconImageView iconImageView = new AdaptiveIconImageView(ctx, i);
iconImageView.setLayoutParams(LayoutHelper.createFrame(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER, 0, 52, 0, 0));
iconImageView.setForeground(icon.foreground);
iconImageView.setBackgroundResource(icon.background);
@ -108,6 +98,7 @@ public class PremiumAppIconsPreviewView extends FrameLayout implements PagerHead
bottomRightIcon.setScaleX(scale);
bottomRightIcon.setScaleY(scale);
topIcon.setTranslationY(progress * (getTop() - topIcon.getTop() - topIcon.getHeight() * 1.8f - AndroidUtilities.dp(32)));
topIcon.setTranslationX(progress * AndroidUtilities.dp(16));
scale = AndroidUtilities.lerp(1f, 1.8f, progress);
@ -115,6 +106,7 @@ public class PremiumAppIconsPreviewView extends FrameLayout implements PagerHead
topIcon.setScaleX(scale);
topIcon.setScaleY(scale);
float leftProgress = CubicBezierInterpolator.EASE_OUT.getInterpolation(progress);
bottomLeftIcon.setTranslationX(leftProgress * (getLeft() - bottomLeftIcon.getLeft() - bottomLeftIcon.getWidth() * 2.5f + AndroidUtilities.dp(32)));
bottomLeftIcon.setTranslationY(leftProgress * (getBottom() - bottomLeftIcon.getBottom() + bottomLeftIcon.getHeight() * 2.5f + AndroidUtilities.dp(32)));
@ -122,5 +114,48 @@ public class PremiumAppIconsPreviewView extends FrameLayout implements PagerHead
scale = Utilities.clamp(scale, 1f, 0);
bottomLeftIcon.setScaleX(scale);
bottomLeftIcon.setScaleY(scale);
float p = progress < 0.4f ? progress / 0.4f : 1f;
bottomRightIcon.particlesScale = p;
topIcon.particlesScale = p;
bottomLeftIcon.particlesScale = p;
}
private class AdaptiveIconImageView extends AppIconsSelectorCell.AdaptiveIconImageView {
StarParticlesView.Drawable drawable = new StarParticlesView.Drawable(20);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
float particlesScale;
public AdaptiveIconImageView(Context ctx, int i) {
super(ctx);
drawable.size1 = 12;
drawable.size2 = 8;
drawable.size3 = 6;
if (i == 1) {
drawable.type = StarParticlesView.TYPE_APP_ICON_REACT;
} if (i == 0) {
drawable.type = StarParticlesView.TYPE_APP_ICON_STAR_PREMIUM;
}
drawable.colorKey = Theme.key_premiumStartSmallStarsColor2;
drawable.init();
paint.setColor(Color.WHITE);
}
@Override
public void draw(Canvas canvas) {
int outBoundOffset = AndroidUtilities.dp(10);
drawable.excludeRect.set(AndroidUtilities.dp(5), AndroidUtilities.dp(5), getMeasuredWidth() - AndroidUtilities.dp(5), getMeasuredHeight() - AndroidUtilities.dp(5));
drawable.rect.set(-outBoundOffset, -outBoundOffset, getWidth() + outBoundOffset, getHeight() + outBoundOffset);
canvas.save();
canvas.scale(1f - particlesScale, 1f - particlesScale, getMeasuredWidth() / 2f, getMeasuredHeight() / 2f);
drawable.onDraw(canvas);
canvas.restore();
invalidate();
AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight());
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(AppIconsSelectorCell.ICONS_ROUND_RADIUS), AndroidUtilities.dp(AppIconsSelectorCell.ICONS_ROUND_RADIUS), paint);
super.draw(canvas);
}
}
}

View File

@ -31,9 +31,11 @@ import java.util.ArrayList;
public class StarParticlesView extends View {
public Drawable drawable;
int size;
boolean distributionAlgorithm;
public final static int TYPE_APP_ICON_REACT = 1001;
public static final int TYPE_APP_ICON_STAR_PREMIUM = 1002;
public StarParticlesView(Context context) {
super(context);
@ -136,6 +138,7 @@ public class StarParticlesView extends View {
public boolean roundEffect = true;
public int type = -1;
public String colorKey = Theme.key_premiumStartSmallStarsColor;
public boolean svg;
public final static int TYPE_SETTINGS = 101;
@ -191,9 +194,9 @@ public class StarParticlesView extends View {
res = R.raw.premium_object_settings;
}
stars[i] = SvgHelper.getBitmap(res, size, size, ColorUtils.setAlphaComponent(Theme.getColor(colorKey), 30));
svg = true;
continue;
}
if (type == PremiumPreviewFragment.PREMIUM_FEATURE_ADS) {
}else if (type == PremiumPreviewFragment.PREMIUM_FEATURE_ADS) {
int res;
if (i == 0) {
res = R.raw.premium_object_adsbubble;
@ -203,9 +206,9 @@ public class StarParticlesView extends View {
res = R.raw.premium_object_noads;
}
stars[i] = SvgHelper.getBitmap(res, size, size, ColorUtils.setAlphaComponent(Theme.getColor(colorKey), 30));
svg = true;
continue;
}
if (type == PremiumPreviewFragment.PREMIUM_FEATURE_ANIMATED_AVATARS) {
} else if (type == PremiumPreviewFragment.PREMIUM_FEATURE_ANIMATED_AVATARS) {
int res;
if (i == 0) {
res = R.raw.premium_object_video2;
@ -215,6 +218,15 @@ public class StarParticlesView extends View {
res = R.raw.premium_object_user;
}
stars[i] = SvgHelper.getBitmap(res, size, size, ColorUtils.setAlphaComponent(Theme.getColor(colorKey), 30));
svg = true;
continue;
} else if (type == TYPE_APP_ICON_REACT) {
stars[i] = SvgHelper.getBitmap(R.raw.premium_object_fire, size, size, ColorUtils.setAlphaComponent(Theme.getColor(colorKey), 30));
svg = true;
continue;
} else if (type == TYPE_APP_ICON_STAR_PREMIUM) {
stars[i] = SvgHelper.getBitmap(R.raw.premium_object_star2, size, size, ColorUtils.setAlphaComponent(Theme.getColor(colorKey), 30));
svg = true;
continue;
}
@ -255,7 +267,11 @@ public class StarParticlesView extends View {
if (roundEffect) {
paint1.setPathEffect(new CornerPathEffect(AndroidUtilities.dpf2(size1 / 5f)));
}
paint1.setAlpha(120);
if (useBlur) {
paint1.setAlpha(60);
} else {
paint1.setAlpha(120);
}
canvas.drawPath(path, paint1);
paint1.setPathEffect(null);
paint1.setAlpha(255);
@ -475,7 +491,7 @@ public class StarParticlesView extends View {
double a = Math.atan2(x - rect.centerX(), y - rect.centerY());
vecX = (float) Math.sin(a);
vecY = (float) Math.cos(a);
if (type == PremiumPreviewFragment.PREMIUM_FEATURE_ADVANCED_CHAT_MANAGEMENT || type == PremiumPreviewFragment.PREMIUM_FEATURE_ADS || type == PremiumPreviewFragment.PREMIUM_FEATURE_ANIMATED_AVATARS) {
if (svg) {
alpha = (int) (120 * ((50 + Utilities.fastRandom.nextInt(50)) / 100f));
} else {
alpha = (int) (255 * ((50 + Utilities.fastRandom.nextInt(50)) / 100f));

View File

@ -346,17 +346,21 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
}
}
public boolean initIfEmpty(ImageLocation imageLocation, ImageLocation thumbLocation) {
public boolean initIfEmpty(ImageLocation imageLocation, ImageLocation thumbLocation, boolean reload) {
if (imageLocation == null || thumbLocation == null || settingMainPhoto != 0) {
return false;
}
if (prevImageLocation == null || prevImageLocation.location.local_id != imageLocation.location.local_id) {
if (!imagesLocations.isEmpty()) {
prevImageLocation = imageLocation;
MessagesController.getInstance(currentAccount).loadDialogPhotos(dialogId, 80, 0, true, parentClassGuid);
if (reload) {
MessagesController.getInstance(currentAccount).loadDialogPhotos(dialogId, 80, 0, true, parentClassGuid);
}
return true;
} else {
MessagesController.getInstance(currentAccount).loadDialogPhotos(dialogId, 80, 0, true, parentClassGuid);
if (reload) {
MessagesController.getInstance(currentAccount).loadDialogPhotos(dialogId, 80, 0, true, parentClassGuid);
}
}
}
if (!imagesLocations.isEmpty()) {

View File

@ -122,7 +122,8 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
private static ThreadLocal<byte[]> bufferLocal = new ThreadLocal<>();
private ArrayList<WeakReference<View>> parentViews = new ArrayList<>();
private static DispatchQueuePool loadFrameRunnableQueue = new DispatchQueuePool(4);
private static final DispatchQueuePool loadFrameRunnableQueue = new DispatchQueuePool(2);
private static final DispatchQueuePool largeSizeLoadFrameRunnableQueue = new DispatchQueuePool(4);
private static ThreadPoolExecutor lottieCacheGenerateQueue;
private static HashSet<String> generatingCacheFiles = new HashSet<>();
@ -133,6 +134,8 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
private Runnable onAnimationEndListener;
private Runnable onFrameReadyRunnable;
private DispatchQueuePool loadFrameQueue = loadFrameRunnableQueue;
protected Runnable uiRunnableNoFrame = new Runnable() {
@Override
public void run() {
@ -394,6 +397,11 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
if (precache && lottieCacheGenerateQueue == null) {
lottieCacheGenerateQueue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
}
if (w > AndroidUtilities.dp(120) || h > AndroidUtilities.dp(120)) {
loadFrameQueue = largeSizeLoadFrameRunnableQueue;
} else {
loadFrameQueue = loadFrameRunnableQueue;
}
if (nativePtr == 0) {
file.delete();
}
@ -424,6 +432,11 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
shouldLimitFps = false;
}
timeBetweenFrames = Math.max(shouldLimitFps ? 33 : 16, (int) (1000.0f / metaData[1]));
if (w > AndroidUtilities.dp(100) || w > AndroidUtilities.dp(100)) {
loadFrameQueue = largeSizeLoadFrameRunnableQueue;
} else {
loadFrameQueue = loadFrameRunnableQueue;
}
}
public RLottieDrawable(int rawRes, String name, int w, int h) {
@ -828,7 +841,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable {
pendingReplaceColors = newReplaceColors;
newReplaceColors = null;
}
loadFrameRunnableQueue.execute(loadFrameTask = loadFrameRunnable);
loadFrameQueue.execute(loadFrameTask = loadFrameRunnable);
return true;
}

View File

@ -1,6 +1,7 @@
package org.telegram.ui.Components;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
@ -20,6 +21,8 @@ public class ScamDrawable extends Drawable {
private int textWidth;
private String text;
private int currentType;
int colorAlpha = 255;
int alpha = 255;
public ScamDrawable(int textSize, int type) {
super();
@ -54,11 +57,16 @@ public class ScamDrawable extends Drawable {
public void setColor(int color) {
textPaint.setColor(color);
paint.setColor(color);
colorAlpha = Color.alpha(color);
}
@Override
public void setAlpha(int alpha) {
if (this.alpha != alpha) {
int localAlpha = (int) (colorAlpha * (alpha / 255f));
paint.setAlpha(localAlpha);
textPaint.setAlpha(localAlpha);
}
}
@Override

View File

@ -566,6 +566,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
notificationCenter.addObserver(this, NotificationCenter.messagesDeleted);
notificationCenter.addObserver(this, NotificationCenter.replaceMessagesObjects);
notificationCenter.addObserver(this, NotificationCenter.chatInfoDidLoad);
notificationCenter.addObserver(this, NotificationCenter.fileLoaded);
}
public void addDelegate(SharedMediaPreloaderDelegate delegate) {
@ -590,6 +591,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
notificationCenter.removeObserver(this, NotificationCenter.messagesDeleted);
notificationCenter.removeObserver(this, NotificationCenter.replaceMessagesObjects);
notificationCenter.removeObserver(this, NotificationCenter.chatInfoDidLoad);
notificationCenter.removeObserver(this, NotificationCenter.fileLoaded);
}
public int[] getLastMediaCount() {
@ -823,6 +825,17 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
if (dialogId < 0 && chatFull.id == -dialogId) {
setChatInfo(chatFull);
}
} else if (id == NotificationCenter.fileLoaded) {
ArrayList<MessageObject> allMessages = new ArrayList<>();
for (int i = 0 ; i < sharedMediaData.length; i++) {
allMessages.addAll(sharedMediaData[i].messages);
}
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
FileLoader.getInstance(account).checkMediaExistance(allMessages);
}
});
}
}
@ -2763,6 +2776,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
sharedMediaData[type].totalCount = mediaData[type].totalCount;
}
sharedMediaData[type].messages.addAll(mediaData[type].messages);
sharedMediaData[type].sections.addAll(mediaData[type].sections);
for (HashMap.Entry<String, ArrayList<MessageObject>> entry : mediaData[type].sectionArrays.entrySet()) {
sharedMediaData[type].sectionArrays.put(entry.getKey(), new ArrayList<>(entry.getValue()));

View File

@ -22,6 +22,7 @@ import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Cells.ChatMessageCell;
@ -223,6 +224,7 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe
for (int i = 0; i < drawingObjects.size(); i++) {
DrawingObject drawingObject = drawingObjects.get(i);
drawingObject.viewFound = false;
float childY = 0;
for (int k = 0; k < listView.getChildCount(); k++) {
View child = listView.getChildAt(k);
if (child instanceof ChatMessageCell) {
@ -231,10 +233,10 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe
drawingObject.viewFound = true;
float viewX = listView.getX() + child.getX();
float viewY = listView.getY() + child.getY();
childY = child.getY();
if (drawingObject.isPremiumSticker) {
drawingObject.lastX = viewX + cell.getPhotoImage().getImageX();
drawingObject.lastY = viewY + cell.getPhotoImage().getImageY();
;
} else {
viewX += cell.getPhotoImage().getImageX();
viewY += cell.getPhotoImage().getImageY();
@ -254,6 +256,16 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe
}
}
if (!drawingObject.viewFound || childY + drawingObject.lastH < chatActivity.getChatListViewPadding() || childY > listView.getMeasuredHeight() - chatActivity.blurredViewBottomOffset) {
drawingObject.removing = true;
}
if (drawingObject.removing && drawingObject.removeProgress != 1f) {
drawingObject.removeProgress = Utilities.clamp(drawingObject.removeProgress + 16 / 150f, 1f, 0);
drawingObject.imageReceiver.setAlpha(1f - drawingObject.removeProgress);
chatActivity.contentView.invalidate();
}
if (drawingObject.isPremiumSticker) {
float size = drawingObject.lastH * 1.49926f;
float paddingHorizontal = size * 0.0546875f;
@ -283,7 +295,7 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe
drawingObject.imageReceiver.draw(canvas);
}
}
if (drawingObject.wasPlayed && drawingObject.imageReceiver.getLottieAnimation() != null && drawingObject.imageReceiver.getLottieAnimation().getCurrentFrame() == drawingObject.imageReceiver.getLottieAnimation().getFramesCount() - 2) {
if (drawingObject.removeProgress == 1f || (drawingObject.wasPlayed && drawingObject.imageReceiver.getLottieAnimation() != null && drawingObject.imageReceiver.getLottieAnimation().getCurrentFrame() == drawingObject.imageReceiver.getLottieAnimation().getFramesCount() - 2)) {
drawingObjects.remove(i);
i--;
} else if (drawingObject.imageReceiver.getLottieAnimation() != null && drawingObject.imageReceiver.getLottieAnimation().isRunning()) {
@ -631,6 +643,8 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe
public boolean isPremiumSticker;
boolean wasPlayed;
boolean isOut;
boolean removing;
float removeProgress;
int messageId;
TLRPC.Document document;
ImageReceiver imageReceiver = new ImageReceiver();

View File

@ -7452,7 +7452,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
avatarsViewPager.setHasActiveVideo(hasAttachedRenderer);
avatarsViewPager.setData(peerId, true);
avatarsViewPager.setCreateThumbFromParent(true);
avatarsViewPager.initIfEmpty(imageLocation, thumbLocation);
avatarsViewPager.initIfEmpty(imageLocation, thumbLocation, true);
if (scrimRenderer != null) {
scrimRenderer.setShowingAsScrimView(true, true);
}
@ -8437,7 +8437,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
thumb = thumbLocation;
}
avatarsViewPager.setCreateThumbFromParent(false);
avatarsViewPager.initIfEmpty(imageLocation, thumb);
avatarsViewPager.initIfEmpty(imageLocation, thumb, true);
avatar = null;
avatarBig = null;
AndroidUtilities.updateVisibleRows(listView);
@ -8465,7 +8465,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
thumb = thumbLocation;
}
avatarsViewPager.setCreateThumbFromParent(false);
avatarsViewPager.initIfEmpty(imageLocation, thumb);
avatarsViewPager.initIfEmpty(imageLocation, thumb, true);
avatar = null;
avatarBig = null;
AndroidUtilities.updateVisibleRows(listView);

View File

@ -68,6 +68,7 @@ import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.transition.TransitionValues;
import android.util.FloatProperty;
import android.util.Log;
import android.util.Property;
import android.util.Range;
import android.util.SparseArray;
@ -12165,13 +12166,22 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (!exists && f1Final != null) {
exists = f1Final.exists();
}
File f2Local = f2Final;
File f3Local = null;
if (f2Local == null && finalF2Resolver != null) {
f2Local = finalF2Resolver.getFile();
} else if (finalF2Resolver != null) {
f3Local = finalF2Resolver.getFile();
}
if (!exists && f2Local != null) {
exists = f2Local.exists();
}
if (!exists && f3Local != null) {
exists = f3Local.exists();
}
if (!exists && a != 0 && messageObjectFinal != null && canStreamFinal) {
if (DownloadController.getInstance(currentAccount).canDownloadMedia(messageObjectFinal.messageOwner) != 0) {
if ((parentChatActivity == null || parentChatActivity.getCurrentEncryptedChat() == null) && !messageObjectFinal.shouldEncryptPhotoOrVideo()) {

View File

@ -47,7 +47,6 @@ import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.util.Linkify;
import android.util.Property;
import android.util.SparseIntArray;
import android.util.TypedValue;
@ -1051,7 +1050,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onPhotosLoaded() {
updateProfileData();
updateProfileData(false);
}
@Override
@ -1989,7 +1988,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
userConfig.setCurrentUser(user);
userConfig.saveConfig(true);
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
updateProfileData();
updateProfileData(true);
}
avatarsViewPager.commitMoveToBegin();
} else if (id == edit_avatar) {
@ -3760,7 +3759,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
};
mediaCounterTextView.setAlpha(0.0f);
avatarContainer2.addView(mediaCounterTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 8, 0));
updateProfileData();
updateProfileData(true);
writeButton = new RLottieImageView(context);
@ -5464,7 +5463,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
boolean infoChanged = (mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0;
if (userId != 0) {
if (infoChanged) {
updateProfileData();
updateProfileData(true);
}
if ((mask & MessagesController.UPDATE_MASK_PHONE) != 0) {
if (listView != null) {
@ -5481,7 +5480,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else {
updateOnlineCount(true);
}
updateProfileData();
updateProfileData(true);
}
if (infoChanged) {
if (listView != null) {
@ -5502,7 +5501,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
chatInfo.online_count = (Integer) args[1];
updateOnlineCount(true);
updateProfileData();
updateProfileData(false);
} else if (id == NotificationCenter.contactsDidLoad) {
createActionBarMenu(true);
} else if (id == NotificationCenter.encryptedChatCreated) {
@ -5732,7 +5731,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
setParentActivityTitle(LocaleController.getString("Settings", R.string.Settings));
}
updateProfileData();
updateProfileData(true);
fixLayout();
if (nameTextView[1] != null) {
setParentActivityTitle(nameTextView[1].getText());
@ -5928,7 +5927,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
topView.invalidate();
needLayout(true);
fragmentView.invalidate();
if (fragmentView != null) {
fragmentView.invalidate();
}
if (aboutLinkCell != null) {
aboutLinkCell.invalidate();
@ -6637,7 +6638,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return premuimCrossfadeDrawable;
}
private void updateProfileData() {
private void updateProfileData(boolean reload) {
if (avatarContainer == null || nameTextView == null) {
return;
}
@ -6669,7 +6670,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
final ImageLocation thumbLocation = ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL);
final ImageLocation videoThumbLocation = ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_VIDEO_THUMB);
final ImageLocation videoLocation = avatarsViewPager.getCurrentVideoLocation(thumbLocation, imageLocation);
avatarsViewPager.initIfEmpty(imageLocation, thumbLocation);
avatarsViewPager.initIfEmpty(imageLocation, thumbLocation, reload);
if (avatarBig == null) {
if (videoThumbLocation != null) {
avatarImage.getImageReceiver().setVideoThumbIsSame(true);
@ -6937,7 +6938,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
final ImageLocation imageLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_BIG);
final ImageLocation thumbLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL);
final ImageLocation videoLocation = avatarsViewPager.getCurrentVideoLocation(thumbLocation, imageLocation);
boolean initied = avatarsViewPager.initIfEmpty(imageLocation, thumbLocation);
boolean initied = avatarsViewPager.initIfEmpty(imageLocation, thumbLocation, reload);
if ((imageLocation == null || initied) && isPulledDown) {
final View view = layoutManager.findViewByPosition(0);
if (view != null) {
@ -7635,7 +7636,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
avatar = null;
avatarBig = null;
avatarsViewPager.setCreateThumbFromParent(false);
updateProfileData();
updateProfileData(true);
showAvatarProgress(false, true);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="84px" height="84px" viewBox="0 0 84 84" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>premium_object_fire</title>
<g id="premium_object_fire" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M58.5425,17.82 C56.2675,14.4725 53.6675,11.3525 50.7425,8.5575 C49.605,7.4525 47.6875,8.4925 48.0125,10.0525 C48.63,13.1075 49.28,17.1375 49.28,20.745 C49.28,27.44 44.8925,32.8675 38.1975,32.8675 C33.1925,32.8675 29.0975,29.845 27.31,25.5225 C26.985,24.8725 26.855,24.4825 26.66,23.7675 C26.3025,22.4025 24.515,21.98 23.735,23.1825 C23.15,24.06 22.5975,24.9375 22.0775,25.88 C18.21,32.51 16,40.245 16,48.5 C16,62.865 27.635,74.5 42,74.5 C56.365,74.5 68,62.865 68,48.5 C68,37.1575 64.49,26.6275 58.5425,17.82 Z" id="Shape" fill="#FFFFFF" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 916 B

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="84px" height="84px" viewBox="0 0 84 84" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>premium_object_star2</title>
<g id="premium_object_star2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M39.1547215,64.6172189 L23.5543411,74.4255797 C21.9334131,75.4446989 19.793232,74.9568364 18.7741128,73.3359084 C18.2728444,72.5386317 18.1174995,71.5717336 18.3438014,70.6575632 L20.8716131,60.4461992 C21.7023743,57.0902511 23.9367956,54.2539303 27.005005,52.6606184 L41.5756897,45.094106 C42.3618748,44.6858424 42.6682408,43.7175505 42.2599772,42.9313653 C41.941889,42.3188291 41.2676228,41.9784541 40.5858929,42.0862741 L24.3517135,44.653815 C20.4744425,45.2670306 16.523615,44.144926 13.547507,41.5852299 L7.30032553,36.2121435 C5.84869973,34.9636267 5.68404734,32.7747287 6.93256411,31.3231029 C7.5281546,30.6306216 8.372959,30.2011572 9.28340444,30.1280308 L27.7761498,28.6427046 C29.0849038,28.5375863 30.2219791,27.7021504 30.7134202,26.4846231 L37.7851689,8.96462584 C38.5018303,7.18912364 40.522128,6.33076355 42.2976302,7.04742493 C43.1704603,7.39973292 43.8625231,8.09179575 44.2148311,8.96462584 L51.2865798,26.4846231 C51.7780209,27.7021504 52.9150962,28.5375863 54.2238502,28.6427046 L72.8145342,30.1358972 C74.723071,30.2891897 76.1459777,31.9606327 75.9926852,33.8691696 C75.9203744,34.76946 75.4995753,35.6059885 74.8198416,36.2007268 L60.5096574,48.7215344 C59.5446427,49.5658816 59.1244794,50.8739291 59.4172819,52.1223049 L63.7930969,70.7787725 C64.2303145,72.6428681 63.0736015,74.5084511 61.2095059,74.9456687 C60.3070137,75.1573454 59.3573387,74.9987762 58.5725748,74.505375 L42.8452785,64.6172189 C41.7173024,63.9080313 40.2826976,63.9080313 39.1547215,64.6172189 Z" id="Star-Copy-12" fill="#FFFFFF"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="1024px" height="1024px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 60 (88103) - https://sketch.com -->
<title>Artboard</title>
<desc>Created with Sketch.</desc>
<g id="Artboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M242.441216,1023.96673 C484.760949,868.195472 619.565351,780.153383 646.854423,759.840461 C738.267847,691.795866 863.983039,585.091695 1024,439.727947 L1024,363.976818 C810.351061,332.876819 639.684394,317.32682 512,317.32682 C384.315606,317.32682 213.648939,332.876819 0,363.976818 L0,1023.96673 L242.441216,1023.96673 Z" id="Path" fill="#FFFFFF"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 794 B