update to 10.1.0 (3919)

This commit is contained in:
xaxtix 2023-09-22 18:40:36 +04:00
parent 6b4602c20a
commit 750eedfc96
137 changed files with 9539 additions and 2271 deletions

View file

@ -17,12 +17,14 @@ configurations.all {
}
dependencies {
implementation 'androidx.fragment:fragment:1.2.0'
implementation 'androidx.core:core:1.10.1'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation 'androidx.exifinterface:exifinterface:1.3.6'
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.sharetarget:sharetarget:1.2.0"
implementation 'androidx.interpolator:interpolator:1.0.0'
compileOnly 'org.checkerframework:checker-qual:2.5.2'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
@ -138,6 +140,19 @@ android {
buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
}
HA_hardcore {
debuggable false
jniDebuggable false
minifyEnabled true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_HARDCORE") + "\""
buildConfigField "boolean", "DEBUG_VERSION", "true"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
}
standalone {
debuggable false
jniDebuggable false

View file

@ -236,7 +236,11 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
.setInterpolator(getRemoveInterpolator())
.alpha(0)
.scaleX(1f - animateByScale(view))
.scaleY(1f - animateByScale(view))
.scaleY(1f - animateByScale(view));
if (Build.VERSION.SDK_INT >= 19) {
animation.setUpdateListener(animation1 -> onRemoveAnimationUpdate(holder));
}
animation
.setListener(
new AnimatorListenerAdapter() {
@Override
@ -284,7 +288,11 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
.scaleY(1f)
.setDuration(getAddDuration())
.setStartDelay(getAddDelay())
.setInterpolator(getAddInterpolator())
.setInterpolator(getAddInterpolator());
if (Build.VERSION.SDK_INT >= 19) {
animation.setUpdateListener(animation1 -> onAddAnimationUpdate(holder));
}
animation
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
@ -342,6 +350,14 @@ public class DefaultItemAnimator extends SimpleItemAnimator {
}
protected void onAddAnimationUpdate(RecyclerView.ViewHolder holder) {
}
protected void onRemoveAnimationUpdate(RecyclerView.ViewHolder holder) {
}
protected void beforeAnimateMoveImpl(final RecyclerView.ViewHolder holder) {
}

View file

@ -785,6 +785,16 @@ public class AndroidUtilities {
return new float[] {xOffset, yOffset};
}
public static void doOnLayout(View view, Runnable runnable) {
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
view.removeOnLayoutChangeListener(this);
runnable.run();
}
});
}
private static class LinkSpec {
String url;
int start;

View file

@ -44,7 +44,7 @@ import java.io.File;
public class ApplicationLoader extends Application {
private static ApplicationLoader applicationLoaderInstance;
public static ApplicationLoader applicationLoaderInstance;
@SuppressLint("StaticFieldLeak")
public static volatile Context applicationContext;
@ -555,4 +555,11 @@ public class ApplicationLoader extends Application {
}
public boolean checkApkInstallPermissions(final Context context) {
return false;
}
public boolean openApkInstall(Activity activity, TLRPC.Document document) {
return false;
}
}

View file

@ -24,8 +24,8 @@ 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 = 3872;
public static String BUILD_VERSION_STRING = "10.0.9";
public static int BUILD_VERSION = 3919;
public static String BUILD_VERSION_STRING = "10.1.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
@ -33,6 +33,7 @@ public class BuildVars {
public static String SAFETYNET_KEY = "AIzaSyDqt8P-7F7CPCseMkOiVRgb1LY8RN1bvH8";
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";
public static String HUAWEI_STORE_URL = "https://appgallery.huawei.com/app/C101184875";
public static String GOOGLE_AUTH_CLIENT_ID = "760348033671-81kmi3pi84p11ub8hp9a1funsv0rn2p9.apps.googleusercontent.com";
public static String HUAWEI_APP_ID = "101184875";

View file

@ -0,0 +1,108 @@
package org.telegram.messenger;
import com.google.android.exoplayer2.util.Consumer;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.BulletinFactory;
public class ChannelBoostsController {
private final int currentAccount;
private final MessagesController messagesController;
private final ConnectionsManager connectionsManager;
public final static int BOOSTS_FOR_LEVEL_1 = 1;
public final static int BOOSTS_FOR_LEVEL_2 = 1;
public ChannelBoostsController(int currentAccount) {
this.currentAccount = currentAccount;
messagesController = MessagesController.getInstance(currentAccount);
connectionsManager = ConnectionsManager.getInstance(currentAccount);
}
public void getBoostsStats(long dialogId, Consumer<TLRPC.TL_stories_boostsStatus> consumer) {
TLRPC.TL_stories_getBoostsStatus req = new TLRPC.TL_stories_getBoostsStatus();
req.peer = messagesController.getInputPeer(dialogId);
connectionsManager.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response != null) {
consumer.accept((TLRPC.TL_stories_boostsStatus) response);
} else {
BulletinFactory.showForError(error);
consumer.accept(null);
}
}));
}
public void userCanBoostChannel(long dialogId, Consumer<CanApplyBoost> consumer) {
TLRPC.TL_stories_canApplyBoost req = new TLRPC.TL_stories_canApplyBoost();
req.peer = messagesController.getInputPeer(dialogId);
connectionsManager.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
CanApplyBoost canApplyBoost = new CanApplyBoost();
if (response != null) {
canApplyBoost.canApply = true;
if (response instanceof TLRPC.TL_stories_canApplyBoostReplace) {
TLRPC.TL_stories_canApplyBoostReplace canApplyBoostReplace = (TLRPC.TL_stories_canApplyBoostReplace) response;
messagesController.putChats(canApplyBoostReplace.chats, false);
canApplyBoost.replaceDialogId = DialogObject.getPeerDialogId(canApplyBoostReplace.current_boost);
if (canApplyBoost.replaceDialogId == 0 && canApplyBoostReplace.chats.size() > 0) {
canApplyBoost.replaceDialogId = -canApplyBoostReplace.chats.get(0).id;
}
}
} else {
if (error != null) {
if (error.text.equals("SAME_BOOST_ALREADY_ACTIVE") || error.text.equals("BOOST_NOT_MODIFIED")) {
canApplyBoost.alreadyActive = true;
} else if (error.text.equals("PREMIUM_GIFTED_NOT_ALLOWED")) {
canApplyBoost.giftedPremium = true;
} else if (error.text.startsWith("FLOOD_WAIT")) {
canApplyBoost.floodWait = Utilities.parseInt(error.text);
canApplyBoost.lastCheckTime = System.currentTimeMillis();
}
}
}
consumer.accept(canApplyBoost);
}), ConnectionsManager.RequestFlagDoNotWaitFloodWait);
}
public void applyBoost(long dialogId) {
TLRPC.TL_stories_applyBoost req = new TLRPC.TL_stories_applyBoost();
req.peer = messagesController.getInputPeer(dialogId);
connectionsManager.sendRequest(req, (response, error) -> {
});
}
public int getTotalBooststToLevel(int level) {
int count = 0;
if (level >= 1) {
count += BOOSTS_FOR_LEVEL_1;
}
if (level >= 2) {
count += BOOSTS_FOR_LEVEL_2;
}
return count;
}
public static class CanApplyBoost {
public boolean canApply;
public long replaceDialogId;
public boolean alreadyActive;
public int floodWait;
public boolean giftedPremium;
private long lastCheckTime;
public void checkTime() {
floodWait -= (System.currentTimeMillis() - lastCheckTime) / 1000;
lastCheckTime = System.currentTimeMillis();
if (floodWait < 0) {
floodWait = 0;
canApply = true;
}
}
}
}

View file

@ -87,7 +87,7 @@ public class ChatMessagesMetadataController {
continue;
}
long storyDialogId = storyItem.dialogId;
req.user_id = chatActivity.getMessagesController().getInputUser(storyDialogId);
req.peer = chatActivity.getMessagesController().getInputPeer(storyDialogId);
req.id.add(storyItem.id);
int storyId = storyItem.id;
int reqId = chatActivity.getConnectionsManager().sendRequest(req, (response, error) -> {

View file

@ -2864,6 +2864,9 @@ public class ContactsController extends BaseController {
}
public static String formatName(TLRPC.User user) {
if (user == null) {
return "";
}
return formatName(user.first_name, user.last_name, 0);
}

View file

@ -1370,6 +1370,12 @@ public class DatabaseMigrationHelper {
version = 133;
}
if (version == 133) {
database.executeFast("ALTER TABLE unread_push_messages ADD COLUMN topicId INTEGER default 0").stepThis().dispose();
database.executeFast("PRAGMA user_version = 134").stepThis().dispose();
version = 134;
}
return version;
}

View file

@ -1169,6 +1169,10 @@ public class FileLoader extends BaseController {
}
public File getPathToMessage(TLRPC.Message message, boolean useFileDatabaseQueue) {
return getPathToMessage(message, useFileDatabaseQueue, false);
}
public File getPathToMessage(TLRPC.Message message, boolean useFileDatabaseQueue, boolean saveAsFile) {
if (message == null) {
return new File("");
}
@ -1184,7 +1188,7 @@ public class FileLoader extends BaseController {
}
} else {
if (MessageObject.getMedia(message) instanceof TLRPC.TL_messageMediaDocument) {
return getPathToAttach(MessageObject.getMedia(message).document, null, MessageObject.getMedia(message).ttl_seconds != 0, useFileDatabaseQueue);
return getPathToAttach(MessageObject.getMedia(message).document, null,null, MessageObject.getMedia(message).ttl_seconds != 0, useFileDatabaseQueue, saveAsFile);
} else if (MessageObject.getMedia(message) instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = MessageObject.getMedia(message).photo.sizes;
if (sizes.size() > 0) {
@ -1221,21 +1225,22 @@ public class FileLoader extends BaseController {
}
public File getPathToAttach(TLObject attach, String ext, boolean forceCache) {
return getPathToAttach(attach, null, ext, forceCache, true);
return getPathToAttach(attach, null, ext, forceCache, true, false);
}
public File getPathToAttach(TLObject attach, String ext, boolean forceCache, boolean useFileDatabaseQueue) {
return getPathToAttach(attach, null, ext, forceCache, useFileDatabaseQueue);
return getPathToAttach(attach, null, ext, forceCache, useFileDatabaseQueue, false);
}
/**
* Return real file name. Used before file.exist()
*/
public File getPathToAttach(TLObject attach, String size, String ext, boolean forceCache, boolean useFileDatabaseQueue) {
public File getPathToAttach(TLObject attach, String size, String ext, boolean forceCache, boolean useFileDatabaseQueue, boolean saveAsFile) {
File dir = null;
long documentId = 0;
int dcId = 0;
int type = 0;
String fileName = null;
if (forceCache) {
dir = getDirectory(MEDIA_DIR_CACHE);
} else {
@ -1252,7 +1257,13 @@ public class FileLoader extends BaseController {
} else if (MessageObject.isVideoDocument(document)) {
type = MEDIA_DIR_VIDEO;
} else {
type = MEDIA_DIR_DOCUMENT;
String documentFileName = getDocumentFileName(document);
if (saveAsFile && !TextUtils.isEmpty(documentFileName)) {
fileName = documentFileName;
type = MEDIA_DIR_FILES;
} else {
type = MEDIA_DIR_DOCUMENT;
}
}
}
documentId = document.id;
@ -1323,7 +1334,10 @@ public class FileLoader extends BaseController {
return new File(path);
}
}
return new File(dir, getAttachFileName(attach, ext));
if (fileName == null) {
fileName = getAttachFileName(attach, ext);
}
return new File(dir, fileName);
}
public FilePathDatabase getFileDatabase() {

View file

@ -352,7 +352,7 @@ public class FileRefController extends BaseController {
if (parentObject instanceof TLRPC.StoryItem) {
TLRPC.StoryItem storyItem = (TLRPC.StoryItem) parentObject;
TLRPC.TL_stories_getStoriesByID req = new TLRPC.TL_stories_getStoriesByID();
req.user_id = getMessagesController().getInputUser(storyItem.dialogId);
req.peer = getMessagesController().getInputPeer(storyItem.dialogId);
req.id.add(storyItem.id);
getConnectionsManager().sendRequest(req, (response, error) -> {
onRequestComplete(locationKey, parentKey, response, error, true, false);
@ -911,35 +911,7 @@ public class FileRefController extends BaseController {
}
} else if (response instanceof TLRPC.TL_help_appUpdate) {
TLRPC.TL_help_appUpdate appUpdate = (TLRPC.TL_help_appUpdate) response;
try {
SharedConfig.pendingAppUpdate = appUpdate;
SharedConfig.saveConfig();
} catch (Exception e) {
FileLog.e(e);
}
try {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.appUpdateAvailable);
} catch (Exception e) {
FileLog.e(e);
}
try {
if (appUpdate.document != null) {
result = appUpdate.document.file_reference;
TLRPC.TL_inputDocumentFileLocation location = new TLRPC.TL_inputDocumentFileLocation();
location.id = appUpdate.document.id;
location.access_hash = appUpdate.document.access_hash;
location.file_reference = appUpdate.document.file_reference;
location.thumb_size = "";
locationReplacement = new TLRPC.InputFileLocation[1];
locationReplacement[0] = location;
}
} catch (Exception e) {
result = null;
FileLog.e(e);
}
if (result == null) {
result = getFileReference(appUpdate.document, requester.location, needReplacement, locationReplacement);
}
result = getFileReference(appUpdate.document, requester.location, needReplacement, locationReplacement);
if (result == null) {
result = getFileReference(appUpdate.sticker, requester.location, needReplacement, locationReplacement);
}
@ -1091,7 +1063,7 @@ public class FileRefController extends BaseController {
TLRPC.StoryItem storyItem = (TLRPC.StoryItem) operation.parentObject;
if (newStoryItem == null) {
TLRPC.TL_updateStory story = new TLRPC.TL_updateStory();
story.user_id = storyItem.dialogId;
story.peer = getMessagesController().getPeer(storyItem.dialogId);
story.story = new TLRPC.TL_storyItemDeleted();
story.story.id = storyItem.id;
ArrayList<TLRPC.Update> updates = new ArrayList<>();

View file

@ -54,6 +54,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
List<ImageReceiver> preloadReceivers;
private boolean allowCrossfadeWithImage = true;
private boolean allowDrawWhileCacheGenerating;
private ArrayList<Decorator> decorators;
public boolean updateThumbShaderMatrix() {
if (currentThumbDrawable != null && thumbShader != null) {
@ -1080,6 +1081,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (lottieDrawable != null) {
lottieDrawable.removeParentView(this);
}
if (decorators != null) {
for (int i = 0; i < decorators.size(); i++) {
decorators.get(i).onDetachedFromWidnow();
}
}
}
public boolean setBackupImage() {
@ -1163,6 +1169,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (staticThumbDrawable instanceof AttachableDrawable) {
((AttachableDrawable) staticThumbDrawable).onAttachedToWindow(this);
}
if (decorators != null) {
for (int i = 0; i < decorators.size(); i++) {
decorators.get(i).onAttachedToWindow(this);
}
}
return false;
}
@ -2028,6 +2039,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (gradientBitmap != null && currentImageKey != null) {
canvas.restore();
}
if (result && isVisible && decorators != null) {
for (int i = 0; i < decorators.size(); i++) {
decorators.get(i).onDraw(canvas, this);
}
}
return result;
}
@ -3142,6 +3158,26 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return holder;
}
public void clearDecorators() {
if (decorators != null) {
if (attachedToWindow) {
for (int i = 0; i < decorators.size(); i++) {
decorators.get(i).onDetachedFromWidnow();
}
}
decorators.clear();
}
}
public void addDecorator(Decorator decorator) {
if (decorators == null) {
decorators = new ArrayList<>();
}
decorators.add(decorator);
if (attachedToWindow) {
decorator.onAttachedToWindow(this);
}
}
public static class BackgroundThreadDrawHolder {
public boolean animationNotReady;
public float overrideAlpha;
@ -3224,4 +3260,14 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
super(bitmap);
}
}
public static abstract class Decorator {
protected abstract void onDraw(Canvas canvas, ImageReceiver imageReceiver);
public void onAttachedToWindow(ImageReceiver imageReceiver) {
}
public void onDetachedFromWidnow() {
}
}
}

View file

@ -2040,14 +2040,14 @@ public class LocaleController {
public static String stringForMessageListDate(long date) {
try {
date *= 1000;
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
rightNow.setTimeInMillis(date);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
if (Math.abs(System.currentTimeMillis() - date) >= 31536000000L) {
return getInstance().formatterYear.format(new Date(date));
} else {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
rightNow.setTimeInMillis(date);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dayDiff = dateDay - day;
if (dayDiff == 0 || dayDiff == -1 && System.currentTimeMillis() - date < 60 * 60 * 8 * 1000) {
return getInstance().formatterDay.format(new Date(date));

View file

@ -4068,7 +4068,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
}
if (path == null || path.length() == 0) {
path = FileLoader.getInstance(currentAccount.getCurrentAccount()).getPathToMessage(message.messageOwner).toString();
path = FileLoader.getInstance(currentAccount.getCurrentAccount()).getPathToMessage(message.messageOwner, true, !isMusic).toString();
}
File sourceFile = new File(path);
if (!sourceFile.exists()) {
@ -4122,7 +4122,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
}
if (path == null || path.length() == 0) {
path = FileLoader.getInstance(currentAccount.getCurrentAccount()).getPathToMessage(message.messageOwner).toString();
path = FileLoader.getInstance(currentAccount.getCurrentAccount()).getPathToMessage(message.messageOwner, true, !isMusic).toString();
}
File sourceFile = new File(path);
if (!sourceFile.exists()) {

View file

@ -94,6 +94,7 @@ import java.util.regex.Pattern;
public class MediaDataController extends BaseController {
public final static String ATTACH_MENU_BOT_ANIMATED_ICON_KEY = "android_animated",
ATTACH_MENU_BOT_STATIC_ICON_KEY = "default_static",
ATTACH_MENU_BOT_SIDE_MENU_ICON_KEY = "android_side_menu_static",
ATTACH_MENU_BOT_PLACEHOLDER_STATIC_KEY = "placeholder_static",
ATTACH_MENU_BOT_COLOR_LIGHT_ICON = "light_icon",
ATTACH_MENU_BOT_COLOR_LIGHT_TEXT = "light_text",
@ -1568,6 +1569,16 @@ public class MediaDataController extends BaseController {
return null;
}
@Nullable
public static TLRPC.TL_attachMenuBotIcon getSideAttachMenuBotIcon(@NonNull TLRPC.TL_attachMenuBot bot) {
for (TLRPC.TL_attachMenuBotIcon icon : bot.icons) {
if (icon.name.equals(ATTACH_MENU_BOT_SIDE_MENU_ICON_KEY)) {
return icon;
}
}
return null;
}
@Nullable
public static TLRPC.TL_attachMenuBotIcon getPlaceholderStaticAttachMenuBotIcon(@NonNull TLRPC.TL_attachMenuBot bot) {
for (TLRPC.TL_attachMenuBotIcon icon : bot.icons) {
@ -5469,7 +5480,7 @@ public class MediaDataController extends BaseController {
}
if (messageObject.type == MessageObject.TYPE_STORY || messageObject.type == MessageObject.TYPE_STORY_MENTION) {
if (messageObject.messageOwner.media.storyItem == null) {
long storyDialogId = messageObject.messageOwner.media.user_id;
long storyDialogId = DialogObject.getPeerDialogId(messageObject.messageOwner.media.peer);
if (messagesWithUnknownStories == null) {
messagesWithUnknownStories = new LongSparseArray<>();
}
@ -5480,7 +5491,7 @@ public class MediaDataController extends BaseController {
}
array.add(messageObject);
} else {
long storyDialogId = messageObject.messageOwner.media.user_id;
long storyDialogId = DialogObject.getPeerDialogId(messageObject.messageOwner.media.peer);
messageObject.messageOwner.media.storyItem = StoriesStorage.checkExpiredStateLocal(currentAccount, storyDialogId, messageObject.messageOwner.media.storyItem);
}
} else if (messageObject.getId() > 0 && messageObject.isReplyToStory()) {
@ -5554,7 +5565,7 @@ public class MediaDataController extends BaseController {
if (attr instanceof TLRPC.TL_webPageAttributeStory) {
TLRPC.TL_webPageAttributeStory attrStory = (TLRPC.TL_webPageAttributeStory) attr;
if (attrStory.storyItem == null) {
long storyDialogId = attrStory.user_id;
long storyDialogId = DialogObject.getPeerDialogId(attrStory.peer);
if (messagesWithUnknownStories == null) {
messagesWithUnknownStories = new LongSparseArray<>();
}
@ -5565,7 +5576,7 @@ public class MediaDataController extends BaseController {
}
array.add(messageObject);
} else {
long storyDialogId = attrStory.user_id;
long storyDialogId = DialogObject.getPeerDialogId(attrStory.peer);
attrStory.storyItem = StoriesStorage.checkExpiredStateLocal(currentAccount, storyDialogId, attrStory.storyItem);
}
}
@ -7235,6 +7246,7 @@ public class MediaDataController extends BaseController {
public void applyAttachMenuBot(TLRPC.TL_attachMenuBotsBot attachMenuBot) {
attachMenuBots.bots.add(attachMenuBot.bot);
loadAttachMenuBots(false, true);
}
public boolean botInAttachMenu(long id) {

View file

@ -233,7 +233,6 @@ public class MessageObject {
public int lastLineWidth;
public int textWidth;
public int textHeight;
public int captionHeight;
public boolean hasRtl;
public float textXOffset;
@ -1647,6 +1646,18 @@ public class MessageObject {
rights.append('\n').append(n.edit_messages ? '+' : '-').append(' ');
rights.append(LocaleController.getString("EventLogPromotedEditMessages", R.string.EventLogPromotedEditMessages));
}
if (o.post_stories != n.post_stories) {
rights.append('\n').append(n.post_stories ? '+' : '-').append(' ');
rights.append(LocaleController.getString("EventLogPromotedPostStories", R.string.EventLogPromotedPostStories));
}
if (o.edit_stories != n.edit_stories) {
rights.append('\n').append(n.edit_messages ? '+' : '-').append(' ');
rights.append(LocaleController.getString("EventLogPromotedEditStories", R.string.EventLogPromotedEditStories));
}
if (o.delete_stories != n.delete_stories) {
rights.append('\n').append(n.delete_stories ? '+' : '-').append(' ');
rights.append(LocaleController.getString("EventLogPromotedDeleteStories", R.string.EventLogPromotedDeleteStories));
}
}
if (o.delete_messages != n.delete_messages) {
rights.append('\n').append(n.delete_messages ? '+' : '-').append(' ');
@ -4295,8 +4306,8 @@ public class MessageObject {
public static boolean canPreviewDocument(TLRPC.Document document) {
if (document != null && document.mime_type != null) {
String mime = document.mime_type.toLowerCase();
if (isDocumentHasThumb(document) && (mime.equals("image/png") || mime.equals("image/jpg") || mime.equals("image/jpeg")) || (Build.VERSION.SDK_INT >= 26 && (mime.equals("image/heic")))) {
String mime = document.mime_type;
if (isDocumentHasThumb(document) && (mime.equalsIgnoreCase("image/png") || mime.equalsIgnoreCase("image/jpg") || mime.equalsIgnoreCase("image/jpeg")) || (Build.VERSION.SDK_INT >= 26 && (mime.equalsIgnoreCase("image/heic")))) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeImageSize) {
@ -4872,28 +4883,6 @@ public class MessageObject {
caption = Emoji.replaceEmoji(text, Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
caption = replaceAnimatedEmoji(caption, entities, Theme.chat_msgTextPaint.getFontMetricsInt(), false);
int maxWidth = getMaxMessageTextWidth();
final float lineSpacing = 1f;
final float lineAdd = 0;
Layout.Alignment align = Layout.Alignment.ALIGN_NORMAL;
StaticLayout captionLayout = null;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
StaticLayout.Builder builder =
StaticLayout.Builder.obtain(caption, 0, caption.length(), Theme.chat_msgTextPaint, maxWidth)
.setLineSpacing(lineAdd, lineSpacing)
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
.setAlignment(align);
captionLayout = builder.build();
} else {
captionLayout = new StaticLayout(caption, Theme.chat_msgTextPaint, maxWidth, align, lineSpacing, lineAdd, false);
}
} catch (Exception e) {
FileLog.e(e);
}
captionHeight = captionLayout == null ? 0 : captionLayout.getHeight();
boolean hasEntities;
if (messageOwner.send_state != MESSAGE_SEND_STATE_SENT) {
hasEntities = false;
@ -6900,10 +6889,6 @@ public class MessageObject {
photoHeight = h;
}
if (caption != null && !TextUtils.isEmpty(caption)) {
photoHeight += captionHeight;
}
return photoHeight + AndroidUtilities.dp(14);
}
}
@ -8080,7 +8065,7 @@ public class MessageObject {
webpage.type = "telegram_story";
TLRPC.TL_webPageAttributeStory attr = new TLRPC.TL_webPageAttributeStory();
attr.id = messageOwner.media.id;
attr.user_id = messageOwner.media.user_id;
attr.peer = MessagesController.getInstance(currentAccount).getPeer(messageOwner.media.user_id);
if (messageOwner.media.storyItem != null) {
attr.flags |= 1;
attr.storyItem = messageOwner.media.storyItem;

View file

@ -146,6 +146,7 @@ public class MessagesController extends BaseController implements NotificationCe
private boolean hasArchivedChats;
private boolean hasStories;
public long storiesChangelogUserId = 777000;
private ChannelBoostsController channelBoostsControler;
public static TLRPC.Peer getPeerFromInputPeer(TLRPC.InputPeer peer) {
if (peer.chat_id != 0) {
@ -163,6 +164,19 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
public ChannelBoostsController getBoostsController() {
if (channelBoostsControler != null) {
return channelBoostsControler;
}
synchronized (lockObjects[currentAccount]) {
if (channelBoostsControler != null) {
return channelBoostsControler;
}
channelBoostsControler = new ChannelBoostsController(currentAccount);
}
return channelBoostsControler;
}
class ChatlistUpdatesStat {
public ChatlistUpdatesStat() {
this.loading = true;
@ -4708,6 +4722,9 @@ public class MessagesController extends BaseController implements NotificationCe
} else {
oldChat.flags |= 16384;
}
if (!chat.stories_hidden_min) {
chat.stories_hidden = oldChat.stories_hidden;
}
if (oldFlags != newFlags || oldFlags2 != newFlags2) {
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.channelRightsUpdated, chat));
}
@ -14788,7 +14805,8 @@ public class MessagesController extends BaseController implements NotificationCe
updatesOnMainThread.add(baseUpdate);
} else if (baseUpdate instanceof TLRPC.TL_updateReadStories) {
TLRPC.TL_updateReadStories updateReadStories = (TLRPC.TL_updateReadStories) baseUpdate;
getStoriesController().markStoriesAsReadFromServer(updateReadStories.user_id, updateReadStories.max_id);
long dialogId = DialogObject.getPeerDialogId(updateReadStories.peer);
getStoriesController().markStoriesAsReadFromServer(dialogId, updateReadStories.max_id);
} else if (baseUpdate instanceof TLRPC.TL_updatePeerSettings) {
TLRPC.TL_updatePeerSettings update = (TLRPC.TL_updatePeerSettings) baseUpdate;
if (contactsIds == null) {
@ -16308,7 +16326,9 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
} else if (baseUpdate instanceof TLRPC.TL_updateSentStoryReaction) {
getStoriesController().updateStoryReaction(((TLRPC.TL_updateSentStoryReaction) baseUpdate).user_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).story_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).reaction);
TLRPC.TL_updateSentStoryReaction updateReaction = (TLRPC.TL_updateSentStoryReaction) baseUpdate;
long dialogId = DialogObject.getPeerDialogId(updateReaction.peer);
getStoriesController().updateStoryReaction(dialogId, updateReaction.story_id, updateReaction.reaction);
}
}
if (editor != null) {

View file

@ -96,7 +96,7 @@ public class MessagesStorage extends BaseController {
}
}
public final static int LAST_DB_VERSION = 133;
public final static int LAST_DB_VERSION = 134;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;
private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
@ -619,7 +619,7 @@ public class MessagesStorage extends BaseController {
database.executeFast("CREATE TABLE wallpapers2(uid INTEGER PRIMARY KEY, data BLOB, num INTEGER)").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS wallpapers_num ON wallpapers2(num);").stepThis().dispose();
database.executeFast("CREATE TABLE unread_push_messages(uid INTEGER, mid INTEGER, random INTEGER, date INTEGER, data BLOB, fm TEXT, name TEXT, uname TEXT, flags INTEGER, PRIMARY KEY(uid, mid))").stepThis().dispose();
database.executeFast("CREATE TABLE unread_push_messages(uid INTEGER, mid INTEGER, random INTEGER, date INTEGER, data BLOB, fm TEXT, name TEXT, uname TEXT, flags INTEGER, topicId INTEGER, PRIMARY KEY(uid, mid))").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS unread_push_messages_idx_date ON unread_push_messages(date);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS unread_push_messages_idx_random ON unread_push_messages(random);").stepThis().dispose();
@ -1273,7 +1273,7 @@ public class MessagesStorage extends BaseController {
flags |= 2;
}
SQLitePreparedStatement state = database.executeFast("REPLACE INTO unread_push_messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
SQLitePreparedStatement state = database.executeFast("REPLACE INTO unread_push_messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
state.requery();
state.bindLong(1, message.getDialogId());
state.bindInteger(2, message.getId());
@ -1296,6 +1296,7 @@ public class MessagesStorage extends BaseController {
state.bindString(8, message.localUserName);
}
state.bindInteger(9, flags);
state.bindInteger(10, MessageObject.getTopicId(message.messageOwner, false));
state.step();
data.reuse();
@ -3510,7 +3511,7 @@ public class MessagesStorage extends BaseController {
cursor = null;
database.executeFast("DELETE FROM unread_push_messages WHERE date <= " + maxDate).stepThis().dispose();
cursor = database.queryFinalized("SELECT data, mid, date, uid, random, fm, name, uname, flags FROM unread_push_messages WHERE 1 ORDER BY date DESC LIMIT 50");
cursor = database.queryFinalized("SELECT data, mid, date, uid, random, fm, name, uname, flags, topicId FROM unread_push_messages WHERE 1 ORDER BY date DESC LIMIT 50");
while (cursor.next()) {
NativeByteBuffer data = cursor.byteBufferValue(0);
if (data != null) {
@ -3524,6 +3525,7 @@ public class MessagesStorage extends BaseController {
String name = cursor.isNull(6) ? null : cursor.stringValue(6);
String userName = cursor.isNull(7) ? null : cursor.stringValue(7);
int flags = cursor.intValue(8);
int topicId = cursor.intValue(9);
if (MessageObject.getFromChatId(message) == 0) {
if (DialogObject.isUserDialog(message.dialog_id)) {
message.from_id = new TLRPC.TL_peerUser();
@ -3539,6 +3541,11 @@ public class MessagesStorage extends BaseController {
chatsToLoad.add(-message.dialog_id);
}
}
if (topicId != 0) {
message.reply_to = new TLRPC.TL_messageReplyHeader();
message.reply_to.forum_topic = true;
message.reply_to.reply_to_top_id = topicId;
}
pushMessages.add(new MessageObject(currentAccount, message, messageText, name, userName, (flags & 1) != 0, (flags & 2) != 0, (message.flags & 0x80000000) != 0, false));
addUsersAndChatsFromMessage(message, usersToLoad, chatsToLoad, null);
@ -14230,6 +14237,15 @@ public class MessagesStorage extends BaseController {
}
}
}
if (message.media.peer != null) {
long dialogId = DialogObject.getPeerDialogId(message.media.peer);
if (dialogId > 0) {
usersToLoad.add(dialogId);
}
if (dialogId < 0) {
chatsToLoad.add(-dialogId);
}
}
}
if (message.replies != null) {
for (int a = 0, N = message.replies.recent_repliers.size(); a < N; a++) {

View file

@ -3692,6 +3692,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
TLRPC.TL_messageMediaStory mediaStory = new MessageMediaStoryFull();
mediaStory.id = sendingStory.id;
mediaStory.user_id = sendingStory.dialogId;
mediaStory.peer = getMessagesController().getPeer(sendingStory.dialogId);
mediaStory.storyItem = sendingStory;
newMsg.media = mediaStory;
type = MEDIA_TYPE_STORY;
@ -4278,7 +4279,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
} else if (type == MEDIA_TYPE_STORY) {
TLRPC.TL_inputMediaStory inputMediaStory = new TLRPC.TL_inputMediaStory();
inputMediaStory.id = sendingStory.id;
inputMediaStory.user_id = MessagesController.getInstance(currentAccount).getInputUser(sendingStory.dialogId);
inputMediaStory.peer = MessagesController.getInstance(currentAccount).getInputPeer(sendingStory.dialogId);
inputMedia = inputMediaStory;
}

View file

@ -234,6 +234,9 @@ public class SharedConfig {
public static int searchMessagesAsListHintShows;
public static int textSelectionHintShows;
public static int scheduledOrNoSoundHintShows;
public static long scheduledOrNoSoundHintSeenAt;
public static int scheduledHintShows;
public static long scheduledHintSeenAt;
public static int lockRecordAudioVideoHint;
public static boolean forwardingOptionsHintShown;
public static boolean searchMessagesAsListUsed;
@ -430,6 +433,9 @@ public class SharedConfig {
editor.putBoolean("sortFilesByName", sortFilesByName);
editor.putInt("textSelectionHintShows", textSelectionHintShows);
editor.putInt("scheduledOrNoSoundHintShows", scheduledOrNoSoundHintShows);
editor.putLong("scheduledOrNoSoundHintSeenAt", scheduledOrNoSoundHintSeenAt);
editor.putInt("scheduledHintShows", scheduledHintShows);
editor.putLong("scheduledHintSeenAt", scheduledHintSeenAt);
editor.putBoolean("forwardingOptionsHintShown", forwardingOptionsHintShown);
editor.putInt("lockRecordAudioVideoHint", lockRecordAudioVideoHint);
editor.putString("storageCacheDir", !TextUtils.isEmpty(storageCacheDir) ? storageCacheDir : "");
@ -605,6 +611,9 @@ public class SharedConfig {
storyReactionsLongPressHint = preferences.getBoolean("storyReactionsLongPressHint", false);
textSelectionHintShows = preferences.getInt("textSelectionHintShows", 0);
scheduledOrNoSoundHintShows = preferences.getInt("scheduledOrNoSoundHintShows", 0);
scheduledOrNoSoundHintSeenAt = preferences.getLong("scheduledOrNoSoundHintSeenAt", 0);
scheduledHintShows = preferences.getInt("scheduledHintShows", 0);
scheduledHintSeenAt = preferences.getLong("scheduledHintSeenAt", 0);
forwardingOptionsHintShown = preferences.getBoolean("forwardingOptionsHintShown", false);
lockRecordAudioVideoHint = preferences.getInt("lockRecordAudioVideoHint", 0);
disableVoiceAudioEffects = preferences.getBoolean("disableVoiceAudioEffects", false);
@ -824,6 +833,9 @@ public class SharedConfig {
lastUpdateVersion = BuildVars.BUILD_VERSION_STRING;
textSelectionHintShows = 0;
scheduledOrNoSoundHintShows = 0;
scheduledOrNoSoundHintSeenAt = 0;
scheduledHintShows = 0;
scheduledHintSeenAt = 0;
lockRecordAudioVideoHint = 0;
forwardingOptionsHintShown = false;
messageSeenHintCount = 3;
@ -887,10 +899,21 @@ public class SharedConfig {
editor.apply();
}
public static void increaseScheduledOrNoSuoundHintShowed() {
public static void increaseScheduledOrNoSoundHintShowed() {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
scheduledOrNoSoundHintSeenAt = System.currentTimeMillis();
editor.putInt("scheduledOrNoSoundHintShows", ++scheduledOrNoSoundHintShows);
editor.putLong("scheduledOrNoSoundHintSeenAt", scheduledOrNoSoundHintSeenAt);
editor.apply();
}
public static void increaseScheduledHintShowed() {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
scheduledHintSeenAt = System.currentTimeMillis();
editor.putInt("scheduledHintShows", ++scheduledHintShows);
editor.putLong("scheduledHintSeenAt", scheduledHintSeenAt);
editor.apply();
}
@ -909,6 +932,13 @@ public class SharedConfig {
editor.apply();
}
public static void removeScheduledHint() {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("scheduledHintShows", 3);
editor.apply();
}
public static void increaseLockRecordAudioVideoHintShowed() {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();

View file

@ -284,19 +284,42 @@ public class VideoEditedInfo {
entity.rotation = rotation;
entity.width = width;
entity.height = height;
entity.additionalHeight = additionalHeight;
entity.text = text;
entity.entities.addAll(entities);
if (entities != null) {
entity.entities = new ArrayList<>();
entity.entities.addAll(entities);
}
entity.color = color;
entity.fontSize = fontSize;
entity.textTypeface = textTypeface;
entity.textTypefaceKey = textTypefaceKey;
entity.textAlign = textAlign;
entity.viewWidth = viewWidth;
entity.viewHeight = viewHeight;
entity.roundRadius = roundRadius;
entity.scale = scale;
entity.textViewWidth = textViewWidth;
entity.textViewHeight = textViewHeight;
entity.textViewX = textViewX;
entity.textViewY = textViewY;
entity.textAlign = textAlign;
entity.textTypeface = textTypeface;
entity.document = document;
entity.parentObject = parentObject;
entity.metadata = metadata;
entity.ptr = ptr;
entity.currentFrame = currentFrame;
entity.framesPerDraw = framesPerDraw;
entity.bitmap = bitmap;
entity.view = view;
entity.canvas = canvas;
entity.animatedFileDrawable = animatedFileDrawable;
entity.roundRadiusCanvas = roundRadiusCanvas;
entity.mediaArea = mediaArea;
entity.mediaGeo = mediaGeo;
entity.density = density;
entity.W = W;
entity.H = H;
entity.visibleReaction = visibleReaction;
return entity;
}
}

View file

@ -68,7 +68,9 @@ public class AudioBufferConverter {
}
private void checkChannels(int inputChannelCount, int outputChannelCount){
// Check channel count.
if (inputChannelCount == 6 && outputChannelCount == 2) {
return;
}
if (inputChannelCount != 1 && inputChannelCount != 2) {
throw new UnsupportedOperationException("Input channel count (" + inputChannelCount + ") not supported.");
}

View file

@ -1,6 +1,7 @@
package org.telegram.messenger.video;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.SurfaceTexture;
import android.net.Uri;
@ -251,6 +252,15 @@ public class VideoPlayerHolderBase {
return;