Commit f6655078 authored by DrKLO's avatar DrKLO

Merge branch 'sessions' into dev

parents 1b913b2a b820e126
...@@ -82,7 +82,7 @@ android { ...@@ -82,7 +82,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 22 targetSdkVersion 22
versionCode 479 versionCode 492
versionName "2.6.1" versionName "2.7.0"
} }
} }
...@@ -104,7 +104,7 @@ include $(BUILD_STATIC_LIBRARY) ...@@ -104,7 +104,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false LOCAL_PRELINK_MODULE := false
LOCAL_STATIC_LIBRARIES := webp sqlite LOCAL_STATIC_LIBRARIES := webp sqlite
LOCAL_MODULE := tmessages.6 LOCAL_MODULE := tmessages.7
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math
......
...@@ -419,6 +419,11 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_calcCDT(JNIEnv *env, jclass ...@@ -419,6 +419,11 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_calcCDT(JNIEnv *env, jclass
free(cdfsMin); free(cdfsMin);
} }
JNIEXPORT int Java_org_telegram_messenger_Utilities_pinBitmap(JNIEnv *env, jclass class, jobject bitmap) {
unsigned char *pixels;
return AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0 ? 1 : 0;
}
JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jobject bitmap, int scale, int width, int height, int stride) { JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jobject bitmap, int scale, int width, int height, int stride) {
AndroidBitmapInfo info; AndroidBitmapInfo info;
......
...@@ -14,6 +14,7 @@ import android.content.Context; ...@@ -14,6 +14,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface; import android.graphics.Typeface;
...@@ -23,6 +24,7 @@ import android.os.Environment; ...@@ -23,6 +24,7 @@ import android.os.Environment;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.StateSet; import android.util.StateSet;
import android.view.Display; import android.view.Display;
...@@ -43,6 +45,10 @@ import org.telegram.messenger.R; ...@@ -43,6 +45,10 @@ import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.ui.Components.ForegroundDetector; import org.telegram.ui.Components.ForegroundDetector;
import org.telegram.ui.Components.NumberPicker; import org.telegram.ui.Components.NumberPicker;
import org.telegram.ui.Components.TypefaceSpan; import org.telegram.ui.Components.TypefaceSpan;
...@@ -538,21 +544,51 @@ public class AndroidUtilities { ...@@ -538,21 +544,51 @@ public class AndroidUtilities {
} }
} }
public static Spannable replaceBold(String str) { public static Spannable replaceTags(String str) {
int start; try {
ArrayList<Integer> bolds = new ArrayList<>(); int start = -1;
while ((start = str.indexOf("<b>")) != -1) { int startColor = -1;
int end = str.indexOf("</b>") - 3; int end = -1;
str = str.replaceFirst("<b>", "").replaceFirst("</b>", ""); StringBuilder stringBuilder = new StringBuilder(str);
bolds.add(start); while ((start = stringBuilder.indexOf("<br>")) != -1) {
bolds.add(end); stringBuilder.replace(start, start + 4, "\n");
} }
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(str); while ((start = stringBuilder.indexOf("<br/>")) != -1) {
for (int a = 0; a < bolds.size() / 2; a++) { stringBuilder.replace(start, start + 5, "\n");
TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); }
stringBuilder.setSpan(span, bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_INCLUSIVE_INCLUSIVE); ArrayList<Integer> bolds = new ArrayList<>();
ArrayList<Integer> colors = new ArrayList<>();
while ((start = stringBuilder.indexOf("<b>")) != -1 || (startColor = stringBuilder.indexOf("<c")) != -1) {
if (start != -1) {
stringBuilder.replace(start, start + 3, "");
end = stringBuilder.indexOf("</b>");
stringBuilder.replace(end, end + 4, "");
bolds.add(start);
bolds.add(end);
} else if (startColor != -1) {
stringBuilder.replace(startColor, startColor + 2, "");
end = stringBuilder.indexOf(">", startColor);
int color = Color.parseColor(stringBuilder.substring(startColor, end));
stringBuilder.replace(startColor, end + 1, "");
end = stringBuilder.indexOf("</c>");
stringBuilder.replace(end, end + 4, "");
colors.add(startColor);
colors.add(end);
colors.add(color);
}
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(stringBuilder);
for (int a = 0; a < bolds.size() / 2; a++) {
spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
for (int a = 0; a < colors.size() / 3; a++) {
spannableStringBuilder.setSpan(new ForegroundColorSpan(colors.get(a * 3 + 2)), colors.get(a * 3), colors.get(a * 3 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return spannableStringBuilder;
} catch (Exception e) {
FileLog.e("tmessages", e);
} }
return stringBuilder; return new SpannableStringBuilder(str);
} }
public static boolean needShowPasscode(boolean reset) { public static boolean needShowPasscode(boolean reset) {
...@@ -569,6 +605,61 @@ public class AndroidUtilities { ...@@ -569,6 +605,61 @@ public class AndroidUtilities {
(UserConfig.appLocked || UserConfig.autoLockIn != 0 && UserConfig.lastPauseTime != 0 && !UserConfig.appLocked && (UserConfig.lastPauseTime + UserConfig.autoLockIn) <= ConnectionsManager.getInstance().getCurrentTime()); (UserConfig.appLocked || UserConfig.autoLockIn != 0 && UserConfig.lastPauseTime != 0 && !UserConfig.appLocked && (UserConfig.lastPauseTime + UserConfig.autoLockIn) <= ConnectionsManager.getInstance().getCurrentTime());
} }
public static void shakeTextView(final TextView textView, final float x, final int num) {
if (num == 6) {
ViewProxy.setTranslationX(textView, 0);
textView.clearAnimation();
return;
}
AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
animatorSetProxy.playTogether(ObjectAnimatorProxy.ofFloat(textView, "translationX", AndroidUtilities.dp(x)));
animatorSetProxy.setDuration(50);
animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animation) {
shakeTextView(textView, num == 5 ? 0 : -x, num + 1);
}
});
animatorSetProxy.start();
}
/*public static String ellipsize(String text, int maxLines, int maxWidth, TextPaint paint) {
if (text == null || paint == null) {
return null;
}
int count;
int offset = 0;
StringBuilder result = null;
TextView
for (int a = 0; a < maxLines; a++) {
count = paint.breakText(text, true, maxWidth, null);
if (a != maxLines - 1) {
if (result == null) {
result = new StringBuilder(count * maxLines + 1);
}
boolean foundSpace = false;
for (int c = count - 1; c >= offset; c--) {
if (text.charAt(c) == ' ') {
foundSpace = true;
result.append(text.substring(offset, c - 1));
offset = c - 1;
}
}
if (!foundSpace) {
offset = count;
}
text = text.substring(0, offset);
} else if (maxLines == 1) {
return text.substring(0, count);
} else {
result.append(text.substring(0, count));
}
}
return result.toString();
}*/
/*public static void turnOffHardwareAcceleration(Window window) { /*public static void turnOffHardwareAcceleration(Window window) {
if (window == null || Build.MODEL == null || Build.VERSION.SDK_INT < 11) { if (window == null || Build.MODEL == null || Build.VERSION.SDK_INT < 11) {
return; return;
......
...@@ -645,9 +645,13 @@ public class ImageLoader { ...@@ -645,9 +645,13 @@ public class ImageLoader {
} else { } else {
opts.inPreferredConfig = Bitmap.Config.RGB_565; opts.inPreferredConfig = Bitmap.Config.RGB_565;
} }
//if (Build.VERSION.SDK_INT < 21) {
// opts.inPurgeable = true;
//}
opts.inDither = false; opts.inDither = false;
if (mediaId != null) { if (mediaId != null) {
image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, null); image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
} }
if (image == null) { if (image == null) {
if (isWebp) { if (isWebp) {
...@@ -1981,6 +1985,15 @@ public class ImageLoader { ...@@ -1981,6 +1985,15 @@ public class ImageLoader {
} }
} }
} }
} else if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
if (message.media.webpage.photo != null) {
for (TLRPC.PhotoSize size : message.media.webpage.photo.sizes) {
if (size instanceof TLRPC.TL_photoCachedSize) {
photoSize = size;
break;
}
}
}
} }
if (photoSize != null && photoSize.bytes != null && photoSize.bytes.length != 0) { if (photoSize != null && photoSize.bytes != null && photoSize.bytes.length != 0) {
if (photoSize.location instanceof TLRPC.TL_fileLocationUnavailable) { if (photoSize.location instanceof TLRPC.TL_fileLocationUnavailable) {
...@@ -2018,6 +2031,13 @@ public class ImageLoader { ...@@ -2018,6 +2031,13 @@ public class ImageLoader {
message.media.video.thumb = newPhotoSize; message.media.video.thumb = newPhotoSize;
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
message.media.document.thumb = newPhotoSize; message.media.document.thumb = newPhotoSize;
} else if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
for (int a = 0; a < message.media.webpage.photo.sizes.size(); a++) {
if (message.media.webpage.photo.sizes.get(a) instanceof TLRPC.TL_photoCachedSize) {
message.media.webpage.photo.sizes.set(a, newPhotoSize);
break;
}
}
} }
} }
} }
......
...@@ -68,7 +68,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg ...@@ -68,7 +68,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
private Matrix shaderMatrix; private Matrix shaderMatrix;
private int alpha = 255; private int alpha = 255;
private boolean isPressed; private boolean isPressed;
private boolean disableRecycle;
private int orientation; private int orientation;
private boolean centerRotation; private boolean centerRotation;
private ImageReceiverDelegate delegate; private ImageReceiverDelegate delegate;
...@@ -224,10 +223,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg ...@@ -224,10 +223,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
setImageBitmap(bitmap != null ? new BitmapDrawable(null, bitmap) : null); setImageBitmap(bitmap != null ? new BitmapDrawable(null, bitmap) : null);
} }
public void setDisableRecycle(boolean value) {
disableRecycle = value;
}
public void setImageBitmap(Drawable bitmap) { public void setImageBitmap(Drawable bitmap) {
ImageLoader.getInstance().cancelLoadingForImageReceiver(this, 0); ImageLoader.getInstance().cancelLoadingForImageReceiver(this, 0);
recycleBitmap(null, false); recycleBitmap(null, false);
...@@ -497,10 +492,18 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg ...@@ -497,10 +492,18 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return imageX; return imageX;
} }
public int getImageX2() {
return imageX + imageW;
}
public int getImageY() { public int getImageY() {
return imageY; return imageY;
} }
public int getImageY2() {
return imageY + imageH;
}
public int getImageWidth() { public int getImageWidth() {
return imageW; return imageW;
} }
...@@ -682,7 +685,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg ...@@ -682,7 +685,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (newKey != null) { if (newKey != null) {
newBitmap = ImageLoader.getInstance().getImageFromMemory(newKey); newBitmap = ImageLoader.getInstance().getImageFromMemory(newKey);
} }
if (key == null || image == null || image == newBitmap || disableRecycle) { if (key == null || image == null || image == newBitmap) {
return; return;
} }
Bitmap bitmap = image.getBitmap(); Bitmap bitmap = image.getBitmap();
......
...@@ -1105,8 +1105,16 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1105,8 +1105,16 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (proximitySensor != null && audioTrackPlayer == null && audioPlayer == null || isPaused || (useFrontSpeaker == (event.values[0] < proximitySensor.getMaximumRange() / 10))) { if (proximitySensor != null && audioTrackPlayer == null && audioPlayer == null || isPaused || (useFrontSpeaker == (event.values[0] < proximitySensor.getMaximumRange() / 10))) {
return; return;
} }
boolean newValue = event.values[0] < proximitySensor.getMaximumRange() / 10;
try {
if (newValue && NotificationsController.getInstance().audioManager.isWiredHeadsetOn()) {
return;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
ignoreProximity = true; ignoreProximity = true;
useFrontSpeaker = event.values[0] < proximitySensor.getMaximumRange() / 10; useFrontSpeaker = newValue;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioRouteChanged, useFrontSpeaker); NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioRouteChanged, useFrontSpeaker);
MessageObject currentMessageObject = playingMessageObject; MessageObject currentMessageObject = playingMessageObject;
float progress = playingMessageObject.audioProgress; float progress = playingMessageObject.audioProgress;
......
...@@ -41,6 +41,7 @@ public class MessageObject { ...@@ -41,6 +41,7 @@ public class MessageObject {
public TLRPC.Message messageOwner; public TLRPC.Message messageOwner;
public CharSequence messageText; public CharSequence messageText;
public CharSequence linkDescription;
public MessageObject replyMessageObject; public MessageObject replyMessageObject;
public int type; public int type;
public int contentType; public int contentType;
...@@ -273,7 +274,7 @@ public class MessageObject { ...@@ -273,7 +274,7 @@ public class MessageObject {
messageText = LocaleController.formatString("YouCreatedBroadcastList", R.string.YouCreatedBroadcastList); messageText = LocaleController.formatString("YouCreatedBroadcastList", R.string.YouCreatedBroadcastList);
} }
} }
} else if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty)) { } else if (!isMediaEmpty()) {
if (message.media instanceof TLRPC.TL_messageMediaPhoto) { if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto); messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto);
} else if (message.media instanceof TLRPC.TL_messageMediaVideo) { } else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
...@@ -309,22 +310,22 @@ public class MessageObject { ...@@ -309,22 +310,22 @@ public class MessageObject {
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20)); messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20));
if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded_old2) { if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded_old2) {
if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) { if (isMediaEmpty()) {
contentType = type = 0; contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) { } else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
contentType = type = 1; contentType = type = 1;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaGeo) { } else if (message.media instanceof TLRPC.TL_messageMediaGeo) {
contentType = 1; contentType = 1;
type = 4; type = 4;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaVideo) { } else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
contentType = 1; contentType = 1;
type = 3; type = 3;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaContact) { } else if (message.media instanceof TLRPC.TL_messageMediaContact) {
contentType = 3; contentType = 3;
type = 12; type = 12;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaUnsupported) { } else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
contentType = type = 0; contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
contentType = 1; contentType = 1;
if (message.media.document.mime_type != null) { if (message.media.document.mime_type != null) {
if (message.media.document.mime_type.equals("image/gif") && message.media.document.thumb != null && !(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) { if (message.media.document.mime_type.equals("image/gif") && message.media.document.thumb != null && !(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
...@@ -340,7 +341,7 @@ public class MessageObject { ...@@ -340,7 +341,7 @@ public class MessageObject {
} else { } else {
type = 9; type = 9;
} }
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaAudio) { } else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
contentType = type = 2; contentType = type = 2;
} }
} else if (message instanceof TLRPC.TL_messageService) { } else if (message instanceof TLRPC.TL_messageService) {
...@@ -433,6 +434,24 @@ public class MessageObject { ...@@ -433,6 +434,24 @@ public class MessageObject {
photoObject.location = messageOwner.media.document.thumb.location; photoObject.location = messageOwner.media.document.thumb.location;
} }
} }
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
if (messageOwner.media.webpage.photo != null) {
if (!update || photoThumbs == null) {
photoThumbs = new ArrayList<>(messageOwner.media.webpage.photo.sizes);
} else if (photoThumbs != null && !photoThumbs.isEmpty()) {
for (TLRPC.PhotoSize photoObject : photoThumbs) {
for (TLRPC.PhotoSize size : messageOwner.media.webpage.photo.sizes) {
if (size instanceof TLRPC.TL_photoSizeEmpty) {
continue;
}
if (size.type.equals(photoObject.type)) {
photoObject.location = size.location;
break;
}
}
}
}
}
} }
} }
} }
...@@ -538,11 +557,24 @@ public class MessageObject { ...@@ -538,11 +557,24 @@ public class MessageObject {
return false; return false;
} }
public void generateLinkDescription() {
if (linkDescription != null) {
return;
}
if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageOwner.media.webpage instanceof TLRPC.TL_webPage && messageOwner.media.webpage.description != null) {
linkDescription = Spannable.Factory.getInstance().newSpannable(messageOwner.media.webpage.description);
if (containsUrls(linkDescription)) {
Linkify.addLinks((Spannable) linkDescription, Linkify.WEB_URLS);
}
}
}
private void generateLayout() { private void generateLayout() {
if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) { if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) {
return; return;
} }
generateLinkDescription();
textLayoutBlocks = new ArrayList<>(); textLayoutBlocks = new ArrayList<>();
if (messageText instanceof Spannable && containsUrls(messageText)) { if (messageText instanceof Spannable && containsUrls(messageText)) {
...@@ -781,7 +813,7 @@ public class MessageObject { ...@@ -781,7 +813,7 @@ public class MessageObject {
} }
public boolean isSending() { public boolean isSending() {
return messageOwner.send_state == MESSAGE_SEND_STATE_SENDING; return messageOwner.send_state == MESSAGE_SEND_STATE_SENDING && messageOwner.id < 0;
} }
public boolean isSendError() { public boolean isSendError() {
...@@ -789,7 +821,7 @@ public class MessageObject { ...@@ -789,7 +821,7 @@ public class MessageObject {
} }
public boolean isSent() { public boolean isSent() {
return messageOwner.send_state == MESSAGE_SEND_STATE_SENT; return messageOwner.send_state == MESSAGE_SEND_STATE_SENT || messageOwner.id > 0;
} }
public String getSecretTimeString() { public String getSecretTimeString() {
...@@ -944,4 +976,12 @@ public class MessageObject { ...@@ -944,4 +976,12 @@ public class MessageObject {
public boolean isReply() { public boolean isReply() {
return !(replyMessageObject != null && replyMessageObject.messageOwner instanceof TLRPC.TL_messageEmpty) && messageOwner.reply_to_msg_id != 0 && (messageOwner.flags & TLRPC.MESSAGE_FLAG_REPLY) != 0; return !(replyMessageObject != null && replyMessageObject.messageOwner instanceof TLRPC.TL_messageEmpty) && messageOwner.reply_to_msg_id != 0 && (messageOwner.flags & TLRPC.MESSAGE_FLAG_REPLY) != 0;
} }
public boolean isMediaEmpty() {
return isMediaEmpty(messageOwner);
}
public static boolean isMediaEmpty(TLRPC.Message message) {
return message == null || message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty || message.media instanceof TLRPC.TL_messageMediaWebPage;
}
} }
...@@ -23,7 +23,7 @@ import java.util.zip.ZipFile; ...@@ -23,7 +23,7 @@ import java.util.zip.ZipFile;
public class NativeLoader { public class NativeLoader {
private final static int LIB_VERSION = 6; private final static int LIB_VERSION = 7;
private final static String LIB_NAME = "tmessages." + LIB_VERSION; private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so"; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so"; private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
......
...@@ -49,9 +49,13 @@ public class NotificationCenter { ...@@ -49,9 +49,13 @@ public class NotificationCenter {
public static final int recentImagesDidLoaded = totalEvents++; public static final int recentImagesDidLoaded = totalEvents++;
public static final int replaceMessagesObjects = totalEvents++; public static final int replaceMessagesObjects = totalEvents++;
public static final int didSetPasscode = totalEvents++; public static final int didSetPasscode = totalEvents++;
public static final int didSetTwoStepPassword = totalEvents++;
public static final int screenStateChanged = totalEvents++; public static final int screenStateChanged = totalEvents++;
public static final int appSwitchedToForeground = totalEvents++; public static final int appSwitchedToForeground = totalEvents++;
public static final int didLoadedReplyMessages = totalEvents++; public static final int didLoadedReplyMessages = totalEvents++;
public static final int newSessionReceived = totalEvents++;
public static final int didReceivedWebpages = totalEvents++;
public static final int didReceivedWebpagesInUpdates = totalEvents++;
public static final int httpFileDidLoaded = totalEvents++; public static final int httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++; public static final int httpFileDidFailedLoad = totalEvents++;
...@@ -64,7 +68,6 @@ public class NotificationCenter { ...@@ -64,7 +68,6 @@ public class NotificationCenter {
public static final int didReceiveSmsCode = totalEvents++; public static final int didReceiveSmsCode = totalEvents++;
public static final int emojiDidLoaded = totalEvents++; public static final int emojiDidLoaded = totalEvents++;
public static final int appDidLogout = totalEvents++; public static final int appDidLogout = totalEvents++;
public static final int needPasswordEnter = totalEvents++;
public static final int FileDidUpload = totalEvents++; public static final int FileDidUpload = totalEvents++;
public static final int FileDidFailUpload = totalEvents++; public static final int FileDidFailUpload = totalEvents++;
......
...@@ -71,7 +71,7 @@ public class NotificationsController { ...@@ -71,7 +71,7 @@ public class NotificationsController {
private long lastSoundPlay; private long lastSoundPlay;
private MediaPlayer mediaPlayerIn; private MediaPlayer mediaPlayerIn;
private MediaPlayer mediaPlayerOut; private MediaPlayer mediaPlayerOut;
private AudioManager audioManager; protected AudioManager audioManager;
private static volatile NotificationsController Instance = null; private static volatile NotificationsController Instance = null;
public static NotificationsController getInstance() { public static NotificationsController getInstance() {
...@@ -171,7 +171,7 @@ public class NotificationsController { ...@@ -171,7 +171,7 @@ public class NotificationsController {
msg = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, UserConfig.getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address); msg = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, UserConfig.getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
} }
} else { } else {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) { if (messageObject.isMediaEmpty()) {
if (!shortMessage) { if (!shortMessage) {
if (messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) { if (messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) {
msg = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, ContactsController.formatName(user.first_name, user.last_name), messageObject.messageOwner.message); msg = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, ContactsController.formatName(user.first_name, user.last_name), messageObject.messageOwner.message);
...@@ -236,7 +236,7 @@ public class NotificationsController { ...@@ -236,7 +236,7 @@ public class NotificationsController {
msg = messageObject.messageText.toString(); msg = messageObject.messageText.toString();
} }
} else { } else {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) { if (messageObject.isMediaEmpty()) {
if (!shortMessage && messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) { if (!shortMessage && messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) {
msg = LocaleController.formatString("NotificationMessageGroupText", R.string.NotificationMessageGroupText, ContactsController.formatName(user.first_name, user.last_name), chat.title, messageObject.messageOwner.message); msg = LocaleController.formatString("NotificationMessageGroupText", R.string.NotificationMessageGroupText, ContactsController.formatName(user.first_name, user.last_name), chat.title, messageObject.messageOwner.message);
} else { } else {
...@@ -868,7 +868,7 @@ public class NotificationsController { ...@@ -868,7 +868,7 @@ public class NotificationsController {
AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_in); AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_in);
if (assetFileDescriptor != null) { if (assetFileDescriptor != null) {
mediaPlayerIn = new MediaPlayer(); mediaPlayerIn = new MediaPlayer();
mediaPlayerIn.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); mediaPlayerIn.setAudioStreamType(AudioManager.STREAM_SYSTEM);
mediaPlayerIn.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength()); mediaPlayerIn.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
mediaPlayerIn.setLooping(false); mediaPlayerIn.setLooping(false);
assetFileDescriptor.close(); assetFileDescriptor.close();
...@@ -938,7 +938,7 @@ public class NotificationsController { ...@@ -938,7 +938,7 @@ public class NotificationsController {
AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_out); AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_out);
if (assetFileDescriptor != null) { if (assetFileDescriptor != null) {
mediaPlayerOut = new MediaPlayer(); mediaPlayerOut = new MediaPlayer();
mediaPlayerOut.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); mediaPlayerOut.setAudioStreamType(AudioManager.STREAM_SYSTEM);
mediaPlayerOut.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength()); mediaPlayerOut.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
mediaPlayerOut.setLooping(false); mediaPlayerOut.setLooping(false);
assetFileDescriptor.close(); assetFileDescriptor.close();
......
...@@ -119,7 +119,7 @@ public class SecretChatHelper { ...@@ -119,7 +119,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -224,7 +224,7 @@ public class SecretChatHelper { ...@@ -224,7 +224,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -252,7 +252,7 @@ public class SecretChatHelper { ...@@ -252,7 +252,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -283,7 +283,7 @@ public class SecretChatHelper { ...@@ -283,7 +283,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -312,7 +312,7 @@ public class SecretChatHelper { ...@@ -312,7 +312,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -343,7 +343,7 @@ public class SecretChatHelper { ...@@ -343,7 +343,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -375,7 +375,7 @@ public class SecretChatHelper { ...@@ -375,7 +375,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -406,7 +406,7 @@ public class SecretChatHelper { ...@@ -406,7 +406,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -436,7 +436,7 @@ public class SecretChatHelper { ...@@ -436,7 +436,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -464,7 +464,7 @@ public class SecretChatHelper { ...@@ -464,7 +464,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -500,7 +500,7 @@ public class SecretChatHelper { ...@@ -500,7 +500,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
} }
...@@ -659,7 +659,7 @@ public class SecretChatHelper { ...@@ -659,7 +659,7 @@ public class SecretChatHelper {
int myLayer = Math.max(17, AndroidUtilities.getMyLayerVersion(chat.layer)); int myLayer = Math.max(17, AndroidUtilities.getMyLayerVersion(chat.layer));
layer.layer = Math.min(myLayer, AndroidUtilities.getPeerLayerVersion(chat.layer)); layer.layer = Math.min(myLayer, AndroidUtilities.getPeerLayerVersion(chat.layer));
layer.message = req; layer.message = req;
layer.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; layer.random_bytes = new byte[15];
Utilities.random.nextBytes(layer.random_bytes); Utilities.random.nextBytes(layer.random_bytes);
toEncryptObject = layer; toEncryptObject = layer;
...@@ -795,7 +795,7 @@ public class SecretChatHelper { ...@@ -795,7 +795,7 @@ public class SecretChatHelper {
@Override @Override
public void run() { public void run() {
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.id, newMsgObj.id, newMsgObj); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.id, newMsgObj.id, newMsgObj, false);
SendMessagesHelper.getInstance().processSentMessage(newMsgObj.id); SendMessagesHelper.getInstance().processSentMessage(newMsgObj.id);
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) { if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
SendMessagesHelper.getInstance().stopVideoService(attachPath); SendMessagesHelper.getInstance().stopVideoService(attachPath);
...@@ -1104,10 +1104,7 @@ public class SecretChatHelper { ...@@ -1104,10 +1104,7 @@ public class SecretChatHelper {
} }
byte[] salt = new byte[256]; byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) { Utilities.random.nextBytes(salt);
salt[a] = (byte) (Utilities.random.nextDouble() * 256);
}
BigInteger p = new BigInteger(1, MessagesStorage.secretPBytes); BigInteger p = new BigInteger(1, MessagesStorage.secretPBytes);
BigInteger g_b = BigInteger.valueOf(MessagesStorage.secretG); BigInteger g_b = BigInteger.valueOf(MessagesStorage.secretG);
g_b = g_b.modPow(new BigInteger(1, salt), p); g_b = g_b.modPow(new BigInteger(1, salt), p);
...@@ -1409,9 +1406,7 @@ public class SecretChatHelper { ...@@ -1409,9 +1406,7 @@ public class SecretChatHelper {
return; return;
} }
final byte[] salt = new byte[256]; final byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) { Utilities.random.nextBytes(salt);
salt[a] = (byte) (Utilities.random.nextDouble() * 256);
}
BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.secretG); BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.secretG);
i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes)); i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes));
......
...@@ -31,7 +31,7 @@ public class WearReplyReceiver extends BroadcastReceiver { ...@@ -31,7 +31,7 @@ public class WearReplyReceiver extends BroadcastReceiver {
if (dialog_id == 0 || max_id == 0) { if (dialog_id == 0 || max_id == 0) {
return; return;
} }
SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null); SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true);
MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false); MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false);
} }
} }
...@@ -1037,11 +1037,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1037,11 +1037,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
for (int i = 0; i < runningRequests.size(); i++) { for (int i = 0; i < runningRequests.size(); i++) {
RPCRequest request = runningRequests.get(i); RPCRequest request = runningRequests.get(i);
if (UserConfig.waitingForPasswordEnter && (request.flags & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
FileLog.e("tmessages", "skip request " + request.rawRequest + ", need password enter");
continue;
}
int datacenterId = request.runningDatacenterId; int datacenterId = request.runningDatacenterId;
if (datacenterId == DEFAULT_DATACENTER_ID) { if (datacenterId == DEFAULT_DATACENTER_ID) {
if (movingToDatacenterId != DEFAULT_DATACENTER_ID) { if (movingToDatacenterId != DEFAULT_DATACENTER_ID) {
...@@ -1244,11 +1239,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1244,11 +1239,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
continue; continue;
} }
if (UserConfig.waitingForPasswordEnter && (request.flags & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
FileLog.e("tmessages", "skip request " + request.rawRequest + ", need password enter");
continue;
}
int datacenterId = request.runningDatacenterId; int datacenterId = request.runningDatacenterId;
if (datacenterId == DEFAULT_DATACENTER_ID) { if (datacenterId == DEFAULT_DATACENTER_ID) {
if (movingToDatacenterId != DEFAULT_DATACENTER_ID && (request.flags & RPCRequest.RPCRequestClassEnableUnauthorized) == 0) { if (movingToDatacenterId != DEFAULT_DATACENTER_ID && (request.flags & RPCRequest.RPCRequestClassEnableUnauthorized) == 0) {
...@@ -2183,10 +2173,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2183,10 +2173,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
}); });
} }
if (request.rawRequest instanceof TLRPC.TL_auth_checkPassword) {
UserConfig.setWaitingForPasswordEnter(false);
UserConfig.saveConfig(false);
}
request.completionBlock.run(resultContainer.result, null); request.completionBlock.run(resultContainer.result, null);
} }
} }
...@@ -2194,7 +2180,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2194,7 +2180,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (implicitError != null && implicitError.code == 401) { if (implicitError != null && implicitError.code == 401) {
isError = true; isError = true;
if (implicitError.text != null && implicitError.text.contains("SESSION_PASSWORD_NEEDED")) { if (implicitError.text != null && implicitError.text.contains("SESSION_PASSWORD_NEEDED")) {
UserConfig.setWaitingForPasswordEnter(true); /*UserConfig.setWaitingForPasswordEnter(true); TODO
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
if (UserConfig.isClientActivated()) { if (UserConfig.isClientActivated()) {
discardResponse = true; discardResponse = true;
...@@ -2204,7 +2190,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2204,7 +2190,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
NotificationCenter.getInstance().postNotificationName(NotificationCenter.needPasswordEnter); NotificationCenter.getInstance().postNotificationName(NotificationCenter.needPasswordEnter);
} }
}); });
} }*/
} else if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) { } else if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) {
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0 && UserConfig.isClientActivated()) { if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0 && UserConfig.isClientActivated()) {
UserConfig.clearConfig(); UserConfig.clearConfig();
......
...@@ -63,7 +63,7 @@ public class RPCRequest { ...@@ -63,7 +63,7 @@ public class RPCRequest {
boolean initRequest = false; boolean initRequest = false;
ArrayList<Long> respondsToMessageIds = new ArrayList<Long>(); ArrayList<Long> respondsToMessageIds = new ArrayList<>();
public void addRespondMessageId(long messageId) { public void addRespondMessageId(long messageId) {
respondsToMessageIds.add(messageId); respondsToMessageIds.add(messageId);
......
...@@ -124,8 +124,6 @@ public class TLClassStore { ...@@ -124,8 +124,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_boolTrue.constructor, TLRPC.TL_boolTrue.class); classStore.put(TLRPC.TL_boolTrue.constructor, TLRPC.TL_boolTrue.class);
classStore.put(TLRPC.TL_boolFalse.constructor, TLRPC.TL_boolFalse.class); classStore.put(TLRPC.TL_boolFalse.constructor, TLRPC.TL_boolFalse.class);
classStore.put(TLRPC.TL_auth_exportedAuthorization.constructor, TLRPC.TL_auth_exportedAuthorization.class); classStore.put(TLRPC.TL_auth_exportedAuthorization.constructor, TLRPC.TL_auth_exportedAuthorization.class);
classStore.put(TLRPC.TL_messages_statedMessagesLinks.constructor, TLRPC.TL_messages_statedMessagesLinks.class);
classStore.put(TLRPC.TL_messages_statedMessages.constructor, TLRPC.TL_messages_statedMessages.class);
classStore.put(TLRPC.TL_inputNotifyChats.constructor, TLRPC.TL_inputNotifyChats.class); classStore.put(TLRPC.TL_inputNotifyChats.constructor, TLRPC.TL_inputNotifyChats.class);
classStore.put(TLRPC.TL_inputNotifyPeer.constructor, TLRPC.TL_inputNotifyPeer.class); classStore.put(TLRPC.TL_inputNotifyPeer.constructor, TLRPC.TL_inputNotifyPeer.class);
classStore.put(TLRPC.TL_inputNotifyUsers.constructor, TLRPC.TL_inputNotifyUsers.class); classStore.put(TLRPC.TL_inputNotifyUsers.constructor, TLRPC.TL_inputNotifyUsers.class);
...@@ -322,8 +320,6 @@ public class TLClassStore { ...@@ -322,8 +320,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_contactFound.constructor, TLRPC.TL_contactFound.class); classStore.put(TLRPC.TL_contactFound.constructor, TLRPC.TL_contactFound.class);
classStore.put(TLRPC.TL_inputFileBig.constructor, TLRPC.TL_inputFileBig.class); classStore.put(TLRPC.TL_inputFileBig.constructor, TLRPC.TL_inputFileBig.class);
classStore.put(TLRPC.TL_inputFile.constructor, TLRPC.TL_inputFile.class); classStore.put(TLRPC.TL_inputFile.constructor, TLRPC.TL_inputFile.class);
classStore.put(TLRPC.TL_messages_statedMessageLink.constructor, TLRPC.TL_messages_statedMessageLink.class);
classStore.put(TLRPC.TL_messages_statedMessage.constructor, TLRPC.TL_messages_statedMessage.class);
classStore.put(TLRPC.TL_userFull.constructor, TLRPC.TL_userFull.class); classStore.put(TLRPC.TL_userFull.constructor, TLRPC.TL_userFull.class);
classStore.put(TLRPC.TL_updates_state.constructor, TLRPC.TL_updates_state.class); classStore.put(TLRPC.TL_updates_state.constructor, TLRPC.TL_updates_state.class);
classStore.put(TLRPC.TL_resPQ.constructor, TLRPC.TL_resPQ.class); classStore.put(TLRPC.TL_resPQ.constructor, TLRPC.TL_resPQ.class);
...@@ -377,6 +373,17 @@ public class TLClassStore { ...@@ -377,6 +373,17 @@ public class TLClassStore {
classStore.put(TLRPC.TL_contactLinkHasPhone.constructor, TLRPC.TL_contactLinkHasPhone.class); classStore.put(TLRPC.TL_contactLinkHasPhone.constructor, TLRPC.TL_contactLinkHasPhone.class);
classStore.put(TLRPC.TL_contactLinkContact.constructor, TLRPC.TL_contactLinkContact.class); classStore.put(TLRPC.TL_contactLinkContact.constructor, TLRPC.TL_contactLinkContact.class);
classStore.put(TLRPC.TL_messages_affectedMessages.constructor, TLRPC.TL_messages_affectedMessages.class); classStore.put(TLRPC.TL_messages_affectedMessages.constructor, TLRPC.TL_messages_affectedMessages.class);
classStore.put(TLRPC.TL_updateWebPage.constructor, TLRPC.TL_updateWebPage.class);
classStore.put(TLRPC.TL_webPagePending.constructor, TLRPC.TL_webPagePending.class);
classStore.put(TLRPC.TL_webPageEmpty.constructor, TLRPC.TL_webPageEmpty.class);
classStore.put(TLRPC.TL_webPage.constructor, TLRPC.TL_webPage.class);
classStore.put(TLRPC.TL_messageMediaWebPage.constructor, TLRPC.TL_messageMediaWebPage.class);
classStore.put(TLRPC.TL_authorization.constructor, TLRPC.TL_authorization.class);
classStore.put(TLRPC.TL_account_authorizations.constructor, TLRPC.TL_account_authorizations.class);
classStore.put(TLRPC.TL_account_passwordSettings.constructor, TLRPC.TL_account_passwordSettings.class);
classStore.put(TLRPC.TL_account_passwordInputSettings.constructor, TLRPC.TL_account_passwordInputSettings.class);
classStore.put(TLRPC.TL_auth_passwordRecovery.constructor, TLRPC.TL_auth_passwordRecovery.class);
classStore.put(TLRPC.TL_messages_getWebPagePreview.constructor, TLRPC.TL_messages_getWebPagePreview.class);
classStore.put(TLRPC.TL_messageMediaUnsupported_old.constructor, TLRPC.TL_messageMediaUnsupported_old.class); classStore.put(TLRPC.TL_messageMediaUnsupported_old.constructor, TLRPC.TL_messageMediaUnsupported_old.class);
classStore.put(TLRPC.TL_userSelf_old2.constructor, TLRPC.TL_userSelf_old2.class); classStore.put(TLRPC.TL_userSelf_old2.constructor, TLRPC.TL_userSelf_old2.class);
......
...@@ -30,7 +30,6 @@ public class UserConfig { ...@@ -30,7 +30,6 @@ public class UserConfig {
private final static Object sync = new Object(); private final static Object sync = new Object();
public static boolean saveIncomingPhotos = false; public static boolean saveIncomingPhotos = false;
public static int contactsVersion = 1; public static int contactsVersion = 1;
public static boolean waitingForPasswordEnter = false;
public static String passcodeHash = ""; public static String passcodeHash = "";
public static boolean appLocked = false; public static boolean appLocked = false;
public static int passcodeType = 0; public static int passcodeType = 0;
...@@ -67,7 +66,6 @@ public class UserConfig { ...@@ -67,7 +66,6 @@ public class UserConfig {
editor.putInt("lastBroadcastId", lastBroadcastId); editor.putInt("lastBroadcastId", lastBroadcastId);
editor.putBoolean("registeredForInternalPush", registeredForInternalPush); editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded); editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded);
editor.putBoolean("waitingForPasswordEnter", waitingForPasswordEnter);
editor.putString("passcodeHash1", passcodeHash); editor.putString("passcodeHash1", passcodeHash);
editor.putBoolean("appLocked", appLocked); editor.putBoolean("appLocked", appLocked);
editor.putInt("passcodeType", passcodeType); editor.putInt("passcodeType", passcodeType);
...@@ -101,18 +99,6 @@ public class UserConfig { ...@@ -101,18 +99,6 @@ public class UserConfig {
} }
} }
public static boolean isWaitingForPasswordEnter() {
synchronized (sync) {
return waitingForPasswordEnter;
}
}
public static void setWaitingForPasswordEnter(boolean value) {
synchronized (sync) {
waitingForPasswordEnter = value;
}
}
public static int getClientUserId() { public static int getClientUserId() {
synchronized (sync) { synchronized (sync) {
return currentUser != null ? currentUser.id : 0; return currentUser != null ? currentUser.id : 0;
...@@ -208,7 +194,6 @@ public class UserConfig { ...@@ -208,7 +194,6 @@ public class UserConfig {
lastBroadcastId = preferences.getInt("lastBroadcastId", -1); lastBroadcastId = preferences.getInt("lastBroadcastId", -1);
registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false); registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false);
blockedUsersLoaded = preferences.getBoolean("blockedUsersLoaded", false); blockedUsersLoaded = preferences.getBoolean("blockedUsersLoaded", false);
waitingForPasswordEnter = preferences.getBoolean("waitingForPasswordEnter", false);
passcodeHash = preferences.getString("passcodeHash1", ""); passcodeHash = preferences.getString("passcodeHash1", "");
appLocked = preferences.getBoolean("appLocked", false); appLocked = preferences.getBoolean("appLocked", false);
passcodeType = preferences.getInt("passcodeType", 0); passcodeType = preferences.getInt("passcodeType", 0);
...@@ -231,7 +216,6 @@ public class UserConfig { ...@@ -231,7 +216,6 @@ public class UserConfig {
currentUser = null; currentUser = null;
registeredForInternalPush = false; registeredForInternalPush = false;
registeredForPush = false; registeredForPush = false;
waitingForPasswordEnter = false;
contactsHash = ""; contactsHash = "";
importHash = ""; importHash = "";
lastSendMessageId = -210000; lastSendMessageId = -210000;
......
...@@ -21,7 +21,6 @@ import android.os.Build; ...@@ -21,7 +21,6 @@ import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.provider.DocumentsContract; import android.provider.DocumentsContract;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.text.Html;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.util.Base64; import android.util.Base64;
...@@ -29,6 +28,8 @@ import net.hockeyapp.android.CrashManager; ...@@ -29,6 +28,8 @@ import net.hockeyapp.android.CrashManager;
import net.hockeyapp.android.CrashManagerListener; import net.hockeyapp.android.CrashManagerListener;
import net.hockeyapp.android.UpdateManager; import net.hockeyapp.android.UpdateManager;
import org.telegram.android.AndroidUtilities;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
...@@ -108,6 +109,7 @@ public class Utilities { ...@@ -108,6 +109,7 @@ public class Utilities {
public native static long doPQNative(long _what); public native static long doPQNative(long _what);
public native static void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride); public native static void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride);
public native static int pinBitmap(Bitmap bitmap);
public native static void blurBitmap(Object bitmap, int radius); public native static void blurBitmap(Object bitmap, int radius);
public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer); public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer);
public native static Bitmap loadWebpImage(ByteBuffer buffer, int len, BitmapFactory.Options options); public native static Bitmap loadWebpImage(ByteBuffer buffer, int len, BitmapFactory.Options options);
...@@ -145,6 +147,9 @@ public class Utilities { ...@@ -145,6 +147,9 @@ public class Utilities {
} }
public static String bytesToHex(byte[] bytes) { public static String bytesToHex(byte[] bytes) {
if (bytes == null) {
return "";
}
char[] hexChars = new char[bytes.length * 2]; char[] hexChars = new char[bytes.length * 2];
int v; int v;
for (int j = 0; j < bytes.length; j++) { for (int j = 0; j < bytes.length; j++) {
...@@ -156,6 +161,9 @@ public class Utilities { ...@@ -156,6 +161,9 @@ public class Utilities {
} }
public static byte[] hexToBytes(String hex) { public static byte[] hexToBytes(String hex) {
if (hex == null) {
return null;
}
int len = hex.length(); int len = hex.length();
byte[] data = new byte[len / 2]; byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) { for (int i = 0; i < len; i += 2) {
...@@ -685,7 +693,7 @@ public class Utilities { ...@@ -685,7 +693,7 @@ public class Utilities {
builder.append(" "); builder.append(" ");
} }
query.trim(); query.trim();
builder.append(Html.fromHtml("<font color=\"#4d83b3\">" + query + "</font>")); builder.append(AndroidUtilities.replaceTags("<c#ff4d83b3>" + query + "</c>"));
lastIndex = end; lastIndex = end;
} }
......
...@@ -121,18 +121,10 @@ public class ActionBar extends FrameLayout { ...@@ -121,18 +121,10 @@ public class ActionBar extends FrameLayout {
} }
int x = 0; int x = 0;
if (backButtonImageView != null) { if (backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE) {
if (AndroidUtilities.isTablet()) { x = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 80 : 72);
x = AndroidUtilities.dp(80);
} else {
x = AndroidUtilities.dp(72);
}
} else { } else {
if (AndroidUtilities.isTablet()) { x = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 26 : 18);
x = AndroidUtilities.dp(26);
} else {
x = AndroidUtilities.dp(18);
}
} }
if (menu != null) { if (menu != null) {
...@@ -202,17 +194,31 @@ public class ActionBar extends FrameLayout { ...@@ -202,17 +194,31 @@ public class ActionBar extends FrameLayout {
} }
public void setBackButtonDrawable(Drawable drawable) { public void setBackButtonDrawable(Drawable drawable) {
boolean reposition = false;
if (backButtonImageView == null) { if (backButtonImageView == null) {
createBackButtonImage(); createBackButtonImage();
} else {
reposition = true;
} }
backButtonImageView.setVisibility(drawable == null ? GONE : VISIBLE);
backButtonImageView.setImageDrawable(drawable); backButtonImageView.setImageDrawable(drawable);
if (reposition) {
positionTitle(getMeasuredWidth(), getMeasuredHeight());
}
} }
public void setBackButtonImage(int resource) { public void setBackButtonImage(int resource) {
boolean reposition = false;
if (backButtonImageView == null) { if (backButtonImageView == null) {
createBackButtonImage(); createBackButtonImage();
} else {
reposition = true;
} }
backButtonImageView.setVisibility(resource == 0 ? GONE : VISIBLE);
backButtonImageView.setImageResource(resource); backButtonImageView.setImageResource(resource);
if (reposition) {
positionTitle(getMeasuredWidth(), getMeasuredHeight());
}
} }
private void createSubtitleTextView() { private void createSubtitleTextView() {
...@@ -234,7 +240,7 @@ public class ActionBar extends FrameLayout { ...@@ -234,7 +240,7 @@ public class ActionBar extends FrameLayout {
createSubtitleTextView(); createSubtitleTextView();
} }
if (subTitleTextView != null) { if (subTitleTextView != null) {
subTitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : GONE); subTitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
subTitleTextView.setText(value); subTitleTextView.setText(value);
positionTitle(getMeasuredWidth(), getMeasuredHeight()); positionTitle(getMeasuredWidth(), getMeasuredHeight());
} }
...@@ -276,7 +282,7 @@ public class ActionBar extends FrameLayout { ...@@ -276,7 +282,7 @@ public class ActionBar extends FrameLayout {
} }
if (titleTextView != null) { if (titleTextView != null) {
lastTitle = value; lastTitle = value;
titleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : GONE); titleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
titleTextView.setText(value); titleTextView.setText(value);
positionTitle(getMeasuredWidth(), getMeasuredHeight()); positionTitle(getMeasuredWidth(), getMeasuredHeight());
} }
...@@ -344,7 +350,7 @@ public class ActionBar extends FrameLayout { ...@@ -344,7 +350,7 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.FILL_PARENT; layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.RIGHT; layoutParams.gravity = Gravity.RIGHT;
actionMode.setLayoutParams(layoutParams); actionMode.setLayoutParams(layoutParams);
actionMode.setVisibility(GONE); actionMode.setVisibility(INVISIBLE);
if (occupyStatusBar) { if (occupyStatusBar) {
actionModeTop = new View(getContext()); actionModeTop = new View(getContext());
...@@ -355,7 +361,7 @@ public class ActionBar extends FrameLayout { ...@@ -355,7 +361,7 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.FILL_PARENT; layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
actionModeTop.setLayoutParams(layoutParams); actionModeTop.setLayoutParams(layoutParams);
actionModeTop.setVisibility(GONE); actionModeTop.setVisibility(INVISIBLE);
} }
return actionMode; return actionMode;
...@@ -381,9 +387,9 @@ public class ActionBar extends FrameLayout { ...@@ -381,9 +387,9 @@ public class ActionBar extends FrameLayout {
if (actionMode == null) { if (actionMode == null) {
return; return;
} }
actionMode.setVisibility(GONE); actionMode.setVisibility(INVISIBLE);
if (occupyStatusBar && actionModeTop != null) { if (occupyStatusBar && actionModeTop != null) {
actionModeTop.setVisibility(GONE); actionModeTop.setVisibility(INVISIBLE);
} }
if (titleFrameLayout != null) { if (titleFrameLayout != null) {
titleFrameLayout.setVisibility(VISIBLE); titleFrameLayout.setVisibility(VISIBLE);
...@@ -400,10 +406,10 @@ public class ActionBar extends FrameLayout { ...@@ -400,10 +406,10 @@ public class ActionBar extends FrameLayout {
protected void onSearchFieldVisibilityChanged(boolean visible) { protected void onSearchFieldVisibilityChanged(boolean visible) {
isSearchFieldVisible = visible; isSearchFieldVisible = visible;
if (titleTextView != null) { if (titleTextView != null) {
titleTextView.setVisibility(visible ? GONE : VISIBLE); titleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
} }
if (subTitleTextView != null) { if (subTitleTextView != null) {
subTitleTextView.setVisibility(visible ? GONE : VISIBLE); subTitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
} }
Drawable drawable = backButtonImageView.getDrawable(); Drawable drawable = backButtonImageView.getDrawable();
if (drawable != null && drawable instanceof MenuDrawable) { if (drawable != null && drawable instanceof MenuDrawable) {
...@@ -460,7 +466,7 @@ public class ActionBar extends FrameLayout { ...@@ -460,7 +466,7 @@ public class ActionBar extends FrameLayout {
createTitleTextView(); createTitleTextView();
} }
if (titleTextView != null) { if (titleTextView != null) {
titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : GONE); titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
titleTextView.setText(textToSet); titleTextView.setText(textToSet);
positionTitle(getMeasuredWidth(), getMeasuredHeight()); positionTitle(getMeasuredWidth(), getMeasuredHeight());
} }
......
...@@ -303,7 +303,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -303,7 +303,7 @@ public class ActionBarLayout extends FrameLayout {
} }
} }
} }
containerViewBack.setVisibility(View.GONE); containerViewBack.setVisibility(View.INVISIBLE);
//AndroidUtilities.unlockOrientation(parentActivity); //AndroidUtilities.unlockOrientation(parentActivity);
startedTracking = false; startedTracking = false;
animationInProgress = false; animationInProgress = false;
...@@ -321,7 +321,15 @@ public class ActionBarLayout extends FrameLayout { ...@@ -321,7 +321,15 @@ public class ActionBarLayout extends FrameLayout {
beginTrackingSent = false; beginTrackingSent = false;
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2); BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
View fragmentView = lastFragment.createView(parentActivity.getLayoutInflater()); View fragmentView = lastFragment.fragmentView;
if (fragmentView == null) {
fragmentView = lastFragment.createView(parentActivity, parentActivity.getLayoutInflater());
} else {
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
ViewGroup parent = (ViewGroup) fragmentView.getParent(); ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) { if (parent != null) {
parent.removeView(fragmentView); parent.removeView(fragmentView);
...@@ -342,7 +350,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -342,7 +350,7 @@ public class ActionBarLayout extends FrameLayout {
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
fragmentView.setLayoutParams(layoutParams); fragmentView.setLayoutParams(layoutParams);
if (fragmentView.getBackground() == null) { if (!lastFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
lastFragment.onResume(); lastFragment.onResume();
...@@ -372,7 +380,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -372,7 +380,7 @@ public class ActionBarLayout extends FrameLayout {
int dx = Math.max(0, (int) (ev.getX() - startedTrackingX)); int dx = Math.max(0, (int) (ev.getX() - startedTrackingX));
int dy = Math.abs((int) ev.getY() - startedTrackingY); int dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev); velocityTracker.addMovement(ev);
if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.dp(10) && Math.abs(dx) / 3 > dy) { if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.getPixelsInCM(0.3f, true) && Math.abs(dx) / 3 > dy) {
prepareForMoving(ev); prepareForMoving(ev);
} else if (startedTracking) { } else if (startedTracking) {
if (!beginTrackingSent) { if (!beginTrackingSent) {
...@@ -531,7 +539,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -531,7 +539,7 @@ public class ActionBarLayout extends FrameLayout {
} }
} }
} }
containerViewBack.setVisibility(View.GONE); containerViewBack.setVisibility(View.INVISIBLE);
} }
public boolean presentFragment(BaseFragment fragment) { public boolean presentFragment(BaseFragment fragment) {
...@@ -555,7 +563,15 @@ public class ActionBarLayout extends FrameLayout { ...@@ -555,7 +563,15 @@ public class ActionBarLayout extends FrameLayout {
final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null; final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;
fragment.setParentLayout(this); fragment.setParentLayout(this);
View fragmentView = fragment.createView(parentActivity.getLayoutInflater()); View fragmentView = fragment.fragmentView;
if (fragmentView == null) {
fragmentView = fragment.createView(parentActivity, parentActivity.getLayoutInflater());
} else {
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
if (fragment.needAddActionBar() && fragment.actionBar != null) { if (fragment.needAddActionBar() && fragment.actionBar != null) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false); fragment.actionBar.setOccupyStatusBar(false);
...@@ -576,7 +592,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -576,7 +592,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentsStack.add(fragment); fragmentsStack.add(fragment);
fragment.onResume(); fragment.onResume();
currentActionBar = fragment.actionBar; currentActionBar = fragment.actionBar;
if (fragmentView.getBackground() == null) { if (!fragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
...@@ -707,7 +723,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -707,7 +723,7 @@ public class ActionBarLayout extends FrameLayout {
fragment.onFragmentDestroy(); fragment.onFragmentDestroy();
fragment.setParentLayout(null); fragment.setParentLayout(null);
fragmentsStack.remove(fragment); fragmentsStack.remove(fragment);
containerViewBack.setVisibility(View.GONE); containerViewBack.setVisibility(View.INVISIBLE);
bringChildToFront(containerView); bringChildToFront(containerView);
} }
...@@ -733,7 +749,15 @@ public class ActionBarLayout extends FrameLayout { ...@@ -733,7 +749,15 @@ public class ActionBarLayout extends FrameLayout {
containerView.setVisibility(View.VISIBLE); containerView.setVisibility(View.VISIBLE);
previousFragment.setParentLayout(this); previousFragment.setParentLayout(this);
View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater()); View fragmentView = previousFragment.fragmentView;
if (fragmentView == null) {
fragmentView = previousFragment.createView(parentActivity, parentActivity.getLayoutInflater());
} else {
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false); previousFragment.actionBar.setOccupyStatusBar(false);
...@@ -752,7 +776,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -752,7 +776,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setLayoutParams(layoutParams); fragmentView.setLayoutParams(layoutParams);
previousFragment.onResume(); previousFragment.onResume();
currentActionBar = previousFragment.actionBar; currentActionBar = previousFragment.actionBar;
if (fragmentView.getBackground() == null) { if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
...@@ -804,9 +828,9 @@ public class ActionBarLayout extends FrameLayout { ...@@ -804,9 +828,9 @@ public class ActionBarLayout extends FrameLayout {
@Override @Override
public void run() { public void run() {
removeFragmentFromStack(currentFragment); removeFragmentFromStack(currentFragment);
setVisibility(GONE); setVisibility(INVISIBLE);
if (backgroundView != null) { if (backgroundView != null) {
backgroundView.setVisibility(GONE); backgroundView.setVisibility(INVISIBLE);
} }
if (drawerLayoutContainer != null) { if (drawerLayoutContainer != null) {
drawerLayoutContainer.setAllowOpenDrawer(true, false); drawerLayoutContainer.setAllowOpenDrawer(true, false);
...@@ -843,9 +867,9 @@ public class ActionBarLayout extends FrameLayout { ...@@ -843,9 +867,9 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation.start(); currentAnimation.start();
} else { } else {
removeFragmentFromStack(currentFragment); removeFragmentFromStack(currentFragment);
setVisibility(GONE); setVisibility(INVISIBLE);
if (backgroundView != null) { if (backgroundView != null) {
backgroundView.setVisibility(GONE); backgroundView.setVisibility(INVISIBLE);
} }
} }
} }
...@@ -857,7 +881,15 @@ public class ActionBarLayout extends FrameLayout { ...@@ -857,7 +881,15 @@ public class ActionBarLayout extends FrameLayout {
} }
BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1); BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1);
previousFragment.setParentLayout(this); previousFragment.setParentLayout(this);
View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater()); View fragmentView = previousFragment.fragmentView;
if (fragmentView == null) {
fragmentView = previousFragment.createView(parentActivity, parentActivity.getLayoutInflater());
} else {
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false); previousFragment.actionBar.setOccupyStatusBar(false);
...@@ -876,7 +908,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -876,7 +908,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setLayoutParams(layoutParams); fragmentView.setLayoutParams(layoutParams);
previousFragment.onResume(); previousFragment.onResume();
currentActionBar = previousFragment.actionBar; currentActionBar = previousFragment.actionBar;
if (fragmentView.getBackground() == null) { if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
} }
......
...@@ -10,6 +10,7 @@ package org.telegram.ui.ActionBar; ...@@ -10,6 +10,7 @@ package org.telegram.ui.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
...@@ -31,6 +32,7 @@ public class BaseFragment { ...@@ -31,6 +32,7 @@ public class BaseFragment {
protected int classGuid = 0; protected int classGuid = 0;
protected Bundle arguments; protected Bundle arguments;
protected boolean swipeBackEnabled = true; protected boolean swipeBackEnabled = true;
protected boolean hasOwnBackground = false;
public BaseFragment() { public BaseFragment() {
classGuid = ConnectionsManager.getInstance().generateClassGuid(); classGuid = ConnectionsManager.getInstance().generateClassGuid();
...@@ -41,7 +43,7 @@ public class BaseFragment { ...@@ -41,7 +43,7 @@ public class BaseFragment {
classGuid = ConnectionsManager.getInstance().generateClassGuid(); classGuid = ConnectionsManager.getInstance().generateClassGuid();
} }
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
return null; return null;
} }
...@@ -201,9 +203,9 @@ public class BaseFragment { ...@@ -201,9 +203,9 @@ public class BaseFragment {
return true; return true;
} }
public void showAlertDialog(AlertDialog.Builder builder) { public AlertDialog showAlertDialog(AlertDialog.Builder builder) {
if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) { if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) {
return; return null;
} }
try { try {
if (visibleDialog != null) { if (visibleDialog != null) {
...@@ -223,9 +225,11 @@ public class BaseFragment { ...@@ -223,9 +225,11 @@ public class BaseFragment {
onDialogDismiss(); onDialogDismiss();
} }
}); });
return visibleDialog;
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
return null;
} }
protected void onDialogDismiss() { protected void onDialogDismiss() {
......
...@@ -301,7 +301,7 @@ public class DrawerLayoutContainer extends FrameLayout { ...@@ -301,7 +301,7 @@ public class DrawerLayoutContainer extends FrameLayout {
float dx = (int) (ev.getX() - startedTrackingX); float dx = (int) (ev.getX() - startedTrackingX);
float dy = Math.abs((int) ev.getY() - startedTrackingY); float dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev); velocityTracker.addMovement(ev);
if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.dp(10))) { if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.2f, true) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.3f, true))) {
prepareForDrawerOpen(ev); prepareForDrawerOpen(ev);
startedTrackingX = (int) ev.getX(); startedTrackingX = (int) ev.getX();
requestDisallowInterceptTouchEvent(true); requestDisallowInterceptTouchEvent(true);
......
...@@ -73,7 +73,7 @@ public class CountrySearchAdapter extends BaseFragmentAdapter { ...@@ -73,7 +73,7 @@ public class CountrySearchAdapter extends BaseFragmentAdapter {
return; return;
} }
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
ArrayList<Country> resultArray = new ArrayList<Country>(); ArrayList<Country> resultArray = new ArrayList<>();
String n = query.substring(0, 1); String n = query.substring(0, 1);
ArrayList<Country> arr = countries.get(n.toUpperCase()); ArrayList<Country> arr = countries.get(n.toUpperCase());
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
package org.telegram.ui.Adapters; package org.telegram.ui.Adapters;
import android.content.Context; import android.content.Context;
import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -348,7 +347,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { ...@@ -348,7 +347,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
user.status.expires = cursor.intValue(7); user.status.expires = cursor.intValue(7);
} }
if (found == 1) { if (found == 1) {
dialogSearchResult.name = Html.fromHtml("<font color=\"#00a60e\">" + ContactsController.formatName(user.first_name, user.last_name) + "</font>"); dialogSearchResult.name = AndroidUtilities.replaceTags("<c#ff00a60e>" + ContactsController.formatName(user.first_name, user.last_name) + "</c>");
} else { } else {
dialogSearchResult.name = Utilities.generateSearchName("@" + user.username, null, "@" + q); dialogSearchResult.name = Utilities.generateSearchName("@" + user.username, null, "@" + q);
} }
...@@ -534,6 +533,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { ...@@ -534,6 +533,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
notifyDataSetChanged(); notifyDataSetChanged();
return; return;
} }
searchResultMessages.clear();
searchResultHashtags.clear(); searchResultHashtags.clear();
for (HashtagObject hashtagObject : hashtags) { for (HashtagObject hashtagObject : hashtags) {
searchResultHashtags.add(hashtagObject.hashtag); searchResultHashtags.add(hashtagObject.hashtag);
...@@ -670,10 +670,11 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { ...@@ -670,10 +670,11 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != localCount - 1 && i != localCount + globalCount - 1); ((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != localCount - 1 && i != localCount + globalCount - 1);
Object obj = getItem(i); Object obj = getItem(i);
if (obj instanceof TLRPC.User) { if (obj instanceof TLRPC.User) {
user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id); /*user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id);
if (user == null) { if (user == null) {
user = (TLRPC.User) obj; user = (TLRPC.User) obj;
} }*/
user = (TLRPC.User) obj;
} else if (obj instanceof TLRPC.Chat) { } else if (obj instanceof TLRPC.Chat) {
chat = MessagesController.getInstance().getChat(((TLRPC.Chat) obj).id); chat = MessagesController.getInstance().getChat(((TLRPC.Chat) obj).id);
} else if (obj instanceof TLRPC.EncryptedChat) { } else if (obj instanceof TLRPC.EncryptedChat) {
...@@ -697,7 +698,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter { ...@@ -697,7 +698,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
foundUserName = foundUserName.substring(1); foundUserName = foundUserName.substring(1);
} }
try { try {
username = Html.fromHtml(String.format("<font color=\"#4d83b3\">@%s</font>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length()))); username = AndroidUtilities.replaceTags(String.format("<c#ff4d83b3>@%s</c>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
} catch (Exception e) { } catch (Exception e) {
username = user.username; username = user.username;
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
package org.telegram.ui.Adapters; package org.telegram.ui.Adapters;
import android.content.Context; import android.content.Context;
import android.text.Html;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -257,7 +256,7 @@ public class SearchAdapter extends BaseSearchAdapter { ...@@ -257,7 +256,7 @@ public class SearchAdapter extends BaseSearchAdapter {
foundUserName = foundUserName.substring(1); foundUserName = foundUserName.substring(1);
} }
try { try {
username = Html.fromHtml(String.format("<font color=\"#4d83b3\">@%s</font>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length()))); username = AndroidUtilities.replaceTags(String.format("<c#ff4d83b3>@%s</c>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
} catch (Exception e) { } catch (Exception e) {
username = user.username; username = user.username;
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
......
...@@ -14,7 +14,6 @@ import android.content.res.Configuration; ...@@ -14,7 +14,6 @@ import android.content.res.Configuration;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.Layout; import android.text.Layout;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
...@@ -83,9 +82,9 @@ public class ChatBaseCell extends BaseCell { ...@@ -83,9 +82,9 @@ public class ChatBaseCell extends BaseCell {
private static TextPaint timeMediaPaint; private static TextPaint timeMediaPaint;
private static TextPaint namePaint; private static TextPaint namePaint;
private static TextPaint forwardNamePaint; private static TextPaint forwardNamePaint;
private static TextPaint replyNamePaint; protected static TextPaint replyNamePaint;
private static TextPaint replyTextPaint; protected static TextPaint replyTextPaint;
private static Paint replyLinePaint; protected static Paint replyLinePaint;
protected int backgroundWidth = 100; protected int backgroundWidth = 100;
...@@ -191,6 +190,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -191,6 +190,7 @@ public class ChatBaseCell extends BaseCell {
replyTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); replyTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
replyTextPaint.setTextSize(AndroidUtilities.dp(14)); replyTextPaint.setTextSize(AndroidUtilities.dp(14));
replyTextPaint.linkColor = 0xff316f9f;
replyLinePaint = new Paint(); replyLinePaint = new Paint();
} }
...@@ -362,7 +362,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -362,7 +362,7 @@ public class ChatBaseCell extends BaseCell {
forwardedNameWidth = getMaxNameWidth(); forwardedNameWidth = getMaxNameWidth();
CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40), TextUtils.TruncateAt.END); CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40), TextUtils.TruncateAt.END);
str = Html.fromHtml(String.format("%s<br>%s <b>%s</b>", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str)); str = AndroidUtilities.replaceTags(String.format("%s\n%s <b>%s</b>", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str));
forwardedNameLayout = new StaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); forwardedNameLayout = new StaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (forwardedNameLayout.getLineCount() > 1) { if (forwardedNameLayout.getLineCount() > 1) {
forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1))); forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1)));
......
...@@ -58,7 +58,7 @@ public class DrawerProfileCell extends FrameLayout { ...@@ -58,7 +58,7 @@ public class DrawerProfileCell extends FrameLayout {
shadowView.setLayoutParams(layoutParams); shadowView.setLayoutParams(layoutParams);
avatarImageView = new BackupImageView(context); avatarImageView = new BackupImageView(context);
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(32)); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));
addView(avatarImageView); addView(avatarImageView);
layoutParams = (LayoutParams) avatarImageView.getLayoutParams(); layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(64); layoutParams.width = AndroidUtilities.dp(64);
......
...@@ -37,7 +37,7 @@ public class MentionCell extends LinearLayout { ...@@ -37,7 +37,7 @@ public class MentionCell extends LinearLayout {
avatarDrawable.setSmallStyle(true); avatarDrawable.setSmallStyle(true);
imageView = new BackupImageView(context); imageView = new BackupImageView(context);
imageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(14)); imageView.setRoundRadius(AndroidUtilities.dp(14));
addView(imageView); addView(imageView);
LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams(); LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
layoutParams.leftMargin = AndroidUtilities.dp(12); layoutParams.leftMargin = AndroidUtilities.dp(12);
......
...@@ -30,6 +30,7 @@ import org.telegram.messenger.UserConfig; ...@@ -30,6 +30,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
public class ProfileSearchCell extends BaseCell { public class ProfileSearchCell extends BaseCell {
private static TextPaint namePaint; private static TextPaint namePaint;
private static TextPaint nameEncryptedPaint; private static TextPaint nameEncryptedPaint;
private static TextPaint onlinePaint; private static TextPaint onlinePaint;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment