Update to 5.13.0 (1820)

Merged some parts of https://github.com/DrKLO/Telegram/pull/1541
This commit is contained in:
DrKLO 2020-01-01 21:32:12 +03:00
parent cc1dc35742
commit 1eea3ab6f7
25 changed files with 206 additions and 105 deletions

View file

@ -57,6 +57,9 @@ void reuse(JNIEnv *env, jclass c, jlong address) {
jobject getJavaByteBuffer(JNIEnv *env, jclass c, jlong address) { jobject getJavaByteBuffer(JNIEnv *env, jclass c, jlong address) {
NativeByteBuffer *buffer = (NativeByteBuffer *) (intptr_t) address; NativeByteBuffer *buffer = (NativeByteBuffer *) (intptr_t) address;
if (buffer == nullptr) {
return nullptr;
}
return buffer->getJavaByteBuffer(); return buffer->getJavaByteBuffer();
} }

View file

@ -2018,9 +2018,8 @@ void ConnectionsManager::requestSaltsForDatacenter(Datacenter *datacenter, bool
if (iter != requestingSaltsForDc.end()) { if (iter != requestingSaltsForDc.end()) {
requestingSaltsForDc.erase(iter); requestingSaltsForDc.erase(iter);
} }
if (error == nullptr) { if (response != nullptr) {
TL_future_salts *res = (TL_future_salts *) response; datacenter->mergeServerSalts((TL_future_salts *) response, media);
datacenter->mergeServerSalts(res->salts, media);
saveConfig(); saveConfig();
} }
}, nullptr, RequestFlagWithoutLogin | RequestFlagEnableUnauthorized | RequestFlagUseUnboundKey, datacenter->getDatacenterId(), connectionType, true); }, nullptr, RequestFlagWithoutLogin | RequestFlagEnableUnauthorized | RequestFlagUseUnboundKey, datacenter->getDatacenterId(), connectionType, true);

View file

@ -681,8 +681,8 @@ int64_t Datacenter::getServerSalt(bool media) {
return result; return result;
} }
void Datacenter::mergeServerSalts(std::vector<std::unique_ptr<TL_future_salt>> &newSalts, bool media) { void Datacenter::mergeServerSalts(TL_future_salts *futureSalts, bool media) {
if (newSalts.empty()) { if (futureSalts->salts.empty()) {
return; return;
} }
std::vector<std::unique_ptr<TL_future_salt>> &salts = media ? mediaServerSalts : serverSalts; std::vector<std::unique_ptr<TL_future_salt>> &salts = media ? mediaServerSalts : serverSalts;
@ -694,11 +694,11 @@ void Datacenter::mergeServerSalts(std::vector<std::unique_ptr<TL_future_salt>> &
existingSalts.push_back(salts[a]->salt); existingSalts.push_back(salts[a]->salt);
} }
bool added = false; bool added = false;
size = newSalts.size(); size = futureSalts->salts.size();
for (uint32_t a = 0; a < size; a++) { for (uint32_t a = 0; a < size; a++) {
int64_t value = newSalts[a]->salt; int64_t value = futureSalts->salts[a]->salt;
if (std::find(existingSalts.begin(), existingSalts.end(), value) == existingSalts.end() && newSalts[a]->valid_until > date) { if (std::find(existingSalts.begin(), existingSalts.end(), value) == existingSalts.end() && futureSalts->salts[a]->valid_until > date) {
salts.push_back(std::unique_ptr<TL_future_salt>(std::move(newSalts[a]))); salts.push_back(std::unique_ptr<TL_future_salt>(std::move(futureSalts->salts[a])));
added = true; added = true;
} }
} }

View file

@ -18,6 +18,7 @@ class TL_future_salt;
class Connection; class Connection;
class NativeByteBuffer; class NativeByteBuffer;
class TL_future_salt; class TL_future_salt;
class TL_future_salts;
class TL_help_configSimple; class TL_help_configSimple;
class ByteArray; class ByteArray;
class TLObject; class TLObject;
@ -41,7 +42,7 @@ public:
void clearAuthKey(HandshakeType type); void clearAuthKey(HandshakeType type);
void clearServerSalts(bool media); void clearServerSalts(bool media);
int64_t getServerSalt(bool media); int64_t getServerSalt(bool media);
void mergeServerSalts(std::vector<std::unique_ptr<TL_future_salt>> &newSalts, bool media); void mergeServerSalts(TL_future_salts *newSalts, bool media);
void addServerSalt(std::unique_ptr<TL_future_salt> &serverSalt, bool media); void addServerSalt(std::unique_ptr<TL_future_salt> &serverSalt, bool media);
bool containsServerSalt(int64_t value, bool media); bool containsServerSalt(int64_t value, bool media);
void suspendConnections(bool suspendPush); void suspendConnections(bool suspendPush);

View file

@ -19,7 +19,7 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean TON_WALLET_STANDALONE = false; 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 String BUILD_VERSION_STRING = "5.13.0";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -1601,7 +1601,7 @@ public class FileLoadOperation {
} }
protected void startDownloadRequest() { protected void startDownloadRequest() {
if (paused || if (paused || reuploadingCdn ||
state != stateDownloading || state != stateDownloading ||
streamPriorityStartOffset == 0 && ( streamPriorityStartOffset == 0 && (
!nextPartWasPreloaded && (requestInfos.size() + delayedRequestInfos.size() >= currentMaxDownloadRequests) || !nextPartWasPreloaded && (requestInfos.size() + delayedRequestInfos.size() >= currentMaxDownloadRequests) ||

View file

@ -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_1080 = 6800_000;
public final static int VIDEO_BITRATE_720 = 2621_440; public final static int VIDEO_BITRATE_720 = 2621_440;
public final static int VIDEO_BITRATE_480 = 1000_000; 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 float[] linearAcceleration = new float[3];
private int hasAudioFocus; private int hasAudioFocus;
private boolean hasRecordAudioFocus;
private boolean callInProgress; private boolean callInProgress;
private int audioFocus = AUDIO_NO_FOCUS_NO_DUCK; private int audioFocus = AUDIO_NO_FOCUS_NO_DUCK;
private boolean resumeAudioOnFocusGain; 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_NO_FOCUS_CAN_DUCK = 1;
private static final int AUDIO_FOCUSED = 2; private static final int AUDIO_FOCUSED = 2;
private ArrayList<MessageObject> 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<VideoConvertMessage> videoConvertQueue = new ArrayList<>();
private final Object videoQueueSync = new Object(); private final Object videoQueueSync = new Object();
private HashMap<String, MessageObject> generatingWaveform = new HashMap<>(); private HashMap<String, MessageObject> generatingWaveform = new HashMap<>();
@ -2821,7 +2840,13 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
boolean paused = false; boolean paused = false;
if (playingMessageObject != null && isPlayingMessage(playingMessageObject) && !isMessagePaused()) { if (playingMessageObject != null && isPlayingMessage(playingMessageObject) && !isMessagePaused()) {
paused = true; 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 { try {
@ -2960,12 +2985,20 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.audioRecordTooShort, recordingGuid, false); NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.audioRecordTooShort, recordingGuid, false);
recordingAudioFileToSend.delete(); recordingAudioFileToSend.delete();
} }
if (hasRecordAudioFocus) {
NotificationsController.audioManager.abandonAudioFocus(audioRecordFocusChangedListener);
hasRecordAudioFocus = false;
}
}); });
}); });
} else { } else {
if (recordingAudioFile != null) { if (recordingAudioFile != null) {
recordingAudioFile.delete(); recordingAudioFile.delete();
} }
if (hasRecordAudioFocus) {
NotificationsController.audioManager.abandonAudioFocus(audioRecordFocusChangedListener);
hasRecordAudioFocus = false;
}
} }
try { try {
if (audioRecorder != null) { if (audioRecorder != null) {
@ -3490,7 +3523,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} else if (isEmpty) { } else if (isEmpty) {
new File(messageObject.messageOwner.attachPath).delete(); new File(messageObject.messageOwner.attachPath).delete();
} }
videoConvertQueue.add(messageObject); videoConvertQueue.add(new VideoConvertMessage(messageObject, messageObject.videoEditedInfo));
if (videoConvertQueue.size() == 1) { if (videoConvertQueue.size() == 1) {
startVideoConvertFromQueue(); startVideoConvertFromQueue();
} }
@ -3501,11 +3534,12 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
if (messageObject != null) { if (messageObject != null) {
if (!videoConvertQueue.isEmpty()) { if (!videoConvertQueue.isEmpty()) {
for (int a = 0; a < videoConvertQueue.size(); a++) { for (int a = 0; a < videoConvertQueue.size(); a++) {
MessageObject object = videoConvertQueue.get(a); VideoConvertMessage videoConvertMessage = videoConvertQueue.get(a);
if (object.getId() == messageObject.getId() && object.currentAccount == messageObject.currentAccount) { MessageObject object = videoConvertMessage.messageObject;
if (object.equals(messageObject) && object.currentAccount == messageObject.currentAccount) {
if (a == 0) { if (a == 0) {
synchronized (videoConvertSync) { synchronized (videoConvertSync) {
messageObject.videoEditedInfo.canceled = true; videoConvertMessage.videoEditedInfo.canceled = true;
} }
} else { } else {
videoConvertQueue.remove(a); videoConvertQueue.remove(a);
@ -3519,10 +3553,12 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
private boolean startVideoConvertFromQueue() { private boolean startVideoConvertFromQueue() {
if (!videoConvertQueue.isEmpty()) { if (!videoConvertQueue.isEmpty()) {
MessageObject messageObject = videoConvertQueue.get(0); VideoConvertMessage videoConvertMessage = videoConvertQueue.get(0);
MessageObject messageObject = videoConvertMessage.messageObject;
VideoEditedInfo videoEditedInfo = videoConvertMessage.videoEditedInfo;
synchronized (videoConvertSync) { synchronized (videoConvertSync) {
if (messageObject != null && messageObject.videoEditedInfo != null) { if (videoEditedInfo != null) {
messageObject.videoEditedInfo.canceled = false; videoEditedInfo.canceled = false;
} }
} }
Intent intent = new Intent(ApplicationLoader.applicationContext, VideoEncodingService.class); Intent intent = new Intent(ApplicationLoader.applicationContext, VideoEncodingService.class);
@ -3544,7 +3580,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
FileLog.e(e); FileLog.e(e);
} }
} }
VideoConvertRunnable.runConversion(messageObject); VideoConvertRunnable.runConversion(videoConvertMessage);
return true; return true;
} }
return false; return false;
@ -3624,44 +3660,44 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
return -5; return -5;
} }
private void didWriteData(final MessageObject messageObject, final File file, final boolean last, long availableSize, final boolean error, final float progress) { private void didWriteData(final VideoConvertMessage message, final File file, final boolean last, long availableSize, final boolean error, final float progress) {
final boolean firstWrite = messageObject.videoEditedInfo.videoConvertFirstWrite; final boolean firstWrite = message.videoEditedInfo.videoConvertFirstWrite;
if (firstWrite) { if (firstWrite) {
messageObject.videoEditedInfo.videoConvertFirstWrite = false; message.videoEditedInfo.videoConvertFirstWrite = false;
} }
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
if (error || last) { if (error || last) {
synchronized (videoConvertSync) { synchronized (videoConvertSync) {
messageObject.videoEditedInfo.canceled = false; message.videoEditedInfo.canceled = false;
} }
videoConvertQueue.remove(messageObject); videoConvertQueue.remove(message);
startVideoConvertFromQueue(); startVideoConvertFromQueue();
} }
if (error) { 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 { } else {
if (firstWrite) { 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 static class VideoConvertRunnable implements Runnable {
private MessageObject messageObject; private VideoConvertMessage convertMessage;
private VideoConvertRunnable(MessageObject message) { private VideoConvertRunnable(VideoConvertMessage message) {
messageObject = message; convertMessage = message;
} }
@Override @Override
public void run() { 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(() -> { new Thread(() -> {
try { try {
VideoConvertRunnable wrapper = new VideoConvertRunnable(obj); VideoConvertRunnable wrapper = new VideoConvertRunnable(obj);
@ -3676,8 +3712,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
private boolean convertVideo(final MessageObject messageObject) { private boolean convertVideo(final VideoConvertMessage convertMessage) {
VideoEditedInfo info = messageObject.videoEditedInfo; MessageObject messageObject = convertMessage.messageObject;
VideoEditedInfo info = convertMessage.videoEditedInfo;
if (messageObject == null || info == null) { if (messageObject == null || info == null) {
return false; return false;
} }
@ -3767,7 +3804,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
lastAvailableSize = availableSize; 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(); 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; return true;
} }

View file

@ -1781,9 +1781,11 @@ public class MediaDataController extends BaseController {
searchResultMessagesMap[0].clear(); searchResultMessagesMap[0].clear();
searchResultMessagesMap[1].clear(); searchResultMessagesMap[1].clear();
messagesSearchCount[0] = 0; messagesSearchCount[0] = 0;
getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsLoading, guid);
} }
boolean added = false; 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); TLRPC.Message message = res.messages.get(a);
added = true; added = true;
MessageObject messageObject = new MessageObject(currentAccount, message, false); MessageObject messageObject = new MessageObject(currentAccount, message, false);

View file

@ -5520,10 +5520,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
} }
public static String getKeyForPhotoSize(TLRPC.PhotoSize photoSize, Bitmap[] bitmap, boolean blur, boolean forceCache) { public static String getKeyForPhotoSize(TLRPC.PhotoSize photoSize, Bitmap[] bitmap, boolean blur, boolean forceCache) {
if (photoSize == null) { if (photoSize == null || photoSize.location == null) {
return null; return null;
} }
Point point = ChatMessageCell.getMessageSize(photoSize.w,photoSize.h); Point point = ChatMessageCell.getMessageSize(photoSize.w, photoSize.h);
if (bitmap != null) { if (bitmap != null) {
try { try {

View file

@ -818,7 +818,7 @@ public class SharedConfig {
int androidVersion = Build.VERSION.SDK_INT; int androidVersion = Build.VERSION.SDK_INT;
int cpuCount = ConnectionsManager.CPU_COUNT; int cpuCount = ConnectionsManager.CPU_COUNT;
int memoryClass = ((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); 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; devicePerformanceClass = PERFORMANCE_CLASS_LOW;
} else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 1650 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) { } else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 1650 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) {
devicePerformanceClass = PERFORMANCE_CLASS_AVERAGE; devicePerformanceClass = PERFORMANCE_CLASS_AVERAGE;

View file

@ -171,7 +171,6 @@ public class Theme {
if (gradientColor != 0 && (gradientShader == null || backgroundHeight != currentBackgroundHeight || currentColor != color || currentGradientColor != gradientColor)) { 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); gradientShader = new LinearGradient(0, 0, 0, backgroundHeight, new int[]{gradientColor, color}, null, Shader.TileMode.CLAMP);
paint.setShader(gradientShader); paint.setShader(gradientShader);
currentBackgroundHeight = backgroundHeight;
currentColor = color; currentColor = color;
currentGradientColor = gradientColor; currentGradientColor = gradientColor;
paint.setColor(0xffffffff); paint.setColor(0xffffffff);
@ -182,6 +181,7 @@ public class Theme {
} }
paint.setColor(color); paint.setColor(color);
} }
currentBackgroundHeight = backgroundHeight;
topY = top; topY = top;
} }
@ -215,19 +215,33 @@ public class Theme {
} }
} else { } else {
path.reset(); path.reset();
path.moveTo(bounds.right - dp(2.6f), bounds.bottom - padding); if (topY + bounds.bottom - rad < currentBackgroundHeight) {
path.lineTo(bounds.left + padding + rad, bounds.bottom - padding); path.moveTo(bounds.right - dp(2.6f), bounds.bottom - padding);
rect.set(bounds.left + padding, bounds.bottom - padding - rad * 2, bounds.left + padding + rad * 2, bounds.bottom - padding); path.lineTo(bounds.left + padding + rad, bounds.bottom - padding);
path.arcTo(rect, 90, 90, false); rect.set(bounds.left + padding, bounds.bottom - padding - rad * 2, bounds.left + padding + rad * 2, bounds.bottom - padding);
path.lineTo(bounds.left + padding, bounds.top + padding + rad); path.arcTo(rect, 90, 90, false);
rect.set(bounds.left + padding, bounds.top + padding, bounds.left + padding + rad * 2, bounds.top + padding + rad * 2); } else {
path.arcTo(rect, 180, 90, false); path.moveTo(bounds.right - dp(8), bounds.top - topY + currentBackgroundHeight);
path.lineTo(bounds.right - dp(8) - rad, bounds.top + padding); path.lineTo(bounds.left + padding, bounds.top - topY + currentBackgroundHeight);
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); if (topY + rad * 2 >= 0) {
path.lineTo(bounds.right - dp(8), bounds.bottom - padding - rad - dp(1)); path.lineTo(bounds.left + padding, bounds.top + padding + rad);
rect.set(bounds.right - dp(8), bounds.bottom - padding - rad * 2 - dp(9), bounds.right - dp(7) + rad * 2, bounds.bottom - padding - dp(1)); rect.set(bounds.left + padding, bounds.top + padding, bounds.left + padding + rad * 2, bounds.top + padding + rad * 2);
path.arcTo(rect, 180, -83, false); 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(); path.close();
canvas.drawPath(path, paint); canvas.drawPath(path, paint);
@ -3756,11 +3770,11 @@ public class Theme {
if (preferences.contains("overrideThemeWallpaper") || preferences.contains("selectedBackground2")) { if (preferences.contains("overrideThemeWallpaper") || preferences.contains("selectedBackground2")) {
boolean override = preferences.getBoolean("overrideThemeWallpaper", false); boolean override = preferences.getBoolean("overrideThemeWallpaper", false);
long id = preferences.getLong("selectedBackground2", 1000001); long id = preferences.getLong("selectedBackground2", 1000001);
if (id != -2 && (override || id != 1000001)) { if (id == -1 || override && id != -2 && id != 1000001) {
OverrideWallpaperInfo overrideWallpaper = new OverrideWallpaperInfo(); OverrideWallpaperInfo overrideWallpaper = new OverrideWallpaperInfo();
overrideWallpaper.color = preferences.getInt("selectedColor", 0); overrideWallpaper.color = preferences.getInt("selectedColor", 0);
overrideWallpaper.slug = preferences.getString("selectedBackgroundSlug", ""); 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.slug = COLOR_BACKGROUND_SLUG;
overrideWallpaper.fileName = ""; overrideWallpaper.fileName = "";
overrideWallpaper.originalFileName = ""; overrideWallpaper.originalFileName = "";

View file

@ -849,7 +849,9 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
@Override @Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
imageUpdater.onActivityResult(requestCode, resultCode, data); if (imageUpdater != null) {
imageUpdater.onActivityResult(requestCode, resultCode, data);
}
} }
@Override @Override

View file

@ -1520,6 +1520,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
searchItem.setVisibility(View.GONE); searchItem.setVisibility(View.GONE);
getMediaDataController().clearFoundMessageObjects(); getMediaDataController().clearFoundMessageObjects();
if (messagesSearchAdapter != null) {
messagesSearchAdapter.notifyDataSetChanged();
}
removeSelectedMessageHighlight(); removeSelectedMessageHighlight();
updateBottomOverlay(); updateBottomOverlay();
updatePinnedMessageView(true); updatePinnedMessageView(true);
@ -6010,6 +6013,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
private void showTextSelectionHint(MessageObject messageObject) { private void showTextSelectionHint(MessageObject messageObject) {
if (getParentActivity() == null) {
return;
}
CharSequence text; CharSequence text;
boolean canShowText = false; boolean canShowText = false;
if (messageObject.textLayoutBlocks != null && !messageObject.textLayoutBlocks.isEmpty()) { if (messageObject.textLayoutBlocks != null && !messageObject.textLayoutBlocks.isEmpty()) {
@ -11308,8 +11314,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
} else if (id == NotificationCenter.chatSearchResultsLoading) { } else if (id == NotificationCenter.chatSearchResultsLoading) {
if (classGuid == (Integer) args[0] && searchItem != null) { if (classGuid == (Integer) args[0]) {
searchItem.setShowSearchProgress(true); if (searchItem != null) {
searchItem.setShowSearchProgress(true);
}
if (messagesSearchAdapter != null) { if (messagesSearchAdapter != null) {
messagesSearchAdapter.notifyDataSetChanged(); messagesSearchAdapter.notifyDataSetChanged();
} }

View file

@ -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)); sendButton.setBackgroundDrawable(Theme.createSelectorDrawable(Color.argb(24, Color.red(color), Color.green(color), Color.blue(color)), 1));
} }
sendButtonContainer.addView(sendButton, LayoutHelper.createFrame(48, 48)); 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); sendButton.setOnLongClickListener(this::onSendLongClick);
slowModeButton = new SimpleTextView(context); slowModeButton = new SimpleTextView(context);

View file

@ -2269,18 +2269,20 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
zoomWas = true; zoomWas = true;
} }
} else { } else {
float diff = (newDistance - pinchStartDistance) / AndroidUtilities.dp(100); if (cameraView != null) {
pinchStartDistance = newDistance; float diff = (newDistance - pinchStartDistance) / AndroidUtilities.dp(100);
cameraZoom += diff; pinchStartDistance = newDistance;
if (cameraZoom < 0.0f) { cameraZoom += diff;
cameraZoom = 0.0f; if (cameraZoom < 0.0f) {
} else if (cameraZoom > 1.0f) { cameraZoom = 0.0f;
cameraZoom = 1.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 { } else {
float newY = event.getY(); float newY = event.getY();

View file

@ -17,10 +17,10 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.RectF; import android.graphics.RectF;
import android.os.Bundle;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; 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.AndroidUtilities;
import org.telegram.messenger.BuildVars; import org.telegram.messenger.BuildVars;
@ -28,6 +28,8 @@ import org.telegram.messenger.FileLog;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.annotation.Keep;
public class CallSwipeView extends View { public class CallSwipeView extends View {
private Paint arrowsPaint, pullBgPaint; private Paint arrowsPaint, pullBgPaint;
@ -48,6 +50,7 @@ public class CallSwipeView extends View {
} }
private void init() { private void init() {
setClickable(true);
arrowsPaint = new Paint(Paint.ANTI_ALIAS_FLAG); arrowsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
arrowsPaint.setColor(0xFFFFFFFF); arrowsPaint.setColor(0xFFFFFFFF);
arrowsPaint.setStyle(Paint.Style.STROKE); arrowsPaint.setStyle(Paint.Style.STROKE);
@ -131,8 +134,10 @@ public class CallSwipeView extends View {
@Override @Override
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
if (!isEnabled()) AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
return false; if (!isEnabled() || am.isTouchExplorationEnabled()) {
return super.onTouchEvent(ev);
}
if (ev.getAction() == MotionEvent.ACTION_DOWN) { if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if ((!dragFromRight && ev.getX() < getDraggedViewWidth()) || (dragFromRight && ev.getX() > getWidth() - getDraggedViewWidth())) { if ((!dragFromRight && ev.getX() < getDraggedViewWidth()) || (dragFromRight && ev.getX() > getWidth() - getDraggedViewWidth())) {
dragging = true; dragging = true;
@ -163,8 +168,9 @@ public class CallSwipeView extends View {
} }
public void startAnimatingArrows() { public void startAnimatingArrows() {
if (animatingArrows || arrowAnim == null) if (animatingArrows || arrowAnim == null) {
return; return;
}
animatingArrows = true; animatingArrows = true;
if (arrowAnim != null) { if (arrowAnim != null) {
arrowAnim.start(); arrowAnim.start();
@ -227,17 +233,11 @@ public class CallSwipeView extends View {
} }
@Override @Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info){ public void onPopulateAccessibilityEvent(AccessibilityEvent ev) {
super.onInitializeAccessibilityNodeInfo(info); if (isEnabled() && ev.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) {
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
}
@Override
public boolean performAccessibilityAction(int action, Bundle arguments){
if(action==AccessibilityNodeInfo.ACTION_CLICK && isEnabled()){
listener.onDragComplete(); listener.onDragComplete();
} }
return super.performAccessibilityAction(action, arguments); super.onPopulateAccessibilityEvent(ev);
} }
public interface Listener { public interface Listener {
@ -254,10 +254,12 @@ public class CallSwipeView extends View {
index = value; index = value;
} }
@Keep
public int getArrowAlpha() { public int getArrowAlpha() {
return arrowAlphas[index]; return arrowAlphas[index];
} }
@Keep
public void setArrowAlpha(int value) { public void setArrowAlpha(int value) {
arrowAlphas[index] = value; arrowAlphas[index] = value;
} }

View file

@ -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) { } 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); 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) { } 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; break;

View file

@ -2567,7 +2567,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
fragment = null; 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); PhonebookShareAlert alert = new PhonebookShareAlert(mainFragmentsStack.get(mainFragmentsStack.size() - 1), null, null, contactsToSendUri, null, null);
alert.setDelegate((user, notify, scheduleDate) -> { alert.setDelegate((user, notify, scheduleDate) -> {
if (fragment != null) { if (fragment != null) {

View file

@ -1261,13 +1261,13 @@ public class NotificationsCustomSettingsActivity extends BaseFragment {
value = preferences.getInt("priority_channel", 1); value = preferences.getInt("priority_channel", 1);
} }
if (value == 0) { 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) { } 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) { } 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) { } 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) { } else if (position == messagePopupNotificationRow) {
int option; int option;

View file

@ -7198,11 +7198,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams();
layoutParams.width = (int) drawRegion.width(); layoutParams.width = (int) drawRegion.width();
layoutParams.height = (int) drawRegion.height(); layoutParams.height = (int) drawRegion.height();
if (layoutParams.width == 0) { if (layoutParams.width <= 0) {
layoutParams.width = 1; layoutParams.width = 100;
} }
if (layoutParams.height == 0) { if (layoutParams.height <= 0) {
layoutParams.height = 1; layoutParams.height = 100;
} }
for (int i = 0; i < animatingImageViews.length; i++) { for (int i = 0; i < animatingImageViews.length; i++) {
@ -7570,11 +7570,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
animatingImageViews[i].setImageBitmap(centerImage.getBitmapSafe()); animatingImageViews[i].setImageBitmap(centerImage.getBitmapSafe());
} }
} }
if (layoutParams.width == 0) { if (layoutParams.width <= 0) {
layoutParams.width = 1; layoutParams.width = 100;
} }
if (layoutParams.height == 0) { if (layoutParams.height <= 0) {
layoutParams.height = 1; layoutParams.height = 100;
} }
float scaleX = (float) windowView.getMeasuredWidth() / layoutParams.width; float scaleX = (float) windowView.getMeasuredWidth() / layoutParams.width;

View file

@ -2771,6 +2771,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
int voiceRowPrev = voiceRow; int voiceRowPrev = voiceRow;
int groupsInCommonRowPrev = groupsInCommonRow; int groupsInCommonRowPrev = groupsInCommonRow;
int sharedSectionRowPrev = sharedSectionRow; int sharedSectionRowPrev = sharedSectionRow;
int itemsCount = rowCount;
updateRowsIds(); updateRowsIds();
if (sharedHeaderRowPrev == -1 && sharedHeaderRow != -1) { if (sharedHeaderRowPrev == -1 && sharedHeaderRow != -1) {
int newRowsCount = 2; int newRowsCount = 2;
@ -2839,6 +2840,27 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else if (groupsInCommonRowPrev != -1 && groupsInCommonRow == -1) { } else if (groupsInCommonRowPrev != -1 && groupsInCommonRow == -1) {
listAdapter.notifyItemRemoved(groupsInCommonRowPrev); 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);
} }
} }

View file

@ -165,7 +165,7 @@ public class QuickRepliesSettingsActivity extends BaseFragment {
settingsKey = "quick_reply_msg4"; settingsKey = "quick_reply_msg4";
defValue = LocaleController.getString("QuickReplyDefault4", R.string.QuickReplyDefault4); 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; break;
} }

View file

@ -76,7 +76,7 @@ class TextSelectionHint extends View {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (getMeasuredWidth() != lastW) { if (getMeasuredWidth() != lastW || textLayout == null) {
if (a != null) { if (a != null) {
a.removeAllListeners(); a.removeAllListeners();
a.cancel(); a.cancel();
@ -144,6 +144,9 @@ class TextSelectionHint extends View {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
if (textLayout == null) {
return;
}
super.onDraw(canvas); super.onDraw(canvas);
canvas.save(); canvas.save();

View file

@ -1732,7 +1732,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No
} else if (position == nightScheduledRow) { } else if (position == nightScheduledRow) {
typeCell.setValue(LocaleController.getString("AutoNightScheduled", R.string.AutoNightScheduled), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SCHEDULED, true); typeCell.setValue(LocaleController.getString("AutoNightScheduled", R.string.AutoNightScheduled), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SCHEDULED, true);
} else if (position == nightAutomaticRow) { } 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) { } else if (position == nightSystemDefaultRow) {
typeCell.setValue(LocaleController.getString("AutoNightSystemDefault", R.string.AutoNightSystemDefault), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SYSTEM, false); typeCell.setValue(LocaleController.getString("AutoNightSystemDefault", R.string.AutoNightSystemDefault), Theme.selectedAutoNightType == Theme.AUTO_NIGHT_TYPE_SYSTEM, false);
} }

View file

@ -1245,6 +1245,7 @@ public class VoIPActivity extends Activity implements VoIPService.StateListener,
} }
}, 200); }, 200);
} else if (state == VoIPService.STATE_BUSY) { } else if (state == VoIPService.STATE_BUSY) {
endBtn.setContentDescription(LocaleController.getString("CallAgain", R.string.CallAgain));
//endBtn.setEnabled(false); //endBtn.setEnabled(false);
setStateTextAnimated(LocaleController.getString("VoipBusy", R.string.VoipBusy), false); setStateTextAnimated(LocaleController.getString("VoipBusy", R.string.VoipBusy), false);
/*stateText.postDelayed(new Runnable() { /*stateText.postDelayed(new Runnable() {