Bug fixes

This commit is contained in:
DrKLO 2014-04-03 14:23:39 +04:00
parent ebedf3c367
commit 51aa4141a4
17 changed files with 68 additions and 62 deletions

View file

@ -82,7 +82,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 217
versionCode 219
versionName "1.4.9"
}
}

View file

@ -37,7 +37,7 @@ public class AwakeService extends Service {
public static void startService() {
try {
if (MessagesController.isScreenOn && ApplicationLoader.lastPauseTime == 0) {
if (ApplicationLoader.isScreenOn && ApplicationLoader.lastPauseTime == 0) {
return;
}
timeout = 10000;

View file

@ -2041,13 +2041,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (request.serverFailureCount < 1) {
discardResponse = true;
request.runningMinStartTime = request.runningStartTime + 1;
request.serverFailureCount++;
}
} else {
discardResponse = true;
request.runningMinStartTime = request.runningStartTime + 1;
int delay = Math.min(1, request.serverFailureCount * 2);
request.runningMinStartTime = request.runningStartTime + delay;
request.confirmed = false;
}
request.serverFailureCount++;
} else if (errorCode == 420) {
if ((request.flags & RPCRequest.RPCRequestClassFailOnServerErrors) == 0) {
double waitTime = 2.0;

View file

@ -323,19 +323,9 @@ public class ContactsController {
name = PhoneFormat.getInstance().format(phone);
}
String[] args = name.split(" ", 2);
Contact contact = new Contact();
if (args.length > 0) {
contact.first_name = args[0];
} else {
contact.first_name = "";
}
if (args.length > 1) {
contact.last_name = args[1];
} else {
contact.first_name = name;
contact.last_name = "";
}
contact.id = pCur.getInt(2);
contactsMap.put(contact.id, contact);

View file

@ -49,13 +49,13 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
}
}
AwakeService.startService();
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
ApplicationLoader.postInitApplication();
AwakeService.startService();
try {
String key = intent.getStringExtra("loc_key");
if ("DC_UPDATE".equals(key)) {

View file

@ -319,13 +319,18 @@ public class LocaleController {
} else if(eventType == XmlPullParser.TEXT) {
if (attrName != null) {
value = parser.getText();
if (value != null) {
value = value.trim();
value = value.replace("\\n", "\n");
value = value.replace("\\", "");
}
}
} else if (eventType == XmlPullParser.END_TAG) {
value = null;
attrName = null;
name = null;
}
if (name != null && name.equals("string") && value != null && attrName != null) {
if (name != null && name.equals("string") && value != null && attrName != null && value.length() != 0 && attrName.length() != 0) {
stringMap.put(attrName, value);
name = null;
value = null;

View file

@ -26,7 +26,6 @@ import android.media.AudioManager;
import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.os.Vibrator;
import android.provider.Settings;
import android.support.v4.app.NotificationCompat;
@ -100,7 +99,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public int fontSize = Utilities.dp(16);
public long scheduleContactsReload = 0;
public static volatile boolean isScreenOn = true;
public MessageObject currentPushMessage;
private class UserActionUpdates extends TLRPC.Updates {
@ -201,14 +199,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
public MessagesController() {
try {
PowerManager pm = (PowerManager)ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
isScreenOn = pm.isScreenOn();
FileLog.e("tmessages", "screen state = " + isScreenOn);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
MessagesStorage storage = MessagesStorage.getInstance();
NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidUpload);
NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidFailUpload);
@ -2186,7 +2176,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
private void performSendEncryptedRequest(final TLRPC.DecryptedMessage req, final MessageObject newMsgObj, final TLRPC.EncryptedChat chat, final TLRPC.InputEncryptedFile encryptedFile) {
if (req == null) {
if (req == null || chat.auth_key == null || chat instanceof TLRPC.TL_encryptedChatRequested || chat instanceof TLRPC.TL_encryptedChatWaiting) {
return;
}
//TLRPC.decryptedMessageLayer messageLayer = new TLRPC.decryptedMessageLayer();
@ -3373,7 +3363,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
});
} else {
gettingDifference = false;
loadCurrentState();
getDifference();
FileLog.e("tmessages", "get difference error, don't know what to do :(");
}
}
@ -3424,7 +3414,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else {
dialog_id = obj.messageOwner.to_id.user_id;
}
if (dialog_id != openned_dialog_id || ApplicationLoader.lastPauseTime != 0 || !isScreenOn) {
if (dialog_id != openned_dialog_id || ApplicationLoader.lastPauseTime != 0 || !ApplicationLoader.isScreenOn) {
showInAppNotification(obj);
}
}
@ -3483,7 +3473,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else {
dialog_id = obj.messageOwner.to_id.user_id;
}
if (dialog_id != openned_dialog_id || ApplicationLoader.lastPauseTime != 0 || !isScreenOn) {
if (dialog_id != openned_dialog_id || ApplicationLoader.lastPauseTime != 0 || !ApplicationLoader.isScreenOn) {
showInAppNotification(obj);
}
}
@ -4240,7 +4230,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
return;
}
if (ApplicationLoader.lastPauseTime == 0 && isScreenOn) {
if (ApplicationLoader.lastPauseTime == 0 && ApplicationLoader.isScreenOn) {
boolean inAppSounds = preferences.getBoolean("EnableInAppSounds", true);
boolean inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true);
boolean inAppPreview = preferences.getBoolean("EnableInAppPreview", true);

View file

@ -34,7 +34,7 @@ public class NativeLoader {
return;
}
if (Build.VERSION.SDK_INT >= 10) {
if (Build.VERSION.SDK_INT > 10) {
try {
String folder = null;
long libSize = 0;

View file

@ -12,15 +12,17 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.telegram.ui.ApplicationLoader;
public class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
FileLog.e("tmessages", "screen off");
MessagesController.isScreenOn = false;
ApplicationLoader.isScreenOn = false;
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
FileLog.e("tmessages", "screen on");
MessagesController.isScreenOn = true;
ApplicationLoader.isScreenOn = true;
}
}
}

View file

@ -60,6 +60,9 @@ public class PhotoObject {
int closestHeight = 9999;
TLRPC.PhotoSize closestObject = null;
for (TLRPC.PhotoSize obj : sizes) {
if (obj == null) {
continue;
}
int diffW = Math.abs(obj.w - width);
int diffH = Math.abs(obj.h - height);
if (closestObject == null || closestObject instanceof TLRPC.TL_photoCachedSize || closestWidth > diffW || closestHeight > diffH) {

View file

@ -21,6 +21,7 @@ import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.PowerManager;
import android.view.ViewConfiguration;
import com.google.android.gms.common.ConnectionResult;
@ -56,6 +57,7 @@ public class ApplicationLoader extends Application {
public static volatile Context applicationContext = null;
public static volatile Handler applicationHandler = null;
private static volatile boolean applicationInited = false;
public static volatile boolean isScreenOn = false;
public static ArrayList<BaseFragment> fragmentsStack = new ArrayList<BaseFragment>();
@ -63,6 +65,7 @@ public class ApplicationLoader extends Application {
if (applicationInited) {
return;
}
applicationInited = true;
NativeLoader.initNativeLibs(applicationContext);
@ -82,6 +85,14 @@ public class ApplicationLoader extends Application {
e.printStackTrace();
}
try {
PowerManager pm = (PowerManager)ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
isScreenOn = pm.isScreenOn();
FileLog.e("tmessages", "screen state = " + isScreenOn);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
UserConfig.loadConfig();
if (UserConfig.currentUser != null) {
boolean changed = false;

View file

@ -198,7 +198,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} else if (currentMessageObject.type == 8) {
if (buttonState == -1) {
buttonState = 2;
if (gifDrawable != null) {
gifDrawable.pause();
}
invalidate();
} else if (buttonState == 2 || buttonState == 0) {
didPressedButton();
@ -344,6 +346,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoImage.setImageBitmap(messageObject.messageOwner.out ? placeholderOutDrawable : placeholderInDrawable);
}
invalidate();
/*if ((type == 6 || type == 7) && videoTimeText != null) {
int duration = message.messageOwner.media.video.duration;
int minutes = duration / 60;

View file

@ -15,7 +15,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
@ -80,6 +79,8 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
selectedBackground = preferences.getInt("selectedBackground", 1000001);
selectedColor = preferences.getInt("selectedColor", 0);
MessagesStorage.getInstance().getWallpapers();
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
toFile.delete();
return true;
}
@ -170,9 +171,15 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
done = false;
FileLog.e("tmessages", e);
}
} else {
if (selectedBackground == -1) {
File fromFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
done = fromFile.renameTo(toFile);
} else {
done = true;
}
}
if (done) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
@ -203,7 +210,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
Utilities.addMediaToGallery(currentPicturePath);
try {
Bitmap bitmap = FileLoader.loadBitmap(currentPicturePath, null, Utilities.dp(320), Utilities.dp(480));
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
FileOutputStream stream = new FileOutputStream(toFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
selectedBackground = -1;
@ -214,21 +221,12 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
}
currentPicturePath = null;
} else if (requestCode == 11) {
Uri imageUri = data.getData();
Cursor cursor = parentActivity.getContentResolver().query(imageUri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
if (cursor == null) {
if (data == null || data.getData() == null) {
return;
}
try {
String imageFilePath = null;
if (cursor.moveToFirst()) {
imageFilePath = cursor.getString(0);
}
cursor.close();
Bitmap bitmap = FileLoader.loadBitmap(imageFilePath, null, Utilities.dp(320), Utilities.dp(480));
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
Bitmap bitmap = FileLoader.loadBitmap(null, data.getData(), Utilities.dp(320), Utilities.dp(480));
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
FileOutputStream stream = new FileOutputStream(toFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
selectedBackground = -1;
@ -291,7 +289,10 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
backgroundImage.setBackgroundColor(0);
selectedColor = 0;
} else if (selectedBackground == -1) {
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
if (!toFile.exists()) {
toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
}
if (toFile.exists()) {
backgroundImage.setImageURI(Uri.fromFile(toFile));
} else {

View file

@ -517,8 +517,8 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
} else {
menu.add(Menu.NONE, share_contact, Menu.NONE, LocaleController.getString("ShareContact", R.string.ShareContact));
menu.add(Menu.NONE, block_contact, Menu.NONE, LocaleController.getString("BlockContact", R.string.BlockContact));
menu.add(Menu.NONE, block_contact, Menu.NONE, LocaleController.getString("EditContact", R.string.EditContact));
menu.add(Menu.NONE, block_contact, Menu.NONE, LocaleController.getString("DeleteContact", R.string.DeleteContact));
menu.add(Menu.NONE, edit_contact, Menu.NONE, LocaleController.getString("EditContact", R.string.EditContact));
menu.add(Menu.NONE, delete_contact, Menu.NONE, LocaleController.getString("DeleteContact", R.string.DeleteContact));
}
}

View file

@ -258,9 +258,9 @@
<string name="Language">Sprache</string>
<string name="AskAQuestionInfo">Please note that Telegram Support is done by volunteers. We try to respond as quickly as possible, but it may take a while.<![CDATA[<br><br>]]>Please take a look at the <![CDATA[<a href="http://telegram.org/faq#general">Telegram FAQ</a>]]>: it has important <![CDATA[<a href="http://telegram.org/faq#troubleshooting">troubleshooting tips</a>]]> and answers to most questions.</string>
<string name="AskButton">Ask a volunteer</string>
<string name="TelegramFaq">Telegram FAQ</string>
<string name="TelegramFaq">Telegram-FAQ</string>
<string name="TelegramFaqUrl">https://telegram.org/faq</string>
<string name="DeleteLocalization">Delete localization?</string>
<string name="DeleteLocalization">Lokalisierung löschen?</string>
<string name="IncorrectLocalization">Incorrect localization file</string>
<!--media view-->

View file

@ -258,10 +258,10 @@
<string name="Language">Idioma</string>
<string name="AskAQuestionInfo">Por favor, ten en cuenta que el Soporte de Telegram está hecho por voluntarios. Intentamos responder lo antes posible, pero puede tomar un tiempo.<![CDATA[<br><br>]]>Por favor, echa un vistazo a las <![CDATA[<a href=“http://telegram.org/faq/es”>Preguntas Frecuentes de Telegram</a>]]>: tiene importantes <![CDATA[<a href=“http://telegram.org/faq/es#solucin-de-problemas”>Soluciones a problemas</a>]]> y respuestas para la mayoría de las preguntas.</string>
<string name="AskButton">Preguntar</string>
<string name="TelegramFaq">Telegram FAQ</string>
<string name="TelegramFaq">Preguntas frecuentes</string>
<string name="TelegramFaqUrl">https://telegram.org/faq/es</string>
<string name="DeleteLocalization">¿Eliminar localización?</string>
<string name="IncorrectLocalization">Incorrect localization file</string>
<string name="IncorrectLocalization">Fichero de localización incorrecto</string>
<!--media view-->
<string name="NoMedia">No hay fotos ni vídeos compartidos aún</string>

View file

@ -258,10 +258,10 @@
<string name="Language">Lingua</string>
<string name="AskAQuestionInfo">Nota che il supporto di Telegram è fornito da volontari. Proviamo a rispondere non appena possibile, ma potrebbe richiedere del tempo.<![CDATA[<br><br>]]>Dai un\'occhiata alle <![CDATA[<a href="http://telegram.org/faq#general">Domande frequenti</a>]]>: troverai risposte alla maggior parte delle domande e suggerimenti importanti per <![CDATA[<a href="http://telegram.org/faq#troubleshooting">l\'individuazione del problema</a>]]>.</string>
<string name="AskButton">Chiedi a un volontario</string>
<string name="TelegramFaq">Telegram FAQ</string>
<string name="TelegramFaq">Domande frequenti</string>
<string name="TelegramFaqUrl">https://telegram.org/faq</string>
<string name="DeleteLocalization">Eliminare la localizzazione?</string>
<string name="IncorrectLocalization">Incorrect localization file</string>
<string name="IncorrectLocalization">File della localizzazione non valido</string>
<!--media view-->
<string name="NoMedia">Nessun media condiviso</string>