v2.6.0.2: New name, new base color, new app icon, replies, mentions and hashtags, added Polish, Croatian and Chinese (Taiwan)
This commit is contained in:
parent
e4c9e62f1b
commit
edd63aeac6
@ -3,7 +3,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.1.0'
|
||||
classpath 'com.android.tools.build:gradle:1.1.3'
|
||||
}
|
||||
}
|
||||
apply plugin: 'com.android.application'
|
||||
@ -13,7 +13,7 @@ repositories {
|
||||
}
|
||||
|
||||
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 'net.hockeyapp.android:HockeySDK:3.5.+'
|
||||
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
|
||||
@ -21,8 +21,8 @@ dependencies {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion '21.1.2'
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
@ -87,8 +87,8 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "org.telegram.plus"
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 21
|
||||
versionCode 459
|
||||
versionName "2.5.2.2"
|
||||
targetSdkVersion 22
|
||||
versionCode 469
|
||||
versionName "2.6.0.2"
|
||||
}
|
||||
}
|
||||
|
@ -22,17 +22,17 @@ import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class AndroidUtilities {
|
||||
|
||||
public static final String THEME_PREFS = "theme";
|
||||
|
||||
public static final int defColor = 0xff58BCD5;//0xff43C3DB;//0xff2f8cc9;58BCD5//0xff55abd2
|
||||
public static final int defColor = 0xff009688;//0xff58BCD5;//0xff43C3DB;//0xff2f8cc9;58BCD5//0xff55abd2
|
||||
public static int themeColor = getIntColor("themeColor");
|
||||
|
||||
public static boolean needRestart = false;
|
||||
@ -189,8 +189,6 @@ public class AndroidUtilities {
|
||||
}
|
||||
InputMethodManager inputManager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
((InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0);
|
||||
}
|
||||
|
||||
public static boolean isKeyboardShowed(View view) {
|
||||
@ -909,6 +907,14 @@ public class AndroidUtilities {
|
||||
}
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
|
||||
public static int getDefBubbleColor(){
|
||||
int color = 0xffb2dfdb;//0xff80cbc4;
|
||||
if(getIntColor("themeColor") != 0xff009688){
|
||||
color = AndroidUtilities.getIntDarkerColor("themeColor", -0x50);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
/*
|
||||
static void modifyXMLfile(File preffile,String sname){
|
||||
try {
|
||||
|
@ -197,7 +197,8 @@ public class ContactsController {
|
||||
}
|
||||
|
||||
public String getInviteText() {
|
||||
return inviteText != null ? inviteText : LocaleController.getString("InviteText", R.string.InviteText);
|
||||
//return inviteText != null ? inviteText : LocaleController.getString("InviteText", R.string.InviteText);
|
||||
return LocaleController.getString("InviteText", R.string.InviteText);
|
||||
}
|
||||
|
||||
public void checkAppAccount() {
|
||||
|
@ -29,8 +29,8 @@ import org.telegram.messenger.Utilities;
|
||||
|
||||
public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
public static interface ImageReceiverDelegate {
|
||||
public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb);
|
||||
public interface ImageReceiverDelegate {
|
||||
void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb);
|
||||
}
|
||||
|
||||
private View parentView;
|
||||
|
@ -158,6 +158,14 @@ public class LocaleController {
|
||||
"tr", "vi", "wo", "yo", "zh", "bo", "dz", "id", "jv", "ka", "km", "kn", "ms", "th"}, new PluralRules_None());
|
||||
|
||||
LocaleInfo localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "العربية";
|
||||
localeInfo.nameEnglish = "Arabic";
|
||||
localeInfo.shortName = "ar";
|
||||
localeInfo.pathToFile = null;
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "Català";
|
||||
localeInfo.nameEnglish = "Catalan";
|
||||
localeInfo.shortName = "ca";
|
||||
@ -165,6 +173,22 @@ public class LocaleController {
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "正體中文(台灣)";
|
||||
localeInfo.nameEnglish = "Chinese Traditional (Taiwan)";
|
||||
localeInfo.shortName = "zh_TW";
|
||||
localeInfo.pathToFile = null;
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "Hrvatski";
|
||||
localeInfo.nameEnglish = "Croatian";
|
||||
localeInfo.shortName = "hr";
|
||||
localeInfo.pathToFile = null;
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "Deutsch";
|
||||
localeInfo.nameEnglish = "German";
|
||||
@ -182,16 +206,16 @@ public class LocaleController {
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "Français";
|
||||
localeInfo.nameEnglish = "French";
|
||||
localeInfo.shortName = "fr";
|
||||
localeInfo.name = "Español";
|
||||
localeInfo.nameEnglish = "Spanish";
|
||||
localeInfo.shortName = "es";
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "Español";
|
||||
localeInfo.nameEnglish = "Spanish";
|
||||
localeInfo.shortName = "es";
|
||||
localeInfo.name = "Français";
|
||||
localeInfo.nameEnglish = "French";
|
||||
localeInfo.shortName = "fr";
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
@ -219,9 +243,9 @@ public class LocaleController {
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "العربية";
|
||||
localeInfo.nameEnglish = "Arabic";
|
||||
localeInfo.shortName = "ar";
|
||||
localeInfo.name = "Polski";
|
||||
localeInfo.nameEnglish = "Polish";
|
||||
localeInfo.shortName = "pl";
|
||||
localeInfo.pathToFile = null;
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
@ -243,7 +267,7 @@ public class LocaleController {
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "русский";
|
||||
localeInfo.name = "Русский";
|
||||
localeInfo.nameEnglish = "Russian";
|
||||
localeInfo.shortName = "ru";
|
||||
sortedLanguages.add(localeInfo);
|
||||
|
@ -87,12 +87,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
|
||||
public static int[] readArgs = new int[3];
|
||||
|
||||
public static interface FileDownloadProgressListener {
|
||||
public void onFailedDownload(String fileName);
|
||||
public void onSuccessDownload(String fileName);
|
||||
public void onProgressDownload(String fileName, float progress);
|
||||
public void onProgressUpload(String fileName, float progress, boolean isEncrypted);
|
||||
public int getObserverTag();
|
||||
public interface FileDownloadProgressListener {
|
||||
void onFailedDownload(String fileName);
|
||||
void onSuccessDownload(String fileName);
|
||||
void onProgressDownload(String fileName, float progress);
|
||||
void onProgressUpload(String fileName, float progress, boolean isEncrypted);
|
||||
int getObserverTag();
|
||||
}
|
||||
|
||||
private class AudioBuffer {
|
||||
@ -234,6 +234,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
private long recordStartTime;
|
||||
private long recordTimeCount;
|
||||
private long recordDialogId;
|
||||
private MessageObject recordReplyingMessageObject;
|
||||
private DispatchQueue fileDecodingQueue;
|
||||
private DispatchQueue playerQueue;
|
||||
private ArrayList<AudioBuffer> usedPlayerBuffers = new ArrayList<>();
|
||||
@ -509,7 +510,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
lastProgress = progress;
|
||||
playingMessageObject.audioProgress = value;
|
||||
playingMessageObject.audioProgressSec = lastProgress / 1000;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioProgressDidChanged, playingMessageObject.messageOwner.id, value);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioProgressDidChanged, playingMessageObject.getId(), value);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -977,7 +978,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
} else if (id == NotificationCenter.messagesDeleted) {
|
||||
if (playingMessageObject != null) {
|
||||
ArrayList<Integer> markAsDeletedMessages = (ArrayList<Integer>)args[0];
|
||||
if (markAsDeletedMessages.contains(playingMessageObject.messageOwner.id)) {
|
||||
if (markAsDeletedMessages.contains(playingMessageObject.getId())) {
|
||||
clenupPlayer(false);
|
||||
}
|
||||
}
|
||||
@ -1187,7 +1188,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
playingMessageObject.audioProgressSec = 0;
|
||||
playingMessageObject = null;
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
try {
|
||||
@ -1249,7 +1250,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
if (messageObject == null) {
|
||||
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) {
|
||||
resumeAudio(messageObject);
|
||||
}
|
||||
@ -1412,7 +1413,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
|
||||
public boolean pauseAudio(MessageObject messageObject) {
|
||||
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;
|
||||
}
|
||||
try {
|
||||
@ -1432,7 +1433,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
|
||||
public boolean resumeAudio(MessageObject messageObject) {
|
||||
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;
|
||||
}
|
||||
try {
|
||||
@ -1451,14 +1452,14 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
}
|
||||
|
||||
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() {
|
||||
return isPaused;
|
||||
}
|
||||
|
||||
public void startRecording(final long dialog_id) {
|
||||
public void startRecording(final long dialog_id, final MessageObject reply_to_msg) {
|
||||
clenupPlayer(true);
|
||||
|
||||
try {
|
||||
@ -1505,6 +1506,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
recordStartTime = System.currentTimeMillis();
|
||||
recordTimeCount = 0;
|
||||
recordDialogId = dialog_id;
|
||||
recordReplyingMessageObject = reply_to_msg;
|
||||
fileBuffer.rewind();
|
||||
|
||||
audioRecorder.startRecording();
|
||||
@ -1557,11 +1559,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
long duration = recordTimeCount;
|
||||
audioToSend.duration = (int) (duration / 1000);
|
||||
if (duration > 700) {
|
||||
SendMessagesHelper.getInstance().sendMessage(audioToSend, recordingAudioFileToSend.getAbsolutePath(), recordDialogId);
|
||||
SendMessagesHelper.getInstance().sendMessage(audioToSend, recordingAudioFileToSend.getAbsolutePath(), recordDialogId, recordReplyingMessageObject);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidSent);
|
||||
} else {
|
||||
recordingAudioFileToSend.delete();
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidSent);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1739,7 +1741,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
return null;
|
||||
}
|
||||
|
||||
if (currentGifDrawable != null && currentGifMessageObject != null && messageObject.messageOwner.id == currentGifMessageObject.messageOwner.id) {
|
||||
if (currentGifDrawable != null && currentGifMessageObject != null && messageObject.getId() == currentGifMessageObject.getId()) {
|
||||
currentMediaCell = cell;
|
||||
currentGifDrawable.parentView = new WeakReference<View>(cell);
|
||||
return currentGifDrawable;
|
||||
@ -1788,7 +1790,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentGifMessageObject != null && messageObject.messageOwner.id == currentGifMessageObject.messageOwner.id) {
|
||||
if (currentGifMessageObject != null && messageObject.getId() == currentGifMessageObject.getId()) {
|
||||
if (currentGifDrawable != null) {
|
||||
currentGifDrawable.stop();
|
||||
currentGifDrawable.recycle();
|
||||
|
@ -30,6 +30,8 @@ import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MessageObject {
|
||||
|
||||
@ -39,6 +41,7 @@ public class MessageObject {
|
||||
|
||||
public TLRPC.Message messageOwner;
|
||||
public CharSequence messageText;
|
||||
public MessageObject replyMessageObject;
|
||||
public int type;
|
||||
public int contentType;
|
||||
public String dateKey;
|
||||
@ -86,9 +89,15 @@ public class MessageObject {
|
||||
textPaintRight.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
|
||||
|
||||
messageOwner = message;
|
||||
|
||||
if (message.replyMessage != null) {
|
||||
replyMessageObject = new MessageObject(message.replyMessage, users, false);
|
||||
}
|
||||
|
||||
if(isOut()){
|
||||
textPaint = textPaintRight;
|
||||
}
|
||||
|
||||
if (message instanceof TLRPC.TL_messageService) {
|
||||
if (message.action != null) {
|
||||
TLRPC.User fromUser = null;
|
||||
@ -292,10 +301,20 @@ public class MessageObject {
|
||||
messageText = LocaleController.getString("UnsuppotedMedia", R.string.UnsuppotedMedia);
|
||||
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
|
||||
if (isSticker()) {
|
||||
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 {
|
||||
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) {
|
||||
messageText = LocaleController.getString("AttachAudio", R.string.AttachAudio);
|
||||
}
|
||||
@ -304,7 +323,7 @@ public class MessageObject {
|
||||
}
|
||||
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) {
|
||||
contentType = type = 0;
|
||||
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
@ -500,6 +519,9 @@ public class MessageObject {
|
||||
} else if (!(c != ' ' && digitsInRow > 0)) {
|
||||
digitsInRow = 0;
|
||||
}
|
||||
if ((c == '@' || c == '#') && i == 0 || i != 0 && (message.charAt(i - 1) == ' ' || message.charAt(i - 1) == '\n')) {
|
||||
return true;
|
||||
}
|
||||
if (c == ':') {
|
||||
if (schemeSequence == 0) {
|
||||
schemeSequence = 1;
|
||||
@ -544,6 +566,22 @@ public class MessageObject {
|
||||
} else {
|
||||
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;
|
||||
@ -716,6 +754,10 @@ public class MessageObject {
|
||||
messageOwner.flags &= ~TLRPC.MESSAGE_FLAG_UNREAD;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return messageOwner.id;
|
||||
}
|
||||
|
||||
public boolean isSecretPhoto() {
|
||||
return messageOwner instanceof TLRPC.TL_message_secret && messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageOwner.ttl != 0 && messageOwner.ttl <= 60;
|
||||
}
|
||||
@ -804,7 +846,121 @@ public class MessageObject {
|
||||
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() {
|
||||
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();
|
||||
if (createTable) {
|
||||
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 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();
|
||||
@ -162,7 +162,7 @@ public class MessagesStorage {
|
||||
database.executeFast("CREATE TABLE keyvalue(id TEXT PRIMARY KEY, value TEXT)").stepThis().dispose();
|
||||
|
||||
//version
|
||||
database.executeFast("PRAGMA user_version = 13").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 14").stepThis().dispose();
|
||||
} else {
|
||||
try {
|
||||
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");
|
||||
if (version < 13) {
|
||||
if (version < 14) {
|
||||
updateDbToLastVersion(version);
|
||||
}
|
||||
}
|
||||
@ -368,6 +368,11 @@ public class MessagesStorage {
|
||||
database.executeFast("PRAGMA user_version = 13").stepThis().dispose();
|
||||
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) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -753,7 +758,7 @@ public class MessagesStorage {
|
||||
try {
|
||||
ArrayList<Integer> ids = 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();
|
||||
while (cursor.next()) {
|
||||
int user_id = cursor.intValue(0);
|
||||
@ -840,7 +845,7 @@ public class MessagesStorage {
|
||||
}
|
||||
|
||||
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<>();
|
||||
try {
|
||||
while (cursor.next()) {
|
||||
@ -1085,20 +1090,16 @@ public class MessagesStorage {
|
||||
});
|
||||
}
|
||||
|
||||
private void updateDialogsWithReadedMessagesInternal(final ArrayList<Integer> messages) {
|
||||
if (Thread.currentThread().getId() != storageQueue.getId()) {
|
||||
throw new RuntimeException("wrong db thread");
|
||||
}
|
||||
private void updateDialogsWithReadedMessagesInternal(final ArrayList<Integer> messages, final HashMap<Integer, Integer> inbox) {
|
||||
try {
|
||||
HashMap<Long, Integer> dialogsToUpdate = new HashMap<>();
|
||||
StringBuilder dialogsToReload = new StringBuilder();
|
||||
|
||||
if (messages != null && !messages.isEmpty()) {
|
||||
StringBuilder dialogsToReload = new StringBuilder();
|
||||
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));
|
||||
while (cursor.next()) {
|
||||
int out = cursor.intValue(2);
|
||||
totalCount++;
|
||||
if (out != 0) {
|
||||
continue;
|
||||
}
|
||||
@ -1119,8 +1120,26 @@ public class MessagesStorage {
|
||||
}
|
||||
}
|
||||
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()) {
|
||||
long did = cursor.longValue(0);
|
||||
int count = cursor.intValue(1);
|
||||
@ -1153,19 +1172,19 @@ public class MessagesStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDialogsWithReadedMessages(final ArrayList<Integer> messages, boolean useQueue) {
|
||||
if (messages.isEmpty()) {
|
||||
public void updateDialogsWithReadedMessages(final HashMap<Integer, Integer> inbox, boolean useQueue) {
|
||||
if (inbox.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (useQueue) {
|
||||
storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateDialogsWithReadedMessagesInternal(messages);
|
||||
updateDialogsWithReadedMessagesInternal(null, inbox);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
updateDialogsWithReadedMessagesInternal(messages);
|
||||
updateDialogsWithReadedMessagesInternal(null, inbox);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1710,6 +1729,8 @@ public class MessagesStorage {
|
||||
try {
|
||||
ArrayList<Integer> loadedUsers = new ArrayList<>();
|
||||
ArrayList<Integer> fromUser = new ArrayList<>();
|
||||
ArrayList<Integer> replyMessages = new ArrayList<>();
|
||||
HashMap<Integer, ArrayList<TLRPC.Message>> replyMessageOwners = new HashMap<>();
|
||||
|
||||
SQLiteCursor cursor = null;
|
||||
int lower_id = (int)dialog_id;
|
||||
@ -1731,18 +1752,18 @@ public class MessagesStorage {
|
||||
cursor.dispose();
|
||||
|
||||
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 " +
|
||||
"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));
|
||||
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, 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 {
|
||||
cursor = null;
|
||||
}
|
||||
} 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) {
|
||||
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 {
|
||||
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 {
|
||||
if (load_type == 2) {
|
||||
@ -1778,16 +1799,16 @@ public class MessagesStorage {
|
||||
offset_query = count_unread - count_query;
|
||||
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 {
|
||||
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) {
|
||||
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 {
|
||||
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 {
|
||||
if (load_type == 2) {
|
||||
@ -1823,7 +1844,7 @@ public class MessagesStorage {
|
||||
offset_query = count_unread - count_query;
|
||||
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) {
|
||||
@ -1849,6 +1870,43 @@ public class MessagesStorage {
|
||||
if (message.fwd_from_id != 0) {
|
||||
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);
|
||||
if (!MessageObject.isUnread(message) && lower_id != 0 || message.id > 0) {
|
||||
message.send_state = 0;
|
||||
@ -1899,33 +1957,39 @@ public class MessagesStorage {
|
||||
}
|
||||
});
|
||||
|
||||
/*ArrayList<Range<Integer>> holes = getHoles(dialog_id);
|
||||
if (holes != null && !res.messages.isEmpty()) {
|
||||
int start = res.messages.get(res.messages.size() - 1).id;
|
||||
int end = res.messages.get(0).id;
|
||||
for (Range<Integer> range : holes) {
|
||||
if (range.contains(start) && range.contains(end)) {
|
||||
res.messages.clear();
|
||||
} else if (range.contains(start)) {
|
||||
while (!res.messages.isEmpty() && range.contains(res.messages.get(res.messages.size() - 1).id)) {
|
||||
res.messages.remove(res.messages.size() - 1);
|
||||
if (!replyMessages.isEmpty()) {
|
||||
cursor = database.queryFinalized(String.format(Locale.US, "SELECT data, mid, date FROM messages WHERE mid IN(%s)", TextUtils.join(",", replyMessages)));
|
||||
while (cursor.next()) {
|
||||
ByteBufferDesc data = buffersStorage.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 (!res.messages.isEmpty()) {
|
||||
start = res.messages.get(res.messages.size() - 1).id;
|
||||
if (message.media != null && message.media.user_id != 0) {
|
||||
fromUser.add(message.media.user_id);
|
||||
}
|
||||
} else if (range.contains(end)) {
|
||||
while (!res.messages.isEmpty() && range.contains(res.messages.get(0).id)) {
|
||||
res.messages.remove(0);
|
||||
if (message.media != null && message.media.audio != null && message.media.audio.user_id != 0) {
|
||||
fromUser.add(message.media.audio.user_id);
|
||||
}
|
||||
if (!res.messages.isEmpty()) {
|
||||
end = res.messages.get(0).id;
|
||||
if (message.fwd_from_id != 0) {
|
||||
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();
|
||||
for (int uid : fromUser) {
|
||||
@ -2590,7 +2654,7 @@ public class MessagesStorage {
|
||||
HashMap<Integer, Long> messagesMediaIdsMap = new HashMap<>();
|
||||
StringBuilder messageIds = 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 state3 = database.executeFast("REPLACE INTO randoms 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()) {
|
||||
throw new RuntimeException("wrong db thread");
|
||||
}
|
||||
try {
|
||||
if (messages != null && !messages.isEmpty()) {
|
||||
String ids = TextUtils.join(",", messages);
|
||||
database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = 1 WHERE mid IN(%s)", ids)).stepThis().dispose();
|
||||
if (inbox != null) {
|
||||
for (HashMap.Entry<Integer, Integer> entry : inbox.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 = 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()) {
|
||||
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) {
|
||||
storageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
markMessagesAsReadInternal(messages, encryptedMessages);
|
||||
markMessagesAsReadInternal(inbox, outbox, encryptedMessages);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
markMessagesAsReadInternal(messages, encryptedMessages);
|
||||
markMessagesAsReadInternal(inbox, outbox, encryptedMessages);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3231,7 +3301,7 @@ public class MessagesStorage {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messagesDeleted, mids);
|
||||
}
|
||||
});
|
||||
MessagesStorage.getInstance().updateDialogsWithReadedMessagesInternal(mids);
|
||||
MessagesStorage.getInstance().updateDialogsWithReadedMessagesInternal(mids, null);
|
||||
MessagesStorage.getInstance().markMessagesAsDeletedInternal(mids);
|
||||
MessagesStorage.getInstance().updateDialogsWithDeletedMessagesInternal(mids);
|
||||
}
|
||||
@ -3472,7 +3542,7 @@ public class MessagesStorage {
|
||||
try {
|
||||
database.beginTransaction();
|
||||
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(?, ?, ?, ?, ?)");
|
||||
for (TLRPC.Message message : messages.messages) {
|
||||
fixUnsupportedMedia(message);
|
||||
@ -3644,7 +3714,7 @@ public class MessagesStorage {
|
||||
}
|
||||
|
||||
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 state3 = database.executeFast("REPLACE INTO media_v2 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 screenStateChanged = totalEvents++;
|
||||
public static final int appSwitchedToForeground = totalEvents++;
|
||||
public static final int didLoadedReplyMessages = totalEvents++;
|
||||
|
||||
public static final int httpFileDidLoaded = totalEvents++;
|
||||
public static final int httpFileDidFailedLoad = totalEvents++;
|
||||
@ -109,7 +110,7 @@ public class NotificationCenter {
|
||||
}
|
||||
|
||||
public interface NotificationCenterDelegate {
|
||||
public abstract void didReceivedNotification(int id, Object... args);
|
||||
void didReceivedNotification(int id, Object... args);
|
||||
}
|
||||
|
||||
public void postNotificationName(int id, Object... args) {
|
||||
|
@ -58,6 +58,7 @@ public class NotificationsController {
|
||||
private NotificationManagerCompat notificationManager = null;
|
||||
private HashMap<Long, Integer> pushDialogs = new HashMap<>();
|
||||
private HashMap<Long, Integer> wearNoticationsIds = new HashMap<>();
|
||||
private HashMap<Long, Integer> pushDialogsOverrideMention = new HashMap<>();
|
||||
private int wearNotificationId = 10000;
|
||||
public ArrayList<MessageObject> popupMessages = new ArrayList<>();
|
||||
private long openned_dialog_id = 0;
|
||||
@ -315,7 +316,11 @@ public class NotificationsController {
|
||||
MessageObject lastMessageObject = pushMessages.get(0);
|
||||
|
||||
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 user_id = lastMessageObject.messageOwner.to_id.user_id;
|
||||
if (user_id == 0) {
|
||||
@ -344,9 +349,9 @@ public class NotificationsController {
|
||||
int vibrate_override = 0;
|
||||
|
||||
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) {
|
||||
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()) {
|
||||
notify_override = 2;
|
||||
}
|
||||
@ -643,7 +648,7 @@ public class NotificationsController {
|
||||
|
||||
for (long dialog_id : sortedDialogs) {
|
||||
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.User user = null;
|
||||
String name = null;
|
||||
@ -765,19 +770,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 oldCount2 = pushMessages.size();
|
||||
if (readMessages != null) {
|
||||
for (Integer id : readMessages) {
|
||||
MessageObject messageObject = pushMessagesDict.get(id);
|
||||
if (messageObject != null) {
|
||||
if (inbox != null) {
|
||||
for (HashMap.Entry<Integer, Integer> entry : inbox.entrySet()) {
|
||||
for (int a = 0; a < pushMessages.size(); a++) {
|
||||
MessageObject messageObject = pushMessages.get(a);
|
||||
if (messageObject.getDialogId() == entry.getKey() && messageObject.getId() <= entry.getValue()) {
|
||||
if (isPersonalMessage(messageObject)) {
|
||||
personal_count--;
|
||||
}
|
||||
pushMessages.remove(messageObject);
|
||||
popupMessages.remove(messageObject);
|
||||
pushMessagesDict.remove(id);
|
||||
popupMessages.remove(messageObject);
|
||||
pushMessagesDict.remove(messageObject.getId());
|
||||
pushMessages.remove(a);
|
||||
a--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -792,11 +799,11 @@ public class NotificationsController {
|
||||
}
|
||||
} else {
|
||||
if (!isPopup) {
|
||||
if (messageObject.messageOwner.id <= max_id || max_id < 0) {
|
||||
if (messageObject.getId() <= max_id || max_id < 0) {
|
||||
remove = true;
|
||||
}
|
||||
} else {
|
||||
if (messageObject.messageOwner.id == max_id || max_id < 0) {
|
||||
if (messageObject.getId() == max_id || max_id < 0) {
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
@ -807,7 +814,7 @@ public class NotificationsController {
|
||||
}
|
||||
pushMessages.remove(a);
|
||||
popupMessages.remove(messageObject);
|
||||
pushMessagesDict.remove(messageObject.messageOwner.id);
|
||||
pushMessagesDict.remove(messageObject.getId());
|
||||
a--;
|
||||
}
|
||||
}
|
||||
@ -830,13 +837,17 @@ public class NotificationsController {
|
||||
int popup = 0;
|
||||
|
||||
for (MessageObject messageObject : messageObjects) {
|
||||
if (pushMessagesDict.containsKey(messageObject.messageOwner.id)) {
|
||||
if (pushMessagesDict.containsKey(messageObject.getId())) {
|
||||
continue;
|
||||
}
|
||||
long dialog_id = messageObject.getDialogId();
|
||||
long original_dialog_id = dialog_id;
|
||||
if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
|
||||
continue;
|
||||
}
|
||||
if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_MENTION) != 0) {
|
||||
dialog_id = messageObject.messageOwner.from_id;
|
||||
}
|
||||
if (isPersonalMessage(messageObject)) {
|
||||
personal_count++;
|
||||
}
|
||||
@ -861,7 +872,10 @@ public class NotificationsController {
|
||||
popupMessages.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -894,6 +908,13 @@ public class NotificationsController {
|
||||
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);
|
||||
|
||||
Integer currentCount = pushDialogs.get(dialog_id);
|
||||
@ -911,6 +932,7 @@ public class NotificationsController {
|
||||
}
|
||||
if (newCount == 0) {
|
||||
pushDialogs.remove(dialog_id);
|
||||
pushDialogsOverrideMention.remove(dialog_id);
|
||||
for (int a = 0; a < pushMessages.size(); a++) {
|
||||
MessageObject messageObject = pushMessages.get(a);
|
||||
if (messageObject.getDialogId() == dialog_id) {
|
||||
@ -919,7 +941,7 @@ public class NotificationsController {
|
||||
}
|
||||
pushMessages.remove(a);
|
||||
a--;
|
||||
pushMessagesDict.remove(messageObject.messageOwner.id);
|
||||
pushMessagesDict.remove(messageObject.getId());
|
||||
popupMessages.remove(messageObject);
|
||||
}
|
||||
}
|
||||
@ -958,27 +980,6 @@ public class NotificationsController {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||
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) {
|
||||
for (TLRPC.Message message : messages) {
|
||||
if (pushMessagesDict.containsKey(message.id)) {
|
||||
@ -989,6 +990,10 @@ public class NotificationsController {
|
||||
personal_count++;
|
||||
}
|
||||
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);
|
||||
if (value == null) {
|
||||
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
|
||||
@ -1004,10 +1009,39 @@ public class NotificationsController {
|
||||
if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
|
||||
continue;
|
||||
}
|
||||
pushMessagesDict.put(messageObject.messageOwner.id, messageObject);
|
||||
pushMessagesDict.put(messageObject.getId(), 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) {
|
||||
popupMessages.clear();
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated);
|
||||
@ -1029,7 +1063,8 @@ public class NotificationsController {
|
||||
public void run() {
|
||||
try {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("tag", "org.telegram.messenger/org.telegram.ui.LaunchActivity");
|
||||
//cv.put("tag", "org.telegram.messenger/org.telegram.ui.LaunchActivity");
|
||||
cv.put("tag", "org.telegram.plus/org.telegram.ui.LaunchActivity");
|
||||
cv.put("count", count);
|
||||
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
|
||||
} catch (Throwable e) {
|
||||
|
@ -174,12 +174,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
for (int a = 0; a < arr.size(); a++) {
|
||||
DelayedMessage obj = arr.get(a);
|
||||
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;
|
||||
arr.remove(a);
|
||||
a--;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, obj.obj.messageOwner.id);
|
||||
processSentMessage(obj.obj.messageOwner.id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, obj.obj.getId());
|
||||
processSentMessage(obj.obj.getId());
|
||||
}
|
||||
}
|
||||
if (arr.isEmpty()) {
|
||||
@ -244,12 +244,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
for (int a = 0; a < arr.size(); a++) {
|
||||
DelayedMessage message = arr.get(a);
|
||||
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;
|
||||
arr.remove(a);
|
||||
a--;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.messageOwner.id);
|
||||
processSentMessage(message.obj.messageOwner.id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
|
||||
processSentMessage(message.obj.getId());
|
||||
}
|
||||
}
|
||||
if (arr.isEmpty()) {
|
||||
@ -284,10 +284,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateMessageMedia, message.obj);
|
||||
} else {
|
||||
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;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.messageOwner.id);
|
||||
processSentMessage(message.obj.messageOwner.id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
|
||||
processSentMessage(message.obj.getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -339,10 +339,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
ArrayList<DelayedMessage> arr = delayedMessages.get(path);
|
||||
if (arr != null) {
|
||||
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;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.messageOwner.id);
|
||||
processSentMessage(message.obj.messageOwner.id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, message.obj.getId());
|
||||
processSentMessage(message.obj.getId());
|
||||
}
|
||||
delayedMessages.remove(path);
|
||||
}
|
||||
@ -356,7 +356,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
ArrayList<DelayedMessage> messages = entry.getValue();
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
DelayedMessage message = messages.get(a);
|
||||
if (message.obj.messageOwner.id == object.messageOwner.id) {
|
||||
if (message.obj.getId() == object.getId()) {
|
||||
messages.remove(a);
|
||||
MediaController.getInstance().cancelVideoConvert(message.obj);
|
||||
if (messages.size() == 0) {
|
||||
@ -378,22 +378,22 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
stopVideoService(keyToRemvoe);
|
||||
}
|
||||
ArrayList<Integer> messages = new ArrayList<>();
|
||||
messages.add(object.messageOwner.id);
|
||||
messages.add(object.getId());
|
||||
MessagesController.getInstance().deleteMessages(messages, null, null);
|
||||
}
|
||||
|
||||
public boolean retrySendMessage(MessageObject messageObject, boolean unsent) {
|
||||
if (messageObject.messageOwner.id >= 0) {
|
||||
if (messageObject.getId() >= 0) {
|
||||
return false;
|
||||
}
|
||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) {
|
||||
int enc_id = (int) (messageObject.getDialogId() >> 32);
|
||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(enc_id);
|
||||
if (encryptedChat == null) {
|
||||
MessagesStorage.getInstance().markMessageAsSendError(messageObject.messageOwner.id);
|
||||
MessagesStorage.getInstance().markMessageAsSendError(messageObject.getId());
|
||||
messageObject.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, messageObject.messageOwner.id);
|
||||
processSentMessage(messageObject.messageOwner.id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, messageObject.getId());
|
||||
processSentMessage(messageObject.getId());
|
||||
return false;
|
||||
}
|
||||
if (messageObject.messageOwner.random_id == 0) {
|
||||
@ -429,7 +429,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
return true;
|
||||
}
|
||||
if (unsent) {
|
||||
unsentMessages.put(messageObject.messageOwner.id, messageObject);
|
||||
unsentMessages.put(messageObject.getId(), messageObject);
|
||||
}
|
||||
sendMessage(messageObject);
|
||||
return true;
|
||||
@ -449,75 +449,233 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
||||
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) {
|
||||
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) {
|
||||
TLRPC.TL_video video = (TLRPC.TL_video) messageObject.messageOwner.media.video;
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
TLRPC.User user = new TLRPC.TL_userContact();
|
||||
user.phone = messageObject.messageOwner.media.phone_number;
|
||||
user.first_name = messageObject.messageOwner.media.first_name;
|
||||
user.last_name = messageObject.messageOwner.media.last_name;
|
||||
user.id = messageObject.messageOwner.media.user_id;
|
||||
sendMessage(user, did);
|
||||
sendMessage(user, did, messageObject.replyMessageObject);
|
||||
} else {
|
||||
sendMessage(messageObject, did);
|
||||
}
|
||||
} else if (messageObject.messageOwner.message != null) {
|
||||
sendMessage(messageObject.messageOwner.message, did);
|
||||
sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject);
|
||||
} else {
|
||||
sendMessage(messageObject, did);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.User user, long peer) {
|
||||
sendMessage(null, null, null, null, null, null, user, null, null, null, peer, false, null);
|
||||
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, 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<>();
|
||||
HashMap<Long, TLRPC.Message> messagesByRandomIds = new HashMap<>();
|
||||
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
MessageObject msgObj = messages.get(a);
|
||||
|
||||
final 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);
|
||||
messagesByRandomIds.put(newMsg.random_id, newMsg);
|
||||
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 (arr.size() == 100 || 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;
|
||||
|
||||
final ArrayList<TLRPC.Message> newMsgObjArr = arr;
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
if (error == null) {
|
||||
final TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
|
||||
if (newMsgObjArr.size() != res.messages.size()) {
|
||||
MessagesController.getInstance().getDifference();
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
for (int a = 0; a < res.messages.size(); a++) {
|
||||
TLRPC.Message message = res.messages.get(a);
|
||||
final TLRPC.Message newMsgObj = newMsgObjArr.get(a);
|
||||
if (newMsgObj == null) {
|
||||
continue;
|
||||
}
|
||||
final int oldId = newMsgObj.id;
|
||||
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
|
||||
sentMessages.add(message);
|
||||
newMsgObj.id = message.id;
|
||||
processSentMessage(newMsgObj, message, null);
|
||||
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(newMsgObj.attachPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (final TLRPC.Message newMsgObj : newMsgObjArr) {
|
||||
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<>();
|
||||
messagesByRandomIds = new HashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
sendMessage(null, null, null, null, null, null, null, document, null, originalPath, peer, false, path);
|
||||
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, reply_to_msg);
|
||||
}
|
||||
|
||||
public void sendMessage(String message, long peer) {
|
||||
sendMessage(message, null, null, null, null, null, null, null, null, null, peer, false, null);
|
||||
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, reply_to_msg);
|
||||
}
|
||||
|
||||
public void sendMessage(double lat, double lon, long peer) {
|
||||
sendMessage(null, lat, lon, null, null, null, null, null, null, null, peer, false, null);
|
||||
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, reply_to_msg);
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.TL_photo photo, String originalPath, String path, long peer) {
|
||||
sendMessage(null, null, null, photo, null, null, null, null, null, originalPath, peer, false, path);
|
||||
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, reply_to_msg);
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.TL_video video, String originalPath, String path, long peer) {
|
||||
sendMessage(null, null, null, null, video, null, null, null, null, originalPath, peer, false, path);
|
||||
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, reply_to_msg);
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.TL_audio audio, String path, long peer) {
|
||||
sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path);
|
||||
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, 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) {
|
||||
return;
|
||||
}
|
||||
@ -537,7 +695,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
newMsg = msgObj.messageOwner;
|
||||
|
||||
if (msgObj.type == 0) {
|
||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
||||
if (msgObj.isForwarded()) {
|
||||
type = 4;
|
||||
} else {
|
||||
message = newMsg.message;
|
||||
@ -548,14 +706,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
lon = newMsg.media.geo._long;
|
||||
type = 1;
|
||||
} else if (msgObj.type == 1) {
|
||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
||||
if (msgObj.isForwarded()) {
|
||||
type = 4;
|
||||
} else {
|
||||
photo = (TLRPC.TL_photo) newMsg.media.photo;
|
||||
type = 2;
|
||||
}
|
||||
} else if (msgObj.type == 3) {
|
||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
||||
if (msgObj.isForwarded()) {
|
||||
type = 4;
|
||||
} else {
|
||||
type = 3;
|
||||
@ -631,24 +789,20 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
newMsg.attachPath = path;
|
||||
} else if (msgObj != null) {
|
||||
newMsg = new TLRPC.TL_messageForwarded();
|
||||
if (msgObj.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
||||
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;
|
||||
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 {
|
||||
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.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) {
|
||||
if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) {
|
||||
newMsg = new TLRPC.TL_message_secret();
|
||||
@ -699,6 +853,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||
newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD;
|
||||
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 (high_id == 1) {
|
||||
if (currentChatInfo == null) {
|
||||
@ -758,6 +916,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
|
||||
MessageObject newMsgObj = new MessageObject(newMsg, null, true);
|
||||
newMsgObj.replyMessageObject = reply_to_msg;
|
||||
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING;
|
||||
|
||||
ArrayList<MessageObject> objArr = new ArrayList<>();
|
||||
@ -782,6 +941,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
reqSend.message = message;
|
||||
reqSend.peer = sendToPeer;
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
@ -915,6 +1077,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
request.peer = sendToPeer;
|
||||
request.random_id = newMsg.random_id;
|
||||
request.media = inputMedia;
|
||||
if (reply_to_msg != null) {
|
||||
request.reply_to_msg_id = reply_to_msg.getId();
|
||||
}
|
||||
if (delayedMessage != null) {
|
||||
delayedMessage.sendRequest = request;
|
||||
}
|
||||
@ -1111,8 +1276,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
TLRPC.TL_messages_forwardMessage reqSend = new TLRPC.TL_messages_forwardMessage();
|
||||
reqSend.peer = sendToPeer;
|
||||
reqSend.random_id = newMsg.random_id;
|
||||
if (msgObj.messageOwner.id >= 0) {
|
||||
reqSend.id = msgObj.messageOwner.id;
|
||||
if (msgObj.getId() >= 0) {
|
||||
reqSend.id = msgObj.getId();
|
||||
} else {
|
||||
reqSend.id = msgObj.messageOwner.fwd_msg_id;
|
||||
}
|
||||
@ -1120,10 +1285,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
} catch (Exception 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;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
|
||||
processSentMessage(newMsgObj.messageOwner.id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.getId());
|
||||
processSentMessage(newMsgObj.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1269,13 +1434,21 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
TLRPC.messages_SentMessage res = (TLRPC.messages_SentMessage) response;
|
||||
newMsgObj.id = res.id;
|
||||
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) {
|
||||
TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||
sentMessages.add(res.message);
|
||||
newMsgObj.id = res.message.id;
|
||||
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) {
|
||||
TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
|
||||
if (!res.messages.isEmpty()) {
|
||||
@ -1286,7 +1459,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
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() {
|
||||
@Override
|
||||
@ -1545,7 +1722,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) {
|
||||
return false;
|
||||
}
|
||||
@ -1653,13 +1830,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id);
|
||||
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id, reply_to_msg);
|
||||
}
|
||||
});
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -1671,10 +1848,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
paths.add(path);
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
@ -1684,14 +1861,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
boolean error = false;
|
||||
if (paths != null) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uris != null) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1713,7 +1890,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}).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<Uri> uris = null;
|
||||
if (imageFilePath != null && imageFilePath.length() != 0) {
|
||||
@ -1724,10 +1901,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
uris = new ArrayList<>();
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
@ -1789,7 +1966,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id);
|
||||
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id, reply_to_msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -1832,7 +2009,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
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 +2019,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}).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()) {
|
||||
return;
|
||||
}
|
||||
@ -1923,7 +2100,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, null, dialog_id);
|
||||
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, null, dialog_id, reply_to_msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1931,14 +2108,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
if (sendAsDocuments != null && !sendAsDocuments.isEmpty()) {
|
||||
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();
|
||||
}
|
||||
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -1955,6 +2132,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
originalPath += temp.length() + "_" + temp.lastModified();
|
||||
if (videoEditedInfo != null) {
|
||||
originalPath += duration + "_" + videoEditedInfo.startTime + "_" + videoEditedInfo.endTime;
|
||||
if (videoEditedInfo.resultWidth == videoEditedInfo.originalWidth) {
|
||||
originalPath += "_" + videoEditedInfo.resultWidth;
|
||||
}
|
||||
}
|
||||
TLRPC.TL_video video = null;
|
||||
if (!isEncrypted) {
|
||||
@ -2049,11 +2229,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendMessagesHelper.getInstance().sendMessage(videoFinal, originalPathFinal, finalPath, dialog_id);
|
||||
SendMessagesHelper.getInstance().sendMessage(videoFinal, originalPathFinal, finalPath, dialog_id, reply_to_msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
prepareSendingDocumentInternal(videoPath, videoPath, null, null, dialog_id);
|
||||
prepareSendingDocumentInternal(videoPath, videoPath, null, null, dialog_id, reply_to_msg);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
@ -51,11 +51,11 @@ public class SmsListener extends BroadcastReceiver {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceiveSmsCode, matcher.group(0));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
} catch(Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class WearReplyReceiver extends BroadcastReceiver {
|
||||
if (dialog_id == 0 || max_id == 0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -28,43 +28,43 @@ public interface Cache {
|
||||
* @param key Cache key
|
||||
* @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.
|
||||
* @param key Cache key
|
||||
* @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;
|
||||
* will be called from a worker thread.
|
||||
*/
|
||||
public void initialize();
|
||||
void initialize();
|
||||
|
||||
/**
|
||||
* Invalidates an entry in the cache.
|
||||
* @param key Cache key
|
||||
* @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.
|
||||
* @param key Cache key
|
||||
*/
|
||||
public void remove(String key);
|
||||
void remove(String key);
|
||||
|
||||
/**
|
||||
* Empties the cache.
|
||||
*/
|
||||
public void clear();
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Data and metadata for an entry returned by the cache.
|
||||
*/
|
||||
public static class Entry {
|
||||
class Entry {
|
||||
/** The data returned from cache. */
|
||||
public byte[] data;
|
||||
|
||||
|
@ -26,5 +26,5 @@ public interface Network {
|
||||
* @return A {@link NetworkResponse} with data and caching metadata; will never be null
|
||||
* @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)}.
|
||||
*/
|
||||
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. */
|
||||
public interface Listener<T> {
|
||||
/** Called when a response is received. */
|
||||
public void onResponse(T response);
|
||||
void onResponse(T response);
|
||||
}
|
||||
|
||||
/** Callback interface for delivering error responses. */
|
||||
@ -35,7 +35,7 @@ public class Response<T> {
|
||||
* Callback method that an error has been occurred with the
|
||||
* 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. */
|
||||
|
@ -20,16 +20,16 @@ public interface ResponseDelivery {
|
||||
/**
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
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).
|
||||
*/
|
||||
public int getCurrentTimeout();
|
||||
int getCurrentTimeout();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -37,5 +37,5 @@ public interface RetryPolicy {
|
||||
* @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.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public String getAuthToken() throws AuthFailureError;
|
||||
String getAuthToken() throws AuthFailureError;
|
||||
|
||||
/**
|
||||
* Invalidates the provided auth token.
|
||||
*/
|
||||
public void invalidateAuthToken(String authToken);
|
||||
void invalidateAuthToken(String authToken);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public interface HttpStack {
|
||||
* {@link Request#getHeaders()}
|
||||
* @return the HTTP response
|
||||
*/
|
||||
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
|
||||
HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
|
||||
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
|
||||
* this URL should not be used at all.
|
||||
*/
|
||||
public String rewriteUrl(String originalUrl);
|
||||
String rewriteUrl(String originalUrl);
|
||||
}
|
||||
|
||||
private final UrlRewriter mUrlRewriter;
|
||||
|
@ -71,8 +71,8 @@ public class ImageLoader {
|
||||
* must not block. Implementation with an LruCache is recommended.
|
||||
*/
|
||||
public interface ImageCache {
|
||||
public Bitmap getBitmap(String url);
|
||||
public void putBitmap(String url, Bitmap bitmap);
|
||||
Bitmap getBitmap(String url);
|
||||
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
|
||||
* 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.datacenterId = 3;
|
||||
datacenter.addAddressAndPort("174.140.142.5", 443);
|
||||
datacenter.addAddressAndPort("149.154.175.117", 443);
|
||||
datacenters.put(datacenter.datacenterId, datacenter);
|
||||
}
|
||||
} else if (datacenters.size() == 1) {
|
||||
@ -646,8 +646,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
int lastClassGuid = 1;
|
||||
public int generateClassGuid() {
|
||||
int guid = lastClassGuid++;
|
||||
ArrayList<Long> requests = new ArrayList<>();
|
||||
requestsByGuids.put(guid, requests);
|
||||
requestsByGuids.put(guid, new ArrayList<Long>());
|
||||
return guid;
|
||||
}
|
||||
|
||||
@ -2155,7 +2154,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
implicitError.code = ((TLRPC.RpcError)resultContainer.result).error_code;
|
||||
implicitError.text = ((TLRPC.RpcError)resultContainer.result).error_message;
|
||||
} else if (!(resultContainer.result instanceof TLRPC.TL_error)) {
|
||||
if (request.rawRequest == null || !request.rawRequest.responseClass().isAssignableFrom(resultContainer.result.getClass())) {
|
||||
if (request.rawRequest == null || resultContainer.result == null || !request.rawRequest.responseClass().isAssignableFrom(resultContainer.result.getClass())) {
|
||||
if (request.rawRequest == null) {
|
||||
FileLog.e("tmessages", "rawRequest is null");
|
||||
} else {
|
||||
|
@ -54,10 +54,10 @@ public class FileLoadOperation {
|
||||
private File tempPath = null;
|
||||
private boolean isForceRequest = false;
|
||||
|
||||
public static interface FileLoadOperationDelegate {
|
||||
public abstract void didFinishLoadingFile(FileLoadOperation operation, File finalFile);
|
||||
public abstract void didFailedLoadingFile(FileLoadOperation operation, int state);
|
||||
public abstract void didChangedLoadProgress(FileLoadOperation operation, float progress);
|
||||
public interface FileLoadOperationDelegate {
|
||||
void didFinishLoadingFile(FileLoadOperation operation, File finalFile);
|
||||
void didFailedLoadingFile(FileLoadOperation operation, int state);
|
||||
void didChangedLoadProgress(FileLoadOperation operation, float progress);
|
||||
}
|
||||
|
||||
public FileLoadOperation(TLRPC.FileLocation photoLocation, int size) {
|
||||
|
@ -19,13 +19,13 @@ import java.util.concurrent.Semaphore;
|
||||
|
||||
public class FileLoader {
|
||||
|
||||
public static interface FileLoaderDelegate {
|
||||
public abstract void fileUploadProgressChanged(String location, float progress, boolean isEncrypted);
|
||||
public abstract void fileDidUploaded(String location, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile);
|
||||
public abstract void fileDidFailedUpload(String location, boolean isEncrypted);
|
||||
public abstract void fileDidLoaded(String location, File finalFile, int type);
|
||||
public abstract void fileDidFailedLoad(String location, int state);
|
||||
public abstract void fileLoadProgressChanged(String location, float progress);
|
||||
public interface FileLoaderDelegate {
|
||||
void fileUploadProgressChanged(String location, float progress, boolean isEncrypted);
|
||||
void fileDidUploaded(String location, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile);
|
||||
void fileDidFailedUpload(String location, boolean isEncrypted);
|
||||
void fileDidLoaded(String location, File finalFile, int type);
|
||||
void fileDidFailedLoad(String location, int state);
|
||||
void fileLoadProgressChanged(String location, float progress);
|
||||
}
|
||||
|
||||
public static final int MEDIA_DIR_IMAGE = 0;
|
||||
@ -132,6 +132,9 @@ public class FileLoader {
|
||||
}
|
||||
|
||||
public void uploadFile(final String location, final boolean encrypted, final boolean small, final int estimatedSize) {
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
fileLoaderQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -628,7 +631,7 @@ public class FileLoader {
|
||||
}
|
||||
|
||||
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side) {
|
||||
if (sizes == null) {
|
||||
if (sizes == null || sizes.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
int lastSide = 0;
|
||||
|
@ -181,7 +181,7 @@ public class FileLog {
|
||||
}
|
||||
|
||||
public static void cleanupLogs() {
|
||||
ArrayList<Uri> uris = new ArrayList<Uri>();
|
||||
ArrayList<Uri> uris = new ArrayList<>();
|
||||
File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null);
|
||||
File dir = new File (sdCard.getAbsolutePath() + "/logs");
|
||||
File[] files = dir.listFiles();
|
||||
|
@ -45,10 +45,10 @@ public class FileUploadOperation {
|
||||
private MessageDigest mdEnc = null;
|
||||
private boolean started = false;
|
||||
|
||||
public static interface FileUploadOperationDelegate {
|
||||
public abstract void didFinishUploadingFile(FileUploadOperation operation, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile);
|
||||
public abstract void didFailedUploadingFile(FileUploadOperation operation);
|
||||
public abstract void didChangedUploadProgress(FileUploadOperation operation, float progress);
|
||||
public interface FileUploadOperationDelegate {
|
||||
void didFinishUploadingFile(FileUploadOperation operation, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile);
|
||||
void didFailedUploadingFile(FileUploadOperation operation);
|
||||
void didChangedUploadProgress(FileUploadOperation operation, float progress);
|
||||
}
|
||||
|
||||
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_help_appUpdate.constructor, TLRPC.TL_help_appUpdate.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_message.constructor, TLRPC.TL_message.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_messageActionGeoChatCreate.constructor, TLRPC.TL_messageActionGeoChatCreate.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_fail.constructor, TLRPC.TL_dh_gen_fail.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_updateReadMessages.constructor, TLRPC.TL_updateReadMessages.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_updateNotifySettings.constructor, TLRPC.TL_updateNotifySettings.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_decryptedMessageActionReadMessages.constructor, TLRPC.TL_decryptedMessageActionReadMessages.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_new_session_created.constructor, TLRPC.TL_new_session_created.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_updatesCombined.constructor, TLRPC.TL_updatesCombined.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_wallPaperSolid.constructor, TLRPC.TL_wallPaperSolid.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_decryptedMessageActionNoop.constructor, TLRPC.TL_decryptedMessageActionNoop.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_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.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_document_old.constructor, TLRPC.TL_document_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;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -28,11 +28,11 @@ public class TcpConnection extends ConnectionContext {
|
||||
TcpConnectionStageSuspended
|
||||
}
|
||||
|
||||
public abstract static interface TcpConnectionDelegate {
|
||||
public abstract void tcpConnectionClosed(TcpConnection connection);
|
||||
public abstract void tcpConnectionConnected(TcpConnection connection);
|
||||
public abstract void tcpConnectionQuiackAckReceived(TcpConnection connection, int ack);
|
||||
public abstract void tcpConnectionReceivedData(TcpConnection connection, ByteBufferDesc data, int length);
|
||||
public interface TcpConnectionDelegate {
|
||||
void tcpConnectionClosed(TcpConnection connection);
|
||||
void tcpConnectionConnected(TcpConnection connection);
|
||||
void tcpConnectionQuiackAckReceived(TcpConnection connection, int ack);
|
||||
void tcpConnectionReceivedData(TcpConnection connection, ByteBufferDesc data, int length);
|
||||
}
|
||||
|
||||
private static PyroSelector selector;
|
||||
|
@ -50,7 +50,6 @@ public class ActionBar extends FrameLayout {
|
||||
|
||||
private boolean allowOverlayTitle;
|
||||
private CharSequence lastTitle;
|
||||
private boolean showingOverlayTitle;
|
||||
private boolean castShadows = true;
|
||||
|
||||
protected boolean isSearchFieldVisible;
|
||||
@ -294,15 +293,6 @@ public class ActionBar extends FrameLayout {
|
||||
titleTextView.setCompoundDrawablePadding(padding);
|
||||
}
|
||||
|
||||
public void setTitleColor(int color) {
|
||||
if (titleTextView == null) {
|
||||
createTitleTextView();
|
||||
}
|
||||
if (titleTextView != null) {
|
||||
titleTextView.setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public Drawable getSubTitleIcon() {
|
||||
return subTitleTextView.getCompoundDrawables()[0];
|
||||
}
|
||||
@ -314,6 +304,15 @@ public class ActionBar extends FrameLayout {
|
||||
return titleTextView.getText();
|
||||
}
|
||||
|
||||
public void setTitleColor(int color) {
|
||||
if (titleTextView == null) {
|
||||
createTitleTextView();
|
||||
}
|
||||
if (titleTextView != null) {
|
||||
titleTextView.setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionBarMenu createMenu() {
|
||||
if (menu != null) {
|
||||
return menu;
|
||||
@ -430,6 +429,13 @@ public class ActionBar extends FrameLayout {
|
||||
menu.closeSearchField();
|
||||
}
|
||||
|
||||
public void openSearchField(String text) {
|
||||
if (isSearchFieldVisible || menu == null) {
|
||||
return;
|
||||
}
|
||||
menu.openSearchField(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int actionBarHeight = AndroidUtilities.getCurrentActionBarHeight();
|
||||
@ -457,10 +463,9 @@ public class ActionBar extends FrameLayout {
|
||||
}
|
||||
|
||||
public void setTitleOverlayText(String text) {
|
||||
if (showingOverlayTitle == (text != null) || !allowOverlayTitle || parentFragment.parentLayout == null) {
|
||||
if (!allowOverlayTitle || parentFragment.parentLayout == null) {
|
||||
return;
|
||||
}
|
||||
showingOverlayTitle = text != null;
|
||||
CharSequence textToSet = text != null ? text : lastTitle;
|
||||
if (textToSet != null && titleTextView == null) {
|
||||
createTitleTextView();
|
||||
|
@ -39,12 +39,12 @@ import java.util.ArrayList;
|
||||
|
||||
public class ActionBarLayout extends FrameLayout {
|
||||
|
||||
public static interface ActionBarLayoutDelegate {
|
||||
public abstract boolean onPreIme();
|
||||
public abstract boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout);
|
||||
public abstract boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout);
|
||||
public abstract boolean needCloseLastFragment(ActionBarLayout layout);
|
||||
public abstract void onRebuildAllFragments(ActionBarLayout layout);
|
||||
public interface ActionBarLayoutDelegate {
|
||||
boolean onPreIme();
|
||||
boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout);
|
||||
boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout);
|
||||
boolean needCloseLastFragment(ActionBarLayout layout);
|
||||
void onRebuildAllFragments(ActionBarLayout layout);
|
||||
}
|
||||
|
||||
public class LinearLayoutContainer extends LinearLayout {
|
||||
@ -809,7 +809,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
backgroundView.setVisibility(GONE);
|
||||
}
|
||||
if (drawerLayoutContainer != null) {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true);
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -52,7 +52,7 @@ public class ActionBarMenu extends LinearLayout {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onItemClick((Integer)view.getTag());
|
||||
onItemClick((Integer) view.getTag());
|
||||
}
|
||||
});
|
||||
return view;
|
||||
@ -147,6 +147,22 @@ public class ActionBarMenu extends LinearLayout {
|
||||
ActionBarMenuItem item = (ActionBarMenuItem)view;
|
||||
if (item.isSearchField()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
|
||||
public static class ActionBarMenuItemSearchListener {
|
||||
public void onSearchExpand() { }
|
||||
public void onSearchCollapse() { }
|
||||
public boolean onSearchCollapse() { return true; }
|
||||
public void onTextChanged(EditText editText) { }
|
||||
public void onSearchPressed(EditText editText) { }
|
||||
}
|
||||
@ -324,11 +324,10 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
return false;
|
||||
}
|
||||
if (searchContainer.getVisibility() == VISIBLE) {
|
||||
if (listener == null || listener != null && listener.onSearchCollapse()) {
|
||||
searchContainer.setVisibility(GONE);
|
||||
setVisibility(VISIBLE);
|
||||
AndroidUtilities.hideKeyboard(searchField);
|
||||
if (listener != null) {
|
||||
listener.onSearchCollapse();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
@ -354,6 +353,10 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
iconView.setImageResource(resId);
|
||||
}
|
||||
|
||||
public void setIcon(Drawable drawable) {
|
||||
iconView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public EditText getSearchField() {
|
||||
return searchField;
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public class ActionBarPopupWindow extends PopupWindow {
|
||||
private ViewTreeObserver.OnScrollChangedListener mSuperScrollListener;
|
||||
private ViewTreeObserver mViewTreeObserver;
|
||||
|
||||
public static interface OnDispatchKeyEventListener {
|
||||
public void onDispatchKeyEvent(KeyEvent keyEvent);
|
||||
public interface OnDispatchKeyEventListener {
|
||||
void onDispatchKeyEvent(KeyEvent keyEvent);
|
||||
}
|
||||
|
||||
public static class ActionBarPopupWindowLayout extends LinearLayout {
|
||||
@ -201,7 +201,7 @@ public class ActionBarPopupWindow extends PopupWindow {
|
||||
public void dismiss() {
|
||||
setFocusable(false);
|
||||
try {
|
||||
super.dismiss();
|
||||
super.dismiss();
|
||||
} catch (Exception e) {
|
||||
//don't promt
|
||||
}
|
||||
|
@ -16,14 +16,17 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
|
||||
public class BaseFragment {
|
||||
private boolean isFinished = false;
|
||||
private AlertDialog visibleDialog = null;
|
||||
protected AlertDialog visibleDialog = null;
|
||||
|
||||
protected View fragmentView;
|
||||
protected ActionBarLayout parentLayout;
|
||||
@ -76,6 +79,7 @@ public class BaseFragment {
|
||||
if (parentLayout != null) {
|
||||
actionBar = new ActionBar(parentLayout.getContext());
|
||||
actionBar.parentFragment = this;
|
||||
//actionBar.setBackgroundColor(0xff54759e);
|
||||
actionBar.setBackgroundResource(R.color.header);
|
||||
actionBar.setItemsBackground(R.drawable.bar_selector);
|
||||
}
|
||||
@ -215,6 +219,21 @@ public class BaseFragment {
|
||||
}
|
||||
try {
|
||||
visibleDialog = builder.show();
|
||||
//
|
||||
int color = AndroidUtilities.getIntColor("themeColor");
|
||||
int id = visibleDialog.getContext().getResources().getIdentifier("android:id/alertTitle", null, null);
|
||||
TextView tv = (TextView) visibleDialog.findViewById(id);
|
||||
tv.setTextColor(color);
|
||||
id = visibleDialog.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
|
||||
View divider = visibleDialog.findViewById(id);
|
||||
if(divider != null)divider.setBackgroundColor(color);
|
||||
Button btn = visibleDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
|
||||
if(btn != null)btn.setTextColor(color);
|
||||
btn = visibleDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if(btn != null)btn.setTextColor(color);
|
||||
btn = visibleDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
|
||||
if(btn != null)btn.setTextColor(color);
|
||||
//
|
||||
visibleDialog.setCanceledOnTouchOutside(true);
|
||||
visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
|
@ -14,7 +14,6 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
@ -252,11 +251,15 @@ public class DrawerLayoutContainer extends FrameLayout {
|
||||
parentActionBarLayout = layout;
|
||||
}
|
||||
|
||||
public void setAllowOpenDrawer(boolean value) {
|
||||
public void setAllowOpenDrawer(boolean value, boolean animated) {
|
||||
allowOpenDrawer = value;
|
||||
if (!allowOpenDrawer && drawerPosition != 0) {
|
||||
if (!animated) {
|
||||
setDrawerPosition(0);
|
||||
onDrawerAnimationEnd(false);
|
||||
} else {
|
||||
closeDrawer(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,20 +8,19 @@
|
||||
|
||||
package org.telegram.ui.Adapters;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Cells.DividerCell;
|
||||
import org.telegram.ui.Cells.GreySectionCell;
|
||||
@ -31,7 +30,6 @@ import org.telegram.ui.Cells.UserCell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ContactsAdapter extends BaseSectionsAdapter {
|
||||
|
||||
@ -176,6 +174,7 @@ public class ContactsAdapter extends BaseSectionsAdapter {
|
||||
((LetterSectionCell) convertView).setLetter("");
|
||||
}
|
||||
}
|
||||
((LetterSectionCell) convertView).setLetterColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff808080));
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@ -186,6 +185,7 @@ public class ContactsAdapter extends BaseSectionsAdapter {
|
||||
if (convertView == null) {
|
||||
convertView = new DividerCell(mContext);
|
||||
convertView.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 28 : 72), 0, AndroidUtilities.dp(LocaleController.isRTL ? 72 : 28), 0);
|
||||
convertView.setTag("contactsRowColor");
|
||||
}
|
||||
} else if (type == 3) {
|
||||
if (convertView == null) {
|
||||
@ -193,6 +193,7 @@ public class ContactsAdapter extends BaseSectionsAdapter {
|
||||
((GreySectionCell) convertView).setText(LocaleController.getString("Contacts", R.string.Contacts).toUpperCase());
|
||||
//((GreySectionCell) convertView).setText(String.format(Locale.US, " %d " + LocaleController.getString("Contacts", R.string.Contacts).toUpperCase(), arr0.size()));
|
||||
((GreySectionCell) convertView).setBackgroundColor(AndroidUtilities.getIntDef("contactsRowColor", 0xffffffff));
|
||||
((GreySectionCell) convertView).setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373));
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (convertView == null) {
|
||||
@ -201,14 +202,26 @@ public class ContactsAdapter extends BaseSectionsAdapter {
|
||||
TextCell actionCell = (TextCell) convertView;
|
||||
actionCell.setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000));
|
||||
if (needPhonebook) {
|
||||
actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
|
||||
//actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
|
||||
Drawable invite = mContext.getResources().getDrawable(R.drawable.menu_invite);
|
||||
invite.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
|
||||
actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), invite);
|
||||
} else {
|
||||
if (position == 0) {
|
||||
actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
|
||||
//actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
|
||||
Drawable newGroup = mContext.getResources().getDrawable(R.drawable.menu_newgroup);
|
||||
newGroup.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
|
||||
actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), newGroup);
|
||||
} else if (position == 1) {
|
||||
actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
|
||||
//actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
|
||||
Drawable secret = mContext.getResources().getDrawable(R.drawable.menu_secret);
|
||||
secret.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
|
||||
actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), secret);
|
||||
} else if (position == 2) {
|
||||
actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast);
|
||||
//actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast);
|
||||
Drawable broadcast = mContext.getResources().getDrawable(R.drawable.menu_broadcast);
|
||||
broadcast.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
|
||||
actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), broadcast);
|
||||
}
|
||||
}
|
||||
} else if (type == 1) {
|
||||
@ -231,6 +244,7 @@ public class ContactsAdapter extends BaseSectionsAdapter {
|
||||
//((UserCell) convertView).setStatusColors(0xffa8a8a8, 0xff3b84c0);
|
||||
((UserCell) convertView).setStatusColors(AndroidUtilities.getIntDef("contactsStatusColor", 0xffa8a8a8), AndroidUtilities.getIntDef("contactsOnlineColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15)));
|
||||
((UserCell) convertView).setNameColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000));
|
||||
((UserCell) convertView).setAvatarRadius(AndroidUtilities.getIntDef("contactsAvatarRadius", 32));
|
||||
}
|
||||
|
||||
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers ? 0 : 1)));
|
||||
|
@ -55,7 +55,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
private long reqId = 0;
|
||||
private int lastReqId;
|
||||
private MessagesActivitySearchAdapterDelegate delegate;
|
||||
private boolean needMessagesSearch;
|
||||
private int needMessagesSearch;
|
||||
private boolean messagesSearchEndReached;
|
||||
private String lastMessagesSearchString;
|
||||
private int lastSearchId = 0;
|
||||
@ -66,11 +66,11 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
public CharSequence name;
|
||||
}
|
||||
|
||||
public static interface MessagesActivitySearchAdapterDelegate {
|
||||
public abstract void searchStateChanged(boolean searching);
|
||||
public interface MessagesActivitySearchAdapterDelegate {
|
||||
void searchStateChanged(boolean searching);
|
||||
}
|
||||
|
||||
public DialogsSearchAdapter(Context context, boolean messagesSearch) {
|
||||
public DialogsSearchAdapter(Context context, int messagesSearch) {
|
||||
mContext = context;
|
||||
needMessagesSearch = messagesSearch;
|
||||
}
|
||||
@ -88,7 +88,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
}
|
||||
|
||||
private void searchMessagesInternal(final String query) {
|
||||
if (!needMessagesSearch) {
|
||||
if (needMessagesSearch == 0) {
|
||||
return;
|
||||
}
|
||||
if (reqId != 0) {
|
||||
@ -110,7 +110,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
req.peer = new TLRPC.TL_inputPeerEmpty();
|
||||
req.q = query;
|
||||
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;
|
||||
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) {
|
||||
if (needMessagesSearch == 2) {
|
||||
return;
|
||||
}
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -178,7 +181,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
int resultCount = 0;
|
||||
|
||||
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()) {
|
||||
long id = cursor.longValue(0);
|
||||
DialogSearchResult dialogSearchResult = new DialogSearchResult();
|
||||
@ -488,8 +491,10 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
if (query == null || query.length() == 0) {
|
||||
searchResult.clear();
|
||||
searchResultNames.clear();
|
||||
searchMessagesInternal(null);
|
||||
if (needMessagesSearch != 2) {
|
||||
queryServerSearch(null);
|
||||
}
|
||||
searchMessagesInternal(null);
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
final int searchId = ++lastSearchId;
|
||||
@ -507,7 +512,9 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (needMessagesSearch != 2) {
|
||||
queryServerSearch(query);
|
||||
}
|
||||
searchMessagesInternal(query);
|
||||
}
|
||||
});
|
||||
|
@ -89,6 +89,7 @@ public class DrawerLayoutAdapter extends BaseAdapter {
|
||||
} else if (type == 2) {
|
||||
if (view == null) {
|
||||
view = new DividerCell(mContext);
|
||||
view.setTag("drawerListColor");
|
||||
}
|
||||
} else if (type == 3) {
|
||||
if (view == null) {
|
||||
@ -156,5 +157,4 @@ public class DrawerLayoutAdapter extends BaseAdapter {
|
||||
public boolean isEmpty() {
|
||||
return !UserConfig.isClientActivated();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
|
||||
private String lastSticker;
|
||||
private boolean visible;
|
||||
|
||||
public static interface StickersAdapterDelegate {
|
||||
public abstract void needChangePanelVisibility(boolean show);
|
||||
public interface StickersAdapterDelegate {
|
||||
void needChangePanelVisibility(boolean show);
|
||||
}
|
||||
|
||||
private class Holder extends RecyclerView.ViewHolder {
|
||||
@ -80,7 +80,7 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
|
||||
@Override
|
||||
public void run() {
|
||||
if (stickers != null && !stickers.isEmpty() && !stickersToLoad.isEmpty() && visible) {
|
||||
String fileName = (String)args[0];
|
||||
String fileName = (String) args[0];
|
||||
stickersToLoad.remove(fileName);
|
||||
if (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<>();
|
||||
for (TLRPC.TL_stickerPack stickerPack : res.packs) {
|
||||
if (stickerPack != null && stickerPack.emoticon != null) {
|
||||
stickerPack.emoticon = stickerPack.emoticon.replace("\uFE0F", "");
|
||||
ArrayList<TLRPC.Document> arrayList = result.get(stickerPack.emoticon);
|
||||
for (Long id : stickerPack.documents) {
|
||||
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 onAnimationEnd(Animator10 animation);
|
||||
void onAnimationCancel(Animator10 animation);
|
||||
void onAnimationRepeat(Animator10 animation);
|
||||
}
|
||||
|
||||
public static interface AnimatorPauseListener {
|
||||
public interface AnimatorPauseListener {
|
||||
void onAnimationPause(Animator10 animation);
|
||||
void onAnimationResume(Animator10 animation);
|
||||
}
|
||||
|
@ -17,5 +17,5 @@
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static interface AnimatorUpdateListener {
|
||||
public interface AnimatorUpdateListener {
|
||||
void onAnimationUpdate(ValueAnimator animation);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
@ -36,10 +37,10 @@ import org.telegram.ui.Components.AvatarDrawable;
|
||||
|
||||
public class ChatActionCell extends BaseCell {
|
||||
|
||||
public static interface ChatActionCellDelegate {
|
||||
public abstract void didClickedImage(ChatActionCell cell);
|
||||
public abstract void didLongPressed(ChatActionCell cell);
|
||||
public abstract void needOpenUserProfile(int uid);
|
||||
public interface ChatActionCellDelegate {
|
||||
void didClickedImage(ChatActionCell cell);
|
||||
void didLongPressed(ChatActionCell cell);
|
||||
void needOpenUserProfile(int uid);
|
||||
}
|
||||
|
||||
private static Drawable backgroundBlack;
|
||||
@ -58,7 +59,6 @@ public class ChatActionCell extends BaseCell {
|
||||
private int textX = 0;
|
||||
private int textY = 0;
|
||||
private int textXLeft = 0;
|
||||
private boolean useBlackBackground = false;
|
||||
private int previousWidth = 0;
|
||||
private boolean imagePressed = false;
|
||||
|
||||
@ -81,6 +81,11 @@ public class ChatActionCell extends BaseCell {
|
||||
imageReceiver = new ImageReceiver(this);
|
||||
imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
//Chat Action Photo
|
||||
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32));
|
||||
imageReceiver.setRoundRadius(radius);
|
||||
avatarDrawable.setRadius(radius);
|
||||
//
|
||||
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
|
||||
}
|
||||
|
||||
@ -124,10 +129,6 @@ public class ChatActionCell extends BaseCell {
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setUseBlackBackground(boolean value) {
|
||||
useBlackBackground = value;
|
||||
}
|
||||
|
||||
public MessageObject getMessageObject() {
|
||||
return currentMessageObject;
|
||||
}
|
||||
@ -266,6 +267,16 @@ public class ChatActionCell extends BaseCell {
|
||||
setMeasuredDimension(width, textHeight + AndroidUtilities.dp(14 + (currentMessageObject.type == 11 ? 70 : 0)));
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
int color = AndroidUtilities.getIntDef("chatDateColor", 0xffffffff);
|
||||
textPaint.setColor(color);
|
||||
if(color != 0xffffffff){
|
||||
textPaint.linkColor = AndroidUtilities.getIntDarkerColor("chatDateColor", -0x50);
|
||||
}
|
||||
textPaint.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatDateSize", 16)));//16
|
||||
backgroundWhite.setColorFilter(AndroidUtilities.getIntDef("chatDateBubbleColor", 0x59000000), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (currentMessageObject == null) {
|
||||
@ -273,7 +284,7 @@ public class ChatActionCell extends BaseCell {
|
||||
}
|
||||
|
||||
Drawable backgroundDrawable = null;
|
||||
if (useBlackBackground) {
|
||||
if (ApplicationLoader.isCustomTheme()) {
|
||||
backgroundDrawable = backgroundWhite;//backgroundBlack;
|
||||
} else {
|
||||
backgroundDrawable = backgroundWhite;//backgroundBlue;
|
||||
@ -292,14 +303,4 @@ public class ChatActionCell extends BaseCell {
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
int color = AndroidUtilities.getIntDef("chatDateColor", 0xffffffff);
|
||||
textPaint.setColor(color);
|
||||
if(color != 0xffffffff){
|
||||
textPaint.linkColor = AndroidUtilities.getIntDarkerColor("chatDateColor", -0x50);
|
||||
}
|
||||
textPaint.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatDateSize", 16)));//16
|
||||
backgroundWhite.setColorFilter(AndroidUtilities.getIntDef("chatDateBubbleColor", 0x59000000), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
seekBar.delegate = this;
|
||||
progressView = new ProgressView();
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
|
||||
//Chat Audio Photo
|
||||
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32));
|
||||
avatarImage.setRoundRadius(radius);
|
||||
avatarDrawable.setRadius(radius);
|
||||
//
|
||||
if (timePaint == null) {
|
||||
statesDrawable[0][0] = getResources().getDrawable(R.drawable.play1);
|
||||
statesDrawable[0][1] = getResources().getDrawable(R.drawable.play1_pressed);
|
||||
@ -183,11 +187,17 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
buttonState = 3;
|
||||
invalidate();
|
||||
} else if (buttonState == 3) {
|
||||
if (currentMessageObject.isOut() && currentMessageObject.isSending()) {
|
||||
if (delegate != null) {
|
||||
delegate.didPressedCancelSendButton(this);
|
||||
}
|
||||
} else {
|
||||
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.audio);
|
||||
buttonState = 2;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateProgress() {
|
||||
if (currentMessageObject == null) {
|
||||
@ -291,12 +301,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
setMeasuredDimension(width, AndroidUtilities.dp(68));
|
||||
if (isChat) {
|
||||
backgroundWidth = Math.min(width - AndroidUtilities.dp(102), AndroidUtilities.dp(300));
|
||||
} else {
|
||||
backgroundWidth = Math.min(width - AndroidUtilities.dp(50), AndroidUtilities.dp(300));
|
||||
}
|
||||
setMeasuredDimension(width, AndroidUtilities.dp(68) + namesOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -325,7 +330,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
}
|
||||
int diff = 0;
|
||||
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 {
|
||||
diff = AndroidUtilities.dp(56);
|
||||
seekBarX -= diff;
|
||||
@ -337,8 +342,8 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
seekBar.height = AndroidUtilities.dp(30);
|
||||
progressView.width = backgroundWidth - AndroidUtilities.dp(136) + diff;
|
||||
progressView.height = AndroidUtilities.dp(30);
|
||||
seekBarY = AndroidUtilities.dp(13);
|
||||
buttonY = AndroidUtilities.dp(10);
|
||||
seekBarY = AndroidUtilities.dp(13) + namesOffset;
|
||||
buttonY = AndroidUtilities.dp(10) + namesOffset;
|
||||
|
||||
updateProgress();
|
||||
}
|
||||
@ -358,6 +363,12 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
@Override
|
||||
public void setMessageObject(MessageObject messageObject) {
|
||||
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;
|
||||
if (uid == 0) {
|
||||
uid = messageObject.messageOwner.from_id;
|
||||
@ -430,7 +441,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
buttonDrawable.draw(canvas);
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(timeX, AndroidUtilities.dp(45));
|
||||
canvas.translate(timeX, AndroidUtilities.dp(45) + namesOffset);
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ package org.telegram.ui.Cells;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Html;
|
||||
@ -23,7 +24,11 @@ import android.view.SoundEffectConstants;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
@ -33,16 +38,19 @@ import org.telegram.ui.Components.AvatarDrawable;
|
||||
|
||||
public class ChatBaseCell extends BaseCell {
|
||||
|
||||
public static interface ChatBaseCellDelegate {
|
||||
public abstract void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user);
|
||||
public abstract void didPressedCancelSendButton(ChatBaseCell cell);
|
||||
public abstract void didLongPressed(ChatBaseCell cell);
|
||||
public abstract boolean canPerformActions();
|
||||
public interface ChatBaseCellDelegate {
|
||||
void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user);
|
||||
void didPressedCancelSendButton(ChatBaseCell cell);
|
||||
void didLongPressed(ChatBaseCell cell);
|
||||
void didPressReplyMessage(ChatBaseCell cell, int id);
|
||||
void didPressUrl(String url);
|
||||
boolean canPerformActions();
|
||||
}
|
||||
|
||||
public boolean isChat = false;
|
||||
protected boolean isPressed = false;
|
||||
protected boolean forwardName = false;
|
||||
protected boolean isHighlighted = false;
|
||||
protected boolean media = false;
|
||||
protected boolean isCheckPressed = true;
|
||||
private boolean wasLayout = false;
|
||||
@ -67,12 +75,17 @@ public class ChatBaseCell extends BaseCell {
|
||||
private static Drawable clockMediaDrawable;
|
||||
private static Drawable broadcastMediaDrawable;
|
||||
private static Drawable errorDrawable;
|
||||
private static Drawable backgroundBlack;
|
||||
private static Drawable backgroundBlue;
|
||||
protected static Drawable mediaBackgroundDrawable;
|
||||
private static TextPaint timePaintIn;
|
||||
private static TextPaint timePaintOut;
|
||||
private static TextPaint timeMediaPaint;
|
||||
private static TextPaint namePaint;
|
||||
private static TextPaint forwardNamePaint;
|
||||
private static TextPaint replyNamePaint;
|
||||
private static TextPaint replyTextPaint;
|
||||
private static Paint replyLinePaint;
|
||||
|
||||
private static Drawable backgroundDrawableOutWhite;
|
||||
private static Drawable backgroundDrawableOutWhiteSelected;
|
||||
@ -81,7 +94,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
private static Drawable checkDrawableWhite;
|
||||
private static Drawable halfCheckDrawableWhite;
|
||||
private static Drawable clockDrawableWhite;
|
||||
|
||||
private static Drawable mediaBackgroundWhiteDrawable;
|
||||
protected int backgroundWidth = 100;
|
||||
|
||||
protected int layoutWidth;
|
||||
@ -92,6 +105,19 @@ public class ChatBaseCell extends BaseCell {
|
||||
private boolean avatarPressed = 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;
|
||||
protected int nameWidth;
|
||||
private float nameOffsetX = 0;
|
||||
@ -146,11 +172,14 @@ public class ChatBaseCell extends BaseCell {
|
||||
mediaBackgroundDrawable = getResources().getDrawable(R.drawable.phototime);
|
||||
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast3);
|
||||
broadcastMediaDrawable = getResources().getDrawable(R.drawable.broadcast4);
|
||||
backgroundBlack = getResources().getDrawable(R.drawable.system_black);
|
||||
backgroundBlue = getResources().getDrawable(R.drawable.system_blue);
|
||||
|
||||
backgroundDrawableOutWhite = getResources().getDrawable(R.drawable.msg_out_white);
|
||||
backgroundDrawableOutWhiteSelected = getResources().getDrawable(R.drawable.msg_out_white_selected);
|
||||
backgroundMediaDrawableOutWhite = getResources().getDrawable(R.drawable.msg_out_photo_white);
|
||||
backgroundMediaDrawableOutWhiteSelected = getResources().getDrawable(R.drawable.msg_out_photo_white_selected);
|
||||
mediaBackgroundWhiteDrawable = getResources().getDrawable(R.drawable.phototime_white);
|
||||
|
||||
checkDrawableWhite = getResources().getDrawable(R.drawable.msg_check_white);
|
||||
halfCheckDrawableWhite = getResources().getDrawable(R.drawable.msg_halfcheck_white);
|
||||
@ -173,16 +202,30 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
forwardNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
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.setRoundRadius(AndroidUtilities.dp(21));
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
replyImageReceiver = new ImageReceiver(this);
|
||||
//Chat Photo
|
||||
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32));
|
||||
avatarImage.setRoundRadius(radius);
|
||||
avatarDrawable.setRadius(radius);
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
int tColor = AndroidUtilities.getIntColor("themeColor");
|
||||
int lColor = AndroidUtilities.getIntDarkerColor("themeColor",-0x80);
|
||||
int dColor = AndroidUtilities.getIntDarkerColor("themeColor",0x15);
|
||||
int lColor = AndroidUtilities.getDefBubbleColor();
|
||||
int dColor = AndroidUtilities.getIntDarkerColor("themeColor", 0x15);
|
||||
backgroundDrawableOutWhite.setColorFilter(AndroidUtilities.getIntDef("chatRBubbleColor", lColor), PorterDuff.Mode.MULTIPLY);
|
||||
backgroundMediaDrawableOutWhite.setColorFilter(AndroidUtilities.getIntDef("chatRBubbleColor", lColor), PorterDuff.Mode.MULTIPLY);
|
||||
backgroundDrawableIn.setColorFilter(AndroidUtilities.getIntDef("chatLBubbleColor",0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
@ -194,16 +237,25 @@ public class ChatBaseCell extends BaseCell {
|
||||
clockDrawableWhite.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
timePaintOut.setColor(AndroidUtilities.getIntDef("chatRTimeColor",dColor));
|
||||
timePaintOut.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize",12)));
|
||||
timePaintIn.setColor(AndroidUtilities.getIntDef("chatLTimeColor",0xffa1aab3));
|
||||
timePaintIn.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize",12)));
|
||||
timePaintOut.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize", 12)));
|
||||
timePaintIn.setColor(AndroidUtilities.getIntDef("chatLTimeColor", 0xffa1aab3));
|
||||
timePaintIn.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize", 12)));
|
||||
|
||||
int bColor = AndroidUtilities.getIntAlphaColor("chatLBubbleColor", 0xffffffff, 0.9f);
|
||||
if(currentMessageObject.isOut()){
|
||||
bColor = AndroidUtilities.getIntAlphaColor("chatRBubbleColor", lColor, 0.9f);
|
||||
}
|
||||
mediaBackgroundWhiteDrawable.setColorFilter(bColor, PorterDuff.Mode.MULTIPLY);
|
||||
mediaBackgroundDrawable = mediaBackgroundWhiteDrawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
avatarImage.clearImage();
|
||||
replyImageReceiver.clearImage();
|
||||
currentPhoto = null;
|
||||
currentReplyPhoto = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,6 +268,14 @@ public class ChatBaseCell extends BaseCell {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public void setHighlighted(boolean value) {
|
||||
if (isHighlighted == value) {
|
||||
return;
|
||||
}
|
||||
isHighlighted = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setCheckPressed(boolean value, boolean pressed) {
|
||||
isCheckPressed = value;
|
||||
isPressed = pressed;
|
||||
@ -240,10 +300,27 @@ public class ChatBaseCell extends BaseCell {
|
||||
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)) {
|
||||
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;
|
||||
if (drawName && isChat && newUser != null && !currentMessageObject.isOut()) {
|
||||
newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
|
||||
@ -255,7 +332,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.fwd_from_id);
|
||||
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);
|
||||
}
|
||||
return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString);
|
||||
@ -269,6 +346,11 @@ public class ChatBaseCell extends BaseCell {
|
||||
isCheckPressed = true;
|
||||
isAvatarVisible = false;
|
||||
wasLayout = false;
|
||||
replyNameLayout = null;
|
||||
replyTextLayout = null;
|
||||
replyNameWidth = 0;
|
||||
replyTextWidth = 0;
|
||||
currentReplyPhoto = null;
|
||||
|
||||
currentUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||
if (isChat && !messageObject.isOut()) {
|
||||
@ -286,7 +368,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
avatarImage.setImage(currentPhoto, "50_50", avatarDrawable, false);
|
||||
}
|
||||
|
||||
/*
|
||||
if (!media) {
|
||||
if (currentMessageObject.isOut()) {
|
||||
currentTimePaint = timePaintOut;
|
||||
@ -295,6 +377,11 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
} else {
|
||||
currentTimePaint = timeMediaPaint;
|
||||
}*/
|
||||
if (currentMessageObject.isOut()) {
|
||||
currentTimePaint = timePaintOut;
|
||||
} else {
|
||||
currentTimePaint = timePaintIn;
|
||||
}
|
||||
|
||||
currentTimeString = LocaleController.formatterDay.format((long) (currentMessageObject.messageOwner.date) * 1000);
|
||||
@ -310,7 +397,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0));
|
||||
namesOffset += AndroidUtilities.dp(18);
|
||||
namesOffset += AndroidUtilities.dp(19);
|
||||
nameOffsetX = nameLayout.getLineLeft(0);
|
||||
} else {
|
||||
nameWidth = 0;
|
||||
@ -321,7 +408,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
nameWidth = 0;
|
||||
}
|
||||
|
||||
if (drawForwardedName && messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
||||
if (drawForwardedName && messageObject.isForwarded()) {
|
||||
currentForwardUser = MessagesController.getInstance().getUser(messageObject.messageOwner.fwd_from_id);
|
||||
if (currentForwardUser != null) {
|
||||
currentForwardNameString = ContactsController.formatName(currentForwardUser.first_name, currentForwardUser.last_name);
|
||||
@ -349,6 +436,95 @@ public class ChatBaseCell extends BaseCell {
|
||||
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);
|
||||
}
|
||||
try {
|
||||
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);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
try {
|
||||
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);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@ -375,6 +551,11 @@ public class ChatBaseCell extends BaseCell {
|
||||
forwardNamePressed = 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) {
|
||||
startCheckLongPress();
|
||||
@ -412,6 +593,20 @@ public class ChatBaseCell extends BaseCell {
|
||||
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;
|
||||
@ -481,7 +676,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
Drawable currentBackgroundDrawable = null;
|
||||
if (currentMessageObject.isOut()) {
|
||||
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed) {
|
||||
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) {
|
||||
if (!media) {
|
||||
currentBackgroundDrawable = backgroundDrawableOutWhiteSelected;//backgroundDrawableOutSelected;
|
||||
} else {
|
||||
@ -496,7 +691,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2));
|
||||
} else {
|
||||
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed) {
|
||||
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) {
|
||||
if (!media) {
|
||||
currentBackgroundDrawable = backgroundDrawableInSelected;
|
||||
} else {
|
||||
@ -534,23 +729,83 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
|
||||
if (drawForwardedName && forwardedNameLayout != null) {
|
||||
canvas.save();
|
||||
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 19 : 0));
|
||||
if (currentMessageObject.isOut()) {
|
||||
//forwardNamePaint.setColor(0xff4a923c);
|
||||
forwardNamePaint.setColor(AndroidUtilities.getIntDef("chatForwardColor", 0xff4a923c));
|
||||
forwardNamePaint.setColor(AndroidUtilities.getIntDef("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10);
|
||||
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 18 : 0));
|
||||
} else {
|
||||
//forwardNamePaint.setColor(0xff006fc8);
|
||||
forwardNamePaint.setColor(AndroidUtilities.getIntDef("chatForwardColor", 0xff006fc8));
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19);
|
||||
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 18 : 0));
|
||||
}
|
||||
canvas.save();
|
||||
canvas.translate(forwardNameX - forwardNameOffsetX, forwardNameY);
|
||||
forwardedNameLayout.draw(canvas);
|
||||
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()) {
|
||||
int color = AndroidUtilities.getIntDef("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15));
|
||||
replyLinePaint.setColor(color);//0xff8dc97a);
|
||||
replyNamePaint.setColor(color);//0xff61a349);
|
||||
replyTextPaint.setColor(color);//0xff70b15c);
|
||||
replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11);
|
||||
} else {
|
||||
int color = AndroidUtilities.getIntDef("chatForwardColor", 0xff999999);
|
||||
replyLinePaint.setColor(color);//0xff6c9fd2);
|
||||
replyNamePaint.setColor(color);//0xff377aae);
|
||||
replyTextPaint.setColor(color);//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 (media) {
|
||||
setDrawableBounds(mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dp(16.5f));
|
||||
@ -597,8 +852,8 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
|
||||
if (drawClock) {
|
||||
clockDrawable = clockMediaDrawable = clockDrawableWhite;
|
||||
if (!media) {
|
||||
clockDrawable = clockDrawableWhite;
|
||||
setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - clockDrawable.getIntrinsicHeight());
|
||||
clockDrawable.draw(canvas);
|
||||
} else {
|
||||
@ -618,8 +873,8 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
} else {
|
||||
if (drawCheck2) {
|
||||
checkDrawable = checkMediaDrawable = checkDrawableWhite;
|
||||
if (!media) {
|
||||
checkDrawable = checkDrawableWhite;
|
||||
if (drawCheck1) {
|
||||
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
} else {
|
||||
@ -636,8 +891,8 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
if (drawCheck1) {
|
||||
halfCheckDrawable = halfCheckMediaDrawable = halfCheckDrawableWhite;
|
||||
if (!media) {
|
||||
halfCheckDrawable = halfCheckDrawableWhite;
|
||||
setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - halfCheckDrawable.getIntrinsicHeight());
|
||||
halfCheckDrawable.draw(canvas);
|
||||
} else {
|
||||
|
@ -32,9 +32,9 @@ import org.telegram.ui.Components.AvatarDrawable;
|
||||
|
||||
public class ChatContactCell extends ChatBaseCell {
|
||||
|
||||
public static interface ChatContactCellDelegate {
|
||||
public abstract void didClickAddButton(ChatContactCell cell, TLRPC.User user);
|
||||
public abstract void didClickPhone(ChatContactCell cell);
|
||||
public interface ChatContactCellDelegate {
|
||||
void didClickAddButton(ChatContactCell cell, TLRPC.User user);
|
||||
void didClickPhone(ChatContactCell cell);
|
||||
}
|
||||
|
||||
private static TextPaint namePaint;
|
||||
@ -74,6 +74,11 @@ public class ChatContactCell extends ChatBaseCell {
|
||||
avatarImage = new ImageReceiver(this);
|
||||
avatarImage.setRoundRadius(AndroidUtilities.dp(21));
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
//Chat Contact Photo
|
||||
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32));
|
||||
avatarImage.setRoundRadius(radius);
|
||||
avatarDrawable.setRadius(radius);
|
||||
//
|
||||
}
|
||||
|
||||
public void setContactDelegate(ChatContactCellDelegate delegate) {
|
||||
@ -113,7 +118,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()) {
|
||||
avatarPressed = 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;
|
||||
result = true;
|
||||
}
|
||||
@ -154,7 +159,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
buttonPressed = false;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
@ -235,7 +240,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(71));
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(71) + namesOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -257,7 +262,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||
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
|
||||
@ -272,14 +277,14 @@ public class ChatContactCell extends ChatBaseCell {
|
||||
|
||||
if (nameLayout != null) {
|
||||
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));
|
||||
nameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
if (phoneLayout != null) {
|
||||
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);
|
||||
canvas.restore();
|
||||
}
|
||||
@ -291,7 +296,7 @@ public class ChatContactCell extends ChatBaseCell {
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import android.view.SoundEffectConstants;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageLoader;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.SendMessagesHelper;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
@ -34,6 +35,7 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.RadialProgress;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
import org.telegram.ui.Components.GifDrawable;
|
||||
@ -44,9 +46,9 @@ import java.util.Locale;
|
||||
|
||||
public class ChatMediaCell extends ChatBaseCell implements MediaController.FileDownloadProgressListener {
|
||||
|
||||
public static interface ChatMediaCellDelegate {
|
||||
public abstract void didClickedImage(ChatMediaCell cell);
|
||||
public abstract void didPressedOther(ChatMediaCell cell);
|
||||
public interface ChatMediaCellDelegate {
|
||||
void didClickedImage(ChatMediaCell cell);
|
||||
void didPressedOther(ChatMediaCell cell);
|
||||
}
|
||||
|
||||
private static Drawable placeholderDocInDrawable;
|
||||
@ -92,6 +94,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
private int infoOffset = 0;
|
||||
private String currentInfoString;
|
||||
|
||||
private StaticLayout infoLayout2;
|
||||
private int infoWidth2;
|
||||
private static TextPaint senderPaint;
|
||||
|
||||
private StaticLayout nameLayout;
|
||||
private int nameWidth = 0;
|
||||
private String currentNameString;
|
||||
@ -123,17 +129,20 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
docMenuInDrawable = getResources().getDrawable(R.drawable.doc_actions_b);
|
||||
docMenuOutDrawable = getResources().getDrawable(R.drawable.doc_actions_g);
|
||||
|
||||
docMenuWhiteDrawable = getResources().getDrawable(R.drawable.doc_actions_w);
|
||||
docMenuWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatFileInfoColor", 0xff70b15c), PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
infoPaint.setTextSize(AndroidUtilities.dp(12));
|
||||
|
||||
namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
//namePaint.setColor(0xff212121);
|
||||
namePaint.setColor(AndroidUtilities.getIntDef("chatFileInfoColor", 0xff212121));
|
||||
namePaint.setColor(0xff212121);
|
||||
namePaint.setTextSize(AndroidUtilities.dp(16));
|
||||
|
||||
//namePaint.setColor(AndroidUtilities.getIntDef("chatFileInfoColor", 0xff212121));
|
||||
docMenuWhiteDrawable = getResources().getDrawable(R.drawable.doc_actions_w);
|
||||
//docMenuWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatFileInfoColor", 0xff70b15c), PorterDuff.Mode.MULTIPLY);
|
||||
senderPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
senderPaint.setColor(0xffffffff);
|
||||
senderPaint.setTextSize(AndroidUtilities.dp(15));
|
||||
|
||||
docBackPaint = new Paint();
|
||||
|
||||
deleteProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
@ -197,7 +206,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
otherPressed = 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()) {
|
||||
imagePressed = true;
|
||||
result = true;
|
||||
@ -365,7 +374,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
photoImage.cancelLoadImage();
|
||||
} else if (currentMessageObject.type == 8 || currentMessageObject.type == 9) {
|
||||
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;
|
||||
}
|
||||
} else if (currentMessageObject.type == 3) {
|
||||
@ -419,7 +428,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
media = messageObject.type != 9;
|
||||
boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet);
|
||||
if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || dataChanged) {
|
||||
super.setMessageObject(messageObject);
|
||||
cancelLoading = false;
|
||||
|
||||
buttonState = -1;
|
||||
@ -431,7 +439,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
drawBackground = true;
|
||||
|
||||
photoImage.setForcePreview(messageObject.isSecretPhoto());
|
||||
if (messageObject.type == 9) {
|
||||
if (messageObject.type == 9) { //FILE
|
||||
String name = messageObject.getDocumentName();
|
||||
if (name == null || name.length() == 0) {
|
||||
name = LocaleController.getString("AttachDocument", R.string.AttachDocument);
|
||||
@ -465,23 +473,47 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
if (currentInfoString == null || !currentInfoString.equals(str)) {
|
||||
currentInfoString = str;
|
||||
infoOffset = 0;
|
||||
|
||||
if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat) ){
|
||||
infoLayout2 = null;
|
||||
}else{
|
||||
TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||
String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name);
|
||||
infoWidth2 = Math.min(maxWidth, (int) Math.ceil(senderPaint.measureText(senderName)));
|
||||
CharSequence str2 = TextUtils.ellipsize(senderName, senderPaint, infoWidth2, TextUtils.TruncateAt.END);
|
||||
infoLayout2 = new StaticLayout(str2, senderPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
|
||||
infoWidth = Math.min(maxWidth, (int) Math.ceil(infoPaint.measureText(currentInfoString)));
|
||||
CharSequence str2 = TextUtils.ellipsize(currentInfoString, infoPaint, infoWidth, TextUtils.TruncateAt.END);
|
||||
infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
//
|
||||
}
|
||||
} else if (messageObject.type == 8) {
|
||||
} else if (messageObject.type == 8) { //GIF
|
||||
gifDrawable = MediaController.getInstance().getGifDrawable(this, false);
|
||||
|
||||
String str = Utilities.formatFileSize(messageObject.messageOwner.media.document.size);
|
||||
if (currentInfoString == null || !currentInfoString.equals(str)) {
|
||||
currentInfoString = str;
|
||||
infoOffset = 0;
|
||||
infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString));
|
||||
infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
//
|
||||
if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat) ){
|
||||
//infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString));
|
||||
//infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
infoLayout = null;
|
||||
infoLayout2 = null;
|
||||
}else{
|
||||
TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||
String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name);
|
||||
infoWidth = (int) Math.ceil(senderPaint.measureText(senderName));
|
||||
infoLayout = new StaticLayout(senderName, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
infoWidth2 = (int) Math.ceil(infoPaint.measureText(currentInfoString));
|
||||
infoLayout2 = new StaticLayout(currentInfoString, infoPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
}
|
||||
nameLayout = null;
|
||||
currentNameString = null;
|
||||
} else if (messageObject.type == 3) {
|
||||
} else if (messageObject.type == 3) { //VIDEO
|
||||
int duration = messageObject.messageOwner.media.video.duration;
|
||||
int minutes = duration / 60;
|
||||
int seconds = duration - minutes * 60;
|
||||
@ -489,19 +521,49 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
if (currentInfoString == null || !currentInfoString.equals(str)) {
|
||||
currentInfoString = str;
|
||||
infoOffset = videoIconDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4);
|
||||
infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString));
|
||||
infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat)){
|
||||
//infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString));
|
||||
//infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
infoLayout = null;
|
||||
infoLayout2 = null;
|
||||
}else{
|
||||
TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||
String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name);
|
||||
infoWidth = (int) Math.ceil(senderPaint.measureText(senderName));
|
||||
infoLayout = new StaticLayout(senderName, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
infoWidth2 = (int) Math.ceil(infoPaint.measureText(currentInfoString));
|
||||
infoLayout2 = new StaticLayout(currentInfoString, infoPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
}
|
||||
nameLayout = null;
|
||||
currentNameString = null;
|
||||
} else {
|
||||
} else if (messageObject.type == 1) { //PHOTO
|
||||
TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||
String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name);
|
||||
|
||||
if (currentInfoString == null || !currentInfoString.equals(senderName)) {
|
||||
currentInfoString = senderName;
|
||||
infoOffset = 0;
|
||||
if(currentMessageObject != null && (currentMessageObject.isOut() || !isChat) ){
|
||||
infoLayout = null;
|
||||
}else{
|
||||
infoWidth = (int) Math.ceil(senderPaint.measureText(currentInfoString));
|
||||
infoLayout = new StaticLayout(currentInfoString, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
infoLayout2 = null;
|
||||
}
|
||||
nameLayout = null;
|
||||
currentNameString = null;
|
||||
}
|
||||
else {
|
||||
currentInfoString = null;
|
||||
currentNameString = null;
|
||||
infoLayout = null;
|
||||
nameLayout = null;
|
||||
updateSecretTimeText();
|
||||
infoLayout2 = null;
|
||||
}
|
||||
if (messageObject.type == 9) { //doc
|
||||
if (messageObject.type == 9) { //doc
|
||||
photoWidth = AndroidUtilities.dp(86);
|
||||
photoHeight = AndroidUtilities.dp(86);
|
||||
backgroundWidth = photoWidth + Math.max(nameWidth, infoWidth) + AndroidUtilities.dp(68);
|
||||
@ -516,13 +578,13 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
photoImage.setImageBitmap((BitmapDrawable) null);
|
||||
}
|
||||
} else if (messageObject.type == 4) { //geo
|
||||
photoWidth = AndroidUtilities.dp(100);
|
||||
photoWidth = AndroidUtilities.dp(200);
|
||||
photoHeight = AndroidUtilities.dp(100);
|
||||
backgroundWidth = photoWidth + AndroidUtilities.dp(12);
|
||||
|
||||
double lat = messageObject.messageOwner.media.geo.lat;
|
||||
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.setShouldGenerateQualityThumb(false);
|
||||
photoImage.setParentMessageObject(null);
|
||||
@ -537,6 +599,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}
|
||||
}
|
||||
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) {
|
||||
photoHeight = (int) maxHeight;
|
||||
photoWidth = photoHeight + AndroidUtilities.dp(100);
|
||||
@ -545,28 +613,32 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
photoWidth *= maxHeight / photoHeight;
|
||||
photoHeight = (int)maxHeight;
|
||||
}
|
||||
if (photoWidth > maxWidth) {
|
||||
photoHeight *= maxWidth / photoWidth;
|
||||
photoWidth = (int)maxWidth;
|
||||
}
|
||||
backgroundWidth = photoWidth + AndroidUtilities.dp(12);
|
||||
currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80);
|
||||
photoImage.setNeedsQualityThumb(false);
|
||||
photoImage.setShouldGenerateQualityThumb(false);
|
||||
photoImage.setParentMessageObject(null);
|
||||
if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() > 0) {
|
||||
File f = new File(currentMessageObject.messageOwner.attachPath);
|
||||
if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() > 0) {
|
||||
File f = new File(messageObject.messageOwner.attachPath);
|
||||
if (f.exists()) {
|
||||
photoImage.setImage(null, currentMessageObject.messageOwner.attachPath,
|
||||
photoImage.setImage(null, messageObject.messageOwner.attachPath,
|
||||
String.format(Locale.US, "%d_%d", photoWidth, photoHeight),
|
||||
null,
|
||||
currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null,
|
||||
"b1",
|
||||
currentMessageObject.messageOwner.media.document.size, true);
|
||||
messageObject.messageOwner.media.document.size, true);
|
||||
}
|
||||
} else if (currentMessageObject.messageOwner.media.document.id != 0) {
|
||||
photoImage.setImage(currentMessageObject.messageOwner.media.document, null,
|
||||
} else if (messageObject.messageOwner.media.document.id != 0) {
|
||||
photoImage.setImage(messageObject.messageOwner.media.document, null,
|
||||
String.format(Locale.US, "%d_%d", photoWidth, photoHeight),
|
||||
null,
|
||||
currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null,
|
||||
"b1",
|
||||
currentMessageObject.messageOwner.media.document.size, true);
|
||||
messageObject.messageOwner.media.document.size, true);
|
||||
}
|
||||
} else {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
@ -604,7 +676,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
|
||||
if (currentPhotoObject != null) {
|
||||
boolean noSize = false;
|
||||
if (currentMessageObject.type == 3 || currentMessageObject.type == 8) {
|
||||
if (messageObject.type == 3 || messageObject.type == 8) {
|
||||
noSize = true;
|
||||
}
|
||||
float scale = (float) currentPhotoObject.w / (float) photoWidth;
|
||||
@ -637,12 +709,12 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
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) {
|
||||
w = timeWidthTotal;
|
||||
}
|
||||
|
||||
if (currentMessageObject.isSecretPhoto()) {
|
||||
if (messageObject.isSecretPhoto()) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
w = h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
|
||||
} else {
|
||||
@ -666,7 +738,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
String fileName = FileLoader.getAttachFileName(currentPhotoObject);
|
||||
if (messageObject.type == 1) {
|
||||
boolean photoExist = true;
|
||||
File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
|
||||
File cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner);
|
||||
if (!cacheFile.exists()) {
|
||||
photoExist = false;
|
||||
} else {
|
||||
@ -697,6 +769,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
photoImage.setImageBitmap((Bitmap)null);
|
||||
}
|
||||
}
|
||||
super.setMessageObject(messageObject);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
@ -739,7 +812,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
buttonState = 1;
|
||||
radialProgress.setBackground(getDrawableForCurrentState(), true, animated);
|
||||
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;
|
||||
}
|
||||
radialProgress.setProgress(progress != null ? progress : 0, false);
|
||||
@ -789,7 +862,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
|
||||
@Override
|
||||
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
|
||||
@ -810,10 +883,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
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);
|
||||
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));
|
||||
deleteProgressRect.set(buttonX + AndroidUtilities.dp(3), buttonY + AndroidUtilities.dp(3), buttonX + AndroidUtilities.dp(45), buttonY + AndroidUtilities.dp(45));
|
||||
@ -860,7 +933,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
gifDrawable.draw(canvas);
|
||||
canvas.restore();
|
||||
} else {
|
||||
photoImage.setPressed(isPressed() && isCheckPressed || !isCheckPressed && isPressed);
|
||||
photoImage.setPressed(isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted);
|
||||
photoImage.setVisible(!PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
|
||||
imageDrawn = photoImage.draw(canvas);
|
||||
drawTime = photoImage.getVisible();
|
||||
@ -888,7 +961,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
namePaint.setColor(color);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (buttonState >= 0 && buttonState < 4) {
|
||||
@ -949,32 +1022,66 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}
|
||||
|
||||
radialProgress.onDraw(canvas);
|
||||
|
||||
if(AndroidUtilities.getBoolPref("chatMemberColorCheck")){
|
||||
senderPaint.setColor(AndroidUtilities.getIntDef("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
|
||||
}else{
|
||||
//if(currentMessageObject.type == 9){
|
||||
senderPaint.setColor(AvatarDrawable.getNameColorForId(MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id).id));
|
||||
//}else{
|
||||
//senderPaint.setColor(0xffffffff);
|
||||
//}
|
||||
}
|
||||
if (nameLayout != null) {
|
||||
if (infoLayout2 != null) {
|
||||
canvas.save();
|
||||
canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8));
|
||||
infoLayout2.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8));
|
||||
canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(30));
|
||||
nameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
if (infoLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(30));
|
||||
canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(50));
|
||||
infoLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
} else if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto())) {
|
||||
infoPaint.setColor(0xffffffff);
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(16.5f));
|
||||
} else if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto() || currentMessageObject.type == 1 || (buttonState == 2 && currentMessageObject.type == 8) )) {
|
||||
//infoPaint.setColor(0xffffffff);
|
||||
if(currentMessageObject.isOut()){
|
||||
infoPaint.setColor(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000));
|
||||
videoIconDrawable.setColorFilter(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000), PorterDuff.Mode.MULTIPLY);
|
||||
}else{
|
||||
infoPaint.setColor(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000));
|
||||
videoIconDrawable.setColorFilter(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
if (currentMessageObject.type == 1){
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(20));
|
||||
} else {
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), Math.max(infoWidth , infoWidth2 + infoOffset) + AndroidUtilities.dp(8) + infoOffset, 2 * AndroidUtilities.dp(20));
|
||||
}
|
||||
mediaBackgroundDrawable.draw(canvas);
|
||||
|
||||
if (currentMessageObject.type == 3) {
|
||||
setDrawableBounds(videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(7.5f));
|
||||
if (infoLayout2 != null) {
|
||||
setDrawableBounds(videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), 2*(photoImage.getImageY() + AndroidUtilities.dp(10)));
|
||||
}else{
|
||||
setDrawableBounds(videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(8));
|
||||
}
|
||||
videoIconDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8) + infoOffset, photoImage.getImageY() + AndroidUtilities.dp(5.5f));
|
||||
canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8) + infoOffset, photoImage.getImageY() + AndroidUtilities.dp(6));
|
||||
infoLayout.draw(canvas);
|
||||
if (infoLayout2 != null) {
|
||||
canvas.translate(infoOffset, photoImage.getImageY() + AndroidUtilities.dp(12));
|
||||
infoLayout2.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
@ -987,7 +1094,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
@Override
|
||||
public void onSuccessDownload(String fileName) {
|
||||
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;
|
||||
didPressedButton(true);
|
||||
} else if (!photoNotSet) {
|
||||
|
@ -17,6 +17,7 @@ import android.view.MotionEvent;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||
|
||||
public class ChatMessageCell extends ChatBaseCell {
|
||||
|
||||
@ -62,7 +63,16 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
} else {
|
||||
if (link[0] == pressedLink) {
|
||||
try {
|
||||
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) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -164,6 +174,8 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
|
||||
int maxChildWidth = Math.max(backgroundWidth, nameWidth);
|
||||
maxChildWidth = Math.max(maxChildWidth, forwardedNameWidth);
|
||||
maxChildWidth = Math.max(maxChildWidth, replyNameWidth);
|
||||
maxChildWidth = Math.max(maxChildWidth, replyTextWidth);
|
||||
|
||||
int timeMore = timeWidth + AndroidUtilities.dp(6);
|
||||
if (messageObject.isOut()) {
|
||||
|
@ -20,7 +20,6 @@ import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
@ -653,7 +652,7 @@ public class DialogCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
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;
|
||||
update(0);
|
||||
}
|
||||
@ -774,6 +773,57 @@ public class DialogCell extends BaseCell {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, Activity.MODE_PRIVATE);
|
||||
int tColor = AndroidUtilities.getIntColor("themeColor");
|
||||
int dColor = AndroidUtilities.getIntDarkerColor("themeColor",0x15);
|
||||
|
||||
namePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
|
||||
namePaint.setColor(themePrefs.getInt("chatsNameColor", 0xff212121));
|
||||
|
||||
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
|
||||
nameEncryptedPaint.setColor(themePrefs.getInt("chatsNameColor", dColor));//0xff00a60e
|
||||
|
||||
nameUnknownPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
|
||||
nameUnknownPaint.setColor(themePrefs.getInt("chatsNameColor", 0xff000000));//0xff4d83b3
|
||||
|
||||
messagePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
|
||||
messagePaint.setColor(themePrefs.getInt("chatsMessageColor", 0xff8f8f8f));
|
||||
|
||||
messagePrintingPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
|
||||
messagePrintingPaint.setColor(AndroidUtilities.getIntDef("chatsMessageColor", tColor));
|
||||
|
||||
messageTypingPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
|
||||
messageTypingPaint.setColor(AndroidUtilities.getIntDef("chatsTypingColor", tColor));
|
||||
|
||||
timePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsTimeSize", 13)));
|
||||
timePaint.setColor(themePrefs.getInt("chatsTimeColor", 0xff999999));
|
||||
|
||||
countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13)));
|
||||
countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff));
|
||||
|
||||
checkWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
|
||||
halfCheckWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
|
||||
clockDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.SRC_IN);
|
||||
|
||||
countWhiteDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.MULTIPLY);
|
||||
lockWhiteDrawable.setColorFilter(dColor, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
int nColor = themePrefs.getInt("chatsNameColor", 0xff000000);
|
||||
groupWhiteDrawable.setColorFilter(nColor, PorterDuff.Mode.MULTIPLY);
|
||||
broadcastWhiteDrawable.setColorFilter(nColor, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
int mColor = themePrefs.getInt("chatsMuteColor", 0xffa8a8a8);
|
||||
muteWhiteDrawable.setColorFilter(mColor, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
linePaint.setColor(themePrefs.getInt("chatsDividerColor", 0xffdcdcdc));
|
||||
|
||||
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatsAvatarRadius", 32));
|
||||
if(avatarImage != null)avatarImage.setRoundRadius(radius);
|
||||
if(avatarDrawable != null)avatarDrawable.setRadius(radius);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (currentDialogId == 0) {
|
||||
@ -852,53 +902,4 @@ public class DialogCell extends BaseCell {
|
||||
|
||||
avatarImage.draw(canvas);
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, Activity.MODE_PRIVATE);
|
||||
int tColor = AndroidUtilities.getIntColor("themeColor");
|
||||
int dColor = AndroidUtilities.getIntDarkerColor("themeColor",0x15);
|
||||
|
||||
namePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
|
||||
namePaint.setColor(themePrefs.getInt("chatsNameColor", 0xff212121));
|
||||
|
||||
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
|
||||
nameEncryptedPaint.setColor(themePrefs.getInt("chatsNameColor", dColor));//0xff00a60e
|
||||
|
||||
nameUnknownPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
|
||||
nameUnknownPaint.setColor(themePrefs.getInt("chatsNameColor", 0xff000000));//0xff4d83b3
|
||||
|
||||
messagePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
|
||||
messagePaint.setColor(themePrefs.getInt("chatsMessageColor", 0xff8f8f8f));
|
||||
|
||||
messagePrintingPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
|
||||
messagePrintingPaint.setColor(AndroidUtilities.getIntDef("chatsMessageColor", tColor));
|
||||
|
||||
messageTypingPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
|
||||
messageTypingPaint.setColor(AndroidUtilities.getIntDef("chatsTypingColor", tColor));
|
||||
|
||||
timePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsTimeSize", 13)));
|
||||
timePaint.setColor(themePrefs.getInt("chatsTimeColor", 0xff999999));
|
||||
|
||||
countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13)));
|
||||
countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff));
|
||||
|
||||
checkWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
|
||||
halfCheckWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
countWhiteDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.MULTIPLY);
|
||||
lockWhiteDrawable.setColorFilter(dColor, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
int nColor = themePrefs.getInt("chatsNameColor", 0xff000000);
|
||||
groupWhiteDrawable.setColorFilter(nColor, PorterDuff.Mode.MULTIPLY);
|
||||
broadcastWhiteDrawable.setColorFilter(nColor, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
int mColor = themePrefs.getInt("chatsMuteColor", 0xffa8a8a8);
|
||||
muteWhiteDrawable.setColorFilter(mColor, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
linePaint.setColor(themePrefs.getInt("chatsDividerColor", 0xffdcdcdc));
|
||||
|
||||
//int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatsAvatarRadius", 32));
|
||||
//if(avatarImage != null)avatarImage.setRoundRadius(radius);
|
||||
//if(avatarDrawable != null)avatarDrawable.setRadius(radius/3);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
|
||||
public class DividerCell extends BaseCell {
|
||||
|
||||
@ -30,6 +31,11 @@ public class DividerCell extends BaseCell {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(16) + 1);
|
||||
String key = getTag() != null ? getTag().toString() : null;
|
||||
if(key != null){
|
||||
int color = AndroidUtilities.getIntDef(key, 0xffffffff);
|
||||
paint.setColor(color == 0xffffffff ? 0xffd9d9d9 : color);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -197,9 +197,9 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
|
||||
}
|
||||
AvatarDrawable avatarDrawable = new AvatarDrawable(user);
|
||||
avatarDrawable.setColor(AndroidUtilities.getIntDef("drawerAvatarColor",AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
|
||||
//int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("drawerAvatarRadius", 32));
|
||||
//avatarDrawable.setRadius(radius/2);
|
||||
//avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(radius));
|
||||
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("drawerAvatarRadius", 32));
|
||||
avatarDrawable.setRadius(radius);
|
||||
avatarImageView.imageReceiver.setRoundRadius(radius);
|
||||
avatarImageView.setImage(photo, "50_50", avatarDrawable);
|
||||
if(AndroidUtilities.getBoolMain("hideMobile")){
|
||||
phoneTextView.setVisibility(GONE);
|
||||
|
@ -48,4 +48,8 @@ public class GreySectionCell extends FrameLayout {
|
||||
public void setText(String text) {
|
||||
textView.setText(text);
|
||||
}
|
||||
|
||||
public void setTextColor(int color) {
|
||||
textView.setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +44,9 @@ public class LetterSectionCell extends FrameLayout {
|
||||
public void setCellHeight(int height) {
|
||||
setLayoutParams(new ViewGroup.LayoutParams(AndroidUtilities.dp(54), height));
|
||||
}
|
||||
|
||||
public void setLetterColor(int color) {
|
||||
textView.setTextColor(color);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,4 +83,10 @@ public class PhotoEditToolCell extends FrameLayoutFixed {
|
||||
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.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -27,8 +26,8 @@ import org.telegram.ui.Components.FrameLayoutFixed;
|
||||
|
||||
public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
|
||||
|
||||
public static interface PhotoPickerAlbumsCellDelegate {
|
||||
public abstract void didSelectAlbum(MediaController.AlbumEntry albumEntry);
|
||||
public interface PhotoPickerAlbumsCellDelegate {
|
||||
void didSelectAlbum(MediaController.AlbumEntry albumEntry);
|
||||
}
|
||||
|
||||
private AlbumView[] albumViews;
|
||||
@ -180,11 +179,6 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
|
||||
albumViews[a].setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
||||
if (layoutParams != null) {
|
||||
layoutParams.height = AndroidUtilities.dp(4) + itemWidth;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(4) + itemWidth, MeasureSpec.EXACTLY));
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ import org.telegram.messenger.R;
|
||||
|
||||
public class PhotoPickerSearchCell extends LinearLayout {
|
||||
|
||||
public static interface PhotoPickerSearchCellDelegate {
|
||||
public abstract void didPressedSearchButton(int index);
|
||||
public interface PhotoPickerSearchCellDelegate {
|
||||
void didPressedSearchButton(int index);
|
||||
}
|
||||
|
||||
private class SearchButton extends FrameLayout {
|
||||
|
@ -14,7 +14,6 @@ import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@ -39,9 +38,9 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
|
||||
private int itemsCount;
|
||||
private boolean isFirst;
|
||||
|
||||
public static interface SharedPhotoVideoCellDelegate {
|
||||
public abstract void didClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
||||
public abstract boolean didLongClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
||||
public interface SharedPhotoVideoCellDelegate {
|
||||
void didClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
||||
boolean didLongClickItem(SharedPhotoVideoCell cell, int index, MessageObject messageObject, int a);
|
||||
}
|
||||
|
||||
private class PhotoVideoView extends FrameLayoutFixed {
|
||||
|
@ -96,10 +96,6 @@ public class TextCell extends FrameLayout {
|
||||
textView.setTextColor(color);
|
||||
}
|
||||
|
||||
public void setTextSize(int size) {
|
||||
textView.setTextSize(size);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
textView.setText(text);
|
||||
imageView.setVisibility(GONE);
|
||||
@ -115,6 +111,22 @@ public class TextCell extends FrameLayout {
|
||||
valueImageView.setVisibility(GONE);
|
||||
}
|
||||
|
||||
public void setTextSize(int size) {
|
||||
textView.setTextSize(size);
|
||||
}
|
||||
|
||||
public void setTextAndIcon(String text, Drawable drawable) {
|
||||
textView.setText(text);
|
||||
imageView.setImageDrawable(drawable);
|
||||
imageView.setVisibility(VISIBLE);
|
||||
valueTextView.setVisibility(GONE);
|
||||
valueImageView.setVisibility(GONE);
|
||||
}
|
||||
|
||||
public void setValueColor(int color) {
|
||||
valueTextView.setTextColor(color);
|
||||
}
|
||||
|
||||
public void setTextAndValue(String text, String value) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.telegram.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
@ -91,4 +92,19 @@ public class TextDetailCell extends FrameLayout {
|
||||
imageView.setVisibility(VISIBLE);
|
||||
imageView.setImageResource(resId);
|
||||
}
|
||||
|
||||
public void setTextAndValueAndIcon(String text, String value, Drawable drawable) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
imageView.setVisibility(VISIBLE);
|
||||
imageView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setTextColor(int color) {
|
||||
textView.setTextColor(color);
|
||||
}
|
||||
|
||||
public void setValueColor(int color) {
|
||||
valueTextView.setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.telegram.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.InputType;
|
||||
import android.util.TypedValue;
|
||||
@ -47,6 +48,7 @@ public class TextFieldCell extends LinearLayout {
|
||||
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
editText.setHintTextColor(0xffbebebe);
|
||||
editText.setTextColor(0xff212121);
|
||||
editText.getBackground().setColorFilter(AndroidUtilities.defColor, PorterDuff.Mode.SRC_IN);
|
||||
editText.setMaxLines(1);
|
||||
editText.setLines(1);
|
||||
editText.setSingleLine(true);
|
||||
|
@ -9,7 +9,6 @@
|
||||
package org.telegram.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
@ -17,11 +16,8 @@ import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class TextInfoCell extends FrameLayout {
|
||||
|
||||
private TextView textView;
|
||||
|
@ -57,9 +57,7 @@ public class TextSettingsCell extends FrameLayout {
|
||||
|
||||
valueTextView = new TextView(context);
|
||||
//valueTextView.setTextColor(0xff2f8cc9);
|
||||
//
|
||||
valueTextView.setTextColor(AndroidUtilities.getIntColor("themeColor"));
|
||||
//
|
||||
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
valueTextView.setLines(1);
|
||||
valueTextView.setMaxLines(1);
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.telegram.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
@ -52,6 +53,10 @@ public class UserCell extends FrameLayout {
|
||||
|
||||
private int nameColor = 0xff000000;
|
||||
|
||||
private Drawable curDrawable = null;
|
||||
|
||||
private int radius = 32;
|
||||
|
||||
public UserCell(Context context, int padding) {
|
||||
super(context);
|
||||
|
||||
@ -69,7 +74,6 @@ public class UserCell extends FrameLayout {
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
|
||||
nameTextView = new TextView(context);
|
||||
//ContactsNamesColor
|
||||
nameTextView.setTextColor(0xff212121);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
|
||||
nameTextView.setLines(1);
|
||||
@ -168,10 +172,6 @@ public class UserCell extends FrameLayout {
|
||||
statusOnlineColor = onlineColor;
|
||||
}
|
||||
|
||||
public void setNameColor(int color) {
|
||||
nameColor = color;
|
||||
}
|
||||
|
||||
public void update(int mask) {
|
||||
if (currentUser == null) {
|
||||
return;
|
||||
@ -239,9 +239,24 @@ public class UserCell extends FrameLayout {
|
||||
statusTextView.setTextSize(AndroidUtilities.getIntDef("contactsStatusSize", 14));
|
||||
imageView.setVisibility(currentDrawable == 0 ? GONE : VISIBLE);
|
||||
imageView.setImageResource(currentDrawable);
|
||||
if(curDrawable != null)imageView.setImageDrawable(curDrawable);
|
||||
|
||||
//int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("contactsAvatarRadius", 32));
|
||||
//avatarImageView.imageReceiver.setRoundRadius(radius);
|
||||
//avatarDrawable.setRadius(radius/3);
|
||||
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(radius));
|
||||
avatarDrawable.setRadius(AndroidUtilities.dp(radius));
|
||||
|
||||
avatarImageView.setImage(photo, "50_50", avatarDrawable);
|
||||
}
|
||||
|
||||
public void setNameColor(int color) {
|
||||
nameColor = color;
|
||||
}
|
||||
|
||||
public void setImageDrawable(Drawable drawable){
|
||||
curDrawable = drawable;
|
||||
}
|
||||
|
||||
public void setAvatarRadius(int value){
|
||||
radius = value;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.TypedValue;
|
||||
@ -95,6 +96,7 @@ public class ChangeChatNameActivity extends BaseFragment {
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
firstNameField.setHintTextColor(0xff979797);
|
||||
firstNameField.setTextColor(0xff212121);
|
||||
firstNameField.getBackground().setColorFilter(AndroidUtilities.getIntColor("themeColor"), PorterDuff.Mode.SRC_IN);
|
||||
firstNameField.setMaxLines(3);
|
||||
firstNameField.setPadding(0, 0, 0, 0);
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
|
@ -10,6 +10,7 @@ package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.text.InputType;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
@ -89,6 +90,7 @@ public class ChangeNameActivity extends BaseFragment {
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
firstNameField.setHintTextColor(0xff979797);
|
||||
firstNameField.setTextColor(0xff212121);
|
||||
firstNameField.getBackground().setColorFilter(AndroidUtilities.getIntColor("themeColor"), PorterDuff.Mode.SRC_IN);
|
||||
firstNameField.setMaxLines(1);
|
||||
firstNameField.setLines(1);
|
||||
firstNameField.setSingleLine(true);
|
||||
@ -121,6 +123,7 @@ public class ChangeNameActivity extends BaseFragment {
|
||||
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
lastNameField.setHintTextColor(0xff979797);
|
||||
lastNameField.setTextColor(0xff212121);
|
||||
lastNameField.getBackground().setColorFilter(AndroidUtilities.getIntColor("themeColor"), PorterDuff.Mode.SRC_IN);
|
||||
lastNameField.setMaxLines(1);
|
||||
lastNameField.setLines(1);
|
||||
lastNameField.setSingleLine(true);
|
||||
|
@ -11,6 +11,7 @@ package org.telegram.ui;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.Editable;
|
||||
@ -445,6 +446,7 @@ public class ChangePhoneActivity extends BaseFragment {
|
||||
phoneField = new EditText(context);
|
||||
phoneField.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||
phoneField.setTextColor(0xff212121);
|
||||
phoneField.getBackground().setColorFilter(AndroidUtilities.getIntColor("themeColor"), PorterDuff.Mode.SRC_IN);
|
||||
phoneField.setHintTextColor(0xff979797);
|
||||
phoneField.setPadding(0, 0, 0, 0);
|
||||
AndroidUtilities.clearCursorDrawable(phoneField);
|
||||
|
@ -13,6 +13,7 @@ import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.InputType;
|
||||
@ -99,6 +100,7 @@ public class ChangeUsernameActivity extends BaseFragment {
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
firstNameField.setHintTextColor(0xff979797);
|
||||
firstNameField.setTextColor(0xff212121);
|
||||
firstNameField.getBackground().setColorFilter(AndroidUtilities.getIntColor("themeColor"), PorterDuff.Mode.SRC_IN);
|
||||
firstNameField.setMaxLines(1);
|
||||
firstNameField.setLines(1);
|
||||
firstNameField.setPadding(0, 0, 0, 0);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
@ -32,16 +33,37 @@ public class AvatarDrawable extends Drawable {
|
||||
|
||||
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private static TextPaint namePaint;
|
||||
private static TextPaint namePaintSmall;
|
||||
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[] arrColorsProfilesBack = {0xffca6056, 0xfff18944, 0xff7d6ac4, 0xff56a14c, 0xff4492ac, 0xff4c84b6, 0xff7d6ac4, 0xff4c84b6};
|
||||
private static int[] arrColorsProfilesText = {0xfff9cbc5, 0xfffdddc8, 0xffcdc4ed, 0xffc0edba, 0xffb8e2f0, 0xffb3d7f7, 0xffcdc4ed, 0xffb3d7f7};
|
||||
private static int[] arrColorsNames = {0xffca5650, 0xffd87b29, 0xff4e92cc, 0xff50b232, 0xff42b1a8, 0xff4e92cc, 0xff4e92cc, 0xff4e92cc};
|
||||
//private static int[] arrColorsNames = {0xffca5650, 0xffd87b29, 0xff4e92cc, 0xff50b232, 0xff42b1a8, 0xff4e92cc, 0xff4e92cc, 0xff4e92cc};
|
||||
private static int[] arrColorsNames = {
|
||||
0xFFF44336, //RED
|
||||
0xFFE91E63, //PINK
|
||||
0xFF9C27B0, //PURPLE
|
||||
0xFF673AB7, //DEEP PURPLE
|
||||
0xFF3F51B5, //INDIGO
|
||||
0xFF2196F3, //BLUE
|
||||
0xFF03A9F4, //LIGHT BLUE
|
||||
0xFF00BCD4, //CYAN
|
||||
0xFF009688, //TEAL
|
||||
0xFF4CAF50, //GREEN
|
||||
0xFF8BC34A, //LIGHT GREEN
|
||||
0xFFCDDC39, //LIME
|
||||
0xFFFFEB3B, //YELLOW
|
||||
0xFFFFC107, //AMBER
|
||||
0xFFFF9800, //ORANGE
|
||||
0xFFFF5722, //DEEP ORANGE
|
||||
0xFF795548, //BROWN
|
||||
0xFF9E9E9E, //GREY
|
||||
0xFF607D8B //BLUE GREY
|
||||
};
|
||||
|
||||
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};
|
||||
|
||||
|
||||
|
||||
private static Drawable broadcastDrawable;
|
||||
private static Drawable photoDrawable;
|
||||
|
||||
@ -53,7 +75,8 @@ public class AvatarDrawable extends Drawable {
|
||||
private boolean isProfile;
|
||||
private boolean drawBrodcast;
|
||||
private boolean drawPhoto;
|
||||
//private int radius;
|
||||
private boolean smallStyle;
|
||||
private int radius;
|
||||
|
||||
public AvatarDrawable() {
|
||||
super();
|
||||
@ -63,9 +86,13 @@ public class AvatarDrawable extends Drawable {
|
||||
namePaint.setColor(0xffffffff);
|
||||
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);
|
||||
}
|
||||
//radius = 32;
|
||||
radius = 32;
|
||||
}
|
||||
|
||||
public AvatarDrawable(TLRPC.User user) {
|
||||
@ -92,8 +119,13 @@ public class AvatarDrawable extends Drawable {
|
||||
}
|
||||
}
|
||||
|
||||
public void setSmallStyle(boolean value) {
|
||||
smallStyle = value;
|
||||
}
|
||||
|
||||
public static int getColorIndex(int id) {
|
||||
if (id >= 0 && id < 8) {
|
||||
//To avoid too similar member colors
|
||||
if (id >= 0 && id < arrColors.length){//8) {
|
||||
return id;
|
||||
}
|
||||
try {
|
||||
@ -119,6 +151,30 @@ public class AvatarDrawable extends Drawable {
|
||||
return id % arrColors.length;
|
||||
}
|
||||
|
||||
public static int getColorNameIndex(int id) {
|
||||
try {
|
||||
String str;
|
||||
if (id >= 0) {
|
||||
str = String.format(Locale.US, "%d%d", id, UserConfig.getClientUserId());
|
||||
} else {
|
||||
str = String.format(Locale.US, "%d", id);
|
||||
}
|
||||
if (str.length() > 15) {
|
||||
str = str.substring(0, 15);
|
||||
}
|
||||
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md.digest(str.getBytes());
|
||||
int b = digest[Math.abs(id % 16)];
|
||||
if (b < 0) {
|
||||
b += 256;
|
||||
}
|
||||
return Math.abs(b) % arrColorsNames.length;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return id % arrColorsNames.length;
|
||||
}
|
||||
|
||||
public static int getColorForId(int id) {
|
||||
return arrColors[getColorIndex(id)];
|
||||
}
|
||||
@ -138,9 +194,12 @@ public class AvatarDrawable extends Drawable {
|
||||
public static int getProfileBackColorForId(int id) {
|
||||
return arrColorsProfilesBack[getColorIndex(id)];
|
||||
}
|
||||
|
||||
/*
|
||||
public static int getNameColorForId(int id) {
|
||||
return arrColorsNames[getColorIndex(id)];
|
||||
}*/
|
||||
public static int getNameColorForId(int id) {
|
||||
return arrColorsNames[getColorNameIndex(id)];
|
||||
}
|
||||
|
||||
public void setInfo(TLRPC.User user) {
|
||||
@ -158,7 +217,7 @@ public class AvatarDrawable extends Drawable {
|
||||
public void setColor(int value) {
|
||||
color = value;
|
||||
}
|
||||
/*
|
||||
|
||||
public void setRadius(int value) {
|
||||
radius = value;
|
||||
}
|
||||
@ -166,7 +225,7 @@ public class AvatarDrawable extends Drawable {
|
||||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
*/
|
||||
|
||||
public void setInfo(int id, String firstName, String lastName, boolean isBroadcast) {
|
||||
if (isProfile) {
|
||||
color = arrColorsProfiles[getColorIndex(id)];
|
||||
@ -216,7 +275,7 @@ public class AvatarDrawable extends Drawable {
|
||||
if (text.length() > 0) {
|
||||
text = text.toUpperCase();
|
||||
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) {
|
||||
textLeft = textLayout.getLineLeft(0);
|
||||
textWidth = textLayout.getLineWidth(0);
|
||||
@ -247,11 +306,12 @@ public class AvatarDrawable extends Drawable {
|
||||
paint.setColor(color);
|
||||
canvas.save();
|
||||
canvas.translate(bounds.left, bounds.top);
|
||||
canvas.drawCircle(size / 2, size / 2, size / 2, paint);
|
||||
/*Rect rect = new Rect(0, 0, size, size);
|
||||
//canvas.drawCircle(size / 2, size / 2, size / 2, paint);
|
||||
|
||||
Rect rect = new Rect(0, 0, size, size);
|
||||
RectF rectF = new RectF(rect);
|
||||
int r = getRadius();
|
||||
canvas.drawRoundRect( rectF, AndroidUtilities.dp(r), AndroidUtilities.dp(r), paint);*/
|
||||
canvas.drawRoundRect( rectF, r, r, paint);
|
||||
|
||||
if (drawBrodcast && broadcastDrawable != null) {
|
||||
int x = (size - broadcastDrawable.getIntrinsicWidth()) / 2;
|
||||
|
@ -45,8 +45,8 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||
private boolean clearAfterUpdate = false;
|
||||
public boolean returnOnly = false;
|
||||
|
||||
public static abstract interface AvatarUpdaterDelegate {
|
||||
public abstract void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big);
|
||||
public interface AvatarUpdaterDelegate {
|
||||
void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
@ -76,18 +76,13 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||
PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true);
|
||||
fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() {
|
||||
@Override
|
||||
public void didSelectPhotos(ArrayList<String> photos) {
|
||||
public void didSelectPhotos(ArrayList<String> photos, ArrayList<MediaController.SearchImage> webPhotos) {
|
||||
if (!photos.isEmpty()) {
|
||||
Bitmap bitmap = ImageLoader.loadBitmap(photos.get(0), null, 800, 800, true);
|
||||
processBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didSelectWebPhotos(ArrayList<MediaController.SearchImage> photos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPhotoSelectActivity() {
|
||||
try {
|
||||
|
@ -20,6 +20,7 @@ import android.os.PowerManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
@ -35,18 +36,21 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.SendMessagesHelper;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
@ -55,18 +59,19 @@ import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
|
||||
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 abstract void onMessageSend();
|
||||
public abstract void needSendTyping();
|
||||
public abstract void onTextChanged(CharSequence text);
|
||||
public abstract void onAttachButtonHidden();
|
||||
public abstract void onAttachButtonShow();
|
||||
public abstract void onWindowSizeChanged(int size);
|
||||
public interface ChatActivityEnterViewDelegate {
|
||||
void onMessageSend();
|
||||
void needSendTyping();
|
||||
void onTextChanged(CharSequence text);
|
||||
void onAttachButtonHidden();
|
||||
void onAttachButtonShow();
|
||||
void onWindowSizeChanged(int size);
|
||||
}
|
||||
|
||||
private EditText messsageEditText;
|
||||
@ -80,6 +85,8 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
private LinearLayout slideText;
|
||||
private SizeNotifierRelativeLayout sizeNotifierRelativeLayout;
|
||||
private FrameLayout attachButton;
|
||||
private LinearLayout textFieldContainer;
|
||||
private View topView;
|
||||
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
private AnimatorSetProxy runningAnimation;
|
||||
@ -97,16 +104,21 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
private float startedDraggingX = -1;
|
||||
private float distCanMove = AndroidUtilities.dp(80);
|
||||
private boolean recordingAudio;
|
||||
private boolean forceShowSendButton;
|
||||
|
||||
private Activity parentActivity;
|
||||
private BaseFragment parentFragment;
|
||||
private long dialog_id;
|
||||
private boolean ignoreTextChange;
|
||||
private MessageObject replyingMessageObject;
|
||||
private ChatActivityEnterViewDelegate delegate;
|
||||
|
||||
private float topViewAnimation;
|
||||
private boolean needShowTopView;
|
||||
private boolean allowShowTopView;
|
||||
|
||||
public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, BaseFragment fragment, boolean isChat) {
|
||||
super(context);
|
||||
setOrientation(HORIZONTAL);
|
||||
setBackgroundResource(R.drawable.compose_panel);
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
@ -127,9 +139,20 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
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);
|
||||
addView(frameLayout);
|
||||
LayoutParams layoutParams = (LayoutParams) frameLayout.getLayoutParams();
|
||||
textFieldContainer.addView(frameLayout);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
||||
layoutParams.width = 0;
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.weight = 1;
|
||||
@ -137,8 +160,8 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
|
||||
emojiButton = new ImageView(context);
|
||||
//emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
|
||||
Drawable emoji = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_smiles_white);
|
||||
emoji.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
|
||||
Drawable emoji = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_smiles);
|
||||
emoji.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
|
||||
emojiButton.setImageDrawable(emoji);
|
||||
emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
emojiButton.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(1), 0, 0);
|
||||
@ -147,7 +170,6 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
layoutParams1.width = AndroidUtilities.dp(48);
|
||||
layoutParams1.height = AndroidUtilities.dp(48);
|
||||
layoutParams1.gravity = Gravity.BOTTOM;
|
||||
layoutParams1.topMargin = AndroidUtilities.dp(2);
|
||||
emojiButton.setLayoutParams(layoutParams1);
|
||||
emojiButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -274,7 +296,6 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
layoutParams1.width = AndroidUtilities.dp(48);
|
||||
layoutParams1.height = AndroidUtilities.dp(48);
|
||||
layoutParams1.gravity = Gravity.BOTTOM | Gravity.RIGHT;
|
||||
layoutParams1.topMargin = AndroidUtilities.dp(2);
|
||||
attachButton.setLayoutParams(layoutParams1);
|
||||
}
|
||||
|
||||
@ -286,11 +307,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams1.height = AndroidUtilities.dp(48);
|
||||
layoutParams1.gravity = Gravity.BOTTOM;
|
||||
layoutParams1.topMargin = AndroidUtilities.dp(2);
|
||||
recordPanel.setLayoutParams(layoutParams1);
|
||||
|
||||
slideText = new LinearLayout(context);
|
||||
slideText.setOrientation(HORIZONTAL);
|
||||
slideText.setOrientation(LinearLayout.HORIZONTAL);
|
||||
recordPanel.addView(slideText);
|
||||
layoutParams1 = (FrameLayout.LayoutParams) slideText.getLayoutParams();
|
||||
layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||
@ -302,7 +322,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
ImageView imageView = new ImageView(context);
|
||||
imageView.setImageResource(R.drawable.slidearrow);
|
||||
slideText.addView(imageView);
|
||||
layoutParams = (LayoutParams) imageView.getLayoutParams();
|
||||
layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
@ -314,7 +334,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
textView.setTextColor(0xff999999);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
||||
slideText.addView(textView);
|
||||
layoutParams = (LayoutParams) textView.getLayoutParams();
|
||||
layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
@ -322,7 +342,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
textView.setLayoutParams(layoutParams);
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(HORIZONTAL);
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
linearLayout.setPadding(AndroidUtilities.dp(13), 0, 0, 0);
|
||||
linearLayout.setBackgroundColor(0xffffffff);
|
||||
recordPanel.addView(linearLayout);
|
||||
@ -335,7 +355,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
imageView = new ImageView(context);
|
||||
imageView.setImageResource(R.drawable.rec);
|
||||
linearLayout.addView(imageView);
|
||||
layoutParams = (LayoutParams) imageView.getLayoutParams();
|
||||
layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
@ -347,7 +367,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
recordTimeText.setTextColor(0xff4d4c4b);
|
||||
recordTimeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
linearLayout.addView(recordTimeText);
|
||||
layoutParams = (LayoutParams) recordTimeText.getLayoutParams();
|
||||
layoutParams = (LinearLayout.LayoutParams) recordTimeText.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
@ -355,20 +375,19 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
recordTimeText.setLayoutParams(layoutParams);
|
||||
|
||||
FrameLayout frameLayout1 = new FrameLayout(context);
|
||||
addView(frameLayout1);
|
||||
layoutParams = (LayoutParams) frameLayout1.getLayoutParams();
|
||||
textFieldContainer.addView(frameLayout1);
|
||||
layoutParams = (LinearLayout.LayoutParams) frameLayout1.getLayoutParams();
|
||||
layoutParams.width = AndroidUtilities.dp(48);
|
||||
layoutParams.height = AndroidUtilities.dp(48);
|
||||
layoutParams.gravity = Gravity.BOTTOM;
|
||||
layoutParams.topMargin = AndroidUtilities.dp(2);
|
||||
frameLayout1.setLayoutParams(layoutParams);
|
||||
|
||||
audioSendButton = new ImageView(context);
|
||||
audioSendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
//audioSendButton.setImageResource(R.drawable.mic_button_states);
|
||||
//audioSendButton.setBackgroundColor(0xffffffff);
|
||||
Drawable mic = parentActivity.getResources().getDrawable(R.drawable.mic_white);
|
||||
mic.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
|
||||
Drawable mic = parentActivity.getResources().getDrawable(R.drawable.mic);
|
||||
mic.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
|
||||
audioSendButton.setImageDrawable(mic);
|
||||
audioSendButton.setBackgroundColor(0x00000000);
|
||||
audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
||||
@ -380,10 +399,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
audioSendButton.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
Drawable mic = parentActivity.getResources().getDrawable(R.drawable.mic_white);
|
||||
Drawable mic = parentActivity.getResources().getDrawable(R.drawable.mic);
|
||||
|
||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
mic.setColorFilter(0xffda564d, PorterDuff.Mode.MULTIPLY);
|
||||
mic.setColorFilter(0xffda564d, PorterDuff.Mode.SRC_IN);
|
||||
audioSendButton.setImageDrawable(mic);
|
||||
if (parentFragment != null) {
|
||||
String action = null;
|
||||
@ -403,11 +422,11 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
}
|
||||
}
|
||||
startedDraggingX = -1;
|
||||
MediaController.getInstance().startRecording(dialog_id);
|
||||
MediaController.getInstance().startRecording(dialog_id, replyingMessageObject);
|
||||
updateAudioRecordIntefrace();
|
||||
audioSendButton.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
mic.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
|
||||
mic.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
|
||||
audioSendButton.setImageDrawable(mic);
|
||||
startedDraggingX = -1;
|
||||
MediaController.getInstance().stopRecording(true);
|
||||
@ -484,14 +503,144 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
}
|
||||
|
||||
private void updateTheme() {
|
||||
Drawable send = parentActivity.getResources().getDrawable(R.drawable.ic_send_white);
|
||||
send.setColorFilter(AndroidUtilities.getIntDef("chatSendIconColor", AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
|
||||
Drawable send = parentActivity.getResources().getDrawable(R.drawable.ic_send);
|
||||
send.setColorFilter(AndroidUtilities.getIntDef("chatSendIconColor", AndroidUtilities.getIntColor("chatEditTextIconsColor")), PorterDuff.Mode.SRC_IN);
|
||||
sendButton.setImageDrawable(send);
|
||||
messsageEditText.setTextColor(AndroidUtilities.getIntDef("chatEditTextColor",0xff000000));
|
||||
messsageEditText.setHintTextColor(AndroidUtilities.getIntAlphaColor("chatEditTextColor", 0xff000000, 0.35f));
|
||||
messsageEditText.setTextSize(AndroidUtilities.getIntDef("chatEditTextSize",18));
|
||||
int color = AndroidUtilities.getIntDef("chatEditTextBGColor", 0xffffffff);
|
||||
setBackgroundColor(color);
|
||||
textFieldContainer.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
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() {
|
||||
@ -521,6 +670,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
dialog_id = id;
|
||||
}
|
||||
|
||||
public void setReplyingMessageObject(MessageObject messageObject) {
|
||||
replyingMessageObject = messageObject;
|
||||
}
|
||||
|
||||
private void sendMessage() {
|
||||
if (parentFragment != null) {
|
||||
String action = null;
|
||||
@ -545,6 +698,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
if (delegate != null) {
|
||||
delegate.onMessageSend();
|
||||
}
|
||||
} else if (forceShowSendButton) {
|
||||
if (delegate != null) {
|
||||
delegate.onMessageSend();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,7 +711,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
int count = (int) Math.ceil(text.length() / 4096.0f);
|
||||
for (int a = 0; a < count; a++) {
|
||||
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;
|
||||
}
|
||||
@ -577,7 +734,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
|
||||
private void checkSendButton(final boolean animated) {
|
||||
String message = getTrimmedString(messsageEditText.getText().toString());
|
||||
if (message.length() > 0) {
|
||||
if (message.length() > 0 || forceShowSendButton) {
|
||||
if (audioSendButton.getVisibility() == View.VISIBLE) {
|
||||
if (animated) {
|
||||
if (runningAnimationType == 1) {
|
||||
@ -659,7 +816,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
if (attachButton != null) {
|
||||
attachButton.setVisibility(View.GONE);
|
||||
attachButton.clearAnimation();
|
||||
|
||||
delegate.onAttachButtonHidden();
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(0);
|
||||
messsageEditText.setLayoutParams(layoutParams);
|
||||
@ -738,6 +895,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
sendButton.clearAnimation();
|
||||
audioSendButton.setVisibility(View.VISIBLE);
|
||||
if (attachButton != null) {
|
||||
delegate.onAttachButtonShow();
|
||||
attachButton.setVisibility(View.VISIBLE);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messsageEditText.getLayoutParams();
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(50);
|
||||
@ -853,12 +1011,16 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
emojiPopup = new PopupWindow(emojiView);
|
||||
|
||||
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 {
|
||||
Field field = PopupWindow.class.getDeclaredField("mWindowLayoutType");
|
||||
field.setAccessible(true);
|
||||
field.set(emojiPopup, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
|
||||
} catch (Exception e) {
|
||||
/* ignored */
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -881,25 +1043,46 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
try {
|
||||
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), Gravity.BOTTOM | Gravity.LEFT, 0, 0);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (Build.VERSION.SDK_INT < 21) {
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
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) {
|
||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);
|
||||
//emojiButton.setImageResource(R.drawable.ic_msg_panel_hide);
|
||||
Drawable hide = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_hide_white);
|
||||
hide.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
|
||||
Drawable hide = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_hide);
|
||||
hide.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
|
||||
emojiButton.setImageDrawable(hide);
|
||||
if (delegate != null) {
|
||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
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);
|
||||
Drawable kb = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_kb_white);
|
||||
@ -909,8 +1092,8 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
}
|
||||
if (emojiButton != null) {
|
||||
//emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
|
||||
Drawable emoji = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_smiles_white);
|
||||
emoji.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
|
||||
Drawable emoji = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_smiles);
|
||||
emoji.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
|
||||
emojiButton.setImageDrawable(emoji);
|
||||
}
|
||||
if (emojiPopup != null) {
|
||||
@ -925,9 +1108,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
public void run() {
|
||||
if (sizeNotifierRelativeLayout != null) {
|
||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, 0);
|
||||
if (delegate != null) {
|
||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -940,6 +1121,10 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
}
|
||||
}
|
||||
|
||||
public void openKeyboard() {
|
||||
AndroidUtilities.showKeyboard(messsageEditText);
|
||||
}
|
||||
|
||||
public void setDelegate(ChatActivityEnterViewDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
@ -952,6 +1137,27 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
messsageEditText.setText(text);
|
||||
messsageEditText.setSelection(messsageEditText.getText().length());
|
||||
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) {
|
||||
@ -1013,16 +1219,13 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
|
||||
@Override
|
||||
public void onSizeChanged(int height) {
|
||||
Rect localRect = new Rect();
|
||||
parentActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
|
||||
|
||||
WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (wm == null || wm.getDefaultDisplay() == null) {
|
||||
return;
|
||||
}
|
||||
int rotation = wm.getDefaultDisplay().getRotation();
|
||||
|
||||
if (height > AndroidUtilities.dp(50) && keyboardVisible) {
|
||||
//if (height > AndroidUtilities.dp(50) && keyboardVisible) {
|
||||
if (height > AndroidUtilities.dp(50)) {
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
keyboardHeightLand = height;
|
||||
ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
|
||||
@ -1041,6 +1244,13 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
}
|
||||
final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) emojiPopup.getContentView().getLayoutParams();
|
||||
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.height = newHeight;
|
||||
wm.updateViewLayout(emojiPopup.getContentView(), layoutParams);
|
||||
@ -1051,9 +1261,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
if (sizeNotifierRelativeLayout != null) {
|
||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, layoutParams.height);
|
||||
sizeNotifierRelativeLayout.requestLayout();
|
||||
if (delegate != null) {
|
||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1068,9 +1276,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
|
||||
} else if (!keyboardVisible && keyboardVisible != oldValue && emojiPopup != null && emojiPopup.isShowing()) {
|
||||
showEmojiPopup(false);
|
||||
}
|
||||
if (delegate != null) {
|
||||
delegate.onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,8 +41,8 @@ public class ClippingImageView extends View {
|
||||
private RectF bitmapRect;
|
||||
private Matrix shaderMatrix;
|
||||
|
||||
public static interface onDrawListener {
|
||||
public abstract void onDraw();
|
||||
public interface onDrawListener {
|
||||
void onDraw();
|
||||
}
|
||||
|
||||
public ClippingImageView(Context context) {
|
||||
|
@ -89,11 +89,11 @@ public class ColorPickerView extends View {
|
||||
}
|
||||
|
||||
public interface OnColorChangedListener {
|
||||
public void onColorChanged(int color);
|
||||
void onColorChanged(int color);
|
||||
}
|
||||
|
||||
public interface OnColorSelectedListener {
|
||||
public void onColorSelected(int color);
|
||||
void onColorSelected(int color);
|
||||
}
|
||||
|
||||
public void setOnColorChangedListener(OnColorChangedListener listener) {
|
||||
|
@ -306,8 +306,8 @@ public class EmojiView extends LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract interface Listener {
|
||||
public abstract void onBackspace();
|
||||
public abstract void onEmojiSelected(String paramString);
|
||||
public interface Listener {
|
||||
void onBackspace();
|
||||
void onEmojiSelected(String paramString);
|
||||
}
|
||||
}
|
@ -20,8 +20,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
public class ForegroundDetector implements Application.ActivityLifecycleCallbacks {
|
||||
|
||||
public interface Listener {
|
||||
public void onBecameForeground();
|
||||
public void onBecameBackground();
|
||||
void onBecameForeground();
|
||||
void onBecameBackground();
|
||||
}
|
||||
|
||||
private int refs;
|
||||
|
@ -35,7 +35,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
|
||||
private int mDisplayOffset = 0;
|
||||
protected Scroller mScroller;
|
||||
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 OnItemClickListener mOnItemClicked;
|
||||
private OnItemLongClickListener mOnItemLongClicked;
|
||||
@ -251,7 +251,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
|
||||
int type = (Integer) child.getTag();
|
||||
LinkedList<View> list = mRemovedViewQueue.get(type);
|
||||
if (list == null) {
|
||||
list = new LinkedList<View>();
|
||||
list = new LinkedList<>();
|
||||
mRemovedViewQueue.put(type, list);
|
||||
}
|
||||
list.add(child);
|
||||
@ -266,7 +266,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
|
||||
int type = (Integer) child.getTag();
|
||||
LinkedList<View> list = mRemovedViewQueue.get(type);
|
||||
if (list == null) {
|
||||
list = new LinkedList<View>();
|
||||
list = new LinkedList<>();
|
||||
mRemovedViewQueue.put(type, list);
|
||||
}
|
||||
list.add(child);
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
@ -16,12 +17,13 @@ import android.widget.ListView;
|
||||
|
||||
public class LayoutListView extends ListView {
|
||||
|
||||
public static interface OnInterceptTouchEventListener {
|
||||
public abstract boolean onInterceptTouchEvent(MotionEvent event);
|
||||
public interface OnInterceptTouchEventListener {
|
||||
boolean onInterceptTouchEvent(MotionEvent event);
|
||||
}
|
||||
|
||||
private OnInterceptTouchEventListener onInterceptTouchEventListener;
|
||||
private int height = -1;
|
||||
private int forceTop = Integer.MIN_VALUE;
|
||||
|
||||
public LayoutListView(Context context) {
|
||||
super(context);
|
||||
@ -39,6 +41,10 @@ public class LayoutListView extends ListView {
|
||||
onInterceptTouchEventListener = listener;
|
||||
}
|
||||
|
||||
public void setForceTop(int value) {
|
||||
forceTop = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (onInterceptTouchEventListener != null) {
|
||||
@ -47,25 +53,32 @@ public class LayoutListView extends ListView {
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@SuppressLint("DrawAllocation")
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
View v = getChildAt(getChildCount() - 1);
|
||||
int scrollTo = getLastVisiblePosition();
|
||||
if (v != null && height > 0 && changed && ((bottom - top) < height)) {
|
||||
int b = height - v.getTop();
|
||||
final int scrollTo = getLastVisiblePosition();
|
||||
int lastTop = forceTop == Integer.MIN_VALUE ? (bottom - top) - (height - v.getTop()) - getPaddingTop() : forceTop;
|
||||
forceTop = Integer.MIN_VALUE;
|
||||
setSelectionFromTop(scrollTo, lastTop);
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
final int offset = (bottom - top) - b;
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setSelectionFromTop(scrollTo, offset - getPaddingTop());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// post(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// try {
|
||||
// setSelectionFromTop(scrollTo, lastTop);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
if (forceTop != Integer.MIN_VALUE) {
|
||||
setSelectionFromTop(scrollTo, forceTop);
|
||||
forceTop = Integer.MIN_VALUE;
|
||||
}
|
||||
try {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
} catch (Exception e) {
|
||||
|
@ -112,15 +112,15 @@ public class NumberPicker extends LinearLayout {
|
||||
}
|
||||
|
||||
public interface OnScrollListener {
|
||||
public static int SCROLL_STATE_IDLE = 0;
|
||||
public static int SCROLL_STATE_TOUCH_SCROLL = 1;
|
||||
public static int SCROLL_STATE_FLING = 2;
|
||||
int SCROLL_STATE_IDLE = 0;
|
||||
int SCROLL_STATE_TOUCH_SCROLL = 1;
|
||||
int SCROLL_STATE_FLING = 2;
|
||||
|
||||
public void onScrollStateChange(NumberPicker view, int scrollState);
|
||||
void onScrollStateChange(NumberPicker view, int scrollState);
|
||||
}
|
||||
|
||||
public interface Formatter {
|
||||
public String format(int value);
|
||||
String format(int value);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
@ -38,7 +38,7 @@ import org.telegram.messenger.R;
|
||||
public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||
|
||||
public interface IconTabProvider {
|
||||
public int getPageIconResId(int position);
|
||||
int getPageIconResId(int position);
|
||||
}
|
||||
|
||||
private LinearLayout.LayoutParams defaultTabLayoutParams;
|
||||
|
@ -59,8 +59,8 @@ import java.util.Locale;
|
||||
|
||||
public class PasscodeView extends FrameLayout {
|
||||
|
||||
public static interface PasscodeViewDelegate {
|
||||
public abstract void didAcceptedPassword();
|
||||
public interface PasscodeViewDelegate {
|
||||
void didAcceptedPassword();
|
||||
}
|
||||
|
||||
private class AnimatingTextView extends FrameLayout {
|
||||
|
@ -22,8 +22,8 @@ import org.telegram.messenger.FileLog;
|
||||
|
||||
public class PhotoCropView extends FrameLayout {
|
||||
|
||||
public static interface PhotoCropViewDelegate {
|
||||
public abstract void needMoveImageTo(float x, float y, float s, boolean animated);
|
||||
public interface PhotoCropViewDelegate {
|
||||
void needMoveImageTo(float x, float y, float s, boolean animated);
|
||||
}
|
||||
|
||||
private boolean freeformCrop = true;
|
||||
|
@ -28,8 +28,8 @@ public class PhotoEditorSeekBar extends View {
|
||||
private int maxValue;
|
||||
private PhotoEditorSeekBarDelegate delegate;
|
||||
|
||||
public abstract interface PhotoEditorSeekBarDelegate {
|
||||
public void onProgressChanged();
|
||||
public interface PhotoEditorSeekBarDelegate {
|
||||
void onProgressChanged();
|
||||
}
|
||||
|
||||
public PhotoEditorSeekBar(Context context) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,12 +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;
|
||||
|
||||
public class PhotoFilterRadialBlurControl {
|
||||
}
|
@ -71,8 +71,8 @@ public class PhotoFilterView extends FrameLayout {
|
||||
private int shadowsTool = 6;
|
||||
private int vignetteTool = 7;
|
||||
private int grainTool = 8;
|
||||
private int blurTool = -1;
|
||||
private int sharpenTool = 9;
|
||||
private int blurTool = 9;
|
||||
private int sharpenTool = 10;
|
||||
|
||||
private float highlightsValue = 0; //0 100
|
||||
private float contrastValue = 0; //-100 100
|
||||
@ -84,18 +84,29 @@ public class PhotoFilterView extends FrameLayout {
|
||||
private float vignetteValue = 0; //0 100
|
||||
private float grainValue = 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 PhotoEditorSeekBar valueSeekBar;
|
||||
private FrameLayout toolsView;
|
||||
private FrameLayout editView;
|
||||
private TextView paramTextView;
|
||||
private TextView blurTextView;
|
||||
private TextView valueTextView;
|
||||
private TextView doneTextView;
|
||||
private TextView cancelTextView;
|
||||
private TextureView textureView;
|
||||
private EGLThread eglThread;
|
||||
private RecyclerListView recyclerListView;
|
||||
private FrameLayout blurLayout;
|
||||
private PhotoFilterBlurControl blurControl;
|
||||
private TextView blurOffButton;
|
||||
private TextView blurRadialButton;
|
||||
private TextView blurLinearButton;
|
||||
|
||||
private Bitmap bitmapToEdit;
|
||||
private int orientation;
|
||||
@ -112,6 +123,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||
private EGLSurface eglSurface;
|
||||
private GL gl;
|
||||
private boolean initied;
|
||||
private boolean needUpdateBlurTexture = true;
|
||||
|
||||
private Bitmap currentBitmap;
|
||||
|
||||
@ -142,6 +154,34 @@ public class PhotoFilterView extends FrameLayout {
|
||||
private int widthHandle;
|
||||
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 sharpenHandle;
|
||||
private int sharpenWidthHandle;
|
||||
@ -156,8 +196,8 @@ public class PhotoFilterView extends FrameLayout {
|
||||
private int simpleSourceImageHandle;
|
||||
|
||||
private int[] enhanceTextures = new int[2];
|
||||
private int[] renderTexture = new int[2];
|
||||
private int[] renderFrameBuffer = new int[2];
|
||||
private int[] renderTexture = new int[3];
|
||||
private int[] renderFrameBuffer = new int[3];
|
||||
private boolean hsvGenerated;
|
||||
private int renderBufferWidth;
|
||||
private int renderBufferHeight;
|
||||
@ -168,9 +208,81 @@ public class PhotoFilterView extends FrameLayout {
|
||||
private FloatBuffer textureBuffer;
|
||||
private FloatBuffer vertexInvertBuffer;
|
||||
|
||||
private boolean blured;
|
||||
|
||||
private final static int PGPhotoEnhanceHistogramBins = 256;
|
||||
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 =
|
||||
"precision highp float;" +
|
||||
"varying vec2 texCoord;" +
|
||||
@ -628,6 +740,97 @@ public class PhotoFilterView extends FrameLayout {
|
||||
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);
|
||||
fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, rgbToHsvFragmentShaderCode);
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -743,130 +1145,10 @@ public class PhotoFilterView extends FrameLayout {
|
||||
}
|
||||
|
||||
GLES20.glViewport(0, 0, renderBufferWidth, renderBufferHeight);
|
||||
//enhance draw
|
||||
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);
|
||||
|
||||
//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);
|
||||
drawEnhancePass();
|
||||
drawSharpenPass();
|
||||
drawCustomParamsPass();
|
||||
blured = drawBlurPass();
|
||||
|
||||
//onscreen draw
|
||||
GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
|
||||
@ -875,7 +1157,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||
|
||||
GLES20.glUseProgram(simpleShaderProgram);
|
||||
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.glEnableVertexAttribArray(simpleInputTexCoordHandle);
|
||||
GLES20.glVertexAttribPointer(simpleInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
|
||||
@ -905,7 +1187,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||
@Override
|
||||
public void run() {
|
||||
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);
|
||||
object[0] = getRenderBufferBitmap();
|
||||
semaphore.release();
|
||||
@ -973,8 +1255,8 @@ public class PhotoFilterView extends FrameLayout {
|
||||
|
||||
currentBitmap = createBitmap(bitmap, renderBufferWidth, renderBufferHeight, scale);
|
||||
}
|
||||
GLES20.glGenFramebuffers(2, renderFrameBuffer, 0);
|
||||
GLES20.glGenTextures(2, renderTexture, 0);
|
||||
GLES20.glGenFramebuffers(3, renderFrameBuffer, 0);
|
||||
GLES20.glGenTextures(3, renderTexture, 0);
|
||||
|
||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
|
||||
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_T, GL10.GL_CLAMP_TO_EDGE);
|
||||
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() {
|
||||
@ -1016,9 +1305,17 @@ public class PhotoFilterView extends FrameLayout {
|
||||
super.run();
|
||||
}
|
||||
|
||||
public void requestRender() {
|
||||
cancelRunnable(drawRunnable);
|
||||
postRunnable(drawRunnable);
|
||||
public void requestRender(final boolean updateBlur) {
|
||||
postRunnable(new Runnable() {
|
||||
@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) {
|
||||
eglThread = new EGLThread(surface, bitmapToEdit);
|
||||
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) {
|
||||
if (eglThread != null) {
|
||||
eglThread.setSurfaceTextureSize(width, height);
|
||||
eglThread.requestRender();
|
||||
eglThread.requestRender(false);
|
||||
eglThread.postRunnable(new Runnable() {
|
||||
@Override
|
||||
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);
|
||||
addView(toolsView);
|
||||
layoutParams = (LayoutParams) toolsView.getLayoutParams();
|
||||
@ -1186,7 +1504,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||
valueSeekBar.setMinMax(0, 100);
|
||||
paramTextView.setText(LocaleController.getString("Sharpen", R.string.Sharpen));
|
||||
} else if (i == blurTool) {
|
||||
|
||||
previousValue = blurType;
|
||||
}
|
||||
valueSeekBar.setProgress((int) previousValue, false);
|
||||
updateValueTextView();
|
||||
@ -1245,9 +1563,11 @@ public class PhotoFilterView extends FrameLayout {
|
||||
grainValue = previousValue;
|
||||
} else if (selectedTool == sharpenTool) {
|
||||
sharpenValue = previousValue;
|
||||
} else if (selectedTool == blurTool) {
|
||||
blurType = (int) previousValue;
|
||||
}
|
||||
if (eglThread != null) {
|
||||
eglThread.requestRender();
|
||||
eglThread.requestRender(selectedTool != blurTool);
|
||||
}
|
||||
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.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
||||
paramTextView.setTextColor(0xff808080);
|
||||
@ -1321,12 +1653,12 @@ public class PhotoFilterView extends FrameLayout {
|
||||
}
|
||||
updateValueTextView();
|
||||
if (eglThread != null) {
|
||||
eglThread.requestRender();
|
||||
eglThread.requestRender(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
editView.addView(valueSeekBar);
|
||||
layoutParams = (FrameLayout.LayoutParams) valueSeekBar.getLayoutParams();
|
||||
layoutParams = (LayoutParams) valueSeekBar.getLayoutParams();
|
||||
layoutParams.height = AndroidUtilities.dp(60);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(14);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(14);
|
||||
@ -1339,6 +1671,113 @@ public class PhotoFilterView extends FrameLayout {
|
||||
layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
|
||||
}
|
||||
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() {
|
||||
@ -1387,13 +1826,13 @@ public class PhotoFilterView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowOriginal(boolean value) {
|
||||
private void setShowOriginal(boolean value) {
|
||||
if (showOriginal == value) {
|
||||
return;
|
||||
}
|
||||
showOriginal = value;
|
||||
if (eglThread != null) {
|
||||
eglThread.requestRender();
|
||||
eglThread.requestRender(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1403,10 +1842,30 @@ public class PhotoFilterView extends FrameLayout {
|
||||
if (editView.getVisibility() == GONE) {
|
||||
viewFrom = toolsView;
|
||||
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 {
|
||||
selectedTool = -1;
|
||||
viewFrom = editView;
|
||||
viewTo = toolsView;
|
||||
blurControl.setVisibility(INVISIBLE);
|
||||
}
|
||||
|
||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||
@ -1495,6 +1954,11 @@ public class PhotoFilterView extends FrameLayout {
|
||||
layoutParams.height = (int) bitmapH;
|
||||
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()) {
|
||||
int total = AndroidUtilities.dp(86) * 10;
|
||||
layoutParams = (FrameLayout.LayoutParams) recyclerListView.getLayoutParams();
|
||||
@ -1613,7 +2077,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 10;
|
||||
return 11;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1651,7 +2115,13 @@ public class PhotoFilterView extends FrameLayout {
|
||||
} else if (i == sharpenTool) {
|
||||
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_details, LocaleController.getString("Sharpen", R.string.Sharpen), sharpenValue);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import android.view.View;
|
||||
public class RecyclerListView extends RecyclerView {
|
||||
|
||||
public interface OnItemClickListener {
|
||||
public void onItemClick(View view, int position);
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
|
||||
public static class RecyclerListViewItemClickListener implements RecyclerView.OnItemTouchListener {
|
||||
|
@ -19,8 +19,8 @@ import org.telegram.messenger.R;
|
||||
|
||||
public class SeekBar {
|
||||
|
||||
public abstract interface SeekBarDelegate {
|
||||
public void onSeekBarDrag(float progress);
|
||||
public interface SeekBarDelegate {
|
||||
void onSeekBarDrag(float progress);
|
||||
}
|
||||
|
||||
private static Drawable thumbDrawable1;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
@ -26,8 +27,8 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
|
||||
private int keyboardHeight;
|
||||
private SizeNotifierRelativeLayoutDelegate delegate;
|
||||
|
||||
public abstract interface SizeNotifierRelativeLayoutDelegate {
|
||||
public abstract void onSizeChanged(int keyboardHeight);
|
||||
public interface SizeNotifierRelativeLayoutDelegate {
|
||||
void onSizeChanged(int keyboardHeight);
|
||||
}
|
||||
|
||||
public SizeNotifierRelativeLayout(Context context) {
|
||||
@ -62,16 +63,24 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@SuppressLint("DrawAllocation")
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
if (delegate != null) {
|
||||
if (changed && delegate != null) {
|
||||
View rootView = this.getRootView();
|
||||
int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
|
||||
this.getWindowVisibleDisplayFrame(rect);
|
||||
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
|
||||
|
@ -25,8 +25,8 @@ import org.telegram.messenger.R;
|
||||
|
||||
public class SlidingTabView extends LinearLayout {
|
||||
|
||||
public static interface SlidingTabViewDelegate {
|
||||
public abstract void didSelectTab(int tab);
|
||||
public interface SlidingTabViewDelegate {
|
||||
void didSelectTab(int tab);
|
||||
}
|
||||
|
||||
private SlidingTabViewDelegate delegate;
|
||||
|
@ -30,8 +30,8 @@ public class VideoSeekBarView extends View {
|
||||
private boolean pressed = false;
|
||||
public SeekBarDelegate delegate;
|
||||
|
||||
public abstract interface SeekBarDelegate {
|
||||
public void onSeekBarDrag(float progress);
|
||||
public interface SeekBarDelegate {
|
||||
void onSeekBarDrag(float progress);
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
|
@ -48,9 +48,9 @@ public class VideoTimelineView extends View {
|
||||
private int framesToLoad = 0;
|
||||
private Drawable pickDrawable = null;
|
||||
|
||||
public abstract interface VideoTimelineViewDelegate {
|
||||
public void onLeftProgressChanged(float progress);
|
||||
public void onRifhtProgressChanged(float progress);
|
||||
public interface VideoTimelineViewDelegate {
|
||||
void onLeftProgressChanged(float progress);
|
||||
void onRifhtProgressChanged(float progress);
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
|
@ -74,6 +74,9 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
if (avatarImage != null) {
|
||||
avatarImage.setImageDrawable(null);
|
||||
}
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
private boolean allowUsernameSearch = true;
|
||||
private ContactsActivityDelegate delegate;
|
||||
|
||||
public static interface ContactsActivityDelegate {
|
||||
public abstract void didSelectContact(TLRPC.User user, String param);
|
||||
public interface ContactsActivityDelegate {
|
||||
void didSelectContact(TLRPC.User user, String param);
|
||||
}
|
||||
|
||||
public ContactsActivity(Bundle args) {
|
||||
@ -156,7 +156,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSearchCollapse() {
|
||||
public boolean onSearchCollapse() {
|
||||
searchListViewAdapter.searchDialogs(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
@ -168,6 +168,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
listView.setFastScrollEnabled(true);
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -418,13 +419,13 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
builder.setView(editText);
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
didSelectResult(user, false, editText.getText().toString());
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showAlertDialog(builder);
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)editText.getLayoutParams();
|
||||
if (layoutParams != null) {
|
||||
|
@ -36,8 +36,8 @@ import org.telegram.ui.Components.LetterSectionsListView;
|
||||
|
||||
public class CountrySelectActivity extends BaseFragment {
|
||||
|
||||
public static interface CountrySelectActivityDelegate {
|
||||
public abstract void didSelectCountry(String name);
|
||||
public interface CountrySelectActivityDelegate {
|
||||
void didSelectCountry(String name);
|
||||
}
|
||||
|
||||
private LetterSectionsListView listView;
|
||||
@ -84,7 +84,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSearchCollapse() {
|
||||
public boolean onSearchCollapse() {
|
||||
searchListViewAdapter.search(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
@ -96,6 +96,8 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
|
||||
emptyTextView.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,9 +51,9 @@ import java.util.HashMap;
|
||||
|
||||
public class DocumentSelectActivity extends BaseFragment {
|
||||
|
||||
public static abstract interface DocumentSelectActivityDelegate {
|
||||
public void didSelectFiles(DocumentSelectActivity activity, ArrayList<String> files);
|
||||
public void startDocumentSelectActivity();
|
||||
public interface DocumentSelectActivityDelegate {
|
||||
void didSelectFiles(DocumentSelectActivity activity, ArrayList<String> files);
|
||||
void startDocumentSelectActivity();
|
||||
}
|
||||
|
||||
private ListView listView;
|
||||
@ -493,7 +493,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
||||
if (getParentActivity() == null) {
|
||||
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() {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user