Bug fixes
This commit is contained in:
parent
fc46daa50f
commit
21273f822c
@ -80,7 +80,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 308
|
versionCode 309
|
||||||
versionName "1.8.0"
|
versionName "1.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||||||
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
|
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||||
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
|
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
|
||||||
|
|
||||||
checkAutodownloadSettings();
|
if (UserConfig.isClientActivated()) {
|
||||||
|
checkAutodownloadSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startProgressTimer() {
|
private void startProgressTimer() {
|
||||||
|
@ -55,6 +55,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||||||
public HashMap<Integer, MessageObject> dialogMessage = new HashMap<Integer, MessageObject>();
|
public HashMap<Integer, MessageObject> dialogMessage = new HashMap<Integer, MessageObject>();
|
||||||
public ConcurrentHashMap<Long, ArrayList<PrintingUser>> printingUsers = new ConcurrentHashMap<Long, ArrayList<PrintingUser>>(100, 1.0f, 2);
|
public ConcurrentHashMap<Long, ArrayList<PrintingUser>> printingUsers = new ConcurrentHashMap<Long, ArrayList<PrintingUser>>(100, 1.0f, 2);
|
||||||
public HashMap<Long, CharSequence> printingStrings = new HashMap<Long, CharSequence>();
|
public HashMap<Long, CharSequence> printingStrings = new HashMap<Long, CharSequence>();
|
||||||
|
public HashMap<Long, Boolean> sendingTypings = new HashMap<Long, Boolean>();
|
||||||
private int lastPrintingStringCount = 0;
|
private int lastPrintingStringCount = 0;
|
||||||
|
|
||||||
public boolean loadingBlockedUsers = false;
|
public boolean loadingBlockedUsers = false;
|
||||||
@ -308,6 +309,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||||||
pendingEncMessagesToDelete.clear();
|
pendingEncMessagesToDelete.clear();
|
||||||
delayedEncryptedChatUpdates.clear();
|
delayedEncryptedChatUpdates.clear();
|
||||||
blockedUsers.clear();
|
blockedUsers.clear();
|
||||||
|
sendingTypings.clear();
|
||||||
|
|
||||||
updatesStartWaitTime = 0;
|
updatesStartWaitTime = 0;
|
||||||
currentDeletingTaskTime = 0;
|
currentDeletingTaskTime = 0;
|
||||||
@ -1192,10 +1194,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendTyping(long dialog_id, int classGuid) {
|
public void cancelTyping(long dialog_id) {
|
||||||
|
sendingTypings.remove(dialog_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendTyping(final long dialog_id, int classGuid) {
|
||||||
if (dialog_id == 0) {
|
if (dialog_id == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (sendingTypings.get(dialog_id) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int lower_part = (int)dialog_id;
|
int lower_part = (int)dialog_id;
|
||||||
int high_id = (int)(dialog_id >> 32);
|
int high_id = (int)(dialog_id >> 32);
|
||||||
if (lower_part != 0) {
|
if (lower_part != 0) {
|
||||||
@ -1223,10 +1232,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.typing = true;
|
req.typing = true;
|
||||||
|
sendingTypings.put(dialog_id, true);
|
||||||
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendingTypings.remove(dialog_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||||
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
||||||
@ -1238,10 +1253,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||||||
req.peer.chat_id = chat.id;
|
req.peer.chat_id = chat.id;
|
||||||
req.peer.access_hash = chat.access_hash;
|
req.peer.access_hash = chat.access_hash;
|
||||||
req.typing = true;
|
req.typing = true;
|
||||||
|
sendingTypings.put(dialog_id, true);
|
||||||
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
sendingTypings.remove(dialog_id);
|
||||||
}
|
}
|
||||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||||
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
||||||
|
@ -276,7 +276,7 @@ public class FileLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadFile(TLRPC.FileLocation location, int size) {
|
public void loadFile(TLRPC.FileLocation location, int size) {
|
||||||
loadFile(null, null, null, location, size, false);
|
loadFile(null, null, null, location, size, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadFile(final TLRPC.Video video, final TLRPC.Document document, final TLRPC.Audio audio, final TLRPC.FileLocation location, final int locationSize, final boolean force) {
|
private void loadFile(final TLRPC.Video video, final TLRPC.Document document, final TLRPC.Audio audio, final TLRPC.FileLocation location, final int locationSize, final boolean force) {
|
||||||
@ -410,21 +410,33 @@ public class FileLoader {
|
|||||||
currentAudioLoadOperationsCount++;
|
currentAudioLoadOperationsCount++;
|
||||||
operation.start();
|
operation.start();
|
||||||
} else {
|
} else {
|
||||||
audioLoadOperationQueue.add(operation);
|
if (force) {
|
||||||
|
audioLoadOperationQueue.add(0, operation);
|
||||||
|
} else {
|
||||||
|
audioLoadOperationQueue.add(operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (location != null) {
|
} else if (location != null) {
|
||||||
if (currentPhotoLoadOperationsCount < 2) {
|
if (currentPhotoLoadOperationsCount < 2) {
|
||||||
currentPhotoLoadOperationsCount++;
|
currentPhotoLoadOperationsCount++;
|
||||||
operation.start();
|
operation.start();
|
||||||
} else {
|
} else {
|
||||||
photoLoadOperationQueue.add(operation);
|
if (force) {
|
||||||
|
photoLoadOperationQueue.add(0, operation);
|
||||||
|
} else {
|
||||||
|
photoLoadOperationQueue.add(operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentLoadOperationsCount < 2) {
|
if (currentLoadOperationsCount < 2) {
|
||||||
currentLoadOperationsCount++;
|
currentLoadOperationsCount++;
|
||||||
operation.start();
|
operation.start();
|
||||||
} else {
|
} else {
|
||||||
loadOperationQueue.add(operation);
|
if (force) {
|
||||||
|
loadOperationQueue.add(0, operation);
|
||||||
|
} else {
|
||||||
|
loadOperationQueue.add(operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
|
|
||||||
package org.telegram.messenger;
|
package org.telegram.messenger;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import org.telegram.ui.ApplicationLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -28,11 +33,13 @@ public class FileUploadOperation {
|
|||||||
private long totalFileSize = 0;
|
private long totalFileSize = 0;
|
||||||
private int totalPartsCount = 0;
|
private int totalPartsCount = 0;
|
||||||
private long currentUploaded = 0;
|
private long currentUploaded = 0;
|
||||||
|
private int saveInfoTimes = 0;
|
||||||
private byte[] key;
|
private byte[] key;
|
||||||
private byte[] iv;
|
private byte[] iv;
|
||||||
private byte[] ivChange;
|
private byte[] ivChange;
|
||||||
private int fingerprint = 0;
|
private int fingerprint = 0;
|
||||||
private boolean isBigFile = false;
|
private boolean isBigFile = false;
|
||||||
|
private String fileKey;
|
||||||
FileInputStream stream;
|
FileInputStream stream;
|
||||||
MessageDigest mdEnc = null;
|
MessageDigest mdEnc = null;
|
||||||
|
|
||||||
@ -89,6 +96,12 @@ public class FileUploadOperation {
|
|||||||
ConnectionsManager.getInstance().cancelRpc(requestToken, true);
|
ConnectionsManager.getInstance().cancelRpc(requestToken, true);
|
||||||
}
|
}
|
||||||
delegate.didFailedUploadingFile(this);
|
delegate.didFailedUploadingFile(this);
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanup() {
|
||||||
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("uploadinfo", Activity.MODE_PRIVATE);
|
||||||
|
preferences.edit().remove(fileKey + "_time").remove(fileKey + "_size").remove(fileKey + "_uploaded").commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startUploadRequest() {
|
private void startUploadRequest() {
|
||||||
@ -104,7 +117,6 @@ public class FileUploadOperation {
|
|||||||
stream = new FileInputStream(cacheFile);
|
stream = new FileInputStream(cacheFile);
|
||||||
totalFileSize = cacheFile.length();
|
totalFileSize = cacheFile.length();
|
||||||
if (totalFileSize > 10 * 1024 * 1024) {
|
if (totalFileSize > 10 * 1024 * 1024) {
|
||||||
FileLog.e("tmessages", "file is big!");
|
|
||||||
isBigFile = true;
|
isBigFile = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +132,51 @@ public class FileUploadOperation {
|
|||||||
uploadChunkSize *= 1024;
|
uploadChunkSize *= 1024;
|
||||||
totalPartsCount = (int) Math.ceil((float) totalFileSize / (float) uploadChunkSize);
|
totalPartsCount = (int) Math.ceil((float) totalFileSize / (float) uploadChunkSize);
|
||||||
readBuffer = new byte[uploadChunkSize];
|
readBuffer = new byte[uploadChunkSize];
|
||||||
|
|
||||||
|
fileKey = Utilities.MD5(uploadingFilePath);
|
||||||
|
/*SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("uploadinfo", Activity.MODE_PRIVATE); TODO
|
||||||
|
long fileSize = preferences.getLong(fileKey + "_size", 0);
|
||||||
|
int currentTime = (int)(System.currentTimeMillis() / 1000);
|
||||||
|
boolean rewrite = false;
|
||||||
|
if (fileSize == totalFileSize) {
|
||||||
|
int date = preferences.getInt(fileKey + "_time", 0);
|
||||||
|
long uploadedSize = preferences.getLong(fileKey + "_uploaded", 0);
|
||||||
|
if (date != 0) {
|
||||||
|
if (isBigFile && date < currentTime - 60 * 60 * 24) {
|
||||||
|
date = 0;
|
||||||
|
} else if (!isBigFile && date < currentTime - 60 * 60 * 1.5f) {
|
||||||
|
date = 0;
|
||||||
|
}
|
||||||
|
if (date != 0) {
|
||||||
|
if (isBigFile) {
|
||||||
|
uploadedSize = uploadedSize / (1024 * 1024) * (1024 * 1024);
|
||||||
|
}
|
||||||
|
if (uploadedSize > 0) {
|
||||||
|
currentUploaded = uploadedSize;
|
||||||
|
stream.skip(uploadedSize);
|
||||||
|
currentPartNum = (int) (uploadedSize / uploadChunkSize);
|
||||||
|
} else {
|
||||||
|
rewrite = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rewrite = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rewrite = true;
|
||||||
|
}
|
||||||
|
if (rewrite) {
|
||||||
|
preferences.edit().putInt(fileKey + "_time", currentTime).putLong(fileKey + "_size", totalFileSize).commit();
|
||||||
|
}*/
|
||||||
|
} else {
|
||||||
|
/*if (saveInfoTimes >= 4) {
|
||||||
|
saveInfoTimes = 0;
|
||||||
|
}
|
||||||
|
if (saveInfoTimes == 0) {
|
||||||
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("uploadinfo", Activity.MODE_PRIVATE);
|
||||||
|
preferences.edit().putLong(fileKey + "_uploaded", currentUploaded).commit();
|
||||||
|
}
|
||||||
|
saveInfoTimes++;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int readed = stream.read(readBuffer);
|
int readed = stream.read(readBuffer);
|
||||||
@ -160,6 +217,7 @@ public class FileUploadOperation {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
delegate.didFailedUploadingFile(this);
|
delegate.didFailedUploadingFile(this);
|
||||||
|
cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
requestToken = ConnectionsManager.getInstance().performRpc(finalRequest, new RPCRequest.RPCRequestDelegate() {
|
requestToken = ConnectionsManager.getInstance().performRpc(finalRequest, new RPCRequest.RPCRequestDelegate() {
|
||||||
@ -184,6 +242,7 @@ public class FileUploadOperation {
|
|||||||
result.id = currentFileId;
|
result.id = currentFileId;
|
||||||
result.name = uploadingFilePath.substring(uploadingFilePath.lastIndexOf("/") + 1);
|
result.name = uploadingFilePath.substring(uploadingFilePath.lastIndexOf("/") + 1);
|
||||||
delegate.didFinishUploadingFile(FileUploadOperation.this, result, null);
|
delegate.didFinishUploadingFile(FileUploadOperation.this, result, null);
|
||||||
|
cleanup();
|
||||||
} else {
|
} else {
|
||||||
TLRPC.InputEncryptedFile result;
|
TLRPC.InputEncryptedFile result;
|
||||||
if (isBigFile) {
|
if (isBigFile) {
|
||||||
@ -198,15 +257,18 @@ public class FileUploadOperation {
|
|||||||
result.iv = iv;
|
result.iv = iv;
|
||||||
result.key = key;
|
result.key = key;
|
||||||
delegate.didFinishUploadingFile(FileUploadOperation.this, null, result);
|
delegate.didFinishUploadingFile(FileUploadOperation.this, null, result);
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
startUploadRequest();
|
startUploadRequest();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delegate.didFailedUploadingFile(FileUploadOperation.this);
|
delegate.didFailedUploadingFile(FileUploadOperation.this);
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delegate.didFailedUploadingFile(FileUploadOperation.this);
|
delegate.didFailedUploadingFile(FileUploadOperation.this);
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null, true, RPCRequest.RPCRequestClassUploadMedia, ConnectionsManager.DEFAULT_DATACENTER_ID);
|
}, null, true, RPCRequest.RPCRequestClassUploadMedia, ConnectionsManager.DEFAULT_DATACENTER_ID);
|
||||||
|
@ -354,8 +354,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false);
|
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false);
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
||||||
|
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
userBlocked = MessagesController.getInstance().blockedUsers.contains(currentUser.id);
|
userBlocked = MessagesController.getInstance().blockedUsers.contains(currentUser.id);
|
||||||
}
|
}
|
||||||
@ -2572,6 +2570,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
}
|
}
|
||||||
|
|
||||||
chatActivityEnterView.setFieldFocused(false);
|
chatActivityEnterView.setFieldFocused(false);
|
||||||
|
MessagesController.getInstance().cancelTyping(dialog_id);
|
||||||
|
|
||||||
/*if (currentEncryptedChat != null) { disabled
|
/*if (currentEncryptedChat != null) { disabled
|
||||||
chatLeaveTime = System.currentTimeMillis();
|
chatLeaveTime = System.currentTimeMillis();
|
||||||
@ -3393,7 +3392,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||||||
((ChatBaseCell)view).setMessageObject(message);
|
((ChatBaseCell)view).setMessageObject(message);
|
||||||
((ChatBaseCell)view).setCheckPressed(!disableSelection, disableSelection && selected);
|
((ChatBaseCell)view).setCheckPressed(!disableSelection, disableSelection && selected);
|
||||||
if (view instanceof ChatAudioCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) {
|
if (view instanceof ChatAudioCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) {
|
||||||
((ChatAudioCell)view).downloadAudioIfNeed(); //TODO
|
((ChatAudioCell)view).downloadAudioIfNeed();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ChatListRowHolderEx holder = (ChatListRowHolderEx)view.getTag();
|
ChatListRowHolderEx holder = (ChatListRowHolderEx)view.getTag();
|
||||||
|
Loading…
Reference in New Issue
Block a user