mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
update to 2.3.6
This commit is contained in:
parent
c824df619a
commit
27b74b537e
8 changed files with 196 additions and 98 deletions
|
@ -141,7 +141,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
void setTimeDifference(int diff) {
|
void setTimeDifference(int diff) {
|
||||||
boolean store = Math.abs(diff - timeDifference) > 25;
|
boolean store = Math.abs(diff - timeDifference) > 25;
|
||||||
timeDifference = diff;
|
timeDifference = diff;
|
||||||
//_timeOffsetFromUTC = _timeDifference + (int)[[NSTimeZone localTimeZone] secondsFromGMT];
|
|
||||||
if (store) {
|
if (store) {
|
||||||
saveSession();
|
saveSession();
|
||||||
}
|
}
|
||||||
|
@ -596,18 +595,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
datacenter.connection.datacenterId = datacenter.datacenterId;
|
datacenter.connection.datacenterId = datacenter.datacenterId;
|
||||||
}
|
}
|
||||||
datacenter.connection.connect();
|
datacenter.connection.connect();
|
||||||
/*if (it == currentDatacenterId) {
|
|
||||||
boolean isConnecting = datacenter.connection.channelToken != 0;
|
|
||||||
if (isConnecting) {
|
|
||||||
_isWaitingForFirstData = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isConnecting != isConnecting)
|
|
||||||
{
|
|
||||||
_isConnecting = isConnecting;
|
|
||||||
[self dispatchConnectingState];
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int it : downloadTransportsToResume) {
|
for (int it : downloadTransportsToResume) {
|
||||||
|
@ -1092,7 +1079,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int num : unauthorizedDatacenterIds) {
|
for (int num : unauthorizedDatacenterIds) {
|
||||||
if (num != currentDatacenterId && num != movingToDatacenterId && UserConfig.clientUserId != 0/* && unavailableDatacenterIds.get(num) == null*/) {
|
if (num != currentDatacenterId && num != movingToDatacenterId && UserConfig.clientUserId != 0) {
|
||||||
boolean notFound = true;
|
boolean notFound = true;
|
||||||
for (Action actor : actionQueue) {
|
for (Action actor : actionQueue) {
|
||||||
if (actor instanceof ExportAuthorizationAction) {
|
if (actor instanceof ExportAuthorizationAction) {
|
||||||
|
@ -1205,7 +1192,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
|
|
||||||
currentSize += protoMessage.bytes;
|
currentSize += protoMessage.bytes;
|
||||||
|
|
||||||
// || currentMessages.size() == 5
|
|
||||||
if (currentSize >= 3 * 1024 || a == messagesToSend.size() - 1) {
|
if (currentSize >= 3 * 1024 || a == messagesToSend.size() - 1) {
|
||||||
ArrayList<Integer> quickAckId = new ArrayList<Integer>();
|
ArrayList<Integer> quickAckId = new ArrayList<Integer>();
|
||||||
byte[] transportData = createConnectionData(currentMessages, sessionId, quickAckId, connection);
|
byte[] transportData = createConnectionData(currentMessages, sessionId, quickAckId, connection);
|
||||||
|
@ -1450,8 +1436,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
|
|
||||||
saveSession();
|
saveSession();
|
||||||
|
|
||||||
//if (sessionId == datacenter.authSessionId && [datacenter.datacenterId isEqualToValue:currentDatacenterId])
|
if (sessionId == datacenter.authSessionId && datacenter.datacenterId == currentDatacenterId && UserConfig.clientActivated) {
|
||||||
// [TGTelegraphInstance stateUpdateRequired];
|
MessagesController.Instance.getDifference();
|
||||||
|
}
|
||||||
arr.add(newSession.unique_id);
|
arr.add(newSession.unique_id);
|
||||||
}
|
}
|
||||||
} else if (message instanceof TLRPC.TL_msg_container) {
|
} else if (message instanceof TLRPC.TL_msg_container) {
|
||||||
|
@ -1894,20 +1881,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tcpConnectionConnected(TcpConnection connection) {
|
public void tcpConnectionConnected(TcpConnection connection) {
|
||||||
/*int requestClass = [transport transportRequestClass];
|
|
||||||
if ([transport datacenter].datacenterId == _currentDatacenterId && requestClass & TGRequestClassGeneric)
|
|
||||||
{
|
|
||||||
if (_isConnecting)
|
|
||||||
{
|
|
||||||
_isConnecting = false;
|
|
||||||
_isWaitingForFirstData = true;
|
|
||||||
[self dispatchConnectingState];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_isReady)
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Datacenter datacenter = datacenterWithId(connection.datacenterId);
|
Datacenter datacenter = datacenterWithId(connection.datacenterId);
|
||||||
if (datacenter.authKey != null) {
|
if (datacenter.authKey != null) {
|
||||||
processRequestQueue(connection.transportRequestClass, connection.datacenterId);
|
processRequestQueue(connection.transportRequestClass, connection.datacenterId);
|
||||||
|
|
|
@ -402,18 +402,6 @@ public class Emoji {
|
||||||
if(bmps[info.page] == null) {
|
if(bmps[info.page] == null) {
|
||||||
loadPageAsync(info.page);
|
loadPageAsync(info.page);
|
||||||
}
|
}
|
||||||
/*drawables.add(new WeakReference<EmojiDrawable>(ed));
|
|
||||||
try {
|
|
||||||
for (int a = 0; a < drawables.size(); a++) {
|
|
||||||
WeakReference<EmojiDrawable> it = drawables.get(a);
|
|
||||||
if (it.get() == null) {
|
|
||||||
drawables.remove(a);
|
|
||||||
a--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(Throwable x) {
|
|
||||||
x.printStackTrace();
|
|
||||||
}*/
|
|
||||||
return ed;
|
return ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +495,8 @@ public class Emoji {
|
||||||
s = Spannable.Factory.getInstance().newSpannable(cs);
|
s = Spannable.Factory.getInstance().newSpannable(cs);
|
||||||
}
|
}
|
||||||
long buf = 0;
|
long buf = 0;
|
||||||
for (int i = 0; i < cs.length(); i++){
|
int emojiCount = 0;
|
||||||
|
for (int i = 0; i < cs.length(); i++) {
|
||||||
char c = cs.charAt(i);
|
char c = cs.charAt(i);
|
||||||
if (c == 0xD83C || c == 0xD83D || (buf != 0 && (buf & 0xFFFFFFFF00000000L) == 0 && (c >= 0xDDE6 && c <= 0xDDFA))) {
|
if (c == 0xD83C || c == 0xD83D || (buf != 0 && (buf & 0xFFFFFFFF00000000L) == 0 && (c >= 0xDDE6 && c <= 0xDDFA))) {
|
||||||
buf <<= 16;
|
buf <<= 16;
|
||||||
|
@ -518,6 +507,7 @@ public class Emoji {
|
||||||
Drawable d = Emoji.getEmojiDrawable(buf);
|
Drawable d = Emoji.getEmojiDrawable(buf);
|
||||||
if (d != null){
|
if (d != null){
|
||||||
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
|
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
|
||||||
|
emojiCount++;
|
||||||
if (c>= 0xDDE6 && c <= 0xDDFA) {
|
if (c>= 0xDDE6 && c <= 0xDDFA) {
|
||||||
s.setSpan(span, i - 3, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
s.setSpan(span, i - 3, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -535,6 +525,7 @@ public class Emoji {
|
||||||
Drawable d = Emoji.getEmojiDrawable(buf);
|
Drawable d = Emoji.getEmojiDrawable(buf);
|
||||||
if(d != null) {
|
if(d != null) {
|
||||||
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
|
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
|
||||||
|
emojiCount++;
|
||||||
s.setSpan(span, i - 1, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
s.setSpan(span, i - 1, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
buf = 0;
|
buf = 0;
|
||||||
|
@ -544,9 +535,13 @@ public class Emoji {
|
||||||
Drawable d = Emoji.getEmojiDrawable(c);
|
Drawable d = Emoji.getEmojiDrawable(c);
|
||||||
if(d != null){
|
if(d != null){
|
||||||
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
|
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
|
||||||
|
emojiCount++;
|
||||||
s.setSpan(span, i, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
s.setSpan(span, i, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (emojiCount >= 50) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class FileUploadOperation {
|
public class FileUploadOperation {
|
||||||
private final int uploadChunkSize = 1024 * 32;
|
private int uploadChunkSize = 1024 * 32;
|
||||||
private String uploadingFilePath;
|
private String uploadingFilePath;
|
||||||
public int state = 0;
|
public int state = 0;
|
||||||
private byte[] readBuffer = new byte[uploadChunkSize];
|
private byte[] readBuffer;
|
||||||
public FileUploadOperationDelegate delegate;
|
public FileUploadOperationDelegate delegate;
|
||||||
private long requestToken = 0;
|
private long requestToken = 0;
|
||||||
private int currentPartNum = 0;
|
private int currentPartNum = 0;
|
||||||
|
@ -103,6 +103,9 @@ public class FileUploadOperation {
|
||||||
File cacheFile = new File(uploadingFilePath);
|
File cacheFile = new File(uploadingFilePath);
|
||||||
stream = new FileInputStream(cacheFile);
|
stream = new FileInputStream(cacheFile);
|
||||||
totalFileSize = cacheFile.length();
|
totalFileSize = cacheFile.length();
|
||||||
|
|
||||||
|
uploadChunkSize = (int)Math.max(32, Math.ceil(totalFileSize / (1024.0f * 3000))) * 1024;
|
||||||
|
readBuffer = new byte[uploadChunkSize];
|
||||||
}
|
}
|
||||||
int readed = stream.read(readBuffer);
|
int readed = stream.read(readBuffer);
|
||||||
int toAdd = 0;
|
int toAdd = 0;
|
||||||
|
|
|
@ -25,7 +25,6 @@ import android.util.Log;
|
||||||
import com.google.android.gms.gcm.GoogleCloudMessaging;
|
import com.google.android.gms.gcm.GoogleCloudMessaging;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.telegram.TL.TLRPC;
|
|
||||||
import org.telegram.ui.ApplicationLoader;
|
import org.telegram.ui.ApplicationLoader;
|
||||||
import org.telegram.ui.LaunchActivity;
|
import org.telegram.ui.LaunchActivity;
|
||||||
|
|
||||||
|
@ -118,8 +117,6 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
int chat_id = 0;
|
int chat_id = 0;
|
||||||
int user_id = 0;
|
int user_id = 0;
|
||||||
TLRPC.User user = null;
|
|
||||||
TLRPC.Chat chat = null;
|
|
||||||
String custom = extras.getString("custom");
|
String custom = extras.getString("custom");
|
||||||
try {
|
try {
|
||||||
if (custom != null) {
|
if (custom != null) {
|
||||||
|
@ -171,7 +168,6 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needVibrate;
|
boolean needVibrate;
|
||||||
boolean needPreview = true;
|
|
||||||
String choosenSoundPath = null;
|
String choosenSoundPath = null;
|
||||||
|
|
||||||
if (chat_id != 0) {
|
if (chat_id != 0) {
|
||||||
|
@ -192,6 +188,8 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
|
||||||
} else if (chatSound != null) {
|
} else if (chatSound != null) {
|
||||||
choosenSoundPath = chatSound;
|
choosenSoundPath = chatSound;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
choosenSoundPath = globalSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||||
|
@ -205,11 +203,9 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
|
||||||
.setStyle(new NotificationCompat.BigTextStyle()
|
.setStyle(new NotificationCompat.BigTextStyle()
|
||||||
.bigText(msg))
|
.bigText(msg))
|
||||||
.setContentText(msg)
|
.setContentText(msg)
|
||||||
.setAutoCancel(true);
|
.setAutoCancel(true)
|
||||||
|
.setTicker(msg);
|
||||||
|
|
||||||
if (needPreview) {
|
|
||||||
mBuilder.setTicker(msg);
|
|
||||||
}
|
|
||||||
if (needVibrate) {
|
if (needVibrate) {
|
||||||
mBuilder.setVibrate(new long[]{0, 100, 0, 100});
|
mBuilder.setVibrate(new long[]{0, 100, 0, 100});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,15 @@ package org.telegram.messenger;
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
import android.content.ContentProviderResult;
|
import android.content.ContentProviderResult;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
@ -27,6 +31,8 @@ import android.os.Build;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
@ -38,6 +44,7 @@ import org.telegram.TL.TLObject;
|
||||||
import org.telegram.TL.TLRPC;
|
import org.telegram.TL.TLRPC;
|
||||||
import org.telegram.objects.MessageObject;
|
import org.telegram.objects.MessageObject;
|
||||||
import org.telegram.ui.ApplicationLoader;
|
import org.telegram.ui.ApplicationLoader;
|
||||||
|
import org.telegram.ui.LaunchActivity;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -4100,61 +4107,182 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inAppSounds = preferences.getBoolean("EnableInAppSounds", true);
|
if (ApplicationLoader.lastPauseTime == 0) {
|
||||||
boolean inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true);
|
boolean inAppSounds = preferences.getBoolean("EnableInAppSounds", true);
|
||||||
boolean inAppPreview = preferences.getBoolean("EnableInAppPreview", true);
|
boolean inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true);
|
||||||
|
boolean inAppPreview = preferences.getBoolean("EnableInAppPreview", true);
|
||||||
|
|
||||||
if ((inAppSounds || inAppVibrate || inAppPreview) && ApplicationLoader.lastPauseTime == 0) {
|
if (inAppSounds || inAppVibrate || inAppPreview) {
|
||||||
long dialog_id = messageObject.messageOwner.dialog_id;
|
long dialog_id = messageObject.messageOwner.dialog_id;
|
||||||
int user_id = messageObject.messageOwner.from_id;
|
int user_id = messageObject.messageOwner.from_id;
|
||||||
int chat_id = 0;
|
int chat_id = 0;
|
||||||
if (dialog_id == 0) {
|
if (dialog_id == 0) {
|
||||||
if (messageObject.messageOwner.to_id.chat_id != 0) {
|
if (messageObject.messageOwner.to_id.chat_id != 0) {
|
||||||
dialog_id = -messageObject.messageOwner.to_id.chat_id;
|
dialog_id = -messageObject.messageOwner.to_id.chat_id;
|
||||||
chat_id = messageObject.messageOwner.to_id.chat_id;
|
chat_id = messageObject.messageOwner.to_id.chat_id;
|
||||||
} else if (messageObject.messageOwner.to_id.user_id != 0) {
|
} else if (messageObject.messageOwner.to_id.user_id != 0) {
|
||||||
if (messageObject.messageOwner.to_id.user_id == UserConfig.clientUserId) {
|
if (messageObject.messageOwner.to_id.user_id == UserConfig.clientUserId) {
|
||||||
dialog_id = messageObject.messageOwner.from_id;
|
dialog_id = messageObject.messageOwner.from_id;
|
||||||
} else {
|
} else {
|
||||||
dialog_id = messageObject.messageOwner.to_id.user_id;
|
dialog_id = messageObject.messageOwner.to_id.user_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
TLRPC.EncryptedChat chat = encryptedChats.get((int)(dialog_id >> 32));
|
||||||
|
if (chat == null) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (dialog_id == 0) {
|
||||||
TLRPC.EncryptedChat chat = encryptedChats.get((int)(dialog_id >> 32));
|
|
||||||
if (chat == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TLRPC.User user = users.get(user_id);
|
||||||
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TLRPC.Chat chat;
|
||||||
|
if (chat_id != 0) {
|
||||||
|
chat = chats.get(chat_id);
|
||||||
|
if (chat == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String key = "notify_" + dialog_id;
|
||||||
|
boolean value = preferences.getBoolean(key, true);
|
||||||
|
if (!value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inAppPreview) {
|
||||||
|
NotificationCenter.Instance.postNotificationName(701, messageObject);
|
||||||
|
}
|
||||||
|
if (inAppVibrate) {
|
||||||
|
Vibrator v = (Vibrator)Utilities.applicationContext.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
v.vibrate(100);
|
||||||
|
}
|
||||||
|
if (inAppSounds) {
|
||||||
|
playNotificationSound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
long dialog_id = messageObject.messageOwner.dialog_id;
|
||||||
|
int chat_id = messageObject.messageOwner.to_id.chat_id;
|
||||||
|
int user_id = messageObject.messageOwner.to_id.user_id;
|
||||||
if (dialog_id == 0) {
|
if (dialog_id == 0) {
|
||||||
return;
|
if (chat_id != 0) {
|
||||||
|
dialog_id = -chat_id;
|
||||||
|
} else if (user_id != 0) {
|
||||||
|
dialog_id = user_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TLRPC.User user = users.get(user_id);
|
if ((int)dialog_id != 0) {
|
||||||
if (user == null) {
|
return; //temporary disable notifications for normal chats
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
TLRPC.Chat chat;
|
|
||||||
if (chat_id != 0) {
|
if (dialog_id != 0) {
|
||||||
chat = chats.get(chat_id);
|
String key = "notify_" + dialog_id;
|
||||||
if (chat == null) {
|
boolean value = preferences.getBoolean(key, true);
|
||||||
|
if (!value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String key = "notify_" + dialog_id;
|
|
||||||
boolean value = preferences.getBoolean(key, true);
|
boolean groupEnabled = preferences.getBoolean("EnableGroup", true);
|
||||||
if (!value) {
|
if (chat_id != 0 && !globalEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inAppPreview) {
|
boolean globalVibrate = preferences.getBoolean("EnableVibrateAll", true);
|
||||||
NotificationCenter.Instance.postNotificationName(701, messageObject);
|
boolean groupVibrate = preferences.getBoolean("EnableVibrateGroup", true);
|
||||||
|
|
||||||
|
String defaultPath = null;
|
||||||
|
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||||
|
if (defaultUri != null) {
|
||||||
|
defaultPath = defaultUri.getPath();
|
||||||
}
|
}
|
||||||
if (inAppVibrate) {
|
|
||||||
Vibrator v = (Vibrator)Utilities.applicationContext.getSystemService(Context.VIBRATOR_SERVICE);
|
String globalSound = preferences.getString("GlobalSoundPath", defaultPath);
|
||||||
v.vibrate(100);
|
String chatSound = preferences.getString("GroupSoundPath", defaultPath);
|
||||||
|
String userSoundPath = null;
|
||||||
|
String chatSoundPath = null;
|
||||||
|
|
||||||
|
NotificationManager mNotificationManager = (NotificationManager)Utilities.applicationContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
Intent intent = new Intent(Utilities.applicationContext, LaunchActivity.class);
|
||||||
|
String msg;
|
||||||
|
|
||||||
|
if ((int)dialog_id != 0) {
|
||||||
|
if (chat_id != 0) {
|
||||||
|
intent.putExtra("chatId", chat_id);
|
||||||
|
}
|
||||||
|
if (user_id != 0) {
|
||||||
|
intent.putExtra("userId", user_id);
|
||||||
|
}
|
||||||
|
msg = messageObject.messageOwner.message;
|
||||||
|
} else {
|
||||||
|
msg = Utilities.applicationContext.getString(R.string.YouHaveNewMessage);
|
||||||
}
|
}
|
||||||
if (inAppSounds) {
|
|
||||||
playNotificationSound();
|
boolean needVibrate = false;
|
||||||
|
|
||||||
|
if (user_id != 0) {
|
||||||
|
userSoundPath = preferences.getString("sound_path_" + user_id, null);
|
||||||
|
needVibrate = globalVibrate;
|
||||||
}
|
}
|
||||||
|
if (chat_id != 0) {
|
||||||
|
chatSoundPath = preferences.getString("sound_chat_path_" + chat_id, null);
|
||||||
|
needVibrate = groupVibrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
String choosenSoundPath = null;
|
||||||
|
|
||||||
|
if (user_id != 0) {
|
||||||
|
if (userSoundPath != null) {
|
||||||
|
choosenSoundPath = userSoundPath;
|
||||||
|
} else if (globalSound != null) {
|
||||||
|
choosenSoundPath = globalSound;
|
||||||
|
}
|
||||||
|
} else if (chat_id != 0) {
|
||||||
|
if (chatSoundPath != null) {
|
||||||
|
choosenSoundPath = chatSoundPath;
|
||||||
|
} else if (chatSound != null) {
|
||||||
|
choosenSoundPath = chatSound;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
choosenSoundPath = globalSound;
|
||||||
|
}
|
||||||
|
|
||||||
|
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
PendingIntent contentIntent = PendingIntent.getActivity(Utilities.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);
|
||||||
|
|
||||||
|
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(Utilities.applicationContext)
|
||||||
|
.setContentTitle(Utilities.applicationContext.getString(R.string.AppName))
|
||||||
|
.setSmallIcon(R.drawable.notification)
|
||||||
|
.setStyle(new NotificationCompat.BigTextStyle()
|
||||||
|
.bigText(msg))
|
||||||
|
.setContentText(msg)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setTicker(msg);
|
||||||
|
|
||||||
|
if (needVibrate) {
|
||||||
|
mBuilder.setVibrate(new long[]{0, 100, 0, 100});
|
||||||
|
}
|
||||||
|
if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) {
|
||||||
|
if (choosenSoundPath.equals(defaultPath)) {
|
||||||
|
mBuilder.setSound(defaultUri);
|
||||||
|
} else {
|
||||||
|
mBuilder.setSound(Uri.parse(choosenSoundPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mBuilder.setContentIntent(contentIntent);
|
||||||
|
mNotificationManager.cancel(1);
|
||||||
|
Notification notification = mBuilder.build();
|
||||||
|
notification.ledARGB = 0xff00ff00;
|
||||||
|
notification.ledOnMS = 1000;
|
||||||
|
notification.ledOffMS = 1000;
|
||||||
|
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
||||||
|
mNotificationManager.notify(1, notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,9 +104,6 @@ public class TcpConnection extends PyroClientAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void suspendConnection(boolean task) {
|
public void suspendConnection(boolean task) {
|
||||||
if (ConnectionsManager.DEBUG_VERSION) {
|
|
||||||
Log.d("tmessages", "suspend connnection " + this);
|
|
||||||
}
|
|
||||||
if (task) {
|
if (task) {
|
||||||
selector.scheduleTask(new Runnable() {
|
selector.scheduleTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,6 +115,9 @@ public class TcpConnection extends PyroClientAdapter {
|
||||||
if (connectionState == TcpConnectionState.TcpConnectionStageIdle || connectionState == TcpConnectionState.TcpConnectionStageSuspended) {
|
if (connectionState == TcpConnectionState.TcpConnectionStageIdle || connectionState == TcpConnectionState.TcpConnectionStageSuspended) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ConnectionsManager.DEBUG_VERSION) {
|
||||||
|
Log.d("tmessages", "suspend connnection " + this);
|
||||||
|
}
|
||||||
connectionState = TcpConnectionState.TcpConnectionStageSuspended;
|
connectionState = TcpConnectionState.TcpConnectionStageSuspended;
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
client.dropConnection();
|
client.dropConnection();
|
||||||
|
@ -130,9 +130,12 @@ public class TcpConnection extends PyroClientAdapter {
|
||||||
reconnectTimer.cancel();
|
reconnectTimer.cancel();
|
||||||
reconnectTimer = null;
|
reconnectTimer = null;
|
||||||
}
|
}
|
||||||
if (connectionState == TcpConnectionState.TcpConnectionStageIdle) {
|
if (connectionState == TcpConnectionState.TcpConnectionStageIdle || connectionState == TcpConnectionState.TcpConnectionStageSuspended) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ConnectionsManager.DEBUG_VERSION) {
|
||||||
|
Log.d("tmessages", "suspend connnection " + this);
|
||||||
|
}
|
||||||
connectionState = TcpConnectionState.TcpConnectionStageSuspended;
|
connectionState = TcpConnectionState.TcpConnectionStageSuspended;
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
client.dropConnection();
|
client.dropConnection();
|
||||||
|
|
|
@ -2165,14 +2165,14 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||||
Intent pickIntent = new Intent();
|
Intent pickIntent = new Intent();
|
||||||
pickIntent.setType("video/*");
|
pickIntent.setType("video/*");
|
||||||
pickIntent.setAction(Intent.ACTION_GET_CONTENT);
|
pickIntent.setAction(Intent.ACTION_GET_CONTENT);
|
||||||
pickIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024 * 1024 * 100);
|
pickIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024 * 1024 * 1000);
|
||||||
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
|
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
|
||||||
File video = Utilities.generateVideoPath();
|
File video = Utilities.generateVideoPath();
|
||||||
if (video != null) {
|
if (video != null) {
|
||||||
if(android.os.Build.VERSION.SDK_INT > 10) {
|
if(android.os.Build.VERSION.SDK_INT > 10) {
|
||||||
takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(video));
|
takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(video));
|
||||||
}
|
}
|
||||||
takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024 * 1024 * 100);
|
takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024 * 1024 * 1000);
|
||||||
currentPicturePath = video.getAbsolutePath();
|
currentPicturePath = video.getAbsolutePath();
|
||||||
}
|
}
|
||||||
Intent chooserIntent = Intent.createChooser(pickIntent, "");
|
Intent chooserIntent = Intent.createChooser(pickIntent, "");
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||||
((ApplicationActivity)parentActivity).presentFragment(fragment, "key_" + dialog_id, false);
|
((ApplicationActivity)parentActivity).presentFragment(fragment, "key_" + dialog_id, false);
|
||||||
} else if (i == 4 && dialog_id != 0 && currentEncryptedChat instanceof TLRPC.TL_encryptedChat) {
|
} else if (i == 4 && dialog_id != 0 && currentEncryptedChat instanceof TLRPC.TL_encryptedChat) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||||
builder.setTitle(getStringEntry(R.string.TextSize));
|
builder.setTitle(getStringEntry(R.string.MessageLifetime));
|
||||||
builder.setItems(new CharSequence[]{
|
builder.setItems(new CharSequence[]{
|
||||||
getStringEntry(R.string.ShortMessageLifetimeForever),
|
getStringEntry(R.string.ShortMessageLifetimeForever),
|
||||||
getStringEntry(R.string.ShortMessageLifetime2s),
|
getStringEntry(R.string.ShortMessageLifetime2s),
|
||||||
|
|
Loading…
Reference in a new issue