update to 8.8.4

This commit is contained in:
xaxtix 2022-06-28 14:00:33 +04:00
parent 4a95c2fc1f
commit 0a3abc5158
34 changed files with 582 additions and 235 deletions

View File

@ -235,7 +235,7 @@ android {
}
}
defaultConfig.versionCode = 2705
defaultConfig.versionCode = 2711
applicationVariants.all { variant ->
variant.outputs.all { output ->
@ -254,7 +254,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.8.3"
versionName "8.8.4"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

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

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

View File

@ -20,11 +20,11 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2705;
public static String BUILD_VERSION_STRING = "8.8.3";
public static int BUILD_VERSION = 2711;
public static String BUILD_VERSION_STRING = "8.8.4";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";;
public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";

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 {
@ -770,7 +772,11 @@ public class FileLoadOperation {
TLRPC.TL_theme theme = (TLRPC.TL_theme) parentObject;
cacheFileFinal = new File(ApplicationLoader.getFilesDirFixed(), "remote" + theme.id + ".attheme");
} 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())) {
@ -1253,18 +1259,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);
@ -1290,14 +1298,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

@ -629,6 +629,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);
@ -675,7 +678,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);
@ -687,14 +689,20 @@ 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)) {
type = MEDIA_DIR_VIDEO;
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);
@ -831,33 +839,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);
@ -868,6 +877,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));
}
@ -893,7 +907,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) {
@ -1162,17 +1176,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) {
@ -1614,6 +1633,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

@ -997,7 +997,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

@ -101,11 +101,17 @@ public class MediaDataController extends BaseController {
public static String SHORTCUT_CATEGORY = "org.telegram.messenger.SHORTCUT_SHARE";
private static volatile MediaDataController[] Instance = new MediaDataController[UserConfig.MAX_ACCOUNT_COUNT];
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[num];
if (localInstance == null) {
synchronized (MediaDataController.class) {
synchronized (lockObjects) {
localInstance = Instance[num];
if (localInstance == null) {
Instance[num] = localInstance = new MediaDataController(num);

View File

@ -145,7 +145,7 @@ public class MessagesController extends BaseController implements NotificationCe
private int pollsToCheckSize;
private long lastViewsCheckTime;
public SparseIntArray premiumFeaturesTypesToPosition = new SparseIntArray();
public ArrayList<DialogFilter> dialogFilters = new ArrayList<>();
public SparseArray<DialogFilter> dialogFiltersById = new SparseArray<>();
private boolean loadingSuggestedFilters;
@ -873,7 +873,7 @@ public class MessagesController extends BaseController implements NotificationCe
};
private static volatile MessagesController[] Instance = new MessagesController[UserConfig.MAX_ACCOUNT_COUNT];
private static volatile Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
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();
@ -1624,6 +1624,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);
@ -2410,6 +2411,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();
@ -9133,7 +9139,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

@ -83,6 +83,13 @@ public class MessagesStorage extends BaseController {
private CountDownLatch openSync = new CountDownLatch(1);
private static volatile MessagesStorage[] Instance = new MessagesStorage[UserConfig.MAX_ACCOUNT_COUNT];
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;
@ -91,7 +98,7 @@ public class MessagesStorage extends BaseController {
public static MessagesStorage getInstance(int num) {
MessagesStorage localInstance = Instance[num];
if (localInstance == null) {
synchronized (MessagesStorage.class) {
synchronized (lockObjects[num]) {
localInstance = Instance[num];
if (localInstance == null) {
Instance[num] = localInstance = new MessagesStorage(num);
@ -10411,6 +10418,7 @@ public class MessagesStorage extends BaseController {
state.step();
state.dispose();
getMessagesStorage().getDatabase().commitTransaction();
data.reuse();
}
deleteFromDownloadQueue(idsToDelete, true);

View File

@ -142,11 +142,17 @@ public class NotificationsController extends BaseController {
}
private static volatile NotificationsController[] Instance = new NotificationsController[UserConfig.MAX_ACCOUNT_COUNT];
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[num];
if (localInstance == null) {
synchronized (NotificationsController.class) {
synchronized (lockObjects[num]) {
localInstance = Instance[num];
if (localInstance == null) {
Instance[num] = localInstance = new NotificationsController(num);

View File

@ -348,7 +348,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 {
@ -1229,7 +1229,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

@ -31865,6 +31865,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));
@ -60296,6 +60299,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

@ -283,8 +283,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;
@ -398,6 +402,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

@ -199,6 +199,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;
}
}
@ -3356,6 +3407,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) {
@ -3423,6 +3475,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;
@ -3456,6 +3509,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();
@ -10646,46 +10702,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;
@ -2064,31 +2063,29 @@ 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);
lastUnreadState = message != null && message.isUnread();
if (dialog instanceof TLRPC.TL_dialogFolder) {
unreadCount = MessagesStorage.getInstance(currentAccount).getArchiveUnreadCount();
mentionCount = 0;
reactionMentionCount = 0;
} else {
unreadCount = dialog.unread_count;
mentionCount = dialog.unread_mentions_count;
reactionMentionCount = dialog.unread_reactions_count;
}
markUnread = dialog.unread_mark;
currentEditDate = message != null ? message.messageOwner.edit_date : 0;
lastMessageDate = dialog.last_message_date;
if (dialogsType == 7 || dialogsType == 8) {
MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0];
drawPin = filter != null && filter.pinnedDialogs.indexOfKey(dialog.id) >= 0;
} else {
drawPin = currentDialogFolderId == 0 && dialog.pinned;
}
if (message != null) {
lastSendState = message.messageOwner.send_state;
}
clearingDialog = MessagesController.getInstance(currentAccount).isClearingDialog(dialog.id);
message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id);
lastUnreadState = message != null && message.isUnread();
if (dialog instanceof TLRPC.TL_dialogFolder) {
unreadCount = MessagesStorage.getInstance(currentAccount).getArchiveUnreadCount();
mentionCount = 0;
reactionMentionCount = 0;
} else {
unreadCount = dialog.unread_count;
mentionCount = dialog.unread_mentions_count;
reactionMentionCount = dialog.unread_reactions_count;
}
markUnread = dialog.unread_mark;
currentEditDate = message != null ? message.messageOwner.edit_date : 0;
lastMessageDate = dialog.last_message_date;
if (dialogsType == 7 || dialogsType == 8) {
MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0];
drawPin = filter != null && filter.pinnedDialogs.indexOfKey(dialog.id) >= 0;
} else {
drawPin = currentDialogFolderId == 0 && dialog.pinned;
}
if (message != null) {
lastSendState = message.messageOwner.send_state;
}
} else {
unreadCount = 0;

View File

@ -61,7 +61,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;
@ -543,6 +542,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;
@ -6543,7 +6543,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() {
@ -10023,9 +10023,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

@ -191,8 +191,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;
@ -543,7 +547,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);
@ -610,7 +613,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
@ -969,21 +976,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;
});
@ -1129,10 +1136,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();
@ -1140,13 +1157,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() {
@ -1313,6 +1336,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
if (handler != null) {
sendMessage(handler.obtainMessage(DO_REINIT_MESSAGE), 0);
}
updateScale();
}
public void finish() {
@ -1430,6 +1454,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;
@ -1444,6 +1470,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: {
@ -1618,8 +1659,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;
@ -1956,25 +1997,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]);
@ -2022,14 +2076,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);
}
}
}
}
@ -2340,8 +2399,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");
@ -2534,18 +2593,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";
}
@ -2553,27 +2615,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";
}
@ -2697,6 +2761,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

@ -452,17 +452,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

@ -120,7 +120,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<>();
@ -131,6 +132,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() {
@ -392,6 +395,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();
}
@ -422,6 +430,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) {
@ -826,7 +839,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

@ -558,6 +558,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) {
@ -582,6 +583,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() {
@ -815,6 +817,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);
}
});
}
}
@ -2741,6 +2754,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;
@ -219,6 +220,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) {
@ -227,10 +229,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();
@ -250,6 +252,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;
@ -279,7 +291,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()) {
@ -627,6 +639,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

@ -7443,7 +7443,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);
}
@ -8428,7 +8428,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);
@ -8456,7 +8456,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;
@ -11984,13 +11985,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;
@ -1020,7 +1019,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override
public void onPhotosLoaded() {
updateProfileData();
updateProfileData(false);
}
@Override
@ -1920,7 +1919,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) {
@ -3393,7 +3392,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);
@ -5062,7 +5061,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) {
@ -5079,7 +5078,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else {
updateOnlineCount(true);
}
updateProfileData();
updateProfileData(true);
}
if (infoChanged) {
if (listView != null) {
@ -5100,7 +5099,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) {
@ -5328,7 +5327,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());
@ -5524,7 +5523,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
topView.invalidate();
needLayout(true);
fragmentView.invalidate();
if (fragmentView != null) {
fragmentView.invalidate();
}
if (aboutLinkCell != null) {
aboutLinkCell.invalidate();
@ -6234,7 +6235,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
return premuimCrossfadeDrawable;
}
private void updateProfileData() {
private void updateProfileData(boolean reload) {
if (avatarContainer == null || nameTextView == null) {
return;
}
@ -6267,7 +6268,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);
@ -6526,7 +6527,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) {
@ -7160,7 +7161,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);