mirror of https://github.com/NekoX-Dev/NekoX.git
Update to 2.6.0
Replies Mentions Hashtags New messages forward logic Blur in photo editor
This commit is contained in:
parent
0f4b890153
commit
300659e30c
|
@ -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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
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;
|
||||||
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 {
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
} 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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
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;
|
||||||
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 {
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
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 {
|
||||||
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 {
|
||||||
}
|
}
|
||||||
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 {
|
||||||
} 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 {
|
||||||
} 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 {
|
||||||
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 {
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -103,7 +103,7 @@ public class MessagesStorage {
|
||||||
database.executeFast("PRAGMA temp_store = 1").stepThis().dispose();
|
database.executeFast("PRAGMA temp_store = 1").stepThis().dispose();
|
||||||
if (createTable) {
|
if (createTable) {
|
||||||
database.executeFast("CREATE TABLE users(uid INTEGER PRIMARY KEY, name TEXT, status INTEGER, data BLOB)").stepThis().dispose();
|
database.executeFast("CREATE TABLE users(uid INTEGER PRIMARY KEY, name TEXT, status INTEGER, data BLOB)").stepThis().dispose();
|
||||||
database.executeFast("CREATE TABLE messages(mid INTEGER PRIMARY KEY, uid INTEGER, read_state INTEGER, send_state INTEGER, date INTEGER, data BLOB, out INTEGER, ttl INTEGER, media INTEGER)").stepThis().dispose();
|
database.executeFast("CREATE TABLE messages(mid INTEGER PRIMARY KEY, uid INTEGER, read_state INTEGER, send_state INTEGER, date INTEGER, data BLOB, out INTEGER, ttl INTEGER, media INTEGER, replydata BLOB)").stepThis().dispose();
|
||||||
database.executeFast("CREATE TABLE chats(uid INTEGER PRIMARY KEY, name TEXT, data BLOB)").stepThis().dispose();
|
database.executeFast("CREATE TABLE chats(uid INTEGER PRIMARY KEY, name TEXT, data BLOB)").stepThis().dispose();
|
||||||
database.executeFast("CREATE TABLE enc_chats(uid INTEGER PRIMARY KEY, user INTEGER, name TEXT, data BLOB, g BLOB, authkey BLOB, ttl INTEGER, layer INTEGER, seq_in INTEGER, seq_out INTEGER, use_count INTEGER, exchange_id INTEGER, key_date INTEGER, fprint INTEGER, fauthkey BLOB, khash BLOB)").stepThis().dispose();
|
database.executeFast("CREATE TABLE enc_chats(uid INTEGER PRIMARY KEY, user INTEGER, name TEXT, data BLOB, g BLOB, authkey BLOB, ttl INTEGER, layer INTEGER, seq_in INTEGER, seq_out INTEGER, use_count INTEGER, exchange_id INTEGER, key_date INTEGER, fprint INTEGER, fauthkey BLOB, khash BLOB)").stepThis().dispose();
|
||||||
database.executeFast("CREATE TABLE dialogs(did INTEGER PRIMARY KEY, date INTEGER, unread_count INTEGER, last_mid INTEGER)").stepThis().dispose();
|
database.executeFast("CREATE TABLE dialogs(did INTEGER PRIMARY KEY, date INTEGER, unread_count INTEGER, last_mid INTEGER)").stepThis().dispose();
|
||||||
|
@ -162,7 +162,7 @@ public class MessagesStorage {
|
||||||
database.executeFast("CREATE TABLE keyvalue(id TEXT PRIMARY KEY, value TEXT)").stepThis().dispose();
|
database.executeFast("CREATE TABLE keyvalue(id TEXT PRIMARY KEY, value TEXT)").stepThis().dispose();
|
||||||
|
|
||||||
//version
|
//version
|
||||||
database.executeFast("PRAGMA user_version = 13").stepThis().dispose();
|
database.executeFast("PRAGMA user_version = 14").stepThis().dispose();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1");
|
SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1");
|
||||||
|
@ -193,7 +193,7 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int version = database.executeInt("PRAGMA user_version");
|
int version = database.executeInt("PRAGMA user_version");
|
||||||
if (version < 13) {
|
if (version < 14) {
|
||||||
updateDbToLastVersion(version);
|
updateDbToLastVersion(version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,6 +368,11 @@ public class MessagesStorage {
|
||||||
database.executeFast("PRAGMA user_version = 13").stepThis().dispose();
|
database.executeFast("PRAGMA user_version = 13").stepThis().dispose();
|
||||||
version = 13;
|
version = 13;
|
||||||
}
|
}
|
||||||
|
if (version == 13 && version < 14) {
|
||||||
|
database.executeFast("ALTER TABLE messages ADD COLUMN replydata BLOB default NULL").stepThis().dispose();
|
||||||
|
database.executeFast("PRAGMA user_version = 14").stepThis().dispose();
|
||||||
|
version = 14;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
|
@ -753,7 +758,7 @@ public class MessagesStorage {
|
||||||
try {
|
try {
|
||||||
ArrayList<Integer> ids = new ArrayList<>();
|
ArrayList<Integer> ids = new ArrayList<>();
|
||||||
ArrayList<TLRPC.User> users = new ArrayList<>();
|
ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT * FROM blocked_users WHERE 1"));
|
SQLiteCursor cursor = database.queryFinalized("SELECT * FROM blocked_users WHERE 1");
|
||||||
StringBuilder usersToLoad = new StringBuilder();
|
StringBuilder usersToLoad = new StringBuilder();
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
int user_id = cursor.intValue(0);
|
int user_id = cursor.intValue(0);
|
||||||
|
@ -840,7 +845,7 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int) did == 0) {
|
if ((int) did == 0) {
|
||||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT data FROM messages WHERE uid = " + did));
|
SQLiteCursor cursor = database.queryFinalized("SELECT data FROM messages WHERE uid = " + did);
|
||||||
ArrayList<File> filesToDelete = new ArrayList<>();
|
ArrayList<File> filesToDelete = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
|
@ -1085,20 +1090,16 @@ public class MessagesStorage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDialogsWithReadedMessagesInternal(final ArrayList<Integer> messages) {
|
private void updateDialogsWithReadedMessagesInternal(final ArrayList<Integer> messages, final HashMap<Integer, Integer> inbox) {
|
||||||
if (Thread.currentThread().getId() != storageQueue.getId()) {
|
|
||||||
throw new RuntimeException("wrong db thread");
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
HashMap<Long, Integer> dialogsToUpdate = new HashMap<>();
|
HashMap<Long, Integer> dialogsToUpdate = new HashMap<>();
|
||||||
|
StringBuilder dialogsToReload = new StringBuilder();
|
||||||
|
|
||||||
if (messages != null && !messages.isEmpty()) {
|
if (messages != null && !messages.isEmpty()) {
|
||||||
StringBuilder dialogsToReload = new StringBuilder();
|
|
||||||
String ids = TextUtils.join(",", messages);
|
String ids = TextUtils.join(",", messages);
|
||||||
int totalCount = 0;
|
|
||||||
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT uid, read_state, out FROM messages WHERE mid IN(%s)", ids));
|
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT uid, read_state, out FROM messages WHERE mid IN(%s)", ids));
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
int out = cursor.intValue(2);
|
int out = cursor.intValue(2);
|
||||||
totalCount++;
|
|
||||||
if (out != 0) {
|
if (out != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1119,8 +1120,26 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
|
} else if (inbox != null && !inbox.isEmpty()) {
|
||||||
|
for (HashMap.Entry<Integer, Integer> entry : inbox.entrySet()) {
|
||||||
|
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(mid) FROM messages WHERE uid = %d AND mid <= %d AND read_state = 0 AND out = 0", entry.getKey(), entry.getValue()));
|
||||||
|
if (cursor.next()) {
|
||||||
|
int count = cursor.intValue(0);
|
||||||
|
if (count == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
dialogsToUpdate.put((long) entry.getKey(), count);
|
||||||
|
if (dialogsToReload.length() != 0) {
|
||||||
|
dialogsToReload.append(",");
|
||||||
|
}
|
||||||
|
dialogsToReload.append(entry.getKey());
|
||||||
|
}
|
||||||
|
cursor.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT did, unread_count FROM dialogs WHERE did IN(%s)", dialogsToReload.toString()));
|
if (dialogsToReload.length() > 0) {
|
||||||
|
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT did, unread_count FROM dialogs WHERE did IN(%s)", dialogsToReload.toString()));
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
long did = cursor.longValue(0);
|
long did = cursor.longValue(0);
|
||||||
int count = cursor.intValue(1);
|
int count = cursor.intValue(1);
|
||||||
|
@ -1153,19 +1172,19 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDialogsWithReadedMessages(final ArrayList<Integer> messages, boolean useQueue) {
|
public void updateDialogsWithReadedMessages(final HashMap<Integer, Integer> inbox, boolean useQueue) {
|
||||||
if (messages.isEmpty()) {
|
if (inbox.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (useQueue) {
|
if (useQueue) {
|
||||||
storageQueue.postRunnable(new Runnable() {
|
storageQueue.postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateDialogsWithReadedMessagesInternal(messages);
|
updateDialogsWithReadedMessagesInternal(null, inbox);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updateDialogsWithReadedMessagesInternal(messages);
|
updateDialogsWithReadedMessagesInternal(null, inbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1710,6 +1729,8 @@ public class MessagesStorage {
|
||||||
try {
|
try {
|
||||||
ArrayList<Integer> loadedUsers = new ArrayList<>();
|
ArrayList<Integer> loadedUsers = new ArrayList<>();
|
||||||
ArrayList<Integer> fromUser = new ArrayList<>();
|
ArrayList<Integer> fromUser = new ArrayList<>();
|
||||||
|
ArrayList<Integer> replyMessages = new ArrayList<>();
|
||||||
|
HashMap<Integer, ArrayList<TLRPC.Message>> replyMessageOwners = new HashMap<>();
|
||||||
|
|
||||||
SQLiteCursor cursor = null;
|
SQLiteCursor cursor = null;
|
||||||
int lower_id = (int)dialog_id;
|
int lower_id = (int)dialog_id;
|
||||||
|
@ -1731,18 +1752,18 @@ public class MessagesStorage {
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
|
|
||||||
if (containMessage) {
|
if (containMessage) {
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid <= %d ORDER BY m.date DESC, m.mid DESC LIMIT %d) UNION " +
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid <= %d ORDER BY m.date DESC, m.mid DESC LIMIT %d) UNION " +
|
||||||
"SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d ORDER BY m.date ASC, m.mid ASC LIMIT %d)", dialog_id, max_id, count_query / 2, dialog_id, max_id, count_query / 2 - 1));
|
"SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d ORDER BY m.date ASC, m.mid ASC LIMIT %d)", dialog_id, max_id, count_query / 2, dialog_id, max_id, count_query / 2 - 1));
|
||||||
} else {
|
} else {
|
||||||
cursor = null;
|
cursor = null;
|
||||||
}
|
}
|
||||||
} else if (load_type == 1) {
|
} else if (load_type == 1) {
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date >= %d AND m.mid > %d ORDER BY m.date ASC, m.mid ASC LIMIT %d", dialog_id, minDate, max_id, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date >= %d AND m.mid > %d ORDER BY m.date ASC, m.mid ASC LIMIT %d", dialog_id, minDate, max_id, count_query));
|
||||||
} else if (minDate != 0) {
|
} else if (minDate != 0) {
|
||||||
if (max_id != 0) {
|
if (max_id != 0) {
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d AND m.mid < %d ORDER BY m.date DESC, m.mid DESC LIMIT %d", dialog_id, minDate, max_id, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d AND m.mid < %d ORDER BY m.date DESC, m.mid DESC LIMIT %d", dialog_id, minDate, max_id, count_query));
|
||||||
} else {
|
} else {
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (load_type == 2) {
|
if (load_type == 2) {
|
||||||
|
@ -1778,16 +1799,16 @@ public class MessagesStorage {
|
||||||
offset_query = count_unread - count_query;
|
offset_query = count_unread - count_query;
|
||||||
count_query += 10;
|
count_query += 10;
|
||||||
}
|
}
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, offset_query, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, offset_query, count_query));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (load_type == 1) {
|
if (load_type == 1) {
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid < %d ORDER BY m.mid DESC LIMIT %d", dialog_id, max_id, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid < %d ORDER BY m.mid DESC LIMIT %d", dialog_id, max_id, count_query));
|
||||||
} else if (minDate != 0) {
|
} else if (minDate != 0) {
|
||||||
if (max_id != 0) {
|
if (max_id != 0) {
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d ORDER BY m.mid ASC LIMIT %d", dialog_id, max_id, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d ORDER BY m.mid ASC LIMIT %d", dialog_id, max_id, count_query));
|
||||||
} else {
|
} else {
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (load_type == 2) {
|
if (load_type == 2) {
|
||||||
|
@ -1823,7 +1844,7 @@ public class MessagesStorage {
|
||||||
offset_query = count_unread - count_query;
|
offset_query = count_unread - count_query;
|
||||||
count_query += 10;
|
count_query += 10;
|
||||||
}
|
}
|
||||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, offset_query, count_query));
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, offset_query, count_query));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
|
@ -1849,6 +1870,43 @@ public class MessagesStorage {
|
||||||
if (message.fwd_from_id != 0) {
|
if (message.fwd_from_id != 0) {
|
||||||
fromUser.add(message.fwd_from_id);
|
fromUser.add(message.fwd_from_id);
|
||||||
}
|
}
|
||||||
|
if (message.reply_to_msg_id != 0) {
|
||||||
|
boolean ok = false;
|
||||||
|
if (!cursor.isNull(6)) {
|
||||||
|
ByteBufferDesc data2 = buffersStorage.getFreeBuffer(cursor.byteArrayLength(6));
|
||||||
|
if (data2 != null && cursor.byteBufferValue(6, data2.buffer) != 0) {
|
||||||
|
message.replyMessage = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data2, data2.readInt32());
|
||||||
|
if (message.replyMessage != null) {
|
||||||
|
fromUser.add(message.replyMessage.from_id);
|
||||||
|
if (message.replyMessage.action != null && message.replyMessage.action.user_id != 0) {
|
||||||
|
fromUser.add(message.replyMessage.action.user_id);
|
||||||
|
}
|
||||||
|
if (message.replyMessage.media != null && message.replyMessage.media.user_id != 0) {
|
||||||
|
fromUser.add(message.replyMessage.media.user_id);
|
||||||
|
}
|
||||||
|
if (message.replyMessage.media != null && message.replyMessage.media.audio != null && message.replyMessage.media.audio.user_id != 0) {
|
||||||
|
fromUser.add(message.replyMessage.media.audio.user_id);
|
||||||
|
}
|
||||||
|
if (message.replyMessage.fwd_from_id != 0) {
|
||||||
|
fromUser.add(message.replyMessage.fwd_from_id);
|
||||||
|
}
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffersStorage.reuseFreeBuffer(data2);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
if (!replyMessages.contains(message.reply_to_msg_id)) {
|
||||||
|
replyMessages.add(message.reply_to_msg_id);
|
||||||
|
}
|
||||||
|
ArrayList<TLRPC.Message> messages = replyMessageOwners.get(message.reply_to_msg_id);
|
||||||
|
if (messages == null) {
|
||||||
|
messages = new ArrayList<>();
|
||||||
|
replyMessageOwners.put(message.reply_to_msg_id, messages);
|
||||||
|
}
|
||||||
|
messages.add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
message.send_state = cursor.intValue(2);
|
message.send_state = cursor.intValue(2);
|
||||||
if (!MessageObject.isUnread(message) && lower_id != 0 || message.id > 0) {
|
if (!MessageObject.isUnread(message) && lower_id != 0 || message.id > 0) {
|
||||||
message.send_state = 0;
|
message.send_state = 0;
|
||||||
|
@ -1899,33 +1957,39 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*ArrayList<Range<Integer>> holes = getHoles(dialog_id);
|
if (!replyMessages.isEmpty()) {
|
||||||
if (holes != null && !res.messages.isEmpty()) {
|
cursor = database.queryFinalized(String.format(Locale.US, "SELECT data, mid, date FROM messages WHERE mid IN(%s)", TextUtils.join(",", replyMessages)));
|
||||||
int start = res.messages.get(res.messages.size() - 1).id;
|
while (cursor.next()) {
|
||||||
int end = res.messages.get(0).id;
|
ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0));
|
||||||
for (Range<Integer> range : holes) {
|
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
|
||||||
if (range.contains(start) && range.contains(end)) {
|
TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
|
||||||
res.messages.clear();
|
message.id = cursor.intValue(1);
|
||||||
} else if (range.contains(start)) {
|
message.date = cursor.intValue(2);
|
||||||
while (!res.messages.isEmpty() && range.contains(res.messages.get(res.messages.size() - 1).id)) {
|
message.dialog_id = dialog_id;
|
||||||
res.messages.remove(res.messages.size() - 1);
|
fromUser.add(message.from_id);
|
||||||
|
if (message.action != null && message.action.user_id != 0) {
|
||||||
|
fromUser.add(message.action.user_id);
|
||||||
}
|
}
|
||||||
if (!res.messages.isEmpty()) {
|
if (message.media != null && message.media.user_id != 0) {
|
||||||
start = res.messages.get(res.messages.size() - 1).id;
|
fromUser.add(message.media.user_id);
|
||||||
}
|
}
|
||||||
} else if (range.contains(end)) {
|
if (message.media != null && message.media.audio != null && message.media.audio.user_id != 0) {
|
||||||
while (!res.messages.isEmpty() && range.contains(res.messages.get(0).id)) {
|
fromUser.add(message.media.audio.user_id);
|
||||||
res.messages.remove(0);
|
|
||||||
}
|
}
|
||||||
if (!res.messages.isEmpty()) {
|
if (message.fwd_from_id != 0) {
|
||||||
end = res.messages.get(0).id;
|
fromUser.add(message.fwd_from_id);
|
||||||
|
}
|
||||||
|
ArrayList<TLRPC.Message> arrayList = replyMessageOwners.get(message.id);
|
||||||
|
if (arrayList != null) {
|
||||||
|
for (TLRPC.Message m : arrayList) {
|
||||||
|
m.replyMessage = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (start >= )
|
|
||||||
if (res.messages.isEmpty()) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
buffersStorage.reuseFreeBuffer(data);
|
||||||
}
|
}
|
||||||
}*/
|
cursor.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder usersToLoad = new StringBuilder();
|
StringBuilder usersToLoad = new StringBuilder();
|
||||||
for (int uid : fromUser) {
|
for (int uid : fromUser) {
|
||||||
|
@ -2590,7 +2654,7 @@ public class MessagesStorage {
|
||||||
HashMap<Integer, Long> messagesMediaIdsMap = new HashMap<>();
|
HashMap<Integer, Long> messagesMediaIdsMap = new HashMap<>();
|
||||||
StringBuilder messageIds = new StringBuilder();
|
StringBuilder messageIds = new StringBuilder();
|
||||||
StringBuilder messageMediaIds = new StringBuilder();
|
StringBuilder messageMediaIds = new StringBuilder();
|
||||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)");
|
||||||
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
||||||
SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO randoms VALUES(?, ?)");
|
SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO randoms VALUES(?, ?)");
|
||||||
SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO download_queue VALUES(?, ?, ?, ?)");
|
SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO download_queue VALUES(?, ?, ?, ?)");
|
||||||
|
@ -3164,14 +3228,20 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markMessagesAsReadInternal(final ArrayList<Integer> messages, HashMap<Integer, Integer> encryptedMessages) {
|
private void markMessagesAsReadInternal(HashMap<Integer, Integer> inbox, HashMap<Integer, Integer> outbox, HashMap<Integer, Integer> encryptedMessages) {
|
||||||
if (Thread.currentThread().getId() != storageQueue.getId()) {
|
if (Thread.currentThread().getId() != storageQueue.getId()) {
|
||||||
throw new RuntimeException("wrong db thread");
|
throw new RuntimeException("wrong db thread");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (messages != null && !messages.isEmpty()) {
|
if (inbox != null) {
|
||||||
String ids = TextUtils.join(",", messages);
|
for (HashMap.Entry<Integer, Integer> entry : inbox.entrySet()) {
|
||||||
database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = 1 WHERE mid IN(%s)", ids)).stepThis().dispose();
|
database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = 1 WHERE uid = %d AND mid <= %d AND read_state = 0 AND out = 0", entry.getKey(), entry.getValue())).stepThis().dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (outbox != null) {
|
||||||
|
for (HashMap.Entry<Integer, Integer> entry : outbox.entrySet()) {
|
||||||
|
database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = 1 WHERE uid = %d AND mid <= %d AND read_state = 0 AND out = 1", entry.getKey(), entry.getValue())).stepThis().dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (encryptedMessages != null && !encryptedMessages.isEmpty()) {
|
if (encryptedMessages != null && !encryptedMessages.isEmpty()) {
|
||||||
for (HashMap.Entry<Integer, Integer> entry : encryptedMessages.entrySet()) {
|
for (HashMap.Entry<Integer, Integer> entry : encryptedMessages.entrySet()) {
|
||||||
|
@ -3190,16 +3260,16 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markMessagesAsRead(final ArrayList<Integer> messages, final HashMap<Integer, Integer> encryptedMessages, boolean useQueue) {
|
public void markMessagesAsRead(final HashMap<Integer, Integer> inbox, final HashMap<Integer, Integer> outbox, final HashMap<Integer, Integer> encryptedMessages, boolean useQueue) {
|
||||||
if (useQueue) {
|
if (useQueue) {
|
||||||
storageQueue.postRunnable(new Runnable() {
|
storageQueue.postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
markMessagesAsReadInternal(messages, encryptedMessages);
|
markMessagesAsReadInternal(inbox, outbox, encryptedMessages);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
markMessagesAsReadInternal(messages, encryptedMessages);
|
markMessagesAsReadInternal(inbox, outbox, encryptedMessages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3231,7 +3301,7 @@ public class MessagesStorage {
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDeleted, mids);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDeleted, mids);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MessagesStorage.getInstance().updateDialogsWithReadedMessagesInternal(mids);
|
MessagesStorage.getInstance().updateDialogsWithReadedMessagesInternal(mids, null);
|
||||||
MessagesStorage.getInstance().markMessagesAsDeletedInternal(mids);
|
MessagesStorage.getInstance().markMessagesAsDeletedInternal(mids);
|
||||||
MessagesStorage.getInstance().updateDialogsWithDeletedMessagesInternal(mids);
|
MessagesStorage.getInstance().updateDialogsWithDeletedMessagesInternal(mids);
|
||||||
}
|
}
|
||||||
|
@ -3472,7 +3542,7 @@ public class MessagesStorage {
|
||||||
try {
|
try {
|
||||||
database.beginTransaction();
|
database.beginTransaction();
|
||||||
if (!messages.messages.isEmpty()) {
|
if (!messages.messages.isEmpty()) {
|
||||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)");
|
||||||
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
||||||
for (TLRPC.Message message : messages.messages) {
|
for (TLRPC.Message message : messages.messages) {
|
||||||
fixUnsupportedMedia(message);
|
fixUnsupportedMedia(message);
|
||||||
|
@ -3644,7 +3714,7 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dialogs.dialogs.isEmpty()) {
|
if (!dialogs.dialogs.isEmpty()) {
|
||||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)");
|
||||||
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)");
|
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)");
|
||||||
SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
||||||
SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO dialog_settings VALUES(?, ?)");
|
SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO dialog_settings VALUES(?, ?)");
|
||||||
|
|
|
@ -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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class NotificationsController {
|
||||||
private NotificationManagerCompat notificationManager = null;
|
private NotificationManagerCompat notificationManager = null;
|
||||||
private HashMap<Long, Integer> pushDialogs = new HashMap<>();
|
private HashMap<Long, Integer> pushDialogs = new HashMap<>();
|
||||||
private HashMap<Long, Integer> wearNoticationsIds = new HashMap<>();
|
private HashMap<Long, Integer> wearNoticationsIds = new HashMap<>();
|
||||||
|
private HashMap<Long, Integer> pushDialogsOverrideMention = new HashMap<>();
|
||||||
private int wearNotificationId = 10000;
|
private int wearNotificationId = 10000;
|
||||||
public ArrayList<MessageObject> popupMessages = new ArrayList<>();
|
public ArrayList<MessageObject> popupMessages = new ArrayList<>();
|
||||||
private long openned_dialog_id = 0;
|
private long openned_dialog_id = 0;
|
||||||
|
@ -313,7 +314,11 @@ public class NotificationsController {
|
||||||
MessageObject lastMessageObject = pushMessages.get(0);
|
MessageObject lastMessageObject = pushMessages.get(0);
|
||||||
|
|
||||||
long dialog_id = lastMessageObject.getDialogId();
|
long dialog_id = lastMessageObject.getDialogId();
|
||||||
int mid = lastMessageObject.messageOwner.id;
|
long override_dialog_id = dialog_id;
|
||||||
|
if ((lastMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_MENTION) != 0) {
|
||||||
|
override_dialog_id = lastMessageObject.messageOwner.from_id;
|
||||||
|
}
|
||||||
|
int mid = lastMessageObject.getId();
|
||||||
int chat_id = lastMessageObject.messageOwner.to_id.chat_id;
|
int chat_id = lastMessageObject.messageOwner.to_id.chat_id;
|
||||||
int user_id = lastMessageObject.messageOwner.to_id.user_id;
|
int user_id = lastMessageObject.messageOwner.to_id.user_id;
|
||||||
if (user_id == 0) {
|
if (user_id == 0) {
|
||||||
|
@ -342,9 +347,9 @@ public class NotificationsController {
|
||||||
int vibrate_override = 0;
|
int vibrate_override = 0;
|
||||||
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||||
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
int notify_override = preferences.getInt("notify2_" + override_dialog_id, 0);
|
||||||
if (notify_override == 3) {
|
if (notify_override == 3) {
|
||||||
int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0);
|
int mute_until = preferences.getInt("notifyuntil_" + override_dialog_id, 0);
|
||||||
if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) {
|
if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) {
|
||||||
notify_override = 2;
|
notify_override = 2;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +620,7 @@ public class NotificationsController {
|
||||||
|
|
||||||
for (long dialog_id : sortedDialogs) {
|
for (long dialog_id : sortedDialogs) {
|
||||||
ArrayList<MessageObject> messageObjects = messagesByDialogs.get(dialog_id);
|
ArrayList<MessageObject> messageObjects = messagesByDialogs.get(dialog_id);
|
||||||
int max_id = messageObjects.get(0).messageOwner.id;
|
int max_id = messageObjects.get(0).getId();
|
||||||
TLRPC.Chat chat = null;
|
TLRPC.Chat chat = null;
|
||||||
TLRPC.User user = null;
|
TLRPC.User user = null;
|
||||||
String name = null;
|
String name = null;
|
||||||
|
@ -737,19 +742,21 @@ public class NotificationsController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processReadMessages(ArrayList<Integer> readMessages, long dialog_id, int max_date, int max_id, boolean isPopup) {
|
public void processReadMessages(HashMap<Integer, Integer> inbox, long dialog_id, int max_date, int max_id, boolean isPopup) {
|
||||||
int oldCount = popupMessages.size();
|
int oldCount = popupMessages.size();
|
||||||
int oldCount2 = pushMessages.size();
|
if (inbox != null) {
|
||||||
if (readMessages != null) {
|
for (HashMap.Entry<Integer, Integer> entry : inbox.entrySet()) {
|
||||||
for (Integer id : readMessages) {
|
for (int a = 0; a < pushMessages.size(); a++) {
|
||||||
MessageObject messageObject = pushMessagesDict.get(id);
|
MessageObject messageObject = pushMessages.get(a);
|
||||||
if (messageObject != null) {
|
if (messageObject.getDialogId() == entry.getKey() && messageObject.getId() <= entry.getValue()) {
|
||||||
if (isPersonalMessage(messageObject)) {
|
if (isPersonalMessage(messageObject)) {
|
||||||
personal_count--;
|
personal_count--;
|
||||||
|
}
|
||||||
|
popupMessages.remove(messageObject);
|
||||||
|
pushMessagesDict.remove(messageObject.getId());
|
||||||
|
pushMessages.remove(a);
|
||||||
|
a--;
|
||||||
}
|
}
|
||||||
pushMessages.remove(messageObject);
|
|
||||||
popupMessages.remove(messageObject);
|
|
||||||
pushMessagesDict.remove(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -764,11 +771,11 @@ public class NotificationsController {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isPopup) {
|
if (!isPopup) {
|
||||||
if (messageObject.messageOwner.id <= max_id || max_id < 0) {
|
if (messageObject.getId() <= max_id || max_id < 0) {
|
||||||
remove = true;
|
remove = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (messageObject.messageOwner.id == max_id || max_id < 0) {
|
if (messageObject.getId() == max_id || max_id < 0) {
|
||||||
remove = true;
|
remove = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -779,7 +786,7 @@ public class NotificationsController {
|
||||||
}
|
}
|
||||||
pushMessages.remove(a);
|
pushMessages.remove(a);
|
||||||
popupMessages.remove(messageObject);
|
popupMessages.remove(messageObject);
|
||||||
pushMessagesDict.remove(messageObject.messageOwner.id);
|
pushMessagesDict.remove(messageObject.getId());
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,13 +809,17 @@ public class NotificationsController {
|
||||||
int popup = 0;
|
int popup = 0;
|
||||||
|
|
||||||
for (MessageObject messageObject : messageObjects) {
|
for (MessageObject messageObject : messageObjects) {
|
||||||
if (pushMessagesDict.containsKey(messageObject.messageOwner.id)) {
|
if (pushMessagesDict.containsKey(messageObject.getId())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
long dialog_id = messageObject.getDialogId();
|
long dialog_id = messageObject.getDialogId();
|
||||||
|
long original_dialog_id = dialog_id;
|
||||||
if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
|
if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_MENTION) != 0) {
|
||||||
|
dialog_id = messageObject.messageOwner.from_id;
|
||||||
|
}
|
||||||
if (isPersonalMessage(messageObject)) {
|
if (isPersonalMessage(messageObject)) {
|
||||||
personal_count++;
|
personal_count++;
|
||||||
}
|
}
|
||||||
|
@ -833,7 +844,10 @@ public class NotificationsController {
|
||||||
popupMessages.add(0, messageObject);
|
popupMessages.add(0, messageObject);
|
||||||
}
|
}
|
||||||
pushMessages.add(0, messageObject);
|
pushMessages.add(0, messageObject);
|
||||||
pushMessagesDict.put(messageObject.messageOwner.id, messageObject);
|
pushMessagesDict.put(messageObject.getId(), messageObject);
|
||||||
|
if (original_dialog_id != dialog_id) {
|
||||||
|
pushDialogsOverrideMention.put(original_dialog_id, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,6 +880,13 @@ public class NotificationsController {
|
||||||
notify_override = 2;
|
notify_override = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (notifyCheck) {
|
||||||
|
Integer override = pushDialogsOverrideMention.get(dialog_id);
|
||||||
|
if (override != null && override == 1) {
|
||||||
|
pushDialogsOverrideMention.put(dialog_id, 0);
|
||||||
|
notify_override = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
boolean canAddValue = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int)dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
|
boolean canAddValue = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int)dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
|
||||||
|
|
||||||
Integer currentCount = pushDialogs.get(dialog_id);
|
Integer currentCount = pushDialogs.get(dialog_id);
|
||||||
|
@ -883,6 +904,7 @@ public class NotificationsController {
|
||||||
}
|
}
|
||||||
if (newCount == 0) {
|
if (newCount == 0) {
|
||||||
pushDialogs.remove(dialog_id);
|
pushDialogs.remove(dialog_id);
|
||||||
|
pushDialogsOverrideMention.remove(dialog_id);
|
||||||
for (int a = 0; a < pushMessages.size(); a++) {
|
for (int a = 0; a < pushMessages.size(); a++) {
|
||||||
MessageObject messageObject = pushMessages.get(a);
|
MessageObject messageObject = pushMessages.get(a);
|
||||||
if (messageObject.getDialogId() == dialog_id) {
|
if (messageObject.getDialogId() == dialog_id) {
|
||||||
|
@ -891,7 +913,7 @@ public class NotificationsController {
|
||||||
}
|
}
|
||||||
pushMessages.remove(a);
|
pushMessages.remove(a);
|
||||||
a--;
|
a--;
|
||||||
pushMessagesDict.remove(messageObject.messageOwner.id);
|
pushMessagesDict.remove(messageObject.getId());
|
||||||
popupMessages.remove(messageObject);
|
popupMessages.remove(messageObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -930,27 +952,6 @@ public class NotificationsController {
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||||
HashMap<Long, Boolean> settingsCache = new HashMap<>();
|
HashMap<Long, Boolean> settingsCache = new HashMap<>();
|
||||||
|
|
||||||
for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) {
|
|
||||||
long dialog_id = entry.getKey();
|
|
||||||
Boolean value = settingsCache.get(dialog_id);
|
|
||||||
if (value == null) {
|
|
||||||
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
|
||||||
if (notify_override == 3) {
|
|
||||||
int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0);
|
|
||||||
if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) {
|
|
||||||
notify_override = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
|
|
||||||
settingsCache.put(dialog_id, value);
|
|
||||||
}
|
|
||||||
if (!value) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int count = entry.getValue();
|
|
||||||
pushDialogs.put(dialog_id, count);
|
|
||||||
total_unread_count += count;
|
|
||||||
}
|
|
||||||
if (messages != null) {
|
if (messages != null) {
|
||||||
for (TLRPC.Message message : messages) {
|
for (TLRPC.Message message : messages) {
|
||||||
if (pushMessagesDict.containsKey(message.id)) {
|
if (pushMessagesDict.containsKey(message.id)) {
|
||||||
|
@ -961,6 +962,10 @@ public class NotificationsController {
|
||||||
personal_count++;
|
personal_count++;
|
||||||
}
|
}
|
||||||
long dialog_id = messageObject.getDialogId();
|
long dialog_id = messageObject.getDialogId();
|
||||||
|
long original_dialog_id = dialog_id;
|
||||||
|
if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_MENTION) != 0) {
|
||||||
|
dialog_id = messageObject.messageOwner.from_id;
|
||||||
|
}
|
||||||
Boolean value = settingsCache.get(dialog_id);
|
Boolean value = settingsCache.get(dialog_id);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
||||||
|
@ -976,10 +981,39 @@ public class NotificationsController {
|
||||||
if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
|
if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pushMessagesDict.put(messageObject.messageOwner.id, messageObject);
|
pushMessagesDict.put(messageObject.getId(), messageObject);
|
||||||
pushMessages.add(0, messageObject);
|
pushMessages.add(0, messageObject);
|
||||||
|
if (original_dialog_id != dialog_id) {
|
||||||
|
pushDialogsOverrideMention.put(original_dialog_id, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) {
|
||||||
|
long dialog_id = entry.getKey();
|
||||||
|
Boolean value = settingsCache.get(dialog_id);
|
||||||
|
if (value == null) {
|
||||||
|
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
||||||
|
if (notify_override == 3) {
|
||||||
|
int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0);
|
||||||
|
if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) {
|
||||||
|
notify_override = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Integer override = pushDialogsOverrideMention.get(dialog_id);
|
||||||
|
if (override != null && override == 1) {
|
||||||
|
pushDialogsOverrideMention.put(dialog_id, 0);
|
||||||
|
notify_override = 1;
|
||||||
|
}
|
||||||
|
value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
|
||||||
|
settingsCache.put(dialog_id, value);
|
||||||
|
}
|
||||||
|
if (!value) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int count = entry.getValue();
|
||||||
|
pushDialogs.put(dialog_id, count);
|
||||||
|
total_unread_count += count;
|
||||||
|
}
|
||||||
if (total_unread_count == 0) {
|
if (total_unread_count == 0) {
|
||||||
popupMessages.clear();
|
popupMessages.clear();
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated);
|
||||||
|
|
|
@ -174,12 +174,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
for (int a = 0; a < arr.size(); a++) {
|
for (int a = 0; a < arr.size(); a++) {
|
||||||
DelayedMessage obj = arr.get(a);
|
DelayedMessage obj = arr.get(a);
|
||||||
if (enc && obj.sendEncryptedRequest != null || !enc && obj.sendRequest != null) {
|
if (enc && obj.sendEncryptedRequest != null || !enc && obj.sendRequest != null) {
|
||||||
MessagesStorage.getInstance().markMessageAsSendError(obj.obj.messageOwner.id);
|
MessagesStorage.getInstance().markMessageAsSendError(obj.obj.getId());
|
||||||
obj.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
obj.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
arr.remove(a);
|
arr.remove(a);
|
||||||
a--;
|
a--;
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, obj.obj.messageOwner.id);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, obj.obj.getId());
|
||||||
processSentMessage(obj.obj.messageOwner.id);
|
processSentMessage(obj.obj.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (arr.isEmpty()) {
|
if (arr.isEmpty()) {
|
||||||
|
@ -244,12 +244,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
for (int a = 0; a < arr.size(); a++) {
|
for (int a = 0; a < arr.size(); a++) {
|
||||||
DelayedMessage message = arr.get(a);
|
DelayedMessage message = arr.get(a);
|
||||||
if (message.obj == messageObject) {
|
if (message.obj == messageObject) {
|
||||||
MessagesStorage.getInstance().markMessageAsSendError(message.obj.messageOwner.id);
|
MessagesStorage.getInstance().markMessageAsSendError(message.obj.getId());
|
||||||
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
arr.remove(a);
|
arr.remove(a);
|
||||||
a--;
|
a--;
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.messageOwner.id);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
|
||||||
processSentMessage(message.obj.messageOwner.id);
|
processSentMessage(message.obj.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (arr.isEmpty()) {
|
if (arr.isEmpty()) {
|
||||||
|
@ -284,10 +284,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateMessageMedia, message.obj);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateMessageMedia, message.obj);
|
||||||
} else {
|
} else {
|
||||||
FileLog.e("tmessages", "can't load image " + message.httpLocation + " to file " + cacheFile.toString());
|
FileLog.e("tmessages", "can't load image " + message.httpLocation + " to file " + cacheFile.toString());
|
||||||
MessagesStorage.getInstance().markMessageAsSendError(message.obj.messageOwner.id);
|
MessagesStorage.getInstance().markMessageAsSendError(message.obj.getId());
|
||||||
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.messageOwner.id);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
|
||||||
processSentMessage(message.obj.messageOwner.id);
|
processSentMessage(message.obj.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -339,10 +339,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
ArrayList<DelayedMessage> arr = delayedMessages.get(path);
|
ArrayList<DelayedMessage> arr = delayedMessages.get(path);
|
||||||
if (arr != null) {
|
if (arr != null) {
|
||||||
for (DelayedMessage message : arr) {
|
for (DelayedMessage message : arr) {
|
||||||
MessagesStorage.getInstance().markMessageAsSendError(message.obj.messageOwner.id);
|
MessagesStorage.getInstance().markMessageAsSendError(message.obj.getId());
|
||||||
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
message.obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.messageOwner.id);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
|
||||||
processSentMessage(message.obj.messageOwner.id);
|
processSentMessage(message.obj.getId());
|
||||||
}
|
}
|
||||||
delayedMessages.remove(path);
|
delayedMessages.remove(path);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
ArrayList<DelayedMessage> messages = entry.getValue();
|
ArrayList<DelayedMessage> messages = entry.getValue();
|
||||||
for (int a = 0; a < messages.size(); a++) {
|
for (int a = 0; a < messages.size(); a++) {
|
||||||
DelayedMessage message = messages.get(a);
|
DelayedMessage message = messages.get(a);
|
||||||
if (message.obj.messageOwner.id == object.messageOwner.id) {
|
if (message.obj.getId() == object.getId()) {
|
||||||
messages.remove(a);
|
messages.remove(a);
|
||||||
MediaController.getInstance().cancelVideoConvert(message.obj);
|
MediaController.getInstance().cancelVideoConvert(message.obj);
|
||||||
if (messages.size() == 0) {
|
if (messages.size() == 0) {
|
||||||
|
@ -378,22 +378,22 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
stopVideoService(keyToRemvoe);
|
stopVideoService(keyToRemvoe);
|
||||||
}
|
}
|
||||||
ArrayList<Integer> messages = new ArrayList<>();
|
ArrayList<Integer> messages = new ArrayList<>();
|
||||||
messages.add(object.messageOwner.id);
|
messages.add(object.getId());
|
||||||
MessagesController.getInstance().deleteMessages(messages, null, null);
|
MessagesController.getInstance().deleteMessages(messages, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean retrySendMessage(MessageObject messageObject, boolean unsent) {
|
public boolean retrySendMessage(MessageObject messageObject, boolean unsent) {
|
||||||
if (messageObject.messageOwner.id >= 0) {
|
if (messageObject.getId() >= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) {
|
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) {
|
||||||
int enc_id = (int) (messageObject.getDialogId() >> 32);
|
int enc_id = (int) (messageObject.getDialogId() >> 32);
|
||||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(enc_id);
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(enc_id);
|
||||||
if (encryptedChat == null) {
|
if (encryptedChat == null) {
|
||||||
MessagesStorage.getInstance().markMessageAsSendError(messageObject.messageOwner.id);
|
MessagesStorage.getInstance().markMessageAsSendError(messageObject.getId());
|
||||||
messageObject.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
messageObject.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, messageObject.messageOwner.id);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, messageObject.getId());
|
||||||
processSentMessage(messageObject.messageOwner.id);
|
processSentMessage(messageObject.getId());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (messageObject.messageOwner.random_id == 0) {
|
if (messageObject.messageOwner.random_id == 0) {
|
||||||
|
@ -429,7 +429,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (unsent) {
|
if (unsent) {
|
||||||
unsentMessages.put(messageObject.messageOwner.id, messageObject);
|
unsentMessages.put(messageObject.getId(), messageObject);
|
||||||
}
|
}
|
||||||
sendMessage(messageObject);
|
sendMessage(messageObject);
|
||||||
return true;
|
return true;
|
||||||
|
@ -449,75 +449,223 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
||||||
if (messageObject.messageOwner.media.photo instanceof TLRPC.TL_photo) {
|
if (messageObject.messageOwner.media.photo instanceof TLRPC.TL_photo) {
|
||||||
sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, null, did);
|
sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, null, did, messageObject.replyMessageObject);
|
||||||
} else if (messageObject.messageOwner.media.audio instanceof TLRPC.TL_audio) {
|
} else if (messageObject.messageOwner.media.audio instanceof TLRPC.TL_audio) {
|
||||||
sendMessage((TLRPC.TL_audio) messageObject.messageOwner.media.audio, messageObject.messageOwner.attachPath, did);
|
sendMessage((TLRPC.TL_audio) messageObject.messageOwner.media.audio, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject);
|
||||||
} else if (messageObject.messageOwner.media.video instanceof TLRPC.TL_video) {
|
} else if (messageObject.messageOwner.media.video instanceof TLRPC.TL_video) {
|
||||||
TLRPC.TL_video video = (TLRPC.TL_video) messageObject.messageOwner.media.video;
|
TLRPC.TL_video video = (TLRPC.TL_video) messageObject.messageOwner.media.video;
|
||||||
video.videoEditedInfo = messageObject.messageOwner.videoEditedInfo;
|
video.videoEditedInfo = messageObject.messageOwner.videoEditedInfo;
|
||||||
sendMessage(video, null, messageObject.messageOwner.attachPath, did);
|
sendMessage(video, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject);
|
||||||
} else if (messageObject.messageOwner.media.document instanceof TLRPC.TL_document) {
|
} else if (messageObject.messageOwner.media.document instanceof TLRPC.TL_document) {
|
||||||
sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, null, messageObject.messageOwner.attachPath, did);
|
sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject);
|
||||||
} else if (messageObject.messageOwner.media.geo instanceof TLRPC.TL_geoPoint) {
|
} else if (messageObject.messageOwner.media.geo instanceof TLRPC.TL_geoPoint) {
|
||||||
sendMessage(messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long, did);
|
sendMessage(messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long, did, messageObject.replyMessageObject);
|
||||||
} else if (messageObject.messageOwner.media.phone_number != null) {
|
} else if (messageObject.messageOwner.media.phone_number != null) {
|
||||||
TLRPC.User user = new TLRPC.TL_userContact();
|
TLRPC.User user = new TLRPC.TL_userContact();
|
||||||
user.phone = messageObject.messageOwner.media.phone_number;
|
user.phone = messageObject.messageOwner.media.phone_number;
|
||||||
user.first_name = messageObject.messageOwner.media.first_name;
|
user.first_name = messageObject.messageOwner.media.first_name;
|
||||||
user.last_name = messageObject.messageOwner.media.last_name;
|
user.last_name = messageObject.messageOwner.media.last_name;
|
||||||
user.id = messageObject.messageOwner.media.user_id;
|
user.id = messageObject.messageOwner.media.user_id;
|
||||||
sendMessage(user, did);
|
sendMessage(user, did, messageObject.replyMessageObject);
|
||||||
} else {
|
} else {
|
||||||
sendMessage(messageObject, did);
|
sendMessage(messageObject, did);
|
||||||
}
|
}
|
||||||
} else if (messageObject.messageOwner.message != null) {
|
} else if (messageObject.messageOwner.message != null) {
|
||||||
sendMessage(messageObject.messageOwner.message, did);
|
sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject);
|
||||||
} else {
|
} else {
|
||||||
sendMessage(messageObject, did);
|
sendMessage(messageObject, did);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(TLRPC.User user, long peer) {
|
public void sendMessage(TLRPC.User user, long peer, MessageObject reply_to_msg) {
|
||||||
sendMessage(null, null, null, null, null, null, user, null, null, null, peer, false, null);
|
sendMessage(null, null, null, null, null, null, user, null, null, null, peer, false, null, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(ArrayList<MessageObject> messages) {
|
public void sendMessage(ArrayList<MessageObject> messages, long peer) {
|
||||||
|
if ((int) peer == 0 || messages == null || messages.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int lower_id = (int) peer;
|
||||||
|
TLRPC.Peer to_id;
|
||||||
|
TLRPC.InputPeer sendToPeer;
|
||||||
|
if (lower_id < 0) {
|
||||||
|
to_id = new TLRPC.TL_peerChat();
|
||||||
|
to_id.chat_id = -lower_id;
|
||||||
|
sendToPeer = new TLRPC.TL_inputPeerChat();
|
||||||
|
sendToPeer.chat_id = -lower_id;
|
||||||
|
} else {
|
||||||
|
to_id = new TLRPC.TL_peerUser();
|
||||||
|
to_id.user_id = lower_id;
|
||||||
|
TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id);
|
||||||
|
if (sendToUser == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
|
||||||
|
sendToPeer = new TLRPC.TL_inputPeerForeign();
|
||||||
|
sendToPeer.user_id = sendToUser.id;
|
||||||
|
sendToPeer.access_hash = sendToUser.access_hash;
|
||||||
|
} else {
|
||||||
|
sendToPeer = new TLRPC.TL_inputPeerContact();
|
||||||
|
sendToPeer.user_id = sendToUser.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<MessageObject> objArr = new ArrayList<>();
|
||||||
|
ArrayList<TLRPC.Message> arr = new ArrayList<>();
|
||||||
|
ArrayList<Long> randomIds = new ArrayList<>();
|
||||||
|
ArrayList<Integer> ids = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int a = 0; a < messages.size(); a++) {
|
||||||
|
MessageObject msgObj = messages.get(a);
|
||||||
|
|
||||||
|
TLRPC.Message newMsg = new TLRPC.TL_message();
|
||||||
|
newMsg.flags |= TLRPC.MESSAGE_FLAG_FWD;
|
||||||
|
if (msgObj.isForwarded()) {
|
||||||
|
newMsg.fwd_from_id = msgObj.messageOwner.fwd_from_id;
|
||||||
|
newMsg.fwd_date = msgObj.messageOwner.fwd_date;
|
||||||
|
} else {
|
||||||
|
newMsg.fwd_from_id = msgObj.messageOwner.from_id;
|
||||||
|
newMsg.fwd_date = msgObj.messageOwner.date;
|
||||||
|
}
|
||||||
|
newMsg.media = msgObj.messageOwner.media;
|
||||||
|
newMsg.message = msgObj.messageOwner.message;
|
||||||
|
newMsg.fwd_msg_id = msgObj.getId();
|
||||||
|
newMsg.attachPath = msgObj.messageOwner.attachPath;
|
||||||
|
if (newMsg.attachPath == null) {
|
||||||
|
newMsg.attachPath = "";
|
||||||
|
}
|
||||||
|
newMsg.local_id = newMsg.id = UserConfig.getNewMessageId();
|
||||||
|
newMsg.from_id = UserConfig.getClientUserId();
|
||||||
|
newMsg.flags |= TLRPC.MESSAGE_FLAG_OUT;
|
||||||
|
if (newMsg.random_id == 0) {
|
||||||
|
newMsg.random_id = getNextRandomId();
|
||||||
|
}
|
||||||
|
randomIds.add(newMsg.random_id);
|
||||||
|
ids.add(newMsg.fwd_msg_id);
|
||||||
|
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||||
|
newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD;
|
||||||
|
newMsg.dialog_id = peer;
|
||||||
|
newMsg.to_id = to_id;
|
||||||
|
MessageObject newMsgObj = new MessageObject(newMsg, null, true);
|
||||||
|
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
|
||||||
|
objArr.add(newMsgObj);
|
||||||
|
arr.add(newMsg);
|
||||||
|
|
||||||
|
putToSendingMessages(newMsg);
|
||||||
|
|
||||||
|
if (a % 100 == 0 || a == messages.size() - 1) {
|
||||||
|
MessagesStorage.getInstance().putMessages(arr, false, true, false, 0);
|
||||||
|
MessagesController.getInstance().updateInterfaceWithMessages(peer, objArr);
|
||||||
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
|
||||||
|
UserConfig.saveConfig(false);
|
||||||
|
|
||||||
|
TLRPC.TL_messages_forwardMessages req = new TLRPC.TL_messages_forwardMessages();
|
||||||
|
req.peer = sendToPeer;
|
||||||
|
req.random_id = randomIds;
|
||||||
|
req.id = ids;
|
||||||
|
|
||||||
|
/*ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||||
|
@Override
|
||||||
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
if (error == null) {
|
||||||
|
final int oldId = newMsgObj.id;
|
||||||
|
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
|
||||||
|
final String attachPath = newMsgObj.attachPath;
|
||||||
|
|
||||||
|
if (response instanceof TLRPC.messages_StatedMessages) {
|
||||||
|
TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
|
||||||
|
if (!res.messages.isEmpty()) {
|
||||||
|
sentMessages.addAll(res.messages);
|
||||||
|
TLRPC.Message message = res.messages.get(0);
|
||||||
|
newMsgObj.id = message.id;
|
||||||
|
processSentMessage(newMsgObj, message, originalPath);
|
||||||
|
}
|
||||||
|
if (res instanceof TLRPC.TL_messages_statedMessages) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
|
||||||
|
} else if (res instanceof TLRPC.TL_messages_statedMessagesLinks) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1, res.pts_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false);
|
||||||
|
MessagesStorage.getInstance().putMessages(sentMessages, true, false, false, 0);
|
||||||
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
|
||||||
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj);
|
||||||
|
processSentMessage(oldId);
|
||||||
|
removeFromSendingMessages(oldId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||||
|
stopVideoService(attachPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
|
||||||
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id);
|
||||||
|
processSentMessage(newMsgObj.id);
|
||||||
|
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||||
|
stopVideoService(newMsgObj.attachPath);
|
||||||
|
}
|
||||||
|
removeFromSendingMessages(newMsgObj.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassCanCompress, ConnectionsManager.DEFAULT_DATACENTER_ID);
|
||||||
|
*/
|
||||||
|
if (a != messages.size() - 1) {
|
||||||
|
objArr = new ArrayList<>();
|
||||||
|
arr = new ArrayList<>();
|
||||||
|
randomIds = new ArrayList<>();
|
||||||
|
ids = new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(MessageObject message) {
|
public void sendMessage(MessageObject message) {
|
||||||
sendMessage(null, null, null, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath);
|
sendMessage(null, null, null, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(MessageObject message, long peer) {
|
public void sendMessage(MessageObject message, long peer) {
|
||||||
sendMessage(null, null, null, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath);
|
sendMessage(null, null, null, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(TLRPC.TL_document document, String originalPath, String path, long peer) {
|
public void sendMessage(TLRPC.TL_document document, String originalPath, String path, long peer, MessageObject reply_to_msg) {
|
||||||
sendMessage(null, null, null, null, null, null, null, document, null, originalPath, peer, false, path);
|
sendMessage(null, null, null, null, null, null, null, document, null, originalPath, peer, false, path, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String message, long peer) {
|
public void sendMessage(String message, long peer, MessageObject reply_to_msg) {
|
||||||
sendMessage(message, null, null, null, null, null, null, null, null, null, peer, false, null);
|
sendMessage(message, null, null, null, null, null, null, null, null, null, peer, false, null, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(double lat, double lon, long peer) {
|
public void sendMessage(double lat, double lon, long peer, MessageObject reply_to_msg) {
|
||||||
sendMessage(null, lat, lon, null, null, null, null, null, null, null, peer, false, null);
|
sendMessage(null, lat, lon, null, null, null, null, null, null, null, peer, false, null, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(TLRPC.TL_photo photo, String originalPath, String path, long peer) {
|
public void sendMessage(TLRPC.TL_photo photo, String originalPath, String path, long peer, MessageObject reply_to_msg) {
|
||||||
sendMessage(null, null, null, photo, null, null, null, null, null, originalPath, peer, false, path);
|
sendMessage(null, null, null, photo, null, null, null, null, null, originalPath, peer, false, path, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(TLRPC.TL_video video, String originalPath, String path, long peer) {
|
public void sendMessage(TLRPC.TL_video video, String originalPath, String path, long peer, MessageObject reply_to_msg) {
|
||||||
sendMessage(null, null, null, null, video, null, null, null, null, originalPath, peer, false, path);
|
sendMessage(null, null, null, null, video, null, null, null, null, originalPath, peer, false, path, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(TLRPC.TL_audio audio, String path, long peer) {
|
public void sendMessage(TLRPC.TL_audio audio, String path, long peer, MessageObject reply_to_msg) {
|
||||||
sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path);
|
sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path) {
|
private void sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path, MessageObject reply_to_msg) {
|
||||||
if (peer == 0) {
|
if (peer == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +685,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
newMsg = msgObj.messageOwner;
|
newMsg = msgObj.messageOwner;
|
||||||
|
|
||||||
if (msgObj.type == 0) {
|
if (msgObj.type == 0) {
|
||||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
if (msgObj.isForwarded()) {
|
||||||
type = 4;
|
type = 4;
|
||||||
} else {
|
} else {
|
||||||
message = newMsg.message;
|
message = newMsg.message;
|
||||||
|
@ -548,14 +696,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
lon = newMsg.media.geo._long;
|
lon = newMsg.media.geo._long;
|
||||||
type = 1;
|
type = 1;
|
||||||
} else if (msgObj.type == 1) {
|
} else if (msgObj.type == 1) {
|
||||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
if (msgObj.isForwarded()) {
|
||||||
type = 4;
|
type = 4;
|
||||||
} else {
|
} else {
|
||||||
photo = (TLRPC.TL_photo) newMsg.media.photo;
|
photo = (TLRPC.TL_photo) newMsg.media.photo;
|
||||||
type = 2;
|
type = 2;
|
||||||
}
|
}
|
||||||
} else if (msgObj.type == 3) {
|
} else if (msgObj.type == 3) {
|
||||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
if (msgObj.isForwarded()) {
|
||||||
type = 4;
|
type = 4;
|
||||||
} else {
|
} else {
|
||||||
type = 3;
|
type = 3;
|
||||||
|
@ -631,24 +779,20 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
newMsg.attachPath = path;
|
newMsg.attachPath = path;
|
||||||
} else if (msgObj != null) {
|
} else if (msgObj != null) {
|
||||||
newMsg = new TLRPC.TL_messageForwarded();
|
newMsg = new TLRPC.TL_message();
|
||||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
newMsg.flags |= TLRPC.MESSAGE_FLAG_FWD;
|
||||||
|
if (msgObj.isForwarded()) {
|
||||||
newMsg.fwd_from_id = msgObj.messageOwner.fwd_from_id;
|
newMsg.fwd_from_id = msgObj.messageOwner.fwd_from_id;
|
||||||
newMsg.fwd_date = msgObj.messageOwner.fwd_date;
|
newMsg.fwd_date = msgObj.messageOwner.fwd_date;
|
||||||
newMsg.media = msgObj.messageOwner.media;
|
|
||||||
newMsg.message = msgObj.messageOwner.message;
|
|
||||||
newMsg.fwd_msg_id = msgObj.messageOwner.id;
|
|
||||||
newMsg.attachPath = msgObj.messageOwner.attachPath;
|
|
||||||
type = 4;
|
|
||||||
} else {
|
} else {
|
||||||
newMsg.fwd_from_id = msgObj.messageOwner.from_id;
|
newMsg.fwd_from_id = msgObj.messageOwner.from_id;
|
||||||
newMsg.fwd_date = msgObj.messageOwner.date;
|
newMsg.fwd_date = msgObj.messageOwner.date;
|
||||||
newMsg.media = msgObj.messageOwner.media;
|
|
||||||
newMsg.message = msgObj.messageOwner.message;
|
|
||||||
newMsg.fwd_msg_id = msgObj.messageOwner.id;
|
|
||||||
newMsg.attachPath = msgObj.messageOwner.attachPath;
|
|
||||||
type = 4;
|
|
||||||
}
|
}
|
||||||
|
newMsg.media = msgObj.messageOwner.media;
|
||||||
|
newMsg.message = msgObj.messageOwner.message;
|
||||||
|
newMsg.fwd_msg_id = msgObj.getId();
|
||||||
|
newMsg.attachPath = msgObj.messageOwner.attachPath;
|
||||||
|
type = 4;
|
||||||
} else if (user != null) {
|
} else if (user != null) {
|
||||||
if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) {
|
if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) {
|
||||||
newMsg = new TLRPC.TL_message_secret();
|
newMsg = new TLRPC.TL_message_secret();
|
||||||
|
@ -699,6 +843,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
|
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||||
newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD;
|
newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD;
|
||||||
newMsg.dialog_id = peer;
|
newMsg.dialog_id = peer;
|
||||||
|
if (reply_to_msg != null) {
|
||||||
|
newMsg.flags |= TLRPC.MESSAGE_FLAG_REPLY;
|
||||||
|
newMsg.reply_to_msg_id = reply_to_msg.getId();
|
||||||
|
}
|
||||||
if (lower_id != 0) {
|
if (lower_id != 0) {
|
||||||
if (high_id == 1) {
|
if (high_id == 1) {
|
||||||
if (currentChatInfo == null) {
|
if (currentChatInfo == null) {
|
||||||
|
@ -758,6 +906,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageObject newMsgObj = new MessageObject(newMsg, null, true);
|
MessageObject newMsgObj = new MessageObject(newMsg, null, true);
|
||||||
|
newMsgObj.replyMessageObject = reply_to_msg;
|
||||||
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
|
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
|
||||||
|
|
||||||
ArrayList<MessageObject> objArr = new ArrayList<>();
|
ArrayList<MessageObject> objArr = new ArrayList<>();
|
||||||
|
@ -782,6 +931,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
reqSend.message = message;
|
reqSend.message = message;
|
||||||
reqSend.peer = sendToPeer;
|
reqSend.peer = sendToPeer;
|
||||||
reqSend.random_id = newMsg.random_id;
|
reqSend.random_id = newMsg.random_id;
|
||||||
|
if (reply_to_msg != null) {
|
||||||
|
reqSend.reply_to_msg_id = reply_to_msg.getId();
|
||||||
|
}
|
||||||
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -915,6 +1067,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
request.peer = sendToPeer;
|
request.peer = sendToPeer;
|
||||||
request.random_id = newMsg.random_id;
|
request.random_id = newMsg.random_id;
|
||||||
request.media = inputMedia;
|
request.media = inputMedia;
|
||||||
|
if (reply_to_msg != null) {
|
||||||
|
request.reply_to_msg_id = reply_to_msg.getId();
|
||||||
|
}
|
||||||
if (delayedMessage != null) {
|
if (delayedMessage != null) {
|
||||||
delayedMessage.sendRequest = request;
|
delayedMessage.sendRequest = request;
|
||||||
}
|
}
|
||||||
|
@ -1111,8 +1266,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
TLRPC.TL_messages_forwardMessage reqSend = new TLRPC.TL_messages_forwardMessage();
|
TLRPC.TL_messages_forwardMessage reqSend = new TLRPC.TL_messages_forwardMessage();
|
||||||
reqSend.peer = sendToPeer;
|
reqSend.peer = sendToPeer;
|
||||||
reqSend.random_id = newMsg.random_id;
|
reqSend.random_id = newMsg.random_id;
|
||||||
if (msgObj.messageOwner.id >= 0) {
|
if (msgObj.getId() >= 0) {
|
||||||
reqSend.id = msgObj.messageOwner.id;
|
reqSend.id = msgObj.getId();
|
||||||
} else {
|
} else {
|
||||||
reqSend.id = msgObj.messageOwner.fwd_msg_id;
|
reqSend.id = msgObj.messageOwner.fwd_msg_id;
|
||||||
}
|
}
|
||||||
|
@ -1120,10 +1275,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.messageOwner.id);
|
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.getId());
|
||||||
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.getId());
|
||||||
processSentMessage(newMsgObj.messageOwner.id);
|
processSentMessage(newMsgObj.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1269,13 +1424,21 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
TLRPC.messages_SentMessage res = (TLRPC.messages_SentMessage) response;
|
TLRPC.messages_SentMessage res = (TLRPC.messages_SentMessage) response;
|
||||||
newMsgObj.id = res.id;
|
newMsgObj.id = res.id;
|
||||||
newMsgObj.date = res.date;
|
newMsgObj.date = res.date;
|
||||||
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.date);
|
if (res instanceof TLRPC.TL_messages_sentMessage) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.date, res.pts_count);
|
||||||
|
} else if (res instanceof TLRPC.TL_messages_sentMessageLink) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.date, res.pts_count);
|
||||||
|
}
|
||||||
} else if (response instanceof TLRPC.messages_StatedMessage) {
|
} else if (response instanceof TLRPC.messages_StatedMessage) {
|
||||||
TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||||
sentMessages.add(res.message);
|
sentMessages.add(res.message);
|
||||||
newMsgObj.id = res.message.id;
|
newMsgObj.id = res.message.id;
|
||||||
processSentMessage(newMsgObj, res.message, originalPath);
|
processSentMessage(newMsgObj, res.message, originalPath);
|
||||||
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date);
|
if (res instanceof TLRPC.TL_messages_statedMessage) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count);
|
||||||
|
} else if (res instanceof TLRPC.TL_messages_statedMessageLink) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date, res.pts_count);
|
||||||
|
}
|
||||||
} else if (response instanceof TLRPC.messages_StatedMessages) {
|
} else if (response instanceof TLRPC.messages_StatedMessages) {
|
||||||
TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
|
TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
|
||||||
if (!res.messages.isEmpty()) {
|
if (!res.messages.isEmpty()) {
|
||||||
|
@ -1286,7 +1449,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
processSentMessage(newMsgObj, message, originalPath);
|
processSentMessage(newMsgObj, message, originalPath);
|
||||||
}
|
}
|
||||||
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1);
|
if (res instanceof TLRPC.TL_messages_statedMessages) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
|
||||||
|
} else if (res instanceof TLRPC.TL_messages_statedMessagesLinks) {
|
||||||
|
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1, res.pts_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1545,7 +1712,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean prepareSendingDocumentInternal(String path, String originalPath, Uri uri, String mime, final long dialog_id) {
|
private static boolean prepareSendingDocumentInternal(String path, String originalPath, Uri uri, String mime, final long dialog_id, final MessageObject reply_to_msg) {
|
||||||
if ((path == null || path.length() == 0) && uri == null) {
|
if ((path == null || path.length() == 0) && uri == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1653,13 +1820,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareSendingDocument(String path, String originalPath, Uri uri, String mine, long dialog_id) {
|
public static void prepareSendingDocument(String path, String originalPath, Uri uri, String mine, long dialog_id, MessageObject reply_to_msg) {
|
||||||
if ((path == null || originalPath == null) && uri == null) {
|
if ((path == null || originalPath == null) && uri == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1671,10 +1838,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
paths.add(path);
|
paths.add(path);
|
||||||
originalPaths.add(originalPath);
|
originalPaths.add(originalPath);
|
||||||
prepareSendingDocuments(paths, originalPaths, uris, mine, dialog_id);
|
prepareSendingDocuments(paths, originalPaths, uris, mine, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareSendingDocuments(final ArrayList<String> paths, final ArrayList<String> originalPaths, final ArrayList<Uri> uris, final String mime, final long dialog_id) {
|
public static void prepareSendingDocuments(final ArrayList<String> paths, final ArrayList<String> originalPaths, final ArrayList<Uri> uris, final String mime, final long dialog_id, final MessageObject reply_to_msg) {
|
||||||
if (paths == null && originalPaths == null && uris == null || paths != null && originalPaths != null && paths.size() != originalPaths.size()) {
|
if (paths == null && originalPaths == null && uris == null || paths != null && originalPaths != null && paths.size() != originalPaths.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1684,14 +1851,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
for (int a = 0; a < paths.size(); a++) {
|
for (int a = 0; a < paths.size(); a++) {
|
||||||
if (!prepareSendingDocumentInternal(paths.get(a), originalPaths.get(a), null, mime, dialog_id)) {
|
if (!prepareSendingDocumentInternal(paths.get(a), originalPaths.get(a), null, mime, dialog_id, reply_to_msg)) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (uris != null) {
|
if (uris != null) {
|
||||||
for (int a = 0; a < uris.size(); a++) {
|
for (int a = 0; a < uris.size(); a++) {
|
||||||
if (!prepareSendingDocumentInternal(null, null, uris.get(a), mime, dialog_id)) {
|
if (!prepareSendingDocumentInternal(null, null, uris.get(a), mime, dialog_id, reply_to_msg)) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1713,7 +1880,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareSendingPhoto(String imageFilePath, Uri imageUri, long dialog_id) {
|
public static void prepareSendingPhoto(String imageFilePath, Uri imageUri, long dialog_id, MessageObject reply_to_msg) {
|
||||||
ArrayList<String> paths = null;
|
ArrayList<String> paths = null;
|
||||||
ArrayList<Uri> uris = null;
|
ArrayList<Uri> uris = null;
|
||||||
if (imageFilePath != null && imageFilePath.length() != 0) {
|
if (imageFilePath != null && imageFilePath.length() != 0) {
|
||||||
|
@ -1724,10 +1891,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
uris = new ArrayList<>();
|
uris = new ArrayList<>();
|
||||||
uris.add(imageUri);
|
uris.add(imageUri);
|
||||||
}
|
}
|
||||||
prepareSendingPhotos(paths, uris, dialog_id);
|
prepareSendingPhotos(paths, uris, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareSendingPhotosSearch(final ArrayList<MediaController.SearchImage> photos, final long dialog_id) {
|
public static void prepareSendingPhotosSearch(final ArrayList<MediaController.SearchImage> photos, final long dialog_id, final MessageObject reply_to_msg) {
|
||||||
if (photos == null || photos.isEmpty()) {
|
if (photos == null || photos.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1789,7 +1956,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1832,7 +1999,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, needDownloadHttpFinal ? searchImage.imageUrl : null, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, needDownloadHttpFinal ? searchImage.imageUrl : null, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1842,7 +2009,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareSendingPhotos(ArrayList<String> paths, ArrayList<Uri> uris, final long dialog_id) {
|
public static void prepareSendingPhotos(ArrayList<String> paths, ArrayList<Uri> uris, final long dialog_id, final MessageObject reply_to_msg) {
|
||||||
if (paths == null && uris == null || paths != null && paths.isEmpty() || uris != null && uris.isEmpty()) {
|
if (paths == null && uris == null || paths != null && paths.isEmpty() || uris != null && uris.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1923,7 +2090,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, null, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, null, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1931,14 +2098,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
if (sendAsDocuments != null && !sendAsDocuments.isEmpty()) {
|
if (sendAsDocuments != null && !sendAsDocuments.isEmpty()) {
|
||||||
for (int a = 0; a < sendAsDocuments.size(); a++) {
|
for (int a = 0; a < sendAsDocuments.size(); a++) {
|
||||||
prepareSendingDocumentInternal(sendAsDocuments.get(a), sendAsDocumentsOriginal.get(a), null, "gif", dialog_id);
|
prepareSendingDocumentInternal(sendAsDocuments.get(a), sendAsDocumentsOriginal.get(a), null, "gif", dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareSendingVideo(final String videoPath, final long estimatedSize, final long duration, final int width, final int height, final TLRPC.VideoEditedInfo videoEditedInfo, final long dialog_id) {
|
public static void prepareSendingVideo(final String videoPath, final long estimatedSize, final long duration, final int width, final int height, final TLRPC.VideoEditedInfo videoEditedInfo, final long dialog_id, final MessageObject reply_to_msg) {
|
||||||
if (videoPath == null || videoPath.length() == 0) {
|
if (videoPath == null || videoPath.length() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1955,6 +2122,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
originalPath += temp.length() + "_" + temp.lastModified();
|
originalPath += temp.length() + "_" + temp.lastModified();
|
||||||
if (videoEditedInfo != null) {
|
if (videoEditedInfo != null) {
|
||||||
originalPath += duration + "_" + videoEditedInfo.startTime + "_" + videoEditedInfo.endTime;
|
originalPath += duration + "_" + videoEditedInfo.startTime + "_" + videoEditedInfo.endTime;
|
||||||
|
if (videoEditedInfo.resultWidth == videoEditedInfo.originalWidth) {
|
||||||
|
originalPath += "_" + videoEditedInfo.resultWidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TLRPC.TL_video video = null;
|
TLRPC.TL_video video = null;
|
||||||
if (!isEncrypted) {
|
if (!isEncrypted) {
|
||||||
|
@ -2049,11 +2219,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SendMessagesHelper.getInstance().sendMessage(videoFinal, originalPathFinal, finalPath, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(videoFinal, originalPathFinal, finalPath, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
prepareSendingDocumentInternal(videoPath, videoPath, null, null, dialog_id);
|
prepareSendingDocumentInternal(videoPath, videoPath, null, null, dialog_id, reply_to_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,185 @@
|
||||||
|
/*
|
||||||
|
* 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 {
|
||||||
* @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 {
|
||||||
* @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 {
|
||||||
* {@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> {
|
||||||
/** 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> {
|
||||||
* 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 {
|
||||||
/**
|
/**
|
||||||
* 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 {
|
||||||
/**
|
/**
|
||||||
* 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 {
|
||||||
* @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 {
|
||||||
*
|
*
|
||||||
* @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 {
|
||||||
* {@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 {
|
||||||
* 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 {
|
||||||
* 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 {
|
||||||
* 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.
|
||||||
|
|
||||||
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.
|
||||||
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 {
|
||||||
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;
|
||||||
|
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 {
|
||||||
|
|
||||||
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 {
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
|
|
||||||
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 {
|
||||||
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 {
|
||||||
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;
|
||||||
|
|
||||||
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 {
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
private long reqId = 0;
|
private long reqId = 0;
|
||||||
private int lastReqId;
|
private int lastReqId;
|
||||||
private MessagesActivitySearchAdapterDelegate delegate;
|
private MessagesActivitySearchAdapterDelegate delegate;
|
||||||
private boolean needMessagesSearch;
|
private int needMessagesSearch;
|
||||||
private boolean messagesSearchEndReached;
|
private boolean messagesSearchEndReached;
|
||||||
private String lastMessagesSearchString;
|
private String lastMessagesSearchString;
|
||||||
private int lastSearchId = 0;
|
private int lastSearchId = 0;
|
||||||
|
@ -66,11 +66,11 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
public CharSequence name;
|
public CharSequence name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface MessagesActivitySearchAdapterDelegate {
|
public interface MessagesActivitySearchAdapterDelegate {
|
||||||
public abstract void searchStateChanged(boolean searching);
|
void searchStateChanged(boolean searching);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DialogsSearchAdapter(Context context, boolean messagesSearch) {
|
public DialogsSearchAdapter(Context context, int messagesSearch) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
needMessagesSearch = messagesSearch;
|
needMessagesSearch = messagesSearch;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchMessagesInternal(final String query) {
|
private void searchMessagesInternal(final String query) {
|
||||||
if (!needMessagesSearch) {
|
if (needMessagesSearch == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (reqId != 0) {
|
if (reqId != 0) {
|
||||||
|
@ -110,7 +110,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
req.peer = new TLRPC.TL_inputPeerEmpty();
|
req.peer = new TLRPC.TL_inputPeerEmpty();
|
||||||
req.q = query;
|
req.q = query;
|
||||||
if (lastMessagesSearchString != null && query.equals(lastMessagesSearchString) && !searchResultMessages.isEmpty()) {
|
if (lastMessagesSearchString != null && query.equals(lastMessagesSearchString) && !searchResultMessages.isEmpty()) {
|
||||||
req.max_id = searchResultMessages.get(searchResultMessages.size() - 1).messageOwner.id;
|
req.max_id = searchResultMessages.get(searchResultMessages.size() - 1).getId();
|
||||||
}
|
}
|
||||||
lastMessagesSearchString = query;
|
lastMessagesSearchString = query;
|
||||||
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
|
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
|
||||||
|
@ -151,6 +151,9 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchDialogsInternal(final String query, final boolean serverOnly, final int searchId) {
|
private void searchDialogsInternal(final String query, final boolean serverOnly, final int searchId) {
|
||||||
|
if (needMessagesSearch == 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -178,7 +181,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
int resultCount = 0;
|
int resultCount = 0;
|
||||||
|
|
||||||
HashMap<Long, DialogSearchResult> dialogsResult = new HashMap<>();
|
HashMap<Long, DialogSearchResult> dialogsResult = new HashMap<>();
|
||||||
SQLiteCursor cursor = MessagesStorage.getInstance().getDatabase().queryFinalized(String.format(Locale.US, "SELECT did, date FROM dialogs ORDER BY date DESC LIMIT 200"));
|
SQLiteCursor cursor = MessagesStorage.getInstance().getDatabase().queryFinalized("SELECT did, date FROM dialogs ORDER BY date DESC LIMIT 200");
|
||||||
while (cursor.next()) {
|
while (cursor.next()) {
|
||||||
long id = cursor.longValue(0);
|
long id = cursor.longValue(0);
|
||||||
DialogSearchResult dialogSearchResult = new DialogSearchResult();
|
DialogSearchResult dialogSearchResult = new DialogSearchResult();
|
||||||
|
@ -488,8 +491,10 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
if (query == null || query.length() == 0) {
|
if (query == null || query.length() == 0) {
|
||||||
searchResult.clear();
|
searchResult.clear();
|
||||||
searchResultNames.clear();
|
searchResultNames.clear();
|
||||||
|
if (needMessagesSearch != 2) {
|
||||||
|
queryServerSearch(null);
|
||||||
|
}
|
||||||
searchMessagesInternal(null);
|
searchMessagesInternal(null);
|
||||||
queryServerSearch(null);
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
final int searchId = ++lastSearchId;
|
final int searchId = ++lastSearchId;
|
||||||
|
@ -507,7 +512,9 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
queryServerSearch(query);
|
if (needMessagesSearch != 2) {
|
||||||
|
queryServerSearch(query);
|
||||||
|
}
|
||||||
searchMessagesInternal(query);
|
searchMessagesInternal(query);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,186 @@
|
||||||
|
/*
|
||||||
|
* 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.ui.Adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.telegram.android.MessageObject;
|
||||||
|
import org.telegram.android.MessagesController;
|
||||||
|
import org.telegram.messenger.TLRPC;
|
||||||
|
import org.telegram.ui.Cells.MentionCell;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class MentionsAdapter extends BaseFragmentAdapter {
|
||||||
|
|
||||||
|
public interface MentionsAdapterDelegate {
|
||||||
|
void needChangePanelVisibility(boolean show);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private TLRPC.ChatParticipants info;
|
||||||
|
private ArrayList<TLRPC.User> searchResult = new ArrayList<>();
|
||||||
|
private MentionsAdapterDelegate delegate;
|
||||||
|
private int usernameStartPosition;
|
||||||
|
private int usernameLength;
|
||||||
|
private String lastText;
|
||||||
|
private int lastPosition;
|
||||||
|
private ArrayList<MessageObject> messages;
|
||||||
|
|
||||||
|
public MentionsAdapter(Context context, MentionsAdapterDelegate delegate) {
|
||||||
|
mContext = context;
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChatInfo(TLRPC.ChatParticipants chatParticipants) {
|
||||||
|
info = chatParticipants;
|
||||||
|
if (lastText != null) {
|
||||||
|
searchUsername(lastText, lastPosition, messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void searchUsername(String text, int position, ArrayList<MessageObject> messageObjects) {
|
||||||
|
if (text == null || text.length() == 0 || position < text.length()) {
|
||||||
|
delegate.needChangePanelVisibility(false);
|
||||||
|
lastText = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (info == null) {
|
||||||
|
lastText = text;
|
||||||
|
lastPosition = position;
|
||||||
|
messages = messageObjects;
|
||||||
|
delegate.needChangePanelVisibility(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastText = null;
|
||||||
|
StringBuilder username = new StringBuilder();
|
||||||
|
boolean found = false;
|
||||||
|
for (int a = position; a >= 0; a--) {
|
||||||
|
if (a >= text.length()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char ch = text.charAt(a);
|
||||||
|
if (ch == '@' && (a == 0 || text.charAt(a - 1) == ' ')) {
|
||||||
|
found = true;
|
||||||
|
usernameStartPosition = a;
|
||||||
|
usernameLength = username.length() + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_')) {
|
||||||
|
delegate.needChangePanelVisibility(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
username.insert(0, ch);
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
delegate.needChangePanelVisibility(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ArrayList<Integer> users = new ArrayList<>();
|
||||||
|
for (int a = 0; a < Math.min(100, messageObjects.size()); a++) {
|
||||||
|
int from_id = messageObjects.get(a).messageOwner.from_id;
|
||||||
|
if (!users.contains(from_id)) {
|
||||||
|
users.add(from_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String usernameString = username.toString().toLowerCase();
|
||||||
|
ArrayList<TLRPC.User> newResult = new ArrayList<>();
|
||||||
|
for (TLRPC.TL_chatParticipant chatParticipant : info.participants) {
|
||||||
|
TLRPC.User user = MessagesController.getInstance().getUser(chatParticipant.user_id);
|
||||||
|
if (user == null || user instanceof TLRPC.TL_userSelf) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (user.username != null && user.username.length() > 0 && (usernameString.length() > 0 && user.username.toLowerCase().startsWith(usernameString) || usernameString.length() == 0)) {
|
||||||
|
newResult.add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
searchResult = newResult;
|
||||||
|
Collections.sort(searchResult, new Comparator<TLRPC.User>() {
|
||||||
|
@Override
|
||||||
|
public int compare(TLRPC.User lhs, TLRPC.User rhs) {
|
||||||
|
int lhsNum = users.indexOf(lhs.id);
|
||||||
|
int rhsNum = users.indexOf(rhs.id);
|
||||||
|
if (lhsNum != -1 && rhsNum != -1) {
|
||||||
|
return Integer.compare(lhsNum, rhsNum);
|
||||||
|
} else if (lhsNum != -1 && rhsNum == -1) {
|
||||||
|
return -1;
|
||||||
|
} else if (lhsNum == -1 && rhsNum != -1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
notifyDataSetChanged();
|
||||||
|
delegate.needChangePanelVisibility(!newResult.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUsernameStartPosition() {
|
||||||
|
return usernameStartPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUsernameLength() {
|
||||||
|
return usernameLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getViewTypeCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return searchResult.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return searchResult.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasStableIds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areAllItemsEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(int position) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TLRPC.User getItem(int i) {
|
||||||
|
if (i < 0 || i >= searchResult.size()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return searchResult.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
|
if (view == null) {
|
||||||
|
view = new MentionCell(mContext);
|
||||||
|
}
|
||||||
|
((MentionCell) view).setUser(searchResult.get(i));
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
@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
|
||||||
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);
|
||||||
|
|
|
@ -177,14 +177,14 @@ public abstract class Animator10 implements Cloneable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface AnimatorListener {
|
public interface AnimatorListener {
|
||||||
void onAnimationStart(Animator10 animation);
|
void onAnimationStart(Animator10 animation);
|
||||||
void onAnimationEnd(Animator10 animation);
|
void onAnimationEnd(Animator10 animation);
|
||||||
void onAnimationCancel(Animator10 animation);
|
void onAnimationCancel(Animator10 animation);
|
||||||
void onAnimationRepeat(Animator10 animation);
|
void onAnimationRepeat(Animator10 animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface AnimatorPauseListener {
|
public interface AnimatorPauseListener {
|
||||||
void onAnimationPause(Animator10 animation);
|
void onAnimationPause(Animator10 animation);
|
||||||
void onAnimationResume(Animator10 animation);
|
void onAnimationResume(Animator10 animation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,5 @@
|
||||||
package org.telegram.ui.Animation;
|
package org.telegram.ui.Animation;
|
||||||
|
|
||||||
public interface TypeEvaluator<T> {
|
public interface TypeEvaluator<T> {
|
||||||
public T evaluate(float fraction, T startValue, T endValue);
|
T evaluate(float fraction, T startValue, T endValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -646,7 +646,7 @@ public class ValueAnimator extends Animator10 {
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface AnimatorUpdateListener {
|
public interface AnimatorUpdateListener {
|
||||||
void onAnimationUpdate(ValueAnimator animation);
|
void onAnimationUpdate(ValueAnimator animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.ImageReceiver;
|
import org.telegram.android.ImageReceiver;
|
||||||
import org.telegram.android.MessageObject;
|
import org.telegram.android.MessageObject;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
|
import org.telegram.messenger.ApplicationLoader;
|
||||||
import org.telegram.messenger.FileLoader;
|
import org.telegram.messenger.FileLoader;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
|
@ -35,10 +36,10 @@ import org.telegram.ui.Components.AvatarDrawable;
|
||||||
|
|
||||||
public class ChatActionCell extends BaseCell {
|
public class ChatActionCell extends BaseCell {
|
||||||
|
|
||||||
public static interface ChatActionCellDelegate {
|
public interface ChatActionCellDelegate {
|
||||||
public abstract void didClickedImage(ChatActionCell cell);
|
void didClickedImage(ChatActionCell cell);
|
||||||
public abstract void didLongPressed(ChatActionCell cell);
|
void didLongPressed(ChatActionCell cell);
|
||||||
public abstract void needOpenUserProfile(int uid);
|
void needOpenUserProfile(int uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable backgroundBlack;
|
private static Drawable backgroundBlack;
|
||||||
|
@ -55,7 +56,6 @@ public class ChatActionCell extends BaseCell {
|
||||||
private int textX = 0;
|
private int textX = 0;
|
||||||
private int textY = 0;
|
private int textY = 0;
|
||||||
private int textXLeft = 0;
|
private int textXLeft = 0;
|
||||||
private boolean useBlackBackground = false;
|
|
||||||
private int previousWidth = 0;
|
private int previousWidth = 0;
|
||||||
private boolean imagePressed = false;
|
private boolean imagePressed = false;
|
||||||
|
|
||||||
|
@ -119,10 +119,6 @@ public class ChatActionCell extends BaseCell {
|
||||||
requestLayout();
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseBlackBackground(boolean value) {
|
|
||||||
useBlackBackground = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageObject getMessageObject() {
|
public MessageObject getMessageObject() {
|
||||||
return currentMessageObject;
|
return currentMessageObject;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +263,7 @@ public class ChatActionCell extends BaseCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable backgroundDrawable = null;
|
Drawable backgroundDrawable = null;
|
||||||
if (useBlackBackground) {
|
if (ApplicationLoader.isCustomTheme()) {
|
||||||
backgroundDrawable = backgroundBlack;
|
backgroundDrawable = backgroundBlack;
|
||||||
} else {
|
} else {
|
||||||
backgroundDrawable = backgroundBlue;
|
backgroundDrawable = backgroundBlue;
|
||||||
|
|
|
@ -183,9 +183,15 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||||
buttonState = 3;
|
buttonState = 3;
|
||||||
invalidate();
|
invalidate();
|
||||||
} else if (buttonState == 3) {
|
} else if (buttonState == 3) {
|
||||||
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.audio);
|
if (currentMessageObject.isOut() && currentMessageObject.isSending()) {
|
||||||
buttonState = 2;
|
if (delegate != null) {
|
||||||
invalidate();
|
delegate.didPressedCancelSendButton(this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.audio);
|
||||||
|
buttonState = 2;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,12 +297,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||||
setMeasuredDimension(width, AndroidUtilities.dp(68));
|
setMeasuredDimension(width, AndroidUtilities.dp(68) + namesOffset);
|
||||||
if (isChat) {
|
|
||||||
backgroundWidth = Math.min(width - AndroidUtilities.dp(102), AndroidUtilities.dp(300));
|
|
||||||
} else {
|
|
||||||
backgroundWidth = Math.min(width - AndroidUtilities.dp(50), AndroidUtilities.dp(300));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -325,7 +326,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||||
}
|
}
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
if (needAvatarImage) {
|
if (needAvatarImage) {
|
||||||
avatarImage.setImageCoords(x, AndroidUtilities.dp(9), AndroidUtilities.dp(50), AndroidUtilities.dp(50));
|
avatarImage.setImageCoords(x, AndroidUtilities.dp(9) + namesOffset, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
|
||||||
} else {
|
} else {
|
||||||
diff = AndroidUtilities.dp(56);
|
diff = AndroidUtilities.dp(56);
|
||||||
seekBarX -= diff;
|
seekBarX -= diff;
|
||||||
|
@ -337,8 +338,8 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||||
seekBar.height = AndroidUtilities.dp(30);
|
seekBar.height = AndroidUtilities.dp(30);
|
||||||
progressView.width = backgroundWidth - AndroidUtilities.dp(136) + diff;
|
progressView.width = backgroundWidth - AndroidUtilities.dp(136) + diff;
|
||||||
progressView.height = AndroidUtilities.dp(30);
|
progressView.height = AndroidUtilities.dp(30);
|
||||||
seekBarY = AndroidUtilities.dp(13);
|
seekBarY = AndroidUtilities.dp(13) + namesOffset;
|
||||||
buttonY = AndroidUtilities.dp(10);
|
buttonY = AndroidUtilities.dp(10) + namesOffset;
|
||||||
|
|
||||||
updateProgress();
|
updateProgress();
|
||||||
}
|
}
|
||||||
|
@ -358,6 +359,12 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||||
@Override
|
@Override
|
||||||
public void setMessageObject(MessageObject messageObject) {
|
public void setMessageObject(MessageObject messageObject) {
|
||||||
if (currentMessageObject != messageObject || isUserDataChanged()) {
|
if (currentMessageObject != messageObject || isUserDataChanged()) {
|
||||||
|
if (AndroidUtilities.isTablet()) {
|
||||||
|
backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat ? 102 : 50), AndroidUtilities.dp(300));
|
||||||
|
} else {
|
||||||
|
backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat ? 102 : 50), AndroidUtilities.dp(300));
|
||||||
|
}
|
||||||
|
|
||||||
int uid = messageObject.messageOwner.media.audio.user_id;
|
int uid = messageObject.messageOwner.media.audio.user_id;
|
||||||
if (uid == 0) {
|
if (uid == 0) {
|
||||||
uid = messageObject.messageOwner.from_id;
|
uid = messageObject.messageOwner.from_id;
|
||||||
|
@ -430,7 +437,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||||
buttonDrawable.draw(canvas);
|
buttonDrawable.draw(canvas);
|
||||||
|
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(timeX, AndroidUtilities.dp(45));
|
canvas.translate(timeX, AndroidUtilities.dp(45) + namesOffset);
|
||||||
timeLayout.draw(canvas);
|
timeLayout.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ package org.telegram.ui.Cells;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
|
@ -22,7 +23,10 @@ import android.view.SoundEffectConstants;
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.ContactsController;
|
import org.telegram.android.ContactsController;
|
||||||
|
import org.telegram.android.Emoji;
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
|
import org.telegram.messenger.ApplicationLoader;
|
||||||
|
import org.telegram.messenger.FileLoader;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
|
@ -32,16 +36,19 @@ import org.telegram.ui.Components.AvatarDrawable;
|
||||||
|
|
||||||
public class ChatBaseCell extends BaseCell {
|
public class ChatBaseCell extends BaseCell {
|
||||||
|
|
||||||
public static interface ChatBaseCellDelegate {
|
public interface ChatBaseCellDelegate {
|
||||||
public abstract void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user);
|
void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user);
|
||||||
public abstract void didPressedCancelSendButton(ChatBaseCell cell);
|
void didPressedCancelSendButton(ChatBaseCell cell);
|
||||||
public abstract void didLongPressed(ChatBaseCell cell);
|
void didLongPressed(ChatBaseCell cell);
|
||||||
public abstract boolean canPerformActions();
|
void didPressReplyMessage(ChatBaseCell cell, int id);
|
||||||
|
void didPressUrl(String url);
|
||||||
|
boolean canPerformActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChat = false;
|
public boolean isChat = false;
|
||||||
protected boolean isPressed = false;
|
protected boolean isPressed = false;
|
||||||
protected boolean forwardName = false;
|
protected boolean forwardName = false;
|
||||||
|
protected boolean isHighlighted = false;
|
||||||
protected boolean media = false;
|
protected boolean media = false;
|
||||||
protected boolean isCheckPressed = true;
|
protected boolean isCheckPressed = true;
|
||||||
private boolean wasLayout = false;
|
private boolean wasLayout = false;
|
||||||
|
@ -66,12 +73,17 @@ public class ChatBaseCell extends BaseCell {
|
||||||
private static Drawable clockMediaDrawable;
|
private static Drawable clockMediaDrawable;
|
||||||
private static Drawable broadcastMediaDrawable;
|
private static Drawable broadcastMediaDrawable;
|
||||||
private static Drawable errorDrawable;
|
private static Drawable errorDrawable;
|
||||||
|
private static Drawable backgroundBlack;
|
||||||
|
private static Drawable backgroundBlue;
|
||||||
protected static Drawable mediaBackgroundDrawable;
|
protected static Drawable mediaBackgroundDrawable;
|
||||||
private static TextPaint timePaintIn;
|
private static TextPaint timePaintIn;
|
||||||
private static TextPaint timePaintOut;
|
private static TextPaint timePaintOut;
|
||||||
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;
|
||||||
|
private static TextPaint replyTextPaint;
|
||||||
|
private static Paint replyLinePaint;
|
||||||
|
|
||||||
protected int backgroundWidth = 100;
|
protected int backgroundWidth = 100;
|
||||||
|
|
||||||
|
@ -83,6 +95,19 @@ public class ChatBaseCell extends BaseCell {
|
||||||
private boolean avatarPressed = false;
|
private boolean avatarPressed = false;
|
||||||
private boolean forwardNamePressed = false;
|
private boolean forwardNamePressed = false;
|
||||||
|
|
||||||
|
private StaticLayout replyNameLayout;
|
||||||
|
private StaticLayout replyTextLayout;
|
||||||
|
private ImageReceiver replyImageReceiver;
|
||||||
|
private int replyStartX;
|
||||||
|
private int replyStartY;
|
||||||
|
protected int replyNameWidth;
|
||||||
|
private float replyNameOffset;
|
||||||
|
protected int replyTextWidth;
|
||||||
|
private float replyTextOffset;
|
||||||
|
private boolean needReplyImage = false;
|
||||||
|
private boolean replyPressed = false;
|
||||||
|
private TLRPC.FileLocation currentReplyPhoto;
|
||||||
|
|
||||||
private StaticLayout nameLayout;
|
private StaticLayout nameLayout;
|
||||||
protected int nameWidth;
|
protected int nameWidth;
|
||||||
private float nameOffsetX = 0;
|
private float nameOffsetX = 0;
|
||||||
|
@ -137,6 +162,8 @@ public class ChatBaseCell extends BaseCell {
|
||||||
mediaBackgroundDrawable = getResources().getDrawable(R.drawable.phototime);
|
mediaBackgroundDrawable = getResources().getDrawable(R.drawable.phototime);
|
||||||
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast3);
|
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast3);
|
||||||
broadcastMediaDrawable = getResources().getDrawable(R.drawable.broadcast4);
|
broadcastMediaDrawable = getResources().getDrawable(R.drawable.broadcast4);
|
||||||
|
backgroundBlack = getResources().getDrawable(R.drawable.system_black);
|
||||||
|
backgroundBlue = getResources().getDrawable(R.drawable.system_blue);
|
||||||
|
|
||||||
timePaintIn = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
timePaintIn = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
timePaintIn.setTextSize(AndroidUtilities.dp(12));
|
timePaintIn.setTextSize(AndroidUtilities.dp(12));
|
||||||
|
@ -155,17 +182,29 @@ public class ChatBaseCell extends BaseCell {
|
||||||
|
|
||||||
forwardNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
forwardNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
forwardNamePaint.setTextSize(AndroidUtilities.dp(14));
|
forwardNamePaint.setTextSize(AndroidUtilities.dp(14));
|
||||||
|
|
||||||
|
replyNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
|
replyNamePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||||
|
replyNamePaint.setTextSize(AndroidUtilities.dp(14));
|
||||||
|
|
||||||
|
replyTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||||
|
replyTextPaint.setTextSize(AndroidUtilities.dp(14));
|
||||||
|
|
||||||
|
replyLinePaint = new Paint();
|
||||||
}
|
}
|
||||||
avatarImage = new ImageReceiver(this);
|
avatarImage = new ImageReceiver(this);
|
||||||
avatarImage.setRoundRadius(AndroidUtilities.dp(21));
|
avatarImage.setRoundRadius(AndroidUtilities.dp(21));
|
||||||
avatarDrawable = new AvatarDrawable();
|
avatarDrawable = new AvatarDrawable();
|
||||||
|
replyImageReceiver = new ImageReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
avatarImage.clearImage();
|
avatarImage.clearImage();
|
||||||
|
replyImageReceiver.clearImage();
|
||||||
currentPhoto = null;
|
currentPhoto = null;
|
||||||
|
currentReplyPhoto = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,6 +217,14 @@ public class ChatBaseCell extends BaseCell {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHighlighted(boolean value) {
|
||||||
|
if (isHighlighted == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isHighlighted = value;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
public void setCheckPressed(boolean value, boolean pressed) {
|
public void setCheckPressed(boolean value, boolean pressed) {
|
||||||
isCheckPressed = value;
|
isCheckPressed = value;
|
||||||
isPressed = pressed;
|
isPressed = pressed;
|
||||||
|
@ -202,10 +249,27 @@ public class ChatBaseCell extends BaseCell {
|
||||||
newPhoto = newUser.photo.photo_small;
|
newPhoto = newUser.photo.photo_small;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (replyTextLayout == null && currentMessageObject.replyMessageObject != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentPhoto == null && newPhoto != null || currentPhoto != null && newPhoto == null || currentPhoto != null && newPhoto != null && (currentPhoto.local_id != newPhoto.local_id || currentPhoto.volume_id != newPhoto.volume_id)) {
|
if (currentPhoto == null && newPhoto != null || currentPhoto != null && newPhoto == null || currentPhoto != null && newPhoto != null && (currentPhoto.local_id != newPhoto.local_id || currentPhoto.volume_id != newPhoto.volume_id)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TLRPC.FileLocation newReplyPhoto = null;
|
||||||
|
|
||||||
|
if (currentMessageObject.replyMessageObject != null) {
|
||||||
|
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(currentMessageObject.replyMessageObject.photoThumbs, 80);
|
||||||
|
if (photoSize != null && currentMessageObject.replyMessageObject.type != 13) {
|
||||||
|
newReplyPhoto = photoSize.location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentReplyPhoto == null && newReplyPhoto != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
String newNameString = null;
|
String newNameString = null;
|
||||||
if (drawName && isChat && newUser != null && !currentMessageObject.isOut()) {
|
if (drawName && isChat && newUser != null && !currentMessageObject.isOut()) {
|
||||||
newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
|
newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
|
||||||
|
@ -217,7 +281,7 @@ public class ChatBaseCell extends BaseCell {
|
||||||
|
|
||||||
newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.fwd_from_id);
|
newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.fwd_from_id);
|
||||||
newNameString = null;
|
newNameString = null;
|
||||||
if (newUser != null && drawForwardedName && currentMessageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
if (newUser != null && drawForwardedName && currentMessageObject.messageOwner.fwd_from_id != 0) {
|
||||||
newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
|
newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
|
||||||
}
|
}
|
||||||
return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString);
|
return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString);
|
||||||
|
@ -231,6 +295,11 @@ public class ChatBaseCell extends BaseCell {
|
||||||
isCheckPressed = true;
|
isCheckPressed = true;
|
||||||
isAvatarVisible = false;
|
isAvatarVisible = false;
|
||||||
wasLayout = false;
|
wasLayout = false;
|
||||||
|
replyNameLayout = null;
|
||||||
|
replyTextLayout = null;
|
||||||
|
replyNameWidth = 0;
|
||||||
|
replyTextWidth = 0;
|
||||||
|
currentReplyPhoto = null;
|
||||||
|
|
||||||
currentUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
currentUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||||
if (isChat && !messageObject.isOut()) {
|
if (isChat && !messageObject.isOut()) {
|
||||||
|
@ -272,7 +341,7 @@ public class ChatBaseCell extends BaseCell {
|
||||||
nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
if (nameLayout.getLineCount() > 0) {
|
if (nameLayout.getLineCount() > 0) {
|
||||||
nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0));
|
nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0));
|
||||||
namesOffset += AndroidUtilities.dp(18);
|
namesOffset += AndroidUtilities.dp(19);
|
||||||
nameOffsetX = nameLayout.getLineLeft(0);
|
nameOffsetX = nameLayout.getLineLeft(0);
|
||||||
} else {
|
} else {
|
||||||
nameWidth = 0;
|
nameWidth = 0;
|
||||||
|
@ -283,7 +352,7 @@ public class ChatBaseCell extends BaseCell {
|
||||||
nameWidth = 0;
|
nameWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawForwardedName && messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
if (drawForwardedName && messageObject.isForwarded()) {
|
||||||
currentForwardUser = MessagesController.getInstance().getUser(messageObject.messageOwner.fwd_from_id);
|
currentForwardUser = MessagesController.getInstance().getUser(messageObject.messageOwner.fwd_from_id);
|
||||||
if (currentForwardUser != null) {
|
if (currentForwardUser != null) {
|
||||||
currentForwardNameString = ContactsController.formatName(currentForwardUser.first_name, currentForwardUser.last_name);
|
currentForwardNameString = ContactsController.formatName(currentForwardUser.first_name, currentForwardUser.last_name);
|
||||||
|
@ -311,6 +380,87 @@ public class ChatBaseCell extends BaseCell {
|
||||||
forwardedNameWidth = 0;
|
forwardedNameWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (messageObject.isReply()) {
|
||||||
|
namesOffset += AndroidUtilities.dp(42);
|
||||||
|
if (messageObject.contentType == 2 || messageObject.contentType == 3) {
|
||||||
|
namesOffset += AndroidUtilities.dp(4);
|
||||||
|
} else if (messageObject.contentType == 1) {
|
||||||
|
if (messageObject.type == 13) {
|
||||||
|
namesOffset -= AndroidUtilities.dp(42);
|
||||||
|
} else {
|
||||||
|
namesOffset += AndroidUtilities.dp(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxWidth;
|
||||||
|
if (messageObject.type == 13) {
|
||||||
|
int width;
|
||||||
|
if (AndroidUtilities.isTablet()) {
|
||||||
|
int leftWidth = AndroidUtilities.displaySize.x / 100 * 35;
|
||||||
|
if (leftWidth < AndroidUtilities.dp(320)) {
|
||||||
|
leftWidth = AndroidUtilities.dp(320);
|
||||||
|
}
|
||||||
|
width = AndroidUtilities.displaySize.x - leftWidth;
|
||||||
|
} else {
|
||||||
|
width = AndroidUtilities.displaySize.x;
|
||||||
|
}
|
||||||
|
if (messageObject.isOut()) {
|
||||||
|
maxWidth = width - backgroundWidth - AndroidUtilities.dp(60);
|
||||||
|
} else {
|
||||||
|
maxWidth = width - backgroundWidth - AndroidUtilities.dp(56 + (isChat ? 61 : 0));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
maxWidth = getMaxNameWidth() - AndroidUtilities.dp(22);
|
||||||
|
}
|
||||||
|
if (!media && messageObject.contentType != 0) {
|
||||||
|
maxWidth -= AndroidUtilities.dp(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
CharSequence stringFinalName = null;
|
||||||
|
CharSequence stringFinalText = null;
|
||||||
|
if (messageObject.replyMessageObject != null) {
|
||||||
|
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.replyMessageObject.photoThumbs, 80);
|
||||||
|
if (photoSize == null || messageObject.replyMessageObject.type == 13 || messageObject.type == 13 && !AndroidUtilities.isTablet()) {
|
||||||
|
replyImageReceiver.setImageBitmap((Drawable) null);
|
||||||
|
needReplyImage = false;
|
||||||
|
} else {
|
||||||
|
currentReplyPhoto = photoSize.location;
|
||||||
|
replyImageReceiver.setImage(photoSize.location, "50_50", null, true);
|
||||||
|
needReplyImage = true;
|
||||||
|
maxWidth -= AndroidUtilities.dp(44);
|
||||||
|
}
|
||||||
|
|
||||||
|
TLRPC.User user = MessagesController.getInstance().getUser(messageObject.replyMessageObject.messageOwner.from_id);
|
||||||
|
if (user != null) {
|
||||||
|
stringFinalName = TextUtils.ellipsize(ContactsController.formatName(user.first_name, user.last_name).replace("\n", " "), replyNamePaint, maxWidth - AndroidUtilities.dp(8), TextUtils.TruncateAt.END);
|
||||||
|
}
|
||||||
|
if (messageObject.replyMessageObject.messageText != null && messageObject.replyMessageObject.messageText.length() > 0) {
|
||||||
|
String mess = messageObject.replyMessageObject.messageText.toString();
|
||||||
|
if (mess.length() > 150) {
|
||||||
|
mess = mess.substring(0, 150);
|
||||||
|
}
|
||||||
|
mess = mess.replace("\n", " ");
|
||||||
|
stringFinalText = Emoji.replaceEmoji(mess, replyTextPaint.getFontMetricsInt(), AndroidUtilities.dp(14));
|
||||||
|
stringFinalText = TextUtils.ellipsize(stringFinalText, replyTextPaint, maxWidth - AndroidUtilities.dp(8), TextUtils.TruncateAt.END);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (stringFinalName == null) {
|
||||||
|
stringFinalName = LocaleController.getString("Loading", R.string.Loading);
|
||||||
|
}
|
||||||
|
replyNameLayout = new StaticLayout(stringFinalName, replyNamePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
|
if (replyNameLayout.getLineCount() > 0) {
|
||||||
|
replyNameWidth = (int)Math.ceil(replyNameLayout.getLineWidth(0)) + AndroidUtilities.dp(12 + (needReplyImage ? 44 : 0));
|
||||||
|
replyNameOffset = replyNameLayout.getLineLeft(0);
|
||||||
|
}
|
||||||
|
if (stringFinalText != null) {
|
||||||
|
replyTextLayout = new StaticLayout(stringFinalText, replyTextPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
|
if (replyTextLayout.getLineCount() > 0) {
|
||||||
|
replyTextWidth = (int) Math.ceil(replyTextLayout.getLineWidth(0)) + AndroidUtilities.dp(12 + (needReplyImage ? 44 : 0));
|
||||||
|
replyTextOffset = replyTextLayout.getLineLeft(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
requestLayout();
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,6 +487,11 @@ public class ChatBaseCell extends BaseCell {
|
||||||
forwardNamePressed = true;
|
forwardNamePressed = true;
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
} else if (currentMessageObject.isReply()) {
|
||||||
|
if (x >= replyStartX && x <= replyStartX + Math.max(replyNameWidth, replyTextWidth) && y >= replyStartY && y <= replyStartY + AndroidUtilities.dp(35)) {
|
||||||
|
replyPressed = true;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
startCheckLongPress();
|
startCheckLongPress();
|
||||||
|
@ -374,6 +529,20 @@ public class ChatBaseCell extends BaseCell {
|
||||||
forwardNamePressed = false;
|
forwardNamePressed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (replyPressed) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
|
replyPressed = false;
|
||||||
|
playSoundEffect(SoundEffectConstants.CLICK);
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.didPressReplyMessage(this, currentMessageObject.messageOwner.reply_to_msg_id);
|
||||||
|
}
|
||||||
|
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||||
|
replyPressed = false;
|
||||||
|
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
|
if (!(x >= replyStartX && x <= replyStartX + Math.max(replyNameWidth, replyTextWidth) && y >= replyStartY && y <= replyStartY + AndroidUtilities.dp(35))) {
|
||||||
|
replyPressed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -442,7 +611,7 @@ public class ChatBaseCell extends BaseCell {
|
||||||
|
|
||||||
Drawable currentBackgroundDrawable = null;
|
Drawable currentBackgroundDrawable = null;
|
||||||
if (currentMessageObject.isOut()) {
|
if (currentMessageObject.isOut()) {
|
||||||
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed) {
|
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) {
|
||||||
if (!media) {
|
if (!media) {
|
||||||
currentBackgroundDrawable = backgroundDrawableOutSelected;
|
currentBackgroundDrawable = backgroundDrawableOutSelected;
|
||||||
} else {
|
} else {
|
||||||
|
@ -457,7 +626,7 @@ public class ChatBaseCell extends BaseCell {
|
||||||
}
|
}
|
||||||
setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2));
|
setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2));
|
||||||
} else {
|
} else {
|
||||||
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed) {
|
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) {
|
||||||
if (!media) {
|
if (!media) {
|
||||||
currentBackgroundDrawable = backgroundDrawableInSelected;
|
currentBackgroundDrawable = backgroundDrawableInSelected;
|
||||||
} else {
|
} else {
|
||||||
|
@ -491,21 +660,79 @@ public class ChatBaseCell extends BaseCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawForwardedName && forwardedNameLayout != null) {
|
if (drawForwardedName && forwardedNameLayout != null) {
|
||||||
canvas.save();
|
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 19 : 0));
|
||||||
if (currentMessageObject.isOut()) {
|
if (currentMessageObject.isOut()) {
|
||||||
forwardNamePaint.setColor(0xff4a923c);
|
forwardNamePaint.setColor(0xff4a923c);
|
||||||
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10);
|
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10);
|
||||||
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 18 : 0));
|
|
||||||
} else {
|
} else {
|
||||||
forwardNamePaint.setColor(0xff006fc8);
|
forwardNamePaint.setColor(0xff006fc8);
|
||||||
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19);
|
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19);
|
||||||
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 18 : 0));
|
|
||||||
}
|
}
|
||||||
|
canvas.save();
|
||||||
canvas.translate(forwardNameX - forwardNameOffsetX, forwardNameY);
|
canvas.translate(forwardNameX - forwardNameOffsetX, forwardNameY);
|
||||||
forwardedNameLayout.draw(canvas);
|
forwardedNameLayout.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentMessageObject.isReply()) {
|
||||||
|
if (currentMessageObject.type == 13) {
|
||||||
|
replyLinePaint.setColor(0xffffffff);
|
||||||
|
replyNamePaint.setColor(0xffffffff);
|
||||||
|
replyTextPaint.setColor(0xffffffff);
|
||||||
|
int backWidth;
|
||||||
|
if (currentMessageObject.isOut()) {
|
||||||
|
backWidth = currentBackgroundDrawable.getBounds().left - AndroidUtilities.dp(32);
|
||||||
|
replyStartX = currentBackgroundDrawable.getBounds().left - AndroidUtilities.dp(9) - backWidth;
|
||||||
|
} else {
|
||||||
|
backWidth = getWidth() - currentBackgroundDrawable.getBounds().right - AndroidUtilities.dp(32);
|
||||||
|
replyStartX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(23);
|
||||||
|
}
|
||||||
|
Drawable back;
|
||||||
|
if (ApplicationLoader.isCustomTheme()) {
|
||||||
|
back = backgroundBlack;
|
||||||
|
} else {
|
||||||
|
back = backgroundBlue;
|
||||||
|
}
|
||||||
|
replyStartY = layoutHeight - AndroidUtilities.dp(58);
|
||||||
|
back.setBounds(replyStartX - AndroidUtilities.dp(7), replyStartY - AndroidUtilities.dp(6), replyStartX - AndroidUtilities.dp(7) + backWidth, replyStartY + AndroidUtilities.dp(41));
|
||||||
|
back.draw(canvas);
|
||||||
|
} else {
|
||||||
|
if (currentMessageObject.isOut()) {
|
||||||
|
replyLinePaint.setColor(0xff8dc97a);
|
||||||
|
replyNamePaint.setColor(0xff61a349);
|
||||||
|
replyTextPaint.setColor(0xff70b15c);
|
||||||
|
replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11);
|
||||||
|
} else {
|
||||||
|
replyLinePaint.setColor(0xff6c9fd2);
|
||||||
|
replyNamePaint.setColor(0xff377aae);
|
||||||
|
replyTextPaint.setColor(0xff999999);
|
||||||
|
if (currentMessageObject.contentType == 1 && media) {
|
||||||
|
replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11);
|
||||||
|
} else {
|
||||||
|
replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
replyStartY = AndroidUtilities.dp(12 + (drawForwardedName && forwardedNameLayout != null ? 36 : 0) + (drawName && nameLayout != null ? 20 : 0));
|
||||||
|
}
|
||||||
|
canvas.drawRect(replyStartX, replyStartY, replyStartX + AndroidUtilities.dp(2), replyStartY + AndroidUtilities.dp(35), replyLinePaint);
|
||||||
|
if (needReplyImage) {
|
||||||
|
replyImageReceiver.setImageCoords(replyStartX + AndroidUtilities.dp(10), replyStartY, AndroidUtilities.dp(35), AndroidUtilities.dp(35));
|
||||||
|
replyImageReceiver.draw(canvas);
|
||||||
|
}
|
||||||
|
if (replyNameLayout != null) {
|
||||||
|
canvas.save();
|
||||||
|
canvas.translate(replyStartX - replyNameOffset + AndroidUtilities.dp(10 + (needReplyImage ? 44 : 0)), replyStartY);
|
||||||
|
replyNameLayout.draw(canvas);
|
||||||
|
canvas.restore();
|
||||||
|
}
|
||||||
|
if (replyTextLayout != null) {
|
||||||
|
canvas.save();
|
||||||
|
canvas.translate(replyStartX - replyTextOffset + AndroidUtilities.dp(10 + (needReplyImage ? 44 : 0)), replyStartY + AndroidUtilities.dp(19));
|
||||||
|
replyTextLayout.draw(canvas);
|
||||||
|
canvas.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (drawTime) {
|
if (drawTime) {
|
||||||
if (media) {
|
if (media) {
|
||||||
setDrawableBounds(mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dp(16.5f));
|
setDrawableBounds(mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dp(16.5f));
|
||||||
|
|
|
@ -32,9 +32,9 @@ import org.telegram.ui.Components.AvatarDrawable;
|
||||||
|
|
||||||
public class ChatContactCell extends ChatBaseCell {
|
public class ChatContactCell extends ChatBaseCell {
|
||||||
|
|
||||||
public static interface ChatContactCellDelegate {
|
public interface ChatContactCellDelegate {
|
||||||
public abstract void didClickAddButton(ChatContactCell cell, TLRPC.User user);
|
void didClickAddButton(ChatContactCell cell, TLRPC.User user);
|
||||||
public abstract void didClickPhone(ChatContactCell cell);
|
void didClickPhone(ChatContactCell cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextPaint namePaint;
|
private static TextPaint namePaint;
|
||||||
|
@ -113,7 +113,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||||
if (x >= avatarImage.getImageX() && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(42) && y >= avatarImage.getImageY() && y <= avatarImage.getImageY() + avatarImage.getImageHeight()) {
|
if (x >= avatarImage.getImageX() && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(42) && y >= avatarImage.getImageY() && y <= avatarImage.getImageY() + avatarImage.getImageHeight()) {
|
||||||
avatarPressed = true;
|
avatarPressed = true;
|
||||||
result = true;
|
result = true;
|
||||||
} else if (x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52)) {
|
} else if (x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) + namesOffset && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52) + namesOffset) {
|
||||||
buttonPressed = true;
|
buttonPressed = true;
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||||
buttonPressed = false;
|
buttonPressed = false;
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
if (!(x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52))) {
|
if (!(x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) + namesOffset && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52) + namesOffset)) {
|
||||||
buttonPressed = false;
|
buttonPressed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(71));
|
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(71) + namesOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,7 +257,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||||
x = AndroidUtilities.dp(16);
|
x = AndroidUtilities.dp(16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
avatarImage.setImageCoords(x, AndroidUtilities.dp(9), AndroidUtilities.dp(42), AndroidUtilities.dp(42));
|
avatarImage.setImageCoords(x, AndroidUtilities.dp(9) + namesOffset, AndroidUtilities.dp(42), AndroidUtilities.dp(42));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -272,14 +272,14 @@ public class ChatContactCell extends ChatBaseCell {
|
||||||
|
|
||||||
if (nameLayout != null) {
|
if (nameLayout != null) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(10));
|
canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(10) + namesOffset);
|
||||||
namePaint.setColor(AvatarDrawable.getColorForId(currentMessageObject.messageOwner.media.user_id));
|
namePaint.setColor(AvatarDrawable.getColorForId(currentMessageObject.messageOwner.media.user_id));
|
||||||
nameLayout.draw(canvas);
|
nameLayout.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
if (phoneLayout != null) {
|
if (phoneLayout != null) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(31));
|
canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(31) + namesOffset);
|
||||||
phoneLayout.draw(canvas);
|
phoneLayout.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||||
} else {
|
} else {
|
||||||
addContactDrawable = addContactDrawableIn;
|
addContactDrawable = addContactDrawableIn;
|
||||||
}
|
}
|
||||||
setDrawableBounds(addContactDrawable, avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(78), AndroidUtilities.dp(13));
|
setDrawableBounds(addContactDrawable, avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(78), AndroidUtilities.dp(13) + namesOffset);
|
||||||
addContactDrawable.draw(canvas);
|
addContactDrawable.draw(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,9 @@ import java.util.Locale;
|
||||||
|
|
||||||
public class ChatMediaCell extends ChatBaseCell implements MediaController.FileDownloadProgressListener {
|
public class ChatMediaCell extends ChatBaseCell implements MediaController.FileDownloadProgressListener {
|
||||||
|
|
||||||
public static interface ChatMediaCellDelegate {
|
public interface ChatMediaCellDelegate {
|
||||||
public abstract void didClickedImage(ChatMediaCell cell);
|
void didClickedImage(ChatMediaCell cell);
|
||||||
public abstract void didPressedOther(ChatMediaCell cell);
|
void didPressedOther(ChatMediaCell cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable placeholderDocInDrawable;
|
private static Drawable placeholderDocInDrawable;
|
||||||
|
@ -191,7 +191,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
otherPressed = true;
|
otherPressed = true;
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (currentMessageObject.type != 13) {
|
||||||
if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) {
|
if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) {
|
||||||
imagePressed = true;
|
imagePressed = true;
|
||||||
result = true;
|
result = true;
|
||||||
|
@ -359,7 +359,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
photoImage.cancelLoadImage();
|
photoImage.cancelLoadImage();
|
||||||
} else if (currentMessageObject.type == 8 || currentMessageObject.type == 9) {
|
} else if (currentMessageObject.type == 8 || currentMessageObject.type == 9) {
|
||||||
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document);
|
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document);
|
||||||
if (lastDownloadedGifMessage != null && lastDownloadedGifMessage.messageOwner.id == currentMessageObject.messageOwner.id) {
|
if (lastDownloadedGifMessage != null && lastDownloadedGifMessage.getId() == currentMessageObject.getId()) {
|
||||||
lastDownloadedGifMessage = null;
|
lastDownloadedGifMessage = null;
|
||||||
}
|
}
|
||||||
} else if (currentMessageObject.type == 3) {
|
} else if (currentMessageObject.type == 3) {
|
||||||
|
@ -413,7 +413,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
media = messageObject.type != 9;
|
media = messageObject.type != 9;
|
||||||
boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet);
|
boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet);
|
||||||
if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || dataChanged) {
|
if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || dataChanged) {
|
||||||
super.setMessageObject(messageObject);
|
|
||||||
cancelLoading = false;
|
cancelLoading = false;
|
||||||
|
|
||||||
buttonState = -1;
|
buttonState = -1;
|
||||||
|
@ -510,13 +509,13 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
photoImage.setImageBitmap((BitmapDrawable) null);
|
photoImage.setImageBitmap((BitmapDrawable) null);
|
||||||
}
|
}
|
||||||
} else if (messageObject.type == 4) { //geo
|
} else if (messageObject.type == 4) { //geo
|
||||||
photoWidth = AndroidUtilities.dp(100);
|
photoWidth = AndroidUtilities.dp(200);
|
||||||
photoHeight = AndroidUtilities.dp(100);
|
photoHeight = AndroidUtilities.dp(100);
|
||||||
backgroundWidth = photoWidth + AndroidUtilities.dp(12);
|
backgroundWidth = photoWidth + AndroidUtilities.dp(12);
|
||||||
|
|
||||||
double lat = messageObject.messageOwner.media.geo.lat;
|
double lat = messageObject.messageOwner.media.geo.lat;
|
||||||
double lon = messageObject.messageOwner.media.geo._long;
|
double lon = messageObject.messageOwner.media.geo._long;
|
||||||
currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(AndroidUtilities.density)), lat, lon);
|
currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=200x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(AndroidUtilities.density)), lat, lon);
|
||||||
photoImage.setNeedsQualityThumb(false);
|
photoImage.setNeedsQualityThumb(false);
|
||||||
photoImage.setShouldGenerateQualityThumb(false);
|
photoImage.setShouldGenerateQualityThumb(false);
|
||||||
photoImage.setParentMessageObject(null);
|
photoImage.setParentMessageObject(null);
|
||||||
|
@ -531,6 +530,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float maxHeight = AndroidUtilities.displaySize.y * 0.4f;
|
float maxHeight = AndroidUtilities.displaySize.y * 0.4f;
|
||||||
|
float maxWidth;
|
||||||
|
if (AndroidUtilities.isTablet()) {
|
||||||
|
maxWidth = AndroidUtilities.getMinTabletSide() * 0.5f;
|
||||||
|
} else {
|
||||||
|
maxWidth = AndroidUtilities.displaySize.x * 0.5f;
|
||||||
|
}
|
||||||
if (photoWidth == 0) {
|
if (photoWidth == 0) {
|
||||||
photoHeight = (int) maxHeight;
|
photoHeight = (int) maxHeight;
|
||||||
photoWidth = photoHeight + AndroidUtilities.dp(100);
|
photoWidth = photoHeight + AndroidUtilities.dp(100);
|
||||||
|
@ -539,28 +544,32 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
photoWidth *= maxHeight / photoHeight;
|
photoWidth *= maxHeight / photoHeight;
|
||||||
photoHeight = (int)maxHeight;
|
photoHeight = (int)maxHeight;
|
||||||
}
|
}
|
||||||
|
if (photoWidth > maxWidth) {
|
||||||
|
photoHeight *= maxWidth / photoWidth;
|
||||||
|
photoWidth = (int)maxWidth;
|
||||||
|
}
|
||||||
backgroundWidth = photoWidth + AndroidUtilities.dp(12);
|
backgroundWidth = photoWidth + AndroidUtilities.dp(12);
|
||||||
currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80);
|
currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80);
|
||||||
photoImage.setNeedsQualityThumb(false);
|
photoImage.setNeedsQualityThumb(false);
|
||||||
photoImage.setShouldGenerateQualityThumb(false);
|
photoImage.setShouldGenerateQualityThumb(false);
|
||||||
photoImage.setParentMessageObject(null);
|
photoImage.setParentMessageObject(null);
|
||||||
if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() > 0) {
|
if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() > 0) {
|
||||||
File f = new File(currentMessageObject.messageOwner.attachPath);
|
File f = new File(messageObject.messageOwner.attachPath);
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
photoImage.setImage(null, currentMessageObject.messageOwner.attachPath,
|
photoImage.setImage(null, messageObject.messageOwner.attachPath,
|
||||||
String.format(Locale.US, "%d_%d", photoWidth, photoHeight),
|
String.format(Locale.US, "%d_%d", photoWidth, photoHeight),
|
||||||
null,
|
null,
|
||||||
currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null,
|
currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null,
|
||||||
"b1",
|
"b1",
|
||||||
currentMessageObject.messageOwner.media.document.size, true);
|
messageObject.messageOwner.media.document.size, true);
|
||||||
}
|
}
|
||||||
} else if (currentMessageObject.messageOwner.media.document.id != 0) {
|
} else if (messageObject.messageOwner.media.document.id != 0) {
|
||||||
photoImage.setImage(currentMessageObject.messageOwner.media.document, null,
|
photoImage.setImage(messageObject.messageOwner.media.document, null,
|
||||||
String.format(Locale.US, "%d_%d", photoWidth, photoHeight),
|
String.format(Locale.US, "%d_%d", photoWidth, photoHeight),
|
||||||
null,
|
null,
|
||||||
currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null,
|
currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null,
|
||||||
"b1",
|
"b1",
|
||||||
currentMessageObject.messageOwner.media.document.size, true);
|
messageObject.messageOwner.media.document.size, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
|
@ -598,7 +607,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
|
|
||||||
if (currentPhotoObject != null) {
|
if (currentPhotoObject != null) {
|
||||||
boolean noSize = false;
|
boolean noSize = false;
|
||||||
if (currentMessageObject.type == 3 || currentMessageObject.type == 8) {
|
if (messageObject.type == 3 || messageObject.type == 8) {
|
||||||
noSize = true;
|
noSize = true;
|
||||||
}
|
}
|
||||||
float scale = (float) currentPhotoObject.w / (float) photoWidth;
|
float scale = (float) currentPhotoObject.w / (float) photoWidth;
|
||||||
|
@ -631,12 +640,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
w = (int) (currentPhotoObject.w / hScale);
|
w = (int) (currentPhotoObject.w / hScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int timeWidthTotal = timeWidth + AndroidUtilities.dp(14 + (currentMessageObject.isOut() ? 20 : 0));
|
int timeWidthTotal = timeWidth + AndroidUtilities.dp(14 + (messageObject.isOut() ? 20 : 0));
|
||||||
if (w < timeWidthTotal) {
|
if (w < timeWidthTotal) {
|
||||||
w = timeWidthTotal;
|
w = timeWidthTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentMessageObject.isSecretPhoto()) {
|
if (messageObject.isSecretPhoto()) {
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
w = h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
|
w = h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
|
||||||
} else {
|
} else {
|
||||||
|
@ -660,7 +669,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
String fileName = FileLoader.getAttachFileName(currentPhotoObject);
|
String fileName = FileLoader.getAttachFileName(currentPhotoObject);
|
||||||
if (messageObject.type == 1) {
|
if (messageObject.type == 1) {
|
||||||
boolean photoExist = true;
|
boolean photoExist = true;
|
||||||
File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
|
File cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner);
|
||||||
if (!cacheFile.exists()) {
|
if (!cacheFile.exists()) {
|
||||||
photoExist = false;
|
photoExist = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -691,6 +700,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
photoImage.setImageBitmap((Bitmap)null);
|
photoImage.setImageBitmap((Bitmap)null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
super.setMessageObject(messageObject);
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
@ -733,7 +743,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
buttonState = 1;
|
buttonState = 1;
|
||||||
radialProgress.setBackground(getDrawableForCurrentState(), true, animated);
|
radialProgress.setBackground(getDrawableForCurrentState(), true, animated);
|
||||||
Float progress = ImageLoader.getInstance().getFileProgress(currentMessageObject.messageOwner.attachPath);
|
Float progress = ImageLoader.getInstance().getFileProgress(currentMessageObject.messageOwner.attachPath);
|
||||||
if (progress == null && SendMessagesHelper.getInstance().isSendingMessage(currentMessageObject.messageOwner.id)) {
|
if (progress == null && SendMessagesHelper.getInstance().isSendingMessage(currentMessageObject.getId())) {
|
||||||
progress = 1.0f;
|
progress = 1.0f;
|
||||||
}
|
}
|
||||||
radialProgress.setProgress(progress != null ? progress : 0, false);
|
radialProgress.setProgress(progress != null ? progress : 0, false);
|
||||||
|
@ -783,7 +793,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), photoHeight + AndroidUtilities.dp(14));
|
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), photoHeight + AndroidUtilities.dp(14) + namesOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -804,10 +814,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
x = AndroidUtilities.dp(15);
|
x = AndroidUtilities.dp(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
photoImage.setImageCoords(x, AndroidUtilities.dp(7), photoWidth, photoHeight);
|
photoImage.setImageCoords(x, AndroidUtilities.dp(7) + namesOffset, photoWidth, photoHeight);
|
||||||
int size = AndroidUtilities.dp(48);
|
int size = AndroidUtilities.dp(48);
|
||||||
buttonX = (int)(x + (photoWidth - size) / 2.0f);
|
buttonX = (int)(x + (photoWidth - size) / 2.0f);
|
||||||
buttonY = (int)(AndroidUtilities.dp(7) + (photoHeight - size) / 2.0f);
|
buttonY = (int)(AndroidUtilities.dp(7) + (photoHeight - size) / 2.0f) + namesOffset;
|
||||||
|
|
||||||
radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(48), buttonY + AndroidUtilities.dp(48));
|
radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(48), buttonY + AndroidUtilities.dp(48));
|
||||||
deleteProgressRect.set(buttonX + AndroidUtilities.dp(3), buttonY + AndroidUtilities.dp(3), buttonX + AndroidUtilities.dp(45), buttonY + AndroidUtilities.dp(45));
|
deleteProgressRect.set(buttonX + AndroidUtilities.dp(3), buttonY + AndroidUtilities.dp(3), buttonX + AndroidUtilities.dp(45), buttonY + AndroidUtilities.dp(45));
|
||||||
|
@ -854,7 +864,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
gifDrawable.draw(canvas);
|
gifDrawable.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
} else {
|
} else {
|
||||||
photoImage.setPressed(isPressed() && isCheckPressed || !isCheckPressed && isPressed);
|
photoImage.setPressed(isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted);
|
||||||
photoImage.setVisible(!PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
|
photoImage.setVisible(!PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
|
||||||
imageDrawn = photoImage.draw(canvas);
|
imageDrawn = photoImage.draw(canvas);
|
||||||
drawTime = photoImage.getVisible();
|
drawTime = photoImage.getVisible();
|
||||||
|
@ -874,7 +884,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
menuDrawable = docMenuInDrawable;
|
menuDrawable = docMenuInDrawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
setDrawableBounds(menuDrawable, photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(44), AndroidUtilities.dp(10));
|
setDrawableBounds(menuDrawable, photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(44), AndroidUtilities.dp(10) + namesOffset);
|
||||||
menuDrawable.draw(canvas);
|
menuDrawable.draw(canvas);
|
||||||
|
|
||||||
if (buttonState >= 0 && buttonState < 4) {
|
if (buttonState >= 0 && buttonState < 4) {
|
||||||
|
@ -973,7 +983,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
@Override
|
@Override
|
||||||
public void onSuccessDownload(String fileName) {
|
public void onSuccessDownload(String fileName) {
|
||||||
radialProgress.setProgress(1, true);
|
radialProgress.setProgress(1, true);
|
||||||
if (currentMessageObject.type == 8 && lastDownloadedGifMessage != null && lastDownloadedGifMessage.messageOwner.id == currentMessageObject.messageOwner.id) {
|
if (currentMessageObject.type == 8 && lastDownloadedGifMessage != null && lastDownloadedGifMessage.getId() == currentMessageObject.getId()) {
|
||||||
buttonState = 2;
|
buttonState = 2;
|
||||||
didPressedButton(true);
|
didPressedButton(true);
|
||||||
} else if (!photoNotSet) {
|
} else if (!photoNotSet) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.view.MotionEvent;
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.android.MessageObject;
|
import org.telegram.android.MessageObject;
|
||||||
|
import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||||
|
|
||||||
public class ChatMessageCell extends ChatBaseCell {
|
public class ChatMessageCell extends ChatBaseCell {
|
||||||
|
|
||||||
|
@ -62,7 +63,16 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||||
} else {
|
} else {
|
||||||
if (link[0] == pressedLink) {
|
if (link[0] == pressedLink) {
|
||||||
try {
|
try {
|
||||||
pressedLink.onClick(this);
|
if (pressedLink instanceof URLSpanNoUnderline) {
|
||||||
|
String url = ((URLSpanNoUnderline) pressedLink).getURL();
|
||||||
|
if (url.startsWith("@") || url.startsWith("#")) {
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.didPressUrl(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pressedLink.onClick(this);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
}
|
}
|
||||||
|
@ -164,6 +174,8 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||||
|
|
||||||
int maxChildWidth = Math.max(backgroundWidth, nameWidth);
|
int maxChildWidth = Math.max(backgroundWidth, nameWidth);
|
||||||
maxChildWidth = Math.max(maxChildWidth, forwardedNameWidth);
|
maxChildWidth = Math.max(maxChildWidth, forwardedNameWidth);
|
||||||
|
maxChildWidth = Math.max(maxChildWidth, replyNameWidth);
|
||||||
|
maxChildWidth = Math.max(maxChildWidth, replyTextWidth);
|
||||||
|
|
||||||
int timeMore = timeWidth + AndroidUtilities.dp(6);
|
int timeMore = timeWidth + AndroidUtilities.dp(6);
|
||||||
if (messageObject.isOut()) {
|
if (messageObject.isOut()) {
|
||||||
|
|
|
@ -612,7 +612,7 @@ public class DialogCell extends BaseCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
if (currentDialogId != dialog.id || message != null && message.messageOwner.id != dialog.top_message || unreadCount != dialog.unread_count) {
|
if (currentDialogId != dialog.id || message != null && message.getId() != dialog.top_message || unreadCount != dialog.unread_count) {
|
||||||
currentDialogId = dialog.id;
|
currentDialogId = dialog.id;
|
||||||
update(0);
|
update(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* 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.ui.Cells;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.android.ContactsController;
|
||||||
|
import org.telegram.messenger.TLRPC;
|
||||||
|
import org.telegram.ui.Components.AvatarDrawable;
|
||||||
|
import org.telegram.ui.Components.BackupImageView;
|
||||||
|
|
||||||
|
public class MentionCell extends LinearLayout {
|
||||||
|
|
||||||
|
private BackupImageView imageView;
|
||||||
|
private TextView nameTextView;
|
||||||
|
private TextView usernameTextView;
|
||||||
|
private AvatarDrawable avatarDrawable;
|
||||||
|
|
||||||
|
public MentionCell(Context context) {
|
||||||
|
super(context);
|
||||||
|
|
||||||
|
setOrientation(HORIZONTAL);
|
||||||
|
|
||||||
|
avatarDrawable = new AvatarDrawable();
|
||||||
|
avatarDrawable.setSmallStyle(true);
|
||||||
|
|
||||||
|
imageView = new BackupImageView(context);
|
||||||
|
imageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(14));
|
||||||
|
addView(imageView);
|
||||||
|
LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(12);
|
||||||
|
layoutParams.topMargin = AndroidUtilities.dp(4);
|
||||||
|
layoutParams.width = AndroidUtilities.dp(28);
|
||||||
|
layoutParams.height = AndroidUtilities.dp(28);
|
||||||
|
imageView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
nameTextView = new TextView(context);
|
||||||
|
nameTextView.setTextColor(0xff000000);
|
||||||
|
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||||
|
nameTextView.setSingleLine(true);
|
||||||
|
nameTextView.setGravity(Gravity.LEFT);
|
||||||
|
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
addView(nameTextView);
|
||||||
|
layoutParams = (LayoutParams) nameTextView.getLayoutParams();
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(12);
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
nameTextView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
usernameTextView = new TextView(context);
|
||||||
|
usernameTextView.setTextColor(0xff999999);
|
||||||
|
usernameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||||
|
usernameTextView.setSingleLine(true);
|
||||||
|
usernameTextView.setGravity(Gravity.LEFT);
|
||||||
|
usernameTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||||
|
addView(usernameTextView);
|
||||||
|
layoutParams = (LayoutParams) usernameTextView.getLayoutParams();
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(12);
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
usernameTextView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(36), MeasureSpec.EXACTLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(TLRPC.User user) {
|
||||||
|
if (user == null) {
|
||||||
|
nameTextView.setText("");
|
||||||
|
usernameTextView.setText("");
|
||||||
|
imageView.setImageDrawable(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
avatarDrawable.setInfo(user);
|
||||||
|
if (user.photo != null && user.photo.photo_small != null) {
|
||||||
|
imageView.setImage(user.photo.photo_small, "50_50", avatarDrawable);
|
||||||
|
} else {
|
||||||
|
imageView.setImageDrawable(avatarDrawable);
|
||||||
|
}
|
||||||
|
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||||
|
usernameTextView.setText("@" + user.username);
|
||||||
|
}
|
||||||
|
}
|
|
@ -83,4 +83,10 @@ public class PhotoEditToolCell extends FrameLayoutFixed {
|
||||||
valueTextView.setText("" + (int) value);
|
valueTextView.setText("" + (int) value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIconAndTextAndValue(int resId, String text, String value) {
|
||||||
|
iconImage.setImageResource(resId);
|
||||||
|
nameTextView.setText(text.toUpperCase());
|
||||||
|
valueTextView.setText(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -27,8 +26,8 @@ import org.telegram.ui.Components.FrameLayoutFixed;
|
||||||
|
|
||||||
public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
|
public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
|
||||||
|
|
||||||
public static interface PhotoPickerAlbumsCellDelegate {
|
public interface PhotoPickerAlbumsCellDelegate {
|
||||||
public abstract void didSelectAlbum(MediaController.AlbumEntry albumEntry);
|
void didSelectAlbum(MediaController.AlbumEntry albumEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AlbumView[] albumViews;
|
private AlbumView[] albumViews;
|
||||||
|
@ -180,11 +179,6 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
|
||||||
albumViews[a].setLayoutParams(layoutParams);
|
albumViews[a].setLayoutParams(layoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(4) + itemWidth, MeasureSpec.EXACTLY));
|
||||||
if (layoutParams != null) {
|
|
||||||
layoutParams.height = AndroidUtilities.dp(4) + itemWidth;
|
|
||||||
setLayoutParams(layoutParams);
|
|
||||||
}
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.telegram.messenger.R;
|
||||||
|
|
||||||
public class PhotoPickerSearchCell extends LinearLayout {
|
public class PhotoPickerSearchCell extends LinearLayout {
|
||||||
|
|
||||||
public static interface PhotoPickerSearchCellDelegate {
|
public interface PhotoPickerSearchCellDelegate {
|
||||||
public abstract void didPressedSearchButton(int index);
|
void didPressedSearchButton(int index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SearchButton extends FrameLayout {
|
private class SearchButton extends FrameLayout {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -39,9 +38,9 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
|
||||||
private int itemsCount;
|
private int itemsCount;
|
||||||
private boolean isFirst;
|
private boolean isFirst;
|
||||||
|
|
||||||
public static interface SharedPhotoVideoCellDelegate {
|
public interface SharedPhotoVideoCellDelegate {
|
||||||
public abstract void didClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
void didClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
||||||
public abstract boolean didLongClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
boolean didLongClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PhotoVideoView extends FrameLayoutFixed {
|
private class PhotoVideoView extends FrameLayoutFixed {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,6 +31,7 @@ public class AvatarDrawable extends Drawable {
|
||||||
|
|
||||||
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
private static TextPaint namePaint;
|
private static TextPaint namePaint;
|
||||||
|
private static TextPaint namePaintSmall;
|
||||||
private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xffeec764, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a};
|
private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xffeec764, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a};
|
||||||
private static int[] arrColorsProfiles = {0xffd86f65, 0xfff69d61, 0xfffabb3c, 0xff67b35d, 0xff56a2bb, 0xff5c98cd, 0xff8c79d2, 0xfff37fa6};
|
private static int[] arrColorsProfiles = {0xffd86f65, 0xfff69d61, 0xfffabb3c, 0xff67b35d, 0xff56a2bb, 0xff5c98cd, 0xff8c79d2, 0xfff37fa6};
|
||||||
private static int[] arrColorsProfilesBack = {0xffca6056, 0xfff18944, 0xff7d6ac4, 0xff56a14c, 0xff4492ac, 0xff4c84b6, 0xff7d6ac4, 0xff4c84b6};
|
private static int[] arrColorsProfilesBack = {0xffca6056, 0xfff18944, 0xff7d6ac4, 0xff56a14c, 0xff4492ac, 0xff4c84b6, 0xff7d6ac4, 0xff4c84b6};
|
||||||
|
@ -39,8 +40,6 @@ public class AvatarDrawable extends Drawable {
|
||||||
private static int[] arrColorsButtons = {R.drawable.bar_selector_red, R.drawable.bar_selector_orange, R.drawable.bar_selector_violet,
|
private static int[] arrColorsButtons = {R.drawable.bar_selector_red, R.drawable.bar_selector_orange, R.drawable.bar_selector_violet,
|
||||||
R.drawable.bar_selector_green, R.drawable.bar_selector_cyan, R.drawable.bar_selector_blue, R.drawable.bar_selector_violet, R.drawable.bar_selector_blue};
|
R.drawable.bar_selector_green, R.drawable.bar_selector_cyan, R.drawable.bar_selector_blue, R.drawable.bar_selector_violet, R.drawable.bar_selector_blue};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static Drawable broadcastDrawable;
|
private static Drawable broadcastDrawable;
|
||||||
private static Drawable photoDrawable;
|
private static Drawable photoDrawable;
|
||||||
|
|
||||||
|
@ -52,6 +51,7 @@ public class AvatarDrawable extends Drawable {
|
||||||
private boolean isProfile;
|
private boolean isProfile;
|
||||||
private boolean drawBrodcast;
|
private boolean drawBrodcast;
|
||||||
private boolean drawPhoto;
|
private boolean drawPhoto;
|
||||||
|
private boolean smallStyle;
|
||||||
|
|
||||||
public AvatarDrawable() {
|
public AvatarDrawable() {
|
||||||
super();
|
super();
|
||||||
|
@ -61,6 +61,10 @@ public class AvatarDrawable extends Drawable {
|
||||||
namePaint.setColor(0xffffffff);
|
namePaint.setColor(0xffffffff);
|
||||||
namePaint.setTextSize(AndroidUtilities.dp(20));
|
namePaint.setTextSize(AndroidUtilities.dp(20));
|
||||||
|
|
||||||
|
namePaintSmall = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
namePaintSmall.setColor(0xffffffff);
|
||||||
|
namePaintSmall.setTextSize(AndroidUtilities.dp(14));
|
||||||
|
|
||||||
broadcastDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.broadcast_w);
|
broadcastDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.broadcast_w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,6 +93,10 @@ public class AvatarDrawable extends Drawable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSmallStyle(boolean value) {
|
||||||
|
smallStyle = value;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getColorIndex(int id) {
|
public static int getColorIndex(int id) {
|
||||||
if (id >= 0 && id < 8) {
|
if (id >= 0 && id < 8) {
|
||||||
return id;
|
return id;
|
||||||
|
@ -205,7 +213,7 @@ public class AvatarDrawable extends Drawable {
|
||||||
if (text.length() > 0) {
|
if (text.length() > 0) {
|
||||||
text = text.toUpperCase();
|
text = text.toUpperCase();
|
||||||
try {
|
try {
|
||||||
textLayout = new StaticLayout(text, namePaint, AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
textLayout = new StaticLayout(text, (smallStyle ? namePaintSmall : namePaint), AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
if (textLayout.getLineCount() > 0) {
|
if (textLayout.getLineCount() > 0) {
|
||||||
textLeft = textLayout.getLineLeft(0);
|
textLeft = textLayout.getLineLeft(0);
|
||||||
textWidth = textLayout.getLineWidth(0);
|
textWidth = textLayout.getLineWidth(0);
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||||
private boolean clearAfterUpdate = false;
|
private boolean clearAfterUpdate = false;
|
||||||
public boolean returnOnly = false;
|
public boolean returnOnly = false;
|
||||||
|
|
||||||
public static abstract interface AvatarUpdaterDelegate {
|
public interface AvatarUpdaterDelegate {
|
||||||
public abstract void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big);
|
void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
@ -76,18 +76,13 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||||
PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true);
|
PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true);
|
||||||
fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() {
|
fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void didSelectPhotos(ArrayList<String> photos) {
|
public void didSelectPhotos(ArrayList<String> photos, ArrayList<MediaController.SearchImage> webPhotos) {
|
||||||
if (!photos.isEmpty()) {
|
if (!photos.isEmpty()) {
|
||||||
Bitmap bitmap = ImageLoader.loadBitmap(photos.get(0), null, 800, 800, true);
|
Bitmap bitmap = ImageLoader.loadBitmap(photos.get(0), null, 800, 800, true);
|
||||||
processBitmap(bitmap);
|
processBitmap(bitmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void didSelectWebPhotos(ArrayList<MediaController.SearchImage> photos) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startPhotoSelectActivity() {
|
public void startPhotoSelectActivity() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -11,7 +11,6 @@ package org.telegram.ui.Components;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
@ -33,12 +32,14 @@ import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.Emoji;
|
import org.telegram.android.Emoji;
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
import org.telegram.android.MediaController;
|
import org.telegram.android.MediaController;
|
||||||
|
import org.telegram.android.MessageObject;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.android.SendMessagesHelper;
|
import org.telegram.android.SendMessagesHelper;
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
|
@ -56,15 +57,15 @@ import org.telegram.messenger.ApplicationLoader;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class ChatActivityEnterView extends LinearLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate {
|
public class ChatActivityEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate {
|
||||||
|
|
||||||
public static interface ChatActivityEnterViewDelegate {
|
public interface ChatActivityEnterViewDelegate {
|
||||||
public abstract void onMessageSend();
|
void onMessageSend();
|
||||||
public abstract void needSendTyping();
|
void needSendTyping();
|
||||||
public abstract void onTextChanged(CharSequence text);
|
void onTextChanged(CharSequence text);
|
||||||
public abstract void onAttachButtonHidden();
|
void onAttachButtonHidden();
|
||||||
public abstract void onAttachButtonShow();
|
void onAttachButtonShow();
|
||||||
public abstract void onWindowSizeChanged(int size);
|
void onWindowSizeChanged(int size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EditText messsageEditText;
|
private EditText messsageEditText;
|
||||||
|
@ -78,6 +79,8 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
private LinearLayout slideText;
|
private LinearLayout slideText;
|
||||||
private SizeNotifierRelativeLayout sizeNotifierRelativeLayout;
|
private SizeNotifierRelativeLayout sizeNotifierRelativeLayout;
|
||||||
private FrameLayout attachButton;
|
private FrameLayout attachButton;
|
||||||
|
private LinearLayout textFieldContainer;
|
||||||
|
private View topView;
|
||||||
|
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
private AnimatorSetProxy runningAnimation;
|
private AnimatorSetProxy runningAnimation;
|
||||||
|
@ -95,16 +98,21 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
private float startedDraggingX = -1;
|
private float startedDraggingX = -1;
|
||||||
private float distCanMove = AndroidUtilities.dp(80);
|
private float distCanMove = AndroidUtilities.dp(80);
|
||||||
private boolean recordingAudio;
|
private boolean recordingAudio;
|
||||||
|
private boolean forceShowSendButton;
|
||||||
|
|
||||||
private Activity parentActivity;
|
private Activity parentActivity;
|
||||||
private BaseFragment parentFragment;
|
private BaseFragment parentFragment;
|
||||||
private long dialog_id;
|
private long dialog_id;
|
||||||
private boolean ignoreTextChange;
|
private boolean ignoreTextChange;
|
||||||
|
private MessageObject replyingMessageObject;
|
||||||
private ChatActivityEnterViewDelegate delegate;
|
private ChatActivityEnterViewDelegate delegate;
|
||||||
|
|
||||||
|
private float topViewAnimation;
|
||||||
|
private boolean needShowTopView;
|
||||||
|
private boolean allowShowTopView;
|
||||||
|
|
||||||
public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, BaseFragment fragment, boolean isChat) {
|
public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, BaseFragment fragment, boolean isChat) {
|
||||||
super(context);
|
super(context);
|
||||||
setOrientation(HORIZONTAL);
|
|
||||||
setBackgroundResource(R.drawable.compose_panel);
|
setBackgroundResource(R.drawable.compose_panel);
|
||||||
setFocusable(true);
|
setFocusable(true);
|
||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
|
@ -125,9 +133,20 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||||
sendByEnter = preferences.getBoolean("send_by_enter", false);
|
sendByEnter = preferences.getBoolean("send_by_enter", false);
|
||||||
|
|
||||||
|
textFieldContainer = new LinearLayout(context);
|
||||||
|
textFieldContainer.setBackgroundColor(0xffffffff);
|
||||||
|
textFieldContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
addView(textFieldContainer);
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.gravity = Gravity.LEFT | Gravity.TOP;
|
||||||
|
layoutParams2.width = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams2.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2);
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
|
||||||
FrameLayoutFixed frameLayout = new FrameLayoutFixed(context);
|
FrameLayoutFixed frameLayout = new FrameLayoutFixed(context);
|
||||||
addView(frameLayout);
|
textFieldContainer.addView(frameLayout);
|
||||||
LayoutParams layoutParams = (LayoutParams) frameLayout.getLayoutParams();
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
||||||
layoutParams.width = 0;
|
layoutParams.width = 0;
|
||||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.weight = 1;
|
layoutParams.weight = 1;
|
||||||
|
@ -142,7 +161,6 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
layoutParams1.width = AndroidUtilities.dp(48);
|
layoutParams1.width = AndroidUtilities.dp(48);
|
||||||
layoutParams1.height = AndroidUtilities.dp(48);
|
layoutParams1.height = AndroidUtilities.dp(48);
|
||||||
layoutParams1.gravity = Gravity.BOTTOM;
|
layoutParams1.gravity = Gravity.BOTTOM;
|
||||||
layoutParams1.topMargin = AndroidUtilities.dp(2);
|
|
||||||
emojiButton.setLayoutParams(layoutParams1);
|
emojiButton.setLayoutParams(layoutParams1);
|
||||||
emojiButton.setOnClickListener(new View.OnClickListener() {
|
emojiButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -269,7 +287,6 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
layoutParams1.width = AndroidUtilities.dp(48);
|
layoutParams1.width = AndroidUtilities.dp(48);
|
||||||
layoutParams1.height = AndroidUtilities.dp(48);
|
layoutParams1.height = AndroidUtilities.dp(48);
|
||||||
layoutParams1.gravity = Gravity.BOTTOM | Gravity.RIGHT;
|
layoutParams1.gravity = Gravity.BOTTOM | Gravity.RIGHT;
|
||||||
layoutParams1.topMargin = AndroidUtilities.dp(2);
|
|
||||||
attachButton.setLayoutParams(layoutParams1);
|
attachButton.setLayoutParams(layoutParams1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,11 +298,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
layoutParams1.height = AndroidUtilities.dp(48);
|
layoutParams1.height = AndroidUtilities.dp(48);
|
||||||
layoutParams1.gravity = Gravity.BOTTOM;
|
layoutParams1.gravity = Gravity.BOTTOM;
|
||||||
layoutParams1.topMargin = AndroidUtilities.dp(2);
|
|
||||||
recordPanel.setLayoutParams(layoutParams1);
|
recordPanel.setLayoutParams(layoutParams1);
|
||||||
|
|
||||||
slideText = new LinearLayout(context);
|
slideText = new LinearLayout(context);
|
||||||
slideText.setOrientation(HORIZONTAL);
|
slideText.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
recordPanel.addView(slideText);
|
recordPanel.addView(slideText);
|
||||||
layoutParams1 = (FrameLayout.LayoutParams) slideText.getLayoutParams();
|
layoutParams1 = (FrameLayout.LayoutParams) slideText.getLayoutParams();
|
||||||
layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
@ -297,7 +313,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
ImageView imageView = new ImageView(context);
|
ImageView imageView = new ImageView(context);
|
||||||
imageView.setImageResource(R.drawable.slidearrow);
|
imageView.setImageResource(R.drawable.slidearrow);
|
||||||
slideText.addView(imageView);
|
slideText.addView(imageView);
|
||||||
layoutParams = (LayoutParams) imageView.getLayoutParams();
|
layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams();
|
||||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
@ -309,7 +325,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
textView.setTextColor(0xff999999);
|
textView.setTextColor(0xff999999);
|
||||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
||||||
slideText.addView(textView);
|
slideText.addView(textView);
|
||||||
layoutParams = (LayoutParams) textView.getLayoutParams();
|
layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
|
||||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
@ -317,7 +333,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
textView.setLayoutParams(layoutParams);
|
textView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
LinearLayout linearLayout = new LinearLayout(context);
|
LinearLayout linearLayout = new LinearLayout(context);
|
||||||
linearLayout.setOrientation(HORIZONTAL);
|
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
linearLayout.setPadding(AndroidUtilities.dp(13), 0, 0, 0);
|
linearLayout.setPadding(AndroidUtilities.dp(13), 0, 0, 0);
|
||||||
linearLayout.setBackgroundColor(0xffffffff);
|
linearLayout.setBackgroundColor(0xffffffff);
|
||||||
recordPanel.addView(linearLayout);
|
recordPanel.addView(linearLayout);
|
||||||
|
@ -330,7 +346,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
imageView = new ImageView(context);
|
imageView = new ImageView(context);
|
||||||
imageView.setImageResource(R.drawable.rec);
|
imageView.setImageResource(R.drawable.rec);
|
||||||
linearLayout.addView(imageView);
|
linearLayout.addView(imageView);
|
||||||
layoutParams = (LayoutParams) imageView.getLayoutParams();
|
layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams();
|
||||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
@ -342,7 +358,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
recordTimeText.setTextColor(0xff4d4c4b);
|
recordTimeText.setTextColor(0xff4d4c4b);
|
||||||
recordTimeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
recordTimeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||||
linearLayout.addView(recordTimeText);
|
linearLayout.addView(recordTimeText);
|
||||||
layoutParams = (LayoutParams) recordTimeText.getLayoutParams();
|
layoutParams = (LinearLayout.LayoutParams) recordTimeText.getLayoutParams();
|
||||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||||
|
@ -350,12 +366,11 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
recordTimeText.setLayoutParams(layoutParams);
|
recordTimeText.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
FrameLayout frameLayout1 = new FrameLayout(context);
|
FrameLayout frameLayout1 = new FrameLayout(context);
|
||||||
addView(frameLayout1);
|
textFieldContainer.addView(frameLayout1);
|
||||||
layoutParams = (LayoutParams) frameLayout1.getLayoutParams();
|
layoutParams = (LinearLayout.LayoutParams) frameLayout1.getLayoutParams();
|
||||||
layoutParams.width = AndroidUtilities.dp(48);
|
layoutParams.width = AndroidUtilities.dp(48);
|
||||||
layoutParams.height = AndroidUtilities.dp(48);
|
layoutParams.height = AndroidUtilities.dp(48);
|
||||||
layoutParams.gravity = Gravity.BOTTOM;
|
layoutParams.gravity = Gravity.BOTTOM;
|
||||||
layoutParams.topMargin = AndroidUtilities.dp(2);
|
|
||||||
frameLayout1.setLayoutParams(layoutParams);
|
frameLayout1.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
audioSendButton = new ImageView(context);
|
audioSendButton = new ImageView(context);
|
||||||
|
@ -390,7 +405,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startedDraggingX = -1;
|
startedDraggingX = -1;
|
||||||
MediaController.getInstance().startRecording(dialog_id);
|
MediaController.getInstance().startRecording(dialog_id, replyingMessageObject);
|
||||||
updateAudioRecordIntefrace();
|
updateAudioRecordIntefrace();
|
||||||
audioSendButton.getParent().requestDisallowInterceptTouchEvent(true);
|
audioSendButton.getParent().requestDisallowInterceptTouchEvent(true);
|
||||||
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
|
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||||
|
@ -466,6 +481,135 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
checkSendButton(false);
|
checkSendButton(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addTopView(View view, int height) {
|
||||||
|
if (view == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addView(view, 0);
|
||||||
|
topView = view;
|
||||||
|
topView.setVisibility(GONE);
|
||||||
|
needShowTopView = false;
|
||||||
|
LayoutParams layoutParams = (LayoutParams) topView.getLayoutParams();
|
||||||
|
layoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = height;
|
||||||
|
layoutParams.topMargin = AndroidUtilities.dp(2);
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
|
topView.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTopViewAnimation(float progress) {
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2) + (int) (topView.getLayoutParams().height * progress);
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTopViewAnimation() {
|
||||||
|
return topViewAnimation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForceShowSendButton(boolean value, boolean animated) {
|
||||||
|
forceShowSendButton = value;
|
||||||
|
checkSendButton(animated);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showTopView(boolean animated) {
|
||||||
|
if (topView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
needShowTopView = true;
|
||||||
|
if (allowShowTopView) {
|
||||||
|
topView.setVisibility(VISIBLE);
|
||||||
|
if (animated) {
|
||||||
|
AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
|
||||||
|
animatorSetProxy.playTogether(
|
||||||
|
ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 0.0f, 1.0f)
|
||||||
|
);
|
||||||
|
animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Object animation) {
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
if (!forceShowSendButton) {
|
||||||
|
openKeyboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
animatorSetProxy.setDuration(200);
|
||||||
|
animatorSetProxy.start();
|
||||||
|
} else {
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideTopView(boolean animated) {
|
||||||
|
if (topView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
needShowTopView = false;
|
||||||
|
if (allowShowTopView) {
|
||||||
|
if (animated) {
|
||||||
|
AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
|
||||||
|
animatorSetProxy.playTogether(
|
||||||
|
ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 1.0f, 0.0f)
|
||||||
|
);
|
||||||
|
animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Object animation) {
|
||||||
|
topView.setVisibility(GONE);
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2);
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
animatorSetProxy.setDuration(200);
|
||||||
|
animatorSetProxy.start();
|
||||||
|
} else {
|
||||||
|
topView.setVisibility(GONE);
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2);
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTopViewVisible() {
|
||||||
|
return topView != null && topView.getVisibility() == VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onWindowSizeChanged(int size) {
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.onWindowSizeChanged(size);
|
||||||
|
}
|
||||||
|
if (topView != null) {
|
||||||
|
if (size < AndroidUtilities.dp(72) + AndroidUtilities.getCurrentActionBarHeight()) {
|
||||||
|
if (allowShowTopView) {
|
||||||
|
allowShowTopView = false;
|
||||||
|
if (needShowTopView) {
|
||||||
|
topView.setVisibility(View.GONE);
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2);
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!allowShowTopView) {
|
||||||
|
allowShowTopView = true;
|
||||||
|
if (needShowTopView) {
|
||||||
|
topView.setVisibility(View.VISIBLE);
|
||||||
|
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
|
||||||
|
layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
|
||||||
|
textFieldContainer.setLayoutParams(layoutParams2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recordStarted);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recordStarted);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recordStartError);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recordStartError);
|
||||||
|
@ -493,6 +637,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
dialog_id = id;
|
dialog_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReplyingMessageObject(MessageObject messageObject) {
|
||||||
|
replyingMessageObject = messageObject;
|
||||||
|
}
|
||||||
|
|
||||||
private void sendMessage() {
|
private void sendMessage() {
|
||||||
if (parentFragment != null) {
|
if (parentFragment != null) {
|
||||||
String action = null;
|
String action = null;
|
||||||
|
@ -517,6 +665,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
if (delegate != null) {
|
if (delegate != null) {
|
||||||
delegate.onMessageSend();
|
delegate.onMessageSend();
|
||||||
}
|
}
|
||||||
|
} else if (forceShowSendButton) {
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.onMessageSend();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +678,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
int count = (int) Math.ceil(text.length() / 4096.0f);
|
int count = (int) Math.ceil(text.length() / 4096.0f);
|
||||||
for (int a = 0; a < count; a++) {
|
for (int a = 0; a < count; a++) {
|
||||||
String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length()));
|
String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length()));
|
||||||
SendMessagesHelper.getInstance().sendMessage(mess, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, replyingMessageObject);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -549,7 +701,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
|
|
||||||
private void checkSendButton(final boolean animated) {
|
private void checkSendButton(final boolean animated) {
|
||||||
String message = getTrimmedString(messsageEditText.getText().toString());
|
String message = getTrimmedString(messsageEditText.getText().toString());
|
||||||
if (message.length() > 0) {
|
if (message.length() > 0 || forceShowSendButton) {
|
||||||
if (audioSendButton.getVisibility() == View.VISIBLE) {
|
if (audioSendButton.getVisibility() == View.VISIBLE) {
|
||||||
if (animated) {
|
if (animated) {
|
||||||
if (runningAnimationType == 1) {
|
if (runningAnimationType == 1) {
|
||||||
|
@ -631,7 +783,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
if (attachButton != null) {
|
if (attachButton != null) {
|
||||||
attachButton.setVisibility(View.GONE);
|
attachButton.setVisibility(View.GONE);
|
||||||
attachButton.clearAnimation();
|
attachButton.clearAnimation();
|
||||||
|
delegate.onAttachButtonHidden();
|
||||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
|
||||||
layoutParams.rightMargin = AndroidUtilities.dp(0);
|
layoutParams.rightMargin = AndroidUtilities.dp(0);
|
||||||
messsageEditText.setLayoutParams(layoutParams);
|
messsageEditText.setLayoutParams(layoutParams);
|
||||||
|
@ -710,6 +862,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
sendButton.clearAnimation();
|
sendButton.clearAnimation();
|
||||||
audioSendButton.setVisibility(View.VISIBLE);
|
audioSendButton.setVisibility(View.VISIBLE);
|
||||||
if (attachButton != null) {
|
if (attachButton != null) {
|
||||||
|
delegate.onAttachButtonShow();
|
||||||
attachButton.setVisibility(View.VISIBLE);
|
attachButton.setVisibility(View.VISIBLE);
|
||||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
|
||||||
layoutParams.rightMargin = AndroidUtilities.dp(50);
|
layoutParams.rightMargin = AndroidUtilities.dp(50);
|
||||||
|
@ -825,12 +978,16 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
emojiPopup = new PopupWindow(emojiView);
|
emojiPopup = new PopupWindow(emojiView);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
/*emojiPopup.setAnimationStyle(0);
|
||||||
|
emojiPopup.setClippingEnabled(true);
|
||||||
|
emojiPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||||
|
emojiPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);*/
|
||||||
try {
|
try {
|
||||||
Field field = PopupWindow.class.getDeclaredField("mWindowLayoutType");
|
Field field = PopupWindow.class.getDeclaredField("mWindowLayoutType");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(emojiPopup, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
|
field.set(emojiPopup, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
/* ignored */
|
//ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -853,22 +1010,43 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.EXACTLY));
|
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.EXACTLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), Gravity.BOTTOM | Gravity.LEFT, 0, 0);
|
||||||
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), Gravity.BOTTOM | Gravity.LEFT, 0, 0);
|
|
||||||
} catch (Exception e) {
|
/*if (Build.VERSION.SDK_INT < 21) {
|
||||||
FileLog.e("tmessages", e);
|
try {
|
||||||
return;
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
if (!keyboardVisible) {
|
if (!keyboardVisible) {
|
||||||
|
/*if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
try {
|
||||||
|
emojiPopup.showAsDropDown(this, 0, 0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
if (sizeNotifierRelativeLayout != null) {
|
if (sizeNotifierRelativeLayout != null) {
|
||||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);
|
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);
|
||||||
emojiButton.setImageResource(R.drawable.ic_msg_panel_hide);
|
emojiButton.setImageResource(R.drawable.ic_msg_panel_hide);
|
||||||
if (delegate != null) {
|
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
/*if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
try {
|
||||||
|
emojiPopup.showAsDropDown(this, 0, -currentHeight - getHeight());
|
||||||
|
emojiPopup.update(this, 0, -currentHeight - getHeight(), -1, -1);
|
||||||
|
AndroidUtilities.hideKeyboard(messsageEditText);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
emojiButton.setImageResource(R.drawable.ic_msg_panel_kb);
|
emojiButton.setImageResource(R.drawable.ic_msg_panel_kb);
|
||||||
return;
|
return;
|
||||||
|
@ -888,9 +1066,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
public void run() {
|
public void run() {
|
||||||
if (sizeNotifierRelativeLayout != null) {
|
if (sizeNotifierRelativeLayout != null) {
|
||||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, 0);
|
sizeNotifierRelativeLayout.setPadding(0, 0, 0, 0);
|
||||||
if (delegate != null) {
|
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -903,6 +1079,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openKeyboard() {
|
||||||
|
AndroidUtilities.showKeyboard(messsageEditText);
|
||||||
|
}
|
||||||
|
|
||||||
public void setDelegate(ChatActivityEnterViewDelegate delegate) {
|
public void setDelegate(ChatActivityEnterViewDelegate delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
@ -915,6 +1095,27 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
messsageEditText.setText(text);
|
messsageEditText.setText(text);
|
||||||
messsageEditText.setSelection(messsageEditText.getText().length());
|
messsageEditText.setSelection(messsageEditText.getText().length());
|
||||||
ignoreTextChange = false;
|
ignoreTextChange = false;
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.onTextChanged(messsageEditText.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCursorPosition() {
|
||||||
|
if (messsageEditText == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return messsageEditText.getSelectionStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void replaceWithText(int start, int len, String text) {
|
||||||
|
try {
|
||||||
|
StringBuilder builder = new StringBuilder(messsageEditText.getText());
|
||||||
|
builder.replace(start, start + len, text);
|
||||||
|
messsageEditText.setText(builder);
|
||||||
|
messsageEditText.setSelection(messsageEditText.length());
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFieldFocused(boolean focus) {
|
public void setFieldFocused(boolean focus) {
|
||||||
|
@ -976,9 +1177,6 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSizeChanged(int height) {
|
public void onSizeChanged(int height) {
|
||||||
Rect localRect = new Rect();
|
|
||||||
parentActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
|
|
||||||
|
|
||||||
WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||||
if (wm == null || wm.getDefaultDisplay() == null) {
|
if (wm == null || wm.getDefaultDisplay() == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1004,6 +1202,13 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
}
|
}
|
||||||
final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) emojiPopup.getContentView().getLayoutParams();
|
final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) emojiPopup.getContentView().getLayoutParams();
|
||||||
if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
|
if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
|
||||||
|
/*if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
if (!keyboardVisible) {
|
||||||
|
emojiPopup.update(this, 0, 0, -1, -1);
|
||||||
|
} else {
|
||||||
|
emojiPopup.update(this, 0, -newHeight - getHeight(), -1, -1);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
layoutParams.width = AndroidUtilities.displaySize.x;
|
layoutParams.width = AndroidUtilities.displaySize.x;
|
||||||
layoutParams.height = newHeight;
|
layoutParams.height = newHeight;
|
||||||
wm.updateViewLayout(emojiPopup.getContentView(), layoutParams);
|
wm.updateViewLayout(emojiPopup.getContentView(), layoutParams);
|
||||||
|
@ -1014,9 +1219,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
if (sizeNotifierRelativeLayout != null) {
|
if (sizeNotifierRelativeLayout != null) {
|
||||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, layoutParams.height);
|
sizeNotifierRelativeLayout.setPadding(0, 0, 0, layoutParams.height);
|
||||||
sizeNotifierRelativeLayout.requestLayout();
|
sizeNotifierRelativeLayout.requestLayout();
|
||||||
if (delegate != null) {
|
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1031,9 +1234,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||||
} else if (!keyboardVisible && keyboardVisible != oldValue && emojiPopup != null && emojiPopup.isShowing()) {
|
} else if (!keyboardVisible && keyboardVisible != oldValue && emojiPopup != null && emojiPopup.isShowing()) {
|
||||||
showEmojiPopup(false);
|
showEmojiPopup(false);
|
||||||
}
|
}
|
||||||
if (delegate != null) {
|
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class ClippingImageView extends View {
|
||||||
private RectF bitmapRect;
|
private RectF bitmapRect;
|
||||||
private Matrix shaderMatrix;
|
private Matrix shaderMatrix;
|
||||||
|
|
||||||
public static interface onDrawListener {
|
public interface onDrawListener {
|
||||||
public abstract void onDraw();
|
void onDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClippingImageView(Context context) {
|
public ClippingImageView(Context context) {
|
||||||
|
|
|
@ -89,11 +89,11 @@ public class ColorPickerView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnColorChangedListener {
|
public interface OnColorChangedListener {
|
||||||
public void onColorChanged(int color);
|
void onColorChanged(int color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnColorSelectedListener {
|
public interface OnColorSelectedListener {
|
||||||
public void onColorSelected(int color);
|
void onColorSelected(int color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnColorChangedListener(OnColorChangedListener listener) {
|
public void setOnColorChangedListener(OnColorChangedListener listener) {
|
||||||
|
|
|
@ -299,8 +299,8 @@ public class EmojiView extends LinearLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract interface Listener {
|
public interface Listener {
|
||||||
public abstract void onBackspace();
|
void onBackspace();
|
||||||
public abstract void onEmojiSelected(String paramString);
|
void onEmojiSelected(String paramString);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,8 +20,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
public class ForegroundDetector implements Application.ActivityLifecycleCallbacks {
|
public class ForegroundDetector implements Application.ActivityLifecycleCallbacks {
|
||||||
|
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
public void onBecameForeground();
|
void onBecameForeground();
|
||||||
public void onBecameBackground();
|
void onBecameBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int refs;
|
private int refs;
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
|
||||||
private int mDisplayOffset = 0;
|
private int mDisplayOffset = 0;
|
||||||
protected Scroller mScroller;
|
protected Scroller mScroller;
|
||||||
private GestureDetector mGesture;
|
private GestureDetector mGesture;
|
||||||
private HashMap<Integer, LinkedList<View>> mRemovedViewQueue = new HashMap<Integer, LinkedList<View>>();
|
private HashMap<Integer, LinkedList<View>> mRemovedViewQueue = new HashMap<>();
|
||||||
private OnItemSelectedListener mOnItemSelected;
|
private OnItemSelectedListener mOnItemSelected;
|
||||||
private OnItemClickListener mOnItemClicked;
|
private OnItemClickListener mOnItemClicked;
|
||||||
private OnItemLongClickListener mOnItemLongClicked;
|
private OnItemLongClickListener mOnItemLongClicked;
|
||||||
|
@ -251,7 +251,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
|
||||||
int type = (Integer) child.getTag();
|
int type = (Integer) child.getTag();
|
||||||
LinkedList<View> list = mRemovedViewQueue.get(type);
|
LinkedList<View> list = mRemovedViewQueue.get(type);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new LinkedList<View>();
|
list = new LinkedList<>();
|
||||||
mRemovedViewQueue.put(type, list);
|
mRemovedViewQueue.put(type, list);
|
||||||
}
|
}
|
||||||
list.add(child);
|
list.add(child);
|
||||||
|
@ -266,7 +266,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
|
||||||
int type = (Integer) child.getTag();
|
int type = (Integer) child.getTag();
|
||||||
LinkedList<View> list = mRemovedViewQueue.get(type);
|
LinkedList<View> list = mRemovedViewQueue.get(type);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new LinkedList<View>();
|
list = new LinkedList<>();
|
||||||
mRemovedViewQueue.put(type, list);
|
mRemovedViewQueue.put(type, list);
|
||||||
}
|
}
|
||||||
list.add(child);
|
list.add(child);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
package org.telegram.ui.Components;
|
package org.telegram.ui.Components;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -16,12 +17,13 @@ import android.widget.ListView;
|
||||||
|
|
||||||
public class LayoutListView extends ListView {
|
public class LayoutListView extends ListView {
|
||||||
|
|
||||||
public static interface OnInterceptTouchEventListener {
|
public interface OnInterceptTouchEventListener {
|
||||||
public abstract boolean onInterceptTouchEvent(MotionEvent event);
|
boolean onInterceptTouchEvent(MotionEvent event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OnInterceptTouchEventListener onInterceptTouchEventListener;
|
private OnInterceptTouchEventListener onInterceptTouchEventListener;
|
||||||
private int height = -1;
|
private int height = -1;
|
||||||
|
private int forceTop = Integer.MIN_VALUE;
|
||||||
|
|
||||||
public LayoutListView(Context context) {
|
public LayoutListView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -39,6 +41,10 @@ public class LayoutListView extends ListView {
|
||||||
onInterceptTouchEventListener = listener;
|
onInterceptTouchEventListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setForceTop(int value) {
|
||||||
|
forceTop = value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
if (onInterceptTouchEventListener != null) {
|
if (onInterceptTouchEventListener != null) {
|
||||||
|
@ -47,25 +53,32 @@ public class LayoutListView extends ListView {
|
||||||
return super.onInterceptTouchEvent(ev);
|
return super.onInterceptTouchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("DrawAllocation")
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
View v = getChildAt(getChildCount() - 1);
|
View v = getChildAt(getChildCount() - 1);
|
||||||
|
int scrollTo = getLastVisiblePosition();
|
||||||
if (v != null && height > 0 && changed && ((bottom - top) < height)) {
|
if (v != null && height > 0 && changed && ((bottom - top) < height)) {
|
||||||
int b = height - v.getTop();
|
int lastTop = forceTop == Integer.MIN_VALUE ? (bottom - top) - (height - v.getTop()) - getPaddingTop() : forceTop;
|
||||||
final int scrollTo = getLastVisiblePosition();
|
forceTop = Integer.MIN_VALUE;
|
||||||
|
setSelectionFromTop(scrollTo, lastTop);
|
||||||
super.onLayout(changed, left, top, right, bottom);
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
final int offset = (bottom - top) - b;
|
|
||||||
post(new Runnable() {
|
// post(new Runnable() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
try {
|
// try {
|
||||||
setSelectionFromTop(scrollTo, offset - getPaddingTop());
|
// setSelectionFromTop(scrollTo, lastTop);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
} else {
|
} else {
|
||||||
|
if (forceTop != Integer.MIN_VALUE) {
|
||||||
|
setSelectionFromTop(scrollTo, forceTop);
|
||||||
|
forceTop = Integer.MIN_VALUE;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
super.onLayout(changed, left, top, right, bottom);
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -110,15 +110,15 @@ public class NumberPicker extends LinearLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnScrollListener {
|
public interface OnScrollListener {
|
||||||
public static int SCROLL_STATE_IDLE = 0;
|
int SCROLL_STATE_IDLE = 0;
|
||||||
public static int SCROLL_STATE_TOUCH_SCROLL = 1;
|
int SCROLL_STATE_TOUCH_SCROLL = 1;
|
||||||
public static int SCROLL_STATE_FLING = 2;
|
int SCROLL_STATE_FLING = 2;
|
||||||
|
|
||||||
public void onScrollStateChange(NumberPicker view, int scrollState);
|
void onScrollStateChange(NumberPicker view, int scrollState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Formatter {
|
public interface Formatter {
|
||||||
public String format(int value);
|
String format(int value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.telegram.messenger.R;
|
||||||
public class PagerSlidingTabStrip extends HorizontalScrollView {
|
public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
|
|
||||||
public interface IconTabProvider {
|
public interface IconTabProvider {
|
||||||
public int getPageIconResId(int position);
|
int getPageIconResId(int position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinearLayout.LayoutParams defaultTabLayoutParams;
|
private LinearLayout.LayoutParams defaultTabLayoutParams;
|
||||||
|
|
|
@ -59,8 +59,8 @@ import java.util.Locale;
|
||||||
|
|
||||||
public class PasscodeView extends FrameLayout {
|
public class PasscodeView extends FrameLayout {
|
||||||
|
|
||||||
public static interface PasscodeViewDelegate {
|
public interface PasscodeViewDelegate {
|
||||||
public abstract void didAcceptedPassword();
|
void didAcceptedPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AnimatingTextView extends FrameLayout {
|
private class AnimatingTextView extends FrameLayout {
|
||||||
|
|
|
@ -22,8 +22,8 @@ import org.telegram.messenger.FileLog;
|
||||||
|
|
||||||
public class PhotoCropView extends FrameLayout {
|
public class PhotoCropView extends FrameLayout {
|
||||||
|
|
||||||
public static interface PhotoCropViewDelegate {
|
public interface PhotoCropViewDelegate {
|
||||||
public abstract void needMoveImageTo(float x, float y, float s, boolean animated);
|
void needMoveImageTo(float x, float y, float s, boolean animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean freeformCrop = true;
|
private boolean freeformCrop = true;
|
||||||
|
|
|
@ -28,8 +28,8 @@ public class PhotoEditorSeekBar extends View {
|
||||||
private int maxValue;
|
private int maxValue;
|
||||||
private PhotoEditorSeekBarDelegate delegate;
|
private PhotoEditorSeekBarDelegate delegate;
|
||||||
|
|
||||||
public abstract interface PhotoEditorSeekBarDelegate {
|
public interface PhotoEditorSeekBarDelegate {
|
||||||
public void onProgressChanged();
|
void onProgressChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhotoEditorSeekBar(Context context) {
|
public PhotoEditorSeekBar(Context context) {
|
||||||
|
|
|
@ -0,0 +1,499 @@
|
||||||
|
/*
|
||||||
|
* 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.ui.Components;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
|
||||||
|
public class PhotoFilterBlurControl extends FrameLayout {
|
||||||
|
|
||||||
|
public interface PhotoFilterLinearBlurControlDelegate {
|
||||||
|
void valueChanged(Point centerPoint, float falloff, float size, float angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static float BlurInsetProximity = AndroidUtilities.dp(20);
|
||||||
|
private final static float BlurMinimumFalloff = 0.1f;
|
||||||
|
private final static float BlurMinimumDifference = 0.02f;
|
||||||
|
private final static float BlurViewCenterInset = AndroidUtilities.dp(30.0f);
|
||||||
|
private final static float BlurViewRadiusInset = AndroidUtilities.dp(30.0f);
|
||||||
|
|
||||||
|
private enum BlurViewActiveControl {
|
||||||
|
BlurViewActiveControlNone,
|
||||||
|
BlurViewActiveControlCenter,
|
||||||
|
BlurViewActiveControlInnerRadius,
|
||||||
|
BlurViewActiveControlOuterRadius,
|
||||||
|
BlurViewActiveControlWholeArea,
|
||||||
|
BlurViewActiveControlRotation
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int GestureStateBegan = 1;
|
||||||
|
private final int GestureStateChanged = 2;
|
||||||
|
private final int GestureStateEnded = 3;
|
||||||
|
private final int GestureStateCancelled = 4;
|
||||||
|
private final int GestureStateFailed = 5;
|
||||||
|
|
||||||
|
private BlurViewActiveControl activeControl;
|
||||||
|
private Point startCenterPoint = new Point();
|
||||||
|
private float startDistance;
|
||||||
|
private float startRadius;
|
||||||
|
private Size actualAreaSize = new Size();
|
||||||
|
private Point centerPoint = new Point(0.5f, 0.5f);
|
||||||
|
private float falloff = 0.15f;
|
||||||
|
private float size = 0.35f;
|
||||||
|
private float angle;
|
||||||
|
private RectF arcRect = new RectF();
|
||||||
|
|
||||||
|
private float pointerStartX;
|
||||||
|
private float pointerStartY;
|
||||||
|
private float startPointerDistance;
|
||||||
|
private float pointerScale = 1;
|
||||||
|
private boolean isMoving;
|
||||||
|
private boolean isZooming;
|
||||||
|
private boolean checkForMoving;
|
||||||
|
private boolean checkForZooming;
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
private Paint arcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
|
||||||
|
private PhotoFilterLinearBlurControlDelegate delegate;
|
||||||
|
|
||||||
|
public PhotoFilterBlurControl(Context context) {
|
||||||
|
super(context);
|
||||||
|
setWillNotDraw(false);
|
||||||
|
paint.setColor(0xffffffff);
|
||||||
|
arcPaint.setColor(0xffffffff);
|
||||||
|
arcPaint.setStrokeWidth(AndroidUtilities.dp(2));
|
||||||
|
arcPaint.setStyle(Paint.Style.STROKE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int blurType) {
|
||||||
|
type = blurType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelegate(PhotoFilterLinearBlurControlDelegate delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getDistance(MotionEvent event) {
|
||||||
|
if (event.getPointerCount() != 2) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
float x1 = event.getX(0);
|
||||||
|
float y1 = event.getY(0);
|
||||||
|
float x2 = event.getX(1);
|
||||||
|
float y2 = event.getY(1);
|
||||||
|
return (float) Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private float degreesToRadians(float degrees) {
|
||||||
|
return degrees * (float) Math.PI / 180.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
int action = event.getActionMasked();
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case MotionEvent.ACTION_POINTER_DOWN:
|
||||||
|
case MotionEvent.ACTION_DOWN: {
|
||||||
|
if (event.getPointerCount() == 1) {
|
||||||
|
if (checkForMoving && !isMoving) {
|
||||||
|
float locationX = event.getX();
|
||||||
|
float locationY = event.getY();
|
||||||
|
Point centerPoint = getActualCenterPoint();
|
||||||
|
Point delta = new Point(locationX - centerPoint.x, locationY - centerPoint.y);
|
||||||
|
float radialDistance = (float) Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
||||||
|
float innerRadius = getActualInnerRadius();
|
||||||
|
float outerRadius = getActualOuterRadius();
|
||||||
|
boolean close = Math.abs(outerRadius - innerRadius) < BlurInsetProximity;
|
||||||
|
float innerRadiusOuterInset = close ? 0 : BlurViewRadiusInset;
|
||||||
|
float outerRadiusInnerInset = close ? 0 : BlurViewRadiusInset;
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
float distance = (float) Math.abs(delta.x * Math.cos(degreesToRadians(angle) + Math.PI / 2) + delta.y * Math.sin(degreesToRadians(angle) + Math.PI / 2));
|
||||||
|
if (radialDistance < BlurViewCenterInset) {
|
||||||
|
isMoving = true;
|
||||||
|
} else if (distance > innerRadius - BlurViewRadiusInset && distance < innerRadius + innerRadiusOuterInset) {
|
||||||
|
isMoving = true;
|
||||||
|
} else if (distance > outerRadius - outerRadiusInnerInset && distance < outerRadius + BlurViewRadiusInset) {
|
||||||
|
isMoving = true;
|
||||||
|
} else if ((distance <= innerRadius - BlurViewRadiusInset) || distance >= outerRadius + BlurViewRadiusInset) {
|
||||||
|
isMoving = true;
|
||||||
|
}
|
||||||
|
} else if (type == 1) {
|
||||||
|
if (radialDistance < BlurViewCenterInset) {
|
||||||
|
isMoving = true;
|
||||||
|
} else if (radialDistance > innerRadius - BlurViewRadiusInset && radialDistance < innerRadius + innerRadiusOuterInset) {
|
||||||
|
isMoving = true;
|
||||||
|
} else if (radialDistance > outerRadius - outerRadiusInnerInset && radialDistance < outerRadius + BlurViewRadiusInset) {
|
||||||
|
isMoving = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkForMoving = false;
|
||||||
|
if (isMoving) {
|
||||||
|
handlePan(GestureStateBegan, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isMoving) {
|
||||||
|
handlePan(GestureStateEnded, event);
|
||||||
|
checkForMoving = true;
|
||||||
|
isMoving = false;
|
||||||
|
}
|
||||||
|
if (event.getPointerCount() == 2) {
|
||||||
|
if (checkForZooming && !isZooming) {
|
||||||
|
handlePinch(GestureStateBegan, event);
|
||||||
|
isZooming = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handlePinch(GestureStateEnded, event);
|
||||||
|
checkForZooming = true;
|
||||||
|
isZooming = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MotionEvent.ACTION_POINTER_UP:
|
||||||
|
case MotionEvent.ACTION_CANCEL:
|
||||||
|
case MotionEvent.ACTION_UP: {
|
||||||
|
if (isMoving) {
|
||||||
|
handlePan(GestureStateEnded, event);
|
||||||
|
isMoving = false;
|
||||||
|
} else if (isZooming) {
|
||||||
|
handlePinch(GestureStateEnded, event);
|
||||||
|
isZooming = false;
|
||||||
|
}
|
||||||
|
checkForMoving = true;
|
||||||
|
checkForZooming = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MotionEvent.ACTION_MOVE: {
|
||||||
|
if (isMoving) {
|
||||||
|
handlePan(GestureStateChanged, event);
|
||||||
|
} else if (isZooming) {
|
||||||
|
handlePinch(GestureStateChanged, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handlePan(int state, MotionEvent event) {
|
||||||
|
float locationX = event.getX();
|
||||||
|
float locationY = event.getY();
|
||||||
|
Point actualCenterPoint = getActualCenterPoint();
|
||||||
|
Point delta = new Point(locationX - actualCenterPoint.x, locationY - actualCenterPoint.y);
|
||||||
|
float radialDistance = (float) Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
||||||
|
float shorterSide = (actualAreaSize.width > actualAreaSize.height) ? actualAreaSize.height : actualAreaSize.width;
|
||||||
|
float innerRadius = shorterSide * falloff;
|
||||||
|
float outerRadius = shorterSide * size;
|
||||||
|
float distance = (float) Math.abs(delta.x * Math.cos(degreesToRadians(angle) + Math.PI / 2.0f) + delta.y * Math.sin(degreesToRadians(angle) + Math.PI / 2.0f));
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case GestureStateBegan: {
|
||||||
|
pointerStartX = event.getX();
|
||||||
|
pointerStartY = event.getY();
|
||||||
|
|
||||||
|
boolean close = Math.abs(outerRadius - innerRadius) < BlurInsetProximity;
|
||||||
|
float innerRadiusOuterInset = close ? 0 : BlurViewRadiusInset;
|
||||||
|
float outerRadiusInnerInset = close ? 0 : BlurViewRadiusInset;
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
if (radialDistance < BlurViewCenterInset) {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlCenter;
|
||||||
|
startCenterPoint = actualCenterPoint;
|
||||||
|
} else if (distance > innerRadius - BlurViewRadiusInset && distance < innerRadius + innerRadiusOuterInset) {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlInnerRadius;
|
||||||
|
startDistance = distance;
|
||||||
|
startRadius = innerRadius;
|
||||||
|
} else if (distance > outerRadius - outerRadiusInnerInset && distance < outerRadius + BlurViewRadiusInset) {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlOuterRadius;
|
||||||
|
startDistance = distance;
|
||||||
|
startRadius = outerRadius;
|
||||||
|
} else if (distance <= innerRadius - BlurViewRadiusInset || distance >= outerRadius + BlurViewRadiusInset) {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlRotation;
|
||||||
|
}
|
||||||
|
} else if (type == 1) {
|
||||||
|
if (radialDistance < BlurViewCenterInset) {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlCenter;
|
||||||
|
startCenterPoint = actualCenterPoint;
|
||||||
|
} else if (radialDistance > innerRadius - BlurViewRadiusInset && radialDistance < innerRadius + innerRadiusOuterInset) {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlInnerRadius;
|
||||||
|
startDistance = radialDistance;
|
||||||
|
startRadius = innerRadius;
|
||||||
|
} else if (radialDistance > outerRadius - outerRadiusInnerInset && radialDistance < outerRadius + BlurViewRadiusInset) {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlOuterRadius;
|
||||||
|
startDistance = radialDistance;
|
||||||
|
startRadius = outerRadius;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSelected(true, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GestureStateChanged: {
|
||||||
|
if (type == 0) {
|
||||||
|
switch (activeControl) {
|
||||||
|
case BlurViewActiveControlCenter: {
|
||||||
|
float translationX = locationX - pointerStartX;
|
||||||
|
float translationY = locationY - pointerStartY;
|
||||||
|
Rect actualArea = new Rect((getWidth() - actualAreaSize.width) / 2, (getHeight() - actualAreaSize.height) / 2, actualAreaSize.width, actualAreaSize.height);
|
||||||
|
Point newPoint = new Point(Math.max(actualArea.x, Math.min(actualArea.x + actualArea.width, startCenterPoint.x + translationX)), Math.max(actualArea.y, Math.min(actualArea.y + actualArea.height, startCenterPoint.y + translationY)));
|
||||||
|
centerPoint = new Point((newPoint.x - actualArea.x) / actualAreaSize.width, ((newPoint.y - actualArea.y) + (actualAreaSize.width - actualAreaSize.height) / 2) / actualAreaSize.width);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlurViewActiveControlInnerRadius: {
|
||||||
|
float d = distance - startDistance;
|
||||||
|
falloff = Math.min(Math.max(BlurMinimumFalloff, (startRadius + d) / shorterSide), size - BlurMinimumDifference);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlurViewActiveControlOuterRadius: {
|
||||||
|
float d = distance - startDistance;
|
||||||
|
size = Math.max(falloff + BlurMinimumDifference, (startRadius + d) / shorterSide);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlurViewActiveControlRotation: {
|
||||||
|
float translationX = locationX - pointerStartX;
|
||||||
|
float translationY = locationY - pointerStartY;
|
||||||
|
|
||||||
|
boolean clockwise = false;
|
||||||
|
|
||||||
|
boolean right = locationX > actualCenterPoint.x;
|
||||||
|
boolean bottom = locationY > actualCenterPoint.y;
|
||||||
|
|
||||||
|
if (!right && !bottom) {
|
||||||
|
if (Math.abs(translationY) > Math.abs(translationX)) {
|
||||||
|
if (translationY < 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (translationX > 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (right && !bottom) {
|
||||||
|
if (Math.abs(translationY) > Math.abs(translationX)) {
|
||||||
|
if (translationY > 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (translationX > 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (right && bottom) {
|
||||||
|
if (Math.abs(translationY) > Math.abs(translationX)) {
|
||||||
|
if (translationY > 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (translationX < 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Math.abs(translationY) > Math.abs(translationX)) {
|
||||||
|
if (translationY < 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (translationX < 0) {
|
||||||
|
clockwise = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float d = (float) Math.sqrt(translationX * translationX + translationY * translationY);
|
||||||
|
angle += d * ((clockwise ? 1 : 0) * 2 - 1) / (float) Math.PI / 1.15f;
|
||||||
|
|
||||||
|
pointerStartX = locationX;
|
||||||
|
pointerStartY = locationY;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (type == 1) {
|
||||||
|
switch (activeControl) {
|
||||||
|
case BlurViewActiveControlCenter: {
|
||||||
|
float translationX = locationX - pointerStartX;
|
||||||
|
float translationY = locationY - pointerStartY;
|
||||||
|
Rect actualArea = new Rect((getWidth() - actualAreaSize.width) / 2, (getHeight() - actualAreaSize.height) / 2, actualAreaSize.width, actualAreaSize.height);
|
||||||
|
Point newPoint = new Point(Math.max(actualArea.x, Math.min(actualArea.x + actualArea.width, startCenterPoint.x + translationX)), Math.max(actualArea.y, Math.min(actualArea.y + actualArea.height, startCenterPoint.y + translationY)));
|
||||||
|
centerPoint = new Point((newPoint.x - actualArea.x) / actualAreaSize.width, ((newPoint.y - actualArea.y) + (actualAreaSize.width - actualAreaSize.height) / 2) / actualAreaSize.width);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlurViewActiveControlInnerRadius: {
|
||||||
|
float d = radialDistance - startDistance;
|
||||||
|
falloff = Math.min(Math.max(BlurMinimumFalloff, (startRadius + d) / shorterSide), size - BlurMinimumDifference);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BlurViewActiveControlOuterRadius: {
|
||||||
|
float d = radialDistance - startDistance;
|
||||||
|
size = Math.max(falloff + BlurMinimumDifference, (startRadius + d) / shorterSide);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
|
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.valueChanged(centerPoint, falloff, size, degreesToRadians(angle) + (float) Math.PI / 2.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GestureStateEnded:
|
||||||
|
case GestureStateCancelled:
|
||||||
|
case GestureStateFailed: {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlNone;
|
||||||
|
setSelected(false, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handlePinch(int state, MotionEvent event) {
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case GestureStateBegan: {
|
||||||
|
startPointerDistance = getDistance(event);
|
||||||
|
pointerScale = 1;
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlWholeArea;
|
||||||
|
setSelected(true, true);
|
||||||
|
}
|
||||||
|
case GestureStateChanged: {
|
||||||
|
float newDistance = getDistance(event);
|
||||||
|
pointerScale += (newDistance - startPointerDistance) / AndroidUtilities.density * 0.01f;
|
||||||
|
|
||||||
|
falloff = Math.max(BlurMinimumFalloff, falloff * pointerScale);
|
||||||
|
size = Math.max(falloff + BlurMinimumDifference, size * pointerScale);
|
||||||
|
|
||||||
|
pointerScale = 1;
|
||||||
|
startPointerDistance = newDistance;
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.valueChanged(centerPoint, falloff, size, degreesToRadians(angle) + (float) Math.PI / 2.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GestureStateEnded:
|
||||||
|
case GestureStateCancelled:
|
||||||
|
case GestureStateFailed: {
|
||||||
|
activeControl = BlurViewActiveControl.BlurViewActiveControlNone;
|
||||||
|
setSelected(false, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSelected(boolean selected, boolean animated) {
|
||||||
|
/*if (animated) {
|
||||||
|
[UIView animateWithDuration:0.16f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState animations:^
|
||||||
|
{
|
||||||
|
self.alpha = selected ? 0.6f : 1.0f;
|
||||||
|
} completion:nil];
|
||||||
|
} else {
|
||||||
|
self.alpha = selected ? 0.6f : 1.0f;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActualAreaSize(float width, float height) {
|
||||||
|
actualAreaSize.width = width;
|
||||||
|
actualAreaSize.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
Point centerPoint = getActualCenterPoint();
|
||||||
|
float innerRadius = getActualInnerRadius();
|
||||||
|
float outerRadius = getActualOuterRadius();
|
||||||
|
canvas.translate(centerPoint.x, centerPoint.y);
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
canvas.rotate(angle);
|
||||||
|
|
||||||
|
float space = AndroidUtilities.dp(6.0f);
|
||||||
|
float length = AndroidUtilities.dp(12.0f);
|
||||||
|
float thickness = AndroidUtilities.dp(1.5f);
|
||||||
|
for (int i = 0; i < 30; i++) {
|
||||||
|
canvas.drawRect(i * (length + space), -innerRadius, i * (length + space) + length, thickness - innerRadius, paint);
|
||||||
|
canvas.drawRect(-i * (length + space) - space - length, -innerRadius, -i * (length + space) - space, thickness - innerRadius, paint);
|
||||||
|
|
||||||
|
canvas.drawRect(i * (length + space), innerRadius, length + i * (length + space), thickness + innerRadius, paint);
|
||||||
|
canvas.drawRect(-i * (length + space) - space - length, innerRadius, -i * (length + space) - space, thickness + innerRadius, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
length = AndroidUtilities.dp(6.0f);
|
||||||
|
for (int i = 0; i < 64; i++) {
|
||||||
|
canvas.drawRect(i * (length + space), -outerRadius, length + i * (length + space), thickness - outerRadius, paint);
|
||||||
|
canvas.drawRect(-i * (length + space) - space - length, -outerRadius, -i * (length + space) - space, thickness - outerRadius, paint);
|
||||||
|
|
||||||
|
canvas.drawRect(i * (length + space), outerRadius, length + i * (length + space), thickness + outerRadius, paint);
|
||||||
|
canvas.drawRect(-i * (length + space) - space - length, outerRadius, -i * (length + space) - space, thickness + outerRadius, paint);
|
||||||
|
}
|
||||||
|
} else if (type == 1) {
|
||||||
|
float radSpace = 6.15f;
|
||||||
|
float radLen = 10.2f;
|
||||||
|
arcRect.set(-innerRadius, -innerRadius, innerRadius, innerRadius);
|
||||||
|
for (int i = 0; i < 22; i++) {
|
||||||
|
canvas.drawArc(arcRect, i * (radSpace + radLen), radLen, false, arcPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
radSpace = 2.02f;
|
||||||
|
radLen = 3.6f;
|
||||||
|
arcRect.set(-outerRadius, -outerRadius, outerRadius, outerRadius);
|
||||||
|
for (int i = 0; i < 64; i++) {
|
||||||
|
canvas.drawArc(arcRect, i * (radSpace + radLen), radLen, false, arcPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
canvas.drawCircle(0, 0, AndroidUtilities.dp(8), paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Point getActualCenterPoint() {
|
||||||
|
return new Point((getWidth() - actualAreaSize.width) / 2 + centerPoint.x * actualAreaSize.width, (getHeight() - actualAreaSize.height) / 2 - (actualAreaSize.width - actualAreaSize.height) / 2 + centerPoint.y * actualAreaSize.width);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getActualInnerRadius() {
|
||||||
|
return (actualAreaSize.width > actualAreaSize.height ? actualAreaSize.height : actualAreaSize.width) * falloff;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getActualOuterRadius() {
|
||||||
|
return (actualAreaSize.width > actualAreaSize.height ? actualAreaSize.height : actualAreaSize.width) * size;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,417 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.ui.Components;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.PointF;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
import android.util.SizeF;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
public class PhotoFilterLinearBlurControl extends FrameLayout {
|
|
||||||
|
|
||||||
private final static float LinearBlurInsetProximity = 20;
|
|
||||||
private final static float LinearBlurMinimumFalloff = 0.1f;
|
|
||||||
private final static float LinearBlurMinimumDifference = 0.02f;
|
|
||||||
private final static float LinearBlurViewCenterInset = 30.0f;
|
|
||||||
private final static float LinearBlurViewRadiusInset = 30.0f;
|
|
||||||
|
|
||||||
private enum LinearBlurViewActiveControl {
|
|
||||||
TGLinearBlurViewActiveControlNone,
|
|
||||||
TGLinearBlurViewActiveControlCenter,
|
|
||||||
TGLinearBlurViewActiveControlInnerRadius,
|
|
||||||
TGLinearBlurViewActiveControlOuterRadius,
|
|
||||||
TGLinearBlurViewActiveControlWholeArea,
|
|
||||||
TGLinearBlurViewActiveControlRotation
|
|
||||||
}
|
|
||||||
|
|
||||||
private LinearBlurViewActiveControl activeControl;
|
|
||||||
private PointF startCenterPoint = new PointF();
|
|
||||||
private PointF startDistance = new PointF();
|
|
||||||
private PointF startRadius = new PointF();
|
|
||||||
private boolean isTracking;
|
|
||||||
private SizeF actualAreaSize;
|
|
||||||
private PointF centerPoint;
|
|
||||||
private float falloff;
|
|
||||||
private float size;
|
|
||||||
private float angle;
|
|
||||||
|
|
||||||
//@property (nonatomic, copy) void (^valueChanged)(CGPoint centerPoint, CGFloat falloff, CGFloat size, CGFloat angle);
|
|
||||||
//@property (nonatomic, copy) void(^interactionEnded)(void);
|
|
||||||
//UILongPressGestureRecognizer *_pressGestureRecognizer;
|
|
||||||
//UIPanGestureRecognizer *_panGestureRecognizer;
|
|
||||||
//UIPinchGestureRecognizer *_pinchGestureRecognizer;
|
|
||||||
|
|
||||||
public PhotoFilterLinearBlurControl(Context context) {
|
|
||||||
super(context);
|
|
||||||
|
|
||||||
setWillNotDraw(false);
|
|
||||||
|
|
||||||
centerPoint = new PointF(0.5f, 0.5f);
|
|
||||||
falloff = 0.15f;
|
|
||||||
size = 0.35f;
|
|
||||||
|
|
||||||
/*_pressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlePress:)];
|
|
||||||
_pressGestureRecognizer.delegate = self;
|
|
||||||
_pressGestureRecognizer.minimumPressDuration = 0.1f;
|
|
||||||
[self addGestureRecognizer:_pressGestureRecognizer];
|
|
||||||
|
|
||||||
_panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
|
|
||||||
_panGestureRecognizer.delegate = self;
|
|
||||||
[self addGestureRecognizer:_panGestureRecognizer];
|
|
||||||
|
|
||||||
_pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
|
|
||||||
_pinchGestureRecognizer.delegate = self;
|
|
||||||
[self addGestureRecognizer:_pinchGestureRecognizer];*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void handlePress() {
|
|
||||||
/*switch (gestureRecognizer.state) {
|
|
||||||
case UIGestureRecognizerStateBegan:
|
|
||||||
[self setSelected:true animated:true];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIGestureRecognizerStateEnded:
|
|
||||||
case UIGestureRecognizerStateCancelled:
|
|
||||||
case UIGestureRecognizerStateFailed:
|
|
||||||
[self setSelected:false animated:true];
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handlePan() {
|
|
||||||
/*CGPoint location = [gestureRecognizer locationInView:self];
|
|
||||||
CGPoint centerPoint = [self _actualCenterPoint];
|
|
||||||
CGPoint delta = CGPointMake(location.x - centerPoint.x, location.y - centerPoint.y);
|
|
||||||
CGFloat radialDistance = sqrtf(delta.x * delta.x + delta.y * delta.y);
|
|
||||||
CGFloat distance = fabsf(delta.x * cosf(self.angle + (CGFloat)M_PI_2) + delta.y * sinf(self.angle + (CGFloat)M_PI_2));
|
|
||||||
|
|
||||||
CGFloat shorterSide = (self.actualAreaSize.width > self.actualAreaSize.height) ? self.actualAreaSize.height : self.actualAreaSize.width;
|
|
||||||
|
|
||||||
CGFloat innerRadius = shorterSide * self.falloff;
|
|
||||||
CGFloat outerRadius = shorterSide * self.size;
|
|
||||||
|
|
||||||
switch (gestureRecognizer.state) {
|
|
||||||
case UIGestureRecognizerStateBegan:
|
|
||||||
{
|
|
||||||
bool close = fabsf(outerRadius - innerRadius) < TGLinearBlurInsetProximity;
|
|
||||||
CGFloat innerRadiusOuterInset = close ? 0 : TGLinearBlurViewRadiusInset;
|
|
||||||
CGFloat outerRadiusInnerInset = close ? 0 : TGLinearBlurViewRadiusInset;
|
|
||||||
|
|
||||||
if (radialDistance < TGLinearBlurViewCenterInset)
|
|
||||||
{
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlCenter;
|
|
||||||
_startCenterPoint = centerPoint;
|
|
||||||
}
|
|
||||||
else if (distance > innerRadius - TGLinearBlurViewRadiusInset && distance < innerRadius + innerRadiusOuterInset)
|
|
||||||
{
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlInnerRadius;
|
|
||||||
_startDistance = distance;
|
|
||||||
_startRadius = innerRadius;
|
|
||||||
}
|
|
||||||
else if (distance > outerRadius - outerRadiusInnerInset && distance < outerRadius + TGLinearBlurViewRadiusInset)
|
|
||||||
{
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlOuterRadius;
|
|
||||||
_startDistance = distance;
|
|
||||||
_startRadius = outerRadius;
|
|
||||||
}
|
|
||||||
else if (distance <= innerRadius - TGLinearBlurViewRadiusInset || distance >= outerRadius + TGLinearBlurViewRadiusInset)
|
|
||||||
{
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlRotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self setSelected:true animated:true];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIGestureRecognizerStateChanged:
|
|
||||||
{
|
|
||||||
switch (_activeControl)
|
|
||||||
{
|
|
||||||
case TGLinearBlurViewActiveControlCenter:
|
|
||||||
{
|
|
||||||
CGPoint translation = [gestureRecognizer translationInView:self];
|
|
||||||
|
|
||||||
CGRect actualArea = CGRectMake((self.frame.size.width - self.actualAreaSize.width) / 2, (self.frame.size.height - self.actualAreaSize.height) / 2, self.actualAreaSize.width, self.actualAreaSize.height);
|
|
||||||
|
|
||||||
CGPoint newPoint = CGPointMake(MAX(CGRectGetMinX(actualArea), MIN(CGRectGetMaxX(actualArea), _startCenterPoint.x + translation.x)),
|
|
||||||
MAX(CGRectGetMinY(actualArea), MIN(CGRectGetMaxY(actualArea), _startCenterPoint.y + translation.y)));
|
|
||||||
|
|
||||||
CGPoint offset = CGPointMake(0, (self.actualAreaSize.width - self.actualAreaSize.height) / 2);
|
|
||||||
CGPoint actualPoint = CGPointMake(newPoint.x - actualArea.origin.x, newPoint.y - actualArea.origin.y);
|
|
||||||
self.centerPoint = CGPointMake((actualPoint.x + offset.x) / self.actualAreaSize.width, (actualPoint.y + offset.y) / self.actualAreaSize.width);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TGLinearBlurViewActiveControlInnerRadius:
|
|
||||||
{
|
|
||||||
CGFloat delta = distance - _startDistance;
|
|
||||||
self.falloff = MIN(MAX(TGLinearBlurMinimumFalloff, (_startRadius + delta) / shorterSide), self.size - TGLinearBlurMinimumDifference);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TGLinearBlurViewActiveControlOuterRadius:
|
|
||||||
{
|
|
||||||
CGFloat delta = distance - _startDistance;
|
|
||||||
self.size = MAX(self.falloff + TGLinearBlurMinimumDifference, (_startRadius + delta) / shorterSide);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TGLinearBlurViewActiveControlRotation:
|
|
||||||
{
|
|
||||||
CGPoint translation = [gestureRecognizer translationInView:self];
|
|
||||||
bool clockwise = false;
|
|
||||||
|
|
||||||
bool right = location.x > centerPoint.x;
|
|
||||||
bool bottom = location.y > centerPoint.y;
|
|
||||||
|
|
||||||
if (!right && !bottom)
|
|
||||||
{
|
|
||||||
if (fabsf(translation.y) > fabsf(translation.x))
|
|
||||||
{
|
|
||||||
if (translation.y < 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (translation.x > 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (right && !bottom)
|
|
||||||
{
|
|
||||||
if (fabsf(translation.y) > fabsf(translation.x))
|
|
||||||
{
|
|
||||||
if (translation.y > 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (translation.x > 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (right && bottom)
|
|
||||||
{
|
|
||||||
if (fabsf(translation.y) > fabsf(translation.x))
|
|
||||||
{
|
|
||||||
if (translation.y > 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (translation.x < 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fabsf(translation.y) > fabsf(translation.x))
|
|
||||||
{
|
|
||||||
if (translation.y < 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (translation.x < 0)
|
|
||||||
clockwise = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CGFloat delta = sqrtf(translation.x * translation.x + translation.y * translation.y);
|
|
||||||
|
|
||||||
CGFloat angleInDegrees = TGRadiansToDegrees(_angle);
|
|
||||||
CGFloat newAngleInDegrees = angleInDegrees + delta * (clockwise * 2 - 1) / (CGFloat)M_PI / 1.15f;
|
|
||||||
|
|
||||||
_angle = TGDegreesToRadians(newAngleInDegrees);
|
|
||||||
|
|
||||||
[gestureRecognizer setTranslation:CGPointZero inView:self];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self setNeedsDisplay];
|
|
||||||
|
|
||||||
if (self.valueChanged != nil)
|
|
||||||
self.valueChanged(self.centerPoint, self.falloff, self.size, self.angle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIGestureRecognizerStateEnded:
|
|
||||||
case UIGestureRecognizerStateCancelled:
|
|
||||||
case UIGestureRecognizerStateFailed:
|
|
||||||
{
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlNone;
|
|
||||||
|
|
||||||
[self setSelected:false animated:true];
|
|
||||||
|
|
||||||
if (self.interactionEnded != nil)
|
|
||||||
self.interactionEnded();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handlePinch() {
|
|
||||||
/*switch (gestureRecognizer.state) {
|
|
||||||
case UIGestureRecognizerStateBegan: {
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlWholeArea;
|
|
||||||
[self setSelected:true animated:true];
|
|
||||||
}
|
|
||||||
case UIGestureRecognizerStateChanged: {
|
|
||||||
CGFloat scale = gestureRecognizer.scale;
|
|
||||||
|
|
||||||
self.falloff = MAX(TGLinearBlurMinimumFalloff, self.falloff * scale);
|
|
||||||
self.size = MAX(self.falloff + TGLinearBlurMinimumDifference, self.size * scale);
|
|
||||||
|
|
||||||
gestureRecognizer.scale = 1.0f;
|
|
||||||
|
|
||||||
[self setNeedsDisplay];
|
|
||||||
|
|
||||||
if (self.valueChanged != nil)
|
|
||||||
self.valueChanged(self.centerPoint, self.falloff, self.size, self.angle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIGestureRecognizerStateEnded: {
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlNone;
|
|
||||||
[self setSelected:false animated:true];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIGestureRecognizerStateCancelled:
|
|
||||||
case UIGestureRecognizerStateFailed: {
|
|
||||||
_activeControl = TGLinearBlurViewActiveControlNone;
|
|
||||||
[self setSelected:false animated:true];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
|
||||||
{
|
|
||||||
if (gestureRecognizer == _pressGestureRecognizer || gestureRecognizer == _panGestureRecognizer)
|
|
||||||
{
|
|
||||||
CGPoint location = [gestureRecognizer locationInView:self];
|
|
||||||
CGPoint centerPoint = [self _actualCenterPoint];
|
|
||||||
CGPoint delta = CGPointMake(location.x - centerPoint.x, location.y - centerPoint.y);
|
|
||||||
CGFloat radialDistance = sqrtf(delta.x * delta.x + delta.y * delta.y);
|
|
||||||
CGFloat distance = fabsf(delta.x * cosf(self.angle + (CGFloat)M_PI_2) + delta.y * sinf(self.angle + (CGFloat)M_PI_2));
|
|
||||||
|
|
||||||
CGFloat innerRadius = [self _actualInnerRadius];
|
|
||||||
CGFloat outerRadius = [self _actualOuterRadius];
|
|
||||||
|
|
||||||
bool close = fabsf(outerRadius - innerRadius) < TGLinearBlurInsetProximity;
|
|
||||||
CGFloat innerRadiusOuterInset = close ? 0 : TGLinearBlurViewRadiusInset;
|
|
||||||
CGFloat outerRadiusInnerInset = close ? 0 : TGLinearBlurViewRadiusInset;
|
|
||||||
|
|
||||||
if (radialDistance < TGLinearBlurViewCenterInset && gestureRecognizer == _panGestureRecognizer)
|
|
||||||
return true;
|
|
||||||
else if (distance > innerRadius - TGLinearBlurViewRadiusInset && distance < innerRadius + innerRadiusOuterInset)
|
|
||||||
return true;
|
|
||||||
else if (distance > outerRadius - outerRadiusInnerInset && distance < outerRadius + TGLinearBlurViewRadiusInset)
|
|
||||||
return true;
|
|
||||||
else if ((distance <= innerRadius - TGLinearBlurViewRadiusInset) || distance >= outerRadius + TGLinearBlurViewRadiusInset)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
|
|
||||||
{
|
|
||||||
if (gestureRecognizer == _pressGestureRecognizer || otherGestureRecognizer == _pressGestureRecognizer)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
private void setSelected(boolean selected, boolean animated) {
|
|
||||||
/*if (animated) {
|
|
||||||
[UIView animateWithDuration:0.16f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState animations:^
|
|
||||||
{
|
|
||||||
self.alpha = selected ? 0.6f : 1.0f;
|
|
||||||
} completion:nil];
|
|
||||||
} else {
|
|
||||||
self.alpha = selected ? 0.6f : 1.0f;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
|
|
||||||
/*PointF centerPoint = getActualCenterPoint();
|
|
||||||
float innerRadius = getActualInnerRadius();
|
|
||||||
float outerRadius = getActualOuterRadius();
|
|
||||||
|
|
||||||
CGContextTranslateCTM(context, centerPoint.x, centerPoint.y);
|
|
||||||
CGContextRotateCTM(context, self.angle);
|
|
||||||
|
|
||||||
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
|
|
||||||
CGContextSetShadowWithColor(context, CGSizeZero, 2.5f, [UIColor colorWithWhite:0.0f alpha:0.3f].CGColor);
|
|
||||||
|
|
||||||
float space = 6.0f;
|
|
||||||
float length = 12.0f;
|
|
||||||
float thickness = 1.5f;
|
|
||||||
for (int i = 0; i < 30; i++) {
|
|
||||||
CGContextAddRect(context, CGRectMake(i * (length + space), -innerRadius, length, thickness));
|
|
||||||
CGContextAddRect(context, CGRectMake(-i * (length + space) - space - length, -innerRadius, length, thickness));
|
|
||||||
|
|
||||||
CGContextAddRect(context, CGRectMake(i * (length + space), innerRadius, length, thickness));
|
|
||||||
CGContextAddRect(context, CGRectMake(-i * (length + space) - space - length, innerRadius, length, thickness));
|
|
||||||
}
|
|
||||||
|
|
||||||
length = 6.0f;
|
|
||||||
thickness = 1.5f;
|
|
||||||
for (int i = 0; i < 64; i++) {
|
|
||||||
CGContextAddRect(context, CGRectMake(i * (length + space), -outerRadius, length, thickness));
|
|
||||||
CGContextAddRect(context, CGRectMake(-i * (length + space) - space - length, -outerRadius, length, thickness));
|
|
||||||
|
|
||||||
CGContextAddRect(context, CGRectMake(i * (length + space), outerRadius, length, thickness));
|
|
||||||
CGContextAddRect(context, CGRectMake(-i * (length + space) - space - length, outerRadius, length, thickness));
|
|
||||||
}
|
|
||||||
|
|
||||||
CGContextFillPath(context);
|
|
||||||
|
|
||||||
CGContextFillEllipseInRect(context, CGRectMake(-16 / 2, - 16 / 2, 16, 16));*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private PointF getActualCenterPoint() {
|
|
||||||
RectF actualArea = new RectF((getWidth() - actualAreaSize.getWidth()) / 2, (getHeight() - actualAreaSize.getHeight()) / 2, actualAreaSize.getWidth(), actualAreaSize.getHeight());
|
|
||||||
PointF offset = new PointF(0, (actualAreaSize.getWidth() - actualAreaSize.getHeight()) / 2);
|
|
||||||
return new PointF(actualArea.left - offset.x + centerPoint.x * actualAreaSize.getWidth(), actualArea.top - offset.y + centerPoint.y * actualAreaSize.getWidth());
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getActualInnerRadius() {
|
|
||||||
float shorterSide = (actualAreaSize.getWidth() > actualAreaSize.getHeight()) ? actualAreaSize.getHeight() : actualAreaSize.getWidth();
|
|
||||||
return shorterSide * falloff;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getActualOuterRadius() {
|
|
||||||
float shorterSide = (actualAreaSize.getWidth() > actualAreaSize.getHeight()) ? actualAreaSize.getHeight() : actualAreaSize.getWidth();
|
|
||||||
return shorterSide * size;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -71,8 +71,8 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
private int shadowsTool = 6;
|
private int shadowsTool = 6;
|
||||||
private int vignetteTool = 7;
|
private int vignetteTool = 7;
|
||||||
private int grainTool = 8;
|
private int grainTool = 8;
|
||||||
private int blurTool = -1;
|
private int blurTool = 9;
|
||||||
private int sharpenTool = 9;
|
private int sharpenTool = 10;
|
||||||
|
|
||||||
private float highlightsValue = 0; //0 100
|
private float highlightsValue = 0; //0 100
|
||||||
private float contrastValue = 0; //-100 100
|
private float contrastValue = 0; //-100 100
|
||||||
|
@ -84,18 +84,29 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
private float vignetteValue = 0; //0 100
|
private float vignetteValue = 0; //0 100
|
||||||
private float grainValue = 0; //0 100
|
private float grainValue = 0; //0 100
|
||||||
private float sharpenValue = 0; //0 100
|
private float sharpenValue = 0; //0 100
|
||||||
|
private int blurType = 0; //0 none, 1 radial, 2 linear
|
||||||
|
private float blurExcludeSize = 0.35f;
|
||||||
|
private Point blurExcludePoint = new Point(0.5f, 0.5f);
|
||||||
|
private float blurExcludeBlurSize = 0.15f;
|
||||||
|
private float blurAngle = (float) Math.PI / 2.0f;
|
||||||
|
|
||||||
private ToolsAdapter toolsAdapter;
|
private ToolsAdapter toolsAdapter;
|
||||||
private PhotoEditorSeekBar valueSeekBar;
|
private PhotoEditorSeekBar valueSeekBar;
|
||||||
private FrameLayout toolsView;
|
private FrameLayout toolsView;
|
||||||
private FrameLayout editView;
|
private FrameLayout editView;
|
||||||
private TextView paramTextView;
|
private TextView paramTextView;
|
||||||
|
private TextView blurTextView;
|
||||||
private TextView valueTextView;
|
private TextView valueTextView;
|
||||||
private TextView doneTextView;
|
private TextView doneTextView;
|
||||||
private TextView cancelTextView;
|
private TextView cancelTextView;
|
||||||
private TextureView textureView;
|
private TextureView textureView;
|
||||||
private EGLThread eglThread;
|
private EGLThread eglThread;
|
||||||
private RecyclerListView recyclerListView;
|
private RecyclerListView recyclerListView;
|
||||||
|
private FrameLayout blurLayout;
|
||||||
|
private PhotoFilterBlurControl blurControl;
|
||||||
|
private TextView blurOffButton;
|
||||||
|
private TextView blurRadialButton;
|
||||||
|
private TextView blurLinearButton;
|
||||||
|
|
||||||
private Bitmap bitmapToEdit;
|
private Bitmap bitmapToEdit;
|
||||||
private int orientation;
|
private int orientation;
|
||||||
|
@ -112,6 +123,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
private EGLSurface eglSurface;
|
private EGLSurface eglSurface;
|
||||||
private GL gl;
|
private GL gl;
|
||||||
private boolean initied;
|
private boolean initied;
|
||||||
|
private boolean needUpdateBlurTexture = true;
|
||||||
|
|
||||||
private Bitmap currentBitmap;
|
private Bitmap currentBitmap;
|
||||||
|
|
||||||
|
@ -142,6 +154,34 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
private int widthHandle;
|
private int widthHandle;
|
||||||
private int heightHandle;
|
private int heightHandle;
|
||||||
|
|
||||||
|
private int blurShaderProgram;
|
||||||
|
private int blurPositionHandle;
|
||||||
|
private int blurInputTexCoordHandle;
|
||||||
|
private int blurSourceImageHandle;
|
||||||
|
private int blurWidthHandle;
|
||||||
|
private int blurHeightHandle;
|
||||||
|
|
||||||
|
private int linearBlurShaderProgram;
|
||||||
|
private int linearBlurPositionHandle;
|
||||||
|
private int linearBlurInputTexCoordHandle;
|
||||||
|
private int linearBlurSourceImageHandle;
|
||||||
|
private int linearBlurSourceImage2Handle;
|
||||||
|
private int linearBlurExcludeSizeHandle;
|
||||||
|
private int linearBlurExcludePointHandle;
|
||||||
|
private int linearBlurExcludeBlurSizeHandle;
|
||||||
|
private int linearBlurAngleHandle;
|
||||||
|
private int linearBlurAspectRatioHandle;
|
||||||
|
|
||||||
|
private int radialBlurShaderProgram;
|
||||||
|
private int radialBlurPositionHandle;
|
||||||
|
private int radialBlurInputTexCoordHandle;
|
||||||
|
private int radialBlurSourceImageHandle;
|
||||||
|
private int radialBlurSourceImage2Handle;
|
||||||
|
private int radialBlurExcludeSizeHandle;
|
||||||
|
private int radialBlurExcludePointHandle;
|
||||||
|
private int radialBlurExcludeBlurSizeHandle;
|
||||||
|
private int radialBlurAspectRatioHandle;
|
||||||
|
|
||||||
private int sharpenShaderProgram;
|
private int sharpenShaderProgram;
|
||||||
private int sharpenHandle;
|
private int sharpenHandle;
|
||||||
private int sharpenWidthHandle;
|
private int sharpenWidthHandle;
|
||||||
|
@ -156,8 +196,8 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
private int simpleSourceImageHandle;
|
private int simpleSourceImageHandle;
|
||||||
|
|
||||||
private int[] enhanceTextures = new int[2];
|
private int[] enhanceTextures = new int[2];
|
||||||
private int[] renderTexture = new int[2];
|
private int[] renderTexture = new int[3];
|
||||||
private int[] renderFrameBuffer = new int[2];
|
private int[] renderFrameBuffer = new int[3];
|
||||||
private boolean hsvGenerated;
|
private boolean hsvGenerated;
|
||||||
private int renderBufferWidth;
|
private int renderBufferWidth;
|
||||||
private int renderBufferHeight;
|
private int renderBufferHeight;
|
||||||
|
@ -168,9 +208,81 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
private FloatBuffer textureBuffer;
|
private FloatBuffer textureBuffer;
|
||||||
private FloatBuffer vertexInvertBuffer;
|
private FloatBuffer vertexInvertBuffer;
|
||||||
|
|
||||||
|
private boolean blured;
|
||||||
|
|
||||||
private final static int PGPhotoEnhanceHistogramBins = 256;
|
private final static int PGPhotoEnhanceHistogramBins = 256;
|
||||||
private final static int PGPhotoEnhanceSegments = 4;
|
private final static int PGPhotoEnhanceSegments = 4;
|
||||||
|
|
||||||
|
private static final String radialBlurFragmentShaderCode =
|
||||||
|
"varying highp vec2 texCoord;" +
|
||||||
|
"uniform sampler2D sourceImage;" +
|
||||||
|
"uniform sampler2D inputImageTexture2;" +
|
||||||
|
"uniform lowp float excludeSize;" +
|
||||||
|
"uniform lowp vec2 excludePoint;" +
|
||||||
|
"uniform lowp float excludeBlurSize;" +
|
||||||
|
"uniform highp float aspectRatio;" +
|
||||||
|
"void main() {" +
|
||||||
|
"lowp vec4 sharpImageColor = texture2D(sourceImage, texCoord);" +
|
||||||
|
"lowp vec4 blurredImageColor = texture2D(inputImageTexture2, texCoord);" +
|
||||||
|
"highp vec2 texCoordToUse = vec2(texCoord.x, (texCoord.y * aspectRatio + 0.5 - 0.5 * aspectRatio));" +
|
||||||
|
"highp float distanceFromCenter = distance(excludePoint, texCoordToUse);" +
|
||||||
|
"gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(excludeSize - excludeBlurSize, excludeSize, distanceFromCenter));" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
private static final String linearBlurFragmentShaderCode =
|
||||||
|
"varying highp vec2 texCoord;" +
|
||||||
|
"uniform sampler2D sourceImage;" +
|
||||||
|
"uniform sampler2D inputImageTexture2;" +
|
||||||
|
"uniform lowp float excludeSize;" +
|
||||||
|
"uniform lowp vec2 excludePoint;" +
|
||||||
|
"uniform lowp float excludeBlurSize;" +
|
||||||
|
"uniform highp float angle;" +
|
||||||
|
"uniform highp float aspectRatio;" +
|
||||||
|
"void main() {" +
|
||||||
|
"lowp vec4 sharpImageColor = texture2D(sourceImage, texCoord);" +
|
||||||
|
"lowp vec4 blurredImageColor = texture2D(inputImageTexture2, texCoord);" +
|
||||||
|
"highp vec2 texCoordToUse = vec2(texCoord.x, (texCoord.y * aspectRatio + 0.5 - 0.5 * aspectRatio));" +
|
||||||
|
"highp float distanceFromCenter = abs((texCoordToUse.x - excludePoint.x) * aspectRatio * cos(angle) + (texCoordToUse.y - excludePoint.y) * sin(angle));" +
|
||||||
|
"gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(excludeSize - excludeBlurSize, excludeSize, distanceFromCenter));" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
private static final String blurVertexShaderCode =
|
||||||
|
"attribute vec4 position;" +
|
||||||
|
"attribute vec4 inputTexCoord;" +
|
||||||
|
"uniform highp float texelWidthOffset;" +
|
||||||
|
"uniform highp float texelHeightOffset;" +
|
||||||
|
"varying vec2 blurCoordinates[9];" +
|
||||||
|
"void main() {" +
|
||||||
|
"gl_Position = position;" +
|
||||||
|
"vec2 singleStepOffset = vec2(texelWidthOffset, texelHeightOffset);" +
|
||||||
|
"blurCoordinates[0] = inputTexCoord.xy;" +
|
||||||
|
"blurCoordinates[1] = inputTexCoord.xy + singleStepOffset * 1.458430;" +
|
||||||
|
"blurCoordinates[2] = inputTexCoord.xy - singleStepOffset * 1.458430;" +
|
||||||
|
"blurCoordinates[3] = inputTexCoord.xy + singleStepOffset * 3.403985;" +
|
||||||
|
"blurCoordinates[4] = inputTexCoord.xy - singleStepOffset * 3.403985;" +
|
||||||
|
"blurCoordinates[5] = inputTexCoord.xy + singleStepOffset * 5.351806;" +
|
||||||
|
"blurCoordinates[6] = inputTexCoord.xy - singleStepOffset * 5.351806;" +
|
||||||
|
"blurCoordinates[7] = inputTexCoord.xy + singleStepOffset * 7.302940;" +
|
||||||
|
"blurCoordinates[8] = inputTexCoord.xy - singleStepOffset * 7.302940;" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
private static final String blurFragmentShaderCode =
|
||||||
|
"uniform sampler2D sourceImage;" +
|
||||||
|
"varying highp vec2 blurCoordinates[9];" +
|
||||||
|
"void main() {" +
|
||||||
|
"lowp vec4 sum = vec4(0.0);" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[0]) * 0.133571;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[1]) * 0.233308;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[2]) * 0.233308;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[3]) * 0.135928;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[4]) * 0.135928;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[5]) * 0.051383;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[6]) * 0.051383;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[7]) * 0.012595;" +
|
||||||
|
"sum += texture2D(sourceImage, blurCoordinates[8]) * 0.012595;" +
|
||||||
|
"gl_FragColor = sum;" +
|
||||||
|
"}";
|
||||||
|
|
||||||
private static final String rgbToHsvFragmentShaderCode =
|
private static final String rgbToHsvFragmentShaderCode =
|
||||||
"precision highp float;" +
|
"precision highp float;" +
|
||||||
"varying vec2 texCoord;" +
|
"varying vec2 texCoord;" +
|
||||||
|
@ -628,6 +740,97 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, blurVertexShaderCode);
|
||||||
|
fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, blurFragmentShaderCode);
|
||||||
|
|
||||||
|
if (vertexShader != 0 && fragmentShader != 0) {
|
||||||
|
blurShaderProgram = GLES20.glCreateProgram();
|
||||||
|
GLES20.glAttachShader(blurShaderProgram, vertexShader);
|
||||||
|
GLES20.glAttachShader(blurShaderProgram, fragmentShader);
|
||||||
|
GLES20.glBindAttribLocation(blurShaderProgram, 0, "position");
|
||||||
|
GLES20.glBindAttribLocation(blurShaderProgram, 1, "inputTexCoord");
|
||||||
|
|
||||||
|
GLES20.glLinkProgram(blurShaderProgram);
|
||||||
|
int[] linkStatus = new int[1];
|
||||||
|
GLES20.glGetProgramiv(blurShaderProgram, GLES20.GL_LINK_STATUS, linkStatus, 0);
|
||||||
|
if (linkStatus[0] == 0) {
|
||||||
|
GLES20.glDeleteProgram(blurShaderProgram);
|
||||||
|
blurShaderProgram = 0;
|
||||||
|
} else {
|
||||||
|
blurPositionHandle = GLES20.glGetAttribLocation(blurShaderProgram, "position");
|
||||||
|
blurInputTexCoordHandle = GLES20.glGetAttribLocation(blurShaderProgram, "inputTexCoord");
|
||||||
|
blurSourceImageHandle = GLES20.glGetUniformLocation(blurShaderProgram, "sourceImage");
|
||||||
|
blurWidthHandle = GLES20.glGetUniformLocation(blurShaderProgram, "texelWidthOffset");
|
||||||
|
blurHeightHandle = GLES20.glGetUniformLocation(blurShaderProgram, "texelHeightOffset");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, simpleVertexShaderCode);
|
||||||
|
fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, linearBlurFragmentShaderCode);
|
||||||
|
|
||||||
|
if (vertexShader != 0 && fragmentShader != 0) {
|
||||||
|
linearBlurShaderProgram = GLES20.glCreateProgram();
|
||||||
|
GLES20.glAttachShader(linearBlurShaderProgram, vertexShader);
|
||||||
|
GLES20.glAttachShader(linearBlurShaderProgram, fragmentShader);
|
||||||
|
GLES20.glBindAttribLocation(linearBlurShaderProgram, 0, "position");
|
||||||
|
GLES20.glBindAttribLocation(linearBlurShaderProgram, 1, "inputTexCoord");
|
||||||
|
|
||||||
|
GLES20.glLinkProgram(linearBlurShaderProgram);
|
||||||
|
int[] linkStatus = new int[1];
|
||||||
|
GLES20.glGetProgramiv(linearBlurShaderProgram, GLES20.GL_LINK_STATUS, linkStatus, 0);
|
||||||
|
if (linkStatus[0] == 0) {
|
||||||
|
GLES20.glDeleteProgram(linearBlurShaderProgram);
|
||||||
|
linearBlurShaderProgram = 0;
|
||||||
|
} else {
|
||||||
|
linearBlurPositionHandle = GLES20.glGetAttribLocation(linearBlurShaderProgram, "position");
|
||||||
|
linearBlurInputTexCoordHandle = GLES20.glGetAttribLocation(linearBlurShaderProgram, "inputTexCoord");
|
||||||
|
linearBlurSourceImageHandle = GLES20.glGetUniformLocation(linearBlurShaderProgram, "sourceImage");
|
||||||
|
linearBlurSourceImage2Handle = GLES20.glGetUniformLocation(linearBlurShaderProgram, "inputImageTexture2");
|
||||||
|
linearBlurExcludeSizeHandle = GLES20.glGetUniformLocation(linearBlurShaderProgram, "excludeSize");
|
||||||
|
linearBlurExcludePointHandle = GLES20.glGetUniformLocation(linearBlurShaderProgram, "excludePoint");
|
||||||
|
linearBlurExcludeBlurSizeHandle = GLES20.glGetUniformLocation(linearBlurShaderProgram, "excludeBlurSize");
|
||||||
|
linearBlurAngleHandle = GLES20.glGetUniformLocation(linearBlurShaderProgram, "angle");
|
||||||
|
linearBlurAspectRatioHandle = GLES20.glGetUniformLocation(linearBlurShaderProgram, "aspectRatio");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, simpleVertexShaderCode);
|
||||||
|
fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, radialBlurFragmentShaderCode);
|
||||||
|
|
||||||
|
if (vertexShader != 0 && fragmentShader != 0) {
|
||||||
|
radialBlurShaderProgram = GLES20.glCreateProgram();
|
||||||
|
GLES20.glAttachShader(radialBlurShaderProgram, vertexShader);
|
||||||
|
GLES20.glAttachShader(radialBlurShaderProgram, fragmentShader);
|
||||||
|
GLES20.glBindAttribLocation(radialBlurShaderProgram, 0, "position");
|
||||||
|
GLES20.glBindAttribLocation(radialBlurShaderProgram, 1, "inputTexCoord");
|
||||||
|
|
||||||
|
GLES20.glLinkProgram(radialBlurShaderProgram);
|
||||||
|
int[] linkStatus = new int[1];
|
||||||
|
GLES20.glGetProgramiv(radialBlurShaderProgram, GLES20.GL_LINK_STATUS, linkStatus, 0);
|
||||||
|
if (linkStatus[0] == 0) {
|
||||||
|
GLES20.glDeleteProgram(radialBlurShaderProgram);
|
||||||
|
radialBlurShaderProgram = 0;
|
||||||
|
} else {
|
||||||
|
radialBlurPositionHandle = GLES20.glGetAttribLocation(radialBlurShaderProgram, "position");
|
||||||
|
radialBlurInputTexCoordHandle = GLES20.glGetAttribLocation(radialBlurShaderProgram, "inputTexCoord");
|
||||||
|
radialBlurSourceImageHandle = GLES20.glGetUniformLocation(radialBlurShaderProgram, "sourceImage");
|
||||||
|
radialBlurSourceImage2Handle = GLES20.glGetUniformLocation(radialBlurShaderProgram, "inputImageTexture2");
|
||||||
|
radialBlurExcludeSizeHandle = GLES20.glGetUniformLocation(radialBlurShaderProgram, "excludeSize");
|
||||||
|
radialBlurExcludePointHandle = GLES20.glGetUniformLocation(radialBlurShaderProgram, "excludePoint");
|
||||||
|
radialBlurExcludeBlurSizeHandle = GLES20.glGetUniformLocation(radialBlurShaderProgram, "excludeBlurSize");
|
||||||
|
radialBlurAspectRatioHandle = GLES20.glGetUniformLocation(radialBlurShaderProgram, "aspectRatio");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, simpleVertexShaderCode);
|
vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, simpleVertexShaderCode);
|
||||||
fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, rgbToHsvFragmentShaderCode);
|
fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, rgbToHsvFragmentShaderCode);
|
||||||
if (vertexShader != 0 && fragmentShader != 0) {
|
if (vertexShader != 0 && fragmentShader != 0) {
|
||||||
|
@ -728,6 +931,205 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawEnhancePass() {
|
||||||
|
if (!hsvGenerated) {
|
||||||
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
|
||||||
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
|
||||||
|
GLES20.glClear(0);
|
||||||
|
|
||||||
|
GLES20.glUseProgram(rgbToHsvShaderProgram);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
|
||||||
|
GLES20.glUniform1i(rgbToHsvSourceImageHandle, 0);
|
||||||
|
GLES20.glEnableVertexAttribArray(rgbToHsvInputTexCoordHandle);
|
||||||
|
GLES20.glVertexAttribPointer(rgbToHsvInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
GLES20.glEnableVertexAttribArray(rgbToHsvPositionHandle);
|
||||||
|
GLES20.glVertexAttribPointer(rgbToHsvPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
|
||||||
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
ByteBuffer hsvBuffer = ByteBuffer.allocateDirect(renderBufferWidth * renderBufferHeight * 4);
|
||||||
|
GLES20.glReadPixels(0, 0, renderBufferWidth, renderBufferHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer);
|
||||||
|
|
||||||
|
GLES20.glBindTexture(GL10.GL_TEXTURE_2D, enhanceTextures[0]);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
|
||||||
|
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, renderBufferWidth, renderBufferHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer);
|
||||||
|
|
||||||
|
ByteBuffer buffer = null;
|
||||||
|
try {
|
||||||
|
buffer = ByteBuffer.allocateDirect(PGPhotoEnhanceSegments * PGPhotoEnhanceSegments * PGPhotoEnhanceHistogramBins * 4);
|
||||||
|
Utilities.calcCDT(hsvBuffer, renderBufferWidth, renderBufferHeight, buffer);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e("tmessages", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLES20.glBindTexture(GL10.GL_TEXTURE_2D, enhanceTextures[1]);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
|
||||||
|
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 16, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buffer);
|
||||||
|
|
||||||
|
hsvGenerated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
|
||||||
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0);
|
||||||
|
GLES20.glClear(0);
|
||||||
|
|
||||||
|
GLES20.glUseProgram(enhanceShaderProgram);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[0]);
|
||||||
|
GLES20.glUniform1i(enhanceSourceImageHandle, 0);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[1]);
|
||||||
|
GLES20.glUniform1i(enhanceInputImageTexture2Handle, 1);
|
||||||
|
if (showOriginal) {
|
||||||
|
GLES20.glUniform1f(enhanceIntensityHandle, 0);
|
||||||
|
} else {
|
||||||
|
GLES20.glUniform1f(enhanceIntensityHandle, getEnhanceValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
GLES20.glEnableVertexAttribArray(enhanceInputTexCoordHandle);
|
||||||
|
GLES20.glVertexAttribPointer(enhanceInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
GLES20.glEnableVertexAttribArray(enhancePositionHandle);
|
||||||
|
GLES20.glVertexAttribPointer(enhancePositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
|
||||||
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawSharpenPass() {
|
||||||
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
|
||||||
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
|
||||||
|
GLES20.glClear(0);
|
||||||
|
|
||||||
|
GLES20.glUseProgram(sharpenShaderProgram);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
|
||||||
|
GLES20.glUniform1i(sharpenSourceImageHandle, 0);
|
||||||
|
if (showOriginal) {
|
||||||
|
GLES20.glUniform1f(sharpenHandle, 0);
|
||||||
|
} else {
|
||||||
|
GLES20.glUniform1f(sharpenHandle, getSharpenValue());
|
||||||
|
}
|
||||||
|
GLES20.glUniform1f(sharpenWidthHandle, renderBufferWidth);
|
||||||
|
GLES20.glUniform1f(sharpenHeightHandle, renderBufferHeight);
|
||||||
|
GLES20.glEnableVertexAttribArray(sharpenInputTexCoordHandle);
|
||||||
|
GLES20.glVertexAttribPointer(sharpenInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
GLES20.glEnableVertexAttribArray(sharpenPositionHandle);
|
||||||
|
GLES20.glVertexAttribPointer(sharpenPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
|
||||||
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawCustomParamsPass() {
|
||||||
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
|
||||||
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0);
|
||||||
|
GLES20.glClear(0);
|
||||||
|
|
||||||
|
GLES20.glUseProgram(toolsShaderProgram);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
|
||||||
|
GLES20.glUniform1i(sourceImageHandle, 0);
|
||||||
|
if (showOriginal) {
|
||||||
|
GLES20.glUniform1f(shadowsHandle, 0);
|
||||||
|
GLES20.glUniform1f(highlightsHandle, 1);
|
||||||
|
GLES20.glUniform1f(exposureHandle, 0);
|
||||||
|
GLES20.glUniform1f(contrastHandle, 1);
|
||||||
|
GLES20.glUniform1f(saturationHandle, 1);
|
||||||
|
GLES20.glUniform1f(warmthHandle, 0);
|
||||||
|
GLES20.glUniform1f(vignetteHandle, 0);
|
||||||
|
GLES20.glUniform1f(grainHandle, 0);
|
||||||
|
} else {
|
||||||
|
GLES20.glUniform1f(shadowsHandle, getShadowsValue());
|
||||||
|
GLES20.glUniform1f(highlightsHandle, getHighlightsValue());
|
||||||
|
GLES20.glUniform1f(exposureHandle, getExposureValue());
|
||||||
|
GLES20.glUniform1f(contrastHandle, getContrastValue());
|
||||||
|
GLES20.glUniform1f(saturationHandle, getSaturationValue());
|
||||||
|
GLES20.glUniform1f(warmthHandle, getWarmthValue());
|
||||||
|
GLES20.glUniform1f(vignetteHandle, getVignetteValue());
|
||||||
|
GLES20.glUniform1f(grainHandle, getGrainValue());
|
||||||
|
}
|
||||||
|
GLES20.glUniform1f(widthHandle, renderBufferWidth);
|
||||||
|
GLES20.glUniform1f(heightHandle, renderBufferHeight);
|
||||||
|
GLES20.glEnableVertexAttribArray(inputTexCoordHandle);
|
||||||
|
GLES20.glVertexAttribPointer(inputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
GLES20.glEnableVertexAttribArray(positionHandle);
|
||||||
|
GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
|
||||||
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean drawBlurPass() {
|
||||||
|
if (showOriginal || blurType == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (needUpdateBlurTexture) {
|
||||||
|
GLES20.glUseProgram(blurShaderProgram);
|
||||||
|
GLES20.glUniform1i(blurSourceImageHandle, 0);
|
||||||
|
GLES20.glEnableVertexAttribArray(blurInputTexCoordHandle);
|
||||||
|
GLES20.glVertexAttribPointer(blurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
GLES20.glEnableVertexAttribArray(blurPositionHandle);
|
||||||
|
GLES20.glVertexAttribPointer(blurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
|
||||||
|
|
||||||
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
|
||||||
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
|
||||||
|
GLES20.glClear(0);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
|
||||||
|
GLES20.glUniform1f(blurWidthHandle, 0.0f);
|
||||||
|
GLES20.glUniform1f(blurHeightHandle, 1.0f / renderBufferHeight);
|
||||||
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[2]);
|
||||||
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[2], 0);
|
||||||
|
GLES20.glClear(0);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
|
||||||
|
GLES20.glUniform1f(blurWidthHandle, 1.0f / renderBufferWidth);
|
||||||
|
GLES20.glUniform1f(blurHeightHandle, 0.0f);
|
||||||
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
needUpdateBlurTexture = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
|
||||||
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
|
||||||
|
GLES20.glClear(0);
|
||||||
|
if (blurType == 1) {
|
||||||
|
GLES20.glUseProgram(radialBlurShaderProgram);
|
||||||
|
GLES20.glUniform1i(radialBlurSourceImageHandle, 0);
|
||||||
|
GLES20.glUniform1i(radialBlurSourceImage2Handle, 1);
|
||||||
|
GLES20.glUniform1f(radialBlurExcludeSizeHandle, blurExcludeSize);
|
||||||
|
GLES20.glUniform1f(radialBlurExcludeBlurSizeHandle, blurExcludeBlurSize);
|
||||||
|
GLES20.glUniform2f(radialBlurExcludePointHandle, blurExcludePoint.x, blurExcludePoint.y);
|
||||||
|
GLES20.glUniform1f(radialBlurAspectRatioHandle, (float) renderBufferHeight / (float) renderBufferWidth);
|
||||||
|
GLES20.glEnableVertexAttribArray(radialBlurInputTexCoordHandle);
|
||||||
|
GLES20.glVertexAttribPointer(radialBlurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
GLES20.glEnableVertexAttribArray(radialBlurPositionHandle);
|
||||||
|
GLES20.glVertexAttribPointer(radialBlurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
|
||||||
|
} else if (blurType == 2) {
|
||||||
|
GLES20.glUseProgram(linearBlurShaderProgram);
|
||||||
|
GLES20.glUniform1i(linearBlurSourceImageHandle, 0);
|
||||||
|
GLES20.glUniform1i(linearBlurSourceImage2Handle, 1);
|
||||||
|
GLES20.glUniform1f(linearBlurExcludeSizeHandle, blurExcludeSize);
|
||||||
|
GLES20.glUniform1f(linearBlurExcludeBlurSizeHandle, blurExcludeBlurSize);
|
||||||
|
GLES20.glUniform1f(linearBlurAngleHandle, blurAngle);
|
||||||
|
GLES20.glUniform2f(linearBlurExcludePointHandle, blurExcludePoint.x, blurExcludePoint.y);
|
||||||
|
GLES20.glUniform1f(linearBlurAspectRatioHandle, (float) renderBufferHeight / (float) renderBufferWidth);
|
||||||
|
GLES20.glEnableVertexAttribArray(linearBlurInputTexCoordHandle);
|
||||||
|
GLES20.glVertexAttribPointer(linearBlurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
GLES20.glEnableVertexAttribArray(linearBlurPositionHandle);
|
||||||
|
GLES20.glVertexAttribPointer(linearBlurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
|
||||||
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[2]);
|
||||||
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private Runnable drawRunnable = new Runnable() {
|
private Runnable drawRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -743,130 +1145,10 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
GLES20.glViewport(0, 0, renderBufferWidth, renderBufferHeight);
|
GLES20.glViewport(0, 0, renderBufferWidth, renderBufferHeight);
|
||||||
//enhance draw
|
drawEnhancePass();
|
||||||
if (!hsvGenerated) {
|
drawSharpenPass();
|
||||||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
|
drawCustomParamsPass();
|
||||||
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
|
blured = drawBlurPass();
|
||||||
GLES20.glClear(0);
|
|
||||||
|
|
||||||
GLES20.glUseProgram(rgbToHsvShaderProgram);
|
|
||||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
|
|
||||||
GLES20.glUniform1i(rgbToHsvSourceImageHandle, 0);
|
|
||||||
GLES20.glEnableVertexAttribArray(rgbToHsvInputTexCoordHandle);
|
|
||||||
GLES20.glVertexAttribPointer(rgbToHsvInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
|
||||||
GLES20.glEnableVertexAttribArray(rgbToHsvPositionHandle);
|
|
||||||
GLES20.glVertexAttribPointer(rgbToHsvPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
|
|
||||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
ByteBuffer hsvBuffer = ByteBuffer.allocateDirect(renderBufferWidth * renderBufferHeight * 4);
|
|
||||||
GLES20.glReadPixels(0, 0, renderBufferWidth, renderBufferHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer);
|
|
||||||
|
|
||||||
GLES20.glBindTexture(GL10.GL_TEXTURE_2D, enhanceTextures[0]);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
|
|
||||||
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, renderBufferWidth, renderBufferHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer);
|
|
||||||
|
|
||||||
ByteBuffer buffer = null;
|
|
||||||
try {
|
|
||||||
buffer = ByteBuffer.allocateDirect(PGPhotoEnhanceSegments * PGPhotoEnhanceSegments * PGPhotoEnhanceHistogramBins * 4);
|
|
||||||
Utilities.calcCDT(hsvBuffer, renderBufferWidth, renderBufferHeight, buffer);
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e("tmessages", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLES20.glBindTexture(GL10.GL_TEXTURE_2D, enhanceTextures[1]);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
|
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
|
|
||||||
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 16, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buffer);
|
|
||||||
|
|
||||||
hsvGenerated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
|
|
||||||
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0);
|
|
||||||
GLES20.glClear(0);
|
|
||||||
|
|
||||||
GLES20.glUseProgram(enhanceShaderProgram);
|
|
||||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[0]);
|
|
||||||
GLES20.glUniform1i(enhanceSourceImageHandle, 0);
|
|
||||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[1]);
|
|
||||||
GLES20.glUniform1i(enhanceInputImageTexture2Handle, 1);
|
|
||||||
if (showOriginal) {
|
|
||||||
GLES20.glUniform1f(enhanceIntensityHandle, 0);
|
|
||||||
} else {
|
|
||||||
GLES20.glUniform1f(enhanceIntensityHandle, getEnhanceValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
GLES20.glEnableVertexAttribArray(enhanceInputTexCoordHandle);
|
|
||||||
GLES20.glVertexAttribPointer(enhanceInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
|
||||||
GLES20.glEnableVertexAttribArray(enhancePositionHandle);
|
|
||||||
GLES20.glVertexAttribPointer(enhancePositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
|
|
||||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
//sharpen draw
|
|
||||||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
|
|
||||||
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
|
|
||||||
GLES20.glClear(0);
|
|
||||||
|
|
||||||
GLES20.glUseProgram(sharpenShaderProgram);
|
|
||||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
|
|
||||||
GLES20.glUniform1i(sharpenSourceImageHandle, 0);
|
|
||||||
if (showOriginal) {
|
|
||||||
GLES20.glUniform1f(sharpenHandle, 0);
|
|
||||||
} else {
|
|
||||||
GLES20.glUniform1f(sharpenHandle, getSharpenValue());
|
|
||||||
}
|
|
||||||
GLES20.glUniform1f(sharpenWidthHandle, renderBufferWidth);
|
|
||||||
GLES20.glUniform1f(sharpenHeightHandle, renderBufferHeight);
|
|
||||||
GLES20.glEnableVertexAttribArray(sharpenInputTexCoordHandle);
|
|
||||||
GLES20.glVertexAttribPointer(sharpenInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
|
||||||
GLES20.glEnableVertexAttribArray(sharpenPositionHandle);
|
|
||||||
GLES20.glVertexAttribPointer(sharpenPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
|
|
||||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
//custom params draw
|
|
||||||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
|
|
||||||
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0);
|
|
||||||
GLES20.glClear(0);
|
|
||||||
|
|
||||||
GLES20.glUseProgram(toolsShaderProgram);
|
|
||||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
|
|
||||||
GLES20.glUniform1i(sourceImageHandle, 0);
|
|
||||||
if (showOriginal) {
|
|
||||||
GLES20.glUniform1f(shadowsHandle, 0);
|
|
||||||
GLES20.glUniform1f(highlightsHandle, 1);
|
|
||||||
GLES20.glUniform1f(exposureHandle, 0);
|
|
||||||
GLES20.glUniform1f(contrastHandle, 1);
|
|
||||||
GLES20.glUniform1f(saturationHandle, 1);
|
|
||||||
GLES20.glUniform1f(warmthHandle, 0);
|
|
||||||
GLES20.glUniform1f(vignetteHandle, 0);
|
|
||||||
GLES20.glUniform1f(grainHandle, 0);
|
|
||||||
} else {
|
|
||||||
GLES20.glUniform1f(shadowsHandle, getShadowsValue());
|
|
||||||
GLES20.glUniform1f(highlightsHandle, getHighlightsValue());
|
|
||||||
GLES20.glUniform1f(exposureHandle, getExposureValue());
|
|
||||||
GLES20.glUniform1f(contrastHandle, getContrastValue());
|
|
||||||
GLES20.glUniform1f(saturationHandle, getSaturationValue());
|
|
||||||
GLES20.glUniform1f(warmthHandle, getWarmthValue());
|
|
||||||
GLES20.glUniform1f(vignetteHandle, getVignetteValue());
|
|
||||||
GLES20.glUniform1f(grainHandle, getGrainValue());
|
|
||||||
}
|
|
||||||
GLES20.glUniform1f(widthHandle, renderBufferWidth);
|
|
||||||
GLES20.glUniform1f(heightHandle, renderBufferHeight);
|
|
||||||
GLES20.glEnableVertexAttribArray(inputTexCoordHandle);
|
|
||||||
GLES20.glVertexAttribPointer(inputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
|
||||||
GLES20.glEnableVertexAttribArray(positionHandle);
|
|
||||||
GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
|
|
||||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
//onscreen draw
|
//onscreen draw
|
||||||
GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
|
GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
|
||||||
|
@ -875,7 +1157,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
|
|
||||||
GLES20.glUseProgram(simpleShaderProgram);
|
GLES20.glUseProgram(simpleShaderProgram);
|
||||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[blured ? 0 : 1]);
|
||||||
GLES20.glUniform1i(simpleSourceImageHandle, 0);
|
GLES20.glUniform1i(simpleSourceImageHandle, 0);
|
||||||
GLES20.glEnableVertexAttribArray(simpleInputTexCoordHandle);
|
GLES20.glEnableVertexAttribArray(simpleInputTexCoordHandle);
|
||||||
GLES20.glVertexAttribPointer(simpleInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
GLES20.glVertexAttribPointer(simpleInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||||
|
@ -905,7 +1187,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
|
||||||
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0);
|
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[blured ? 0 : 1], 0);
|
||||||
GLES20.glClear(0);
|
GLES20.glClear(0);
|
||||||
object[0] = getRenderBufferBitmap();
|
object[0] = getRenderBufferBitmap();
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
|
@ -973,8 +1255,8 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
|
|
||||||
currentBitmap = createBitmap(bitmap, renderBufferWidth, renderBufferHeight, scale);
|
currentBitmap = createBitmap(bitmap, renderBufferWidth, renderBufferHeight, scale);
|
||||||
}
|
}
|
||||||
GLES20.glGenFramebuffers(2, renderFrameBuffer, 0);
|
GLES20.glGenFramebuffers(3, renderFrameBuffer, 0);
|
||||||
GLES20.glGenTextures(2, renderTexture, 0);
|
GLES20.glGenTextures(3, renderTexture, 0);
|
||||||
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
|
||||||
|
@ -989,6 +1271,13 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
|
||||||
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
|
||||||
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, currentBitmap, 0);
|
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, currentBitmap, 0);
|
||||||
|
|
||||||
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[2]);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
|
||||||
|
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
|
||||||
|
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, renderBufferWidth, renderBufferHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
@ -1016,9 +1305,17 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
super.run();
|
super.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestRender() {
|
public void requestRender(final boolean updateBlur) {
|
||||||
cancelRunnable(drawRunnable);
|
postRunnable(new Runnable() {
|
||||||
postRunnable(drawRunnable);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!needUpdateBlurTexture) {
|
||||||
|
needUpdateBlurTexture = updateBlur;
|
||||||
|
}
|
||||||
|
cancelRunnable(drawRunnable);
|
||||||
|
postRunnable(drawRunnable);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1343,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
if (eglThread == null && surface != null) {
|
if (eglThread == null && surface != null) {
|
||||||
eglThread = new EGLThread(surface, bitmapToEdit);
|
eglThread = new EGLThread(surface, bitmapToEdit);
|
||||||
eglThread.setSurfaceTextureSize(width, height);
|
eglThread.setSurfaceTextureSize(width, height);
|
||||||
eglThread.requestRender();
|
eglThread.requestRender(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,11 +1351,11 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, final int width, final int height) {
|
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, final int width, final int height) {
|
||||||
if (eglThread != null) {
|
if (eglThread != null) {
|
||||||
eglThread.setSurfaceTextureSize(width, height);
|
eglThread.setSurfaceTextureSize(width, height);
|
||||||
eglThread.requestRender();
|
eglThread.requestRender(false);
|
||||||
eglThread.postRunnable(new Runnable() {
|
eglThread.postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
eglThread.requestRender();
|
eglThread.requestRender(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1079,6 +1376,27 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
blurControl = new PhotoFilterBlurControl(context);
|
||||||
|
blurControl.setVisibility(INVISIBLE);
|
||||||
|
addView(blurControl);
|
||||||
|
layoutParams = (LayoutParams) blurControl.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||||
|
layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
||||||
|
blurControl.setLayoutParams(layoutParams);
|
||||||
|
blurControl.setDelegate(new PhotoFilterBlurControl.PhotoFilterLinearBlurControlDelegate() {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(Point centerPoint, float falloff, float size, float angle) {
|
||||||
|
blurExcludeSize = size;
|
||||||
|
blurExcludePoint = centerPoint;
|
||||||
|
blurExcludeBlurSize = falloff;
|
||||||
|
blurAngle = angle;
|
||||||
|
if (eglThread != null) {
|
||||||
|
eglThread.requestRender(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
toolsView = new FrameLayout(context);
|
toolsView = new FrameLayout(context);
|
||||||
addView(toolsView);
|
addView(toolsView);
|
||||||
layoutParams = (LayoutParams) toolsView.getLayoutParams();
|
layoutParams = (LayoutParams) toolsView.getLayoutParams();
|
||||||
|
@ -1186,7 +1504,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
valueSeekBar.setMinMax(0, 100);
|
valueSeekBar.setMinMax(0, 100);
|
||||||
paramTextView.setText(LocaleController.getString("Sharpen", R.string.Sharpen));
|
paramTextView.setText(LocaleController.getString("Sharpen", R.string.Sharpen));
|
||||||
} else if (i == blurTool) {
|
} else if (i == blurTool) {
|
||||||
|
previousValue = blurType;
|
||||||
}
|
}
|
||||||
valueSeekBar.setProgress((int) previousValue, false);
|
valueSeekBar.setProgress((int) previousValue, false);
|
||||||
updateValueTextView();
|
updateValueTextView();
|
||||||
|
@ -1245,9 +1563,11 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
grainValue = previousValue;
|
grainValue = previousValue;
|
||||||
} else if (selectedTool == sharpenTool) {
|
} else if (selectedTool == sharpenTool) {
|
||||||
sharpenValue = previousValue;
|
sharpenValue = previousValue;
|
||||||
|
} else if (selectedTool == blurTool) {
|
||||||
|
blurType = (int) previousValue;
|
||||||
}
|
}
|
||||||
if (eglThread != null) {
|
if (eglThread != null) {
|
||||||
eglThread.requestRender();
|
eglThread.requestRender(selectedTool != blurTool);
|
||||||
}
|
}
|
||||||
switchToOrFromEditMode();
|
switchToOrFromEditMode();
|
||||||
}
|
}
|
||||||
|
@ -1271,6 +1591,18 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
blurTextView = new TextView(context);
|
||||||
|
blurTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||||
|
blurTextView.setTextColor(0xffffffff);
|
||||||
|
blurTextView.setText(LocaleController.getString("Blur", R.string.Blur));
|
||||||
|
frameLayout.addView(blurTextView);
|
||||||
|
layoutParams = (LayoutParams) blurTextView.getLayoutParams();
|
||||||
|
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||||
|
layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
|
||||||
|
layoutParams.topMargin = AndroidUtilities.dp(9);
|
||||||
|
blurTextView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
paramTextView = new TextView(context);
|
paramTextView = new TextView(context);
|
||||||
paramTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
paramTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
||||||
paramTextView.setTextColor(0xff808080);
|
paramTextView.setTextColor(0xff808080);
|
||||||
|
@ -1321,12 +1653,12 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
}
|
}
|
||||||
updateValueTextView();
|
updateValueTextView();
|
||||||
if (eglThread != null) {
|
if (eglThread != null) {
|
||||||
eglThread.requestRender();
|
eglThread.requestRender(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
editView.addView(valueSeekBar);
|
editView.addView(valueSeekBar);
|
||||||
layoutParams = (FrameLayout.LayoutParams) valueSeekBar.getLayoutParams();
|
layoutParams = (LayoutParams) valueSeekBar.getLayoutParams();
|
||||||
layoutParams.height = AndroidUtilities.dp(60);
|
layoutParams.height = AndroidUtilities.dp(60);
|
||||||
layoutParams.leftMargin = AndroidUtilities.dp(14);
|
layoutParams.leftMargin = AndroidUtilities.dp(14);
|
||||||
layoutParams.rightMargin = AndroidUtilities.dp(14);
|
layoutParams.rightMargin = AndroidUtilities.dp(14);
|
||||||
|
@ -1339,6 +1671,113 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
||||||
}
|
}
|
||||||
valueSeekBar.setLayoutParams(layoutParams);
|
valueSeekBar.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
blurLayout = new FrameLayout(context);
|
||||||
|
editView.addView(blurLayout);
|
||||||
|
layoutParams = (LayoutParams) blurLayout.getLayoutParams();
|
||||||
|
layoutParams.width = AndroidUtilities.dp(280);
|
||||||
|
layoutParams.height = AndroidUtilities.dp(60);
|
||||||
|
layoutParams.topMargin = AndroidUtilities.dp(10);
|
||||||
|
layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
|
||||||
|
blurLayout.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
blurOffButton = new TextView(context);
|
||||||
|
blurOffButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_off_active, 0, 0);
|
||||||
|
blurOffButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
||||||
|
blurOffButton.setTextColor(0xff51bdf3);
|
||||||
|
blurOffButton.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
|
blurOffButton.setText(LocaleController.getString("BlurOff", R.string.BlurOff));
|
||||||
|
blurLayout.addView(blurOffButton);
|
||||||
|
layoutParams = (LayoutParams) blurOffButton.getLayoutParams();
|
||||||
|
layoutParams.width = AndroidUtilities.dp(80);
|
||||||
|
layoutParams.height = AndroidUtilities.dp(60);
|
||||||
|
blurOffButton.setLayoutParams(layoutParams);
|
||||||
|
blurOffButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
blurType = 0;
|
||||||
|
updateSelectedBlurType();
|
||||||
|
blurControl.setVisibility(INVISIBLE);
|
||||||
|
if (eglThread != null) {
|
||||||
|
eglThread.requestRender(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
blurRadialButton = new TextView(context);
|
||||||
|
blurRadialButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_radial, 0, 0);
|
||||||
|
blurRadialButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
||||||
|
blurRadialButton.setTextColor(0xffffffff);
|
||||||
|
blurRadialButton.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
|
blurRadialButton.setText(LocaleController.getString("BlurRadial", R.string.BlurRadial));
|
||||||
|
blurLayout.addView(blurRadialButton);
|
||||||
|
layoutParams = (LayoutParams) blurRadialButton.getLayoutParams();
|
||||||
|
layoutParams.width = AndroidUtilities.dp(80);
|
||||||
|
layoutParams.height = AndroidUtilities.dp(60);
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(100);
|
||||||
|
blurRadialButton.setLayoutParams(layoutParams);
|
||||||
|
blurRadialButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
blurType = 1;
|
||||||
|
updateSelectedBlurType();
|
||||||
|
blurControl.setVisibility(VISIBLE);
|
||||||
|
blurControl.setType(1);
|
||||||
|
if (eglThread != null) {
|
||||||
|
eglThread.requestRender(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
blurLinearButton = new TextView(context);
|
||||||
|
blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_linear, 0, 0);
|
||||||
|
blurLinearButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
||||||
|
blurLinearButton.setTextColor(0xffffffff);
|
||||||
|
blurLinearButton.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
|
blurLinearButton.setText(LocaleController.getString("BlurLinear", R.string.BlurLinear));
|
||||||
|
blurLayout.addView(blurLinearButton);
|
||||||
|
layoutParams = (LayoutParams) blurLinearButton.getLayoutParams();
|
||||||
|
layoutParams.width = AndroidUtilities.dp(80);
|
||||||
|
layoutParams.height = AndroidUtilities.dp(60);
|
||||||
|
layoutParams.leftMargin = AndroidUtilities.dp(200);
|
||||||
|
blurLinearButton.setLayoutParams(layoutParams);
|
||||||
|
blurLinearButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
blurType = 2;
|
||||||
|
updateSelectedBlurType();
|
||||||
|
blurControl.setVisibility(VISIBLE);
|
||||||
|
blurControl.setType(0);
|
||||||
|
if (eglThread != null) {
|
||||||
|
eglThread.requestRender(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSelectedBlurType() {
|
||||||
|
if (blurType == 0) {
|
||||||
|
blurOffButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_off_active, 0, 0);
|
||||||
|
blurOffButton.setTextColor(0xff51bdf3);
|
||||||
|
blurRadialButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_radial, 0, 0);
|
||||||
|
blurRadialButton.setTextColor(0xffffffff);
|
||||||
|
blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_linear, 0, 0);
|
||||||
|
blurLinearButton.setTextColor(0xffffffff);
|
||||||
|
} else if (blurType == 1) {
|
||||||
|
blurOffButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_off, 0, 0);
|
||||||
|
blurOffButton.setTextColor(0xffffffff);
|
||||||
|
blurRadialButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_radial_active, 0, 0);
|
||||||
|
blurRadialButton.setTextColor(0xff51bdf3);
|
||||||
|
blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_linear, 0, 0);
|
||||||
|
blurLinearButton.setTextColor(0xffffffff);
|
||||||
|
} else if (blurType == 2) {
|
||||||
|
blurOffButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_off, 0, 0);
|
||||||
|
blurOffButton.setTextColor(0xffffffff);
|
||||||
|
blurRadialButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_radial, 0, 0);
|
||||||
|
blurRadialButton.setTextColor(0xffffffff);
|
||||||
|
blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.blur_linear_active, 0, 0);
|
||||||
|
blurLinearButton.setTextColor(0xff51bdf3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateValueTextView() {
|
private void updateValueTextView() {
|
||||||
|
@ -1387,13 +1826,13 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowOriginal(boolean value) {
|
private void setShowOriginal(boolean value) {
|
||||||
if (showOriginal == value) {
|
if (showOriginal == value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showOriginal = value;
|
showOriginal = value;
|
||||||
if (eglThread != null) {
|
if (eglThread != null) {
|
||||||
eglThread.requestRender();
|
eglThread.requestRender(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1403,10 +1842,30 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
if (editView.getVisibility() == GONE) {
|
if (editView.getVisibility() == GONE) {
|
||||||
viewFrom = toolsView;
|
viewFrom = toolsView;
|
||||||
viewTo = editView;
|
viewTo = editView;
|
||||||
|
|
||||||
|
if (selectedTool == blurTool) {
|
||||||
|
blurLayout.setVisibility(VISIBLE);
|
||||||
|
valueSeekBar.setVisibility(INVISIBLE);
|
||||||
|
blurTextView.setVisibility(VISIBLE);
|
||||||
|
paramTextView.setVisibility(INVISIBLE);
|
||||||
|
valueTextView.setVisibility(INVISIBLE);
|
||||||
|
if (blurType != 0) {
|
||||||
|
blurControl.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
updateSelectedBlurType();
|
||||||
|
} else {
|
||||||
|
blurLayout.setVisibility(INVISIBLE);
|
||||||
|
valueSeekBar.setVisibility(VISIBLE);
|
||||||
|
blurTextView.setVisibility(INVISIBLE);
|
||||||
|
paramTextView.setVisibility(VISIBLE);
|
||||||
|
valueTextView.setVisibility(VISIBLE);
|
||||||
|
blurControl.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
selectedTool = -1;
|
selectedTool = -1;
|
||||||
viewFrom = editView;
|
viewFrom = editView;
|
||||||
viewTo = toolsView;
|
viewTo = toolsView;
|
||||||
|
blurControl.setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||||
|
@ -1495,6 +1954,11 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
layoutParams.height = (int) bitmapH;
|
layoutParams.height = (int) bitmapH;
|
||||||
textureView.setLayoutParams(layoutParams);
|
textureView.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
blurControl.setActualAreaSize(layoutParams.width, layoutParams.height);
|
||||||
|
layoutParams = (LayoutParams) blurControl.getLayoutParams();
|
||||||
|
layoutParams.height = viewHeight + AndroidUtilities.dp(28);
|
||||||
|
blurControl.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
int total = AndroidUtilities.dp(86) * 10;
|
int total = AndroidUtilities.dp(86) * 10;
|
||||||
layoutParams = (FrameLayout.LayoutParams) recyclerListView.getLayoutParams();
|
layoutParams = (FrameLayout.LayoutParams) recyclerListView.getLayoutParams();
|
||||||
|
@ -1613,7 +2077,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return 10;
|
return 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1651,7 +2115,13 @@ public class PhotoFilterView extends FrameLayout {
|
||||||
} else if (i == sharpenTool) {
|
} else if (i == sharpenTool) {
|
||||||
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_details, LocaleController.getString("Sharpen", R.string.Sharpen), sharpenValue);
|
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_details, LocaleController.getString("Sharpen", R.string.Sharpen), sharpenValue);
|
||||||
} else if (i == blurTool) {
|
} else if (i == blurTool) {
|
||||||
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_details, LocaleController.getString("Blur", R.string.Blur), 0); //TODO add value
|
String value = "";
|
||||||
|
if (blurType == 1) {
|
||||||
|
value = "R";
|
||||||
|
} else if (blurType == 2) {
|
||||||
|
value = "L";
|
||||||
|
}
|
||||||
|
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_blur, LocaleController.getString("Blur", R.string.Blur), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,16 @@
|
||||||
|
|
||||||
package org.telegram.ui.Components;
|
package org.telegram.ui.Components;
|
||||||
|
|
||||||
public class PhotoFilterRadialBlurControl {
|
public class Point {
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
|
||||||
|
public Point() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point(float x, float y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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.ui.Components;
|
||||||
|
|
||||||
|
public class Rect {
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float width;
|
||||||
|
public float height;
|
||||||
|
|
||||||
|
public Rect(float x, float y, float width, float height) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ import android.view.View;
|
||||||
public class RecyclerListView extends RecyclerView {
|
public class RecyclerListView extends RecyclerView {
|
||||||
|
|
||||||
public interface OnItemClickListener {
|
public interface OnItemClickListener {
|
||||||
public void onItemClick(View view, int position);
|
void onItemClick(View view, int position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RecyclerListViewItemClickListener implements RecyclerView.OnItemTouchListener {
|
public static class RecyclerListViewItemClickListener implements RecyclerView.OnItemTouchListener {
|
||||||
|
|
|
@ -19,8 +19,8 @@ import org.telegram.messenger.R;
|
||||||
|
|
||||||
public class SeekBar {
|
public class SeekBar {
|
||||||
|
|
||||||
public abstract interface SeekBarDelegate {
|
public interface SeekBarDelegate {
|
||||||
public void onSeekBarDrag(float progress);
|
void onSeekBarDrag(float progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable thumbDrawable1;
|
private static Drawable thumbDrawable1;
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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.ui.Components;
|
||||||
|
|
||||||
|
public class Size {
|
||||||
|
public float width;
|
||||||
|
public float height;
|
||||||
|
|
||||||
|
public Size() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Size(float width, float height) {
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
package org.telegram.ui.Components;
|
package org.telegram.ui.Components;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
@ -26,8 +27,8 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
|
||||||
private int keyboardHeight;
|
private int keyboardHeight;
|
||||||
private SizeNotifierRelativeLayoutDelegate delegate;
|
private SizeNotifierRelativeLayoutDelegate delegate;
|
||||||
|
|
||||||
public abstract interface SizeNotifierRelativeLayoutDelegate {
|
public interface SizeNotifierRelativeLayoutDelegate {
|
||||||
public abstract void onSizeChanged(int keyboardHeight);
|
void onSizeChanged(int keyboardHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SizeNotifierRelativeLayout(Context context) {
|
public SizeNotifierRelativeLayout(Context context) {
|
||||||
|
@ -62,16 +63,24 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("DrawAllocation")
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
super.onLayout(changed, l, t, r, b);
|
if (changed && delegate != null) {
|
||||||
if (delegate != null) {
|
|
||||||
View rootView = this.getRootView();
|
View rootView = this.getRootView();
|
||||||
int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
|
int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
|
||||||
this.getWindowVisibleDisplayFrame(rect);
|
this.getWindowVisibleDisplayFrame(rect);
|
||||||
keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
||||||
delegate.onSizeChanged(keyboardHeight);
|
post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (delegate != null) {
|
||||||
|
delegate.onSizeChanged(keyboardHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
super.onLayout(changed, l, t, r, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,8 +25,8 @@ import org.telegram.messenger.R;
|
||||||
|
|
||||||
public class SlidingTabView extends LinearLayout {
|
public class SlidingTabView extends LinearLayout {
|
||||||
|
|
||||||
public static interface SlidingTabViewDelegate {
|
public interface SlidingTabViewDelegate {
|
||||||
public abstract void didSelectTab(int tab);
|
void didSelectTab(int tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SlidingTabViewDelegate delegate;
|
private SlidingTabViewDelegate delegate;
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class VideoSeekBarView extends View {
|
||||||
private boolean pressed = false;
|
private boolean pressed = false;
|
||||||
public SeekBarDelegate delegate;
|
public SeekBarDelegate delegate;
|
||||||
|
|
||||||
public abstract interface SeekBarDelegate {
|
public interface SeekBarDelegate {
|
||||||
public void onSeekBarDrag(float progress);
|
void onSeekBarDrag(float progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(Context context) {
|
private void init(Context context) {
|
||||||
|
|
|
@ -48,9 +48,9 @@ public class VideoTimelineView extends View {
|
||||||
private int framesToLoad = 0;
|
private int framesToLoad = 0;
|
||||||
private Drawable pickDrawable = null;
|
private Drawable pickDrawable = null;
|
||||||
|
|
||||||
public abstract interface VideoTimelineViewDelegate {
|
public interface VideoTimelineViewDelegate {
|
||||||
public void onLeftProgressChanged(float progress);
|
void onLeftProgressChanged(float progress);
|
||||||
public void onRifhtProgressChanged(float progress);
|
void onRifhtProgressChanged(float progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(Context context) {
|
private void init(Context context) {
|
||||||
|
|
|
@ -74,6 +74,9 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentDestroy() {
|
public void onFragmentDestroy() {
|
||||||
super.onFragmentDestroy();
|
super.onFragmentDestroy();
|
||||||
|
if (avatarImage != null) {
|
||||||
|
avatarImage.setImageDrawable(null);
|
||||||
|
}
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||||
private boolean allowUsernameSearch = true;
|
private boolean allowUsernameSearch = true;
|
||||||
private ContactsActivityDelegate delegate;
|
private ContactsActivityDelegate delegate;
|
||||||
|
|
||||||
public static interface ContactsActivityDelegate {
|
public interface ContactsActivityDelegate {
|
||||||
public abstract void didSelectContact(TLRPC.User user, String param);
|
void didSelectContact(TLRPC.User user, String param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactsActivity(Bundle args) {
|
public ContactsActivity(Bundle args) {
|
||||||
|
@ -154,7 +154,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchCollapse() {
|
public boolean onSearchCollapse() {
|
||||||
searchListViewAdapter.searchDialogs(null);
|
searchListViewAdapter.searchDialogs(null);
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
|
@ -166,6 +166,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||||
listView.setFastScrollEnabled(true);
|
listView.setFastScrollEnabled(true);
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -416,13 +417,13 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||||
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||||
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
builder.setView(editText);
|
builder.setView(editText);
|
||||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
didSelectResult(user, false, editText.getText().toString());
|
didSelectResult(user, false, editText.getText().toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.Cancel, null);
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
showAlertDialog(builder);
|
showAlertDialog(builder);
|
||||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)editText.getLayoutParams();
|
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)editText.getLayoutParams();
|
||||||
if (layoutParams != null) {
|
if (layoutParams != null) {
|
||||||
|
|
|
@ -36,8 +36,8 @@ import org.telegram.ui.Components.LetterSectionsListView;
|
||||||
|
|
||||||
public class CountrySelectActivity extends BaseFragment {
|
public class CountrySelectActivity extends BaseFragment {
|
||||||
|
|
||||||
public static interface CountrySelectActivityDelegate {
|
public interface CountrySelectActivityDelegate {
|
||||||
public abstract void didSelectCountry(String name);
|
void didSelectCountry(String name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LetterSectionsListView listView;
|
private LetterSectionsListView listView;
|
||||||
|
@ -84,7 +84,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchCollapse() {
|
public boolean onSearchCollapse() {
|
||||||
searchListViewAdapter.search(null);
|
searchListViewAdapter.search(null);
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
|
@ -96,6 +96,8 @@ public class CountrySelectActivity extends BaseFragment {
|
||||||
listView.setVerticalScrollBarEnabled(false);
|
listView.setVerticalScrollBarEnabled(false);
|
||||||
|
|
||||||
emptyTextView.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
emptyTextView.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,9 +51,9 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public class DocumentSelectActivity extends BaseFragment {
|
public class DocumentSelectActivity extends BaseFragment {
|
||||||
|
|
||||||
public static abstract interface DocumentSelectActivityDelegate {
|
public interface DocumentSelectActivityDelegate {
|
||||||
public void didSelectFiles(DocumentSelectActivity activity, ArrayList<String> files);
|
void didSelectFiles(DocumentSelectActivity activity, ArrayList<String> files);
|
||||||
public void startDocumentSelectActivity();
|
void startDocumentSelectActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
|
@ -487,7 +487,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
||||||
if (getParentActivity() == null) {
|
if (getParentActivity() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new AlertDialog.Builder(getParentActivity()).setTitle(LocaleController.getString("AppName", R.string.AppName)).setMessage(error).setPositiveButton(R.string.OK, null).show();
|
new AlertDialog.Builder(getParentActivity()).setTitle(LocaleController.getString("AppName", R.string.AppName)).setMessage(error).setPositiveButton(LocaleController.getString("OK", R.string.OK), null).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listRoots() {
|
private void listRoots() {
|
||||||
|
|
|
@ -61,8 +61,8 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public class GroupCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class GroupCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
|
|
||||||
public static interface GroupCreateActivityDelegate {
|
public interface GroupCreateActivityDelegate {
|
||||||
public abstract void didSelectUsers(ArrayList<Integer> ids);
|
void didSelectUsers(ArrayList<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class XImageSpan extends ImageSpan {
|
private class XImageSpan extends ImageSpan {
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchCollapse() {
|
public boolean onSearchCollapse() {
|
||||||
search(null);
|
search(null);
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
|
@ -86,6 +86,8 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||||
emptyTextView.setVisibility(View.GONE);
|
emptyTextView.setVisibility(View.GONE);
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,8 +40,8 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class LastSeenUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class LastSeenUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
|
|
||||||
public static interface LastSeenUsersActivityDelegate {
|
public interface LastSeenUsersActivityDelegate {
|
||||||
public abstract void didUpdatedUserList(ArrayList<Integer> ids, boolean added);
|
void didUpdatedUserList(ArrayList<Integer> ids, boolean added);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
|
|
|
@ -345,14 +345,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||||
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
|
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
|
||||||
actionBarLayout.addFragmentToStack(new LoginActivity());
|
actionBarLayout.addFragmentToStack(new LoginActivity());
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
} else {
|
} else {
|
||||||
if (UserConfig.isWaitingForPasswordEnter()) {
|
if (UserConfig.isWaitingForPasswordEnter()) {
|
||||||
actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
|
actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
} else {
|
} else {
|
||||||
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
|
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(true);
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
if (actionBarLayout.fragmentsStack.size() == 1 && (actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity || actionBarLayout.fragmentsStack.get(0) instanceof AccountPasswordActivity)) {
|
if (actionBarLayout.fragmentsStack.size() == 1 && (actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity || actionBarLayout.fragmentsStack.get(0) instanceof AccountPasswordActivity)) {
|
||||||
allowOpen = false;
|
allowOpen = false;
|
||||||
}
|
}
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(allowOpen);
|
drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleIntent(getIntent(), false, savedInstanceState != null, false);
|
handleIntent(getIntent(), false, savedInstanceState != null, false);
|
||||||
|
@ -431,7 +431,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
}
|
}
|
||||||
passcodeView.onShow();
|
passcodeView.onShow();
|
||||||
UserConfig.isWaitingForPasscodeEnter = true;
|
UserConfig.isWaitingForPasscodeEnter = true;
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
passcodeView.setDelegate(new PasscodeView.PasscodeViewDelegate() {
|
passcodeView.setDelegate(new PasscodeView.PasscodeViewDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void didAcceptedPassword() {
|
public void didAcceptedPassword() {
|
||||||
|
@ -440,7 +440,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
handleIntent(passcodeSaveIntent, passcodeSaveIntentIsNew, passcodeSaveIntentIsRestore, true);
|
handleIntent(passcodeSaveIntent, passcodeSaveIntentIsNew, passcodeSaveIntentIsRestore, true);
|
||||||
passcodeSaveIntent = null;
|
passcodeSaveIntent = null;
|
||||||
}
|
}
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(true);
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||||
actionBarLayout.showLastFragment();
|
actionBarLayout.showLastFragment();
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
layersActionBarLayout.showLastFragment();
|
layersActionBarLayout.showLastFragment();
|
||||||
|
@ -847,10 +847,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
actionBarLayout.showLastFragment();
|
actionBarLayout.showLastFragment();
|
||||||
rightActionBarLayout.showLastFragment();
|
rightActionBarLayout.showLastFragment();
|
||||||
}
|
}
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
} else if (open_settings != 0) {
|
} else if (open_settings != 0) {
|
||||||
actionBarLayout.presentFragment(new SettingsActivity(), false, true, true);
|
actionBarLayout.presentFragment(new SettingsActivity(), false, true, true);
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
actionBarLayout.showLastFragment();
|
actionBarLayout.showLastFragment();
|
||||||
rightActionBarLayout.showLastFragment();
|
rightActionBarLayout.showLastFragment();
|
||||||
|
@ -863,16 +863,16 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
|
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
|
||||||
if (layersActionBarLayout.fragmentsStack.isEmpty()) {
|
if (layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||||
layersActionBarLayout.addFragmentToStack(new LoginActivity());
|
layersActionBarLayout.addFragmentToStack(new LoginActivity());
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||||
if (UserConfig.isWaitingForPasswordEnter()) {
|
if (UserConfig.isWaitingForPasswordEnter()) {
|
||||||
layersActionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
|
layersActionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
} else {
|
} else {
|
||||||
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
|
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(true);
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -880,14 +880,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||||
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
|
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
|
||||||
actionBarLayout.addFragmentToStack(new LoginActivity());
|
actionBarLayout.addFragmentToStack(new LoginActivity());
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
} else {
|
} else {
|
||||||
if (UserConfig.isWaitingForPasswordEnter()) {
|
if (UserConfig.isWaitingForPasswordEnter()) {
|
||||||
actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
|
actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
} else {
|
} else {
|
||||||
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
|
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(true);
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -954,7 +954,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
actionBarLayout.presentFragment(fragment, true);
|
actionBarLayout.presentFragment(fragment, true);
|
||||||
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id);
|
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
actionBarLayout.presentFragment(fragment, true);
|
actionBarLayout.presentFragment(fragment, true);
|
||||||
|
@ -963,14 +963,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
fragment.processSendingText(sendingText);
|
fragment.processSendingText(sendingText);
|
||||||
}
|
}
|
||||||
if (photoPathsArray != null) {
|
if (photoPathsArray != null) {
|
||||||
SendMessagesHelper.prepareSendingPhotos(null, photoPathsArray, dialog_id);
|
SendMessagesHelper.prepareSendingPhotos(null, photoPathsArray, dialog_id, null);
|
||||||
}
|
}
|
||||||
if (documentsPathsArray != null || documentsUrisArray != null) {
|
if (documentsPathsArray != null || documentsUrisArray != null) {
|
||||||
SendMessagesHelper.prepareSendingDocuments(documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, documentsMimeType, dialog_id);
|
SendMessagesHelper.prepareSendingDocuments(documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, documentsMimeType, dialog_id, null);
|
||||||
}
|
}
|
||||||
if (contactsToSend != null && !contactsToSend.isEmpty()) {
|
if (contactsToSend != null && !contactsToSend.isEmpty()) {
|
||||||
for (TLRPC.User user : contactsToSend) {
|
for (TLRPC.User user : contactsToSend) {
|
||||||
SendMessagesHelper.getInstance().sendMessage(user, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1227,14 +1227,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
rightActionBarLayout.closeLastFragment(false);
|
rightActionBarLayout.closeLastFragment(false);
|
||||||
actionBarLayout.closeLastFragment(false);
|
actionBarLayout.closeLastFragment(false);
|
||||||
layersActionBarLayout.presentFragment(new AccountPasswordActivity(1), false, true, true);
|
layersActionBarLayout.presentFragment(new AccountPasswordActivity(1), false, true, true);
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
} else {
|
} else {
|
||||||
for (int a = 0; a < actionBarLayout.fragmentsStack.size() - 1; a++) {
|
for (int a = 0; a < actionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||||
actionBarLayout.removeFragmentFromStack(actionBarLayout.fragmentsStack.get(0));
|
actionBarLayout.removeFragmentFromStack(actionBarLayout.fragmentsStack.get(0));
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
actionBarLayout.presentFragment(new AccountPasswordActivity(1), true);
|
actionBarLayout.presentFragment(new AccountPasswordActivity(1), true);
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||||
}
|
}
|
||||||
} else if (id == NotificationCenter.screenStateChanged) {
|
} else if (id == NotificationCenter.screenStateChanged) {
|
||||||
if (!ApplicationLoader.mainInterfacePaused) {
|
if (!ApplicationLoader.mainInterfacePaused) {
|
||||||
|
@ -1448,15 +1448,15 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
@Override
|
@Override
|
||||||
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
|
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof AccountPasswordActivity) && !(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE);
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof AccountPasswordActivity) && !(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
|
||||||
if (fragment instanceof MessagesActivity) {
|
if (fragment instanceof MessagesActivity) {
|
||||||
MessagesActivity messagesActivity = (MessagesActivity)fragment;
|
MessagesActivity messagesActivity = (MessagesActivity)fragment;
|
||||||
if (messagesActivity.getDelegate() == null && layout != actionBarLayout) {
|
if (messagesActivity.isMainDialogList() && layout != actionBarLayout) {
|
||||||
actionBarLayout.removeAllFragments();
|
actionBarLayout.removeAllFragments();
|
||||||
actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
|
actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
|
||||||
layersActionBarLayout.removeAllFragments();
|
layersActionBarLayout.removeAllFragments();
|
||||||
layersActionBarLayout.setVisibility(View.GONE);
|
layersActionBarLayout.setVisibility(View.GONE);
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(true);
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||||
if (!tabletFullSize) {
|
if (!tabletFullSize) {
|
||||||
shadowTabletSide.setVisibility(View.VISIBLE);
|
shadowTabletSide.setVisibility(View.VISIBLE);
|
||||||
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||||
|
@ -1516,7 +1516,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
}
|
}
|
||||||
} else if (layout != layersActionBarLayout) {
|
} else if (layout != layersActionBarLayout) {
|
||||||
layersActionBarLayout.setVisibility(View.VISIBLE);
|
layersActionBarLayout.setVisibility(View.VISIBLE);
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, true);
|
||||||
if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) {
|
if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) {
|
||||||
backgroundTablet.setVisibility(View.VISIBLE);
|
backgroundTablet.setVisibility(View.VISIBLE);
|
||||||
shadowTabletSide.setVisibility(View.GONE);
|
shadowTabletSide.setVisibility(View.GONE);
|
||||||
|
@ -1529,7 +1529,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity));
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity), false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1537,15 +1537,15 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
@Override
|
@Override
|
||||||
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
|
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE);
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
|
||||||
if (fragment instanceof MessagesActivity) {
|
if (fragment instanceof MessagesActivity) {
|
||||||
MessagesActivity messagesActivity = (MessagesActivity)fragment;
|
MessagesActivity messagesActivity = (MessagesActivity)fragment;
|
||||||
if (messagesActivity.getDelegate() == null && layout != actionBarLayout) {
|
if (messagesActivity.isMainDialogList() && layout != actionBarLayout) {
|
||||||
actionBarLayout.removeAllFragments();
|
actionBarLayout.removeAllFragments();
|
||||||
actionBarLayout.addFragmentToStack(fragment);
|
actionBarLayout.addFragmentToStack(fragment);
|
||||||
layersActionBarLayout.removeAllFragments();
|
layersActionBarLayout.removeAllFragments();
|
||||||
layersActionBarLayout.setVisibility(View.GONE);
|
layersActionBarLayout.setVisibility(View.GONE);
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(true);
|
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||||
if (!tabletFullSize) {
|
if (!tabletFullSize) {
|
||||||
shadowTabletSide.setVisibility(View.VISIBLE);
|
shadowTabletSide.setVisibility(View.VISIBLE);
|
||||||
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||||
|
@ -1581,7 +1581,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
}
|
}
|
||||||
} else if (layout != layersActionBarLayout) {
|
} else if (layout != layersActionBarLayout) {
|
||||||
layersActionBarLayout.setVisibility(View.VISIBLE);
|
layersActionBarLayout.setVisibility(View.VISIBLE);
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(false);
|
drawerLayoutContainer.setAllowOpenDrawer(false, true);
|
||||||
if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) {
|
if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) {
|
||||||
backgroundTablet.setVisibility(View.VISIBLE);
|
backgroundTablet.setVisibility(View.VISIBLE);
|
||||||
shadowTabletSide.setVisibility(View.GONE);
|
shadowTabletSide.setVisibility(View.GONE);
|
||||||
|
@ -1594,7 +1594,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity));
|
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity), false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||||
private final static int map_list_menu_satellite = 3;
|
private final static int map_list_menu_satellite = 3;
|
||||||
private final static int map_list_menu_hybrid = 4;
|
private final static int map_list_menu_hybrid = 4;
|
||||||
|
|
||||||
public static interface LocationActivityDelegate {
|
public interface LocationActivityDelegate {
|
||||||
public abstract void didSelectLocation(double latitude, double longitude);
|
void didSelectLocation(double latitude, double longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,6 +88,9 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||||
if (mapView != null) {
|
if (mapView != null) {
|
||||||
mapView.onDestroy();
|
mapView.onDestroy();
|
||||||
}
|
}
|
||||||
|
if (avatarImageView != null) {
|
||||||
|
avatarImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -268,7 +271,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||||
private void updateUserData() {
|
private void updateUserData() {
|
||||||
if (messageObject != null && avatarImageView != null) {
|
if (messageObject != null && avatarImageView != null) {
|
||||||
int fromId = messageObject.messageOwner.from_id;
|
int fromId = messageObject.messageOwner.from_id;
|
||||||
if (messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
if (messageObject.isForwarded()) {
|
||||||
fromId = messageObject.messageOwner.fwd_from_id;
|
fromId = messageObject.messageOwner.fwd_from_id;
|
||||||
}
|
}
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(fromId);
|
TLRPC.User user = MessagesController.getInstance().getUser(fromId);
|
||||||
|
@ -279,6 +282,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||||
}
|
}
|
||||||
avatarImageView.setImage(photo, null, new AvatarDrawable(user));
|
avatarImageView.setImage(photo, null, new AvatarDrawable(user));
|
||||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||||
|
} else {
|
||||||
|
avatarImageView.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ import android.widget.TextView;
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
import org.telegram.android.LocaleController;
|
import org.telegram.android.LocaleController;
|
||||||
import org.telegram.android.MessagesController;
|
import org.telegram.android.MessagesController;
|
||||||
import org.telegram.android.SendMessagesHelper;
|
|
||||||
import org.telegram.android.query.SharedMediaQuery;
|
import org.telegram.android.query.SharedMediaQuery;
|
||||||
import org.telegram.messenger.ApplicationLoader;
|
import org.telegram.messenger.ApplicationLoader;
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
|
@ -118,7 +117,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
private int max_id;
|
private int max_id;
|
||||||
|
|
||||||
public boolean addMessage(MessageObject messageObject, boolean isNew, boolean enc) {
|
public boolean addMessage(MessageObject messageObject, boolean isNew, boolean enc) {
|
||||||
if (messagesDict.containsKey(messageObject.messageOwner.id)) {
|
if (messagesDict.containsKey(messageObject.getId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayList<MessageObject> messageObjects = sectionArrays.get(messageObject.monthKey);
|
ArrayList<MessageObject> messageObjects = sectionArrays.get(messageObject.monthKey);
|
||||||
|
@ -138,13 +137,13 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
messageObjects.add(messageObject);
|
messageObjects.add(messageObject);
|
||||||
messages.add(messageObject);
|
messages.add(messageObject);
|
||||||
}
|
}
|
||||||
messagesDict.put(messageObject.messageOwner.id, messageObject);
|
messagesDict.put(messageObject.getId(), messageObject);
|
||||||
if (!enc) {
|
if (!enc) {
|
||||||
if (messageObject.messageOwner.id > 0) {
|
if (messageObject.getId() > 0) {
|
||||||
max_id = Math.min(messageObject.messageOwner.id, max_id);
|
max_id = Math.min(messageObject.getId(), max_id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
max_id = Math.max(messageObject.messageOwner.id, max_id);
|
max_id = Math.max(messageObject.getId(), max_id);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +159,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
}
|
}
|
||||||
messageObjects.remove(messageObject);
|
messageObjects.remove(messageObject);
|
||||||
messages.remove(messageObject);
|
messages.remove(messageObject);
|
||||||
messagesDict.remove(messageObject.messageOwner.id);
|
messagesDict.remove(messageObject.getId());
|
||||||
if (messageObjects.isEmpty()) {
|
if (messageObjects.isEmpty()) {
|
||||||
sectionArrays.remove(messageObject.monthKey);
|
sectionArrays.remove(messageObject.monthKey);
|
||||||
sections.remove(messageObject.monthKey);
|
sections.remove(messageObject.monthKey);
|
||||||
|
@ -285,8 +284,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean("onlySelect", true);
|
args.putBoolean("onlySelect", true);
|
||||||
args.putBoolean("serverOnly", true);
|
args.putBoolean("serverOnly", true);
|
||||||
args.putString("selectAlertString", LocaleController.getString("ForwardMessagesTo", R.string.ForwardMessagesTo));
|
|
||||||
args.putString("selectAlertStringGroup", LocaleController.getString("ForwardMessagesToGroup", R.string.ForwardMessagesToGroup));
|
|
||||||
MessagesActivity fragment = new MessagesActivity(args);
|
MessagesActivity fragment = new MessagesActivity(args);
|
||||||
fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
|
fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -301,11 +298,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
args.putInt("chat_id", -lower_part);
|
args.putInt("chat_id", -lower_part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<MessageObject> fmessages = new ArrayList<>();
|
||||||
ArrayList<Integer> ids = new ArrayList<>(selectedFiles.keySet());
|
ArrayList<Integer> ids = new ArrayList<>(selectedFiles.keySet());
|
||||||
Collections.sort(ids);
|
Collections.sort(ids);
|
||||||
for (Integer id : ids) {
|
for (Integer id : ids) {
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
SendMessagesHelper.getInstance().sendMessage(selectedFiles.get(id), did);
|
fmessages.add(selectedFiles.get(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selectedFiles.clear();
|
selectedFiles.clear();
|
||||||
|
@ -314,6 +312,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||||
ChatActivity chatActivity = new ChatActivity(args);
|
ChatActivity chatActivity = new ChatActivity(args);
|
||||||
presentFragment(chatActivity, true);
|
presentFragment(chatActivity, true);
|
||||||
|
chatActivity.showReplyForMessageObjectOrForward(true, null, fmessages, false);
|
||||||
|
|
||||||
if (!AndroidUtilities.isTablet()) {
|
if (!AndroidUtilities.isTablet()) {
|
||||||
removeSelfFromStack();
|
removeSelfFromStack();
|
||||||
|
@ -347,12 +346,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchCollapse() {
|
public boolean onSearchCollapse() {
|
||||||
dropDownContainer.setVisibility(View.VISIBLE);
|
dropDownContainer.setVisibility(View.VISIBLE);
|
||||||
documentsSearchAdapter.searchDocuments(null);
|
documentsSearchAdapter.searchDocuments(null);
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
switchToCurrentSelectedMode();
|
switchToCurrentSelectedMode();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -734,7 +735,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BackupImageView imageView = cell.getImageView(i);
|
BackupImageView imageView = cell.getImageView(i);
|
||||||
if (message.messageOwner.id == messageObject.messageOwner.id) {
|
if (message.getId() == messageObject.getId()) {
|
||||||
int coords[] = new int[2];
|
int coords[] = new int[2];
|
||||||
imageView.getLocationInWindow(coords);
|
imageView.getLocationInWindow(coords);
|
||||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||||
|
@ -836,7 +837,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
if (actionBar.isActionModeShowed()) {
|
if (actionBar.isActionModeShowed()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
selectedFiles.put(item.messageOwner.id, item);
|
selectedFiles.put(item.getId(), item);
|
||||||
selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
|
selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size()));
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||||
|
@ -869,10 +870,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (actionBar.isActionModeShowed()) {
|
if (actionBar.isActionModeShowed()) {
|
||||||
if (selectedFiles.containsKey(message.messageOwner.id)) {
|
if (selectedFiles.containsKey(message.getId())) {
|
||||||
selectedFiles.remove(message.messageOwner.id);
|
selectedFiles.remove(message.getId());
|
||||||
} else {
|
} else {
|
||||||
selectedFiles.put(message.messageOwner.id, message);
|
selectedFiles.put(message.getId(), message);
|
||||||
}
|
}
|
||||||
if (selectedFiles.isEmpty()) {
|
if (selectedFiles.isEmpty()) {
|
||||||
actionBar.hideActionMode();
|
actionBar.hideActionMode();
|
||||||
|
@ -881,9 +882,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
}
|
}
|
||||||
scrolling = false;
|
scrolling = false;
|
||||||
if (view instanceof SharedDocumentCell) {
|
if (view instanceof SharedDocumentCell) {
|
||||||
((SharedDocumentCell) view).setChecked(selectedFiles.containsKey(message.messageOwner.id), true);
|
((SharedDocumentCell) view).setChecked(selectedFiles.containsKey(message.getId()), true);
|
||||||
} else if (view instanceof SharedPhotoVideoCell) {
|
} else if (view instanceof SharedPhotoVideoCell) {
|
||||||
((SharedPhotoVideoCell) view).setChecked(a, selectedFiles.containsKey(message.messageOwner.id), true);
|
((SharedPhotoVideoCell) view).setChecked(a, selectedFiles.containsKey(message.getId()), true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (selectedMode == 0) {
|
if (selectedMode == 0) {
|
||||||
|
@ -1056,7 +1057,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
MessageObject messageObject = messageObjects.get(position - 1);
|
MessageObject messageObject = messageObjects.get(position - 1);
|
||||||
sharedDocumentCell.setDocument(messageObject, position != messageObjects.size() || section == sharedMediaData[1].sections.size() - 1 && sharedMediaData[1].loading);
|
sharedDocumentCell.setDocument(messageObject, position != messageObjects.size() || section == sharedMediaData[1].sections.size() - 1 && sharedMediaData[1].loading);
|
||||||
if (actionBar.isActionModeShowed()) {
|
if (actionBar.isActionModeShowed()) {
|
||||||
sharedDocumentCell.setChecked(selectedFiles.containsKey(messageObject.messageOwner.id), !scrolling);
|
sharedDocumentCell.setChecked(selectedFiles.containsKey(messageObject.getId()), !scrolling);
|
||||||
} else {
|
} else {
|
||||||
sharedDocumentCell.setChecked(false, !scrolling);
|
sharedDocumentCell.setChecked(false, !scrolling);
|
||||||
}
|
}
|
||||||
|
@ -1176,7 +1177,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
cell.setItem(a, sharedMediaData[0].messages.indexOf(messageObject), messageObject);
|
cell.setItem(a, sharedMediaData[0].messages.indexOf(messageObject), messageObject);
|
||||||
|
|
||||||
if (actionBar.isActionModeShowed()) {
|
if (actionBar.isActionModeShowed()) {
|
||||||
cell.setChecked(a, selectedFiles.containsKey(messageObject.messageOwner.id), !scrolling);
|
cell.setChecked(a, selectedFiles.containsKey(messageObject.getId()), !scrolling);
|
||||||
} else {
|
} else {
|
||||||
cell.setChecked(a, false, !scrolling);
|
cell.setChecked(a, false, !scrolling);
|
||||||
}
|
}
|
||||||
|
@ -1184,6 +1185,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
cell.setItem(a, index, null);
|
cell.setItem(a, index, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cell.requestLayout();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
|
@ -1317,7 +1319,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!sharedMediaData[1].messages.isEmpty()) {
|
if (!sharedMediaData[1].messages.isEmpty()) {
|
||||||
MessageObject messageObject = sharedMediaData[1].messages.get(sharedMediaData[1].messages.size() - 1);
|
MessageObject messageObject = sharedMediaData[1].messages.get(sharedMediaData[1].messages.size() - 1);
|
||||||
queryServerSearch(query, messageObject.messageOwner.id);
|
queryServerSearch(query, messageObject.getId());
|
||||||
}
|
}
|
||||||
final ArrayList<MessageObject> copy = new ArrayList<>();
|
final ArrayList<MessageObject> copy = new ArrayList<>();
|
||||||
copy.addAll(sharedMediaData[1].messages);
|
copy.addAll(sharedMediaData[1].messages);
|
||||||
|
@ -1431,7 +1433,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||||
MessageObject messageObject = getItem(i);
|
MessageObject messageObject = getItem(i);
|
||||||
sharedDocumentCell.setDocument(messageObject, i != getCount() - 1);
|
sharedDocumentCell.setDocument(messageObject, i != getCount() - 1);
|
||||||
if (actionBar.isActionModeShowed()) {
|
if (actionBar.isActionModeShowed()) {
|
||||||
sharedDocumentCell.setChecked(selectedFiles.containsKey(messageObject.messageOwner.id), !scrolling);
|
sharedDocumentCell.setChecked(selectedFiles.containsKey(messageObject.getId()), !scrolling);
|
||||||
} else {
|
} else {
|
||||||
sharedDocumentCell.setChecked(false, !scrolling);
|
sharedDocumentCell.setChecked(false, !scrolling);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
private boolean searchWas = false;
|
private boolean searchWas = false;
|
||||||
private boolean onlySelect = false;
|
private boolean onlySelect = false;
|
||||||
private long selectedDialog;
|
private long selectedDialog;
|
||||||
|
private String searchString;
|
||||||
|
|
||||||
private MessagesActivityDelegate delegate;
|
private MessagesActivityDelegate delegate;
|
||||||
|
|
||||||
|
@ -90,8 +91,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
|
|
||||||
private static final int passcode_menu_item = 1;
|
private static final int passcode_menu_item = 1;
|
||||||
|
|
||||||
public static interface MessagesActivityDelegate {
|
public interface MessagesActivityDelegate {
|
||||||
public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id, boolean param);
|
void didSelectDialog(MessagesActivity fragment, long dialog_id, boolean param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagesActivity(Bundle args) {
|
public MessagesActivity(Bundle args) {
|
||||||
|
@ -101,18 +102,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
@Override
|
@Override
|
||||||
public boolean onFragmentCreate() {
|
public boolean onFragmentCreate() {
|
||||||
super.onFragmentCreate();
|
super.onFragmentCreate();
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogsNeedReload);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.openedChatChanged);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageReceivedByAck);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageReceivedByServer);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageSendError);
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didSetPasscode);
|
|
||||||
|
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
onlySelect = arguments.getBoolean("onlySelect", false);
|
onlySelect = arguments.getBoolean("onlySelect", false);
|
||||||
|
@ -120,6 +109,23 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
selectAlertString = arguments.getString("selectAlertString");
|
selectAlertString = arguments.getString("selectAlertString");
|
||||||
selectAlertStringGroup = arguments.getString("selectAlertStringGroup");
|
selectAlertStringGroup = arguments.getString("selectAlertStringGroup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (searchString == null) {
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogsNeedReload);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.openedChatChanged);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageReceivedByAck);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageReceivedByServer);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageSendError);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didSetPasscode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!dialogsLoaded) {
|
if (!dialogsLoaded) {
|
||||||
MessagesController.getInstance().loadDialogs(0, 0, 100, true);
|
MessagesController.getInstance().loadDialogs(0, 0, 100, true);
|
||||||
ContactsController.getInstance().checkInviteText();
|
ContactsController.getInstance().checkInviteText();
|
||||||
|
@ -131,18 +137,20 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentDestroy() {
|
public void onFragmentDestroy() {
|
||||||
super.onFragmentDestroy();
|
super.onFragmentDestroy();
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.dialogsNeedReload);
|
if (searchString == null) {
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.dialogsNeedReload);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.openedChatChanged);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.openedChatChanged);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageReceivedByAck);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageReceivedByServer);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageReceivedByAck);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageSendError);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageReceivedByServer);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didSetPasscode);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageSendError);
|
||||||
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didSetPasscode);
|
||||||
|
}
|
||||||
delegate = null;
|
delegate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +161,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
|
|
||||||
ActionBarMenu menu = actionBar.createMenu();
|
ActionBarMenu menu = actionBar.createMenu();
|
||||||
if (!onlySelect) {
|
if (!onlySelect && searchString == null) {
|
||||||
passcodeItem = menu.addItem(passcode_menu_item, R.drawable.lock_close);
|
passcodeItem = menu.addItem(passcode_menu_item, R.drawable.lock_close);
|
||||||
updatePasscodeButton();
|
updatePasscodeButton();
|
||||||
}
|
}
|
||||||
|
@ -162,9 +170,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
public void onSearchExpand() {
|
public void onSearchExpand() {
|
||||||
searching = true;
|
searching = true;
|
||||||
if (messagesListView != null) {
|
if (messagesListView != null) {
|
||||||
messagesListView.setEmptyView(searchEmptyView);
|
if (searchString != null) {
|
||||||
|
messagesListView.setEmptyView(progressView);
|
||||||
|
searchEmptyView.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
messagesListView.setEmptyView(searchEmptyView);
|
||||||
|
progressView.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
emptyView.setVisibility(View.INVISIBLE);
|
emptyView.setVisibility(View.INVISIBLE);
|
||||||
progressView.setVisibility(View.INVISIBLE);
|
|
||||||
if (!onlySelect) {
|
if (!onlySelect) {
|
||||||
floatingButton.setVisibility(View.GONE);
|
floatingButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +186,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchCollapse() {
|
public boolean onSearchCollapse() {
|
||||||
|
if (searchString != null) {
|
||||||
|
finishFragment();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
searching = false;
|
searching = false;
|
||||||
searchWas = false;
|
searchWas = false;
|
||||||
if (messagesListView != null) {
|
if (messagesListView != null) {
|
||||||
|
@ -202,6 +219,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
dialogsSearchAdapter.searchDialogs(null, false);
|
dialogsSearchAdapter.searchDialogs(null, false);
|
||||||
}
|
}
|
||||||
updatePasscodeButton();
|
updatePasscodeButton();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -229,7 +247,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
||||||
} else {
|
} else {
|
||||||
actionBar.setBackButtonDrawable(new MenuDrawable());
|
if (searchString != null) {
|
||||||
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
|
} else {
|
||||||
|
actionBar.setBackButtonDrawable(new MenuDrawable());
|
||||||
|
}
|
||||||
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
}
|
}
|
||||||
actionBar.setAllowOverlayTitle(true);
|
actionBar.setAllowOverlayTitle(true);
|
||||||
|
@ -253,11 +275,19 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
|
|
||||||
fragmentView = inflater.inflate(R.layout.messages_list, null, false);
|
fragmentView = inflater.inflate(R.layout.messages_list, null, false);
|
||||||
|
|
||||||
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
|
if (searchString == null) {
|
||||||
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
|
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
|
||||||
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
|
||||||
|
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity(), !onlySelect);
|
int type = 0;
|
||||||
|
if (searchString != null) {
|
||||||
|
type = 2;
|
||||||
|
} else if (!onlySelect) {
|
||||||
|
type = 1;
|
||||||
|
}
|
||||||
|
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity(), type);
|
||||||
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
|
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void searchStateChanged(boolean search) {
|
public void searchStateChanged(boolean search) {
|
||||||
|
@ -270,13 +300,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
});
|
});
|
||||||
|
|
||||||
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
||||||
messagesListView.setAdapter(dialogsAdapter);
|
if (dialogsAdapter != null) {
|
||||||
|
messagesListView.setAdapter(dialogsAdapter);
|
||||||
|
}
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
messagesListView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
messagesListView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
progressView = fragmentView.findViewById(R.id.progressLayout);
|
progressView = fragmentView.findViewById(R.id.progressLayout);
|
||||||
dialogsAdapter.notifyDataSetChanged();
|
|
||||||
searchEmptyView = fragmentView.findViewById(R.id.search_empty_view);
|
searchEmptyView = fragmentView.findViewById(R.id.search_empty_view);
|
||||||
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
|
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -296,7 +327,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1);
|
TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1);
|
||||||
textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
|
textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
|
||||||
textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2);
|
textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2);
|
||||||
textView.setText(LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp));
|
String help = LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp);
|
||||||
|
if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) {
|
||||||
|
help = help.replace("\n", " ");
|
||||||
|
}
|
||||||
|
textView.setText(help);
|
||||||
textView = (TextView)fragmentView.findViewById(R.id.search_empty_text);
|
textView = (TextView)fragmentView.findViewById(R.id.search_empty_text);
|
||||||
textView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
textView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||||
|
|
||||||
|
@ -375,7 +410,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
} else if (obj instanceof MessageObject) {
|
} else if (obj instanceof MessageObject) {
|
||||||
MessageObject messageObject = (MessageObject)obj;
|
MessageObject messageObject = (MessageObject)obj;
|
||||||
dialog_id = messageObject.getDialogId();
|
dialog_id = messageObject.getDialogId();
|
||||||
message_id = messageObject.messageOwner.id;
|
message_id = messageObject.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,10 +448,17 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
if (openedDialogId == dialog_id) {
|
if (openedDialogId == dialog_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
if (dialogsAdapter != null) {
|
||||||
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
||||||
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (searchString != null) {
|
||||||
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||||
|
presentFragment(new ChatActivity(args));
|
||||||
|
} else {
|
||||||
|
presentFragment(new ChatActivity(args));
|
||||||
}
|
}
|
||||||
presentFragment(new ChatActivity(args));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -533,6 +575,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (searchString != null) {
|
||||||
|
actionBar.openSearchField(searchString);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
|
@ -703,8 +749,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagesActivityDelegate getDelegate() {
|
public void setSearchString(String string) {
|
||||||
return delegate;
|
searchString = string;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMainDialogList() {
|
||||||
|
return delegate == null && searchString == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) {
|
private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) {
|
||||||
|
@ -754,13 +804,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||||
builder.setView(checkBox);
|
builder.setView(checkBox);
|
||||||
}*/
|
}*/
|
||||||
final CheckBox checkBoxFinal = checkBox;
|
final CheckBox checkBoxFinal = checkBox;
|
||||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
didSelectResult(dialog_id, false, checkBoxFinal != null && checkBoxFinal.isChecked());
|
didSelectResult(dialog_id, false, checkBoxFinal != null && checkBoxFinal.isChecked());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.Cancel, null);
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
showAlertDialog(builder);
|
showAlertDialog(builder);
|
||||||
if (checkBox != null) {
|
if (checkBox != null) {
|
||||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)checkBox.getLayoutParams();
|
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)checkBox.getLayoutParams();
|
||||||
|
|
|
@ -382,7 +382,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
|
builder.setNeutralButton(LocaleController.getString("LedDisabled", R.string.LedDisabled), new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||||
|
@ -427,7 +427,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
|
builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
|
||||||
builder.setItems(new CharSequence[] {
|
builder.setItems(new CharSequence[] {
|
||||||
LocaleController.getString("Disabled", R.string.Disabled),
|
LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
|
||||||
LocaleController.getString("Default", R.string.Default),
|
LocaleController.getString("Default", R.string.Default),
|
||||||
LocaleController.getString("Short", R.string.Short),
|
LocaleController.getString("Short", R.string.Short),
|
||||||
LocaleController.getString("Long", R.string.Long)
|
LocaleController.getString("Long", R.string.Long)
|
||||||
|
@ -484,7 +484,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications));
|
builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications));
|
||||||
builder.setItems(new CharSequence[] {
|
builder.setItems(new CharSequence[] {
|
||||||
LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever),
|
LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled),
|
||||||
LocaleController.formatPluralString("Minutes", 5),
|
LocaleController.formatPluralString("Minutes", 5),
|
||||||
LocaleController.formatPluralString("Minutes", 10),
|
LocaleController.formatPluralString("Minutes", 10),
|
||||||
LocaleController.formatPluralString("Minutes", 30),
|
LocaleController.formatPluralString("Minutes", 30),
|
||||||
|
|
|
@ -45,10 +45,9 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public class PhotoAlbumPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class PhotoAlbumPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
|
|
||||||
public static interface PhotoAlbumPickerActivityDelegate {
|
public interface PhotoAlbumPickerActivityDelegate {
|
||||||
public abstract void didSelectPhotos(ArrayList<String> photos);
|
void didSelectPhotos(ArrayList<String> photos, ArrayList<MediaController.SearchImage> webPhotos);
|
||||||
public abstract void didSelectWebPhotos(ArrayList<MediaController.SearchImage> photos);
|
void startPhotoSelectActivity();
|
||||||
public abstract void startPhotoSelectActivity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<MediaController.AlbumEntry> albumsSorted = null;
|
private ArrayList<MediaController.AlbumEntry> albumsSorted = null;
|
||||||
|
@ -332,8 +331,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
|
||||||
MessagesStorage.getInstance().putWebRecent(recentGifImages);
|
MessagesStorage.getInstance().putWebRecent(recentGifImages);
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate.didSelectPhotos(photos);
|
delegate.didSelectPhotos(photos, webPhotos);
|
||||||
delegate.didSelectWebPhotos(webPhotos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixLayout() {
|
private void fixLayout() {
|
||||||
|
@ -466,6 +464,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
|
||||||
photoPickerAlbumsCell.setAlbum(a, null);
|
photoPickerAlbumsCell.setAlbum(a, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
photoPickerAlbumsCell.requestLayout();
|
||||||
} else if (type == 1) {
|
} else if (type == 1) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = new PhotoPickerSearchCell(mContext);
|
view = new PhotoPickerSearchCell(mContext);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.io.File;
|
||||||
public class PhotoCropActivity extends BaseFragment {
|
public class PhotoCropActivity extends BaseFragment {
|
||||||
|
|
||||||
public interface PhotoEditActivityDelegate {
|
public interface PhotoEditActivityDelegate {
|
||||||
public abstract void didFinishEdit(Bitmap bitmap, Bundle args);
|
void didFinishEdit(Bitmap bitmap, Bundle args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PhotoCropView extends FrameLayout {
|
private class PhotoCropView extends FrameLayout {
|
||||||
|
|
|
@ -67,9 +67,9 @@ import java.util.Map;
|
||||||
|
|
||||||
public class PhotoPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider {
|
public class PhotoPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider {
|
||||||
|
|
||||||
public static interface PhotoPickerActivityDelegate {
|
public interface PhotoPickerActivityDelegate {
|
||||||
public abstract void selectedPhotosChanged();
|
void selectedPhotosChanged();
|
||||||
public abstract void actionButtonPressed(boolean canceled);
|
void actionButtonPressed(boolean canceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestQueue requestQueue;
|
private RequestQueue requestQueue;
|
||||||
|
@ -175,8 +175,9 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchCollapse() {
|
public boolean onSearchCollapse() {
|
||||||
finishFragment();
|
finishFragment();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -405,26 +405,26 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface PhotoViewerProvider {
|
public interface PhotoViewerProvider {
|
||||||
public PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index);
|
PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index);
|
||||||
|
|
||||||
public Bitmap getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index);
|
Bitmap getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index);
|
||||||
|
|
||||||
public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index);
|
void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index);
|
||||||
|
|
||||||
public void willHidePhotoViewer();
|
void willHidePhotoViewer();
|
||||||
|
|
||||||
public boolean isPhotoChecked(int index);
|
boolean isPhotoChecked(int index);
|
||||||
|
|
||||||
public void setPhotoChecked(int index);
|
void setPhotoChecked(int index);
|
||||||
|
|
||||||
public void cancelButtonPressed();
|
void cancelButtonPressed();
|
||||||
|
|
||||||
public void sendButtonPressed(int index);
|
void sendButtonPressed(int index);
|
||||||
|
|
||||||
public int getSelectedCount();
|
int getSelectedCount();
|
||||||
|
|
||||||
public void updatePhotoAtIndex(int index);
|
void updatePhotoAtIndex(int index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FrameLayoutTouchListener extends FrameLayout {
|
private class FrameLayoutTouchListener extends FrameLayout {
|
||||||
|
@ -593,18 +593,18 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
|
|
||||||
int added = 0;
|
int added = 0;
|
||||||
for (MessageObject message : arr) {
|
for (MessageObject message : arr) {
|
||||||
if (!imagesByIdsTemp.containsKey(message.messageOwner.id)) {
|
if (!imagesByIdsTemp.containsKey(message.getId())) {
|
||||||
imagesByIdsTemp.put(message.messageOwner.id, message);
|
imagesByIdsTemp.put(message.getId(), message);
|
||||||
if (opennedFromMedia) {
|
if (opennedFromMedia) {
|
||||||
imagesArrTemp.add(message);
|
imagesArrTemp.add(message);
|
||||||
if (message.messageOwner.id == currentMessage.messageOwner.id) {
|
if (message.getId() == currentMessage.getId()) {
|
||||||
foundIndex = added;
|
foundIndex = added;
|
||||||
}
|
}
|
||||||
added++;
|
added++;
|
||||||
} else {
|
} else {
|
||||||
added++;
|
added++;
|
||||||
imagesArrTemp.add(0, message);
|
imagesArrTemp.add(0, message);
|
||||||
if (message.messageOwner.id == currentMessage.messageOwner.id) {
|
if (message.getId() == currentMessage.getId()) {
|
||||||
foundIndex = arr.size() - added;
|
foundIndex = arr.size() - added;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,23 +631,23 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
if (!cacheEndReached || !arr.isEmpty() && added != 0) {
|
if (!cacheEndReached || !arr.isEmpty() && added != 0) {
|
||||||
loadingMoreImages = true;
|
loadingMoreImages = true;
|
||||||
if (opennedFromMedia) {
|
if (opennedFromMedia) {
|
||||||
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, imagesArrTemp.get(imagesArrTemp.size() - 1).messageOwner.id, SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid);
|
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, imagesArrTemp.get(imagesArrTemp.size() - 1).getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid);
|
||||||
} else {
|
} else {
|
||||||
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, imagesArrTemp.get(0).messageOwner.id, SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid);
|
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, imagesArrTemp.get(0).getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int added = 0;
|
int added = 0;
|
||||||
for (MessageObject message : arr) {
|
for (MessageObject message : arr) {
|
||||||
if (!imagesByIds.containsKey(message.messageOwner.id)) {
|
if (!imagesByIds.containsKey(message.getId())) {
|
||||||
added++;
|
added++;
|
||||||
if (opennedFromMedia) {
|
if (opennedFromMedia) {
|
||||||
imagesArr.add(message);
|
imagesArr.add(message);
|
||||||
} else {
|
} else {
|
||||||
imagesArr.add(0, message);
|
imagesArr.add(0, message);
|
||||||
}
|
}
|
||||||
imagesByIds.put(message.messageOwner.id, message);
|
imagesByIds.put(message.getId(), message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (arr.isEmpty() && !fromCache) {
|
if (arr.isEmpty() && !fromCache) {
|
||||||
|
@ -740,7 +740,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(R.string.OK, null);
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
||||||
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
|
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
|
||||||
showAlertDialog(builder);
|
showAlertDialog(builder);
|
||||||
}
|
}
|
||||||
|
@ -812,7 +812,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
MessageObject obj = imagesArr.get(currentIndex);
|
MessageObject obj = imagesArr.get(currentIndex);
|
||||||
if (obj.isSent()) {
|
if (obj.isSent()) {
|
||||||
ArrayList<Integer> arr = new ArrayList<>();
|
ArrayList<Integer> arr = new ArrayList<>();
|
||||||
arr.add(obj.messageOwner.id);
|
arr.add(obj.getId());
|
||||||
|
|
||||||
ArrayList<Long> random_ids = null;
|
ArrayList<Long> random_ids = null;
|
||||||
TLRPC.EncryptedChat encryptedChat = null;
|
TLRPC.EncryptedChat encryptedChat = null;
|
||||||
|
@ -960,7 +960,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||||
builder.setPositiveButton(R.string.OK, null);
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
||||||
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
|
builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
|
||||||
showAlertDialog(builder);
|
showAlertDialog(builder);
|
||||||
}
|
}
|
||||||
|
@ -1802,7 +1802,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
imagesArr.add(messageObject);
|
imagesArr.add(messageObject);
|
||||||
if (messageObject.messageOwner.action == null || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) {
|
if (messageObject.messageOwner.action == null || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) {
|
||||||
needSearchImageInArr = true;
|
needSearchImageInArr = true;
|
||||||
imagesByIds.put(messageObject.messageOwner.id, messageObject);
|
imagesByIds.put(messageObject.getId(), messageObject);
|
||||||
if (messageObject.messageOwner.dialog_id != 0) {
|
if (messageObject.messageOwner.dialog_id != 0) {
|
||||||
currentDialogId = messageObject.messageOwner.dialog_id;
|
currentDialogId = messageObject.messageOwner.dialog_id;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1827,7 +1827,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
imagesArrLocationsSizes.add(object.size);
|
imagesArrLocationsSizes.add(object.size);
|
||||||
avatarsArr.add(new TLRPC.TL_photoEmpty());
|
avatarsArr.add(new TLRPC.TL_photoEmpty());
|
||||||
bottomLayout.clearAnimation();
|
bottomLayout.clearAnimation();
|
||||||
bottomLayout.setVisibility(View.GONE);
|
|
||||||
shareButton.setVisibility(View.VISIBLE);
|
shareButton.setVisibility(View.VISIBLE);
|
||||||
menuItem.hideSubItem(gallery_menu_showall);
|
menuItem.hideSubItem(gallery_menu_showall);
|
||||||
setImageIndex(0, true);
|
setImageIndex(0, true);
|
||||||
|
@ -1841,7 +1840,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
index = imagesArr.size() - index - 1;
|
index = imagesArr.size() - index - 1;
|
||||||
}
|
}
|
||||||
for (MessageObject message : imagesArr) {
|
for (MessageObject message : imagesArr) {
|
||||||
imagesByIds.put(message.messageOwner.id, message);
|
imagesByIds.put(message.getId(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageObject.messageOwner.dialog_id != 0) {
|
if (messageObject.messageOwner.dialog_id != 0) {
|
||||||
|
@ -1937,14 +1936,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
if (opennedFromMedia) {
|
if (opennedFromMedia) {
|
||||||
if (imagesArr.size() < totalImagesCount && !loadingMoreImages && currentIndex > imagesArr.size() - 5) {
|
if (imagesArr.size() < totalImagesCount && !loadingMoreImages && currentIndex > imagesArr.size() - 5) {
|
||||||
MessageObject lastMessage = imagesArr.get(imagesArr.size() - 1);
|
MessageObject lastMessage = imagesArr.get(imagesArr.size() - 1);
|
||||||
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, lastMessage.messageOwner.id, SharedMediaQuery.MEDIA_PHOTOVIDEO, !cacheEndReached, classGuid);
|
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, lastMessage.getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, !cacheEndReached, classGuid);
|
||||||
loadingMoreImages = true;
|
loadingMoreImages = true;
|
||||||
}
|
}
|
||||||
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, totalImagesCount));
|
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, totalImagesCount));
|
||||||
} else {
|
} else {
|
||||||
if (imagesArr.size() < totalImagesCount && !loadingMoreImages && currentIndex < 5) {
|
if (imagesArr.size() < totalImagesCount && !loadingMoreImages && currentIndex < 5) {
|
||||||
MessageObject lastMessage = imagesArr.get(0);
|
MessageObject lastMessage = imagesArr.get(0);
|
||||||
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, lastMessage.messageOwner.id, SharedMediaQuery.MEDIA_PHOTOVIDEO, !cacheEndReached, classGuid);
|
SharedMediaQuery.loadMedia(currentDialogId, 0, 100, lastMessage.getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, !cacheEndReached, classGuid);
|
||||||
loadingMoreImages = true;
|
loadingMoreImages = true;
|
||||||
}
|
}
|
||||||
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, (totalImagesCount - imagesArr.size()) + currentIndex + 1, totalImagesCount));
|
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, (totalImagesCount - imagesArr.size()) + currentIndex + 1, totalImagesCount));
|
||||||
|
@ -2258,7 +2257,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingImage(MessageObject object) {
|
public boolean isShowingImage(MessageObject object) {
|
||||||
return isVisible && !disableShowCheck && object != null && currentMessageObject != null && currentMessageObject.messageOwner.id == object.messageOwner.id;
|
return isVisible && !disableShowCheck && object != null && currentMessageObject != null && currentMessageObject.getId() == object.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingImage(TLRPC.FileLocation object) {
|
public boolean isShowingImage(TLRPC.FileLocation object) {
|
||||||
|
|
|
@ -185,7 +185,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||||
if (chatActivityEnterView != null) {
|
if (chatActivityEnterView != null) {
|
||||||
chatActivityEnterView.onDestroy();
|
chatActivityEnterView.onDestroy();
|
||||||
}
|
}
|
||||||
chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, true);
|
chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
|
||||||
popupContainer.addView(chatActivityEnterView);
|
popupContainer.addView(chatActivityEnterView);
|
||||||
layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams();
|
layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams();
|
||||||
layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT;
|
layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
@ -201,7 +201,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||||
if (currentMessageNum >= 0 && currentMessageNum < NotificationsController.getInstance().popupMessages.size()) {
|
if (currentMessageNum >= 0 && currentMessageNum < NotificationsController.getInstance().popupMessages.size()) {
|
||||||
NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
|
NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
|
||||||
}
|
}
|
||||||
MessagesController.getInstance().markDialogAsRead(currentMessageObject.getDialogId(), currentMessageObject.messageOwner.id, Math.max(0, currentMessageObject.messageOwner.id), 0, currentMessageObject.messageOwner.date, true, true);
|
MessagesController.getInstance().markDialogAsRead(currentMessageObject.getDialogId(), currentMessageObject.getId(), Math.max(0, currentMessageObject.getId()), 0, currentMessageObject.messageOwner.date, true, true);
|
||||||
currentMessageObject = null;
|
currentMessageObject = null;
|
||||||
getNewMessage();
|
getNewMessage();
|
||||||
}
|
}
|
||||||
|
@ -802,7 +802,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
|
if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
|
||||||
for (int a = 0; a < NotificationsController.getInstance().popupMessages.size(); a++) {
|
for (int a = 0; a < NotificationsController.getInstance().popupMessages.size(); a++) {
|
||||||
if (NotificationsController.getInstance().popupMessages.get(a).messageOwner.id == currentMessageObject.messageOwner.id) {
|
if (NotificationsController.getInstance().popupMessages.get(a).getId() == currentMessageObject.getId()) {
|
||||||
currentMessageNum = a;
|
currentMessageNum = a;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1032,7 +1032,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||||
View view = messageContainer.getChildAt(a);
|
View view = messageContainer.getChildAt(a);
|
||||||
if ((Integer)view.getTag() == 3) {
|
if ((Integer)view.getTag() == 3) {
|
||||||
PopupAudioView cell = (PopupAudioView)view.findViewWithTag(300);
|
PopupAudioView cell = (PopupAudioView)view.findViewWithTag(300);
|
||||||
if (cell.getMessageObject() != null && cell.getMessageObject().messageOwner.id == mid) {
|
if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) {
|
||||||
cell.updateButtonState();
|
cell.updateButtonState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1047,7 +1047,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||||
View view = messageContainer.getChildAt(a);
|
View view = messageContainer.getChildAt(a);
|
||||||
if ((Integer)view.getTag() == 3) {
|
if ((Integer)view.getTag() == 3) {
|
||||||
PopupAudioView cell = (PopupAudioView)view.findViewWithTag(300);
|
PopupAudioView cell = (PopupAudioView)view.findViewWithTag(300);
|
||||||
if (cell.getMessageObject() != null && cell.getMessageObject().messageOwner.id == mid) {
|
if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) {
|
||||||
cell.updateProgress();
|
cell.updateProgress();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1079,6 +1079,9 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||||
if (wakeLock.isHeld()) {
|
if (wakeLock.isHeld()) {
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
}
|
}
|
||||||
|
if (avatarImageView != null) {
|
||||||
|
avatarImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onFinish() {
|
protected void onFinish() {
|
||||||
|
|
|
@ -208,6 +208,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentDestroy() {
|
public void onFragmentDestroy() {
|
||||||
super.onFragmentDestroy();
|
super.onFragmentDestroy();
|
||||||
|
if (avatarImage != null) {
|
||||||
|
avatarImage.setImageDrawable(null);
|
||||||
|
}
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
|
||||||
|
@ -1213,7 +1216,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||||
presentFragment(new ChatActivity(args), true);
|
presentFragment(new ChatActivity(args), true);
|
||||||
removeSelfFromStack();
|
removeSelfFromStack();
|
||||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||||
SendMessagesHelper.getInstance().sendMessage(user, dialog_id);
|
SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue