diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index 9d13b642a..40b5ca178 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -1665,38 +1665,43 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. } void refillSaltSet(final Datacenter datacenter) { - for (RPCRequest request : requestQueue) { - if (request.rawRequest instanceof TLRPC.TL_get_future_salts) { - Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId); - if (requestDatacenter.datacenterId == datacenter.datacenterId) { - return; - } - } - } - - for (RPCRequest request : runningRequests) { - if (request.rawRequest instanceof TLRPC.TL_get_future_salts) { - Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId); - if (requestDatacenter.datacenterId == datacenter.datacenterId) { - return; - } - } - } - - TLRPC.TL_get_future_salts getFutureSalts = new TLRPC.TL_get_future_salts(); - getFutureSalts.num = 32; - - performRpc(getFutureSalts, new RPCRequest.RPCRequestDelegate() { + Utilities.stageQueue.postRunnable(new Runnable() { @Override - public void run(TLObject response, TLRPC.TL_error error) { - TLRPC.TL_futuresalts res = (TLRPC.TL_futuresalts)response; - if (error == null) { - int currentTime = getCurrentTime(); - datacenter.mergeServerSalts(currentTime, res.salts); - saveSession(); + public void run() { + for (RPCRequest request : requestQueue) { + if (request.rawRequest instanceof TLRPC.TL_get_future_salts) { + Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId); + if (requestDatacenter.datacenterId == datacenter.datacenterId) { + return; + } + } } + + for (RPCRequest request : runningRequests) { + if (request.rawRequest instanceof TLRPC.TL_get_future_salts) { + Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId); + if (requestDatacenter.datacenterId == datacenter.datacenterId) { + return; + } + } + } + + TLRPC.TL_get_future_salts getFutureSalts = new TLRPC.TL_get_future_salts(); + getFutureSalts.num = 32; + + performRpc(getFutureSalts, new RPCRequest.RPCRequestDelegate() { + @Override + public void run(TLObject response, TLRPC.TL_error error) { + TLRPC.TL_futuresalts res = (TLRPC.TL_futuresalts)response; + if (error == null) { + int currentTime = getCurrentTime(); + datacenter.mergeServerSalts(currentTime, res.salts); + saveSession(); + } + } + }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin, datacenter.datacenterId); } - }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin, datacenter.datacenterId); + }); } void messagesConfirmed(final long requestMsgId) { @@ -2195,12 +2200,22 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. TLRPC.MsgDetailedInfo detailedInfo = (TLRPC.MsgDetailedInfo)message; boolean requestResend = false; + boolean confirm = true; if (detailedInfo instanceof TLRPC.TL_msg_detailed_info) { long requestMid = ((TLRPC.TL_msg_detailed_info)detailedInfo).msg_id; for (RPCRequest request : runningRequests) { if (request.respondsToMessageId(requestMid)) { - requestResend = true; + if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0) { + if (request.runningStartTime + 60 < System.currentTimeMillis() / 1000) { + requestResend = true; + } else { + confirm = false; + } + break; + } else { + requestResend = true; + } break; } } @@ -2221,7 +2236,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. arr.add(networkMessage); sendMessagesToTransport(arr, connection, false); } else { - connection.addMessageToConfirm(detailedInfo.answer_msg_id); + if (confirm) { + connection.addMessageToConfirm(detailedInfo.answer_msg_id); + } } } else if (message instanceof TLRPC.TL_gzip_packed) { TLRPC.TL_gzip_packed packet = (TLRPC.TL_gzip_packed)message; @@ -2494,6 +2511,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (message == null) { FileLog.e("tmessages", "***** Error parsing message: " + constructor); } else { + FileLog.e("tmessages", "received object " + message); processMessage(message, messageId, messageSeqNo, messageServerSalt, connection, 0, 0); connection.addProcessedMessageId(messageId); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java index f436b1161..aaac83a3f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -459,9 +459,9 @@ public class FileLoadOperation { if (requestInfo.response != null) { requestInfo.response.disableFree = false; requestInfo.response.freeResources(); - requestInfo.response = null; } } + delayedRequestInfos.clear(); } } @@ -635,12 +635,14 @@ public class FileLoadOperation { if (error == null) { try { if (downloadedBytes != requestInfo.offset) { - delayedRequestInfos.add(requestInfo); - requestInfo.response.disableFree = true; + if (state == 1) { + delayedRequestInfos.add(requestInfo); + requestInfo.response.disableFree = true; + } return; } - if (requestInfo.response.bytes.limit() == 0) { + if (requestInfo.response.bytes == null || requestInfo.response.bytes.limit() == 0) { onFinishLoadingFile(); return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 894ad0619..d49ff5a6e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1416,6 +1416,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not sendAsDocuments.add(tempPath); sendAsDocumentsOriginal.add(originalPath); } else { + if (tempPath != null) { + File temp = new File(tempPath); + originalPath += temp.length() + "_" + temp.lastModified(); + } TLRPC.TL_photo photo = (TLRPC.TL_photo)MessagesStorage.getInstance().getSentFile(originalPath, currentEncryptedChat == null ? 0 : 3); if (photo == null && uri != null) { photo = (TLRPC.TL_photo)MessagesStorage.getInstance().getSentFile(Utilities.getPath(uri), currentEncryptedChat == null ? 0 : 3); @@ -1561,7 +1565,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not new Thread(new Runnable() { @Override public void run() { - TLRPC.TL_video video = (TLRPC.TL_video)MessagesStorage.getInstance().getSentFile(videoPath, currentEncryptedChat == null ? 2 : 5); + String originalPath = videoPath; + File temp = new File(originalPath); + originalPath += temp.length() + "_" + temp.lastModified(); + TLRPC.TL_video video = (TLRPC.TL_video)MessagesStorage.getInstance().getSentFile(originalPath, currentEncryptedChat == null ? 2 : 5); if (video == null) { Bitmap thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Video.Thumbnails.MINI_KIND); TLRPC.PhotoSize size = FileLoader.scaleAndSaveImage(thumb, 90, 90, 55, currentEncryptedChat != null); @@ -1574,7 +1581,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not video.caption = ""; video.mime_type = "video/mp4"; video.id = 0; - File temp = new File(videoPath); if (temp != null && temp.exists()) { video.size = (int) temp.length(); } @@ -1593,10 +1599,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not video.path = videoPath; final TLRPC.TL_video videoFinal = video; + final String originalPathFinal = originalPath; Utilities.RunOnUIThread(new Runnable() { @Override public void run() { - MessagesController.getInstance().sendMessage(videoFinal, videoPath, dialog_id); + MessagesController.getInstance().sendMessage(videoFinal, originalPathFinal, dialog_id); if (chatListView != null) { chatListView.setSelection(messages.size() + 1); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java index f03db3574..d390540f8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java @@ -9,6 +9,9 @@ package org.telegram.ui; import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageInfo; +import android.os.Build; import android.os.Bundle; import android.text.Html; import android.util.AttributeSet; @@ -36,6 +39,7 @@ import org.telegram.messenger.Utilities; import org.telegram.ui.Views.SlideView; import java.util.ArrayList; +import java.util.Locale; import java.util.Timer; import java.util.TimerTask; @@ -46,6 +50,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente private EditText codeField; private TextView confirmTextView; private TextView timeText; + private TextView problemText; private Bundle currentParams; private Timer timeTimer; @@ -54,6 +59,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente private double lastCurrentTime; private boolean waitingForSms = false; private boolean nextPressed = false; + private String lastError = ""; public LoginActivitySmsView(Context context) { super(context); @@ -75,8 +81,11 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente codeField = (EditText)findViewById(R.id.login_sms_code_field); codeField.setHint(LocaleController.getString("Code", R.string.Code)); timeText = (TextView)findViewById(R.id.login_time_text); + problemText = (TextView)findViewById(R.id.login_problem); TextView wrongNumber = (TextView) findViewById(R.id.wrong_number); wrongNumber.setText(LocaleController.getString("WrongNumber", R.string.WrongNumber)); + problemText.setText(LocaleController.getString("DidNotGetTheCode", R.string.DidNotGetTheCode)); + problemText.setVisibility(time < 1000 ? VISIBLE : GONE); wrongNumber.setOnClickListener(new OnClickListener() { @Override @@ -86,6 +95,27 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente } }); + problemText.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + try { + PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); + String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode); + + Intent mailer = new Intent(Intent.ACTION_SEND); + mailer.setType("message/rfc822"); + mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@telegram.org"}); + mailer.putExtra(Intent.EXTRA_SUBJECT, "Android registration/login issue " + version + " " + requestPhone); + mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError); + getContext().startActivity(Intent.createChooser(mailer, "Send email...")); + } catch (Exception e) { + if (delegate != null) { + delegate.needShowAlert(LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled)); + } + } + } + }); + codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { @@ -134,6 +164,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente destroyTimer(); timeText.setText(String.format("%s 1:00", LocaleController.getString("CallText", R.string.CallText))); lastCurrentTime = System.currentTimeMillis(); + problemText.setVisibility(time < 1000 ? VISIBLE : GONE); createTimer(); } @@ -158,6 +189,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente int seconds = time / 1000 - minutes * 60; timeText.setText(String.format("%s %d:%02d", LocaleController.getString("CallText", R.string.CallText), minutes, seconds)); } else { + problemText.setVisibility(VISIBLE); timeText.setText(LocaleController.getString("Calling", R.string.Calling)); destroyTimer(); TLRPC.TL_auth_sendCall req = new TLRPC.TL_auth_sendCall(); @@ -165,7 +197,15 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente req.phone_code_hash = phoneHash; ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { @Override - public void run(TLObject response, TLRPC.TL_error error) { + public void run(TLObject response, final TLRPC.TL_error error) { + if (error != null && error.text != null) { + Utilities.RunOnUIThread(new Runnable() { + @Override + public void run() { + lastError = error.text; + } + }); + } } }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin); } @@ -232,6 +272,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente delegate.needFinishActivity(); ConnectionsManager.getInstance().initPushConnection(); } else { + lastError = error.text; if (error.text.contains("PHONE_NUMBER_UNOCCUPIED") && registered == null) { Bundle params = new Bundle(); params.putString("phoneFormated", requestPhone); diff --git a/TMessagesProj/src/main/res/layout/login_layout.xml b/TMessagesProj/src/main/res/layout/login_layout.xml index 9b249a74f..70818ccca 100644 --- a/TMessagesProj/src/main/res/layout/login_layout.xml +++ b/TMessagesProj/src/main/res/layout/login_layout.xml @@ -159,6 +159,18 @@ android:textColor="#808080" android:lineSpacingExtra="2dp"/> + + جاري الاتصال بك ... رمز التفعيل الرقم خاطئ؟ + Didn\'t get the code? اسمك @@ -355,6 +356,7 @@ اسم العائلة غير صحيح جاري التحميل ... ليس لديك أي مشغل مقاطع مرئية، يرجى تنزيل أية مشغل + Please send an email to sms@telegram.org and explain your problem. لا يوجد لديك تطبيق يمكنه فتح \'%1$s\'، يرجى تنزيل تطبيق مناسب للإستمرار هذا المستخدم ليس لديه تيليجرام بعد ، هل ترغب في دعوته الآن؟ هل أنت متأكد؟ diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index d59ae358d..baa8ca46a 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -22,6 +22,7 @@ Wir rufen dich an… Code Falsche Nummer? + Didn\'t get the code? Dein Name @@ -355,6 +356,7 @@ Ungültiger Nachname Lädt… Du hast keinen Videoplayer. Bitte installiere einen um fortzufahren. + Please send an email to sms@telegram.org and explain your problem. Du hast keine App, die den Dokumententyp \'%1$s\' öffnen kann. Dieser Benutzer hat noch kein Telegram. Möchtest du ihn einladen? Bist du sicher? diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index bb22fce3b..8f0f7a43f 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -22,6 +22,7 @@ Llamándote... Código ¿Número incorrecto? + Didn\'t get the code? Tu nombre @@ -355,6 +356,7 @@ Apellido/s inválido/s Cargando... No tienes reproductor de vídeo. Por favor, instala uno para continuar. + Please send an email to sms@telegram.org and explain your problem. No tienes una aplicación que pueda manejar el tipo mime \'%1$s\'. Por favor, instala una para continuar Este usuario no tiene Telegram aún. ¿Enviarle una invitación? ¿Estás seguro? diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index 741d366d5..fc3a0a580 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -22,6 +22,7 @@ Ti stiamo chiamando… Codice Numero errato? + Didn\'t get the code? Il tuo nome @@ -355,6 +356,7 @@ Cognome non valido Caricamento… Non hai un lettore video, per favore installane uno per continuare + Please send an email to sms@telegram.org and explain your problem. Non hai nessuna applicazione che può gestire il tipo mime \'%1$s\', installane una per continuare Questo utente non ha ancora Telegram, vuoi invitarlo? Sei sicuro? diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index e3005f5e4..d5729dabf 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -22,6 +22,7 @@ We bellen je… Code Verkeerd nummer? + Didn\'t get the code? Je naam @@ -355,6 +356,7 @@ Ongeldige achternaam Bezig met laden… Je hebt geen mediaspeler. Installeer een mediaspeler om door te gaan. + Please send an email to sms@telegram.org and explain your problem. Je hebt geen applicaties die het MIME-type \'%1$s\' ondersteunen. Installeer een geschikte applicatie om door te gaan. Deze gebruiker heeft nog geen Telegram. Wil je een uitnodiging sturen? Weet je het zeker? diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 21691d0ae..2d0d4c09d 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -22,6 +22,7 @@ Estamos te ligando... Código Número incorreto? + Didn\'t get the code? Seu nome @@ -355,6 +356,7 @@ Sobrenome inválido Carregando... Você não possui um reprodutor de vídeo, instale um para continuar + Please send an email to sms@telegram.org and explain your problem. Você não possui algum aplicativo que pode lidar com o tipo MIME \'%1$s\'. Por favor, instale um para continuar Este usuário ainda não possui Telegram, deseja enviar um convite? Você tem certeza? diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index 2a96eb91b..ac23ff2f3 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -22,6 +22,7 @@ A ligar... Código Número incorreto? + Didn\'t get the code? O seu nome @@ -355,6 +356,7 @@ Apelido inválido A carregar... Não tem nenhum reprodutor de vídeo. Para continuar, instale algum + Please send an email to sms@telegram.org and explain your problem. Não tem nenhuma aplicação que controle o tipo de MIME \'%1$s\'. Para continuar, instale alguma Este utilizador ainda não tem o Telegram. Quer enviar um convite? Tem a certeza? diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 0c9a7fedf..14d0d36dc 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -22,6 +22,7 @@ Calling you... Code Wrong number? + Didn\'t get the code? Your name @@ -355,6 +356,7 @@ Invalid last name Loading... You don\'t have a video player, please install one to continue + Please send an email to sms@telegram.org and explain your problem. You don\'t have any application that can handle with mime type \'%1$s\', please install one to continue This user does not have Telegram yet, send an invitation? Are you sure?