1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-06-30 10:14:04 +00:00

Bug fixes

This commit is contained in:
DrKLO 2014-07-04 02:41:59 +04:00
parent 97ac030a65
commit c549e8bc57
13 changed files with 135 additions and 39 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -159,6 +159,18 @@
android:textColor="#808080"
android:lineSpacingExtra="2dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login_problem"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:textSize="16dp"
android:textColor="#316f9f"
android:lineSpacingExtra="2dp"
android:paddingTop="2dp"
android:paddingBottom="12dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"

View File

@ -22,6 +22,7 @@
<string name="Calling">جاري الاتصال بك ...</string>
<string name="Code">رمز التفعيل</string>
<string name="WrongNumber">الرقم خاطئ؟</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">اسمك</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">اسم العائلة غير صحيح</string>
<string name="Loading">جاري التحميل ...</string>
<string name="NoPlayerInstalled">ليس لديك أي مشغل مقاطع مرئية، يرجى تنزيل أية مشغل</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">لا يوجد لديك تطبيق يمكنه فتح \'%1$s\'، يرجى تنزيل تطبيق مناسب للإستمرار</string>
<string name="InviteUser">هذا المستخدم ليس لديه تيليجرام بعد ، هل ترغب في دعوته الآن؟</string>
<string name="AreYouSure">هل أنت متأكد؟</string>

View File

@ -22,6 +22,7 @@
<string name="Calling">Wir rufen dich an…</string>
<string name="Code">Code</string>
<string name="WrongNumber">Falsche Nummer?</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">Dein Name</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">Ungültiger Nachname</string>
<string name="Loading">Lädt…</string>
<string name="NoPlayerInstalled">Du hast keinen Videoplayer. Bitte installiere einen um fortzufahren.</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">Du hast keine App, die den Dokumententyp \'%1$s\' öffnen kann.</string>
<string name="InviteUser">Dieser Benutzer hat noch kein Telegram. Möchtest du ihn einladen?</string>
<string name="AreYouSure">Bist du sicher?</string>

View File

@ -22,6 +22,7 @@
<string name="Calling">Llamándote...</string>
<string name="Code">Código</string>
<string name="WrongNumber">¿Número incorrecto?</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">Tu nombre</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">Apellido/s inválido/s</string>
<string name="Loading">Cargando...</string>
<string name="NoPlayerInstalled">No tienes reproductor de vídeo. Por favor, instala uno para continuar.</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">No tienes una aplicación que pueda manejar el tipo mime \'%1$s\'. Por favor, instala una para continuar</string>
<string name="InviteUser">Este usuario no tiene Telegram aún. ¿Enviarle una invitación?</string>
<string name="AreYouSure">¿Estás seguro?</string>

View File

@ -22,6 +22,7 @@
<string name="Calling">Ti stiamo chiamando…</string>
<string name="Code">Codice</string>
<string name="WrongNumber">Numero errato?</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">Il tuo nome</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">Cognome non valido</string>
<string name="Loading">Caricamento…</string>
<string name="NoPlayerInstalled">Non hai un lettore video, per favore installane uno per continuare</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">Non hai nessuna applicazione che può gestire il tipo mime \'%1$s\', installane una per continuare</string>
<string name="InviteUser">Questo utente non ha ancora Telegram, vuoi invitarlo?</string>
<string name="AreYouSure">Sei sicuro?</string>

View File

@ -22,6 +22,7 @@
<string name="Calling">We bellen je…</string>
<string name="Code">Code</string>
<string name="WrongNumber">Verkeerd nummer?</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">Je naam</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">Ongeldige achternaam</string>
<string name="Loading">Bezig met laden…</string>
<string name="NoPlayerInstalled">Je hebt geen mediaspeler. Installeer een mediaspeler om door te gaan.</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">Je hebt geen applicaties die het MIME-type \'%1$s\' ondersteunen. Installeer een geschikte applicatie om door te gaan.</string>
<string name="InviteUser">Deze gebruiker heeft nog geen Telegram. Wil je een uitnodiging sturen?</string>
<string name="AreYouSure">Weet je het zeker?</string>

View File

@ -22,6 +22,7 @@
<string name="Calling">Estamos te ligando...</string>
<string name="Code">Código</string>
<string name="WrongNumber">Número incorreto?</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">Seu nome</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">Sobrenome inválido</string>
<string name="Loading">Carregando...</string>
<string name="NoPlayerInstalled">Você não possui um reprodutor de vídeo, instale um para continuar</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">Você não possui algum aplicativo que pode lidar com o tipo MIME \'%1$s\'. Por favor, instale um para continuar</string>
<string name="InviteUser">Este usuário ainda não possui Telegram, deseja enviar um convite?</string>
<string name="AreYouSure">Você tem certeza?</string>

View File

@ -22,6 +22,7 @@
<string name="Calling">A ligar...</string>
<string name="Code">Código</string>
<string name="WrongNumber">Número incorreto?</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">O seu nome</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">Apelido inválido</string>
<string name="Loading">A carregar...</string>
<string name="NoPlayerInstalled">Não tem nenhum reprodutor de vídeo. Para continuar, instale algum</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">Não tem nenhuma aplicação que controle o tipo de MIME \'%1$s\'. Para continuar, instale alguma</string>
<string name="InviteUser">Este utilizador ainda não tem o Telegram. Quer enviar um convite?</string>
<string name="AreYouSure">Tem a certeza?</string>

View File

@ -22,6 +22,7 @@
<string name="Calling">Calling you...</string>
<string name="Code">Code</string>
<string name="WrongNumber">Wrong number?</string>
<string name="DidNotGetTheCode">Didn\'t get the code?</string>
<!--signup view-->
<string name="YourName">Your name</string>
@ -355,6 +356,7 @@
<string name="InvalidLastName">Invalid last name</string>
<string name="Loading">Loading...</string>
<string name="NoPlayerInstalled">You don\'t have a video player, please install one to continue</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string>
<string name="NoHandleAppInstalled">You don\'t have any application that can handle with mime type \'%1$s\', please install one to continue</string>
<string name="InviteUser">This user does not have Telegram yet, send an invitation?</string>
<string name="AreYouSure">Are you sure?</string>