From 1eea3ab6f7fa8ff5b90282a2bb0e919aabea7d35 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Wed, 1 Jan 2020 21:32:12 +0300 Subject: [PATCH] Update to 5.13.0 (1820) Merged some parts of https://github.com/DrKLO/Telegram/pull/1541 --- TMessagesProj/jni/TgNetWrapper.cpp | 3 + .../jni/tgnet/ConnectionsManager.cpp | 5 +- TMessagesProj/jni/tgnet/Datacenter.cpp | 12 +-- TMessagesProj/jni/tgnet/Datacenter.h | 3 +- .../org/telegram/messenger/BuildVars.java | 2 +- .../telegram/messenger/FileLoadOperation.java | 2 +- .../telegram/messenger/MediaController.java | 91 +++++++++++++------ .../messenger/MediaDataController.java | 4 +- .../messenger/SendMessagesHelper.java | 4 +- .../org/telegram/messenger/SharedConfig.java | 2 +- .../java/org/telegram/ui/ActionBar/Theme.java | 46 ++++++---- .../telegram/ui/ChannelCreateActivity.java | 4 +- .../java/org/telegram/ui/ChatActivity.java | 12 ++- .../ui/Components/ChatActivityEnterView.java | 7 +- .../ui/Components/ChatAttachAlert.java | 24 ++--- .../ui/Components/voip/CallSwipeView.java | 30 +++--- .../org/telegram/ui/DataUsageActivity.java | 2 +- .../java/org/telegram/ui/LaunchActivity.java | 2 +- .../NotificationsCustomSettingsActivity.java | 8 +- .../java/org/telegram/ui/PhotoViewer.java | 16 ++-- .../java/org/telegram/ui/ProfileActivity.java | 22 +++++ .../ui/QuickRepliesSettingsActivity.java | 2 +- .../org/telegram/ui/TextSelectionHint.java | 5 +- .../java/org/telegram/ui/ThemeActivity.java | 2 +- .../java/org/telegram/ui/VoIPActivity.java | 1 + 25 files changed, 206 insertions(+), 105 deletions(-) diff --git a/TMessagesProj/jni/TgNetWrapper.cpp b/TMessagesProj/jni/TgNetWrapper.cpp index d91438b46..008782f22 100644 --- a/TMessagesProj/jni/TgNetWrapper.cpp +++ b/TMessagesProj/jni/TgNetWrapper.cpp @@ -57,6 +57,9 @@ void reuse(JNIEnv *env, jclass c, jlong address) { jobject getJavaByteBuffer(JNIEnv *env, jclass c, jlong address) { NativeByteBuffer *buffer = (NativeByteBuffer *) (intptr_t) address; + if (buffer == nullptr) { + return nullptr; + } return buffer->getJavaByteBuffer(); } diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 23ebc1621..fb5950500 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -2018,9 +2018,8 @@ void ConnectionsManager::requestSaltsForDatacenter(Datacenter *datacenter, bool if (iter != requestingSaltsForDc.end()) { requestingSaltsForDc.erase(iter); } - if (error == nullptr) { - TL_future_salts *res = (TL_future_salts *) response; - datacenter->mergeServerSalts(res->salts, media); + if (response != nullptr) { + datacenter->mergeServerSalts((TL_future_salts *) response, media); saveConfig(); } }, nullptr, RequestFlagWithoutLogin | RequestFlagEnableUnauthorized | RequestFlagUseUnboundKey, datacenter->getDatacenterId(), connectionType, true); diff --git a/TMessagesProj/jni/tgnet/Datacenter.cpp b/TMessagesProj/jni/tgnet/Datacenter.cpp index 02e18de7e..90bf51cb7 100644 --- a/TMessagesProj/jni/tgnet/Datacenter.cpp +++ b/TMessagesProj/jni/tgnet/Datacenter.cpp @@ -681,8 +681,8 @@ int64_t Datacenter::getServerSalt(bool media) { return result; } -void Datacenter::mergeServerSalts(std::vector> &newSalts, bool media) { - if (newSalts.empty()) { +void Datacenter::mergeServerSalts(TL_future_salts *futureSalts, bool media) { + if (futureSalts->salts.empty()) { return; } std::vector> &salts = media ? mediaServerSalts : serverSalts; @@ -694,11 +694,11 @@ void Datacenter::mergeServerSalts(std::vector> & existingSalts.push_back(salts[a]->salt); } bool added = false; - size = newSalts.size(); + size = futureSalts->salts.size(); for (uint32_t a = 0; a < size; a++) { - int64_t value = newSalts[a]->salt; - if (std::find(existingSalts.begin(), existingSalts.end(), value) == existingSalts.end() && newSalts[a]->valid_until > date) { - salts.push_back(std::unique_ptr(std::move(newSalts[a]))); + int64_t value = futureSalts->salts[a]->salt; + if (std::find(existingSalts.begin(), existingSalts.end(), value) == existingSalts.end() && futureSalts->salts[a]->valid_until > date) { + salts.push_back(std::unique_ptr(std::move(futureSalts->salts[a]))); added = true; } } diff --git a/TMessagesProj/jni/tgnet/Datacenter.h b/TMessagesProj/jni/tgnet/Datacenter.h index 0b144e6b6..b4c19d5d2 100644 --- a/TMessagesProj/jni/tgnet/Datacenter.h +++ b/TMessagesProj/jni/tgnet/Datacenter.h @@ -18,6 +18,7 @@ class TL_future_salt; class Connection; class NativeByteBuffer; class TL_future_salt; +class TL_future_salts; class TL_help_configSimple; class ByteArray; class TLObject; @@ -41,7 +42,7 @@ public: void clearAuthKey(HandshakeType type); void clearServerSalts(bool media); int64_t getServerSalt(bool media); - void mergeServerSalts(std::vector> &newSalts, bool media); + void mergeServerSalts(TL_future_salts *newSalts, bool media); void addServerSalt(std::unique_ptr &serverSalt, bool media); bool containsServerSalt(int64_t value, bool media); void suspendConnections(bool suspendPush); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 400df7919..1fbf707f5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -19,7 +19,7 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean TON_WALLET_STANDALONE = false; - public static int BUILD_VERSION = 1819; + public static int BUILD_VERSION = 1820; public static String BUILD_VERSION_STRING = "5.13.0"; 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 abbaa1257..9171dc416 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -1601,7 +1601,7 @@ public class FileLoadOperation { } protected void startDownloadRequest() { - if (paused || + if (paused || reuploadingCdn || state != stateDownloading || streamPriorityStartOffset == 0 && ( !nextPartWasPreloaded && (requestInfos.size() + delayedRequestInfos.size() >= currentMaxDownloadRequests) || diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index fca0133a8..0868310f3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -300,6 +300,12 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } } + AudioManager.OnAudioFocusChangeListener audioRecordFocusChangedListener = focusChange -> { + if (focusChange != AudioManager.AUDIOFOCUS_GAIN) { + hasRecordAudioFocus = false; + } + }; + public final static int VIDEO_BITRATE_1080 = 6800_000; public final static int VIDEO_BITRATE_720 = 2621_440; public final static int VIDEO_BITRATE_480 = 1000_000; @@ -340,6 +346,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, private float[] linearAcceleration = new float[3]; private int hasAudioFocus; + private boolean hasRecordAudioFocus; private boolean callInProgress; private int audioFocus = AUDIO_NO_FOCUS_NO_DUCK; private boolean resumeAudioOnFocusGain; @@ -350,7 +357,19 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, private static final int AUDIO_NO_FOCUS_CAN_DUCK = 1; private static final int AUDIO_FOCUSED = 2; - private ArrayList videoConvertQueue = new ArrayList<>(); + private class VideoConvertMessage { + public MessageObject messageObject; + public VideoEditedInfo videoEditedInfo; + public int currentAccount; + + public VideoConvertMessage(MessageObject object, VideoEditedInfo info) { + messageObject = object; + currentAccount = messageObject.currentAccount; + videoEditedInfo = info; + } + } + + private ArrayList videoConvertQueue = new ArrayList<>(); private final Object videoQueueSync = new Object(); private HashMap generatingWaveform = new HashMap<>(); @@ -2821,7 +2840,13 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, boolean paused = false; if (playingMessageObject != null && isPlayingMessage(playingMessageObject) && !isMessagePaused()) { paused = true; - pauseMessage(playingMessageObject); + } + + if (!hasRecordAudioFocus) { + int result = NotificationsController.audioManager.requestAudioFocus(audioRecordFocusChangedListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); + if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { + hasRecordAudioFocus = true; + } } try { @@ -2960,12 +2985,20 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.audioRecordTooShort, recordingGuid, false); recordingAudioFileToSend.delete(); } + if (hasRecordAudioFocus) { + NotificationsController.audioManager.abandonAudioFocus(audioRecordFocusChangedListener); + hasRecordAudioFocus = false; + } }); }); } else { if (recordingAudioFile != null) { recordingAudioFile.delete(); } + if (hasRecordAudioFocus) { + NotificationsController.audioManager.abandonAudioFocus(audioRecordFocusChangedListener); + hasRecordAudioFocus = false; + } } try { if (audioRecorder != null) { @@ -3490,7 +3523,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } else if (isEmpty) { new File(messageObject.messageOwner.attachPath).delete(); } - videoConvertQueue.add(messageObject); + videoConvertQueue.add(new VideoConvertMessage(messageObject, messageObject.videoEditedInfo)); if (videoConvertQueue.size() == 1) { startVideoConvertFromQueue(); } @@ -3501,11 +3534,12 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (messageObject != null) { if (!videoConvertQueue.isEmpty()) { for (int a = 0; a < videoConvertQueue.size(); a++) { - MessageObject object = videoConvertQueue.get(a); - if (object.getId() == messageObject.getId() && object.currentAccount == messageObject.currentAccount) { + VideoConvertMessage videoConvertMessage = videoConvertQueue.get(a); + MessageObject object = videoConvertMessage.messageObject; + if (object.equals(messageObject) && object.currentAccount == messageObject.currentAccount) { if (a == 0) { synchronized (videoConvertSync) { - messageObject.videoEditedInfo.canceled = true; + videoConvertMessage.videoEditedInfo.canceled = true; } } else { videoConvertQueue.remove(a); @@ -3519,10 +3553,12 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, private boolean startVideoConvertFromQueue() { if (!videoConvertQueue.isEmpty()) { - MessageObject messageObject = videoConvertQueue.get(0); + VideoConvertMessage videoConvertMessage = videoConvertQueue.get(0); + MessageObject messageObject = videoConvertMessage.messageObject; + VideoEditedInfo videoEditedInfo = videoConvertMessage.videoEditedInfo; synchronized (videoConvertSync) { - if (messageObject != null && messageObject.videoEditedInfo != null) { - messageObject.videoEditedInfo.canceled = false; + if (videoEditedInfo != null) { + videoEditedInfo.canceled = false; } } Intent intent = new Intent(ApplicationLoader.applicationContext, VideoEncodingService.class); @@ -3544,7 +3580,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, FileLog.e(e); } } - VideoConvertRunnable.runConversion(messageObject); + VideoConvertRunnable.runConversion(videoConvertMessage); return true; } return false; @@ -3624,44 +3660,44 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, return -5; } - private void didWriteData(final MessageObject messageObject, final File file, final boolean last, long availableSize, final boolean error, final float progress) { - final boolean firstWrite = messageObject.videoEditedInfo.videoConvertFirstWrite; + private void didWriteData(final VideoConvertMessage message, final File file, final boolean last, long availableSize, final boolean error, final float progress) { + final boolean firstWrite = message.videoEditedInfo.videoConvertFirstWrite; if (firstWrite) { - messageObject.videoEditedInfo.videoConvertFirstWrite = false; + message.videoEditedInfo.videoConvertFirstWrite = false; } AndroidUtilities.runOnUIThread(() -> { if (error || last) { synchronized (videoConvertSync) { - messageObject.videoEditedInfo.canceled = false; + message.videoEditedInfo.canceled = false; } - videoConvertQueue.remove(messageObject); + videoConvertQueue.remove(message); startVideoConvertFromQueue(); } if (error) { - NotificationCenter.getInstance(messageObject.currentAccount).postNotificationName(NotificationCenter.filePreparingFailed, messageObject, file.toString(), progress); + NotificationCenter.getInstance(message.currentAccount).postNotificationName(NotificationCenter.filePreparingFailed, message.messageObject, file.toString(), progress); } else { if (firstWrite) { - NotificationCenter.getInstance(messageObject.currentAccount).postNotificationName(NotificationCenter.filePreparingStarted, messageObject, file.toString(), progress); + NotificationCenter.getInstance(message.currentAccount).postNotificationName(NotificationCenter.filePreparingStarted, message.messageObject, file.toString(), progress); } - NotificationCenter.getInstance(messageObject.currentAccount).postNotificationName(NotificationCenter.fileNewChunkAvailable, messageObject, file.toString(), availableSize, last ? file.length() : 0, progress); + NotificationCenter.getInstance(message.currentAccount).postNotificationName(NotificationCenter.fileNewChunkAvailable, message.messageObject, file.toString(), availableSize, last ? file.length() : 0, progress); } }); } private static class VideoConvertRunnable implements Runnable { - private MessageObject messageObject; + private VideoConvertMessage convertMessage; - private VideoConvertRunnable(MessageObject message) { - messageObject = message; + private VideoConvertRunnable(VideoConvertMessage message) { + convertMessage = message; } @Override public void run() { - MediaController.getInstance().convertVideo(messageObject); + MediaController.getInstance().convertVideo(convertMessage); } - public static void runConversion(final MessageObject obj) { + public static void runConversion(final VideoConvertMessage obj) { new Thread(() -> { try { VideoConvertRunnable wrapper = new VideoConvertRunnable(obj); @@ -3676,8 +3712,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } - private boolean convertVideo(final MessageObject messageObject) { - VideoEditedInfo info = messageObject.videoEditedInfo; + private boolean convertVideo(final VideoConvertMessage convertMessage) { + MessageObject messageObject = convertMessage.messageObject; + VideoEditedInfo info = convertMessage.videoEditedInfo; if (messageObject == null || info == null) { return false; } @@ -3767,7 +3804,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } lastAvailableSize = availableSize; - MediaController.this.didWriteData(messageObject, cacheFile, false, availableSize, false, progress); + MediaController.this.didWriteData(convertMessage, cacheFile, false, availableSize, false, progress); } }; @@ -3795,7 +3832,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } preferences.edit().putBoolean("isPreviousOk", true).apply(); - didWriteData(messageObject, cacheFile, true, cacheFile.length(), error || canceled, 1f); + didWriteData(convertMessage, cacheFile, true, cacheFile.length(), error || canceled, 1f); return true; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java index 6a53383e4..ef7b00f05 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java @@ -1781,9 +1781,11 @@ public class MediaDataController extends BaseController { searchResultMessagesMap[0].clear(); searchResultMessagesMap[1].clear(); messagesSearchCount[0] = 0; + getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsLoading, guid); } boolean added = false; - for (int a = 0; a < Math.min(res.messages.size(), 20); a++) { + int N = Math.min(res.messages.size(), 20); + for (int a = 0; a < N; a++) { TLRPC.Message message = res.messages.get(a); added = true; MessageObject messageObject = new MessageObject(currentAccount, message, false); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index a87830f8c..a264ef019 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -5520,10 +5520,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe } public static String getKeyForPhotoSize(TLRPC.PhotoSize photoSize, Bitmap[] bitmap, boolean blur, boolean forceCache) { - if (photoSize == null) { + if (photoSize == null || photoSize.location == null) { return null; } - Point point = ChatMessageCell.getMessageSize(photoSize.w,photoSize.h); + Point point = ChatMessageCell.getMessageSize(photoSize.w, photoSize.h); if (bitmap != null) { try { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java index 11b71d422..71dfabc35 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java @@ -818,7 +818,7 @@ public class SharedConfig { int androidVersion = Build.VERSION.SDK_INT; int cpuCount = ConnectionsManager.CPU_COUNT; int memoryClass = ((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); - if (androidVersion < 21 || cpuCount <= 2 || memoryClass <= 100 || cpuCount <= 4 && maxCpuFreq != -1 && maxCpuFreq <= 1250 || cpuCount <= 4 && maxCpuFreq <= 1600 && memoryClass <= 128 && androidVersion <= 21) { + if (androidVersion < 21 || cpuCount <= 2 || memoryClass <= 100 || cpuCount <= 4 && maxCpuFreq != -1 && maxCpuFreq <= 1250 || cpuCount <= 4 && maxCpuFreq <= 1600 && memoryClass <= 128 && androidVersion <= 21 || cpuCount <= 4 && maxCpuFreq <= 1300 && memoryClass <= 128 && androidVersion <= 24) { devicePerformanceClass = PERFORMANCE_CLASS_LOW; } else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 1650 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) { devicePerformanceClass = PERFORMANCE_CLASS_AVERAGE; 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 635c03e91..611531445 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -171,7 +171,6 @@ public class Theme { if (gradientColor != 0 && (gradientShader == null || backgroundHeight != currentBackgroundHeight || currentColor != color || currentGradientColor != gradientColor)) { gradientShader = new LinearGradient(0, 0, 0, backgroundHeight, new int[]{gradientColor, color}, null, Shader.TileMode.CLAMP); paint.setShader(gradientShader); - currentBackgroundHeight = backgroundHeight; currentColor = color; currentGradientColor = gradientColor; paint.setColor(0xffffffff); @@ -182,6 +181,7 @@ public class Theme { } paint.setColor(color); } + currentBackgroundHeight = backgroundHeight; topY = top; } @@ -215,19 +215,33 @@ public class Theme { } } else { path.reset(); - path.moveTo(bounds.right - dp(2.6f), bounds.bottom - padding); - path.lineTo(bounds.left + padding + rad, bounds.bottom - padding); - rect.set(bounds.left + padding, bounds.bottom - padding - rad * 2, bounds.left + padding + rad * 2, bounds.bottom - padding); - path.arcTo(rect, 90, 90, false); - path.lineTo(bounds.left + padding, bounds.top + padding + rad); - rect.set(bounds.left + padding, bounds.top + padding, bounds.left + padding + rad * 2, bounds.top + padding + rad * 2); - path.arcTo(rect, 180, 90, false); - path.lineTo(bounds.right - dp(8) - rad, bounds.top + padding); - rect.set(bounds.right - dp(8) - rad * 2, bounds.top + padding, bounds.right - dp(8), bounds.top + padding + rad * 2); - path.arcTo(rect, 270, 90, false); - path.lineTo(bounds.right - dp(8), bounds.bottom - padding - rad - dp(1)); - rect.set(bounds.right - dp(8), bounds.bottom - padding - rad * 2 - dp(9), bounds.right - dp(7) + rad * 2, bounds.bottom - padding - dp(1)); - path.arcTo(rect, 180, -83, false); + if (topY + bounds.bottom - rad < currentBackgroundHeight) { + path.moveTo(bounds.right - dp(2.6f), bounds.bottom - padding); + path.lineTo(bounds.left + padding + rad, bounds.bottom - padding); + rect.set(bounds.left + padding, bounds.bottom - padding - rad * 2, bounds.left + padding + rad * 2, bounds.bottom - padding); + path.arcTo(rect, 90, 90, false); + } else { + path.moveTo(bounds.right - dp(8), bounds.top - topY + currentBackgroundHeight); + path.lineTo(bounds.left + padding, bounds.top - topY + currentBackgroundHeight); + } + if (topY + rad * 2 >= 0) { + path.lineTo(bounds.left + padding, bounds.top + padding + rad); + rect.set(bounds.left + padding, bounds.top + padding, bounds.left + padding + rad * 2, bounds.top + padding + rad * 2); + path.arcTo(rect, 180, 90, false); + path.lineTo(bounds.right - dp(8) - rad, bounds.top + padding); + rect.set(bounds.right - dp(8) - rad * 2, bounds.top + padding, bounds.right - dp(8), bounds.top + padding + rad * 2); + path.arcTo(rect, 270, 90, false); + } else { + path.lineTo(bounds.left + padding, bounds.top - topY); + path.lineTo(bounds.right - dp(8), bounds.top - topY); + } + if (topY + bounds.bottom - rad * 2 < currentBackgroundHeight) { + path.lineTo(bounds.right - dp(8), bounds.bottom - padding - rad - dp(1)); + rect.set(bounds.right - dp(8), bounds.bottom - padding - rad * 2 - dp(9), bounds.right - dp(7) + rad * 2, bounds.bottom - padding - dp(1)); + path.arcTo(rect, 180, -83, false); + } else { + path.lineTo(bounds.right - dp(8), bounds.top - topY + currentBackgroundHeight); + } path.close(); canvas.drawPath(path, paint); @@ -3756,11 +3770,11 @@ public class Theme { if (preferences.contains("overrideThemeWallpaper") || preferences.contains("selectedBackground2")) { boolean override = preferences.getBoolean("overrideThemeWallpaper", false); long id = preferences.getLong("selectedBackground2", 1000001); - if (id != -2 && (override || id != 1000001)) { + if (id == -1 || override && id != -2 && id != 1000001) { OverrideWallpaperInfo overrideWallpaper = new OverrideWallpaperInfo(); overrideWallpaper.color = preferences.getInt("selectedColor", 0); overrideWallpaper.slug = preferences.getString("selectedBackgroundSlug", ""); - if (id >= -100 && id <= -1 && TextUtils.isEmpty(overrideWallpaper.slug)) { + if (id >= -100 && id <= -1 && overrideWallpaper.color != 0) { overrideWallpaper.slug = COLOR_BACKGROUND_SLUG; overrideWallpaper.fileName = ""; overrideWallpaper.originalFileName = ""; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java index d4db16b93..b5aaa65c4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java @@ -849,7 +849,9 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC @Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { - imageUpdater.onActivityResult(requestCode, resultCode, data); + if (imageUpdater != null) { + imageUpdater.onActivityResult(requestCode, resultCode, data); + } } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 0d24643c4..fa4c06a89 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1520,6 +1520,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } searchItem.setVisibility(View.GONE); getMediaDataController().clearFoundMessageObjects(); + if (messagesSearchAdapter != null) { + messagesSearchAdapter.notifyDataSetChanged(); + } removeSelectedMessageHighlight(); updateBottomOverlay(); updatePinnedMessageView(true); @@ -6010,6 +6013,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void showTextSelectionHint(MessageObject messageObject) { + if (getParentActivity() == null) { + return; + } CharSequence text; boolean canShowText = false; if (messageObject.textLayoutBlocks != null && !messageObject.textLayoutBlocks.isEmpty()) { @@ -11308,8 +11314,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } else if (id == NotificationCenter.chatSearchResultsLoading) { - if (classGuid == (Integer) args[0] && searchItem != null) { - searchItem.setShowSearchProgress(true); + if (classGuid == (Integer) args[0]) { + if (searchItem != null) { + searchItem.setShowSearchProgress(true); + } if (messagesSearchAdapter != null) { messagesSearchAdapter.notifyDataSetChanged(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index e80270de9..1116504d0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -1732,7 +1732,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe sendButton.setBackgroundDrawable(Theme.createSelectorDrawable(Color.argb(24, Color.red(color), Color.green(color), Color.blue(color)), 1)); } sendButtonContainer.addView(sendButton, LayoutHelper.createFrame(48, 48)); - sendButton.setOnClickListener(view -> sendMessage()); + sendButton.setOnClickListener(view -> { + if (sendPopupWindow != null && sendPopupWindow.isShowing()) { + return; + } + sendMessage(); + }); sendButton.setOnLongClickListener(this::onSendLongClick); slowModeButton = new SimpleTextView(context); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java index 6cd64aefb..bc92d77ee 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java @@ -2269,18 +2269,20 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N zoomWas = true; } } else { - float diff = (newDistance - pinchStartDistance) / AndroidUtilities.dp(100); - pinchStartDistance = newDistance; - cameraZoom += diff; - if (cameraZoom < 0.0f) { - cameraZoom = 0.0f; - } else if (cameraZoom > 1.0f) { - cameraZoom = 1.0f; + if (cameraView != null) { + float diff = (newDistance - pinchStartDistance) / AndroidUtilities.dp(100); + pinchStartDistance = newDistance; + cameraZoom += diff; + if (cameraZoom < 0.0f) { + cameraZoom = 0.0f; + } else if (cameraZoom > 1.0f) { + cameraZoom = 1.0f; + } + zoomControlView.setZoom(cameraZoom, false); + containerView.invalidate(); + cameraView.setZoom(cameraZoom); + showZoomControls(true, true); } - zoomControlView.setZoom(cameraZoom, false); - containerView.invalidate(); - cameraView.setZoom(cameraZoom); - showZoomControls(true, true); } } else { float newY = event.getY(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/CallSwipeView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/CallSwipeView.java index de550331f..577293820 100755 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/CallSwipeView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/CallSwipeView.java @@ -17,10 +17,10 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.RectF; -import android.os.Bundle; import android.view.MotionEvent; import android.view.View; -import android.view.accessibility.AccessibilityNodeInfo; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.BuildVars; @@ -28,6 +28,8 @@ import org.telegram.messenger.FileLog; import java.util.ArrayList; +import androidx.annotation.Keep; + public class CallSwipeView extends View { private Paint arrowsPaint, pullBgPaint; @@ -48,6 +50,7 @@ public class CallSwipeView extends View { } private void init() { + setClickable(true); arrowsPaint = new Paint(Paint.ANTI_ALIAS_FLAG); arrowsPaint.setColor(0xFFFFFFFF); arrowsPaint.setStyle(Paint.Style.STROKE); @@ -131,8 +134,10 @@ public class CallSwipeView extends View { @Override public boolean onTouchEvent(MotionEvent ev) { - if (!isEnabled()) - return false; + AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); + if (!isEnabled() || am.isTouchExplorationEnabled()) { + return super.onTouchEvent(ev); + } if (ev.getAction() == MotionEvent.ACTION_DOWN) { if ((!dragFromRight && ev.getX() < getDraggedViewWidth()) || (dragFromRight && ev.getX() > getWidth() - getDraggedViewWidth())) { dragging = true; @@ -163,8 +168,9 @@ public class CallSwipeView extends View { } public void startAnimatingArrows() { - if (animatingArrows || arrowAnim == null) + if (animatingArrows || arrowAnim == null) { return; + } animatingArrows = true; if (arrowAnim != null) { arrowAnim.start(); @@ -227,17 +233,11 @@ public class CallSwipeView extends View { } @Override - public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info){ - super.onInitializeAccessibilityNodeInfo(info); - info.addAction(AccessibilityNodeInfo.ACTION_CLICK); - } - - @Override - public boolean performAccessibilityAction(int action, Bundle arguments){ - if(action==AccessibilityNodeInfo.ACTION_CLICK && isEnabled()){ + public void onPopulateAccessibilityEvent(AccessibilityEvent ev) { + if (isEnabled() && ev.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) { listener.onDragComplete(); } - return super.performAccessibilityAction(action, arguments); + super.onPopulateAccessibilityEvent(ev); } public interface Listener { @@ -254,10 +254,12 @@ public class CallSwipeView extends View { index = value; } + @Keep public int getArrowAlpha() { return arrowAlphas[index]; } + @Keep public void setArrowAlpha(int value) { arrowAlphas[index] = value; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java index f030e27b9..05525954f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java @@ -772,7 +772,7 @@ public class DataUsageActivity extends BaseFragment { } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) { textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true); } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) { - textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position != totalBytesReceivedRow); + textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position == callsBytesReceivedRow); } } break; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 3027c0672..072481686 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -2567,7 +2567,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa fragment = null; } - if (contactsToSend != null && contactsToSend.size() == 1) { + if (contactsToSend != null && contactsToSend.size() == 1 && !mainFragmentsStack.isEmpty()) { PhonebookShareAlert alert = new PhonebookShareAlert(mainFragmentsStack.get(mainFragmentsStack.size() - 1), null, null, contactsToSendUri, null, null); alert.setDelegate((user, notify, scheduleDate) -> { if (fragment != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsCustomSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsCustomSettingsActivity.java index f02f44e94..394b98eff 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsCustomSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsCustomSettingsActivity.java @@ -1261,13 +1261,13 @@ public class NotificationsCustomSettingsActivity extends BaseFragment { value = preferences.getInt("priority_channel", 1); } if (value == 0) { - textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), true); + textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), false); } else if (value == 1 || value == 2) { - textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityUrgent", R.string.NotificationsPriorityUrgent), true); + textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityUrgent", R.string.NotificationsPriorityUrgent), false); } else if (value == 4) { - textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityLow", R.string.NotificationsPriorityLow), true); + textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityLow", R.string.NotificationsPriorityLow), false); } else if (value == 5) { - textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityMedium", R.string.NotificationsPriorityMedium), true); + textCell.setTextAndValue(LocaleController.getString("NotificationsImportance", R.string.NotificationsImportance), LocaleController.getString("NotificationsPriorityMedium", R.string.NotificationsPriorityMedium), false); } } else if (position == messagePopupNotificationRow) { int option; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 7e59553ed..2bd42e314 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -7198,11 +7198,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); layoutParams.width = (int) drawRegion.width(); layoutParams.height = (int) drawRegion.height(); - if (layoutParams.width == 0) { - layoutParams.width = 1; + if (layoutParams.width <= 0) { + layoutParams.width = 100; } - if (layoutParams.height == 0) { - layoutParams.height = 1; + if (layoutParams.height <= 0) { + layoutParams.height = 100; } for (int i = 0; i < animatingImageViews.length; i++) { @@ -7570,11 +7570,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animatingImageViews[i].setImageBitmap(centerImage.getBitmapSafe()); } } - if (layoutParams.width == 0) { - layoutParams.width = 1; + if (layoutParams.width <= 0) { + layoutParams.width = 100; } - if (layoutParams.height == 0) { - layoutParams.height = 1; + if (layoutParams.height <= 0) { + layoutParams.height = 100; } float scaleX = (float) windowView.getMeasuredWidth() / layoutParams.width; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 624136923..7025d7756 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -2771,6 +2771,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. int voiceRowPrev = voiceRow; int groupsInCommonRowPrev = groupsInCommonRow; int sharedSectionRowPrev = sharedSectionRow; + int itemsCount = rowCount; updateRowsIds(); if (sharedHeaderRowPrev == -1 && sharedHeaderRow != -1) { int newRowsCount = 2; @@ -2839,6 +2840,27 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else if (groupsInCommonRowPrev != -1 && groupsInCommonRow == -1) { listAdapter.notifyItemRemoved(groupsInCommonRowPrev); } + } else if (sharedHeaderRowPrev != -1 && sharedHeaderRow == -1) { + int newRowsCountPrev = 2; + if (photosRowPrev != -1) { + newRowsCountPrev++; + } + if (filesRowPrev != -1) { + newRowsCountPrev++; + } + if (linksRowPrev != -1) { + newRowsCountPrev++; + } + if (audioRowPrev != -1) { + newRowsCountPrev++; + } + if (voiceRowPrev != -1) { + newRowsCountPrev++; + } + if (groupsInCommonRowPrev != -1) { + newRowsCountPrev++; + } + listAdapter.notifyItemRangeChanged(sharedHeaderRowPrev, newRowsCountPrev); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/QuickRepliesSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/QuickRepliesSettingsActivity.java index 67bb21b82..3b451bbd6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/QuickRepliesSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/QuickRepliesSettingsActivity.java @@ -165,7 +165,7 @@ public class QuickRepliesSettingsActivity extends BaseFragment { settingsKey = "quick_reply_msg4"; defValue = LocaleController.getString("QuickReplyDefault4", R.string.QuickReplyDefault4); } - textCell.setTextAndHint(getParentActivity().getSharedPreferences("mainconfig", Context.MODE_PRIVATE).getString(settingsKey, ""), defValue, true); + textCell.setTextAndHint(getParentActivity().getSharedPreferences("mainconfig", Context.MODE_PRIVATE).getString(settingsKey, ""), defValue, position != reply4Row); break; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TextSelectionHint.java b/TMessagesProj/src/main/java/org/telegram/ui/TextSelectionHint.java index 03c37c4dd..f820e3152 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TextSelectionHint.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TextSelectionHint.java @@ -76,7 +76,7 @@ class TextSelectionHint extends View { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - if (getMeasuredWidth() != lastW) { + if (getMeasuredWidth() != lastW || textLayout == null) { if (a != null) { a.removeAllListeners(); a.cancel(); @@ -144,6 +144,9 @@ class TextSelectionHint extends View { @Override protected void onDraw(Canvas canvas) { + if (textLayout == null) { + return; + } super.onDraw(canvas); canvas.save(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java index b25d9b872..259f26c46 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java @@ -1732,7 +1732,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No } else if (position == nightScheduledRow) { typeCell.setValue(LocaleController.getString("AutoNightScheduled", R.string.AutoNightScheduled), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SCHEDULED, true); } else if (position == nightAutomaticRow) { - typeCell.setValue(LocaleController.getString("AutoNightAdaptive", R.string.AutoNightAdaptive), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_AUTOMATIC, true); + typeCell.setValue(LocaleController.getString("AutoNightAdaptive", R.string.AutoNightAdaptive), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_AUTOMATIC, nightSystemDefaultRow != -1); } else if (position == nightSystemDefaultRow) { typeCell.setValue(LocaleController.getString("AutoNightSystemDefault", R.string.AutoNightSystemDefault), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SYSTEM, false); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/VoIPActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/VoIPActivity.java index ec47938d6..6fbb4ca53 100755 --- a/TMessagesProj/src/main/java/org/telegram/ui/VoIPActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/VoIPActivity.java @@ -1245,6 +1245,7 @@ public class VoIPActivity extends Activity implements VoIPService.StateListener, } }, 200); } else if (state == VoIPService.STATE_BUSY) { + endBtn.setContentDescription(LocaleController.getString("CallAgain", R.string.CallAgain)); //endBtn.setEnabled(false); setStateTextAnimated(LocaleController.getString("VoipBusy", R.string.VoipBusy), false); /*stateText.postDelayed(new Runnable() {