diff --git a/TMessagesProj/src/main/java/androidx/recyclerview/widget/DefaultItemAnimator.java b/TMessagesProj/src/main/java/androidx/recyclerview/widget/DefaultItemAnimator.java index b5caeeb4e02..cc171b104d3 100644 --- a/TMessagesProj/src/main/java/androidx/recyclerview/widget/DefaultItemAnimator.java +++ b/TMessagesProj/src/main/java/androidx/recyclerview/widget/DefaultItemAnimator.java @@ -233,6 +233,7 @@ protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) { animation .setDuration(getRemoveDuration()) .setStartDelay(getRemoveDelay()) + .setInterpolator(getRemoveInterpolator()) .alpha(0) .scaleX(1f - animateByScale(view)) .scaleY(1f - animateByScale(view)) @@ -283,29 +284,30 @@ public void animateAddImpl(final RecyclerView.ViewHolder holder) { .scaleY(1f) .setDuration(getAddDuration()) .setStartDelay(getAddDelay()) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animator) { - dispatchAddStarting(holder); - } + .setInterpolator(getAddInterpolator()) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animator) { + dispatchAddStarting(holder); + } - @Override - public void onAnimationCancel(Animator animator) { - view.setAlpha(1); - if (animateByScale(view) > 0) { - view.setScaleX(1f); - view.setScaleY(1f); - } + @Override + public void onAnimationCancel(Animator animator) { + view.setAlpha(1); + if (animateByScale(view) > 0) { + view.setScaleX(1f); + view.setScaleY(1f); } + } - @Override - public void onAnimationEnd(Animator animator) { - animation.setListener(null); - dispatchAddFinished(holder); - mAddAnimations.remove(holder); - dispatchFinishedWhenDone(); - } - }).start(); + @Override + public void onAnimationEnd(Animator animator) { + animation.setListener(null); + dispatchAddFinished(holder); + mAddAnimations.remove(holder); + dispatchFinishedWhenDone(); + } + }).start(); } @Override @@ -368,12 +370,13 @@ protected void animateMoveImpl(final RecyclerView.ViewHolder holder, MoveInfo mo } if (translationInterpolator != null) { animation.setInterpolator(translationInterpolator); + } else { + animation.setInterpolator(getMoveInterpolator()); } beforeAnimateMoveImpl(holder); animation .setDuration(getMoveDuration()) .setStartDelay(getMoveDelay()) - .setInterpolator(getMoveInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { @@ -455,6 +458,7 @@ void animateChangeImpl(final ChangeInfo changeInfo) { .scaleY(1f - animateByScale(view)); } oldViewAnim + .setInterpolator(getChangeInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { @@ -484,6 +488,7 @@ public void onAnimationEnd(Animator animator) { .translationX(0).translationY(0) .setDuration(getChangeAddDuration()) .setStartDelay(getChangeDelay() + (getChangeDuration() - getChangeAddDuration())) + .setInterpolator(getChangeInterpolator()) .alpha(1); if (animateByScale(newView) > 0) { newViewAnimation.scaleX(1f).scaleY(1f); diff --git a/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java b/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java index 83547b5b8a8..dc2a4deef70 100644 --- a/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java +++ b/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java @@ -12747,7 +12747,10 @@ public abstract static class ItemAnimator { private long mChangeAddDuration = 250; private long mChangeRemoveDuration = 250; - private TimeInterpolator mMoveInterpolator = null; + private TimeInterpolator mAddInterpolator; + private TimeInterpolator mMoveInterpolator; + private TimeInterpolator mRemoveInterpolator; + private TimeInterpolator mChangeInterpolator; private long mAddDelay = 0; private long mRemoveDelay = 0; @@ -12902,10 +12905,29 @@ public void setMoveInterpolator(TimeInterpolator interpolator) { mMoveInterpolator = interpolator; } + public void setInterpolator(TimeInterpolator interpolator) { + mAddInterpolator = interpolator; + mMoveInterpolator = interpolator; + mRemoveInterpolator = interpolator; + mChangeInterpolator = interpolator; + } + + public TimeInterpolator getAddInterpolator() { + return mAddInterpolator; + } + public TimeInterpolator getMoveInterpolator() { return mMoveInterpolator; } + public TimeInterpolator getRemoveInterpolator() { + return mRemoveInterpolator; + } + + public TimeInterpolator getChangeInterpolator() { + return mChangeInterpolator; + } + /** * Internal only: * Sets the listener that must be called when the animator is finished diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index ee09a72d4eb..344575aeba8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -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 = 2956; - public static String BUILD_VERSION_STRING = "9.2.0"; + public static int BUILD_VERSION = 2962; + public static String BUILD_VERSION_STRING = "9.2.1"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java index f200a952fca..6cb108a952f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -35,6 +35,7 @@ public class FileLoadOperation { long streamOffset; public static volatile DispatchQueue filesQueue = new DispatchQueue("writeFileQueue"); + private boolean forceSmallChunk; public void setStream(FileLoadOperationStream stream, boolean streamPriority, long streamOffset) { this.stream = stream; @@ -48,6 +49,7 @@ protected static class RequestInfo { private TLRPC.TL_upload_file response; private TLRPC.TL_upload_webFile responseWeb; private TLRPC.TL_upload_cdnFile responseCdn; + private boolean forceSmallChunk; } public static class Range { @@ -205,7 +207,7 @@ public interface FileLoadOperationDelegate { } private void updateParams() { - if (MessagesController.getInstance(currentAccount).getfileExperimentalParams) { + if (MessagesController.getInstance(currentAccount).getfileExperimentalParams && !forceSmallChunk) { downloadChunkSizeBig = 1024 * 512; maxDownloadRequests = 8; maxDownloadRequestsBig = 8; @@ -1756,7 +1758,14 @@ protected boolean processRequestResult(RequestInfo requestInfo, TLRPC.TL_error e } } } else { - if (error.text.contains("FILE_MIGRATE_")) { + if (error.text.contains("LIMIT_INVALID") && !requestInfo.forceSmallChunk) { + if (!forceSmallChunk) { + forceSmallChunk = true; + currentDownloadChunkSize = 0; + pause(); + start(); + } + } else if (error.text.contains("FILE_MIGRATE_")) { String errorMsg = error.text.replace("FILE_MIGRATE_", ""); Scanner scanner = new Scanner(errorMsg); scanner.useDelimiter(""); @@ -1993,6 +2002,7 @@ protected void startDownloadRequest() { final RequestInfo requestInfo = new RequestInfo(); requestInfos.add(requestInfo); requestInfo.offset = downloadOffset; + requestInfo.forceSmallChunk = forceSmallChunk; if (!isPreloadVideoOperation && supportsPreloading && preloadStream != null && preloadedBytesRanges != null) { PreloadRange range = preloadedBytesRanges.get(requestInfo.offset); @@ -2032,7 +2042,7 @@ protected void startDownloadRequest() { continue; } } - + requestInfo.forceSmallChunk = forceSmallChunk; requestInfo.requestToken = ConnectionsManager.getInstance(currentAccount).sendRequest(request, (response, error) -> { if (!requestInfos.contains(requestInfo)) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java index 200ad3bfeb6..bbb75c28d53 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java @@ -77,7 +77,7 @@ public static void dumpResponseAndRequest(TLObject request, TLObject response, T String requestSimpleName = request.getClass().getSimpleName(); checkGson(); - if (excludeRequests.contains(requestSimpleName)) { + if (excludeRequests.contains(requestSimpleName) && error == null) { return; } try { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java index e33a1a7aac5..75decfcfafe 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java @@ -478,12 +478,12 @@ public boolean isCurrentLocalLocale() { return currentLocaleInfo.isLocal(); } - public void reloadCurrentRemoteLocale(int currentAccount, String langCode, boolean force) { + public void reloadCurrentRemoteLocale(int currentAccount, String langCode, boolean force, Runnable onDone) { if (langCode != null) { langCode = langCode.replace("-", "_"); } if (langCode == null || currentLocaleInfo != null && (langCode.equals(currentLocaleInfo.shortName) || langCode.equals(currentLocaleInfo.baseLangCode))) { - applyRemoteLanguage(currentLocaleInfo, langCode, force, currentAccount); + applyRemoteLanguage(currentLocaleInfo, langCode, force, currentAccount, onDone); } } @@ -493,11 +493,11 @@ public void checkUpdateForCurrentRemoteLocale(int currentAccount, int version, i } if (currentLocaleInfo.hasBaseLang()) { if (currentLocaleInfo.baseVersion < baseVersion) { - applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.baseLangCode, false, currentAccount); + applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.baseLangCode, false, currentAccount, null); } } if (currentLocaleInfo.version < version) { - applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.shortName, false, currentAccount); + applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.shortName, false, currentAccount, null); } } @@ -654,7 +654,7 @@ public boolean applyLanguageFile(File file, int currentAccount) { saveOtherLanguages(); } localeValues = stringMap; - applyLanguage(localeInfo, true, false, true, false, currentAccount); + applyLanguage(localeInfo, true, false, true, false, currentAccount, null); return true; } } catch (Exception e) { @@ -848,14 +848,15 @@ private HashMap getLocaleFileStrings(File file, boolean preserve return new HashMap<>(); } - public void applyLanguage(LocaleInfo localeInfo, boolean override, boolean init, final int currentAccount) { - applyLanguage(localeInfo, override, init, false, false, currentAccount); + public int applyLanguage(LocaleInfo localeInfo, boolean override, boolean init, final int currentAccount) { + return applyLanguage(localeInfo, override, init, false, false, currentAccount, null); } - public void applyLanguage(final LocaleInfo localeInfo, boolean override, boolean init, boolean fromFile, boolean force, final int currentAccount) { + public int applyLanguage(final LocaleInfo localeInfo, boolean override, boolean init, boolean fromFile, boolean force, final int currentAccount, Runnable onDone) { if (localeInfo == null) { - return; + return 0; } + int requestId = 0; boolean hasBase = localeInfo.hasBaseLang(); File pathToFile = localeInfo.getPathToFile(); File pathToBaseFile = localeInfo.getPathToBaseFile(); @@ -884,9 +885,9 @@ public void applyLanguage(final LocaleInfo localeInfo, boolean override, boolean } isLoadingRemote = true; if (init) { - AndroidUtilities.runOnUIThread(() -> applyRemoteLanguage(localeInfo, null, true, currentAccount)); + AndroidUtilities.runOnUIThread(() -> applyRemoteLanguage(localeInfo, null, true, currentAccount, onDone)); } else { - applyRemoteLanguage(localeInfo, null, true, currentAccount); + requestId = applyRemoteLanguage(localeInfo, null, true, currentAccount, onDone); } } try { @@ -943,9 +944,9 @@ public void applyLanguage(final LocaleInfo localeInfo, boolean override, boolean changingConfiguration = false; if (reloadLastFile) { if (init) { - AndroidUtilities.runOnUIThread(() -> reloadCurrentRemoteLocale(currentAccount, null, force)); + AndroidUtilities.runOnUIThread(() -> reloadCurrentRemoteLocale(currentAccount, null, force, null)); } else { - reloadCurrentRemoteLocale(currentAccount, null, force); + reloadCurrentRemoteLocale(currentAccount, null, force, null); } reloadLastFile = false; } @@ -955,6 +956,9 @@ public void applyLanguage(final LocaleInfo localeInfo, boolean override, boolean } else { NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.reloadInterface); } + if (onDone != null) { + onDone.run(); + } } } catch (Exception e) { FileLog.e(e); @@ -964,6 +968,7 @@ public void applyLanguage(final LocaleInfo localeInfo, boolean override, boolean if (force) { MediaDataController.getInstance(currentAccount).loadAttachMenuBots(false, true); } + return requestId; } public LocaleInfo getCurrentLocaleInfo() { @@ -2053,10 +2058,10 @@ public void saveRemoteLocaleStringsForCurrentLocale(final TLRPC.TL_langPackDiffe if (!langCode.equals(currentLocaleInfo.shortName) && !langCode.equals(currentLocaleInfo.baseLangCode)) { return; } - saveRemoteLocaleStrings(currentLocaleInfo, difference, currentAccount); + saveRemoteLocaleStrings(currentLocaleInfo, difference, currentAccount, null); } - public void saveRemoteLocaleStrings(LocaleInfo localeInfo, final TLRPC.TL_langPackDifference difference, int currentAccount) { + public void saveRemoteLocaleStrings(LocaleInfo localeInfo, final TLRPC.TL_langPackDifference difference, int currentAccount, Runnable onDone) { if (difference == null || difference.strings.isEmpty() || localeInfo == null || localeInfo.isLocal()) { return; } @@ -2171,6 +2176,9 @@ public void saveRemoteLocaleStrings(LocaleInfo localeInfo, final TLRPC.TL_langPa } recreateFormatters(); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.reloadInterface); + if (onDone != null) { + onDone.run(); + } }); } catch (Exception ignore) { @@ -2256,9 +2264,9 @@ public void loadRemoteLanguages(final int currentAccount, boolean applyCurrent) }, ConnectionsManager.RequestFlagWithoutLogin); } - private void applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean force, final int currentAccount) { + private int applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean force, final int currentAccount, Runnable onDone) { if (localeInfo == null || !localeInfo.isRemote() && !localeInfo.isUnofficial()) { - return; + return 0; } if (localeInfo.hasBaseLang() && (langCode == null || langCode.equals(localeInfo.baseLangCode))) { if (localeInfo.baseVersion != 0 && !force) { @@ -2267,18 +2275,18 @@ private void applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean req.from_version = localeInfo.baseVersion; req.lang_code = localeInfo.getBaseLangCode(); req.lang_pack = ""; - ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { + return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { if (response != null) { - AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount)); + AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone)); } }, ConnectionsManager.RequestFlagWithoutLogin); } } else { TLRPC.TL_langpack_getLangPack req = new TLRPC.TL_langpack_getLangPack(); req.lang_code = localeInfo.getBaseLangCode(); - ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> { + return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> { if (response != null) { - AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount)); + AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone)); } }, ConnectionsManager.RequestFlagWithoutLogin); } @@ -2289,9 +2297,9 @@ private void applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean req.from_version = localeInfo.version; req.lang_code = localeInfo.getLangCode(); req.lang_pack = ""; - ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { + return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { if (response != null) { - AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount)); + AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone)); } }, ConnectionsManager.RequestFlagWithoutLogin); } else { @@ -2300,13 +2308,14 @@ private void applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean } TLRPC.TL_langpack_getLangPack req = new TLRPC.TL_langpack_getLangPack(); req.lang_code = localeInfo.getLangCode(); - ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> { + return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> { if (response != null) { - AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount)); + AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone)); } }, ConnectionsManager.RequestFlagWithoutLogin); } } + return 0; } public String getTranslitString(String src) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 04ac68ef22f..ef1a90b0a13 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -2320,6 +2320,15 @@ public MessageObject(int accountNum, TLRPC.TL_channelAdminLogEvent event, ArrayL ); messageText = replaceWithLink(messageText, "un2", pinTopic.new_topic); } + } else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionToggleAntiSpam) { + TLRPC.TL_channelAdminLogEventActionToggleAntiSpam action = (TLRPC.TL_channelAdminLogEventActionToggleAntiSpam) event.action; + messageText = replaceWithLink( + action.new_value ? + LocaleController.getString("EventLogEnabledAntiSpam", R.string.EventLogEnabledAntiSpam) : + LocaleController.getString("EventLogDisabledAntiSpam", R.string.EventLogDisabledAntiSpam), + "un1", + fromUser + ); } else { messageText = "unsupported " + event.action; } @@ -6180,7 +6189,7 @@ public static TLRPC.InputStickerSet getInputStickerSet(TLRPC.Document document) for (int a = 0, N = document.attributes.size(); a < N; a++) { TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker || - attribute instanceof TLRPC.TL_documentAttributeCustomEmoji) { + attribute instanceof TLRPC.TL_documentAttributeCustomEmoji) { if (attribute.stickerset instanceof TLRPC.TL_inputStickerSetEmpty) { return null; } @@ -6201,7 +6210,7 @@ public static String findAnimatedEmojiEmoticon(TLRPC.Document document, String f for (int a = 0, N = document.attributes.size(); a < N; a++) { TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeCustomEmoji || - attribute instanceof TLRPC.TL_documentAttributeSticker) { + attribute instanceof TLRPC.TL_documentAttributeSticker) { return attribute.alt; } } @@ -6234,6 +6243,23 @@ public static boolean isFreeEmoji(TLRPC.Document document) { return false; } + public static boolean isTextColorEmoji(TLRPC.Document document) { + if (document == null) { + return false; + } + TLRPC.InputStickerSet set = MessageObject.getInputStickerSet(document); + for (int a = 0, N = document.attributes.size(); a < N; a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeCustomEmoji) { + if (attribute.stickerset instanceof TLRPC.TL_inputStickerSetID && attribute.stickerset.id == 1269403972611866647L) { + return true; + } + return ((TLRPC.TL_documentAttributeCustomEmoji) attribute).text_color; + } + } + return false; + } + public static boolean isPremiumEmojiPack(TLRPC.TL_messages_stickerSet set) { if (set != null && set.set != null && !set.set.emojis) { return false; @@ -7375,7 +7401,7 @@ public boolean selectReaction(ReactionsLayoutInBubble.VisibleReaction visibleRea } int maxReactionsCount = MessagesController.getInstance(currentAccount).getMaxUserReactionsCount(); - if (!choosenReactions.isEmpty() && (choosenReactions.contains(newReaction) || fromDoubleTap)) { + if (!choosenReactions.isEmpty() && choosenReactions.contains(newReaction)) { if (newReaction != null) { newReaction.chosen = false; newReaction.count--; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 9268e6772c9..ee5b76908ae 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -182,13 +182,13 @@ public class MessagesController extends BaseController implements NotificationCe private LongSparseArray fullChats = new LongSparseArray<>(); private LongSparseArray groupCalls = new LongSparseArray<>(); private LongSparseArray groupCallsByChatId = new LongSparseArray<>(); - private ArrayList loadingFullUsers = new ArrayList<>(); - private ArrayList loadedFullUsers = new ArrayList<>(); - private ArrayList loadingFullChats = new ArrayList<>(); - private ArrayList loadingGroupCalls = new ArrayList<>(); - private ArrayList loadingFullParticipants = new ArrayList<>(); - private ArrayList loadedFullParticipants = new ArrayList<>(); - private ArrayList loadedFullChats = new ArrayList<>(); + private HashSet loadingFullUsers = new HashSet<>(); + private LongSparseLongArray loadedFullUsers = new LongSparseLongArray(); + private HashSet loadingFullChats = new HashSet<>(); + private HashSet loadingGroupCalls = new HashSet<>(); + private HashSet loadingFullParticipants = new HashSet<>(); + private HashSet loadedFullParticipants = new HashSet<>(); + public LongSparseLongArray loadedFullChats = new LongSparseLongArray(); private LongSparseArray> channelAdmins = new LongSparseArray<>(); private LongSparseIntArray loadingChannelAdmins = new LongSparseIntArray(); @@ -3955,7 +3955,7 @@ public void putChat(final TLRPC.Chat chat, boolean fromCache) { if (!fromCache) { if (oldChat != null) { if (chat.version != oldChat.version) { - loadedFullChats.remove(chat.id); + loadedFullChats.delete(chat.id); } if (oldChat.participants_count != 0 && chat.participants_count == 0) { chat.participants_count = oldChat.participants_count; @@ -4328,10 +4328,11 @@ public void processLoadedChannelAdmins(final LongSparseArray 0; + if (loadingFullChats.contains(chatId) || !force && loaded) { + return; + } loadingFullChats.add(chatId); TLObject request; long dialogId = -chatId; @@ -4413,7 +4414,7 @@ public void loadFullChat(long chatId, int classGuid, boolean force) { } exportedChats.put(chatId, res.full_chat.exported_invite); loadingFullChats.remove(chatId); - loadedFullChats.add(chatId); + loadedFullChats.put(chatId, System.currentTimeMillis()); putUsers(res.users, false); putChats(res.chats, false); @@ -4450,7 +4451,7 @@ public void loadFullChat(long chatId, int classGuid, boolean force) { } public void loadFullUser(final TLRPC.User user, int classGuid, boolean force) { - if (user == null || loadingFullUsers.contains(user.id) || !force && loadedFullUsers.contains(user.id)) { + if (user == null || loadingFullUsers.contains(user.id) || !force && loadedFullUsers.get(user.id) > 0) { return; } loadingFullUsers.add(user.id); @@ -4491,7 +4492,7 @@ public void loadFullUser(final TLRPC.User user, int classGuid, boolean force) { } fullUsers.put(user.id, userFull); loadingFullUsers.remove(user.id); - loadedFullUsers.add(user.id); + loadedFullUsers.put(user.id, System.currentTimeMillis()); String names = user.first_name + user.last_name + UserObject.getPublicUsername(user); ArrayList users = new ArrayList<>(); users.add(userFull.user); @@ -6302,7 +6303,10 @@ public void putChatFull(TLRPC.ChatFull chatFull) { public void processChatInfo(long chatId, TLRPC.ChatFull info, ArrayList usersArr, boolean fromCache, boolean force, boolean byChannelUsers, ArrayList pinnedMessages, HashMap pinnedMessagesMap, int totalPinnedCount, boolean pinnedEndReached) { AndroidUtilities.runOnUIThread(() -> { if (fromCache && chatId > 0 && !byChannelUsers) { - loadFullChat(chatId, 0, force); + long lastLoadedTime = loadedFullChats.get(chatId, 0); + if (System.currentTimeMillis() - lastLoadedTime > 60 * 1000) { + loadFullChat(chatId, 0, force); + } } if (info != null) { if (fullChats.get(chatId) == null) { @@ -6341,7 +6345,10 @@ public void updateUsernameActiveness(TLObject object, String username, boolean a public void processUserInfo(TLRPC.User user, TLRPC.UserFull info, boolean fromCache, boolean force, int classGuid, ArrayList pinnedMessages, HashMap pinnedMessagesMap, int totalPinnedCount, boolean pinnedEndReached) { AndroidUtilities.runOnUIThread(() -> { if (fromCache) { - loadFullUser(user, classGuid, force); + long lastLoadedTime = loadedFullUsers.get(user.id, 0); + if (System.currentTimeMillis() - lastLoadedTime > 60 * 1000) { + loadFullUser(user, classGuid, force); + } } if (info != null) { if (fullUsers.get(user.id) == null) { @@ -14324,7 +14331,7 @@ public boolean processUpdateArray(ArrayList updates, ArrayList LocaleController.getInstance().saveRemoteLocaleStringsForCurrentLocale(update.difference, currentAccount)); } else if (baseUpdate instanceof TLRPC.TL_updateLangPackTooLong) { TLRPC.TL_updateLangPackTooLong update = (TLRPC.TL_updateLangPackTooLong) baseUpdate; - LocaleController.getInstance().reloadCurrentRemoteLocale(currentAccount, update.lang_code, false); + LocaleController.getInstance().reloadCurrentRemoteLocale(currentAccount, update.lang_code, false, null); } else if (baseUpdate instanceof TLRPC.TL_updateRecentReactions) { if (updatesOnMainThread == null) { updatesOnMainThread = new ArrayList<>(); @@ -14456,7 +14463,7 @@ public boolean processUpdateArray(ArrayList updates, ArrayList(); } MessagesStorage.TopicKey topicKey = MessagesStorage.TopicKey.of(-update.channel_id, update.top_msg_id); - topicsReadInbox.put(MessagesStorage.TopicKey.of(-update.channel_id, update.top_msg_id), Math.max(Utilities.getOrDefault(topicsReadInbox, topicKey, 0), update.read_max_id)); + topicsReadInbox.put(topicKey, Math.max(Utilities.getOrDefault(topicsReadInbox, topicKey, 0), update.read_max_id)); if (updatesOnMainThread == null) { updatesOnMainThread = new ArrayList<>(); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index 6d89856d612..60533c794a2 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -11060,6 +11060,7 @@ private void createOrEditTopic(long dialogId, TLRPC.Message message) { forumTopic.icon_emoji_id = action.icon_emoji_id; forumTopic.title = action.title; forumTopic.closed = action.closed; + forumTopic.hidden = action.hidden; int flags = 0; if ((action.flags & 1) != 0) { flags += TopicsController.TOPIC_FLAG_TITLE; @@ -11070,6 +11071,9 @@ private void createOrEditTopic(long dialogId, TLRPC.Message message) { if ((action.flags & 4) != 0) { flags += TopicsController.TOPIC_FLAG_CLOSE; } + if ((action.flags & 8) != 0) { + flags += TopicsController.TOPIC_FLAG_HIDE; + } updateTopicData(dialogId, forumTopic, flags); int finalFlags = flags; AndroidUtilities.runOnUIThread(() -> { diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index a17ceb6c978..e8bc858b22f 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -1877,10 +1877,12 @@ public static class TL_documentAttributeCustomEmoji extends DocumentAttribute { public static int constructor = 0xfd149899; public boolean free; + public boolean text_color; public void readParams(AbstractSerializedData stream, boolean exception) { flags = stream.readInt32(exception); free = (flags & 1) != 0; + text_color = (flags & 2) != 0; alt = stream.readString(exception); stickerset = InputStickerSet.TLdeserialize(stream, stream.readInt32(exception), exception); } @@ -1888,6 +1890,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) { public void serializeToStream(AbstractSerializedData stream) { stream.writeInt32(constructor); flags = free ? (flags | 1) : (flags &~ 1); + flags = text_color ? (flags | 2) : (flags &~ 2); stream.writeInt32(flags); stream.writeString(alt); stickerset.serializeToStream(stream); @@ -41030,6 +41033,9 @@ public static ChannelAdminLogEventAction TLdeserialize(AbstractSerializedData st case 0xae168909: result = new TL_channelAdminLogEventActionDeleteTopic(); break; + case 0x64f36dfc: + result = new TL_channelAdminLogEventActionToggleAntiSpam(); + break; } if (result == null && exception) { throw new RuntimeException(String.format("can't parse magic %x in ChannelAdminLogEventAction", constructor)); @@ -41774,6 +41780,21 @@ public void serializeToStream(AbstractSerializedData stream) { } } + public static class TL_channelAdminLogEventActionToggleAntiSpam extends ChannelAdminLogEventAction { + public static int constructor = 0x64f36dfc; + + public boolean new_value; + + public void readParams(AbstractSerializedData stream, boolean exception) { + new_value = stream.readBool(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeBool(new_value); + } + } + public static abstract class InputWebFileLocation extends TLObject { public static InputWebFileLocation TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index 1b1ccaaf124..3911792d7c6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -37,6 +37,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewPropertyAnimator; +import android.view.animation.Interpolator; import android.widget.FrameLayout; import android.widget.ImageView; @@ -1621,6 +1622,10 @@ public static int getCurrentActionBarHeight() { } public void setTitleAnimated(CharSequence title, boolean fromBottom, long duration) { + setTitleAnimated(title, fromBottom, duration, null); + } + + public void setTitleAnimated(CharSequence title, boolean fromBottom, long duration, Interpolator interpolator) { if (titleTextView[0] == null || title == null) { setTitle(title); return; @@ -1648,13 +1653,20 @@ public void setTitleAnimated(CharSequence title, boolean fromBottom, long durati if (!crossfade) { titleTextView[0].setTranslationY(fromBottom ? AndroidUtilities.dp(20) : -AndroidUtilities.dp(20)); } - titleTextView[0].animate().alpha(1f).translationY(0).setDuration(duration).start(); + ViewPropertyAnimator a1 = titleTextView[0].animate().alpha(1f).translationY(0).setDuration(duration); + if (interpolator != null) { + a1.setInterpolator(interpolator); + } + a1.start(); titleAnimationRunning = true; ViewPropertyAnimator a = titleTextView[1].animate().alpha(0); if (!crossfade) { a.translationY(fromBottom ? -AndroidUtilities.dp(20) : AndroidUtilities.dp(20)); } + if (interpolator != null) { + a.setInterpolator(interpolator); + } a.setDuration(duration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java index 30d74f3ab34..6f902421310 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -3059,6 +3059,7 @@ public void run() { public static MessageDrawable chat_msgOutMediaDrawable; public static MessageDrawable chat_msgOutMediaSelectedDrawable; private static StatusDrawable[] chat_status_drawables = new StatusDrawable[6]; + public static PorterDuffColorFilter chat_animatedEmojiTextColorFilter; public static PathAnimator playPauseAnimator; public static Drawable chat_msgOutCheckDrawable; @@ -8896,6 +8897,8 @@ public static void applyCommonTheme() { dialogs_unarchiveDrawable.setLayerColor("Box1.**", getNonAnimatedColor(key_chats_archiveIcon)); dialogs_unarchiveDrawable.commitApplyLayerColors(); + chat_animatedEmojiTextColorFilter = new PorterDuffColorFilter(getColor(key_windowBackgroundWhiteBlackText), PorterDuff.Mode.SRC_IN); + PremiumGradient.getInstance().checkIconColors(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java index c070fdf8475..f677d33ad65 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -287,7 +287,7 @@ public TLObject getItem(int i) { if (itemInternals.get(i).dialog != null) { return itemInternals.get(i).dialog; } else if (itemInternals.get(i).contact != null) { - return itemInternals.get(i).contact; + return MessagesController.getInstance(currentAccount).getUser(itemInternals.get(i).contact.user_id); } else if (itemInternals.get(i).recentMeUrl != null) { return itemInternals.get(i).recentMeUrl; } @@ -731,8 +731,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) { } case VIEW_TYPE_USER: { UserCell cell = (UserCell) holder.itemView; - TLRPC.TL_contact contact = (TLRPC.TL_contact) getItem(i); - TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(contact.user_id); + TLRPC.User user = (TLRPC.User) getItem(i); cell.setData(user, null, null, 0); break; } @@ -803,27 +802,28 @@ public int getItemViewType(int i) { return itemInternals.get(i).viewType; } + public void moveDialogs(RecyclerListView recyclerView, int fromPosition, int toPosition) { + ArrayList dialogs = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, false); + int fromIndex = fixPosition(fromPosition); + int toIndex = fixPosition(toPosition); + TLRPC.Dialog fromDialog = dialogs.get(fromIndex); + TLRPC.Dialog toDialog = dialogs.get(toIndex); + if (dialogsType == 7 || dialogsType == 8) { + MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0]; + int idx1 = filter.pinnedDialogs.get(fromDialog.id); + int idx2 = filter.pinnedDialogs.get(toDialog.id); + filter.pinnedDialogs.put(fromDialog.id, idx2); + filter.pinnedDialogs.put(toDialog.id, idx1); + } else { + int oldNum = fromDialog.pinnedNum; + fromDialog.pinnedNum = toDialog.pinnedNum; + toDialog.pinnedNum = oldNum; + } + Collections.swap(dialogs, fromIndex, toIndex); + updateList(recyclerView); + } @Override public void notifyItemMoved(int fromPosition, int toPosition) { - if (!fromDiffUtils) { - ArrayList dialogs = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, false); - int fromIndex = fixPosition(fromPosition); - int toIndex = fixPosition(toPosition); - TLRPC.Dialog fromDialog = dialogs.get(fromIndex); - TLRPC.Dialog toDialog = dialogs.get(toIndex); - if (dialogsType == 7 || dialogsType == 8) { - MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0]; - int idx1 = filter.pinnedDialogs.get(fromDialog.id); - int idx2 = filter.pinnedDialogs.get(toDialog.id); - filter.pinnedDialogs.put(fromDialog.id, idx2); - filter.pinnedDialogs.put(toDialog.id, idx1); - } else { - int oldNum = fromDialog.pinnedNum; - fromDialog.pinnedNum = toDialog.pinnedNum; - toDialog.pinnedNum = oldNum; - } - Collections.swap(dialogs, fromIndex, toIndex); - } super.notifyItemMoved(fromPosition, toPosition); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java index 49462a91845..7a2cadc8945 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java @@ -697,6 +697,7 @@ public void clearRecentSearch() { while (filtered2RecentSearchObjects.size() > 0) { RecentSearchObject obj = filtered2RecentSearchObjects.remove(0); recentSearchObjects.remove(obj); + filteredRecentSearchObjects.remove(obj); recentSearchObjectsById.remove(obj.did); if (queryFilter == null) { queryFilter = new StringBuilder("did IN ("); @@ -712,6 +713,7 @@ public void clearRecentSearch() { } } else { filtered2RecentSearchObjects.clear(); + filteredRecentSearchObjects.clear(); recentSearchObjects.clear(); recentSearchObjectsById.clear(); queryFilter = new StringBuilder("1"); @@ -735,6 +737,8 @@ public void removeRecentSearch(long did) { } recentSearchObjectsById.remove(did); recentSearchObjects.remove(object); + filtered2RecentSearchObjects.remove(object); + filteredRecentSearchObjects.remove(object); notifyDataSetChanged(); MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> { try { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java index 6a60aa59ac6..e115c0f4401 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java @@ -313,7 +313,7 @@ private void loadDialogEntities() { i--; } } - Collections.sort(entities, (o1, o2) -> (int) (o2.totalSize - o1.totalSize)); + sort(entities); AndroidUtilities.runOnUIThread(() -> { loadingDialogs = false; getMessagesController().putUsers(users, true); @@ -333,7 +333,7 @@ private void loadDialogEntities() { unknownChatsEntity = dialogEntities; } if (changed) { - Collections.sort(entities, (o1, o2) -> (int) (o2.totalSize - o1.totalSize)); + sort(entities); } } } @@ -346,6 +346,17 @@ private void loadDialogEntities() { }); } + private void sort(ArrayList entities) { + Collections.sort(entities, (o1, o2) -> { + if (o2.totalSize > o1.totalSize) { + return 1; + } else if (o2.totalSize < o1.totalSize) { + return -1; + } + return 0; + }); + } + ArrayList dialogsFilesEntities = null; @@ -1569,6 +1580,6 @@ private void checkActionMode() { selectedDialogsCountTextView.setOnTouchListener((v, event) -> true); - ActionBarMenuItem deleteItem = actionMode.addItemWithWidth(delete_id, R.drawable.msg_delete, AndroidUtilities.dp(54), LocaleController.getString("ClearCache", R.string.ClearCache)); + ActionBarMenuItem deleteItem = actionMode.addItemWithWidth(delete_id, R.drawable.msg_clear, AndroidUtilities.dp(54), LocaleController.getString("ClearCache", R.string.ClearCache)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 48d0a46a7f2..3ac18c1802d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -6241,6 +6241,9 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe if (messageObject.isAnimatedAnimatedEmoji()) { photoWidth = Math.max(512, photoWidth); photoHeight = Math.max(512, photoHeight); + if (MessageObject.isTextColorEmoji(messageObject.getDocument())) { + photoImage.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + } } float maxHeight; int maxWidth; @@ -11934,9 +11937,9 @@ private void setMessageObjectInternal(MessageObject messageObject) { } drawTopic = false; - if (!isThreadChat && (delegate != null && delegate.shouldShowTopicButton()) && !pinnedTop && (MessageObject.getTopicId(messageObject.messageOwner, ChatObject.isForum(currentChat)) != 0 || messageObject.replyToForumTopic != null)) { + if (!isThreadChat && (delegate != null && delegate.shouldShowTopicButton()) && !pinnedTop && (MessageObject.getTopicId(messageObject.messageOwner, true) != 0 || messageObject.replyToForumTopic != null)) { if (currentPosition == null || currentPosition.minY == 0) { - int topicId = messageObject.replyToForumTopic == null ? MessageObject.getTopicId(messageObject.messageOwner, ChatObject.isForum(currentChat)) : messageObject.replyToForumTopic.id; + int topicId = messageObject.replyToForumTopic == null ? MessageObject.getTopicId(messageObject.messageOwner, true) : messageObject.replyToForumTopic.id; TLRPC.TL_forumTopic topic = messageObject.replyToForumTopic == null ? MessagesController.getInstance(currentAccount).getTopicsController().findTopic(-messageObject.getDialogId(), topicId) : messageObject.replyToForumTopic; if (topic != null) { drawTopic = true; @@ -13965,6 +13968,9 @@ public void drawNamesLayout(Canvas canvas, float alpha) { x -= AndroidUtilities.dp(2.33f); y = AndroidUtilities.dp(12) + (drawNameLayout && nameLayout != null ? AndroidUtilities.dp(6) + (int) Theme.chat_namePaint.getTextSize() : 0); } + if (transitionParams.animateBackgroundBoundsInner) { + x += transitionParams.deltaLeft; + } topicButton.draw(canvas, x, y, animatingAlpha * replyForwardAlpha); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index a540792e17d..77e6b3e2d7e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -2070,6 +2070,7 @@ public void buildLayout() { if (useForceThreeLines || SharedConfig.useThreeLinesLayout) { typingLayout = StaticLayoutEx.createStaticLayout(typingString, Theme.dialogs_messagePrintingPaint[paintIndex], messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, AndroidUtilities.dp(1), false, TextUtils.TruncateAt.END, messageWidth, typingString != null ? 1 : 2); } else { + typingString = TextUtils.ellipsize(typingString, currentMessagePaint, messageWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); typingLayout = new StaticLayout(typingString, Theme.dialogs_messagePrintingPaint[paintIndex], messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } } @@ -2318,7 +2319,7 @@ private CharSequence formatTopicsNames() { } if (boldLen > 0) { spannableStringBuilder.setSpan( - new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.getColor(Theme.key_chats_name, resourcesProvider)), + new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.key_chats_name, null), 0, Math.min(spannableStringBuilder.length(), boldLen + 2), 0 ); } @@ -4717,7 +4718,9 @@ public boolean update() { } int messageHash = message == null ? 0 : message.getId(); Integer printingType = null; - long readHash = dialog.read_inbox_max_id + ((long) dialog.read_outbox_max_id << 8) + ((long) dialog.unread_count << 16); + long readHash = dialog.read_inbox_max_id + ((long) dialog.read_outbox_max_id << 8) + ((long) (dialog.unread_count + (dialog.unread_mark ? -1 : 0)) << 16) + + (dialog.unread_reactions_count > 0 ? (1 << 18) : 0) + + (dialog.unread_mentions_count > 0 ? (1 << 19) : 0); if (!isForumCell() && (isDialogCell || isTopic)) { if (!TextUtils.isEmpty(MessagesController.getInstance(currentAccount).getPrintingString(currentDialogId, getTopicId(), true))) { printingType = MessagesController.getInstance(currentAccount).getPrintingStringType(currentDialogId, getTopicId()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java index c955d8f3ecf..12e6752eeb1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java @@ -401,12 +401,13 @@ public void animateChange(ReactionsLayoutInBubble.VisibleReaction react) { public void setColor(int color) { this.color = color; final ColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY); + final ColorFilter colorFilterEmoji = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN); for (int i = 0; i < animations.size(); ++i) { Object animation = animations.get(i); if (animation instanceof ImageReceiver) { ((ImageReceiver) animation).setColorFilter(colorFilter); } else if (animation instanceof AnimatedEmojiEffect) { - ((AnimatedEmojiEffect) animation).animatedEmojiDrawable.setColorFilter(colorFilter); + ((AnimatedEmojiEffect) animation).animatedEmojiDrawable.setColorFilter(colorFilterEmoji); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java index 75afc21dc9e..3eb61f019ff 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java @@ -123,6 +123,7 @@ public void setTextColor(int color) { } public void setText(CharSequence text) { + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); textView.setText(text); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java index 818d17c00be..7b117e8a58e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java @@ -432,7 +432,8 @@ protected void onDraw(Canvas canvas) { } } if (needDivider) { - canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint); + int margin = currentType == 1 ? 49 : 21; + canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(margin), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(margin) : 0), getMeasuredHeight() - 1, Theme.dividerPaint); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java index 771cdd7bb2f..78b6f935f74 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java @@ -143,6 +143,7 @@ public void setSticker(TLRPC.Document document, SendMessagesHelper.ImportingStic currentEmoji = emoji; isPremiumSticker = MessageObject.isPremiumSticker(document); drawInParentView = false; + imageView.setColorFilter(null); if (isPremiumSticker) { premiumIconView.setColor(Theme.getColor(Theme.key_windowBackgroundWhite)); premiumIconView.setWaitingImage(); @@ -167,6 +168,9 @@ public void setSticker(TLRPC.Document document, SendMessagesHelper.ImportingStic TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90); SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(document, fromEmojiPanel ? Theme.key_emptyListPlaceholder : Theme.key_windowBackgroundGray, fromEmojiPanel ? 0.2f : 1.0f); String imageFilter = fromEmojiPanel ? "66_66_pcache_compress" : "66_66"; + if (MessageObject.isTextColorEmoji(document)) { + imageView.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + } if (MessageObject.canAutoplayAnimatedSticker(document)) { if (fromEmojiPanel) { drawInParentView = true; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java index 83099899d5d..13fb08876a3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java @@ -304,6 +304,7 @@ public void setStickersSet(TLRPC.TL_messages_stickerSet set, boolean divider, bo emojis = set.set.emojis; sideButtons.setVisibility(emojis ? View.VISIBLE : View.GONE); optionsButton.setVisibility(emojis ? View.GONE : View.VISIBLE); + imageView.setColorFilter(null); ArrayList documents = set.documents; if (documents != null && !documents.isEmpty()) { @@ -341,6 +342,9 @@ public void setStickersSet(TLRPC.TL_messages_stickerSet set, boolean divider, bo } else { imageView.setImage(ImageLocation.getForDocument(sticker), "50_50", imageLocation, null, 0, set); } + if (MessageObject.isTextColorEmoji(sticker)) { + imageView.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + } } else if (imageLocation != null && imageLocation.imageType == FileLoader.IMAGE_TYPE_LOTTIE) { imageView.setImage(imageLocation, "50_50", "tgs", svgThumb, set); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java index 28f9669daba..adb8dbba6e6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java @@ -51,6 +51,7 @@ public class TextCheckCell extends FrameLayout { private float lastTouchX; private ObjectAnimator animator; private boolean drawCheckRipple; + private int padding; private Theme.ResourcesProvider resourcesProvider; public static final Property ANIMATION_PROGRESS = new AnimationProperties.FloatProperty("animationProgress") { @@ -86,6 +87,8 @@ public TextCheckCell(Context context, int padding, boolean dialog, Theme.Resourc super(context); this.resourcesProvider = resourcesProvider; + this.padding = padding; + textView = new TextView(context); textView.setTextColor(Theme.getColor(dialog ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText, resourcesProvider)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); @@ -153,6 +156,19 @@ public void setTextAndCheck(String text, boolean checked, boolean divider) { setWillNotDraw(!divider); } + public void updateRTL() { + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); + removeView(textView); + addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 70 : padding, 0, LocaleController.isRTL ? padding : 70, 0)); + + valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + removeView(valueTextView); + addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : padding, 36, LocaleController.isRTL ? padding : 64, 0)); + + removeView(checkBox); + addView(checkBox, LayoutHelper.createFrame(37, 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0)); + } + public void setColors(String key, String switchKey, String switchKeyChecked, String switchThumb, String switchThumbChecked) { textView.setTextColor(Theme.getColor(key, resourcesProvider)); checkBox.setColors(switchKey, switchKeyChecked, switchThumb, switchThumbChecked); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java index 762f5ccf178..2f05f76e083 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java @@ -354,4 +354,20 @@ protected void onDetachedFromWindow() { ((AnimatedEmojiDrawable) valueBackupImageView.getImageReceiver().getDrawable()).removeView(this); } } + + public void updateRTL() { + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); + removeView(textView); + addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, 0, padding, 0)); + + valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); + removeView(valueTextView); + addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 0, padding, 0)); + + removeView(imageView); + addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 21, 0, 21, 0)); + + removeView(valueImageView); + addView(valueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, padding, 0, padding, 0)); + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java index 3a73a048b8f..9319f9ed601 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java @@ -1182,7 +1182,7 @@ private boolean createMenu(View v, float x, float y) { final ArrayList options = new ArrayList<>(); final ArrayList icons = new ArrayList<>(); - if (message.currentEvent != null && message.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionDeleteMessage && message.currentEvent.user_id == getMessagesController().telegramAntispamUserId) { + if (message.currentEvent != null && (message.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionDeleteMessage && message.currentEvent.user_id == getMessagesController().telegramAntispamUserId || message.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionToggleAntiSpam)) { if (v instanceof ChatActionCell) { SpannableString arrow = new SpannableString(">"); Drawable arrowDrawable = getContext().getResources().getDrawable(R.drawable.attach_arrow_right).mutate(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index f72d5df2e5a..9a8167464d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -4638,10 +4638,17 @@ private void processTouchEvent(MotionEvent e) { } slidingView = (ChatMessageCell) view; MessageObject message = slidingView.getMessageObject(); + boolean allowReplyOnOpenTopic = false; + if (message != null && ChatObject.isForum(currentChat)) { + TLRPC.TL_forumTopic topic = getMessagesController().getTopicsController().findTopic(currentChat.id, MessageObject.getTopicId(message.messageOwner, true)); + if (topic != null) { + allowReplyOnOpenTopic = !topic.closed || ChatObject.canManageTopic(currentAccount, currentChat, topic); + } + } if (chatMode != 0 || threadMessageObjects != null && threadMessageObjects.contains(message) || getMessageType(message) == 1 && (message.getDialogId() == mergeDialogId || message.needDrawBluredPreview()) || currentEncryptedChat == null && message.getId() < 0 || - bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE && !(bottomOverlayChatWaitsReply && message != null && (MessageObject.getTopicId(message.messageOwner, ChatObject.isForum(currentChat)) != 0 || message.wasJustSent)) || + bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE && !(bottomOverlayChatWaitsReply && allowReplyOnOpenTopic || message.wasJustSent) || currentChat != null && (ChatObject.isNotInChat(currentChat) && !isThreadChat() || ChatObject.isChannel(currentChat) && !ChatObject.canPost(currentChat) && !currentChat.megagroup || !ChatObject.canSendMessages(currentChat)) || textSelectionHelper.isSelectionMode()) { slidingView.setSlidingOffset(0); @@ -4879,46 +4886,6 @@ public void onDraw(Canvas c) { } } - private boolean isSkeletonVisible() { - if (justCreatedTopic || justCreatedChat || currentUser != null || !SharedConfig.animationsEnabled()) { - return false; - } - int childHeight = 0; - int maxTop = Integer.MAX_VALUE; - for (int i = 0; i < getChildCount(); i++) { - childHeight += getChildAt(i).getHeight(); - int top = getChildAt(i).getTop(); - if (top < maxTop) { - maxTop = top; - } - } - if (maxTop <= chatListViewPaddingTop) { - checkDispatchHideSkeletons(fragmentBeginToShow); - } - - boolean visible = (!endReached[0] || mergeDialogId != 0 && !endReached[1] || messages.isEmpty()) && loading && maxTop > chatListViewPaddingTop && (messages.isEmpty() ? animateProgressViewTo : childHeight != 0); - if (!visible && startMessageAppearTransitionMs == 0) { - checkDispatchHideSkeletons(fragmentBeginToShow); - } - if (SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW && !fromPullingDownTransition && !fragmentBeginToShow) { - Drawable wallpaper = themeDelegate.getWallpaperDrawable(); - if (fragmentView != null) { - wallpaper = ((SizeNotifierFrameLayout) fragmentView).getBackgroundImage(); - } - if (wallpaper instanceof MotionBackgroundDrawable) { - MotionBackgroundDrawable motion = (MotionBackgroundDrawable) wallpaper; - if (((MotionBackgroundDrawable) wallpaper).isIndeterminateAnimation() != visible) { - motion.setIndeterminateAnimation(visible); - motion.setIndeterminateSpeedScale(visible ? 1.5f : 1f); - motion.updateAnimation(true); - } else if (visible) { - motion.updateAnimation(false); - } - } - } - return visible || startMessageAppearTransitionMs != 0 && System.currentTimeMillis() - startMessageAppearTransitionMs <= SKELETON_DISAPPEAR_MS; - } - @Override public void draw(Canvas canvas) { if ((startMessageAppearTransitionMs == 0 || System.currentTimeMillis() - startMessageAppearTransitionMs <= SKELETON_DISAPPEAR_MS) && !AndroidUtilities.isTablet() && !isComments && currentUser == null) { @@ -14273,7 +14240,7 @@ public void updateTitle(boolean animated) { private void updateTopicTitleIcon() { if (forumTopic != null && avatarContainer != null) { avatarContainer.getAvatarImageView().setVisibility(View.VISIBLE); - ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, true, themeDelegate); + ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, true, true, themeDelegate); } } @@ -14823,6 +14790,47 @@ public void restoreSelfArgs(Bundle args) { currentPicturePath = args.getString("path"); } + private boolean isSkeletonVisible() { + if (justCreatedTopic || justCreatedChat || currentUser != null || !SharedConfig.animationsEnabled()) { + return false; + } + int childHeight = 0; + int maxTop = Integer.MAX_VALUE; + for (int i = 0; i < chatListView.getChildCount(); i++) { + childHeight += chatListView.getChildAt(i).getHeight(); + int top = chatListView.getChildAt(i).getTop(); + if (top < maxTop) { + maxTop = top; + } + } + if (maxTop <= chatListViewPaddingTop) { + checkDispatchHideSkeletons(fragmentBeginToShow); + } + + boolean visible = (!endReached[0] || mergeDialogId != 0 && !endReached[1] || messages.isEmpty()) && loading && maxTop > chatListViewPaddingTop && (messages.isEmpty() ? animateProgressViewTo : childHeight != 0); + if (!visible && startMessageAppearTransitionMs == 0) { + checkDispatchHideSkeletons(fragmentBeginToShow); + } + if (SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW && !fromPullingDownTransition && fragmentBeginToShow) { + boolean rotate = visible && startMessageAppearTransitionMs == 0; + Drawable wallpaper = themeDelegate.getWallpaperDrawable(); + if (fragmentView != null) { + wallpaper = ((SizeNotifierFrameLayout) fragmentView).getBackgroundImage(); + } + if (wallpaper instanceof MotionBackgroundDrawable) { + MotionBackgroundDrawable motion = (MotionBackgroundDrawable) wallpaper; + if (((MotionBackgroundDrawable) wallpaper).isIndeterminateAnimation() != rotate) { + motion.setIndeterminateAnimation(rotate); + motion.setIndeterminateSpeedScale(rotate ? 1.5f : 1f); + motion.updateAnimation(true); + } else if (rotate) { + motion.updateAnimation(false); + } + } + } + return visible || startMessageAppearTransitionMs != 0 && System.currentTimeMillis() - startMessageAppearTransitionMs <= SKELETON_DISAPPEAR_MS; + } + private void checkDispatchHideSkeletons(boolean animate) { if (startMessageAppearTransitionMs == 0) { if (animate && !messageSkeletons.isEmpty()) { @@ -14830,6 +14838,7 @@ private void checkDispatchHideSkeletons(boolean animate) { } else { startMessageAppearTransitionMs = 1; } + isSkeletonVisible(); if (chatListView != null) { chatListView.invalidate(); } @@ -18446,7 +18455,7 @@ private void processNewMessages(ArrayList arr) { int lastAdIndex = -1; for (int a = 0; a < arr.size(); a++) { MessageObject obj = arr.get(a); - if (obj.scheduled != (chatMode == MODE_SCHEDULED) || threadMessageId != 0 && threadMessageId != obj.getReplyTopMsgId() && threadMessageId != obj.getReplyMsgId()) { + if (obj.scheduled != (chatMode == MODE_SCHEDULED) || threadMessageId != 0 && (!ChatObject.isForum(currentChat) || threadMessageId != 1) && threadMessageId != obj.getReplyTopMsgId() && threadMessageId != obj.getReplyMsgId()) { continue; } if (obj.isOut()) { @@ -26965,7 +26974,7 @@ public void didPressTopicButton(ChatMessageCell cell) { @Override public boolean shouldShowTopicButton() { - return true; + return ChatObject.isForum(currentChat) && !isTopic; } @Override @@ -28216,96 +28225,112 @@ private boolean openLinkInternally(String urlFinal, int fromMessageId) { return true; } } else if (ChatObject.getPublicUsername(currentChat) != null) { - String username = ChatObject.getPublicUsername(currentChat).toLowerCase(); - if (publicMsgUrlPattern == null) { - publicMsgUrlPattern = Pattern.compile("(https://)?t.me/([0-9a-zA-Z_]+)/([0-9]+)"); - voiceChatUrlPattern = Pattern.compile("(https://)?t.me/([0-9a-zA-Z_]+)\\?(voicechat+)"); - } - Matcher matcher = publicMsgUrlPattern.matcher(urlFinal); - if (matcher.find(2) && matcher.find(3) && username.equals(matcher.group(2).toLowerCase())) { - Uri data = Uri.parse(urlFinal); - int threadId = Utilities.parseInt(data.getQueryParameter("thread")); - int commentId = Utilities.parseInt(data.getQueryParameter("comment")); - if (threadId != 0 || commentId != 0) { - return false; - } else { - int messageId = Integer.parseInt(matcher.group(3)); - showScrollToMessageError = true; - if (chatMode == MODE_PINNED) { - chatActivityDelegate.openReplyMessage(messageId); - finishFragment(); - } else { - startFromVideoTimestamp = LaunchActivity.getTimestampFromLink(data); - if (startFromVideoTimestamp >= 0) { - startFromVideoMessageId = messageId; - } - scrollToMessageId(messageId, fromMessageId, true, 0, false, 0); - } + try { + if (publicMsgUrlPattern == null) { + publicMsgUrlPattern = Pattern.compile("(https://)?t.me/([0-9a-zA-Z_]+)/([0-9]+)/?([0-9]+)?"); + voiceChatUrlPattern = Pattern.compile("(https://)?t.me/([0-9a-zA-Z_]+)\\?(voicechat+)"); } - return true; - } else if (urlFinal.startsWith("tg:resolve") || urlFinal.startsWith("tg://resolve")) { - String urlTmp = urlFinal.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve", "tg://telegram.org"); - Uri data = Uri.parse(urlTmp); - String usernameE = data.getQueryParameter("domain").toLowerCase(); - int messageId = Utilities.parseInt(data.getQueryParameter("post")); - int threadId = Utilities.parseInt(data.getQueryParameter("thread")); - int commentId = Utilities.parseInt(data.getQueryParameter("comment")); - if (username.equals(usernameE) && messageId != 0) { + Matcher matcher = publicMsgUrlPattern.matcher(urlFinal); + if (matcher.find(2) && matcher.find(3) && ChatObject.hasPublicLink(currentChat, matcher.group(2))) { + Uri data = Uri.parse(urlFinal); + int threadId = Utilities.parseInt(data.getQueryParameter("thread")); + int commentId = Utilities.parseInt(data.getQueryParameter("comment")); if (threadId != 0 || commentId != 0) { return false; } else { + int messageId, topicId; + if (matcher.group(4) != null) { + topicId = Integer.parseInt(matcher.group(3)); + messageId = Integer.parseInt(matcher.group(4)); + } else { + topicId = 0; + messageId = Integer.parseInt(matcher.group(3)); + } + if (ChatObject.isForum(currentChat) && topicId != getTopicId()) { + return false; + } + showScrollToMessageError = true; if (chatMode == MODE_PINNED) { chatActivityDelegate.openReplyMessage(messageId); finishFragment(); } else { + startFromVideoTimestamp = LaunchActivity.getTimestampFromLink(data); + if (startFromVideoTimestamp >= 0) { + startFromVideoMessageId = messageId; + } scrollToMessageId(messageId, fromMessageId, true, 0, false, 0); } - return true; } - } - } else { - matcher = voiceChatUrlPattern.matcher(urlFinal); - try { - if (matcher.find(2) && matcher.find(3) && username.equals(matcher.group(2).toLowerCase())) { - Uri data = Uri.parse(urlFinal); - String voicechat = data.getQueryParameter("voicechat"); - if (!TextUtils.isEmpty(voicechat)) { - voiceChatHash = voicechat; - checkGroupCallJoin(true); + return true; + } else if (urlFinal.startsWith("tg:resolve") || urlFinal.startsWith("tg://resolve")) { + String urlTmp = urlFinal.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve", "tg://telegram.org"); + Uri data = Uri.parse(urlTmp); + String usernameE = data.getQueryParameter("domain").toLowerCase(); + int messageId = Utilities.parseInt(data.getQueryParameter("post")); + int threadId = Utilities.parseInt(data.getQueryParameter("thread")); + int commentId = Utilities.parseInt(data.getQueryParameter("comment")); + if (ChatObject.hasPublicLink(currentChat, usernameE) && messageId != 0) { + if (threadId != 0 || commentId != 0) { + return false; + } else { + if (chatMode == MODE_PINNED) { + chatActivityDelegate.openReplyMessage(messageId); + finishFragment(); + } else { + scrollToMessageId(messageId, fromMessageId, true, 0, false, 0); + } return true; } } - } catch (Exception e) { - FileLog.e(e); + } else { + matcher = voiceChatUrlPattern.matcher(urlFinal); + try { + if (matcher.find(2) && matcher.find(3) && ChatObject.hasPublicLink(currentChat, matcher.group(2))) { + Uri data = Uri.parse(urlFinal); + String voicechat = data.getQueryParameter("voicechat"); + if (!TextUtils.isEmpty(voicechat)) { + voiceChatHash = voicechat; + checkGroupCallJoin(true); + return true; + } + } + } catch (Exception e) { + FileLog.e(e); + } } + } catch (Exception e) { + FileLog.e(e); } } else { - if (privateMsgUrlPattern == null) { - privateMsgUrlPattern = Pattern.compile("(https://)?t.me/c/([0-9]+)/([0-9]+)/?([0-9]+)?"); - } - - Matcher matcher = privateMsgUrlPattern.matcher(urlFinal); - if (matcher.find(2) && matcher.find(3) && !matcher.find(4)) { - long channelId = Long.parseLong(matcher.group(2)); - int messageId = Integer.parseInt(matcher.group(3)); - if (channelId == currentChat.id && messageId != 0) { - Uri data = Uri.parse(urlFinal); - int threadId = Utilities.parseInt(data.getQueryParameter("thread")); - int topicId = Utilities.parseInt(data.getQueryParameter("topic")); - int commentId = Utilities.parseInt(data.getQueryParameter("comment")); - if (threadId != 0 || topicId != 0 || commentId != 0) { - return false; - } else { - showScrollToMessageError = true; - if (chatMode == MODE_PINNED) { - chatActivityDelegate.openReplyMessage(messageId); - finishFragment(); + try { + if (privateMsgUrlPattern == null) { + privateMsgUrlPattern = Pattern.compile("(https://)?t.me/c/([0-9]+)/([0-9]+)/?([0-9]+)?"); + } + Matcher matcher = privateMsgUrlPattern.matcher(urlFinal); + if (matcher.find(2) && matcher.find(3) && matcher.group(4) == null) { + long channelId = Long.parseLong(matcher.group(2)); + int messageId = Integer.parseInt(matcher.group(3)); + if (channelId == currentChat.id && messageId != 0) { + Uri data = Uri.parse(urlFinal); + int threadId = Utilities.parseInt(data.getQueryParameter("thread")); + int topicId = Utilities.parseInt(data.getQueryParameter("topic")); + int commentId = Utilities.parseInt(data.getQueryParameter("comment")); + if (threadId != 0 || topicId != 0 || commentId != 0) { + return false; } else { - scrollToMessageId(messageId, fromMessageId, true, 0, false, 0); + showScrollToMessageError = true; + if (chatMode == MODE_PINNED) { + chatActivityDelegate.openReplyMessage(messageId); + finishFragment(); + } else { + scrollToMessageId(messageId, fromMessageId, true, 0, false, 0); + } + return true; } - return true; } } + } catch (Exception e) { + FileLog.e(e); } } return false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java index 52e05481a1a..74984526bec 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java @@ -573,7 +573,7 @@ public static AlertDialog.Builder createLanguageAlert(LaunchActivity activity, f localeInfo.pathToFile = "unofficial"; } } - LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, UserConfig.selectedAccount); + LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, UserConfig.selectedAccount, null); activity.rebuildAllFragments(true); }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiDrawable.java index ac097c8b1e3..9fd1fac3f86 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiDrawable.java @@ -645,9 +645,20 @@ public boolean canOverrideColor() { if (canOverrideColorCached != null) { return canOverrideColorCached; } + if (document != null) { + return canOverrideColorCached = (isDefaultStatusEmoji() || MessageObject.isTextColorEmoji(document)); + } + return false; + } + + private Boolean isDefaultStatusEmojiCached = null; + public boolean isDefaultStatusEmoji() { + if (isDefaultStatusEmojiCached != null) { + return isDefaultStatusEmojiCached; + } if (document != null) { TLRPC.InputStickerSet set = MessageObject.getInputStickerSet(document); - return canOverrideColorCached = ( + return isDefaultStatusEmojiCached = ( set instanceof TLRPC.TL_inputStickerSetEmojiDefaultStatuses || set instanceof TLRPC.TL_inputStickerSetID && (set.id == 773947703670341676L || set.id == 2964141614563343L) ); @@ -655,6 +666,17 @@ public boolean canOverrideColor() { return false; } + public static boolean isDefaultStatusEmoji(Drawable drawable) { + if (!(drawable instanceof AnimatedEmojiDrawable)) { + return false; + } + return isDefaultStatusEmoji((AnimatedEmojiDrawable) drawable); + } + + public static boolean isDefaultStatusEmoji(AnimatedEmojiDrawable drawable) { + return drawable != null && drawable.isDefaultStatusEmoji(); + } + @Override public int getAlpha() { return (int) (255 * this.alpha); @@ -672,7 +694,7 @@ public void setAlpha(int alpha) { @Override public void setColorFilter(@Nullable ColorFilter colorFilter) { - if (imageReceiver == null) { + if (imageReceiver == null || document == null) { colorFilterToSet = colorFilter; } else if (canOverrideColor()) { imageReceiver.setColorFilter(colorFilter); @@ -848,7 +870,7 @@ public void setColor(Integer color) { return; } lastColor = color; - colorFilter = color != null ? new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY) : null; + colorFilter = color != null ? new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN) : null; } public Integer getColor() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiSpan.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiSpan.java index f25350b5dca..c2622d880d3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiSpan.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedEmojiSpan.java @@ -23,6 +23,7 @@ import org.telegram.messenger.MessageObject; import org.telegram.messenger.UserConfig; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.spoilers.SpoilerEffect; import java.util.ArrayList; @@ -279,6 +280,7 @@ public void draw(Canvas canvas, long time, float boundTop, float boundBottom, fl } if (drawable.getImageReceiver() != null) { + drawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); drawable.setTime(time); drawable.draw(canvas, drawableBounds, alpha * this.alpha); // drawable.setTime(0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java index 5f151792498..580b6409964 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java @@ -1,6 +1,8 @@ package org.telegram.ui.Components; import android.content.Context; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.text.Spannable; import android.text.SpannableStringBuilder; @@ -257,6 +259,9 @@ public Bulletin createEmojiBulletin(String emoji, String text, String button, Ru public Bulletin createEmojiBulletin(TLRPC.Document document, CharSequence text, CharSequence button, Runnable onButtonClick) { final Bulletin.LottieLayout layout = new Bulletin.LottieLayout(getContext(), resourcesProvider); + if (MessageObject.isTextColorEmoji(document)) { + layout.imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_infoColor), PorterDuff.Mode.SRC_IN)); + } layout.setAnimation(document, 36, 36); layout.textView.setText(text); layout.textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); @@ -268,6 +273,9 @@ public Bulletin createEmojiBulletin(TLRPC.Document document, CharSequence text, public Bulletin createEmojiLoadingBulletin(TLRPC.Document document, CharSequence text, CharSequence button, Runnable onButtonClick) { final Bulletin.LoadingLottieLayout layout = new Bulletin.LoadingLottieLayout(getContext(), resourcesProvider); + if (MessageObject.isTextColorEmoji(document)) { + layout.imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_infoColor), PorterDuff.Mode.SRC_IN)); + } layout.setAnimation(document, 36, 36); layout.textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); layout.textView.setSingleLine(false); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java index a0d1b1a1df9..7fc20702740 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java @@ -868,7 +868,6 @@ public void setChatAvatar(TLRPC.Chat chat) { avatarImageView.setForUserOrChat(chat, avatarDrawable); avatarImageView.setRoundRadius(chat != null && chat.forum ? AndroidUtilities.dp(16) : AndroidUtilities.dp(21)); } - } public void setUserAvatar(TLRPC.User user) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java index d899b47ce67..a1484244ec2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java @@ -201,7 +201,7 @@ protected void dispatchDraw(Canvas canvas) { if (drawable == null) { animatedEmojiDrawables.put(documentId, drawable = AnimatedEmojiDrawable.make(currentAccount, AnimatedEmojiDrawable.CACHE_TYPE_ALERT_PREVIEW, documentId)); } - drawable.setColorFilter(colorFilter); + drawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); drawable.addView(this); ArrayList arrayList = viewsGroupedByLines.get(child.getTop()); if (arrayList == null) { @@ -317,7 +317,8 @@ public void prepareDraw(long time) { drawable.setAlpha(255); AndroidUtilities.rectTmp2.set(imageView.getLeft() + imageView.getPaddingLeft(), imageView.getPaddingTop(), imageView.getRight() - imageView.getPaddingRight(), imageView.getMeasuredHeight() - imageView.getPaddingBottom()); imageView.backgroundThreadDrawHolder[threadIndex].setBounds(AndroidUtilities.rectTmp2); - imageView.imageReceiver = drawable.getImageReceiver(); + drawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + imageView.imageReceiver = drawable.getImageReceiver();; drawInBackgroundViews.add(imageView); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java index b45dc416cef..8d69c5e12ec 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java @@ -6,6 +6,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; @@ -22,6 +23,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; +import androidx.annotation.Nullable; import androidx.core.graphics.ColorUtils; import androidx.core.math.MathUtils; @@ -616,6 +618,10 @@ public void select(int index, boolean animated) { } } + protected ColorFilter getEmojiColorFilter() { + return Theme.chat_animatedEmojiTextColorFilter; + } + private int selectorColor() { return 0x2effffff & Theme.getColor(Theme.key_chat_emojiPanelIcon, resourcesProvider); } @@ -629,6 +635,7 @@ public class EmojiTabButton extends ViewGroup { public Integer id; public boolean newly; + private boolean isAnimatedEmoji; private ImageView imageView; private RLottieDrawable lottieDrawable; @@ -712,8 +719,17 @@ protected void dispatchDraw(Canvas canvas) { } } } + + @Override + public void setImageDrawable(@Nullable Drawable drawable) { + super.setImageDrawable(drawable); + } }; imageView.setImageDrawable(drawable); + if (drawable instanceof AnimatedEmojiDrawable) { + isAnimatedEmoji = true; + imageView.setColorFilter(getEmojiColorFilter()); + } addView(imageView); lockView = new PremiumLockIconView(context, PremiumLockIconView.TYPE_STICKERS_PREMIUM_LOCKED, resourcesProvider); @@ -914,7 +930,7 @@ public void updateColor() { private void setColor(int color) { PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY); - if (imageView != null) { + if (imageView != null && !isAnimatedEmoji) { imageView.setColorFilter(colorFilter); imageView.invalidate(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java index df76b4c1bee..69bc5436b32 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java @@ -2836,6 +2836,7 @@ public void prepareDraw(long time) { AndroidUtilities.rectTmp2.set(imageView.getLeft() + imageView.getPaddingLeft() - startOffset, topOffset, imageView.getRight() - imageView.getPaddingRight() - startOffset, topOffset + imageView.getMeasuredHeight() - imageView.getPaddingTop() - imageView.getPaddingBottom()); imageView.backgroundThreadDrawHolder[threadIndex].setBounds(AndroidUtilities.rectTmp2); imageView.drawable = drawable; + imageView.drawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); imageView.imageReceiver = drawable.getImageReceiver(); drawInBackgroundViews.add(imageView); } @@ -5086,7 +5087,6 @@ public void updateColors() { bottomTabContainerBackground.setBackgroundColor(getThemedColor(Theme.key_chat_emojiPanelBackground)); } } - if (emojiTabs != null) { emojiTabs.setBackgroundColor(getThemedColor(Theme.key_chat_emojiPanelBackground)); emojiTabsShadow.setBackgroundColor(getThemedColor(Theme.key_chat_emojiPanelShadowLine)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/ForumUtilities.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/ForumUtilities.java index 7228a09f006..94475ecfef4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/ForumUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/ForumUtilities.java @@ -48,9 +48,9 @@ public class ForumUtilities { public static void setTopicIcon(BackupImageView backupImageView, TLRPC.TL_forumTopic forumTopic) { - setTopicIcon(backupImageView, forumTopic, false, null); + setTopicIcon(backupImageView, forumTopic, false, false, null); } - public static void setTopicIcon(BackupImageView backupImageView, TLRPC.TL_forumTopic forumTopic, boolean largeIcon, Theme.ResourcesProvider resourcesProvider) { + public static void setTopicIcon(BackupImageView backupImageView, TLRPC.TL_forumTopic forumTopic, boolean actionBar, boolean largeIcon, Theme.ResourcesProvider resourcesProvider) { if (forumTopic == null || backupImageView == null) { return; } @@ -60,7 +60,9 @@ public static void setTopicIcon(BackupImageView backupImageView, TLRPC.TL_forumT } else if (forumTopic.icon_emoji_id != 0) { backupImageView.setImageDrawable(null); if (backupImageView.animatedEmojiDrawable == null || forumTopic.icon_emoji_id != backupImageView.animatedEmojiDrawable.getDocumentId()) { - backupImageView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(largeIcon ? AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC_LARGE : AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC, UserConfig.selectedAccount, forumTopic.icon_emoji_id)); + AnimatedEmojiDrawable drawable = new AnimatedEmojiDrawable(largeIcon ? AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC_LARGE : AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC, UserConfig.selectedAccount, forumTopic.icon_emoji_id); + drawable.setColorFilter(actionBar ? new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultTitle), PorterDuff.Mode.SRC_IN) : Theme.chat_animatedEmojiTextColorFilter); + backupImageView.setAnimatedEmojiDrawable(drawable); } } else { backupImageView.setAnimatedEmojiDrawable(null); @@ -256,6 +258,9 @@ public static CharSequence getTopicSpannedName(TLRPC.ForumTopic topic, Paint pai } public static void applyTopic(ChatActivity chatActivity, MessagesStorage.TopicKey topicKey) { + if (topicKey.topicId == 0) { + return; + } TLRPC.TL_forumTopic topic = chatActivity.getMessagesController().getTopicsController().findTopic(-topicKey.dialogId, topicKey.topicId); if (topic == null) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/MessageTopicButton.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/MessageTopicButton.java index ff22c012c91..1f1b70cba45 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/MessageTopicButton.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Forum/MessageTopicButton.java @@ -16,6 +16,7 @@ import android.text.TextUtils; import android.view.MotionEvent; +import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; import org.telegram.messenger.AndroidUtilities; @@ -40,6 +41,8 @@ public class MessageTopicButton { private int topicWidth; private int topicHeight; + private boolean topicClosed; + private Drawable topicClosedDrawable; private Paint topicPaint; private boolean isGeneralTopic; private Path topicPath; @@ -73,9 +76,9 @@ public MessageTopicButton(Context context, Theme.ResourcesProvider resourcesProv protected void onClick() {} - public int set(ChatMessageCell cell, MessageObject messageObject, TLRPC.TL_forumTopic topic, int maxWidth) { + public int set(ChatMessageCell cell, MessageObject messageObject, @NonNull TLRPC.TL_forumTopic topic, int maxWidth) { lastMessageObject = messageObject; - isGeneralTopic = topic == null || topic.id == 1; + isGeneralTopic = topic.id == 1; if (cell == null || messageObject == null) { return 0; } @@ -87,6 +90,10 @@ public int set(ChatMessageCell cell, MessageObject messageObject, TLRPC.TL_forum maxWidth -= padleft + padright; String title = topic.title == null ? "" : topic.title; + topicClosed = topic.closed; + if (topicClosed) { + maxWidth -= AndroidUtilities.dp(18); + } topicNameLayout = StaticLayoutEx.createStaticLayout(title, 0, title.length(), Theme.chat_topicTextPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0, false, TextUtils.TruncateAt.END, maxWidth, 2, false); topicHeight = AndroidUtilities.dp(4 + 4.5f) + Math.min(AndroidUtilities.dp(24), topicNameLayout == null ? 0 : topicNameLayout.getHeight()); float textWidth = 0; @@ -131,17 +138,25 @@ public int set(ChatMessageCell cell, MessageObject messageObject, TLRPC.TL_forum topicBackgroundColorAnimated = new AnimatedColor(cell); } } - if (topicArrowDrawable == null && context != null) { + if (topicArrowDrawable == null) { topicArrowDrawable = context.getResources().getDrawable(R.drawable.msg_mini_topicarrow).mutate(); } topicArrowDrawable.setColorFilter(new PorterDuffColorFilter(topicArrowColor = ColorUtils.setAlphaComponent(topicNameColor, 140), PorterDuff.Mode.MULTIPLY)); + if (topicClosedDrawable == null) { + topicClosedDrawable = context.getResources().getDrawable(R.drawable.msg_mini_lock2).mutate(); + } + topicClosedDrawable.setColorFilter(new PorterDuffColorFilter(topicArrowColor = ColorUtils.setAlphaComponent(topicNameColor, 140), PorterDuff.Mode.MULTIPLY)); float R = (AndroidUtilities.dp(11) + (int) Theme.chat_topicTextPaint.getTextSize()); int arrowsz = Math.max(1, (int) Theme.chat_topicTextPaint.getTextSize() + AndroidUtilities.dp(0)); + int locksz = Math.max(1, (int) Theme.chat_topicTextPaint.getTextSize() - AndroidUtilities.dp(4)); if (lineCount == 2) { topicHeight = AndroidUtilities.dp(15) + 2 * ((int) Theme.chat_topicTextPaint.getTextSize()); float l1w = Math.abs(topicNameLayout.getLineRight(0) - topicNameLayout.getLineLeft(0)); float l2w = Math.abs(topicNameLayout.getLineRight(1) - topicNameLayout.getLineLeft(1)); + if (topicClosed) { + l2w += AndroidUtilities.dp(4) + locksz; + } topicNameLeft = Math.min(topicNameLayout.getLineLeft(0), topicNameLayout.getLineLeft(1)); boolean isRTL = topicNameLeft != 0; textWidth = Math.max(l1w, l2w); @@ -179,6 +194,12 @@ public int set(ChatMessageCell cell, MessageObject messageObject, TLRPC.TL_forum (int) (padleft + padright + AndroidUtilities.dp(-4) + l2w), (int) ((topicHeight - AndroidUtilities.dp(11) - Theme.chat_topicTextPaint.getTextSize() + topicHeight) / 2f + arrowsz / 2) ); + topicClosedDrawable.setBounds( + (int) (padleft + padright + AndroidUtilities.dp(-4) - arrowsz + l2w - locksz), + (int) ((topicHeight - AndroidUtilities.dp(11) - Theme.chat_topicTextPaint.getTextSize() + topicHeight) / 2f - locksz / 2), + (int) (padleft + padright + AndroidUtilities.dp(-4) - arrowsz + l2w), + (int) ((topicHeight - AndroidUtilities.dp(11) - Theme.chat_topicTextPaint.getTextSize() + topicHeight) / 2f + locksz / 2) + ); AndroidUtilities.rectTmp.set(padleft + padright + l2w - r, topicHeight - r, padleft + padright + l2w, topicHeight); topicPath.arcTo(AndroidUtilities.rectTmp, 0, 90); AndroidUtilities.rectTmp.set(0, topicHeight - R, R, topicHeight); @@ -187,6 +208,9 @@ public int set(ChatMessageCell cell, MessageObject messageObject, TLRPC.TL_forum } else if (lineCount == 1) { topicHeight = AndroidUtilities.dp(11) + (int) Theme.chat_topicTextPaint.getTextSize(); textWidth = Math.abs(topicNameLayout.getLineRight(0) - topicNameLayout.getLineLeft(0)); + if (topicClosed) { + textWidth += AndroidUtilities.dp(4) + locksz; + } topicNameLeft = topicNameLayout.getLineLeft(0); AndroidUtilities.rectTmp.set(0, 0, padleft + padright + textWidth, topicHeight); topicArrowDrawableVisible = true; @@ -196,22 +220,37 @@ public int set(ChatMessageCell cell, MessageObject messageObject, TLRPC.TL_forum (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth), (int) (topicHeight / 2f + arrowsz / 2) ); + topicClosedDrawable.setBounds( + (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - arrowsz - locksz), + (int) (topicHeight / 2f - locksz / 2), + (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - arrowsz), + (int) (topicHeight / 2f + locksz / 2) + ); topicPath.addRoundRect(AndroidUtilities.rectTmp, R, R, Path.Direction.CW); } else if (lineCount == 0) { topicHeight = AndroidUtilities.dp(11) + (int) Theme.chat_topicTextPaint.getTextSize(); textWidth = 0; + if (topicClosed) { + textWidth += AndroidUtilities.dp(4) + locksz; + } topicNameLeft = 0; topicArrowDrawableVisible = true; topicArrowDrawable.setBounds( - (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - arrowsz), + (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - locksz), (int) (topicHeight / 2f - arrowsz / 2), (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth), (int) (topicHeight / 2f + arrowsz / 2) ); + topicClosedDrawable.setBounds( + (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - arrowsz - locksz), + (int) (topicHeight / 2f - locksz / 2), + (int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - arrowsz), + (int) (topicHeight / 2f + locksz / 2) + ); AndroidUtilities.rectTmp.set(0, 0, padleft + padright + textWidth, topicHeight); topicPath.addRoundRect(AndroidUtilities.rectTmp, R, R, Path.Direction.CW); } - topicWidth = (int) (padleft + padright -AndroidUtilities.dp(1) + textWidth); + topicWidth = (int) (padleft + padright - AndroidUtilities.dp(1) + textWidth); int occupingHeight = 0; if (!messageObject.isAnyKindOfSticker() && messageObject.type != MessageObject.TYPE_ROUND_VIDEO || messageObject.type == MessageObject.TYPE_EMOJIS) { occupingHeight += AndroidUtilities.dp(6) + topicHeight; @@ -413,10 +452,17 @@ public void draw(Canvas canvas, float x, float y, float alpha) { } else { Theme.chat_topicTextPaint.setColor(nameColor = topicNameColor); } - Theme.chat_topicTextPaint.setAlpha((int) (Theme.chat_topicTextPaint.getAlpha() * alpha)); + Theme.chat_topicTextPaint.setAlpha((int) (Theme.chat_topicTextPaint.getAlpha() * alpha * (topicClosed ? .7f : 1f))); topicNameLayout.draw(canvas); canvas.restore(); } + if (topicClosedDrawable != null && topicClosed) { + int arrowColor = ColorUtils.setAlphaComponent(nameColor, 140); + if (topicArrowColor != arrowColor) { + topicClosedDrawable.setColorFilter(new PorterDuffColorFilter(topicArrowColor = arrowColor, PorterDuff.Mode.MULTIPLY)); + } + topicClosedDrawable.draw(canvas); + } if (topicArrowDrawable != null && topicArrowDrawableVisible) { int arrowColor = ColorUtils.setAlphaComponent(nameColor, 140); if (topicArrowColor != arrowColor) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/MessageContainsEmojiButton.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/MessageContainsEmojiButton.java index 2f01858be6d..8ddb6589784 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/MessageContainsEmojiButton.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/MessageContainsEmojiButton.java @@ -131,6 +131,7 @@ public void draw(@NonNull Canvas canvas, CharSequence charSequence, int start, i } }, 0, emoji.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); emojiDrawable = AnimatedEmojiDrawable.make(currentAccount, AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, document); + emojiDrawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); emojiDrawable.addView(this); SpannableString stickerPack = new SpannableString(stickerPackName); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java index e4878ee29e3..bd0d8697147 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java @@ -433,7 +433,9 @@ void setUserReaction(TLRPC.MessagePeerReaction reaction) { reactView.setImageDrawable(null); } } else { - reactView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, currentAccount, visibleReaction.documentId)); + AnimatedEmojiDrawable drawable = new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, currentAccount, visibleReaction.documentId); + drawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + reactView.setAnimatedEmojiDrawable(drawable); hasReactImage = true; } setContentDescription(LocaleController.formatString("AccDescrReactedWith", R.string.AccDescrReactedWith, UserObject.getUserName(u), reaction.reaction)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsEffectOverlay.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsEffectOverlay.java index 99f1460961a..9d03036ab89 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsEffectOverlay.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsEffectOverlay.java @@ -4,6 +4,8 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.PixelFormat; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.view.HapticFeedbackConstants; import android.view.View; import android.view.ViewGroup; @@ -18,6 +20,7 @@ import org.telegram.messenger.MessagesController; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Cells.ChatMessageCell; import org.telegram.ui.ChatActivity; import org.telegram.ui.Components.AnimatedEmojiDrawable; @@ -546,8 +549,16 @@ protected void onDetachedFromWindow() { emojiImageView.setAnimatedReactionDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_KEYBOARD, currentAccount, visibleReaction.documentId)); } if (animationType == LONG_ANIMATION || animationType == SHORT_ANIMATION) { - effectImageView.setAnimatedEmojiEffect(AnimatedEmojiEffect.createFrom(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_KEYBOARD, currentAccount, visibleReaction.documentId), animationType == LONG_ANIMATION, true)); - windowView.setClipChildren(false); + AnimatedEmojiDrawable animatedEmojiDrawable = new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_KEYBOARD, currentAccount, visibleReaction.documentId); + int color = Theme.getColor( + cell.getMessageObject().shouldDrawWithoutBackground() ? + cell.getMessageObject().isOutOwner() ? Theme.key_chat_outReactionButtonBackground : Theme.key_chat_inReactionButtonBackground : + cell.getMessageObject().isOutOwner() ? Theme.key_chat_outReactionButtonTextSelected : Theme.key_chat_inReactionButtonTextSelected, + fragment.getResourceProvider() + ); + animatedEmojiDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); + effectImageView.setAnimatedEmojiEffect(AnimatedEmojiEffect.createFrom(animatedEmojiDrawable, animationType == LONG_ANIMATION, true)); + windowView.setClipChildren(false); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java index 1963c321352..c6af97580a7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java @@ -3,6 +3,8 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.text.TextPaint; import android.text.TextUtils; @@ -483,6 +485,7 @@ public class ReactionButton { public int height; ImageReceiver imageReceiver = new ImageReceiver(); AnimatedEmojiDrawable animatedEmojiDrawable; + int animatedEmojiDrawableColor; CounterView.CounterDrawable counterDrawable = new CounterView.CounterDrawable(parentView, false, null); int backgroundColor; int textColor; @@ -643,6 +646,9 @@ private void updateColors(float progress) { private void drawImage(Canvas canvas, float alpha) { ImageReceiver imageReceiver = animatedEmojiDrawable != null ? animatedEmojiDrawable.getImageReceiver() : this.imageReceiver; + if (animatedEmojiDrawable != null && animatedEmojiDrawableColor != lastDrawnTextColor) { + animatedEmojiDrawable.setColorFilter(new PorterDuffColorFilter(animatedEmojiDrawableColor = lastDrawnTextColor, PorterDuff.Mode.SRC_IN)); + } if (drawImage && ((realCount > 1 || !ReactionsEffectOverlay.isPlaying(messageObject.getId(), messageObject.getGroupId(), visibleReaction)) || !isSelected)) { ImageReceiver imageReceiver2 = animatedReactions.get(visibleReaction); boolean drawStaticImage = true; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java index 852481f5b22..c55725d3ff0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java @@ -1258,8 +1258,12 @@ private void setReaction(ReactionsLayoutInBubble.VisibleReaction react, int posi } else { pressedBackupImageView.getImageReceiver().clearImage(); loopImageView.getImageReceiver().clearImage(); - pressedBackupImageView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_ALERT_PREVIEW_LARGE, currentAccount, currentReaction.documentId)); - loopImageView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_ALERT_PREVIEW, currentAccount, currentReaction.documentId)); + AnimatedEmojiDrawable pressedDrawable = new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_ALERT_PREVIEW_LARGE, currentAccount, currentReaction.documentId); + pressedDrawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + pressedBackupImageView.setAnimatedEmojiDrawable(pressedDrawable); + AnimatedEmojiDrawable loopDrawable = new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_ALERT_PREVIEW, currentAccount, currentReaction.documentId); + loopDrawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + loopImageView.setAnimatedEmojiDrawable(loopDrawable); } setFocusable(true); shouldSwitchToLoopView = hasEnterAnimation && showCustomEmojiReaction(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java index 874b3443cac..f0e97538536 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java @@ -1459,8 +1459,41 @@ protected void drawSectionBackground(Canvas canvas, int fromAdapterPosition, int } int position = getChildAdapterPosition(child); if (position >= fromAdapterPosition && position <= toAdapterPosition) { - top = Math.min(child.getTop(), top); - bottom = Math.max(child.getBottom(), bottom); + top = Math.min((int) child.getY(), top); + bottom = Math.max((int) child.getY() + child.getHeight(), bottom); + } + } + + if (top < bottom) { + if (backgroundPaint == null) { + backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + } + backgroundPaint.setColor(color); + canvas.drawRect(0, top, getWidth(), bottom, backgroundPaint); + } + } + + protected void drawItemBackground(Canvas canvas, int adapterPosition, int color) { + drawItemBackground(canvas, adapterPosition, -1, color); + } + + protected void drawItemBackground(Canvas canvas, int adapterPosition, int height, int color) { + int top = Integer.MAX_VALUE; + int bottom = Integer.MIN_VALUE; + + for (int i = 0; i < getChildCount(); ++i) { + View child = getChildAt(i); + if (child == null) { + continue; + } + int position = getChildAdapterPosition(child); + if (position == adapterPosition) { + top = (int) child.getY(); + if (height <= 0) { + bottom = top + child.getHeight(); + } else { + bottom = top + height; + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java index 612cedeb3a2..9d0aeab9bd7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java @@ -3245,6 +3245,7 @@ public void onActionBarItemClick(View v, int id) { Bundle args = new Bundle(); args.putBoolean("onlySelect", true); + args.putBoolean("canSelectTopics", true); args.putInt("dialogsType", 3); DialogsActivity fragment = new DialogsActivity(args); fragment.setDelegate((fragment1, dids, message, param) -> { @@ -3306,6 +3307,7 @@ public void onActionBarItemClick(View v, int id) { profileActivity.getNotificationCenter().postNotificationName(NotificationCenter.closeChats); ChatActivity chatActivity = new ChatActivity(args1); + ForumUtilities.applyTopic(chatActivity, dids.get(0)); fragment1.presentFragment(chatActivity, true); chatActivity.showFieldPanelForForward(true, fmessages); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierFrameLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierFrameLayout.java index 209a0093dac..a442d83eb97 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierFrameLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierFrameLayout.java @@ -694,6 +694,10 @@ protected void onDetachedFromWindow() { blurIsRunning = false; } + public boolean blurWasDrawn() { + return SharedConfig.chatBlurEnabled() && currentBitmap != null; + } + public void drawBlurRect(Canvas canvas, float y, Rect rectTmp, Paint blurScrimPaint, boolean top) { int blurAlpha = Color.alpha(Theme.getColor(Theme.key_chat_BlurAlpha)); if (currentBitmap == null || !SharedConfig.chatBlurEnabled()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java index ba256842dc0..eb70c01eb83 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java @@ -14,12 +14,15 @@ import android.text.style.MetricAffectingSpan; import org.telegram.messenger.AndroidUtilities; +import org.telegram.ui.ActionBar.Theme; public class TypefaceSpan extends MetricAffectingSpan { private Typeface typeface; private int textSize; private int color; + private String colorKey; + Theme.ResourcesProvider resourcesProvider; public TypefaceSpan(Typeface tf) { typeface = tf; @@ -38,6 +41,16 @@ public TypefaceSpan(Typeface tf, int size, int textColor) { color = textColor; } + public TypefaceSpan(Typeface tf, int size, String colorKey, Theme.ResourcesProvider resourcesProvider) { + typeface = tf; + if (size > 0) { + textSize = size; + } + this.resourcesProvider = resourcesProvider; + this.colorKey = colorKey; + color = Theme.getColor(colorKey, resourcesProvider); + } + public Typeface getTypeface() { return typeface; } @@ -71,6 +84,9 @@ public void updateMeasureState(TextPaint p) { @Override public void updateDrawState(TextPaint tp) { + if (colorKey != null) { + color = Theme.getColor(colorKey, resourcesProvider); + } if (typeface != null) { tp.setTypeface(typeface); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index d84e64188cb..4b920885086 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -271,11 +271,6 @@ public void updateList(boolean animated) { AndroidUtilities.runOnUIThread(updateListRunnable, 36); } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - } } private ViewPagerFixed.TabsView searchTabsView; @@ -1642,7 +1637,7 @@ protected void onMeasure(int widthSpec, int heightSpec) { } int pos = parentPage.layoutManager.findFirstVisibleItemPosition(); - if (pos != RecyclerView.NO_POSITION && !dialogsListFrozen && parentPage.itemTouchhelper.isIdle()) { + if (pos != RecyclerView.NO_POSITION && parentPage.itemTouchhelper.isIdle()) { RecyclerView.ViewHolder holder = parentPage.listView.findViewHolderForAdapterPosition(pos); if (holder != null) { int top = holder.itemView.getTop(); @@ -1731,7 +1726,7 @@ private void updatePullState() { @Override public boolean onTouchEvent(MotionEvent e) { - if (fastScrollAnimationRunning || waitingForScrollFinished || parentPage.dialogsItemAnimator.isRunning() || rightFragmentTransitionInProgress) { + if (fastScrollAnimationRunning || waitingForScrollFinished || rightFragmentTransitionInProgress) { return false; } int action = e.getAction(); @@ -1995,8 +1990,10 @@ public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, } int fromIndex = source.getAdapterPosition(); int toIndex = target.getAdapterPosition(); - parentPage.listView.setItemAnimator(parentPage.dialogsItemAnimator); - parentPage.dialogsAdapter.notifyItemMoved(fromIndex, toIndex); + if (parentPage.listView.getItemAnimator() == null) { + parentPage.listView.setItemAnimator(parentPage.dialogsItemAnimator); + } + parentPage.dialogsAdapter.moveDialogs(parentPage.listView, fromIndex, toIndex); if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) { MessagesController.DialogFilter filter = getMessagesController().selectedDialogFilter[viewPages[0].dialogsType == 8 ? 1 : 0]; @@ -5036,7 +5033,9 @@ private void switchToCurrentSelectedMode(boolean animated) { } int a = animated ? 1 : 0; RecyclerView.Adapter currentAdapter = viewPages[a].listView.getAdapter(); - + if (viewPages[a].selectedType < 0 || viewPages[a].selectedType >= getMessagesController().dialogFilters.size()) { + return; + } MessagesController.DialogFilter filter = getMessagesController().dialogFilters.get(viewPages[a].selectedType); if (filter.isDefault()) { viewPages[a].dialogsType = 0; @@ -5177,7 +5176,7 @@ private void updateFilterTabs(boolean force, boolean animated) { private void updateDrawerSwipeEnabled() { if (parentLayout != null && parentLayout.getDrawerLayoutContainer() != null) { - parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(isFirstTab && !searchIsShowed && SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS && (rightSlidingDialogContainer == null || !rightSlidingDialogContainer.hasFragment())); + parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(((isFirstTab && SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS) || SharedConfig.getChatSwipeAction(currentAccount) != SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS) && !searchIsShowed && (rightSlidingDialogContainer == null || !rightSlidingDialogContainer.hasFragment())); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java index c073cf3f389..1f64befc40b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java @@ -15,12 +15,15 @@ import android.view.ViewGroup; import android.widget.FrameLayout; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ChatObject; +import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; @@ -39,9 +42,6 @@ import java.util.ArrayList; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - public class GroupInviteActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { private ListAdapter listAdapter; @@ -86,6 +86,7 @@ public boolean onFragmentCreate() { @Override public void onFragmentDestroy() { + super.onFragmentDestroy(); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.chatInfoDidLoad); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java index 4b8d27dc603..d4940e41b8f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -15,6 +15,8 @@ import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.graphics.Canvas; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; @@ -22,6 +24,7 @@ import android.widget.LinearLayout; import android.widget.TextView; +import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -33,6 +36,7 @@ import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.Utilities; +import org.telegram.tgnet.ConnectionsManager; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; @@ -73,6 +77,9 @@ public class LanguageSelectActivity extends BaseFragment implements Notification private ArrayList sortedLanguages; private ArrayList unofficialLanguages; + private ActionBarMenuItem searchItem; + private int translateSettingsBackgroundHeight; + @Override public boolean onFragmentCreate() { fillLanguages(); @@ -106,7 +113,7 @@ public void onItemClick(int id) { }); ActionBarMenu menu = actionBar.createMenu(); - ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { + searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { searching = true; @@ -142,7 +149,7 @@ public void onTextChanged(EditText editText) { } } }); - item.setSearchFieldHint(LocaleController.getString("Search", R.string.Search)); + searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search)); listAdapter = new ListAdapter(context, false); searchListViewAdapter = new ListAdapter(context, true); @@ -157,11 +164,32 @@ public void onTextChanged(EditText editText) { emptyView.setShowAtCenter(true); frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); - listView = new RecyclerListView(context); + listView = new RecyclerListView(context) { + @Override + protected void dispatchDraw(Canvas canvas) { + if (getAdapter() == listAdapter && getItemAnimator() != null && getItemAnimator().isRunning()) { + int backgroundColor = Theme.getColor(Theme.key_windowBackgroundWhite, resourcesProvider); + drawItemBackground(canvas, 0, translateSettingsBackgroundHeight, backgroundColor); +// drawItemBackground(canvas, 1, Theme.getColor(Theme.key_windowBackgroundWhite, resourcesProvider)); + drawSectionBackground(canvas, 1, 2, backgroundColor); + } + super.dispatchDraw(canvas); + } + }; listView.setEmptyView(emptyView); listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); listView.setVerticalScrollBarEnabled(false); listView.setAdapter(listAdapter); + DefaultItemAnimator itemAnimator = new DefaultItemAnimator() { + @Override + protected void onMoveAnimationUpdate(RecyclerView.ViewHolder holder) { + listView.invalidate(); + listView.updateSelector(); + } + }; + itemAnimator.setDurations(400); + itemAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT); + listView.setItemAnimator(itemAnimator); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); listView.setOnItemClickListener((view, position) -> { @@ -186,8 +214,21 @@ public void onTextChanged(EditText editText) { } if (localeInfo != null) { LocaleController.LocaleInfo prevLocale = LocaleController.getInstance().getCurrentLocaleInfo(); - LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, currentAccount); - parentLayout.rebuildAllFragmentViews(false, false); + boolean sameLang = prevLocale == localeInfo; + + final AlertDialog progressDialog = new AlertDialog(getContext(), 3); + int reqId = LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, currentAccount, () -> { + progressDialog.dismiss(); + if (!sameLang) { + actionBar.closeSearchField(); + updateLanguage(); + } + }); + if (reqId != 0) { + progressDialog.setOnCancelListener(di -> { + ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true); + }); + } String langCode = localeInfo.pluralLangCode, prevLangCode = prevLocale.pluralLangCode; @@ -202,7 +243,9 @@ public void onTextChanged(EditText editText) { } preferences.edit().putStringSet("translate_button_restricted_languages", newSelectedLanguages).apply(); - finishFragment(); + if (!sameLang) { + progressDialog.showDelayed(500); + } } } catch (Exception e) { FileLog.e(e); @@ -359,6 +402,22 @@ public void search(final String query) { } } + private void updateLanguage() { + if (actionBar != null) { + actionBar.setTitleAnimated(LocaleController.getString("Language", R.string.Language), true, 350, CubicBezierInterpolator.EASE_OUT_QUINT); + } + if (listView != null) { + for (int i = 0; i < listView.getChildCount(); ++i) { + View child = listView.getChildAt(i); + if (child instanceof TranslateSettings || child instanceof HeaderCell) { + listAdapter.notifyItemChanged(listView.getChildAdapterPosition(child)); + } else { + listAdapter.onBindViewHolder(listView.getChildViewHolder(child), listView.getChildAdapterPosition(child)); + } + } + } + } + private void processSearch(final String query) { Utilities.searchQueue.postRunnable(() -> { @@ -478,6 +537,21 @@ public TranslateSettings(Context context) { update(); } + public void updateTranslations() { + header.setText(LocaleController.getString("TranslateMessages", R.string.TranslateMessages)); + showButtonCheck.setTextAndCheck( + LocaleController.getString("ShowTranslateButton", R.string.ShowTranslateButton), getValue(), getValue() + ); + showButtonCheck.updateRTL(); + doNotTranslateCell.updateRTL(); + info.setText(LocaleController.getString("TranslateMessagesInfo1", R.string.TranslateMessagesInfo1)); + info.getTextView().setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + info2.setText(LocaleController.getString("TranslateMessagesInfo2", R.string.TranslateMessagesInfo2)); + info2.getTextView().setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + update(); + updateHeight(); + } + private boolean getValue() { return preferences.getBoolean("translate_button", false); } @@ -521,15 +595,8 @@ public void update() { info.setTranslationY(-doNotTranslateCell.getHeight() * (1f - t)); info2.setAlpha(1f - t); info2.setTranslationY(-doNotTranslateCell.getHeight() * (1f - t)); -// header2.setTranslationY(-Math.max(doNotTranslateCell.getHeight(), info2.getHeight())); -// updateHeight(); -// header2.setTranslationY(-doNotTranslateCell.getHeight()); -// header2.setTranslationY(-doNotTranslateCell.getHeight() * (1f - t)); - -// ViewGroup.LayoutParams layoutParams = getLayoutParams(); -// layoutParams.height = AndroidUtilities.dp(HEIGHT_CLOSED + (HEIGHT_OPEN - HEIGHT_CLOSED) * t); -// setLayoutParams(layoutParams); + translateSettingsBackgroundHeight = header.getMeasuredHeight() + showButtonCheck.getMeasuredHeight() + (int) (doNotTranslateCell.getAlpha() * doNotTranslateCell.getMeasuredHeight()); }); doNotTranslateCellAnimation.addListener(new AnimatorListenerAdapter() { @Override @@ -540,11 +607,12 @@ public void onAnimationEnd(Animator animation) { } else { info2.setVisibility(View.VISIBLE); } + + translateSettingsBackgroundHeight = header.getMeasuredHeight() + showButtonCheck.getMeasuredHeight() + (int) (doNotTranslateCell.getAlpha() * doNotTranslateCell.getMeasuredHeight()); } }); doNotTranslateCellAnimation.setDuration((long) (Math.abs(doNotTranslateCell.getAlpha() - (value ? 1f : 0f)) * 200)); doNotTranslateCellAnimation.start(); - // updateHeight(); } @@ -576,6 +644,7 @@ void updateHeight() { setLayoutParams(lp); } } + int height() { return Math.max(AndroidUtilities.dp(40), header.getMeasuredHeight()) + Math.max(AndroidUtilities.dp(50), showButtonCheck.getMeasuredHeight()) + @@ -661,7 +730,6 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType case 3: HeaderCell header = new HeaderCell(mContext); header.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); - header.setText(LocaleController.getString("Language", R.string.Language)); view = header; break; case 1: @@ -679,7 +747,6 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { case 0: { if (!search) position -= 2; -// LanguageCell textSettingsCell = (LanguageCell) holder.itemView; TextRadioCell textSettingsCell = (TextRadioCell) holder.itemView; LocaleController.LocaleInfo localeInfo; boolean last; @@ -718,7 +785,13 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { case 2: { TranslateSettings translateSettings = (TranslateSettings) holder.itemView; translateSettings.setVisibility(searching ? View.GONE : View.VISIBLE); - translateSettings.updateHeight(); + translateSettings.updateTranslations(); + break; + } + case 3: { + HeaderCell header = (HeaderCell) holder.itemView; + header.setText(LocaleController.getString("Language", R.string.Language)); + break; } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index d6d23713493..c83daf1dc51 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -3043,7 +3043,7 @@ private int runCommentRequest(int intentAccount, AlertDialog progressDialog, Int for (int a = 0, N = res.messages.size(); a < N; a++) { arrayList.add(new MessageObject(UserConfig.selectedAccount, res.messages.get(a), true, true)); } - if (!arrayList.isEmpty()) { + if (!arrayList.isEmpty() || chat.forum && threadId != null && threadId == 1) { if (chat.forum) { TLRPC.TL_channels_getForumTopicsByID getForumTopicsByID = new TLRPC.TL_channels_getForumTopicsByID(); getForumTopicsByID.channel = MessagesController.getInstance(currentAccount).getInputChannel(chat.id); @@ -3063,11 +3063,17 @@ private int runCommentRequest(int intentAccount, AlertDialog progressDialog, Int TLRPC.TL_forumTopic topic = MessagesController.getInstance(currentAccount).getTopicsController().findTopic(chat.id, threadId); if (topic != null) { Bundle args = new Bundle(); - args.putLong("chat_id", -arrayList.get(0).getDialogId()); + args.putLong("chat_id", chat.id); if (messageId != topic.id) { args.putInt("message_id", Math.max(1, messageId)); } ChatActivity chatActivity = new ChatActivity(args); + if (arrayList.isEmpty()) { + TLRPC.Message message = new TLRPC.Message(); + message.id = 1; + message.action = new TLRPC.TL_messageActionChannelMigrateFrom(); + arrayList.add(new MessageObject(currentAccount, message, false, false)); + } chatActivity.setThreadMessages(arrayList, chat, req.msg_id, topic.read_inbox_max_id, topic.read_outbox_max_id, topic); if (commentId != null) { chatActivity.setHighlightMessageId(commentId); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java index ee18f1e4ba8..88afdc2ba9b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java @@ -49,6 +49,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewOutlineProvider; +import android.view.WindowManager; import android.view.animation.OvershootInterpolator; import android.widget.EditText; import android.widget.FrameLayout; @@ -79,6 +80,8 @@ import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; +import org.telegram.ui.ActionBar.ActionBarMenuSubItem; +import org.telegram.ui.ActionBar.ActionBarPopupWindow; import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.Theme; @@ -224,6 +227,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter public final static int LOCATION_TYPE_GROUP_VIEW = 5; public final static int LOCATION_TYPE_LIVE_VIEW = 6; + private ActionBarPopupWindow popupWindow; + private Runnable markAsReadRunnable; public static class VenueLocation { @@ -542,7 +547,7 @@ public void onItemClick(int id) { } else if (id == share_live_location) { openShareLiveLocation(0); } else if (id == get_directions) { - openDirections(); + openDirections(null); } } }); @@ -951,7 +956,24 @@ public void getOutline(View view, Outline outline) { listView.setAdapter(adapter = new LocationActivityAdapter(context, locationType, dialogId, false, null) { @Override protected void onDirectionClick() { - openDirections(); + openDirections(null); + } + + @Override + public void setLiveLocations(ArrayList liveLocations) { + if (messageObject != null && messageObject.isLiveLocation()) { + int otherPeopleLocations = 0; + if (liveLocations != null) { + for (int i = 0; i < liveLocations.size(); ++i) { + LiveLocation loc = liveLocations.get(i); + if (loc != null && !UserObject.isUserSelf(loc.user)) { + otherPeopleLocations++; + } + } + } + otherItem.setVisibility(otherPeopleLocations == 1 ? View.VISIBLE : View.GONE); + } + super.setLiveLocations(liveLocations); } }); adapter.setMyLocationDenied(locationDenied); @@ -978,6 +1000,47 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { } }); ((DefaultItemAnimator) listView.getItemAnimator()).setDelayAnimations(false); + listView.setOnItemLongClickListener((view, position) -> { + if (locationType == 2) { + Object object = adapter.getItem(position); + if (object instanceof LiveLocation) { + + final LiveLocation location = (LiveLocation) object; + + ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(context); + ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), true, true, getResourceProvider()); + cell.setMinimumWidth(AndroidUtilities.dp(200)); + cell.setTextAndIcon(LocaleController.getString("GetDirections", R.string.GetDirections), R.drawable.navigate); + cell.setOnClickListener(e -> { + openDirections(location); + if (popupWindow != null) { + popupWindow.dismiss(); + } + }); + popupLayout.addView(cell); + + popupWindow = new ActionBarPopupWindow(popupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) { + @Override + public void dismiss() { + super.dismiss(); + popupWindow = null; + } + }; + popupWindow.setOutsideTouchable(true); + popupWindow.setClippingEnabled(true); + popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED); + popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED); + + int[] loc = new int[2]; + view.getLocationInWindow(loc); + popupWindow.showAtLocation(view, Gravity.TOP, 0, loc[1] - AndroidUtilities.dp(48 + 4)); + popupWindow.dimBehind(); + + return true; + } + } + return false; + }); listView.setOnItemClickListener((view, position) -> { if (locationType == LOCATION_TYPE_GROUP) { if (position == 1) { @@ -1289,9 +1352,12 @@ private boolean isActiveThemeDark() { return AndroidUtilities.computePerceivedBrightness(color) < 0.721f; } - private void openDirections() { + private void openDirections(LiveLocation location) { double daddrLat, daddrLong; - if (messageObject != null) { + if (location != null && location.object != null) { + daddrLat = location.object.media.geo.lat; + daddrLong = location.object.media.geo._long; + } else if (messageObject != null) { daddrLat = messageObject.messageOwner.media.geo.lat; daddrLong = messageObject.messageOwner.media.geo._long; } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSoundActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSoundActivity.java index 733d4678393..81710096a0e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSoundActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSoundActivity.java @@ -298,7 +298,7 @@ private void deleteSelectedMessages() { if (dialogId < 0) { if (topicId != 0) { TLRPC.TL_forumTopic forumTopic = getMessagesController().getTopicsController().findTopic(-dialogId, topicId); - ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, true, resourcesProvider); + ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, false, true, resourcesProvider); avatarContainer.setTitle(forumTopic.title); } else { TLRPC.Chat chatLocal = getMessagesController().getChat(-dialogId); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 010b8a41dd7..1f5f8b25724 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -758,7 +758,7 @@ protected void onDraw(Canvas canvas) { if (y1 != 0) { if (previousTransitionFragment != null && previousTransitionFragment.getContentView() != null) { AndroidUtilities.rectTmp2.set(0, 0, getMeasuredWidth(), y1); - if (previousTransitionFragment.getActionBar() != null && previousTransitionFragment.getActionBar().getBackground() == null) { + if (previousTransitionFragment.getActionBar() != null && !previousTransitionFragment.getContentView().blurWasDrawn() && previousTransitionFragment.getActionBar().getBackground() == null) { paint.setColor(Theme.getColor(Theme.key_actionBarDefault, previousTransitionFragment.getResourceProvider())); canvas.drawRect(AndroidUtilities.rectTmp2, paint); } else { @@ -7230,8 +7230,11 @@ private void updateProfileData(boolean reload) { icon.setLayerNum(7); icon.setRoundRadius(AndroidUtilities.dp(4)); icon.setImage(mediaLocation, mediaFilter, ImageLocation.getForDocument(thumb, document), "140_140", thumbDrawable, document); - if (((AnimatedEmojiDrawable) emojiStatusDrawable[1].getDrawable()).canOverrideColor()) { - icon.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_windowBackgroundWhiteBlueIcon), PorterDuff.Mode.MULTIPLY)); + if (AnimatedEmojiDrawable.isDefaultStatusEmoji(emojiStatusDrawable[1].getDrawable())) { + icon.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_windowBackgroundWhiteBlueIcon), PorterDuff.Mode.SRC_IN)); + } else if (((AnimatedEmojiDrawable) emojiStatusDrawable[1].getDrawable()).canOverrideColor()) { + icon.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.SRC_IN)); + premiumPreviewBottomSheet.statusStickerSet = MessageObject.getInputStickerSet(document); } else { premiumPreviewBottomSheet.statusStickerSet = MessageObject.getInputStickerSet(document); } @@ -7436,7 +7439,7 @@ private void updateProfileData(boolean reload) { imageLocation = null; thumbLocation = null; videoLocation = null; - ForumUtilities.setTopicIcon(avatarImage, topic, true, resourcesProvider); + ForumUtilities.setTopicIcon(avatarImage, topic, true, true, resourcesProvider); } else { avatarDrawable.setInfo(chat); imageLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_BIG); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java index 52634b69e1c..ee7e880dcfe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java @@ -321,7 +321,7 @@ public void onItemClick(int id) { if (dialogId < 0) { if (topicId != 0) { TLRPC.TL_forumTopic forumTopic = getMessagesController().getTopicsController().findTopic(-dialogId, topicId); - ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, true, resourcesProvider); + ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, false, true, resourcesProvider); avatarContainer.setTitle(forumTopic.title); } else { TLRPC.Chat chatLocal = getMessagesController().getChat(-dialogId); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/QrActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/QrActivity.java index 80cba4698b5..44eb3b3f2a6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/QrActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/QrActivity.java @@ -405,7 +405,7 @@ public void onError(TLRPC.TL_error error) { } private boolean phoneIsPublic() { - final ArrayList privacyRules = ContactsController.getInstance(currentAccount).getPrivacyRules(ContactsController.PRIVACY_RULES_TYPE_PHONE); + ArrayList privacyRules = ContactsController.getInstance(currentAccount).getPrivacyRules(ContactsController.PRIVACY_RULES_TYPE_PHONE); if (privacyRules == null) { return false; } @@ -423,6 +423,23 @@ private boolean phoneIsPublic() { break; } } + if (type == 2) { + privacyRules = ContactsController.getInstance(currentAccount).getPrivacyRules(ContactsController.PRIVACY_RULES_TYPE_ADDED_BY_PHONE); + if (privacyRules == null || privacyRules.size() == 0) { + return true; + } else { + for (int a = 0; a < privacyRules.size(); a++) { + TLRPC.PrivacyRule rule = privacyRules.get(a); + if (rule instanceof TLRPC.TL_privacyValueAllowAll) { + return true; + } else if (rule instanceof TLRPC.TL_privacyValueDisallowAll) { + return false; + } else if (rule instanceof TLRPC.TL_privacyValueAllowContacts) { + return false; + } + } + } + } return type == 0 || type == 1; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java index fcaca2dc673..30604a04944 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java @@ -380,7 +380,7 @@ public SelectAnimatedEmojiDialog(BaseFragment baseFragment, Context context, boo selectorPaint.setColor(Theme.getColor(Theme.key_listSelector, resourcesProvider)); selectorAccentPaint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhiteBlueIcon, resourcesProvider), 30)); - premiumStarColorFilter = new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlueIcon, resourcesProvider), PorterDuff.Mode.MULTIPLY); + premiumStarColorFilter = new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlueIcon, resourcesProvider), PorterDuff.Mode.SRC_IN); this.emojiX = emojiX; final Integer bubbleX = emojiX == null ? null : MathUtils.clamp(emojiX, AndroidUtilities.dp(26), AndroidUtilities.dp(340 - 48)); @@ -482,6 +482,12 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { dismiss.run(); } } : null) { + + @Override + protected ColorFilter getEmojiColorFilter() { + return premiumStarColorFilter; + } + @Override protected boolean onTabClick(int index) { if (smoothScrolling) { @@ -1039,7 +1045,7 @@ protected void dispatchDraw(Canvas canvas) { canvas.translate(0, -getTranslationY()); emojiSelectView.drawable.setAlpha((int) (255 * emojiSelectAlpha)); emojiSelectView.drawable.setBounds(emojiSelectRect); - emojiSelectView.drawable.setColorFilter(new PorterDuffColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteBlueIcon, resourcesProvider), scrimColor, 1f - scrimAlpha), PorterDuff.Mode.MULTIPLY)); + emojiSelectView.drawable.setColorFilter(new PorterDuffColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteBlueIcon, resourcesProvider), scrimColor, 1f - scrimAlpha), PorterDuff.Mode.SRC_IN)); emojiSelectView.drawable.draw(canvas); canvas.restore(); } @@ -3433,12 +3439,13 @@ private void skew(Canvas canvas, int i, int h) { private void drawImage(Canvas canvas, Drawable drawable, ImageViewEmoji imageView, float alpha) { if (drawable != null) { - drawable.setColorFilter(premiumStarColorFilter); drawable.setAlpha((int) (255 * alpha)); if (drawable instanceof AnimatedEmojiDrawable) { ((AnimatedEmojiDrawable) drawable).draw(canvas, false); + drawable.setColorFilter(premiumStarColorFilter); } else { drawable.draw(canvas); + drawable.setColorFilter(premiumStarColorFilter); } if (imageView.premiumLockIconView != null) { @@ -4228,7 +4235,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto } imageReceiver.setImage(mediaLocation, mediaFilter, ImageLocation.getForDocument(thumb, document), filter, null, null, thumbDrawable, document.size, null, document, 1); if (imageViewEmoji.drawable instanceof AnimatedEmojiDrawable && ((AnimatedEmojiDrawable) imageViewEmoji.drawable).canOverrideColor()) { - imageReceiver.setColorFilter(premiumStarColorFilter); + imageReceiver.setColorFilter(AnimatedEmojiDrawable.isDefaultStatusEmoji((AnimatedEmojiDrawable) imageViewEmoji.drawable) ? premiumStarColorFilter : Theme.chat_animatedEmojiTextColorFilter); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TopicCreateFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/TopicCreateFragment.java index 6fdfaaf9ff1..fb31bd36095 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TopicCreateFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TopicCreateFragment.java @@ -224,10 +224,20 @@ public void onItemClick(int id) { editForumRequest.icon_emoji_id = selectedEmojiDocumentId; editForumRequest.flags |= 2; } - if (checkBoxCell != null) { - editForumRequest.hidden = !checkBoxCell.isChecked(); - editForumRequest.flags |= 8; - } +// if (checkBoxCell != null ) { +// editForumRequest.hidden = !checkBoxCell.isChecked(); +// editForumRequest.flags |= 8; +// } + ConnectionsManager.getInstance(currentAccount).sendRequest(editForumRequest, (response, error) -> { + + }); + } + if (checkBoxCell != null && topicForEdit.id == 1 && !checkBoxCell.isChecked() != topicForEdit.hidden) { + TLRPC.TL_channels_editForumTopic editForumRequest = new TLRPC.TL_channels_editForumTopic(); + editForumRequest.channel = getMessagesController().getInputChannel(chatId); + editForumRequest.topic_id = topicForEdit.id; + editForumRequest.hidden = !checkBoxCell.isChecked(); + editForumRequest.flags |= 8; ConnectionsManager.getInstance(currentAccount).sendRequest(editForumRequest, (response, error) -> { }); @@ -520,6 +530,7 @@ private void selectEmoji(Long documentId, boolean free) { if (docId != 0) { AnimatedEmojiDrawable animatedEmojiDrawable = new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC, currentAccount, docId); + animatedEmojiDrawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); backupImageView[1].setAnimatedEmojiDrawable(animatedEmojiDrawable); backupImageView[1].setImageDrawable(null); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java index a506732e84a..3f5cfe44a2b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java @@ -468,7 +468,7 @@ protected void dispatchDraw(Canvas canvas) { } }; - contentView.needBlur = true; + contentView.needBlur = !inPreviewMode; actionBar.setAddToContainer(false); actionBar.setCastShadows(false); @@ -2879,6 +2879,9 @@ public void setAnimatedEmojiDrawable(AnimatedEmojiDrawable animatedEmojiDrawable if (this.animatedEmojiDrawable != null && attached) { this.animatedEmojiDrawable.removeView(this); } + if (animatedEmojiDrawable != null) { + animatedEmojiDrawable.setColorFilter(Theme.chat_animatedEmojiTextColorFilter); + } this.animatedEmojiDrawable = animatedEmojiDrawable; if (animatedEmojiDrawable != null && attached) { animatedEmojiDrawable.addView(this); diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_location.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_location.png old mode 100755 new mode 100644 index a24c3ab78dd..a6aa262e7bd Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_location.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_location.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_location.png old mode 100755 new mode 100644 index d65cbe22c4e..9775374d5f3 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_location.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_location.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_location.png old mode 100755 new mode 100644 index 1c4037a0c24..507c60d8f24 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_location.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_location.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_location.png old mode 100755 new mode 100644 index 1375e98dfa2..67be05650a1 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_location.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_location.png differ diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index b9e6733593d..485dc28d1ea 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -905,6 +905,8 @@ un1 delete topic un2 un1 pin topic un2 un1 unpin topic un2 + un1 enabled anti-spam + un1 disabled anti-spam New Broadcast List Enter list name diff --git a/gradle.properties b/gradle.properties index 25a68b5ba28..c7b69c17b9b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Sat Mar 12 05:53:50 MSK 2016 -APP_VERSION_NAME=9.2.0 -APP_VERSION_CODE=2956 +APP_VERSION_NAME=9.2.1 +APP_VERSION_CODE=2962 APP_PACKAGE=org.telegram.messenger RELEASE_KEY_PASSWORD=TelegramAndroidPswd RELEASE_KEY_ALIAS=tmessages