Commit 27b74b53 authored by DrKLO's avatar DrKLO

update to 2.3.6

parent c824df61
...@@ -141,7 +141,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -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. ...@@ -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. ...@@ -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. ...@@ -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. ...@@ -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. ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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; ...@@ -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 { ...@@ -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; ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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});
} }
......
...@@ -104,9 +104,6 @@ public class TcpConnection extends PyroClientAdapter { ...@@ -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 { ...@@ -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 { ...@@ -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 ...@@ -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 ...@@ -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),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment