Commit 300659e3 authored by DrKLO's avatar DrKLO

Update to 2.6.0

Replies
Mentions
Hashtags
New messages forward logic
Blur in photo editor
parent 0f4b8901
...@@ -3,7 +3,7 @@ buildscript { ...@@ -3,7 +3,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.1.0' classpath 'com.android.tools.build:gradle:1.1.3'
} }
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
...@@ -13,7 +13,7 @@ repositories { ...@@ -13,7 +13,7 @@ repositories {
} }
dependencies { dependencies {
compile 'com.android.support:support-v4:21.0.+' compile 'com.android.support:support-v4:22.0.+'
compile 'com.google.android.gms:play-services:3.2.+' compile 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.5.+' compile 'net.hockeyapp.android:HockeySDK:3.5.+'
compile 'com.googlecode.mp4parser:isoparser:1.0.+' compile 'com.googlecode.mp4parser:isoparser:1.0.+'
...@@ -21,8 +21,8 @@ dependencies { ...@@ -21,8 +21,8 @@ dependencies {
} }
android { android {
compileSdkVersion 21 compileSdkVersion 22
buildToolsVersion '21.1.2' buildToolsVersion '22.0.0'
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7 sourceCompatibility JavaVersion.VERSION_1_7
...@@ -81,8 +81,8 @@ android { ...@@ -81,8 +81,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 21 targetSdkVersion 22
versionCode 458 versionCode 466
versionName "2.5.2" versionName "2.6.0"
} }
} }
...@@ -22,17 +22,17 @@ import java.io.IOException; ...@@ -22,17 +22,17 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public interface PyroClientListener { public interface PyroClientListener {
public void connectedClient(PyroClient client); void connectedClient(PyroClient client);
public void unconnectableClient(PyroClient client, Exception cause); void unconnectableClient(PyroClient client, Exception cause);
public void droppedClient(PyroClient client, IOException cause); void droppedClient(PyroClient client, IOException cause);
public void disconnectedClient(PyroClient client); void disconnectedClient(PyroClient client);
// //
public void receivedData(PyroClient client, ByteBuffer data); void receivedData(PyroClient client, ByteBuffer data);
public void sentData(PyroClient client, int bytes); void sentData(PyroClient client, int bytes);
} }
...@@ -169,8 +169,6 @@ public class AndroidUtilities { ...@@ -169,8 +169,6 @@ public class AndroidUtilities {
} }
InputMethodManager inputManager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager inputManager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
((InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0);
} }
public static boolean isKeyboardShowed(View view) { public static boolean isKeyboardShowed(View view) {
......
...@@ -29,8 +29,8 @@ import org.telegram.messenger.Utilities; ...@@ -29,8 +29,8 @@ import org.telegram.messenger.Utilities;
public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate { public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate {
public static interface ImageReceiverDelegate { public interface ImageReceiverDelegate {
public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb); void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb);
} }
private View parentView; private View parentView;
......
...@@ -87,12 +87,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -87,12 +87,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public static int[] readArgs = new int[3]; public static int[] readArgs = new int[3];
public static interface FileDownloadProgressListener { public interface FileDownloadProgressListener {
public void onFailedDownload(String fileName); void onFailedDownload(String fileName);
public void onSuccessDownload(String fileName); void onSuccessDownload(String fileName);
public void onProgressDownload(String fileName, float progress); void onProgressDownload(String fileName, float progress);
public void onProgressUpload(String fileName, float progress, boolean isEncrypted); void onProgressUpload(String fileName, float progress, boolean isEncrypted);
public int getObserverTag(); int getObserverTag();
} }
private class AudioBuffer { private class AudioBuffer {
...@@ -234,6 +234,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -234,6 +234,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
private long recordStartTime; private long recordStartTime;
private long recordTimeCount; private long recordTimeCount;
private long recordDialogId; private long recordDialogId;
private MessageObject recordReplyingMessageObject;
private DispatchQueue fileDecodingQueue; private DispatchQueue fileDecodingQueue;
private DispatchQueue playerQueue; private DispatchQueue playerQueue;
private ArrayList<AudioBuffer> usedPlayerBuffers = new ArrayList<>(); private ArrayList<AudioBuffer> usedPlayerBuffers = new ArrayList<>();
...@@ -509,7 +510,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -509,7 +510,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
lastProgress = progress; lastProgress = progress;
playingMessageObject.audioProgress = value; playingMessageObject.audioProgress = value;
playingMessageObject.audioProgressSec = lastProgress / 1000; playingMessageObject.audioProgressSec = lastProgress / 1000;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioProgressDidChanged, playingMessageObject.messageOwner.id, value); NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioProgressDidChanged, playingMessageObject.getId(), value);
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
...@@ -977,7 +978,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -977,7 +978,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} else if (id == NotificationCenter.messagesDeleted) { } else if (id == NotificationCenter.messagesDeleted) {
if (playingMessageObject != null) { if (playingMessageObject != null) {
ArrayList<Integer> markAsDeletedMessages = (ArrayList<Integer>)args[0]; ArrayList<Integer> markAsDeletedMessages = (ArrayList<Integer>)args[0];
if (markAsDeletedMessages.contains(playingMessageObject.messageOwner.id)) { if (markAsDeletedMessages.contains(playingMessageObject.getId())) {
clenupPlayer(false); clenupPlayer(false);
} }
} }
...@@ -1187,7 +1188,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1187,7 +1188,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
playingMessageObject.audioProgressSec = 0; playingMessageObject.audioProgressSec = 0;
playingMessageObject = null; playingMessageObject = null;
if (notify) { if (notify) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidReset, lastFile.messageOwner.id); NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidReset, lastFile.getId());
} }
} }
} }
...@@ -1227,7 +1228,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1227,7 +1228,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} }
public boolean seekToProgress(MessageObject messageObject, float progress) { public boolean seekToProgress(MessageObject messageObject, float progress) {
if (audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.messageOwner.id != messageObject.messageOwner.id) { if (audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.getId() != messageObject.getId()) {
return false; return false;
} }
try { try {
...@@ -1249,7 +1250,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1249,7 +1250,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (messageObject == null) { if (messageObject == null) {
return false; return false;
} }
if ((audioTrackPlayer != null || audioPlayer != null) && playingMessageObject != null && messageObject.messageOwner.id == playingMessageObject.messageOwner.id) { if ((audioTrackPlayer != null || audioPlayer != null) && playingMessageObject != null && messageObject.getId() == playingMessageObject.getId()) {
if (isPaused) { if (isPaused) {
resumeAudio(messageObject); resumeAudio(messageObject);
} }
...@@ -1412,7 +1413,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1412,7 +1413,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public boolean pauseAudio(MessageObject messageObject) { public boolean pauseAudio(MessageObject messageObject) {
stopProximitySensor(); stopProximitySensor();
if (audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.messageOwner.id != messageObject.messageOwner.id) { if (audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.getId() != messageObject.getId()) {
return false; return false;
} }
try { try {
...@@ -1432,7 +1433,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1432,7 +1433,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public boolean resumeAudio(MessageObject messageObject) { public boolean resumeAudio(MessageObject messageObject) {
startProximitySensor(); startProximitySensor();
if (audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.messageOwner.id != messageObject.messageOwner.id) { if (audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.getId() != messageObject.getId()) {
return false; return false;
} }
try { try {
...@@ -1451,14 +1452,14 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1451,14 +1452,14 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} }
public boolean isPlayingAudio(MessageObject messageObject) { public boolean isPlayingAudio(MessageObject messageObject) {
return !(audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.messageOwner.id != messageObject.messageOwner.id); return !(audioTrackPlayer == null && audioPlayer == null || messageObject == null || playingMessageObject == null || playingMessageObject != null && playingMessageObject.getId() != messageObject.getId());
} }
public boolean isAudioPaused() { public boolean isAudioPaused() {
return isPaused; return isPaused;
} }
public void startRecording(final long dialog_id) { public void startRecording(final long dialog_id, final MessageObject reply_to_msg) {
clenupPlayer(true); clenupPlayer(true);
try { try {
...@@ -1505,6 +1506,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1505,6 +1506,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
recordStartTime = System.currentTimeMillis(); recordStartTime = System.currentTimeMillis();
recordTimeCount = 0; recordTimeCount = 0;
recordDialogId = dialog_id; recordDialogId = dialog_id;
recordReplyingMessageObject = reply_to_msg;
fileBuffer.rewind(); fileBuffer.rewind();
audioRecorder.startRecording(); audioRecorder.startRecording();
...@@ -1557,11 +1559,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1557,11 +1559,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
long duration = recordTimeCount; long duration = recordTimeCount;
audioToSend.duration = (int) (duration / 1000); audioToSend.duration = (int) (duration / 1000);
if (duration > 700) { if (duration > 700) {
SendMessagesHelper.getInstance().sendMessage(audioToSend, recordingAudioFileToSend.getAbsolutePath(), recordDialogId); SendMessagesHelper.getInstance().sendMessage(audioToSend, recordingAudioFileToSend.getAbsolutePath(), recordDialogId, recordReplyingMessageObject);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidSent);
} else { } else {
recordingAudioFileToSend.delete(); recordingAudioFileToSend.delete();
} }
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidSent);
} }
}); });
} }
...@@ -1739,7 +1741,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1739,7 +1741,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
return null; return null;
} }
if (currentGifDrawable != null && currentGifMessageObject != null && messageObject.messageOwner.id == currentGifMessageObject.messageOwner.id) { if (currentGifDrawable != null && currentGifMessageObject != null && messageObject.getId() == currentGifMessageObject.getId()) {
currentMediaCell = cell; currentMediaCell = cell;
currentGifDrawable.parentView = new WeakReference<View>(cell); currentGifDrawable.parentView = new WeakReference<View>(cell);
return currentGifDrawable; return currentGifDrawable;
...@@ -1788,7 +1790,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1788,7 +1790,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
return; return;
} }
if (currentGifMessageObject != null && messageObject.messageOwner.id == currentGifMessageObject.messageOwner.id) { if (currentGifMessageObject != null && messageObject.getId() == currentGifMessageObject.getId()) {
if (currentGifDrawable != null) { if (currentGifDrawable != null) {
currentGifDrawable.stop(); currentGifDrawable.stop();
currentGifDrawable.recycle(); currentGifDrawable.recycle();
......
...@@ -30,6 +30,8 @@ import java.util.AbstractMap; ...@@ -30,6 +30,8 @@ import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MessageObject { public class MessageObject {
...@@ -39,6 +41,7 @@ public class MessageObject { ...@@ -39,6 +41,7 @@ public class MessageObject {
public TLRPC.Message messageOwner; public TLRPC.Message messageOwner;
public CharSequence messageText; public CharSequence messageText;
public MessageObject replyMessageObject;
public int type; public int type;
public int contentType; public int contentType;
public String dateKey; public String dateKey;
...@@ -76,6 +79,10 @@ public class MessageObject { ...@@ -76,6 +79,10 @@ public class MessageObject {
messageOwner = message; messageOwner = message;
if (message.replyMessage != null) {
replyMessageObject = new MessageObject(message.replyMessage, users, false);
}
if (message instanceof TLRPC.TL_messageService) { if (message instanceof TLRPC.TL_messageService) {
if (message.action != null) { if (message.action != null) {
TLRPC.User fromUser = null; TLRPC.User fromUser = null;
...@@ -279,9 +286,19 @@ public class MessageObject { ...@@ -279,9 +286,19 @@ public class MessageObject {
messageText = LocaleController.getString("UnsuppotedMedia", R.string.UnsuppotedMedia); messageText = LocaleController.getString("UnsuppotedMedia", R.string.UnsuppotedMedia);
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
if (isSticker()) { if (isSticker()) {
messageText = LocaleController.getString("AttachSticker", R.string.AttachSticker); String sch = getStrickerChar();
if (sch != null && sch.length() > 0) {
messageText = String.format("%s %s", sch, LocaleController.getString("AttachSticker", R.string.AttachSticker));
} else {
messageText = LocaleController.getString("AttachSticker", R.string.AttachSticker);
}
} else { } else {
messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument); String name = FileLoader.getDocumentFileName(message.media.document);
if (name != null && name.length() > 0) {
messageText = name;
} else {
messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument);
}
} }
} else if (message.media instanceof TLRPC.TL_messageMediaAudio) { } else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
messageText = LocaleController.getString("AttachAudio", R.string.AttachAudio); messageText = LocaleController.getString("AttachAudio", R.string.AttachAudio);
...@@ -291,7 +308,7 @@ public class MessageObject { ...@@ -291,7 +308,7 @@ 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) { if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded_old2) {
if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) { if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) {
contentType = type = 0; contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) { } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) {
...@@ -487,6 +504,9 @@ public class MessageObject { ...@@ -487,6 +504,9 @@ public class MessageObject {
} else if (!(c != ' ' && digitsInRow > 0)) { } else if (!(c != ' ' && digitsInRow > 0)) {
digitsInRow = 0; digitsInRow = 0;
} }
if ((c == '@' || c == '#') && i == 0 || i != 0 && message.charAt(i - 1) == ' ') {
return true;
}
if (c == ':') { if (c == ':') {
if (schemeSequence == 0) { if (schemeSequence == 0) {
schemeSequence = 1; schemeSequence = 1;
...@@ -531,6 +551,22 @@ public class MessageObject { ...@@ -531,6 +551,22 @@ public class MessageObject {
} else { } else {
Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS); Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS);
} }
try {
Pattern pattern = Pattern.compile("(^|\\s)@[a-zA-Z\\d_]{5,32}|(^|\\s)#[\\w@\\.]+");
Matcher matcher = pattern.matcher(messageText);
while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
if (messageText.charAt(start) != '@' && messageText.charAt(start) != '#') {
start++;
}
URLSpanNoUnderline url = new URLSpanNoUnderline(messageText.subSequence(start, end).toString());
((Spannable) messageText).setSpan(url, start, end, 0);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} }
int maxWidth; int maxWidth;
...@@ -703,6 +739,10 @@ public class MessageObject { ...@@ -703,6 +739,10 @@ public class MessageObject {
messageOwner.flags &= ~TLRPC.MESSAGE_FLAG_UNREAD; messageOwner.flags &= ~TLRPC.MESSAGE_FLAG_UNREAD;
} }
public int getId() {
return messageOwner.id;
}
public boolean isSecretPhoto() { public boolean isSecretPhoto() {
return messageOwner instanceof TLRPC.TL_message_secret && messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageOwner.ttl != 0 && messageOwner.ttl <= 60; return messageOwner instanceof TLRPC.TL_message_secret && messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageOwner.ttl != 0 && messageOwner.ttl <= 60;
} }
...@@ -791,7 +831,121 @@ public class MessageObject { ...@@ -791,7 +831,121 @@ public class MessageObject {
return false; return false;
} }
public String getStrickerChar() {
if (messageOwner.media != null && messageOwner.media.document != null) {
for (TLRPC.DocumentAttribute attribute : messageOwner.media.document.attributes) {
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
return attribute.alt;
}
}
}
return null;
}
public int getApproximateHeight() {
if (type == 0) {
return textHeight;
} else if (contentType == 2) {
return AndroidUtilities.dp(68);
} else if (contentType == 3) {
return AndroidUtilities.dp(71);
} else if (type == 9) {
return AndroidUtilities.dp(100);
} else if (type == 4) {
return AndroidUtilities.dp(114);
} else if (type == 13) {
float maxHeight = AndroidUtilities.displaySize.y * 0.4f;
float maxWidth;
if (AndroidUtilities.isTablet()) {
maxWidth = AndroidUtilities.getMinTabletSide() * 0.5f;
} else {
maxWidth = AndroidUtilities.displaySize.x * 0.5f;
}
int photoHeight = 0;
int photoWidth = 0;
for (TLRPC.DocumentAttribute attribute : messageOwner.media.document.attributes) {
if (attribute instanceof TLRPC.TL_documentAttributeImageSize) {
photoWidth = attribute.w;
photoHeight = attribute.h;
break;
}
}
if (photoWidth == 0) {
photoHeight = (int) maxHeight;
photoWidth = photoHeight + AndroidUtilities.dp(100);
}
if (photoHeight > maxHeight) {
photoWidth *= maxHeight / photoHeight;
photoHeight = (int)maxHeight;
}
if (photoWidth > maxWidth) {
photoHeight *= maxWidth / photoWidth;
}
return photoHeight + AndroidUtilities.dp(14);
} else {
int photoHeight = 0;
int photoWidth = 0;
if (AndroidUtilities.isTablet()) {
photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
} else {
photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
}
photoHeight = photoWidth + AndroidUtilities.dp(100);
if (photoWidth > AndroidUtilities.getPhotoSize()) {
photoWidth = AndroidUtilities.getPhotoSize();
}
if (photoHeight > AndroidUtilities.getPhotoSize()) {
photoHeight = AndroidUtilities.getPhotoSize();
}
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, AndroidUtilities.getPhotoSize());
if (currentPhotoObject != null) {
float scale = (float) currentPhotoObject.w / (float) photoWidth;
int w = (int) (currentPhotoObject.w / scale);
int h = (int) (currentPhotoObject.h / scale);
if (w == 0) {
w = AndroidUtilities.dp(100);
}
if (h == 0) {
h = AndroidUtilities.dp(100);
}
if (h > photoHeight) {
float scale2 = h;
h = photoHeight;
scale2 /= h;
w = (int) (w / scale2);
} else if (h < AndroidUtilities.dp(120)) {
h = AndroidUtilities.dp(120);
float hScale = (float) currentPhotoObject.h / h;
if (currentPhotoObject.w / hScale < photoWidth) {
w = (int) (currentPhotoObject.w / hScale);
}
}
if (isSecretPhoto()) {
if (AndroidUtilities.isTablet()) {
w = h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
} else {
w = h = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
}
}
photoWidth = w;
photoHeight = h;
}
return photoHeight + AndroidUtilities.dp(14);
}
}
public boolean isSticker() { public boolean isSticker() {
return isStickerMessage(messageOwner); return isStickerMessage(messageOwner);
} }
public boolean isForwarded() {
return (messageOwner.flags & TLRPC.MESSAGE_FLAG_FWD) != 0;
}
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;
}
} }
...@@ -51,6 +51,7 @@ public class NotificationCenter { ...@@ -51,6 +51,7 @@ public class NotificationCenter {
public static final int didSetPasscode = totalEvents++; public static final int didSetPasscode = 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 httpFileDidLoaded = totalEvents++; public static final int httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++; public static final int httpFileDidFailedLoad = totalEvents++;
...@@ -109,7 +110,7 @@ public class NotificationCenter { ...@@ -109,7 +110,7 @@ public class NotificationCenter {
} }
public interface NotificationCenterDelegate { public interface NotificationCenterDelegate {
public abstract void didReceivedNotification(int id, Object... args); void didReceivedNotification(int id, Object... args);
} }
public void postNotificationName(int id, Object... args) { public void postNotificationName(int id, Object... args) {
......
...@@ -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); SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null);
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);
} }
} }
/*
* This is the source code of Telegram for Android v. 2.x
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2015.
*/
package org.telegram.android.query;
import android.text.TextUtils;
import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ImageLoader;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ByteBufferDesc;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLClassStore;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
public class ReplyMessageQuery {
public static void loadReplyMessagesForMessages(final ArrayList<MessageObject> messages, final long dialog_id) {
final ArrayList<Integer> replyMessages = new ArrayList<>();
final HashMap<Integer, ArrayList<MessageObject>> replyMessageOwners = new HashMap<>();
for (MessageObject messageObject : messages) {
if (messageObject.getId() > 0 && messageObject.isReply() && messageObject.replyMessageObject == null) {
Integer id = messageObject.messageOwner.reply_to_msg_id;
ArrayList<MessageObject> messageObjects = replyMessageOwners.get(id);
if (messageObjects == null) {
messageObjects = new ArrayList<>();
replyMessageOwners.put(id, messageObjects);
}
messageObjects.add(messageObject);
if (!replyMessages.contains(id)) {
replyMessages.add(id);
}
}
}
if (replyMessages.isEmpty()) {
return;
}
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
try {
final ArrayList<TLRPC.Message> result = new ArrayList<>();
final ArrayList<TLRPC.User> users = new ArrayList<>();
ArrayList<Integer> loadedUsers = new ArrayList<>();
ArrayList<Integer> fromUser = new ArrayList<>();
SQLiteCursor cursor = MessagesStorage.getInstance().getDatabase().queryFinalized(String.format(Locale.US, "SELECT data, mid, date FROM messages WHERE mid IN(%s)", TextUtils.join(",", replyMessages)));
while (cursor.next()) {
ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0));
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
message.id = cursor.intValue(1);
message.date = cursor.intValue(2);
message.dialog_id = dialog_id;
fromUser.add(message.from_id);
if (message.action != null && message.action.user_id != 0) {
fromUser.add(message.action.user_id);
}
if (message.media != null && message.media.user_id != 0) {
fromUser.add(message.media.user_id);
}
if (message.media != null && message.media.audio != null && message.media.audio.user_id != 0) {
fromUser.add(message.media.audio.user_id);
}
if (message.fwd_from_id != 0) {
fromUser.add(message.fwd_from_id);
}
result.add(message);
replyMessages.remove((Integer) message.id);
}
MessagesStorage.getInstance().getBuffersStorage().reuseFreeBuffer(data);
}
cursor.dispose();
StringBuilder usersToLoad = new StringBuilder();
for (int uid : fromUser) {
if (!loadedUsers.contains(uid)) {
if (usersToLoad.length() != 0) {
usersToLoad.append(",");
}
usersToLoad.append(uid);
loadedUsers.add(uid);
}
}
if (usersToLoad.length() != 0) {
MessagesStorage.getInstance().getUsersInternal(usersToLoad.toString(), users);
}
broadcastReplyMessages(result, replyMessageOwners, users, dialog_id);
if (!replyMessages.isEmpty()) {
TLRPC.TL_messages_getMessages req = new TLRPC.TL_messages_getMessages();
req.id = replyMessages;
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
TLRPC.messages_Messages messagesRes = (TLRPC.messages_Messages) response;
ImageLoader.saveMessagesThumbs(messagesRes.messages);
broadcastReplyMessages(messagesRes.messages, replyMessageOwners, messagesRes.users, dialog_id);
MessagesStorage.getInstance().putUsersAndChats(messagesRes.users, null, true, true);
saveReplyMessages(replyMessageOwners, messagesRes.messages);
}
}
});
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
private static void saveReplyMessages(final HashMap<Integer, ArrayList<MessageObject>> replyMessageOwners, final ArrayList<TLRPC.Message> result) {
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
try {
MessagesStorage.getInstance().getDatabase().beginTransaction();
SQLitePreparedStatement state = MessagesStorage.getInstance().getDatabase().executeFast("UPDATE messages SET replydata = ? WHERE mid = ?");
for (TLRPC.Message message : result) {
ArrayList<MessageObject> messageObjects = replyMessageOwners.get(message.id);
if (messageObjects != null) {
ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(message.getObjectSize());
message.serializeToStream(data);
for (MessageObject messageObject : messageObjects) {
state.requery();
state.bindByteBuffer(1, data.buffer);
state.bindInteger(2, messageObject.getId());
state.step();
}
MessagesStorage.getInstance().getBuffersStorage().reuseFreeBuffer(data);
}
}
state.dispose();
MessagesStorage.getInstance().getDatabase().commitTransaction();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
private static void broadcastReplyMessages(final ArrayList<TLRPC.Message> result, final HashMap<Integer, ArrayList<MessageObject>> replyMessageOwners, ArrayList<TLRPC.User> users, final long dialog_id) {
final HashMap<Integer, TLRPC.User> usersHashMap = new HashMap<>();
for (TLRPC.User user : users) {
usersHashMap.put(user.id, user);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
boolean changed = false;
for (TLRPC.Message message : result) {
ArrayList<MessageObject> arrayList = replyMessageOwners.get(message.id);
if (arrayList != null) {
MessageObject messageObject = new MessageObject(message, usersHashMap, false);
for (MessageObject m : arrayList) {
m.replyMessageObject = messageObject;
}
changed = true;
}
}
if (changed) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didLoadedReplyMessages, dialog_id);
}
}
});
}
}
...@@ -28,43 +28,43 @@ public interface Cache { ...@@ -28,43 +28,43 @@ public interface Cache {
* @param key Cache key * @param key Cache key
* @return An {@link Entry} or null in the event of a cache miss * @return An {@link Entry} or null in the event of a cache miss
*/ */
public Entry get(String key); Entry get(String key);
/** /**
* Adds or replaces an entry to the cache. * Adds or replaces an entry to the cache.
* @param key Cache key * @param key Cache key
* @param entry Data to store and metadata for cache coherency, TTL, etc. * @param entry Data to store and metadata for cache coherency, TTL, etc.
*/ */
public void put(String key, Entry entry); void put(String key, Entry entry);
/** /**
* Performs any potentially long-running actions needed to initialize the cache; * Performs any potentially long-running actions needed to initialize the cache;
* will be called from a worker thread. * will be called from a worker thread.
*/ */
public void initialize(); void initialize();
/** /**
* Invalidates an entry in the cache. * Invalidates an entry in the cache.
* @param key Cache key * @param key Cache key
* @param fullExpire True to fully expire the entry, false to soft expire * @param fullExpire True to fully expire the entry, false to soft expire
*/ */
public void invalidate(String key, boolean fullExpire); void invalidate(String key, boolean fullExpire);
/** /**
* Removes an entry from the cache. * Removes an entry from the cache.
* @param key Cache key * @param key Cache key
*/ */
public void remove(String key); void remove(String key);
/** /**
* Empties the cache. * Empties the cache.
*/ */
public void clear(); void clear();
/** /**
* Data and metadata for an entry returned by the cache. * Data and metadata for an entry returned by the cache.
*/ */
public static class Entry { class Entry {
/** The data returned from cache. */ /** The data returned from cache. */
public byte[] data; public byte[] data;
......
...@@ -26,5 +26,5 @@ public interface Network { ...@@ -26,5 +26,5 @@ public interface Network {
* @return A {@link NetworkResponse} with data and caching metadata; will never be null * @return A {@link NetworkResponse} with data and caching metadata; will never be null
* @throws VolleyError on errors * @throws VolleyError on errors
*/ */
public NetworkResponse performRequest(Request<?> request) throws VolleyError; NetworkResponse performRequest(Request<?> request) throws VolleyError;
} }
...@@ -175,7 +175,7 @@ public class RequestQueue { ...@@ -175,7 +175,7 @@ public class RequestQueue {
* {@link RequestQueue#cancelAll(RequestFilter)}. * {@link RequestQueue#cancelAll(RequestFilter)}.
*/ */
public interface RequestFilter { public interface RequestFilter {
public boolean apply(Request<?> request); boolean apply(Request<?> request);
} }
/** /**
......
...@@ -26,7 +26,7 @@ public class Response<T> { ...@@ -26,7 +26,7 @@ public class Response<T> {
/** Callback interface for delivering parsed responses. */ /** Callback interface for delivering parsed responses. */
public interface Listener<T> { public interface Listener<T> {
/** Called when a response is received. */ /** Called when a response is received. */
public void onResponse(T response); void onResponse(T response);
} }
/** Callback interface for delivering error responses. */ /** Callback interface for delivering error responses. */
...@@ -35,7 +35,7 @@ public class Response<T> { ...@@ -35,7 +35,7 @@ public class Response<T> {
* Callback method that an error has been occurred with the * Callback method that an error has been occurred with the
* provided error code and optional user-readable message. * provided error code and optional user-readable message.
*/ */
public void onErrorResponse(VolleyError error); void onErrorResponse(VolleyError error);
} }
/** Returns a successful response containing the parsed result. */ /** Returns a successful response containing the parsed result. */
......
...@@ -20,16 +20,16 @@ public interface ResponseDelivery { ...@@ -20,16 +20,16 @@ public interface ResponseDelivery {
/** /**
* Parses a response from the network or cache and delivers it. * Parses a response from the network or cache and delivers it.
*/ */
public void postResponse(Request<?> request, Response<?> response); void postResponse(Request<?> request, Response<?> response);
/** /**
* Parses a response from the network or cache and delivers it. The provided * Parses a response from the network or cache and delivers it. The provided
* Runnable will be executed after delivery. * Runnable will be executed after delivery.
*/ */
public void postResponse(Request<?> request, Response<?> response, Runnable runnable); void postResponse(Request<?> request, Response<?> response, Runnable runnable);
/** /**
* Posts an error for the given request. * Posts an error for the given request.
*/ */
public void postError(Request<?> request, VolleyError error); void postError(Request<?> request, VolleyError error);
} }
...@@ -24,12 +24,12 @@ public interface RetryPolicy { ...@@ -24,12 +24,12 @@ public interface RetryPolicy {
/** /**
* Returns the current timeout (used for logging). * Returns the current timeout (used for logging).
*/ */
public int getCurrentTimeout(); int getCurrentTimeout();
/** /**
* Returns the current retry count (used for logging). * Returns the current retry count (used for logging).
*/ */
public int getCurrentRetryCount(); int getCurrentRetryCount();
/** /**
* Prepares for the next retry by applying a backoff to the timeout. * Prepares for the next retry by applying a backoff to the timeout.
...@@ -37,5 +37,5 @@ public interface RetryPolicy { ...@@ -37,5 +37,5 @@ public interface RetryPolicy {
* @throws VolleyError In the event that the retry could not be performed (for example if we * @throws VolleyError In the event that the retry could not be performed (for example if we
* ran out of attempts), the passed in error is thrown. * ran out of attempts), the passed in error is thrown.
*/ */
public void retry(VolleyError error) throws VolleyError; void retry(VolleyError error) throws VolleyError;
} }
...@@ -27,10 +27,10 @@ public interface Authenticator { ...@@ -27,10 +27,10 @@ public interface Authenticator {
* *
* @throws AuthFailureError If authentication did not succeed * @throws AuthFailureError If authentication did not succeed
*/ */
public String getAuthToken() throws AuthFailureError; String getAuthToken() throws AuthFailureError;
/** /**
* Invalidates the provided auth token. * Invalidates the provided auth token.
*/ */
public void invalidateAuthToken(String authToken); void invalidateAuthToken(String authToken);
} }
...@@ -38,7 +38,7 @@ public interface HttpStack { ...@@ -38,7 +38,7 @@ public interface HttpStack {
* {@link Request#getHeaders()} * {@link Request#getHeaders()}
* @return the HTTP response * @return the HTTP response
*/ */
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
throws IOException, AuthFailureError; throws IOException, AuthFailureError;
} }
...@@ -56,7 +56,7 @@ public class HurlStack implements HttpStack { ...@@ -56,7 +56,7 @@ public class HurlStack implements HttpStack {
* Returns a URL to use instead of the provided one, or null to indicate * Returns a URL to use instead of the provided one, or null to indicate
* this URL should not be used at all. * this URL should not be used at all.
*/ */
public String rewriteUrl(String originalUrl); String rewriteUrl(String originalUrl);
} }
private final UrlRewriter mUrlRewriter; private final UrlRewriter mUrlRewriter;
......
...@@ -71,8 +71,8 @@ public class ImageLoader { ...@@ -71,8 +71,8 @@ public class ImageLoader {
* must not block. Implementation with an LruCache is recommended. * must not block. Implementation with an LruCache is recommended.
*/ */
public interface ImageCache { public interface ImageCache {
public Bitmap getBitmap(String url); Bitmap getBitmap(String url);
public void putBitmap(String url, Bitmap bitmap); void putBitmap(String url, Bitmap bitmap);
} }
/** /**
...@@ -138,7 +138,7 @@ public class ImageLoader { ...@@ -138,7 +138,7 @@ public class ImageLoader {
* image loading in order to, for example, run an animation to fade in network loaded * image loading in order to, for example, run an animation to fade in network loaded
* images. * images.
*/ */
public void onResponse(ImageContainer response, boolean isImmediate); void onResponse(ImageContainer response, boolean isImmediate);
} }
/** /**
......
...@@ -480,7 +480,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -480,7 +480,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter = new Datacenter(); datacenter = new Datacenter();
datacenter.datacenterId = 3; datacenter.datacenterId = 3;
datacenter.addAddressAndPort("174.140.142.5", 443); datacenter.addAddressAndPort("149.154.175.117", 443);
datacenters.put(datacenter.datacenterId, datacenter); datacenters.put(datacenter.datacenterId, datacenter);
} }
} else if (datacenters.size() == 1) { } else if (datacenters.size() == 1) {
...@@ -646,8 +646,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -646,8 +646,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
int lastClassGuid = 1; int lastClassGuid = 1;
public int generateClassGuid() { public int generateClassGuid() {
int guid = lastClassGuid++; int guid = lastClassGuid++;
ArrayList<Long> requests = new ArrayList<>(); requestsByGuids.put(guid, new ArrayList<Long>());
requestsByGuids.put(guid, requests);
return guid; return guid;
} }
......
...@@ -54,10 +54,10 @@ public class FileLoadOperation { ...@@ -54,10 +54,10 @@ public class FileLoadOperation {
private File tempPath = null; private File tempPath = null;
private boolean isForceRequest = false; private boolean isForceRequest = false;
public static interface FileLoadOperationDelegate { public interface FileLoadOperationDelegate {
public abstract void didFinishLoadingFile(FileLoadOperation operation, File finalFile); void didFinishLoadingFile(FileLoadOperation operation, File finalFile);
public abstract void didFailedLoadingFile(FileLoadOperation operation, int state); void didFailedLoadingFile(FileLoadOperation operation, int state);
public abstract void didChangedLoadProgress(FileLoadOperation operation, float progress); void didChangedLoadProgress(FileLoadOperation operation, float progress);
} }
public FileLoadOperation(TLRPC.FileLocation photoLocation, int size) { public FileLoadOperation(TLRPC.FileLocation photoLocation, int size) {
......
...@@ -19,13 +19,13 @@ import java.util.concurrent.Semaphore; ...@@ -19,13 +19,13 @@ import java.util.concurrent.Semaphore;
public class FileLoader { public class FileLoader {
public static interface FileLoaderDelegate { public interface FileLoaderDelegate {
public abstract void fileUploadProgressChanged(String location, float progress, boolean isEncrypted); void fileUploadProgressChanged(String location, float progress, boolean isEncrypted);
public abstract void fileDidUploaded(String location, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile); void fileDidUploaded(String location, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile);
public abstract void fileDidFailedUpload(String location, boolean isEncrypted); void fileDidFailedUpload(String location, boolean isEncrypted);
public abstract void fileDidLoaded(String location, File finalFile, int type); void fileDidLoaded(String location, File finalFile, int type);
public abstract void fileDidFailedLoad(String location, int state); void fileDidFailedLoad(String location, int state);
public abstract void fileLoadProgressChanged(String location, float progress); void fileLoadProgressChanged(String location, float progress);
} }
public static final int MEDIA_DIR_IMAGE = 0; public static final int MEDIA_DIR_IMAGE = 0;
...@@ -628,7 +628,7 @@ public class FileLoader { ...@@ -628,7 +628,7 @@ public class FileLoader {
} }
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side) { public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side) {
if (sizes == null) { if (sizes == null || sizes.isEmpty()) {
return null; return null;
} }
int lastSide = 0; int lastSide = 0;
......
...@@ -45,10 +45,10 @@ public class FileUploadOperation { ...@@ -45,10 +45,10 @@ public class FileUploadOperation {
private MessageDigest mdEnc = null; private MessageDigest mdEnc = null;
private boolean started = false; private boolean started = false;
public static interface FileUploadOperationDelegate { public interface FileUploadOperationDelegate {
public abstract void didFinishUploadingFile(FileUploadOperation operation, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile); void didFinishUploadingFile(FileUploadOperation operation, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile);
public abstract void didFailedUploadingFile(FileUploadOperation operation); void didFailedUploadingFile(FileUploadOperation operation);
public abstract void didChangedUploadProgress(FileUploadOperation operation, float progress); void didChangedUploadProgress(FileUploadOperation operation, float progress);
} }
public FileUploadOperation(String location, boolean encrypted, int estimated) { public FileUploadOperation(String location, boolean encrypted, int estimated) {
......
...@@ -61,7 +61,6 @@ public class TLClassStore { ...@@ -61,7 +61,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_account_privacyRules.constructor, TLRPC.TL_account_privacyRules.class); classStore.put(TLRPC.TL_account_privacyRules.constructor, TLRPC.TL_account_privacyRules.class);
classStore.put(TLRPC.TL_help_appUpdate.constructor, TLRPC.TL_help_appUpdate.class); classStore.put(TLRPC.TL_help_appUpdate.constructor, TLRPC.TL_help_appUpdate.class);
classStore.put(TLRPC.TL_help_noAppUpdate.constructor, TLRPC.TL_help_noAppUpdate.class); classStore.put(TLRPC.TL_help_noAppUpdate.constructor, TLRPC.TL_help_noAppUpdate.class);
classStore.put(TLRPC.TL_messageForwarded.constructor, TLRPC.TL_messageForwarded.class);
classStore.put(TLRPC.TL_messageEmpty.constructor, TLRPC.TL_messageEmpty.class); classStore.put(TLRPC.TL_messageEmpty.constructor, TLRPC.TL_messageEmpty.class);
classStore.put(TLRPC.TL_message.constructor, TLRPC.TL_message.class); classStore.put(TLRPC.TL_message.constructor, TLRPC.TL_message.class);
classStore.put(TLRPC.TL_messageService.constructor, TLRPC.TL_messageService.class); classStore.put(TLRPC.TL_messageService.constructor, TLRPC.TL_messageService.class);
...@@ -157,9 +156,6 @@ public class TLClassStore { ...@@ -157,9 +156,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_messageActionChatEditTitle.constructor, TLRPC.TL_messageActionChatEditTitle.class); classStore.put(TLRPC.TL_messageActionChatEditTitle.constructor, TLRPC.TL_messageActionChatEditTitle.class);
classStore.put(TLRPC.TL_messageActionGeoChatCreate.constructor, TLRPC.TL_messageActionGeoChatCreate.class); classStore.put(TLRPC.TL_messageActionGeoChatCreate.constructor, TLRPC.TL_messageActionGeoChatCreate.class);
classStore.put(TLRPC.TL_messageActionGeoChatCheckin.constructor, TLRPC.TL_messageActionGeoChatCheckin.class); classStore.put(TLRPC.TL_messageActionGeoChatCheckin.constructor, TLRPC.TL_messageActionGeoChatCheckin.class);
classStore.put(TLRPC.TL_contacts_foreignLinkMutual.constructor, TLRPC.TL_contacts_foreignLinkMutual.class);
classStore.put(TLRPC.TL_contacts_foreignLinkUnknown.constructor, TLRPC.TL_contacts_foreignLinkUnknown.class);
classStore.put(TLRPC.TL_contacts_foreignLinkRequested.constructor, TLRPC.TL_contacts_foreignLinkRequested.class);
classStore.put(TLRPC.TL_dh_gen_retry.constructor, TLRPC.TL_dh_gen_retry.class); classStore.put(TLRPC.TL_dh_gen_retry.constructor, TLRPC.TL_dh_gen_retry.class);
classStore.put(TLRPC.TL_dh_gen_fail.constructor, TLRPC.TL_dh_gen_fail.class); classStore.put(TLRPC.TL_dh_gen_fail.constructor, TLRPC.TL_dh_gen_fail.class);
classStore.put(TLRPC.TL_dh_gen_ok.constructor, TLRPC.TL_dh_gen_ok.class); classStore.put(TLRPC.TL_dh_gen_ok.constructor, TLRPC.TL_dh_gen_ok.class);
...@@ -222,7 +218,6 @@ public class TLClassStore { ...@@ -222,7 +218,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_updateContactLink.constructor, TLRPC.TL_updateContactLink.class); classStore.put(TLRPC.TL_updateContactLink.constructor, TLRPC.TL_updateContactLink.class);
classStore.put(TLRPC.TL_updateReadMessages.constructor, TLRPC.TL_updateReadMessages.class); classStore.put(TLRPC.TL_updateReadMessages.constructor, TLRPC.TL_updateReadMessages.class);
classStore.put(TLRPC.TL_updateChatParticipantDelete.constructor, TLRPC.TL_updateChatParticipantDelete.class); classStore.put(TLRPC.TL_updateChatParticipantDelete.constructor, TLRPC.TL_updateChatParticipantDelete.class);
classStore.put(TLRPC.TL_updateRestoreMessages.constructor, TLRPC.TL_updateRestoreMessages.class);
classStore.put(TLRPC.TL_updateServiceNotification.constructor, TLRPC.TL_updateServiceNotification.class); classStore.put(TLRPC.TL_updateServiceNotification.constructor, TLRPC.TL_updateServiceNotification.class);
classStore.put(TLRPC.TL_updateNotifySettings.constructor, TLRPC.TL_updateNotifySettings.class); classStore.put(TLRPC.TL_updateNotifySettings.constructor, TLRPC.TL_updateNotifySettings.class);
classStore.put(TLRPC.TL_updateUserTyping.constructor, TLRPC.TL_updateUserTyping.class); classStore.put(TLRPC.TL_updateUserTyping.constructor, TLRPC.TL_updateUserTyping.class);
...@@ -260,9 +255,6 @@ public class TLClassStore { ...@@ -260,9 +255,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_decryptedMessageActionTyping.constructor, TLRPC.TL_decryptedMessageActionTyping.class); classStore.put(TLRPC.TL_decryptedMessageActionTyping.constructor, TLRPC.TL_decryptedMessageActionTyping.class);
classStore.put(TLRPC.TL_decryptedMessageActionReadMessages.constructor, TLRPC.TL_decryptedMessageActionReadMessages.class); classStore.put(TLRPC.TL_decryptedMessageActionReadMessages.constructor, TLRPC.TL_decryptedMessageActionReadMessages.class);
classStore.put(TLRPC.TL_decryptedMessageActionScreenshotMessages.constructor, TLRPC.TL_decryptedMessageActionScreenshotMessages.class); classStore.put(TLRPC.TL_decryptedMessageActionScreenshotMessages.constructor, TLRPC.TL_decryptedMessageActionScreenshotMessages.class);
classStore.put(TLRPC.TL_contacts_myLinkRequested.constructor, TLRPC.TL_contacts_myLinkRequested.class);
classStore.put(TLRPC.TL_contacts_myLinkContact.constructor, TLRPC.TL_contacts_myLinkContact.class);
classStore.put(TLRPC.TL_contacts_myLinkEmpty.constructor, TLRPC.TL_contacts_myLinkEmpty.class);
classStore.put(TLRPC.TL_server_DH_inner_data.constructor, TLRPC.TL_server_DH_inner_data.class); classStore.put(TLRPC.TL_server_DH_inner_data.constructor, TLRPC.TL_server_DH_inner_data.class);
classStore.put(TLRPC.TL_new_session_created.constructor, TLRPC.TL_new_session_created.class); classStore.put(TLRPC.TL_new_session_created.constructor, TLRPC.TL_new_session_created.class);
classStore.put(TLRPC.TL_account_password.constructor, TLRPC.TL_account_password.class); classStore.put(TLRPC.TL_account_password.constructor, TLRPC.TL_account_password.class);
...@@ -341,7 +333,6 @@ public class TLClassStore { ...@@ -341,7 +333,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_updateShort.constructor, TLRPC.TL_updateShort.class); classStore.put(TLRPC.TL_updateShort.constructor, TLRPC.TL_updateShort.class);
classStore.put(TLRPC.TL_updatesCombined.constructor, TLRPC.TL_updatesCombined.class); classStore.put(TLRPC.TL_updatesCombined.constructor, TLRPC.TL_updatesCombined.class);
classStore.put(TLRPC.TL_updatesTooLong.constructor, TLRPC.TL_updatesTooLong.class); classStore.put(TLRPC.TL_updatesTooLong.constructor, TLRPC.TL_updatesTooLong.class);
classStore.put(TLRPC.TL_messages_chat.constructor, TLRPC.TL_messages_chat.class);
classStore.put(TLRPC.TL_wallPaper.constructor, TLRPC.TL_wallPaper.class); classStore.put(TLRPC.TL_wallPaper.constructor, TLRPC.TL_wallPaper.class);
classStore.put(TLRPC.TL_wallPaperSolid.constructor, TLRPC.TL_wallPaperSolid.class); classStore.put(TLRPC.TL_wallPaperSolid.constructor, TLRPC.TL_wallPaperSolid.class);
classStore.put(TLRPC.TL_msg_new_detailed_info.constructor, TLRPC.TL_msg_new_detailed_info.class); classStore.put(TLRPC.TL_msg_new_detailed_info.constructor, TLRPC.TL_msg_new_detailed_info.class);
...@@ -379,7 +370,16 @@ public class TLClassStore { ...@@ -379,7 +370,16 @@ public class TLClassStore {
classStore.put(TLRPC.TL_decryptedMessageActionAbortKey.constructor, TLRPC.TL_decryptedMessageActionAbortKey.class); classStore.put(TLRPC.TL_decryptedMessageActionAbortKey.constructor, TLRPC.TL_decryptedMessageActionAbortKey.class);
classStore.put(TLRPC.TL_decryptedMessageActionNoop.constructor, TLRPC.TL_decryptedMessageActionNoop.class); classStore.put(TLRPC.TL_decryptedMessageActionNoop.constructor, TLRPC.TL_decryptedMessageActionNoop.class);
classStore.put(TLRPC.TL_decryptedMessageMediaExternalDocument.constructor, TLRPC.TL_decryptedMessageMediaExternalDocument.class); classStore.put(TLRPC.TL_decryptedMessageMediaExternalDocument.constructor, TLRPC.TL_decryptedMessageMediaExternalDocument.class);
classStore.put(TLRPC.TL_updateReadHistoryInbox.constructor, TLRPC.TL_updateReadHistoryInbox.class);
classStore.put(TLRPC.TL_updateReadHistoryOutbox.constructor, TLRPC.TL_updateReadHistoryOutbox.class);
classStore.put(TLRPC.TL_contactLinkUnknown.constructor, TLRPC.TL_contactLinkUnknown.class);
classStore.put(TLRPC.TL_contactLinkNone.constructor, TLRPC.TL_contactLinkNone.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_messages_affectedMessages.constructor, TLRPC.TL_messages_affectedMessages.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_msg_container.constructor, TLRPC.TL_msg_container.class); classStore.put(TLRPC.TL_msg_container.constructor, TLRPC.TL_msg_container.class);
classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class); classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class);
classStore.put(TLRPC.TL_messageActionTTLChange.constructor, TLRPC.TL_messageActionTTLChange.class); classStore.put(TLRPC.TL_messageActionTTLChange.constructor, TLRPC.TL_messageActionTTLChange.class);
...@@ -415,6 +415,9 @@ public class TLClassStore { ...@@ -415,6 +415,9 @@ public class TLClassStore {
classStore.put(TLRPC.TL_documentEncrypted_old.constructor, TLRPC.TL_documentEncrypted_old.class); classStore.put(TLRPC.TL_documentEncrypted_old.constructor, TLRPC.TL_documentEncrypted_old.class);
classStore.put(TLRPC.TL_document_old.constructor, TLRPC.TL_document_old.class); classStore.put(TLRPC.TL_document_old.constructor, TLRPC.TL_document_old.class);
classStore.put(TLRPC.TL_config_old.constructor, TLRPC.TL_config_old.class); classStore.put(TLRPC.TL_config_old.constructor, TLRPC.TL_config_old.class);
classStore.put(TLRPC.TL_messageForwarded_old2.constructor, TLRPC.TL_messageForwarded_old2.class);
classStore.put(TLRPC.TL_message_old2.constructor, TLRPC.TL_message_old2.class);
classStore.put(TLRPC.TL_documentAttributeSticker_old.constructor, TLRPC.TL_documentAttributeSticker_old.class);
} }
static TLClassStore store = null; static TLClassStore store = null;
......
...@@ -28,11 +28,11 @@ public class TcpConnection extends ConnectionContext { ...@@ -28,11 +28,11 @@ public class TcpConnection extends ConnectionContext {
TcpConnectionStageSuspended TcpConnectionStageSuspended
} }
public abstract static interface TcpConnectionDelegate { public interface TcpConnectionDelegate {
public abstract void tcpConnectionClosed(TcpConnection connection); void tcpConnectionClosed(TcpConnection connection);
public abstract void tcpConnectionConnected(TcpConnection connection); void tcpConnectionConnected(TcpConnection connection);
public abstract void tcpConnectionQuiackAckReceived(TcpConnection connection, int ack); void tcpConnectionQuiackAckReceived(TcpConnection connection, int ack);
public abstract void tcpConnectionReceivedData(TcpConnection connection, ByteBufferDesc data, int length); void tcpConnectionReceivedData(TcpConnection connection, ByteBufferDesc data, int length);
} }
private static PyroSelector selector; private static PyroSelector selector;
......
...@@ -48,7 +48,6 @@ public class ActionBar extends FrameLayout { ...@@ -48,7 +48,6 @@ public class ActionBar extends FrameLayout {
private boolean allowOverlayTitle; private boolean allowOverlayTitle;
private CharSequence lastTitle; private CharSequence lastTitle;
private boolean showingOverlayTitle;
private boolean castShadows = true; private boolean castShadows = true;
protected boolean isSearchFieldVisible; protected boolean isSearchFieldVisible;
...@@ -419,6 +418,13 @@ public class ActionBar extends FrameLayout { ...@@ -419,6 +418,13 @@ public class ActionBar extends FrameLayout {
menu.closeSearchField(); menu.closeSearchField();
} }
public void openSearchField(String text) {
if (isSearchFieldVisible || menu == null) {
return;
}
menu.openSearchField(text);
}
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int actionBarHeight = AndroidUtilities.getCurrentActionBarHeight(); int actionBarHeight = AndroidUtilities.getCurrentActionBarHeight();
...@@ -446,10 +452,9 @@ public class ActionBar extends FrameLayout { ...@@ -446,10 +452,9 @@ public class ActionBar extends FrameLayout {
} }
public void setTitleOverlayText(String text) { public void setTitleOverlayText(String text) {
if (showingOverlayTitle == (text != null) || !allowOverlayTitle || parentFragment.parentLayout == null) { if (!allowOverlayTitle || parentFragment.parentLayout == null) {
return; return;
} }
showingOverlayTitle = text != null;
CharSequence textToSet = text != null ? text : lastTitle; CharSequence textToSet = text != null ? text : lastTitle;
if (textToSet != null && titleTextView == null) { if (textToSet != null && titleTextView == null) {
createTitleTextView(); createTitleTextView();
......
...@@ -39,12 +39,12 @@ import java.util.ArrayList; ...@@ -39,12 +39,12 @@ import java.util.ArrayList;
public class ActionBarLayout extends FrameLayout { public class ActionBarLayout extends FrameLayout {
public static interface ActionBarLayoutDelegate { public interface ActionBarLayoutDelegate {
public abstract boolean onPreIme(); boolean onPreIme();
public abstract boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout); boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout);
public abstract boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout); boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout);
public abstract boolean needCloseLastFragment(ActionBarLayout layout); boolean needCloseLastFragment(ActionBarLayout layout);
public abstract void onRebuildAllFragments(ActionBarLayout layout); void onRebuildAllFragments(ActionBarLayout layout);
} }
public class LinearLayoutContainer extends LinearLayout { public class LinearLayoutContainer extends LinearLayout {
...@@ -809,7 +809,7 @@ public class ActionBarLayout extends FrameLayout { ...@@ -809,7 +809,7 @@ public class ActionBarLayout extends FrameLayout {
backgroundView.setVisibility(GONE); backgroundView.setVisibility(GONE);
} }
if (drawerLayoutContainer != null) { if (drawerLayoutContainer != null) {
drawerLayoutContainer.setAllowOpenDrawer(true); drawerLayoutContainer.setAllowOpenDrawer(true, false);
} }
} }
}; };
......
...@@ -52,7 +52,7 @@ public class ActionBarMenu extends LinearLayout { ...@@ -52,7 +52,7 @@ public class ActionBarMenu extends LinearLayout {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
onItemClick((Integer)view.getTag()); onItemClick((Integer) view.getTag());
} }
}); });
return view; return view;
...@@ -147,6 +147,22 @@ public class ActionBarMenu extends LinearLayout { ...@@ -147,6 +147,22 @@ public class ActionBarMenu extends LinearLayout {
ActionBarMenuItem item = (ActionBarMenuItem)view; ActionBarMenuItem item = (ActionBarMenuItem)view;
if (item.isSearchField()) { if (item.isSearchField()) {
parentActionBar.onSearchFieldVisibilityChanged(item.toggleSearch()); parentActionBar.onSearchFieldVisibilityChanged(item.toggleSearch());
break;
}
}
}
}
public void openSearchField(String text) {
for (int a = 0; a < getChildCount(); a++) {
View view = getChildAt(a);
if (view instanceof ActionBarMenuItem) {
ActionBarMenuItem item = (ActionBarMenuItem)view;
if (item.isSearchField()) {
parentActionBar.onSearchFieldVisibilityChanged(item.toggleSearch());
item.getSearchField().setText(text);
item.getSearchField().setSelection(text.length());
break;
} }
} }
} }
......
...@@ -42,7 +42,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed { ...@@ -42,7 +42,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
public static class ActionBarMenuItemSearchListener { public static class ActionBarMenuItemSearchListener {
public void onSearchExpand() { } public void onSearchExpand() { }
public void onSearchCollapse() { } public boolean onSearchCollapse() { return true; }
public void onTextChanged(EditText editText) { } public void onTextChanged(EditText editText) { }
public void onSearchPressed(EditText editText) { } public void onSearchPressed(EditText editText) { }
} }
...@@ -322,11 +322,10 @@ public class ActionBarMenuItem extends FrameLayoutFixed { ...@@ -322,11 +322,10 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
return false; return false;
} }
if (searchContainer.getVisibility() == VISIBLE) { if (searchContainer.getVisibility() == VISIBLE) {
searchContainer.setVisibility(GONE); if (listener == null || listener != null && listener.onSearchCollapse()) {
setVisibility(VISIBLE); searchContainer.setVisibility(GONE);
AndroidUtilities.hideKeyboard(searchField); setVisibility(VISIBLE);
if (listener != null) { AndroidUtilities.hideKeyboard(searchField);
listener.onSearchCollapse();
} }
return false; return false;
} else { } else {
......
...@@ -48,8 +48,8 @@ public class ActionBarPopupWindow extends PopupWindow { ...@@ -48,8 +48,8 @@ public class ActionBarPopupWindow extends PopupWindow {
private ViewTreeObserver.OnScrollChangedListener mSuperScrollListener; private ViewTreeObserver.OnScrollChangedListener mSuperScrollListener;
private ViewTreeObserver mViewTreeObserver; private ViewTreeObserver mViewTreeObserver;
public static interface OnDispatchKeyEventListener { public interface OnDispatchKeyEventListener {
public void onDispatchKeyEvent(KeyEvent keyEvent); void onDispatchKeyEvent(KeyEvent keyEvent);
} }
public static class ActionBarPopupWindowLayout extends LinearLayout { public static class ActionBarPopupWindowLayout extends LinearLayout {
......
...@@ -23,7 +23,7 @@ import org.telegram.messenger.R; ...@@ -23,7 +23,7 @@ import org.telegram.messenger.R;
public class BaseFragment { public class BaseFragment {
private boolean isFinished = false; private boolean isFinished = false;
private AlertDialog visibleDialog = null; protected AlertDialog visibleDialog = null;
protected View fragmentView; protected View fragmentView;
protected ActionBarLayout parentLayout; protected ActionBarLayout parentLayout;
......
...@@ -251,11 +251,15 @@ public class DrawerLayoutContainer extends FrameLayout { ...@@ -251,11 +251,15 @@ public class DrawerLayoutContainer extends FrameLayout {
parentActionBarLayout = layout; parentActionBarLayout = layout;
} }
public void setAllowOpenDrawer(boolean value) { public void setAllowOpenDrawer(boolean value, boolean animated) {
allowOpenDrawer = value; allowOpenDrawer = value;
if (!allowOpenDrawer && drawerPosition != 0) { if (!allowOpenDrawer && drawerPosition != 0) {
setDrawerPosition(0); if (!animated) {
onDrawerAnimationEnd(false); setDrawerPosition(0);
onDrawerAnimationEnd(false);
} else {
closeDrawer(true);
}
} }
} }
......
...@@ -47,8 +47,8 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio ...@@ -47,8 +47,8 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
private String lastSticker; private String lastSticker;
private boolean visible; private boolean visible;
public static interface StickersAdapterDelegate { public interface StickersAdapterDelegate {
public abstract void needChangePanelVisibility(boolean show); void needChangePanelVisibility(boolean show);
} }
private class Holder extends RecyclerView.ViewHolder { private class Holder extends RecyclerView.ViewHolder {
...@@ -80,7 +80,7 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio ...@@ -80,7 +80,7 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
@Override @Override
public void run() { public void run() {
if (stickers != null && !stickers.isEmpty() && !stickersToLoad.isEmpty() && visible) { if (stickers != null && !stickers.isEmpty() && !stickersToLoad.isEmpty() && visible) {
String fileName = (String)args[0]; String fileName = (String) args[0];
stickersToLoad.remove(fileName); stickersToLoad.remove(fileName);
if (stickersToLoad.isEmpty()) { if (stickersToLoad.isEmpty()) {
delegate.needChangePanelVisibility(stickers != null && !stickers.isEmpty() && stickersToLoad.isEmpty()); delegate.needChangePanelVisibility(stickers != null && !stickers.isEmpty() && stickersToLoad.isEmpty());
...@@ -214,6 +214,7 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio ...@@ -214,6 +214,7 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
final HashMap<String, ArrayList<TLRPC.Document>> result = new HashMap<>(); final HashMap<String, ArrayList<TLRPC.Document>> result = new HashMap<>();
for (TLRPC.TL_stickerPack stickerPack : res.packs) { for (TLRPC.TL_stickerPack stickerPack : res.packs) {
if (stickerPack != null && stickerPack.emoticon != null) { if (stickerPack != null && stickerPack.emoticon != null) {
stickerPack.emoticon = stickerPack.emoticon.replace("\uFE0F", "");
ArrayList<TLRPC.Document> arrayList = result.get(stickerPack.emoticon); ArrayList<TLRPC.Document> arrayList = result.get(stickerPack.emoticon);
for (Long id : stickerPack.documents) { for (Long id : stickerPack.documents) {
TLRPC.Document document = documents.get(id); TLRPC.Document document = documents.get(id);
......
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.
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.
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