mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Bug fixes
This commit is contained in:
parent
fc46daa50f
commit
21273f822c
6 changed files with 104 additions and 13 deletions
|
@ -80,7 +80,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 308
|
||||
versionCode 309
|
||||
versionName "1.8.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -382,7 +382,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
|
||||
|
||||
checkAutodownloadSettings();
|
||||
if (UserConfig.isClientActivated()) {
|
||||
checkAutodownloadSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void startProgressTimer() {
|
||||
|
|
|
@ -55,6 +55,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
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 HashMap<Long, CharSequence> printingStrings = new HashMap<Long, CharSequence>();
|
||||
public HashMap<Long, Boolean> sendingTypings = new HashMap<Long, Boolean>();
|
||||
private int lastPrintingStringCount = 0;
|
||||
|
||||
public boolean loadingBlockedUsers = false;
|
||||
|
@ -308,6 +309,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
pendingEncMessagesToDelete.clear();
|
||||
delayedEncryptedChatUpdates.clear();
|
||||
blockedUsers.clear();
|
||||
sendingTypings.clear();
|
||||
|
||||
updatesStartWaitTime = 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) {
|
||||
return;
|
||||
}
|
||||
if (sendingTypings.get(dialog_id) != null) {
|
||||
return;
|
||||
}
|
||||
int lower_part = (int)dialog_id;
|
||||
int high_id = (int)(dialog_id >> 32);
|
||||
if (lower_part != 0) {
|
||||
|
@ -1223,10 +1232,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
req.typing = true;
|
||||
sendingTypings.put(dialog_id, true);
|
||||
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
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);
|
||||
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
||||
|
@ -1238,10 +1253,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
req.peer.chat_id = chat.id;
|
||||
req.peer.access_hash = chat.access_hash;
|
||||
req.typing = true;
|
||||
sendingTypings.put(dialog_id, true);
|
||||
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
sendingTypings.remove(dialog_id);
|
||||
}
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
||||
|
|
|
@ -276,7 +276,7 @@ public class FileLoader {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -410,21 +410,33 @@ public class FileLoader {
|
|||
currentAudioLoadOperationsCount++;
|
||||
operation.start();
|
||||
} else {
|
||||
audioLoadOperationQueue.add(operation);
|
||||
if (force) {
|
||||
audioLoadOperationQueue.add(0, operation);
|
||||
} else {
|
||||
audioLoadOperationQueue.add(operation);
|
||||
}
|
||||
}
|
||||
} else if (location != null) {
|
||||
if (currentPhotoLoadOperationsCount < 2) {
|
||||
currentPhotoLoadOperationsCount++;
|
||||
operation.start();
|
||||
} else {
|
||||
photoLoadOperationQueue.add(operation);
|
||||
if (force) {
|
||||
photoLoadOperationQueue.add(0, operation);
|
||||
} else {
|
||||
photoLoadOperationQueue.add(operation);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentLoadOperationsCount < 2) {
|
||||
currentLoadOperationsCount++;
|
||||
operation.start();
|
||||
} else {
|
||||
loadOperationQueue.add(operation);
|
||||
if (force) {
|
||||
loadOperationQueue.add(0, operation);
|
||||
} else {
|
||||
loadOperationQueue.add(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
|
||||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.math.BigInteger;
|
||||
|
@ -28,11 +33,13 @@ public class FileUploadOperation {
|
|||
private long totalFileSize = 0;
|
||||
private int totalPartsCount = 0;
|
||||
private long currentUploaded = 0;
|
||||
private int saveInfoTimes = 0;
|
||||
private byte[] key;
|
||||
private byte[] iv;
|
||||
private byte[] ivChange;
|
||||
private int fingerprint = 0;
|
||||
private boolean isBigFile = false;
|
||||
private String fileKey;
|
||||
FileInputStream stream;
|
||||
MessageDigest mdEnc = null;
|
||||
|
||||
|
@ -89,6 +96,12 @@ public class FileUploadOperation {
|
|||
ConnectionsManager.getInstance().cancelRpc(requestToken, true);
|
||||
}
|
||||
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() {
|
||||
|
@ -104,7 +117,6 @@ public class FileUploadOperation {
|
|||
stream = new FileInputStream(cacheFile);
|
||||
totalFileSize = cacheFile.length();
|
||||
if (totalFileSize > 10 * 1024 * 1024) {
|
||||
FileLog.e("tmessages", "file is big!");
|
||||
isBigFile = true;
|
||||
}
|
||||
|
||||
|
@ -120,6 +132,51 @@ public class FileUploadOperation {
|
|||
uploadChunkSize *= 1024;
|
||||
totalPartsCount = (int) Math.ceil((float) totalFileSize / (float) 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);
|
||||
|
@ -160,6 +217,7 @@ public class FileUploadOperation {
|
|||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
delegate.didFailedUploadingFile(this);
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
requestToken = ConnectionsManager.getInstance().performRpc(finalRequest, new RPCRequest.RPCRequestDelegate() {
|
||||
|
@ -184,6 +242,7 @@ public class FileUploadOperation {
|
|||
result.id = currentFileId;
|
||||
result.name = uploadingFilePath.substring(uploadingFilePath.lastIndexOf("/") + 1);
|
||||
delegate.didFinishUploadingFile(FileUploadOperation.this, result, null);
|
||||
cleanup();
|
||||
} else {
|
||||
TLRPC.InputEncryptedFile result;
|
||||
if (isBigFile) {
|
||||
|
@ -198,15 +257,18 @@ public class FileUploadOperation {
|
|||
result.iv = iv;
|
||||
result.key = key;
|
||||
delegate.didFinishUploadingFile(FileUploadOperation.this, null, result);
|
||||
cleanup();
|
||||
}
|
||||
} else {
|
||||
startUploadRequest();
|
||||
}
|
||||
} else {
|
||||
delegate.didFailedUploadingFile(FileUploadOperation.this);
|
||||
cleanup();
|
||||
}
|
||||
} else {
|
||||
delegate.didFailedUploadingFile(FileUploadOperation.this);
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassUploadMedia, ConnectionsManager.DEFAULT_DATACENTER_ID);
|
||||
|
|
|
@ -354,8 +354,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
loading = true;
|
||||
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
|
||||
if (currentUser != null) {
|
||||
userBlocked = MessagesController.getInstance().blockedUsers.contains(currentUser.id);
|
||||
}
|
||||
|
@ -2572,6 +2570,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
chatActivityEnterView.setFieldFocused(false);
|
||||
MessagesController.getInstance().cancelTyping(dialog_id);
|
||||
|
||||
/*if (currentEncryptedChat != null) { disabled
|
||||
chatLeaveTime = System.currentTimeMillis();
|
||||
|
@ -3393,7 +3392,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
((ChatBaseCell)view).setMessageObject(message);
|
||||
((ChatBaseCell)view).setCheckPressed(!disableSelection, disableSelection && selected);
|
||||
if (view instanceof ChatAudioCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) {
|
||||
((ChatAudioCell)view).downloadAudioIfNeed(); //TODO
|
||||
((ChatAudioCell)view).downloadAudioIfNeed();
|
||||
}
|
||||
} else {
|
||||
ChatListRowHolderEx holder = (ChatListRowHolderEx)view.getTag();
|
||||
|
|
Loading…
Reference in a new issue