Commit 358a067a authored by DrKLO's avatar DrKLO

Avoid uploading same file twice, bug fixes

parent a87968ce
......@@ -81,7 +81,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 257
versionName "1.5.4"
versionCode 258
versionName "1.5.5"
}
}
......@@ -63,7 +63,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
private boolean paused = false;
private long lastPingTime = System.currentTimeMillis();
private long lastPushPingTime = System.currentTimeMillis();
private long lastPushPingTime = 0;
private boolean sendingPushPing = false;
private int nextSleepTimeout = 30000;
private long nextPingId = 0;
......@@ -88,7 +89,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
Utilities.stageQueue.handler.removeCallbacks(stageRunnable);
t = System.currentTimeMillis();
if (datacenters != null) {
if (lastPushPingTime < System.currentTimeMillis() - 29000) {
if (sendingPushPing && lastPushPingTime < System.currentTimeMillis() - 30000 || Math.abs(lastPushPingTime - System.currentTimeMillis()) > 60000 * 4) {
lastPushPingTime = 0;
sendingPushPing = false;
}
if (lastPushPingTime < System.currentTimeMillis() - 60000 * 3) {
lastPushPingTime = System.currentTimeMillis();
Datacenter datacenter = datacenterWithId(currentDatacenterId);
if (datacenter != null) {
......@@ -1955,14 +1960,15 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (UserConfig.isClientActivated() && !UserConfig.registeredForInternalPush && (connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
registerForPush();
}
TLRPC.TL_pong pong = (TLRPC.TL_pong)message;
if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) == 0) {
TLRPC.TL_pong pong = (TLRPC.TL_pong) message;
long pingId = pong.ping_id;
ArrayList<Long> itemsToDelete = new ArrayList<Long>();
for (Long pid : pingIdToDate.keySet()) {
if (pid == pingId) {
int time = pingIdToDate.get(pid);
int pingTime = (int)(System.currentTimeMillis() / 1000) - time;
int pingTime = (int) (System.currentTimeMillis() / 1000) - time;
if (Math.abs(pingTime) < 10) {
currentPingTime = (pingTime + currentPingTime) / 2;
......@@ -1970,7 +1976,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (messageId != 0) {
long timeMessage = getTimeFromMsgId(messageId);
long currentTime = System.currentTimeMillis();
timeDifference = (int)((timeMessage - currentTime) / 1000 - currentPingTime / 2.0);
timeDifference = (int) ((timeMessage - currentTime) / 1000 - currentPingTime / 2.0);
}
}
itemsToDelete.add(pid);
......@@ -1981,6 +1987,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
for (Long pid : itemsToDelete) {
pingIdToDate.remove(pid);
}
} else {
sendingPushPing = false;
}
} else if (message instanceof TLRPC.TL_futuresalts) {
TLRPC.TL_futuresalts futureSalts = (TLRPC.TL_futuresalts)message;
long requestMid = futureSalts.req_msg_id;
......@@ -2345,8 +2354,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
TLRPC.TL_ping_delay_disconnect ping = new TLRPC.TL_ping_delay_disconnect();
ping.ping_id = nextPingId++;
if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
ping.disconnect_delay = 60 * 7;
} else {
ping.disconnect_delay = 35;
pingIdToDate.put(ping.ping_id, (int)(System.currentTimeMillis() / 1000));
pingIdToDate.put(ping.ping_id, (int) (System.currentTimeMillis() / 1000));
if (pingIdToDate.size() > 20) {
ArrayList<Long> itemsToDelete = new ArrayList<Long>();
for (Long pid : pingIdToDate.keySet()) {
......@@ -2358,6 +2370,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
pingIdToDate.remove(pid);
}
}
}
NetworkMessage networkMessage = new NetworkMessage();
networkMessage.protoMessage = wrapMessage(ping, connection, false);
......@@ -2377,6 +2390,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (connection != null && (push || !push && connection.channelToken != 0)) {
ByteBufferDesc transportData = generatePingData(connection);
if (transportData != null) {
if (push) {
sendingPushPing = true;
}
connection.sendData(null, transportData, false);
}
}
......@@ -2558,6 +2574,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
NotificationCenter.getInstance().postNotificationName(703, stateCopy);
}
});
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
sendingPushPing = false;
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 5000;
}
}
......@@ -2566,6 +2585,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
Datacenter datacenter = datacenterWithId(connection.getDatacenterId());
if (datacenter.authKey != null) {
processRequestQueue(connection.transportRequestClass, connection.getDatacenterId());
if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
sendingPushPing = false;
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 10000;
}
}
}
......
......@@ -181,6 +181,10 @@ public class ContactsController {
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (pCur != null) {
pCur.close();
}
}
try {
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._COUNT}, null, null, null);
......@@ -195,6 +199,10 @@ public class ContactsController {
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (pCur != null) {
pCur.close();
}
}
try {
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._COUNT}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, null);
......@@ -209,6 +217,10 @@ public class ContactsController {
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (pCur != null) {
pCur.close();
}
}
try {
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._ID}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, ContactsContract.Data._ID + " desc LIMIT 1");
......@@ -223,6 +235,10 @@ public class ContactsController {
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (pCur != null) {
pCur.close();
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
......
......@@ -337,11 +337,11 @@ public class FileLoader {
return memCache.get(key) != null;
}
public void uploadFile(final String location, final byte[] key, final byte[] iv) {
public void uploadFile(final String location, final String originalLocation, final boolean encrypted) {
fileLoaderQueue.postRunnable(new Runnable() {
@Override
public void run() {
if (key != null) {
if (encrypted) {
if (uploadOperationPathsEnc.containsKey(location)) {
return;
}
......@@ -350,8 +350,8 @@ public class FileLoader {
return;
}
}
FileUploadOperation operation = new FileUploadOperation(location, key, iv);
if (key != null) {
FileUploadOperation operation = new FileUploadOperation(location, originalLocation, encrypted);
if (encrypted) {
uploadOperationPathsEnc.put(location, operation);
} else {
uploadOperationPaths.put(location, operation);
......@@ -369,7 +369,7 @@ public class FileLoader {
fileProgresses.remove(location);
}
});
if (key != null) {
if (encrypted) {
uploadOperationPathsEnc.remove(location);
} else {
uploadOperationPaths.remove(location);
......@@ -396,11 +396,11 @@ public class FileLoader {
public void run() {
fileProgresses.remove(location);
if (operation.state != 2) {
NotificationCenter.getInstance().postNotificationName(FileDidFailUpload, location, key != null);
NotificationCenter.getInstance().postNotificationName(FileDidFailUpload, location, encrypted);
}
}
});
if (key != null) {
if (encrypted) {
uploadOperationPathsEnc.remove(location);
} else {
uploadOperationPaths.remove(location);
......@@ -428,7 +428,7 @@ public class FileLoader {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(FileUploadProgressChanged, location, progress, key != null);
NotificationCenter.getInstance().postNotificationName(FileUploadProgressChanged, location, progress, encrypted);
}
});
}
......
......@@ -13,11 +13,14 @@ import java.io.FileInputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.Semaphore;
public class FileUploadOperation {
private int uploadChunkSize = 1024 * 32;
private String uploadingFilePath;
private String originalPath;
public int state = 0;
private byte[] readBuffer;
public FileUploadOperationDelegate delegate;
......@@ -30,6 +33,7 @@ public class FileUploadOperation {
private long currentUploaded = 0;
private byte[] key;
private byte[] iv;
private byte[] ivChange;
private int fingerprint;
private boolean isBigFile = false;
FileInputStream stream;
......@@ -41,12 +45,16 @@ public class FileUploadOperation {
public abstract void didChangedUploadProgress(FileUploadOperation operation, float progress);
}
public FileUploadOperation(String location, byte[] keyarr, byte[] ivarr) {
public FileUploadOperation(String location, String originalLocaltion, boolean encrypted) {
uploadingFilePath = location;
if (ivarr != null && keyarr != null) {
originalPath = originalLocaltion;
if (encrypted) {
iv = new byte[32];
key = keyarr;
System.arraycopy(ivarr, 0, iv, 0, 32);
key = new byte[32];
ivChange = new byte[32];
Utilities.random.nextBytes(iv);
Utilities.random.nextBytes(key);
System.arraycopy(iv, 0, ivChange, 0, 32);
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] arr = new byte[64];
......@@ -98,6 +106,26 @@ public class FileUploadOperation {
try {
if (stream == null) {
if (originalPath != null) {
Semaphore semaphore = new Semaphore(0);
ArrayList<TLObject> result = new ArrayList<TLObject>();
String path = originalPath;
if (key != null) {
path += "e";
}
MessagesStorage.getInstance().getSentFile(path, semaphore, result);
semaphore.acquire();
if (!result.isEmpty()) {
TLObject object = result.get(0);
if (object instanceof TLRPC.InputFile) {
delegate.didFinishUploadingFile(FileUploadOperation.this, (TLRPC.InputFile) object, null);
return;
} else if (object instanceof TLRPC.InputEncryptedFile) {
delegate.didFinishUploadingFile(FileUploadOperation.this, null, (TLRPC.InputEncryptedFile) object);
return;
}
}
}
File cacheFile = new File(uploadingFilePath);
stream = new FileInputStream(cacheFile);
totalFileSize = cacheFile.length();
......@@ -106,7 +134,7 @@ public class FileUploadOperation {
isBigFile = true;
}
uploadChunkSize = (int)Math.max(32, Math.ceil(totalFileSize / (1024.0f * 3000)));
uploadChunkSize = (int) Math.max(32, Math.ceil(totalFileSize / (1024.0f * 3000)));
if (1024 % uploadChunkSize != 0) {
int chunkSize = 64;
while (uploadChunkSize > chunkSize) {
......@@ -116,7 +144,7 @@ public class FileUploadOperation {
}
uploadChunkSize *= 1024;
totalPartsCount = (int)Math.ceil((float)totalFileSize / (float)uploadChunkSize);
totalPartsCount = (int) Math.ceil((float) totalFileSize / (float) uploadChunkSize);
readBuffer = new byte[uploadChunkSize];
}
......@@ -134,7 +162,7 @@ public class FileUploadOperation {
for (int a = 0; a < toAdd; a++) {
sendBuffer.writeByte(0);
}
Utilities.aesIgeEncryption2(sendBuffer.buffer, key, iv, true, true, readed + toAdd);
Utilities.aesIgeEncryption2(sendBuffer.buffer, key, ivChange, true, true, readed + toAdd);
}
sendBuffer.rewind();
if (!isBigFile) {
......@@ -167,7 +195,7 @@ public class FileUploadOperation {
if (error == null) {
if (response instanceof TLRPC.TL_boolTrue) {
currentPartNum++;
delegate.didChangedUploadProgress(FileUploadOperation.this, (float)currentUploaded / (float)totalFileSize);
delegate.didChangedUploadProgress(FileUploadOperation.this, (float) currentUploaded / (float) totalFileSize);
if (isLastPart) {
state = 3;
if (key == null) {
......@@ -182,6 +210,9 @@ public class FileUploadOperation {
result.id = currentFileId;
result.name = uploadingFilePath.substring(uploadingFilePath.lastIndexOf("/") + 1);
delegate.didFinishUploadingFile(FileUploadOperation.this, result, null);
if (originalPath != null) {
MessagesStorage.getInstance().putSentFile(originalPath, result, null, null);
}
} else {
TLRPC.InputEncryptedFile result;
if (isBigFile) {
......@@ -193,7 +224,12 @@ public class FileUploadOperation {
result.parts = currentPartNum;
result.id = currentFileId;
result.key_fingerprint = fingerprint;
result.iv = iv;
result.key = key;
delegate.didFinishUploadingFile(FileUploadOperation.this, null, result);
if (originalPath != null) {
MessagesStorage.getInstance().putSentFile(originalPath + "e", result, key, iv);
}
}
} else {
startUploadRequest();
......
......@@ -97,6 +97,8 @@ public class MessagesStorage {
database.executeFast("CREATE TABLE user_contacts_v6(uid INTEGER PRIMARY KEY, fname TEXT, sname TEXT)").stepThis().dispose();
database.executeFast("CREATE TABLE user_phones_v6(uid INTEGER, phone TEXT, sphone TEXT, deleted INTEGER, PRIMARY KEY (uid, phone))").stepThis().dispose();
database.executeFast("CREATE TABLE sent_files(uid TEXT PRIMARY KEY, data BLOB, key BLOB, iv BLOB)").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS sphone_deleted_idx_user_phones ON user_phones_v6(sphone, deleted);").stepThis().dispose();
......@@ -166,6 +168,8 @@ public class MessagesStorage {
database.executeFast("CREATE INDEX IF NOT EXISTS sphone_deleted_idx_user_phones ON user_phones_v6(sphone, deleted);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);").stepThis().dispose();
database.executeFast("CREATE TABLE IF NOT EXISTS sent_files(uid TEXT PRIMARY KEY, data BLOB, key BLOB, iv BLOB)").stepThis().dispose();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
......@@ -1496,6 +1500,80 @@ public class MessagesStorage {
});
}
public void getSentFile(final String path, final Semaphore semaphore, final ArrayList<TLObject> result) {
if (path == null || semaphore == null || result == null) {
return;
}
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
String id = Utilities.MD5(path);
if (id != null) {
SQLiteCursor cursor = database.queryFinalized("SELECT data, key, iv FROM sent_files WHERE uid = '" + id + "'");
if (cursor.next()) {
byte[] fileData = cursor.byteArrayValue(0);
if (fileData != null) {
SerializedData data = new SerializedData(fileData);
TLObject file = TLClassStore.Instance().TLdeserialize(data, data.readInt32());
if (file instanceof TLRPC.InputEncryptedFile) {
TLRPC.InputEncryptedFile encFile = (TLRPC.InputEncryptedFile)file;
encFile.key = cursor.byteArrayValue(1);
encFile.iv = cursor.byteArrayValue(2);
if (encFile.key != null && encFile.iv != null) {
result.add(file);
}
} else if (file instanceof TLRPC.InputFile) {
result.add(file);
}
}
}
cursor.dispose();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
semaphore.release();
}
}
});
}
public void putSentFile(final String path, final TLObject file, final byte[] key, final byte[] iv) {
if (path == null || file == null) {
return;
}
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
String id = Utilities.MD5(path);
if (id != null) {
SQLitePreparedStatement state = null;
if (key != null && iv != null) {
state = database.executeFast("REPLACE INTO sent_files VALUES(?, ?, ?, ?)");
} else {
state = database.executeFast("REPLACE INTO sent_files VALUES(?, ?, NULL, NULL)");
}
state.requery();
SerializedData data = new SerializedData();
file.serializeToStream(data);
state.bindString(1, id);
state.bindByteArray(2, data.toByteArray());
if (key != null && iv != null) {
state.bindByteArray(3, key);
state.bindByteArray(4, iv);
}
state.step();
state.dispose();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
public void getEncryptedChat(final int chat_id, final Semaphore semaphore, final ArrayList<TLObject> result) {
if (semaphore == null || result == null) {
return;
......
......@@ -47,8 +47,25 @@ public class NativeLoader {
}
}
private static OutputStreamWriter streamWriter = null;
private static FileOutputStream stream = null;
private static void closeStream() {
try {
if (stream != null) {
streamWriter.close();
stream.close();
stream = null;
streamWriter = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void writeNativeError(Context context, String info, Throwable throwable) {
try {
if (stream == null) {
File sdCard = context.getFilesDir();
if (sdCard == null) {
return;
......@@ -58,17 +75,16 @@ public class NativeLoader {
return;
}
FileOutputStream stream = new FileOutputStream(file);
OutputStreamWriter streamWriter = new OutputStreamWriter(stream);
streamWriter.write("info" + "\n");
stream = new FileOutputStream(file);
streamWriter = new OutputStreamWriter(stream);
}
streamWriter.write(info + "\n");
streamWriter.write(throwable + "\n");
StackTraceElement[] stack = throwable.getStackTrace();
for (StackTraceElement el : stack) {
streamWriter.write(el + "\n");
}
streamWriter.flush();
streamWriter.close();
stream.close();
} catch (Exception e) {
e.printStackTrace();
}
......@@ -147,9 +163,9 @@ public class NativeLoader {
return;
}
try {
cleanNativeLog(context);
try {
String folder = null;
long libSize = 0;
long libSize2 = 0;
......@@ -191,6 +207,7 @@ public class NativeLoader {
try {
System.loadLibrary("tmessages");
nativeLoaded = true;
closeStream();
return;
} catch (Error e) {
FileLog.e("tmessages", e);
......@@ -206,6 +223,7 @@ public class NativeLoader {
FileLog.d("tmessages", "Load local lib");
System.load(destLocalFile.getAbsolutePath());
nativeLoaded = true;
closeStream();
return;
} catch (Error e) {
FileLog.e("tmessages", e);
......@@ -230,6 +248,7 @@ public class NativeLoader {
try {
System.loadLibrary("tmessages");
nativeLoaded = true;
closeStream();
} catch (Error e) {
writeNativeError(context, "last chance", e);
FileLog.e("tmessages", e);
......
......@@ -3783,14 +3783,6 @@ public class TLRPC {
}
}
public static class InputEncryptedFile extends TLObject {
public long id;
public long access_hash;
public int parts;
public int key_fingerprint;
public String md5_checksum;
}
public static class TL_inputEncryptedFile extends InputEncryptedFile {
public static int constructor = 0x5a17b5e5;
......@@ -9212,4 +9204,14 @@ public class TLRPC {
}
}
}
public static class InputEncryptedFile extends TLObject {
public long id;
public long access_hash;
public int parts;
public int key_fingerprint;
public String md5_checksum;
public byte[] key;
public byte[] iv;
}
}
......@@ -135,7 +135,7 @@ public class TcpConnection extends ConnectionContext {
client.addListener(TcpConnection.this);
if ((transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
if (isNextPort) {
client.setTimeout(15000);
client.setTimeout(20000);
} else {
client.setTimeout(30000);
}
......@@ -424,7 +424,7 @@ public class TcpConnection extends ConnectionContext {
datacenter.storeCurrentAddressAndPortNum();
isNextPort = false;
if ((transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
client.setTimeout(40000);
client.setTimeout(60000 * 3 + 20000);
} else {
client.setTimeout(25000);
}
......
......@@ -747,6 +747,9 @@ public class Utilities {
}
public static String MD5(String md5) {
if (md5 == null) {
return null;
}
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(md5.getBytes());
......
......@@ -102,6 +102,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
onlineText = (TextView)fragmentView.findViewById(R.id.settings_online);
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
avatarImage.processDetach = false;
phoneText = (TextView)fragmentView.findViewById(R.id.settings_name);
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
phoneText.setTypeface(typeface);
......
......@@ -85,7 +85,7 @@ public class CountrySelectActivity extends BaseFragment {
}
arr.add(c);
}
reader.close();//TODO
reader.close();
stream.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
......
......@@ -45,7 +45,7 @@ import java.util.HashMap;
public class DocumentSelectActivity extends BaseFragment {
public static abstract interface DocumentSelectActivityDelegate {
public void didSelectFile(DocumentSelectActivity activity, String path, String name, String ext, long size);
public void didSelectFile(DocumentSelectActivity activity, String path);
public void startDocumentSelectActivity();
}
......@@ -186,7 +186,7 @@ public class DocumentSelectActivity extends BaseFragment {
return;
}
if (delegate != null) {
delegate.didSelectFile(DocumentSelectActivity.this, file.getAbsolutePath(), item.title, item.ext, file.length());
delegate.didSelectFile(DocumentSelectActivity.this, file.getAbsolutePath());
}
}
}
......
......@@ -498,14 +498,14 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
fragment.processSendingText(sendingText);
}
if (documentPath != null) {
fragment.processSendingDocument(documentPath);
fragment.processSendingDocument(documentPath, null);
}
if (imagesPathArray != null) {
fragment.processSendingPhotos(null, imagesPathArray);
}
if (documentsPathArray != null) {
for (String path : documentsPathArray) {
fragment.processSendingDocument(path);
fragment.processSendingDocument(path, null);
}
}
if (contactsToSend != null && !contactsToSend.isEmpty()) {
......
......@@ -148,6 +148,12 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
if (id == -1) {
finishFragment();
} else if (id == block_contact) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
if (user == null) {
return;
......@@ -163,6 +169,10 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
}
}, null, true, RPCRequest.RPCRequestClassGeneric);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (id == add_contact) {
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
Bundle args = new Bundle();
......
......@@ -377,7 +377,7 @@ public class ActionBarLayer extends FrameLayout {
}
actionMode.setVisibility(GONE);
if (backButtonFrameLayout != null) {
backButtonFrameLayout.setVisibility(VISIBLE);
backButtonFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE);
}
if (menu != null) {
menu.setVisibility(VISIBLE);
......@@ -471,10 +471,10 @@ public class ActionBarLayer extends FrameLayout {
return;
}
isBackOverlayVisible = visible;
positionBackOverlay(getMeasuredWidth(), getMeasuredHeight());
if (visible) {
((ActionBarActivity)getContext()).onOverlayShow(actionOverlay, parentFragment);
}
positionBackOverlay(getMeasuredWidth(), getMeasuredHeight());
}
private void positionBackOverlay(int widthMeasureSpec, int heightMeasureSpec) {
......
......@@ -129,7 +129,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
uploadingAvatar = Utilities.getCacheDir() + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg";
NotificationCenter.getInstance().addObserver(AvatarUpdater.this, FileLoader.FileDidUpload);
NotificationCenter.getInstance().addObserver(AvatarUpdater.this, FileLoader.FileDidFailUpload);
FileLoader.getInstance().uploadFile(uploadingAvatar, null, null);
FileLoader.getInstance().uploadFile(uploadingAvatar, null, false);
}
}
}
......
<FrameLayout
<org.telegram.ui.Views.FrameLayoutFixed
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400dp"
android:layout_height="fill_parent"
android:background="@drawable/bar_selector"
android:id="@+id/back_button_background">
android:id="@+id/back_button_background"
android:layout_gravity="top">
<ProgressBar
android:layout_height="32dp"
......@@ -26,15 +27,15 @@
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_marginLeft="52dp"
android:textColor="#ffffff"
android:textSize="17dp"
android:layout_gravity="center_vertical|left"
android:gravity="left"
android:gravity="top|left"
android:ellipsize="end"
android:singleLine="true"
android:paddingRight="2dp"
android:id="@+id/status_text"/>
</FrameLayout>
\ No newline at end of file
</org.telegram.ui.Views.FrameLayoutFixed>
\ No newline at end of file
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