Update to 5.13.0 (1819)

This commit is contained in:
DrKLO 2019-12-31 22:46:59 +03:00
parent 471ed12003
commit cc1dc35742
24 changed files with 175 additions and 120 deletions

View file

@ -283,7 +283,7 @@ android {
} }
} }
defaultConfig.versionCode = 1818 defaultConfig.versionCode = 1819
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->

View file

@ -1440,10 +1440,11 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
TL_bad_server_salt *response = (TL_bad_server_salt *) message; TL_bad_server_salt *response = (TL_bad_server_salt *) message;
int64_t resultMid = response->bad_msg_id; int64_t resultMid = response->bad_msg_id;
if (resultMid != 0) { if (resultMid != 0) {
bool beginHandshake = false;
for (requestsIter iter = runningRequests.begin(); iter != runningRequests.end(); iter++) { for (requestsIter iter = runningRequests.begin(); iter != runningRequests.end(); iter++) {
Request *request = iter->get(); Request *request = iter->get();
if (request->datacenterId == datacenter->datacenterId && typeid(*request->rawRequest) == typeid(TL_auth_bindTempAuthKey) && request->respondsToMessageId(response->bad_msg_id)) { if (!beginHandshake && request->datacenterId == datacenter->datacenterId && typeid(*request->rawRequest) == typeid(TL_auth_bindTempAuthKey) && request->respondsToMessageId(response->bad_msg_id)) {
datacenter->beginHandshake(HandshakeTypeCurrent, false); beginHandshake = true;
} }
if ((request->connectionType & ConnectionTypeDownload) == 0) { if ((request->connectionType & ConnectionTypeDownload) == 0) {
continue; continue;
@ -1454,6 +1455,9 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
request->failedBySalt = true; request->failedBySalt = true;
} }
} }
if (beginHandshake) {
datacenter->beginHandshake(HandshakeTypeCurrent, false);
}
} }
datacenter->clearServerSalts(media); datacenter->clearServerSalts(media);

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 = 1818; public static int BUILD_VERSION = 1819;
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

@ -24,7 +24,7 @@ public class EmojiData {
0x2197, 0x2198, 0x2199, 0x2196, 0x2195, 0x2194, 0x21AA, 0x21A9, 0x2934, 0x2935, 0x2197, 0x2198, 0x2199, 0x2196, 0x2195, 0x2194, 0x21AA, 0x21A9, 0x2934, 0x2935,
0x2139, 0x2714, 0x2716, 0x2611, 0x26AA, 0x26AB, 0x25AA, 0x25AB, 0x2B1B, 0x2B1C, 0x2139, 0x2714, 0x2716, 0x2611, 0x26AA, 0x26AB, 0x25AA, 0x25AB, 0x2B1B, 0x2B1C,
0x25FC, 0x25FB, 0x25FE, 0x25FD, 0x2660, 0x2663, 0x2665, 0x2666, 0x263A, 0x2639, 0x25FC, 0x25FB, 0x25FE, 0x25FD, 0x2660, 0x2663, 0x2665, 0x2666, 0x263A, 0x2639,
0x270C, 0x261D, 0x2764 0x270C, 0x261D, 0x2764, 0x2603
}; };
public static final char[] dataChars = { public static final char[] dataChars = {

View file

@ -1388,7 +1388,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
countLess = 0; countLess = 0;
} else if (proximityTouched) { } else if (proximityTouched) {
if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) { if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) {
if (!useFrontSpeaker && NotificationsController.audioManager.isWiredHeadsetOn()) { if (!useFrontSpeaker && !NotificationsController.audioManager.isWiredHeadsetOn()) {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("start listen by proximity only"); FileLog.d("start listen by proximity only");
} }
@ -3521,8 +3521,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
if (!videoConvertQueue.isEmpty()) { if (!videoConvertQueue.isEmpty()) {
MessageObject messageObject = videoConvertQueue.get(0); MessageObject messageObject = videoConvertQueue.get(0);
synchronized (videoConvertSync) { synchronized (videoConvertSync) {
if (messageObject != null && messageObject.videoEditedInfo != null) {
messageObject.videoEditedInfo.canceled = false; messageObject.videoEditedInfo.canceled = false;
} }
}
Intent intent = new Intent(ApplicationLoader.applicationContext, VideoEncodingService.class); Intent intent = new Intent(ApplicationLoader.applicationContext, VideoEncodingService.class);
intent.putExtra("path", messageObject.messageOwner.attachPath); intent.putExtra("path", messageObject.messageOwner.attachPath);
intent.putExtra("currentAccount", messageObject.currentAccount); intent.putExtra("currentAccount", messageObject.currentAccount);
@ -3675,19 +3677,20 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
private boolean convertVideo(final MessageObject messageObject) { private boolean convertVideo(final MessageObject messageObject) {
if (messageObject == null || messageObject.videoEditedInfo == null) { VideoEditedInfo info = messageObject.videoEditedInfo;
if (messageObject == null || info == null) {
return false; return false;
} }
String videoPath = messageObject.videoEditedInfo.originalPath; String videoPath = info.originalPath;
long startTime = messageObject.videoEditedInfo.startTime; long startTime = info.startTime;
long endTime = messageObject.videoEditedInfo.endTime; long endTime = info.endTime;
int resultWidth = messageObject.videoEditedInfo.resultWidth; int resultWidth = info.resultWidth;
int resultHeight = messageObject.videoEditedInfo.resultHeight; int resultHeight = info.resultHeight;
int rotationValue = messageObject.videoEditedInfo.rotationValue; int rotationValue = info.rotationValue;
int originalWidth = messageObject.videoEditedInfo.originalWidth; int originalWidth = info.originalWidth;
int originalHeight = messageObject.videoEditedInfo.originalHeight; int originalHeight = info.originalHeight;
int framerate = messageObject.videoEditedInfo.framerate; int framerate = info.framerate;
int bitrate = messageObject.videoEditedInfo.bitrate; int bitrate = info.bitrate;
int rotateRender = 0; int rotateRender = 0;
boolean isSecret = ((int) messageObject.getDialogId()) == 0; boolean isSecret = ((int) messageObject.getDialogId()) == 0;
final File cacheFile = new File(messageObject.messageOwner.attachPath); final File cacheFile = new File(messageObject.messageOwner.attachPath);
@ -3705,9 +3708,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} else if (endTime > 0) { } else if (endTime > 0) {
duration = endTime; duration = endTime;
} else if (startTime > 0) { } else if (startTime > 0) {
duration = messageObject.videoEditedInfo.originalDuration - startTime; duration = info.originalDuration - startTime;
} else { } else {
duration = messageObject.videoEditedInfo.originalDuration; duration = info.originalDuration;
} }
if (framerate == 0) { if (framerate == 0) {
@ -3734,7 +3737,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
boolean needCompress = resultWidth != originalWidth || resultHeight != originalHeight || rotateRender != 0 boolean needCompress = resultWidth != originalWidth || resultHeight != originalHeight || rotateRender != 0
|| messageObject.videoEditedInfo.roundVideo || Build.VERSION.SDK_INT >= 18 && startTime != -1; || info.roundVideo || Build.VERSION.SDK_INT >= 18 && startTime != -1;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("videoconvert", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("videoconvert", Activity.MODE_PRIVATE);
@ -3747,17 +3750,19 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
@Override @Override
public boolean checkConversionCanceled() { public boolean checkConversionCanceled() {
return messageObject.videoEditedInfo.canceled; return info.canceled;
} }
@Override @Override
public void didWriteData(long availableSize, float progress) { public void didWriteData(long availableSize, float progress) {
if (messageObject.videoEditedInfo.canceled) return; if (info.canceled) {
return;
}
if (availableSize < 0) { if (availableSize < 0) {
availableSize = cacheFile.length(); availableSize = cacheFile.length();
} }
if (!messageObject.videoEditedInfo.needUpdateProgress && lastAvailableSize == availableSize) { if (!info.needUpdateProgress && lastAvailableSize == availableSize) {
return; return;
} }
@ -3766,7 +3771,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
}; };
messageObject.videoEditedInfo.videoConvertFirstWrite = true; info.videoConvertFirstWrite = true;
MediaCodecVideoConvertor videoConvertor = new MediaCodecVideoConvertor(); MediaCodecVideoConvertor videoConvertor = new MediaCodecVideoConvertor();
boolean error = videoConvertor.convertVideo(videoPath, cacheFile, boolean error = videoConvertor.convertVideo(videoPath, cacheFile,
@ -3778,10 +3783,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
callback); callback);
boolean canceled = messageObject.videoEditedInfo.canceled; boolean canceled = info.canceled;
if (!canceled) { if (!canceled) {
synchronized (videoConvertSync) { synchronized (videoConvertSync) {
canceled = messageObject.videoEditedInfo.canceled; canceled = info.canceled;
} }
} }

View file

@ -3081,7 +3081,7 @@ public class MessageObject {
} }
} }
private static void addUrlsByPattern(boolean isOut, CharSequence charSequence, boolean botCommands, int patternType, int duration) { public static void addUrlsByPattern(boolean isOut, CharSequence charSequence, boolean botCommands, int patternType, int duration) {
try { try {
Matcher matcher; Matcher matcher;
if (patternType == 3 || patternType == 4) { if (patternType == 3 || patternType == 4) {

View file

@ -841,13 +841,14 @@ public class MessagesController extends BaseController implements NotificationCe
TLRPC.TL_account_uploadWallPaper req = new TLRPC.TL_account_uploadWallPaper(); TLRPC.TL_account_uploadWallPaper req = new TLRPC.TL_account_uploadWallPaper();
req.file = file; req.file = file;
req.mime_type = "image/jpeg"; req.mime_type = "image/jpeg";
Theme.OverrideWallpaperInfo overrideWallpaperInfo = uploadingWallpaperInfo;
final TLRPC.TL_wallPaperSettings settings = new TLRPC.TL_wallPaperSettings(); final TLRPC.TL_wallPaperSettings settings = new TLRPC.TL_wallPaperSettings();
settings.blur = uploadingWallpaperInfo.isBlurred; settings.blur = overrideWallpaperInfo.isBlurred;
settings.motion = uploadingWallpaperInfo.isMotion; settings.motion = overrideWallpaperInfo.isMotion;
req.settings = settings; req.settings = settings;
getConnectionsManager().sendRequest(req, (response, error) -> { getConnectionsManager().sendRequest(req, (response, error) -> {
TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) response; TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) response;
File path = new File(ApplicationLoader.getFilesDirFixed(), uploadingWallpaperInfo.originalFileName); File path = new File(ApplicationLoader.getFilesDirFixed(), overrideWallpaperInfo.originalFileName);
if (wallPaper != null) { if (wallPaper != null) {
try { try {
AndroidUtilities.copyFile(path, FileLoader.getPathToAttach(wallPaper.document, true)); AndroidUtilities.copyFile(path, FileLoader.getPathToAttach(wallPaper.document, true));
@ -859,8 +860,8 @@ public class MessagesController extends BaseController implements NotificationCe
if (uploadingWallpaper != null && wallPaper != null) { if (uploadingWallpaper != null && wallPaper != null) {
wallPaper.settings = settings; wallPaper.settings = settings;
wallPaper.flags |= 4; wallPaper.flags |= 4;
uploadingWallpaperInfo.slug = wallPaper.slug; overrideWallpaperInfo.slug = wallPaper.slug;
uploadingWallpaperInfo.saveOverrideWallpaper(); overrideWallpaperInfo.saveOverrideWallpaper();
ArrayList<TLRPC.WallPaper> wallpapers = new ArrayList<>(); ArrayList<TLRPC.WallPaper> wallpapers = new ArrayList<>();
wallpapers.add(wallPaper); wallpapers.add(wallPaper);
getMessagesStorage().putWallpapers(wallpapers, 2); getMessagesStorage().putWallpapers(wallpapers, 2);

View file

@ -290,7 +290,7 @@ public class Browser {
builder.setToolbarColor(Theme.getColor(Theme.key_actionBarBrowser)); builder.setToolbarColor(Theme.getColor(Theme.key_actionBarBrowser));
builder.setShowTitle(true); builder.setShowTitle(true);
builder.setActionButton(BitmapFactory.decodeResource(context.getResources(), R.drawable.abc_ic_menu_share_mtrl_alpha), LocaleController.getString("ShareFile", R.string.ShareFile), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, share, 0), false); builder.setActionButton(BitmapFactory.decodeResource(context.getResources(), R.drawable.abc_ic_menu_share_mtrl_alpha), LocaleController.getString("ShareFile", R.string.ShareFile), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, share, 0), true);
CustomTabsIntent intent = builder.build(); CustomTabsIntent intent = builder.build();
intent.setUseNewTask(); intent.setUseNewTask();
intent.launchUrl(context, uri); intent.launchUrl(context, uri);

View file

@ -177,52 +177,10 @@ public class MediaCodecVideoConvertor {
outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, framerate); outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, framerate);
outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 2); outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 2);
if (Build.VERSION.SDK_INT >= 23) { if (Build.VERSION.SDK_INT < 23 && Math.min(resultHeight, resultWidth) <= 480) {
int profile;
int level;
if (Math.min(resultHeight, resultWidth) >= 1080) {
profile = MediaCodecInfo.CodecProfileLevel.AVCProfileHigh;
level = MediaCodecInfo.CodecProfileLevel.AVCLevel41;
} else if (Math.min(resultHeight, resultWidth) >= 720) {
profile = MediaCodecInfo.CodecProfileLevel.AVCProfileHigh;
level = MediaCodecInfo.CodecProfileLevel.AVCLevel4;
} else if (Math.min(resultHeight, resultWidth) >= 480) {
profile = MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline;
level = MediaCodecInfo.CodecProfileLevel.AVCLevel31;
} else {
profile = MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline;
level = MediaCodecInfo.CodecProfileLevel.AVCLevel3;
}
MediaCodecInfo.CodecCapabilities capabilities = MediaCodecInfo.CodecCapabilities.createFromProfileLevel(MediaController.VIDEO_MIME_TYPE, profile, level);
if (capabilities == null && profile == MediaCodecInfo.CodecProfileLevel.AVCProfileHigh) {
profile = MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline;
capabilities = MediaCodecInfo.CodecCapabilities.createFromProfileLevel(MediaController.VIDEO_MIME_TYPE, profile, level);
}
if (capabilities.getEncoderCapabilities() != null) {
outputFormat.setInteger(MediaFormat.KEY_PROFILE, profile);
outputFormat.setInteger(MediaFormat.KEY_LEVEL, level);
int maxBitrate = capabilities.getVideoCapabilities().getBitrateRange().getUpper();
if (bitrate > maxBitrate) {
bitrate = maxBitrate;
outputFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate);
}
int maxFramerate = capabilities.getVideoCapabilities().getSupportedFrameRates().getUpper();
if (framerate > maxFramerate) {
framerate = maxFramerate;
outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, framerate);
}
}
} else {
if (Math.min(resultHeight, resultWidth) <= 480) {
if (bitrate > 921600) bitrate = 921600; if (bitrate > 921600) bitrate = 921600;
outputFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate); outputFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate);
} }
}
if (Build.VERSION.SDK_INT < 18) { if (Build.VERSION.SDK_INT < 18) {
outputFormat.setInteger("stride", resultWidth + 32); outputFormat.setInteger("stride", resultWidth + 32);

View file

@ -30,7 +30,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.Components.FireworksEffect; import org.telegram.ui.Components.FireworksEffect;
@ -172,7 +171,7 @@ public class ActionBar extends FrameLayout {
snowflakesEffect = new SnowflakesEffect(); snowflakesEffect = new SnowflakesEffect();
titleTextView.invalidate(); titleTextView.invalidate();
invalidate(); invalidate();
} else if (BuildVars.DEBUG_PRIVATE_VERSION) { } else {
snowflakesEffect = null; snowflakesEffect = null;
fireworksEffect = new FireworksEffect(); fireworksEffect = new FireworksEffect();
titleTextView.invalidate(); titleTextView.invalidate();

View file

@ -3760,7 +3760,7 @@ public class Theme {
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 == -1 && TextUtils.isEmpty(overrideWallpaper.slug)) { if (id >= -100 && id <= -1 && TextUtils.isEmpty(overrideWallpaper.slug)) {
overrideWallpaper.slug = COLOR_BACKGROUND_SLUG; overrideWallpaper.slug = COLOR_BACKGROUND_SLUG;
overrideWallpaper.fileName = ""; overrideWallpaper.fileName = "";
overrideWallpaper.originalFileName = ""; overrideWallpaper.originalFileName = "";
@ -4714,7 +4714,7 @@ public class Theme {
} }
public static boolean deleteThemeAccent(ThemeInfo theme, ThemeAccent accent, boolean save) { public static boolean deleteThemeAccent(ThemeInfo theme, ThemeAccent accent, boolean save) {
if (accent == null) { if (accent == null || theme == null || theme.themeAccents == null) {
return false; return false;
} }
boolean current = accent.id == theme.currentAccentId; boolean current = accent.id == theme.currentAccentId;
@ -5335,7 +5335,7 @@ public class Theme {
boolean changed = false; boolean changed = false;
if (response instanceof TLRPC.TL_theme) { if (response instanceof TLRPC.TL_theme) {
TLRPC.TL_theme theme = (TLRPC.TL_theme) response; TLRPC.TL_theme theme = (TLRPC.TL_theme) response;
if (theme.settings != null) { if (accent != null && theme.settings != null) {
if (!ThemeInfo.accentEquals(accent, theme.settings)) { if (!ThemeInfo.accentEquals(accent, theme.settings)) {
File file = accent.getPathToWallpaper(); File file = accent.getPathToWallpaper();
if (file != null) { if (file != null) {
@ -5347,6 +5347,7 @@ public class Theme {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, currentTheme, currentNightTheme == currentTheme, null, -1); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, currentTheme, currentNightTheme == currentTheme, null, -1);
} }
PatternsLoader.createLoader(true); PatternsLoader.createLoader(true);
changed = true;
} }
accent.patternMotion = theme.settings.wallpaper != null && theme.settings.wallpaper.settings != null && theme.settings.wallpaper.settings.motion; accent.patternMotion = theme.settings.wallpaper != null && theme.settings.wallpaper.settings != null && theme.settings.wallpaper.settings.motion;
} else if (theme.document != null && theme.document.id != info.document.id) { } else if (theme.document != null && theme.document.id != info.document.id) {
@ -6835,6 +6836,9 @@ public class Theme {
Integer color = currentColorsNoAccent.get(key); Integer color = currentColorsNoAccent.get(key);
if (color != null) { if (color != null) {
ThemeAccent accent = currentTheme.getAccent(false); ThemeAccent accent = currentTheme.getAccent(false);
if (accent == null) {
return 0;
}
float[] hsvTemp1 = getTempHsv(1); float[] hsvTemp1 = getTempHsv(1);
float[] hsvTemp2 = getTempHsv(2); float[] hsvTemp2 = getTempHsv(2);
Color.colorToHSV(currentTheme.accentBaseColor, hsvTemp1); Color.colorToHSV(currentTheme.accentBaseColor, hsvTemp1);

View file

@ -671,6 +671,9 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
} }
private void updateColors() { private void updateColors() {
if (colors == null || imageView == null) {
return;
}
colors[0] = 0x333333; colors[0] = 0x333333;
colors[1] = Theme.getColor(Theme.key_windowBackgroundWhiteBlackText); colors[1] = Theme.getColor(Theme.key_windowBackgroundWhiteBlackText);

View file

@ -985,6 +985,8 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
layoutManager[0] = layoutManagerToUpdate; layoutManager[0] = layoutManagerToUpdate;
pagesStack.remove(pagesStack.size() - 1); pagesStack.remove(pagesStack.size() - 1);
currentPage = pagesStack.get(pagesStack.size() - 1); currentPage = pagesStack.get(pagesStack.size() - 1);
titleTextView.setText(currentPage.site_name == null ? "" : currentPage.site_name);
} }
listView[1].setVisibility(GONE); listView[1].setVisibility(GONE);
headerView.invalidate(); headerView.invalidate();
@ -1923,7 +1925,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
boolean extraSpace = maxWidth >= 0 && innerRichText instanceof TLRPC.TL_textUrl && ((TLRPC.TL_textUrl) innerRichText).webpage_id != 0; boolean extraSpace = maxWidth >= 0 && innerRichText instanceof TLRPC.TL_textUrl && ((TLRPC.TL_textUrl) innerRichText).webpage_id != 0;
if (extraSpace && spannableStringBuilder.length() != 0 && spannableStringBuilder.charAt(spannableStringBuilder.length() - 1) != '\n') { if (extraSpace && spannableStringBuilder.length() != 0 && spannableStringBuilder.charAt(spannableStringBuilder.length() - 1) != '\n') {
spannableStringBuilder.append(" "); spannableStringBuilder.append(" ");
spannableStringBuilder.setSpan(new TextSelectionHelper.IngnoreCopySpanable(), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0); spannableStringBuilder.setSpan(new TextSelectionHelper.IgnoreCopySpannable(), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
CharSequence innerText = getText(parentView, parentRichText, innerRichText, parentBlock, maxWidth); CharSequence innerText = getText(parentView, parentRichText, innerRichText, parentBlock, maxWidth);
@ -1943,17 +1945,17 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
span = new TextPaintUrlSpan(getTextPaint(parentRichText, lastRichText, parentBlock), url); span = new TextPaintUrlSpan(getTextPaint(parentRichText, lastRichText, parentBlock), url);
} }
if (startLength != spannableStringBuilder.length()) { if (startLength != spannableStringBuilder.length()) {
spannableStringBuilder.setSpan(span, startLength, spannableStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); spannableStringBuilder.setSpan(span, startLength, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
} else { } else {
if (startLength != spannableStringBuilder.length()) { if (startLength != spannableStringBuilder.length()) {
spannableStringBuilder.setSpan(new TextPaintSpan(getTextPaint(parentRichText, lastRichText, parentBlock)), startLength, spannableStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); spannableStringBuilder.setSpan(new TextPaintSpan(getTextPaint(parentRichText, lastRichText, parentBlock)), startLength, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
} }
} }
if (extraSpace && a != count - 1) { if (extraSpace && a != count - 1) {
spannableStringBuilder.append(" "); spannableStringBuilder.append(" ");
spannableStringBuilder.setSpan(new TextSelectionHelper.IngnoreCopySpanable(), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0); spannableStringBuilder.setSpan(new TextSelectionHelper.IgnoreCopySpannable(), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
} }
return spannableStringBuilder; return spannableStringBuilder;

View file

@ -70,7 +70,7 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
private int longpressDelay; private int longpressDelay;
private int touchSlop; private int touchSlop;
protected Path path = new Path(); protected PathWithSavedBottom path = new PathWithSavedBottom();
protected Paint selectionPaint = new Paint(); protected Paint selectionPaint = new Paint();
@ -1334,7 +1334,7 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
fillLayoutForOffset(offset, layoutBlock); fillLayoutForOffset(offset, layoutBlock);
StaticLayout layout = layoutBlock.layout; StaticLayout layout = layoutBlock.layout;
if (layout == null || offset >= layout.getText().length()) { if (layout == null || offset > layout.getText().length()) {
return tmpCoord; return tmpCoord;
} }
int line = layout.getLineForOffset(offset); int line = layout.getLineForOffset(offset);
@ -1387,12 +1387,11 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
private void drawLine(Canvas canvas, StaticLayout layout, int line, int start, int end) { private void drawLine(Canvas canvas, StaticLayout layout, int line, int start, int end) {
layout.getSelectionPath(start, end, path); layout.getSelectionPath(start, end, path);
boolean rtl = layout.getParagraphDirection(line) == StaticLayout.DIR_RIGHT_TO_LEFT; if (path.lastBottom < layout.getLineBottom(line)) {
if (!rtl && layout.getSpacingAdd() > 0 && line < layout.getLineCount() - 1) {
int lineBottom = layout.getLineBottom(line); int lineBottom = layout.getLineBottom(line);
int lineTop = layout.getLineTop(line); int lineTop = layout.getLineTop(line);
float lineH = lineBottom - lineTop; float lineH = lineBottom - lineTop;
float lineHWithoutSpaсing = (lineBottom - layout.getSpacingAdd()) - lineTop; float lineHWithoutSpaсing = path.lastBottom - lineTop;
canvas.save(); canvas.save();
canvas.scale(1f, lineH / lineHWithoutSpaсing, 0, lineTop); canvas.scale(1f, lineH / lineHWithoutSpaсing, 0, lineTop);
canvas.drawPath(path, selectionPaint); canvas.drawPath(path, selectionPaint);
@ -2322,11 +2321,28 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
for (int k = startViewChildPosition; k <= n; k++) { for (int k = startViewChildPosition; k <= n; k++) {
CharSequence text = textByPosition.get(i + (k << 16)); CharSequence text = textByPosition.get(i + (k << 16));
if (startViewPosition == endViewPosition && k == endViewChildPosition && k == startViewChildPosition) { if (startViewPosition == endViewPosition && k == endViewChildPosition && k == startViewChildPosition) {
stringBuilder.append(text.subSequence(startViewOffset, endViewOffset)); int e = endViewOffset;
int s = startViewOffset;
if (s < text.length()) {
if (e > text.length()) e = text.length();
stringBuilder.append(text.subSequence(s, e));
stringBuilder.append('\n');
}
} else if (startViewPosition == endViewPosition && k == endViewChildPosition) {
CharSequence prefix = prefixTextByPosition.get(i + (k << 16));
if (prefix != null) {
stringBuilder.append(prefix).append(' ');
}
int e = endViewOffset;
if (e > text.length()) e = text.length();
stringBuilder.append(text.subSequence(0, e));
stringBuilder.append('\n'); stringBuilder.append('\n');
} else if (k == startViewChildPosition) { } else if (k == startViewChildPosition) {
stringBuilder.append(text.subSequence(startViewOffset, text.length())); int s = startViewOffset;
if (s < text.length()) {
stringBuilder.append(text.subSequence(s, text.length()));
stringBuilder.append('\n'); stringBuilder.append('\n');
}
} else { } else {
CharSequence prefix = prefixTextByPosition.get(i + (k << 16)); CharSequence prefix = prefixTextByPosition.get(i + (k << 16));
if (prefix != null) { if (prefix != null) {
@ -2340,14 +2356,21 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
for (int k = 0; k <= endViewChildPosition; k++) { for (int k = 0; k <= endViewChildPosition; k++) {
CharSequence text = textByPosition.get(i + (k << 16)); CharSequence text = textByPosition.get(i + (k << 16));
if (startViewPosition == endViewPosition && k == endViewChildPosition && k == startViewChildPosition) { if (startViewPosition == endViewPosition && k == endViewChildPosition && k == startViewChildPosition) {
stringBuilder.append(text.subSequence(startViewOffset, endViewOffset)); int e = endViewOffset;
int s = startViewOffset;
if (s < text.length()) {
if (e > text.length()) e = text.length();
stringBuilder.append(text.subSequence(s, e));
stringBuilder.append('\n'); stringBuilder.append('\n');
}
} else if (k == endViewChildPosition) { } else if (k == endViewChildPosition) {
CharSequence prefix = prefixTextByPosition.get(i + (k << 16)); CharSequence prefix = prefixTextByPosition.get(i + (k << 16));
if (prefix != null) { if (prefix != null) {
stringBuilder.append(prefix).append(' '); stringBuilder.append(prefix).append(' ');
} }
stringBuilder.append(text.subSequence(0, endViewOffset)); int e = endViewOffset;
if (e > text.length()) e = text.length();
stringBuilder.append(text.subSequence(0, e));
stringBuilder.append('\n'); stringBuilder.append('\n');
} else { } else {
CharSequence prefix = prefixTextByPosition.get(i + (k << 16)); CharSequence prefix = prefixTextByPosition.get(i + (k << 16));
@ -2372,8 +2395,8 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
} }
if (stringBuilder.length() > 0) { if (stringBuilder.length() > 0) {
IngnoreCopySpanable[] spans = stringBuilder.getSpans(0, stringBuilder.length() - 1, IngnoreCopySpanable.class); IgnoreCopySpannable[] spans = stringBuilder.getSpans(0, stringBuilder.length() - 1, IgnoreCopySpannable.class);
for (IngnoreCopySpanable span : spans) { for (IgnoreCopySpannable span : spans) {
int end = stringBuilder.getSpanEnd(span); int end = stringBuilder.getSpanEnd(span);
int start = stringBuilder.getSpanStart(span); int start = stringBuilder.getSpanStart(span);
stringBuilder.delete(start, end); stringBuilder.delete(start, end);
@ -2484,7 +2507,26 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
} }
} }
public static class IngnoreCopySpanable { public static class IgnoreCopySpannable {
} }
private static class PathWithSavedBottom extends Path {
float lastBottom = 0;
@Override
public void reset() {
super.reset();
lastBottom = 0;
}
@Override
public void addRect(float left, float top, float right, float bottom, Direction dir) {
super.addRect(left, top, right, bottom, dir);
if (bottom > lastBottom) {
lastBottom = bottom;
}
}
}
} }

View file

@ -2827,6 +2827,9 @@ public class AlertsCreator {
} }
private static void processCreate(EditTextBoldCursor editText, AlertDialog alertDialog, BaseFragment fragment) { private static void processCreate(EditTextBoldCursor editText, AlertDialog alertDialog, BaseFragment fragment) {
if (fragment == null || fragment.getParentActivity() == null) {
return;
}
AndroidUtilities.hideKeyboard(editText); AndroidUtilities.hideKeyboard(editText);
Theme.ThemeInfo themeInfo = Theme.createNewTheme(editText.getText().toString()); Theme.ThemeInfo themeInfo = Theme.createNewTheme(editText.getText().toString());
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.themeListUpdated); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.themeListUpdated);

View file

@ -278,9 +278,11 @@ public class CropAreaView extends View {
canvas.drawRect(0, (int) actualRect.top, (int) actualRect.left, (int) actualRect.bottom, dimPaint); canvas.drawRect(0, (int) actualRect.top, (int) actualRect.left, (int) actualRect.bottom, dimPaint);
canvas.drawRect((int) actualRect.right, (int) actualRect.top, getWidth(), (int) actualRect.bottom, dimPaint); canvas.drawRect((int) actualRect.right, (int) actualRect.top, getWidth(), (int) actualRect.bottom, dimPaint);
canvas.drawRect(0, (int) actualRect.bottom, getWidth(), getHeight(), dimPaint); canvas.drawRect(0, (int) actualRect.bottom, getWidth(), getHeight(), dimPaint);
if (circleBitmap != null) {
canvas.drawBitmap(circleBitmap, (int) actualRect.left, (int) actualRect.top, null); canvas.drawBitmap(circleBitmap, (int) actualRect.left, (int) actualRect.top, null);
} }
} }
}
private void updateTouchAreas() { private void updateTouchAreas() {
int touchPadding = AndroidUtilities.dp(16); int touchPadding = AndroidUtilities.dp(16);

View file

@ -667,7 +667,9 @@ public class EditTextBoldCursor extends EditText {
floatingToolbar = new FloatingToolbar(getContext(), windowView != null ? windowView : attachedToWindow, getActionModeStyle()); floatingToolbar = new FloatingToolbar(getContext(), windowView != null ? windowView : attachedToWindow, getActionModeStyle());
floatingActionMode = new FloatingActionMode(getContext(), new ActionModeCallback2Wrapper(callback), this, floatingToolbar); floatingActionMode = new FloatingActionMode(getContext(), new ActionModeCallback2Wrapper(callback), this, floatingToolbar);
floatingToolbarPreDrawListener = () -> { floatingToolbarPreDrawListener = () -> {
if (floatingActionMode != null) {
floatingActionMode.updateViewLocationInWindow(); floatingActionMode.updateViewLocationInWindow();
}
return true; return true;
}; };
callback.onCreateActionMode(floatingActionMode, floatingActionMode.getMenu()); callback.onCreateActionMode(floatingActionMode, floatingActionMode.getMenu());

View file

@ -99,6 +99,9 @@ public class ScrollSlidingTabStrip extends HorizontalScrollView {
layoutTransition.setAnimateParentHierarchy(false); layoutTransition.setAnimateParentHierarchy(false);
layoutTransition.setDuration(250); layoutTransition.setDuration(250);
layoutTransition.addTransitionListener(new LayoutTransition.TransitionListener() { layoutTransition.addTransitionListener(new LayoutTransition.TransitionListener() {
private boolean inTransition;
@Override @Override
public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) { public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
@ -106,7 +109,12 @@ public class ScrollSlidingTabStrip extends HorizontalScrollView {
@Override @Override
public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) { public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
if (inTransition) {
return;
}
inTransition = true;
tabsContainer.setLayoutTransition(null); tabsContainer.setLayoutTransition(null);
inTransition = false;
} }
}); });
} }

View file

@ -518,14 +518,18 @@ public class DialogOrContactPickerActivity extends BaseFragment {
if (scrollY != 0 && scrollY != actionBarHeight) { if (scrollY != 0 && scrollY != actionBarHeight) {
if (scrollY < actionBarHeight / 2) { if (scrollY < actionBarHeight / 2) {
viewPages[0].listView.smoothScrollBy(0, -scrollY); viewPages[0].listView.smoothScrollBy(0, -scrollY);
if (viewPages[0].listView2 != null) {
viewPages[0].listView2.smoothScrollBy(0, -scrollY); viewPages[0].listView2.smoothScrollBy(0, -scrollY);
}
} else { } else {
viewPages[0].listView.smoothScrollBy(0, actionBarHeight - scrollY); viewPages[0].listView.smoothScrollBy(0, actionBarHeight - scrollY);
if (viewPages[0].listView2 != null) {
viewPages[0].listView2.smoothScrollBy(0, actionBarHeight - scrollY); viewPages[0].listView2.smoothScrollBy(0, actionBarHeight - scrollY);
} }
} }
} }
} }
}
@Override @Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

View file

@ -727,6 +727,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
int dialogIndex = dialogsAdapter.fixPosition(position); int dialogIndex = dialogsAdapter.fixPosition(position);
int count = dialogsAdapter.getItemCount(); int count = dialogsAdapter.getItemCount();
Runnable finishRunnable = () -> { Runnable finishRunnable = () -> {
if (frozenDialogsList == null) {
return;
}
TLRPC.Dialog dialog = frozenDialogsList.remove(dialogIndex); TLRPC.Dialog dialog = frozenDialogsList.remove(dialogIndex);
int pinnedNum = dialog.pinnedNum; int pinnedNum = dialog.pinnedNum;
slidingView = null; slidingView = null;
@ -1097,8 +1100,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName)); actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
} }
} }
if (folderId == 0) {
actionBar.setSupportsHolidayImage(true); actionBar.setSupportsHolidayImage(true);
} }
}
actionBar.setTitleActionRunnable(() -> { actionBar.setTitleActionRunnable(() -> {
hideFloatingButton(false); hideFloatingButton(false);
scrollToTop(); scrollToTop();

View file

@ -2051,6 +2051,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
shadowDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogBackground), PorterDuff.Mode.MULTIPLY)); shadowDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogBackground), PorterDuff.Mode.MULTIPLY));
shadow.invalidate(); shadow.invalidate();
if (googleMap != null) {
if (Theme.getCurrentTheme().isDark() || Theme.isCurrentThemeNight()) { if (Theme.getCurrentTheme().isDark() || Theme.isCurrentThemeNight()) {
if (!currentMapStyleDark) { if (!currentMapStyleDark) {
currentMapStyleDark = true; currentMapStyleDark = true;
@ -2063,6 +2064,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
googleMap.setMapStyle(null); googleMap.setMapStyle(null);
} }
} }
}
}; };
return new ThemeDescription[]{ return new ThemeDescription[]{
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, cellDelegate, Theme.key_dialogBackground), new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, cellDelegate, Theme.key_dialogBackground),

View file

@ -6435,6 +6435,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (messageObject != null && !messageObject.messageOwner.entities.isEmpty()) { if (messageObject != null && !messageObject.messageOwner.entities.isEmpty()) {
Spannable spannableString = SpannableString.valueOf(caption.toString()); Spannable spannableString = SpannableString.valueOf(caption.toString());
messageObject.addEntitiesToText(spannableString, true, false); messageObject.addEntitiesToText(spannableString, true, false);
if (messageObject.isVideo()) {
MessageObject.addUrlsByPattern(messageObject.isOutOwner(), spannableString, false, 3, messageObject.getDuration());
}
str = Emoji.replaceEmoji(spannableString, captionTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); str = Emoji.replaceEmoji(spannableString, captionTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
} else { } else {
str = Emoji.replaceEmoji(new SpannableStringBuilder(caption), captionTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); str = Emoji.replaceEmoji(new SpannableStringBuilder(caption), captionTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);

View file

@ -569,9 +569,13 @@ public class ProxySettingsActivity extends BaseFragment {
private void updatePasteCell() { private void updatePasteCell() {
final ClipData clip = clipboardManager.getPrimaryClip(); final ClipData clip = clipboardManager.getPrimaryClip();
final String clipText; String clipText;
if (clip != null && clip.getItemCount() > 0) { if (clip != null && clip.getItemCount() > 0) {
try {
clipText = clip.getItemAt(0).coerceToText(fragmentView.getContext()).toString(); clipText = clip.getItemAt(0).coerceToText(fragmentView.getContext()).toString();
} catch (Exception e) {
clipText = null;
}
} else { } else {
clipText = null; clipText = null;
} }

View file

@ -895,7 +895,8 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No
return; return;
} }
Theme.ThemeInfo themeInfo = Theme.getCurrentTheme(); Theme.ThemeInfo themeInfo = Theme.getCurrentTheme();
if (themeInfo.themeAccents != null && !themeInfo.themeAccents.isEmpty() && themeInfo.getAccent(false).id >= 100) { Theme.ThemeAccent accent = themeInfo.getAccent(false);
if (themeInfo.themeAccents != null && !themeInfo.themeAccents.isEmpty() && accent != null && accent.id >= 100) {
menuItem.showSubItem(share_theme); menuItem.showSubItem(share_theme);
menuItem.showSubItem(edit_theme); menuItem.showSubItem(edit_theme);
} else { } else {
@ -1583,6 +1584,9 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No
} }
}); });
accentsListView.setOnItemLongClickListener((view12, position) -> { accentsListView.setOnItemLongClickListener((view12, position) -> {
if (position < 0 || position >= accentsAdapter.themeAccents.size()) {
return false;
}
Theme.ThemeAccent accent = accentsAdapter.themeAccents.get(position); Theme.ThemeAccent accent = accentsAdapter.themeAccents.get(position);
if (accent.id >= 100) { if (accent.id >= 100) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());