update to 1.2.7

This commit is contained in:
DrKLO 2013-11-04 16:31:01 +04:00
parent 27b74b537e
commit 90d8e8a370
55 changed files with 632 additions and 468 deletions

View File

@ -32,18 +32,18 @@ tasks.withType(Compile) {
dependencies { dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.google.android.gms:play-services:3.1.+' compile 'com.google.android.gms:play-services:4.0.+'
compile 'net.hockeyapp.android:HockeySDK:3.0.0' compile 'net.hockeyapp.android:HockeySDK:3.0.1'
compile 'com.android.support:support-v4:18.0.+' compile 'com.android.support:support-v4:19.0.+'
compile fileTree(dir: "$buildDir/native-libs", include: '*.jar') compile fileTree(dir: "$buildDir/native-libs", include: '*.jar')
} }
android { android {
compileSdkVersion 18 compileSdkVersion 19
buildToolsVersion "17.0.0" buildToolsVersion "19.0.0"
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 18 targetSdkVersion 19
} }
} }

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.telegram.messenger" package="org.telegram.messenger"
android:versionCode="91" android:versionCode="98"
android:versionName="1.2.4"> android:versionName="1.2.7">
<supports-screens android:anyDensity="true" <supports-screens android:anyDensity="true"
android:smallScreens="true" android:smallScreens="true"
@ -11,7 +11,7 @@
android:resizeable="true" android:resizeable="true"
android:xlargeScreens="true"/> android:xlargeScreens="true"/>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/> <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-feature android:name="android.hardware.telephony" android:required="false" /> <uses-feature android:name="android.hardware.telephony" android:required="false" />
@ -19,6 +19,8 @@
<uses-feature android:name="android.hardware.location.network" android:required="false" /> <uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" /> <uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.hardware.LOCATION" android:required="false" /> <uses-feature android:name="android.hardware.LOCATION" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />

View File

@ -228,7 +228,6 @@
31;NL;Netherlands 31;NL;Netherlands
30;GR;Greece 30;GR;Greece
27;ZA;South Africa 27;ZA;South Africa
21;DZ;Algeria
20;EG;Egypt 20;EG;Egypt
7;KZ;Kazakhstan 7;KZ;Kazakhstan
7;RU;Russia 7;RU;Russia

View File

@ -24,7 +24,7 @@
package org.telegram.PhoneFormat; package org.telegram.PhoneFormat;
import org.telegram.messenger.Utilities; import org.telegram.ui.ApplicationLoader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
@ -78,7 +78,7 @@ public class PhoneFormat {
public void init(String countryCode) { public void init(String countryCode) {
try { try {
InputStream stream = Utilities.applicationContext.getAssets().open("PhoneFormats.dat"); InputStream stream = ApplicationLoader.applicationContext.getAssets().open("PhoneFormats.dat");
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
int len; int len;

View File

@ -150,7 +150,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
Utilities.stageQueue.postRunnable(new Runnable() { Utilities.stageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
File configFile = new File(Utilities.applicationContext.getFilesDir(), "config.dat"); File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "config.dat");
if (configFile.exists()) { if (configFile.exists()) {
try { try {
SerializedData data = new SerializedData(configFile); SerializedData data = new SerializedData(configFile);
@ -235,7 +235,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
data.writeInt32(0); data.writeInt32(0);
} }
try { try {
File configFile = new File(Utilities.applicationContext.getFilesDir(), "config.dat"); File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "config.dat");
if (!configFile.exists()) { if (!configFile.exists()) {
configFile.createNewFile(); configFile.createNewFile();
} }
@ -491,7 +491,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
public static boolean isNetworkOnline() { public static boolean isNetworkOnline() {
boolean status = false; boolean status = false;
try { try {
ConnectivityManager cm = (ConnectivityManager)Utilities.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getNetworkInfo(0); NetworkInfo netInfo = cm.getNetworkInfo(0);
if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) { if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
status = true; status = true;

View File

@ -27,6 +27,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.ui.ApplicationLoader;
public class Emoji { public class Emoji {
private static final int[] ROW_SIZES = {27, 29, 33, 34, 34}; private static final int[] ROW_SIZES = {27, 29, 33, 34, 34};
private static HashMap<Long, DrawableInfo> rects = new HashMap<Long, DrawableInfo>(); private static HashMap<Long, DrawableInfo> rects = new HashMap<Long, DrawableInfo>();
@ -287,7 +289,7 @@ public class Emoji {
0x00000000D83DDD34L, 0x00000000D83DDD35L, 0x00000000D83DDD3BL, 0x00000000D83DDD36L, 0x00000000D83DDD37L, 0x00000000D83DDD38L, 0x00000000D83DDD39L}}; 0x00000000D83DDD34L, 0x00000000D83DDD35L, 0x00000000D83DDD3BL, 0x00000000D83DDD36L, 0x00000000D83DDD37L, 0x00000000D83DDD38L, 0x00000000D83DDD39L}};
static { static {
imgSize = Math.min(scale(30), Utilities.applicationContext.getResources().getDisplayMetrics().density < 1.5f ? 28 : 56); imgSize = Math.min(scale(30), ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density < 1.5f ? 28 : 56);
drawImgSize = scale(20); drawImgSize = scale(20);
bigImgSize = scale(30); bigImgSize = scale(30);
if(Math.abs(imgSize - bigImgSize) < 5) { if(Math.abs(imgSize - bigImgSize) < 5) {
@ -306,7 +308,7 @@ public class Emoji {
} }
public static int scale(float value) { public static int scale(float value) {
return (int)(Utilities.applicationContext.getResources().getDisplayMetrics().density * value); return (int)(ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density * value);
} }
private static Bitmap loadPage(final int page){ private static Bitmap loadPage(final int page){
@ -317,13 +319,13 @@ public class Emoji {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888; opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
opts.inDither = false; opts.inDither = false;
if (Utilities.applicationContext.getResources().getDisplayMetrics().density < 1.5f) { if (ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density < 1.5f) {
opts.inSampleSize = 2; opts.inSampleSize = 2;
} }
int iw, ih; int iw, ih;
InputStream is = Utilities.applicationContext.getAssets().open("emojisprite_" + page + ".png"); InputStream is = ApplicationLoader.applicationContext.getAssets().open("emojisprite_" + page + ".png");
Bitmap color = BitmapFactory.decodeStream(is, null, opts); Bitmap color = BitmapFactory.decodeStream(is, null, opts);
is.close(); is.close();
@ -559,8 +561,8 @@ public class Emoji {
int sz = super.getSize(paint, text, start, end, fm); int sz = super.getSize(paint, text, start, end, fm);
int offset = (int)(8 * Utilities.applicationContext.getResources().getDisplayMetrics().density); int offset = (int)(8 * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density);
int w = (int)(20 * Utilities.applicationContext.getResources().getDisplayMetrics().density / 2); int w = (int)(20 * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density / 2);
fm.top = -w - offset; fm.top = -w - offset;
fm.bottom = w - offset; fm.bottom = w - offset;
fm.ascent = -w - offset; fm.ascent = -w - offset;
@ -586,7 +588,7 @@ public class Emoji {
int sz = super.getSize(paint, text, start, end, fm); int sz = super.getSize(paint, text, start, end, fm);
int offset = (int)(6 * Utilities.applicationContext.getResources().getDisplayMetrics().density); int offset = (int)(6 * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density);
int w = (fm.bottom - fm.top) / 2; int w = (fm.bottom - fm.top) / 2;
fm.top = -w - offset; fm.top = -w - offset;
fm.bottom = w - offset; fm.bottom = w - offset;

View File

@ -18,6 +18,7 @@ import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import org.telegram.TL.TLRPC; import org.telegram.TL.TLRPC;
import org.telegram.ui.ApplicationLoader;
import org.telegram.ui.Views.BackupImageView; import org.telegram.ui.Views.BackupImageView;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -247,7 +248,7 @@ public class FileLoader {
public FileLoader() { public FileLoader() {
int maxMemory = (int)Runtime.getRuntime().maxMemory(); int maxMemory = (int)Runtime.getRuntime().maxMemory();
int cacheSize = maxMemory / 10; int cacheSize = maxMemory / 10;
density = Utilities.applicationContext.getResources().getDisplayMetrics().density; density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (Build.VERSION.SDK_INT < 11) { if (Build.VERSION.SDK_INT < 11) {
runtimeHack = new VMRuntimeHack(); runtimeHack = new VMRuntimeHack();
cacheSize = 1024 * 1024 * 3; cacheSize = 1024 * 1024 * 3;

View File

@ -198,7 +198,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setContentTitle(Utilities.applicationContext.getString(R.string.AppName)) .setContentTitle(ApplicationLoader.applicationContext.getString(R.string.AppName))
.setSmallIcon(R.drawable.notification) .setSmallIcon(R.drawable.notification)
.setStyle(new NotificationCompat.BigTextStyle() .setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg)) .bigText(msg))

View File

@ -39,6 +39,7 @@ import android.util.SparseArray;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.TL.TLClassStore; import org.telegram.TL.TLClassStore;
import org.telegram.TL.TLObject; import org.telegram.TL.TLObject;
import org.telegram.TL.TLRPC; import org.telegram.TL.TLRPC;
@ -197,7 +198,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
try { try {
soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
sound = soundPool.load(Utilities.applicationContext, R.raw.sound_a, 1); sound = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_a, 1);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -364,7 +365,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
public void checkAppAccount() { public void checkAppAccount() {
AccountManager am = AccountManager.get(Utilities.applicationContext); AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
Account[] accounts = am.getAccountsByType("org.telegram.messenger.account"); Account[] accounts = am.getAccountsByType("org.telegram.messenger.account");
boolean recreateAccount = false; boolean recreateAccount = false;
if (UserConfig.currentUser != null) { if (UserConfig.currentUser != null) {
@ -460,7 +461,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req.peer = new TLRPC.TL_inputPeerChat(); req.peer = new TLRPC.TL_inputPeerChat();
req.peer.chat_id = -lower_part; req.peer.chat_id = -lower_part;
} else { } else {
TLRPC.User user = MessagesController.Instance.users.get(uid); TLRPC.User user = users.get(lower_part);
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) { if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
req.peer = new TLRPC.TL_inputPeerForeign(); req.peer = new TLRPC.TL_inputPeerForeign();
req.peer.access_hash = user.access_hash; req.peer.access_hash = user.access_hash;
@ -518,7 +519,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req.peer = new TLRPC.TL_inputPeerChat(); req.peer = new TLRPC.TL_inputPeerChat();
req.peer.chat_id = -lower_part; req.peer.chat_id = -lower_part;
} else { } else {
TLRPC.User user = MessagesController.Instance.users.get(uid); TLRPC.User user = users.get(lower_part);
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) { if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
req.peer = new TLRPC.TL_inputPeerForeign(); req.peer = new TLRPC.TL_inputPeerForeign();
req.peer.access_hash = user.access_hash; req.peer.access_hash = user.access_hash;
@ -562,7 +563,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
final HashMap<String, ArrayList<Contact>> sectionsDict = new HashMap<String, ArrayList<Contact>>(); final HashMap<String, ArrayList<Contact>> sectionsDict = new HashMap<String, ArrayList<Contact>>();
final ArrayList<String> sortedSectionsArray = new ArrayList<String>(); final ArrayList<String> sortedSectionsArray = new ArrayList<String>();
ContentResolver cr = Utilities.applicationContext.getContentResolver(); ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();
String[] projectioPhones = { String[] projectioPhones = {
ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
@ -594,23 +595,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter
contactsMap.put(id, contact); contactsMap.put(id, contact);
contact.id = id; contact.id = id;
} }
number = number.replace(" ", "").replace("(", "").replace(")", "").replace("-", "").replace("+", "");
if (number.startsWith("8")) {
number = "7" + number.substring(1);
}
contact.phones.add(number); contact.phones.add(number);
if (type == ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM) { if (type == ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM) {
contact.phoneTypes.add(pCur.getString(3)); contact.phoneTypes.add(pCur.getString(3));
} else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_HOME) { } else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_HOME) {
contact.phoneTypes.add(Utilities.applicationContext.getString(R.string.PhoneHome)); contact.phoneTypes.add(ApplicationLoader.applicationContext.getString(R.string.PhoneHome));
} else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE) { } else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE) {
contact.phoneTypes.add(Utilities.applicationContext.getString(R.string.PhoneMobile)); contact.phoneTypes.add(ApplicationLoader.applicationContext.getString(R.string.PhoneMobile));
} else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_WORK) { } else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_WORK) {
contact.phoneTypes.add(Utilities.applicationContext.getString(R.string.PhoneWork)); contact.phoneTypes.add(ApplicationLoader.applicationContext.getString(R.string.PhoneWork));
} else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_MAIN) { } else if (type == ContactsContract.CommonDataKinds.Phone.TYPE_MAIN) {
contact.phoneTypes.add(Utilities.applicationContext.getString(R.string.PhoneMain)); contact.phoneTypes.add(ApplicationLoader.applicationContext.getString(R.string.PhoneMain));
} else { } else {
contact.phoneTypes.add(Utilities.applicationContext.getString(R.string.PhoneOther)); contact.phoneTypes.add(ApplicationLoader.applicationContext.getString(R.string.PhoneOther));
} }
} }
} }
@ -676,7 +674,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
imp.client_id = id; imp.client_id = id;
imp.first_name = value.first_name; imp.first_name = value.first_name;
imp.last_name = value.last_name; imp.last_name = value.last_name;
imp.phone = value.phones.get(a); imp.phone = PhoneFormat.stripExceptNumbers(value.phones.get(a));
toImport.add(imp); toImport.add(imp);
String str = imp.client_id + imp.first_name + imp.last_name + imp.phone; String str = imp.client_id + imp.first_name + imp.last_name + imp.phone;
if (mdEnc != null) { if (mdEnc != null) {
@ -747,7 +745,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (!toImport.isEmpty() && !UserConfig.importHash.equals(importHash)) { if (!toImport.isEmpty() && !UserConfig.importHash.equals(importHash)) {
UserConfig.importHash = importHash; UserConfig.importHash = importHash;
UserConfig.saveConfig(); UserConfig.saveConfig(false);
importContacts(toImport); importContacts(toImport);
} else { } else {
loadContacts(true); loadContacts(true);
@ -774,7 +772,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
try { try {
Uri rawContactUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_NAME, currentAccount.name).appendQueryParameter( Uri rawContactUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_NAME, currentAccount.name).appendQueryParameter(
ContactsContract.RawContacts.ACCOUNT_TYPE, currentAccount.type).build(); ContactsContract.RawContacts.ACCOUNT_TYPE, currentAccount.type).build();
Cursor c1 = Utilities.applicationContext.getContentResolver().query(rawContactUri, new String[]{BaseColumns._ID, ContactsContract.RawContacts.SYNC2}, null, null, null); Cursor c1 = ApplicationLoader.applicationContext.getContentResolver().query(rawContactUri, new String[]{BaseColumns._ID, ContactsContract.RawContacts.SYNC2}, null, null, null);
HashMap<Integer, Long> bookContacts = new HashMap<Integer, Long>(); HashMap<Integer, Long> bookContacts = new HashMap<Integer, Long>();
if (c1 != null) { if (c1 != null) {
while (c1.moveToNext()) { while (c1.moveToNext()) {
@ -832,7 +830,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
builder.withValue(ContactsContract.Data.DATA4, user.id); builder.withValue(ContactsContract.Data.DATA4, user.id);
query.add(builder.build()); query.add(builder.build());
try { try {
ContentProviderResult[] result = Utilities.applicationContext.getContentResolver().applyBatch(ContactsContract.AUTHORITY, query); ContentProviderResult[] result = ApplicationLoader.applicationContext.getContentResolver().applyBatch(ContactsContract.AUTHORITY, query);
return Long.parseLong(result[0].uri.getLastPathSegment()); return Long.parseLong(result[0].uri.getLastPathSegment());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -894,7 +892,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req.peer = new TLRPC.TL_inputPeerChat(); req.peer = new TLRPC.TL_inputPeerChat();
req.peer.chat_id = -lower_part; req.peer.chat_id = -lower_part;
} else { } else {
TLRPC.User user = MessagesController.Instance.users.get(did); TLRPC.User user = users.get(lower_part);
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) { if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
req.peer = new TLRPC.TL_inputPeerForeign(); req.peer = new TLRPC.TL_inputPeerForeign();
req.peer.access_hash = user.access_hash; req.peer.access_hash = user.access_hash;
@ -911,11 +909,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (res.offset > 0) { if (res.offset > 0) {
deleteDialog(did, res.offset, onlyHistory); deleteDialog(did, res.offset, onlyHistory);
} }
if (UserConfig.lastSeqValue + 1 == res.seq) { if (MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else if (UserConfig.lastSeqValue != res.seq) { } else if (MessagesStorage.lastSeqValue != res.seq) {
getDifference(); getDifference();
} }
} }
@ -1057,13 +1055,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
ArrayList<Long> keys = new ArrayList<Long>(printingUsers.keySet()); ArrayList<Long> keys = new ArrayList<Long>(printingUsers.keySet());
for (Long key : keys) { for (Long key : keys) {
if (key > 0) { if (key > 0) {
newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s</font>", Utilities.applicationContext.getString(R.string.Typing)))); newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s</font>", ApplicationLoader.applicationContext.getString(R.string.Typing))));
} else { } else {
ArrayList<PrintingUser> arr = printingUsers.get(key); ArrayList<PrintingUser> arr = printingUsers.get(key);
int count = 0; int count = 0;
String label = ""; String label = "";
for (PrintingUser pu : arr) { for (PrintingUser pu : arr) {
TLRPC.User user = MessagesController.Instance.users.get(pu.userId); TLRPC.User user = users.get(pu.userId);
if (user != null) { if (user != null) {
if (label.length() != 0) { if (label.length() != 0) {
label += ", "; label += ", ";
@ -1078,12 +1076,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (label.length() != 0) { if (label.length() != 0) {
if (count > 1) { if (count > 1) {
if (arr.size() > 2) { if (arr.size() > 2) {
newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s %s %s</font>", label, String.format(Utilities.applicationContext.getString(R.string.AndMoreTyping), arr.size() - 2), Utilities.applicationContext.getString(R.string.AreTyping)))); newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s %s %s</font>", label, String.format(ApplicationLoader.applicationContext.getString(R.string.AndMoreTyping), arr.size() - 2), ApplicationLoader.applicationContext.getString(R.string.AreTyping))));
} else { } else {
newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s %s</font>", label, Utilities.applicationContext.getString(R.string.AreTyping)))); newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s %s</font>", label, ApplicationLoader.applicationContext.getString(R.string.AreTyping))));
} }
} else { } else {
newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s %s</font>", label, Utilities.applicationContext.getString(R.string.IsTyping)))); newPrintingStrings.put(key, Html.fromHtml(String.format("<font color='#006fc8'>%s %s</font>", label, ApplicationLoader.applicationContext.getString(R.string.IsTyping))));
} }
} }
} }
@ -1127,7 +1125,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
ids += aContactsArr.user_id; ids += aContactsArr.user_id;
} }
UserConfig.contactsHash = Utilities.MD5(ids); UserConfig.contactsHash = Utilities.MD5(ids);
UserConfig.saveConfig(); UserConfig.saveConfig(false);
if (from == 2) { if (from == 2) {
loadContacts(false); loadContacts(false);
} }
@ -1414,7 +1412,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run() { public void run() {
for (TLRPC.User u : messagesRes.users) { for (TLRPC.User u : messagesRes.users) {
if (isCache) { if (isCache) {
users.putIfAbsent(u.id, u); if (u.id == UserConfig.clientUserId || u.id == 333000) {
users.put(u.id, u);
} else {
users.putIfAbsent(u.id, u);
}
} else { } else {
users.put(u.id, u); users.put(u.id, u);
if (u.id == UserConfig.clientUserId) { if (u.id == UserConfig.clientUserId) {
@ -1568,7 +1570,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run() { public void run() {
for (TLRPC.User u : dialogsRes.users) { for (TLRPC.User u : dialogsRes.users) {
if (isCache) { if (isCache) {
users.putIfAbsent(u.id, u); if (u.id == UserConfig.clientUserId || u.id == 333000) {
users.put(u.id, u);
} else {
users.putIfAbsent(u.id, u);
}
} else { } else {
users.put(u.id, u); users.put(u.id, u);
if (u.id == UserConfig.clientUserId) { if (u.id == UserConfig.clientUserId) {
@ -1632,7 +1638,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run() { public void run() {
for (TLRPC.User u : dialogsRes.users) { for (TLRPC.User u : dialogsRes.users) {
if (isCache) { if (isCache) {
users.putIfAbsent(u.id, u); if (u.id == UserConfig.clientUserId || u.id == 333000) {
users.put(u.id, u);
} else {
users.putIfAbsent(u.id, u);
}
} else { } else {
users.put(u.id, u); users.put(u.id, u);
if (u.id == UserConfig.clientUserId) { if (u.id == UserConfig.clientUserId) {
@ -1737,7 +1747,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (sizes.isEmpty()) { if (sizes.isEmpty()) {
return null; return null;
} else { } else {
UserConfig.saveConfig(); UserConfig.saveConfig(false);
TLRPC.TL_photo photo = new TLRPC.TL_photo(); TLRPC.TL_photo photo = new TLRPC.TL_photo();
photo.user_id = UserConfig.clientUserId; photo.user_id = UserConfig.clientUserId;
photo.date = ConnectionsManager.Instance.getCurrentTime(); photo.date = ConnectionsManager.Instance.getCurrentTime();
@ -1784,11 +1794,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
markDialogAsRead(dialog_id, 0, res.offset, max_date, was); markDialogAsRead(dialog_id, 0, res.offset, max_date, was);
} }
if (UserConfig.lastSeqValue + 1 == res.seq) { if (MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else if (UserConfig.lastSeqValue != res.seq) { } else if (MessagesStorage.lastSeqValue != res.seq) {
getDifference(); getDifference();
} }
} }
@ -1914,7 +1924,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMsg.out = true; newMsg.out = true;
newMsg.date = ConnectionsManager.Instance.getCurrentTime(); newMsg.date = ConnectionsManager.Instance.getCurrentTime();
newMsg.random_id = getNextRandomId(); newMsg.random_id = getNextRandomId();
UserConfig.saveConfig(); UserConfig.saveConfig(false);
final MessageObject newMsgObj = new MessageObject(newMsg, users); final MessageObject newMsgObj = new MessageObject(newMsg, users);
newMsgObj.messageOwner.send_state = MESSAGE_SEND_STATE_SENDING; newMsgObj.messageOwner.send_state = MESSAGE_SEND_STATE_SENDING;
@ -2048,7 +2058,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMsg.out = true; newMsg.out = true;
newMsg.date = ConnectionsManager.Instance.getCurrentTime(); newMsg.date = ConnectionsManager.Instance.getCurrentTime();
newMsg.random_id = getNextRandomId(); newMsg.random_id = getNextRandomId();
UserConfig.saveConfig(); UserConfig.saveConfig(false);
final MessageObject newMsgObj = new MessageObject(newMsg, null); final MessageObject newMsgObj = new MessageObject(newMsg, null);
newMsgObj.messageOwner.send_state = MESSAGE_SEND_STATE_SENDING; newMsgObj.messageOwner.send_state = MESSAGE_SEND_STATE_SENDING;
@ -2284,6 +2294,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
private void performSendEncryptedRequest(final TLRPC.DecryptedMessage req, final MessageObject newMsgObj, final TLRPC.EncryptedChat chat, final TLRPC.InputEncryptedFile encryptedFile) { private void performSendEncryptedRequest(final TLRPC.DecryptedMessage req, final MessageObject newMsgObj, final TLRPC.EncryptedChat chat, final TLRPC.InputEncryptedFile encryptedFile) {
if (req == null) {
return;
}
//TLRPC.decryptedMessageLayer messageLayer = new TLRPC.decryptedMessageLayer(); //TLRPC.decryptedMessageLayer messageLayer = new TLRPC.decryptedMessageLayer();
//messageLayer.layer = 8; //messageLayer.layer = 8;
//messageLayer.message = req; //messageLayer.message = req;
@ -2377,11 +2390,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (response instanceof TLRPC.TL_messages_sentMessage) { if (response instanceof TLRPC.TL_messages_sentMessage) {
TLRPC.TL_messages_sentMessage res = (TLRPC.TL_messages_sentMessage)response; TLRPC.TL_messages_sentMessage res = (TLRPC.TL_messages_sentMessage)response;
newMsgObj.messageOwner.id = res.id; newMsgObj.messageOwner.id = res.id;
if(UserConfig.lastSeqValue + 1 == res.seq) { if(MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastDateValue = res.date; MessagesStorage.lastDateValue = res.date;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else { } else {
getDifference(); getDifference();
} }
@ -2390,11 +2403,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
sendedMessages.add(res.message); sendedMessages.add(res.message);
newMsgObj.messageOwner.id = res.message.id; newMsgObj.messageOwner.id = res.message.id;
processSendedMessage(newMsgObj.messageOwner, res.message, null, null); processSendedMessage(newMsgObj.messageOwner, res.message, null, null);
if(UserConfig.lastSeqValue + 1 == res.seq) { if(MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.lastDateValue = res.message.date; MessagesStorage.lastDateValue = res.message.date;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else { } else {
getDifference(); getDifference();
} }
@ -2406,10 +2419,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
sendedMessages.add(message); sendedMessages.add(message);
processSendedMessage(newMsgObj.messageOwner, message, null, null); processSendedMessage(newMsgObj.messageOwner, message, null, null);
} }
if(UserConfig.lastSeqValue + 1 == res.seq) { if(MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else { } else {
getDifference(); getDifference();
} }
@ -2524,7 +2537,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newContactBook.phones = new ArrayList<String>(); newContactBook.phones = new ArrayList<String>();
newContactBook.phones.add(user.phone); newContactBook.phones.add(user.phone);
newContactBook.phoneTypes = new ArrayList<String>(); newContactBook.phoneTypes = new ArrayList<String>();
newContactBook.phoneTypes.add(Utilities.applicationContext.getString(R.string.PhoneMobile)); newContactBook.phoneTypes.add(ApplicationLoader.applicationContext.getString(R.string.PhoneMobile));
contactsMapBook.put((int)bookId, newContactBook); contactsMapBook.put((int)bookId, newContactBook);
String contactsImportHash = ""; String contactsImportHash = "";
@ -2715,7 +2728,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
UserConfig.contactsHash = Utilities.MD5(ids); UserConfig.contactsHash = Utilities.MD5(ids);
UserConfig.importHash = importHash; UserConfig.importHash = importHash;
UserConfig.saveConfig(); UserConfig.saveConfig(false);
MessagesStorage.Instance.putContacts(contactsArr, true); MessagesStorage.Instance.putContacts(contactsArr, true);
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>(); ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
@ -2816,7 +2829,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.TL_messages_createChat req = new TLRPC.TL_messages_createChat(); TLRPC.TL_messages_createChat req = new TLRPC.TL_messages_createChat();
req.title = title; req.title = title;
for (Integer uid : selectedContacts) { for (Integer uid : selectedContacts) {
TLRPC.User user = MessagesController.Instance.users.get(uid); TLRPC.User user = users.get(uid);
TLRPC.InputUser inputUser; TLRPC.InputUser inputUser;
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) { if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
inputUser = new TLRPC.TL_inputUserForeign(); inputUser = new TLRPC.TL_inputUserForeign();
@ -2845,11 +2858,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>(); final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>();
messages.add(res.message); messages.add(res.message);
MessagesStorage.Instance.putMessages(messages, true, true); MessagesStorage.Instance.putMessages(messages, true, true);
if (UserConfig.lastSeqValue + 1 == res.seq) { if (MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else if (UserConfig.lastSeqValue != res.seq) { } else if (MessagesStorage.lastSeqValue != res.seq) {
getDifference(); getDifference();
} }
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@ -2883,7 +2896,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.TL_messages_addChatUser req = new TLRPC.TL_messages_addChatUser(); TLRPC.TL_messages_addChatUser req = new TLRPC.TL_messages_addChatUser();
req.chat_id = chat_id; req.chat_id = chat_id;
req.fwd_limit = 50; req.fwd_limit = 50;
TLRPC.User user = MessagesController.Instance.users.get(user_id); TLRPC.User user = users.get(user_id);
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) { if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
req.user_id = new TLRPC.TL_inputUserForeign(); req.user_id = new TLRPC.TL_inputUserForeign();
req.user_id.user_id = user.id; req.user_id.user_id = user.id;
@ -2904,11 +2917,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>(); final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>();
messages.add(res.message); messages.add(res.message);
MessagesStorage.Instance.putMessages(messages, true, true); MessagesStorage.Instance.putMessages(messages, true, true);
if (UserConfig.lastSeqValue + 1 == res.seq) { if (MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else if (UserConfig.lastSeqValue != res.seq) { } else if (MessagesStorage.lastSeqValue != res.seq) {
getDifference(); getDifference();
} }
@ -2954,7 +2967,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void deleteUserFromChat(int chat_id, final int user_id, final TLRPC.ChatParticipants info) { public void deleteUserFromChat(int chat_id, final int user_id, final TLRPC.ChatParticipants info) {
TLRPC.TL_messages_deleteChatUser req = new TLRPC.TL_messages_deleteChatUser(); TLRPC.TL_messages_deleteChatUser req = new TLRPC.TL_messages_deleteChatUser();
req.chat_id = chat_id; req.chat_id = chat_id;
TLRPC.User user = MessagesController.Instance.users.get(user_id); TLRPC.User user = users.get(user_id);
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) { if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
req.user_id = new TLRPC.TL_inputUserForeign(); req.user_id = new TLRPC.TL_inputUserForeign();
req.user_id.user_id = user.id; req.user_id.user_id = user.id;
@ -2978,11 +2991,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
messages.add(res.message); messages.add(res.message);
MessagesStorage.Instance.putMessages(messages, true, true); MessagesStorage.Instance.putMessages(messages, true, true);
} }
if (UserConfig.lastSeqValue + 1 == res.seq) { if (MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else if (UserConfig.lastSeqValue != res.seq) { } else if (MessagesStorage.lastSeqValue != res.seq) {
getDifference(); getDifference();
} }
@ -3042,11 +3055,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>(); final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>();
messages.add(res.message); messages.add(res.message);
MessagesStorage.Instance.putMessages(messages, true, true); MessagesStorage.Instance.putMessages(messages, true, true);
if (UserConfig.lastSeqValue + 1 == res.seq) { if (MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else if (UserConfig.lastSeqValue != res.seq) { } else if (MessagesStorage.lastSeqValue != res.seq) {
getDifference(); getDifference();
} }
@ -3095,11 +3108,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>(); final ArrayList<TLRPC.Message> messages = new ArrayList<TLRPC.Message>();
messages.add(res.message); messages.add(res.message);
MessagesStorage.Instance.putMessages(messages, true, true); MessagesStorage.Instance.putMessages(messages, true, true);
if (UserConfig.lastSeqValue + 1 == res.seq) { if (MessagesStorage.lastSeqValue + 1 == res.seq) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else if (UserConfig.lastSeqValue != res.seq) { } else if (MessagesStorage.lastSeqValue != res.seq) {
getDifference(); getDifference();
} }
@ -3168,7 +3181,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req.device_model = "Android unknown"; req.device_model = "Android unknown";
} }
req.system_version = "SDK " + Build.VERSION.SDK_INT; req.system_version = "SDK " + Build.VERSION.SDK_INT;
PackageInfo pInfo = Utilities.applicationContext.getPackageManager().getPackageInfo(Utilities.applicationContext.getPackageName(), 0); PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
req.app_version = pInfo.versionName; req.app_version = pInfo.versionName;
if (req.app_version == null) { if (req.app_version == null) {
req.app_version = "App version unknown"; req.app_version = "App version unknown";
@ -3186,7 +3199,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
Log.e("tmessages", "registered for push"); Log.e("tmessages", "registered for push");
UserConfig.registeredForPush = true; UserConfig.registeredForPush = true;
UserConfig.pushString = regid; UserConfig.pushString = regid;
UserConfig.saveConfig(); UserConfig.saveConfig(false);
} }
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@Override @Override
@ -3211,11 +3224,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
updatingState = false; updatingState = false;
if (error == null) { if (error == null) {
TLRPC.TL_updates_state res = (TLRPC.TL_updates_state)response; TLRPC.TL_updates_state res = (TLRPC.TL_updates_state)response;
UserConfig.lastDateValue = res.date; MessagesStorage.lastDateValue = res.date;
UserConfig.lastPtsValue = res.pts; MessagesStorage.lastPtsValue = res.pts;
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastQtsValue = res.qts; MessagesStorage.lastQtsValue = res.qts;
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} else { } else {
loadCurrentState(); loadCurrentState();
} }
@ -3225,7 +3238,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void getDifference() { public void getDifference() {
registerForPush(UserConfig.pushString); registerForPush(UserConfig.pushString);
if (UserConfig.lastDateValue == 0) { if (MessagesStorage.lastDateValue == 0) {
loadCurrentState(); loadCurrentState();
return; return;
} }
@ -3238,9 +3251,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
gettingDifference = true; gettingDifference = true;
TLRPC.TL_updates_getDifference req = new TLRPC.TL_updates_getDifference(); TLRPC.TL_updates_getDifference req = new TLRPC.TL_updates_getDifference();
req.pts = UserConfig.lastPtsValue; req.pts = MessagesStorage.lastPtsValue;
req.date = UserConfig.lastDateValue; req.date = MessagesStorage.lastDateValue;
req.qts = UserConfig.lastQtsValue; req.qts = MessagesStorage.lastQtsValue;
if (ConnectionsManager.Instance.connectionState == 0) { if (ConnectionsManager.Instance.connectionState == 0) {
ConnectionsManager.Instance.connectionState = 3; ConnectionsManager.Instance.connectionState = 3;
final int stateCopy = ConnectionsManager.Instance.connectionState; final int stateCopy = ConnectionsManager.Instance.connectionState;
@ -3373,10 +3386,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
if (res instanceof TLRPC.TL_updates_difference) { if (res instanceof TLRPC.TL_updates_difference) {
UserConfig.lastSeqValue = res.state.seq; MessagesStorage.lastSeqValue = res.state.seq;
UserConfig.lastDateValue = res.state.date; MessagesStorage.lastDateValue = res.state.date;
UserConfig.lastPtsValue = res.state.pts; MessagesStorage.lastPtsValue = res.state.pts;
UserConfig.lastQtsValue = res.state.qts; MessagesStorage.lastQtsValue = res.state.qts;
ConnectionsManager.Instance.connectionState = 0; ConnectionsManager.Instance.connectionState = 0;
final int stateCopy = ConnectionsManager.Instance.connectionState; final int stateCopy = ConnectionsManager.Instance.connectionState;
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@ -3386,14 +3399,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
}); });
} else if (res instanceof TLRPC.TL_updates_differenceSlice) { } else if (res instanceof TLRPC.TL_updates_differenceSlice) {
UserConfig.lastSeqValue = res.intermediate_state.seq; MessagesStorage.lastSeqValue = res.intermediate_state.seq;
UserConfig.lastDateValue = res.intermediate_state.date; MessagesStorage.lastDateValue = res.intermediate_state.date;
UserConfig.lastPtsValue = res.intermediate_state.pts; MessagesStorage.lastPtsValue = res.intermediate_state.pts;
UserConfig.lastQtsValue = res.intermediate_state.qts; MessagesStorage.lastQtsValue = res.intermediate_state.qts;
getDifference(); getDifference();
} else if (res instanceof TLRPC.TL_updates_differenceEmpty) { } else if (res instanceof TLRPC.TL_updates_differenceEmpty) {
UserConfig.lastSeqValue = res.seq; MessagesStorage.lastSeqValue = res.seq;
UserConfig.lastDateValue = res.date; MessagesStorage.lastDateValue = res.date;
ConnectionsManager.Instance.connectionState = 0; ConnectionsManager.Instance.connectionState = 0;
final int stateCopy = ConnectionsManager.Instance.connectionState; final int stateCopy = ConnectionsManager.Instance.connectionState;
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@ -3403,14 +3416,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
}); });
} }
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} }
}); });
} }
}); });
if (ConnectionsManager.DEBUG_VERSION) { if (ConnectionsManager.DEBUG_VERSION) {
Log.e("tmessages", "received defference with date = " + UserConfig.lastDateValue + " pts = " + UserConfig.lastPtsValue + " seq = " + UserConfig.lastSeqValue); Log.e("tmessages", "received defference with date = " + MessagesStorage.lastDateValue + " pts = " + MessagesStorage.lastPtsValue + " seq = " + MessagesStorage.lastSeqValue);
Log.e("tmessages", "messages = " + res.new_messages.size() + " users = " + res.users.size() + " chats = " + res.chats.size() + " other updates = " + res.other_updates.size()); Log.e("tmessages", "messages = " + res.new_messages.size() + " users = " + res.users.size() + " chats = " + res.chats.size() + " other updates = " + res.other_updates.size());
} }
} else { } else {
@ -3429,7 +3442,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
arr.add(updates.update); arr.add(updates.update);
processUpdateArray(arr, null, null); processUpdateArray(arr, null, null);
} else if (updates instanceof TLRPC.TL_updateShortChatMessage) { } else if (updates instanceof TLRPC.TL_updateShortChatMessage) {
if (UserConfig.lastSeqValue + 1 == updates.seq && chats.get(updates.chat_id) != null && users.get(updates.from_id) != null) { if (MessagesStorage.lastSeqValue + 1 == updates.seq && chats.get(updates.chat_id) != null && users.get(updates.from_id) != null) {
TLRPC.TL_message message = new TLRPC.TL_message(); TLRPC.TL_message message = new TLRPC.TL_message();
message.from_id = updates.from_id; message.from_id = updates.from_id;
message.id = updates.id; message.id = updates.id;
@ -3439,8 +3452,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
message.date = updates.date; message.date = updates.date;
message.unread = true; message.unread = true;
message.media = new TLRPC.TL_messageMediaEmpty(); message.media = new TLRPC.TL_messageMediaEmpty();
UserConfig.lastSeqValue = updates.seq; MessagesStorage.lastSeqValue = updates.seq;
UserConfig.lastPtsValue = updates.pts; MessagesStorage.lastPtsValue = updates.pts;
final MessageObject obj = new MessageObject(message, null); final MessageObject obj = new MessageObject(message, null);
final ArrayList<MessageObject> objArr = new ArrayList<MessageObject>(); final ArrayList<MessageObject> objArr = new ArrayList<MessageObject>();
objArr.add(obj); objArr.add(obj);
@ -3477,7 +3490,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
needGetDiff = true; needGetDiff = true;
} }
} else if (updates instanceof TLRPC.TL_updateShortMessage) { } else if (updates instanceof TLRPC.TL_updateShortMessage) {
if (UserConfig.lastSeqValue + 1 == updates.seq && users.get(updates.from_id) != null) { if (MessagesStorage.lastSeqValue + 1 == updates.seq && users.get(updates.from_id) != null) {
TLRPC.TL_message message = new TLRPC.TL_message(); TLRPC.TL_message message = new TLRPC.TL_message();
message.from_id = updates.from_id; message.from_id = updates.from_id;
message.id = updates.id; message.id = updates.id;
@ -3487,9 +3500,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
message.date = updates.date; message.date = updates.date;
message.unread = true; message.unread = true;
message.media = new TLRPC.TL_messageMediaEmpty(); message.media = new TLRPC.TL_messageMediaEmpty();
UserConfig.lastSeqValue = updates.seq; MessagesStorage.lastSeqValue = updates.seq;
UserConfig.lastPtsValue = updates.pts; MessagesStorage.lastPtsValue = updates.pts;
UserConfig.lastDateValue = updates.date; MessagesStorage.lastDateValue = updates.date;
final MessageObject obj = new MessageObject(message, null); final MessageObject obj = new MessageObject(message, null);
final ArrayList<MessageObject> objArr = new ArrayList<MessageObject>(); final ArrayList<MessageObject> objArr = new ArrayList<MessageObject>();
objArr.add(obj); objArr.add(obj);
@ -3526,18 +3539,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
needGetDiff = true; needGetDiff = true;
} }
} else if (updates instanceof TLRPC.TL_updatesCombined) { } else if (updates instanceof TLRPC.TL_updatesCombined) {
if (UserConfig.lastSeqValue + 1 == updates.seq_start || updates.seq_start == 0 || UserConfig.lastSeqValue == updates.seq_start) { if (MessagesStorage.lastSeqValue + 1 == updates.seq_start || updates.seq_start == 0 || MessagesStorage.lastSeqValue == updates.seq_start) {
MessagesStorage.Instance.putUsersAndChats(updates.users, updates.chats, true, true); MessagesStorage.Instance.putUsersAndChats(updates.users, updates.chats, true, true);
int lastPtsValue = UserConfig.lastPtsValue; int lastPtsValue = MessagesStorage.lastPtsValue;
int lastQtsValue = UserConfig.lastQtsValue; int lastQtsValue = MessagesStorage.lastQtsValue;
if (!processUpdateArray(updates.updates, updates.users, updates.chats)) { if (!processUpdateArray(updates.updates, updates.users, updates.chats)) {
UserConfig.lastPtsValue = lastPtsValue; MessagesStorage.lastPtsValue = lastPtsValue;
UserConfig.lastQtsValue = lastQtsValue; MessagesStorage.lastQtsValue = lastQtsValue;
needGetDiff = true; needGetDiff = true;
} else { } else {
UserConfig.lastDateValue = updates.date; MessagesStorage.lastDateValue = updates.date;
UserConfig.lastSeqValue = updates.seq; MessagesStorage.lastSeqValue = updates.seq;
if (UserConfig.lastQtsValue != lastQtsValue) { if (MessagesStorage.lastQtsValue != lastQtsValue) {
needReceivedQueue = true; needReceivedQueue = true;
} }
} }
@ -3545,18 +3558,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
needGetDiff = true; needGetDiff = true;
} }
} else if (updates instanceof TLRPC.TL_updates) { } else if (updates instanceof TLRPC.TL_updates) {
if (UserConfig.lastSeqValue + 1 == updates.seq || updates.seq == 0 || updates.seq == UserConfig.lastSeqValue) { if (MessagesStorage.lastSeqValue + 1 == updates.seq || updates.seq == 0 || updates.seq == MessagesStorage.lastSeqValue) {
MessagesStorage.Instance.putUsersAndChats(updates.users, updates.chats, true, true); MessagesStorage.Instance.putUsersAndChats(updates.users, updates.chats, true, true);
int lastPtsValue = UserConfig.lastPtsValue; int lastPtsValue = MessagesStorage.lastPtsValue;
int lastQtsValue = UserConfig.lastQtsValue; int lastQtsValue = MessagesStorage.lastQtsValue;
if (!processUpdateArray(updates.updates, updates.users, updates.chats)) { if (!processUpdateArray(updates.updates, updates.users, updates.chats)) {
needGetDiff = true; needGetDiff = true;
UserConfig.lastPtsValue = lastPtsValue; MessagesStorage.lastPtsValue = lastPtsValue;
UserConfig.lastQtsValue = lastQtsValue; MessagesStorage.lastQtsValue = lastQtsValue;
} else { } else {
UserConfig.lastDateValue = updates.date; MessagesStorage.lastDateValue = updates.date;
UserConfig.lastSeqValue = updates.seq; MessagesStorage.lastSeqValue = updates.seq;
if (UserConfig.lastQtsValue != lastQtsValue) { if (MessagesStorage.lastQtsValue != lastQtsValue) {
needReceivedQueue = true; needReceivedQueue = true;
} }
} }
@ -3571,7 +3584,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
if (needReceivedQueue) { if (needReceivedQueue) {
TLRPC.TL_messages_receivedQueue req = new TLRPC.TL_messages_receivedQueue(); TLRPC.TL_messages_receivedQueue req = new TLRPC.TL_messages_receivedQueue();
req.max_qts = UserConfig.lastQtsValue; req.max_qts = MessagesStorage.lastQtsValue;
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
@ -3579,7 +3592,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
}, null, true, RPCRequest.RPCRequestClassGeneric); }, null, true, RPCRequest.RPCRequestClassGeneric);
} }
UserConfig.saveConfig(); MessagesStorage.Instance.saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
} }
public boolean processUpdateArray(ArrayList<TLRPC.Update> updates, final ArrayList<TLRPC.User> usersArr, final ArrayList<TLRPC.Chat> chatsArr) { public boolean processUpdateArray(ArrayList<TLRPC.Update> updates, final ArrayList<TLRPC.User> usersArr, final ArrayList<TLRPC.Chat> chatsArr) {
@ -3653,7 +3666,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
messages.put(uid, arr); messages.put(uid, arr);
} }
arr.add(obj); arr.add(obj);
UserConfig.lastPtsValue = update.pts; MessagesStorage.lastPtsValue = update.pts;
if (upd.message.from_id != UserConfig.clientUserId && upd.message.to_id != null) { if (upd.message.from_id != UserConfig.clientUserId && upd.message.to_id != null) {
if (uid != openned_dialog_id) { if (uid != openned_dialog_id) {
lastMessage = obj; lastMessage = obj;
@ -3663,12 +3676,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
//can't be here //can't be here
} else if (update instanceof TLRPC.TL_updateReadMessages) { } else if (update instanceof TLRPC.TL_updateReadMessages) {
markAsReadMessages.addAll(update.messages); markAsReadMessages.addAll(update.messages);
UserConfig.lastPtsValue = update.pts; MessagesStorage.lastPtsValue = update.pts;
} else if (update instanceof TLRPC.TL_updateDeleteMessages) { } else if (update instanceof TLRPC.TL_updateDeleteMessages) {
deletedMessages.addAll(update.messages); deletedMessages.addAll(update.messages);
UserConfig.lastPtsValue = update.pts; MessagesStorage.lastPtsValue = update.pts;
} else if (update instanceof TLRPC.TL_updateRestoreMessages) { } else if (update instanceof TLRPC.TL_updateRestoreMessages) {
UserConfig.lastPtsValue = update.pts; MessagesStorage.lastPtsValue = update.pts;
} else if (update instanceof TLRPC.TL_updateUserTyping || update instanceof TLRPC.TL_updateChatUserTyping) { } else if (update instanceof TLRPC.TL_updateUserTyping || update instanceof TLRPC.TL_updateChatUserTyping) {
if (update.user_id != UserConfig.clientUserId) { if (update.user_id != UserConfig.clientUserId) {
long uid = -update.chat_id; long uid = -update.chat_id;
@ -3727,7 +3740,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else if (update instanceof TLRPC.TL_updateNewGeoChatMessage) { } else if (update instanceof TLRPC.TL_updateNewGeoChatMessage) {
//TODO //TODO
} else if (update instanceof TLRPC.TL_updateNewEncryptedMessage) { } else if (update instanceof TLRPC.TL_updateNewEncryptedMessage) {
UserConfig.lastQtsValue = update.qts; MessagesStorage.lastQtsValue = update.qts;
TLRPC.Message message = decryptMessage(((TLRPC.TL_updateNewEncryptedMessage)update).message); TLRPC.Message message = decryptMessage(((TLRPC.TL_updateNewEncryptedMessage)update).message);
if (message != null) { if (message != null) {
int cid = ((TLRPC.TL_updateNewEncryptedMessage)update).message.chat_id; int cid = ((TLRPC.TL_updateNewEncryptedMessage)update).message.chat_id;
@ -3852,7 +3865,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
}); });
MessagesStorage.Instance.putEncryptedChat(newChat, user, dialog); MessagesStorage.Instance.putEncryptedChat(newChat, user, dialog);
MessagesController.Instance.acceptSecretChat(newChat); acceptSecretChat(newChat);
} else if (newChat instanceof TLRPC.TL_encryptedChat) { } else if (newChat instanceof TLRPC.TL_encryptedChat) {
if (existingChat != null && existingChat instanceof TLRPC.TL_encryptedChatWaiting && (existingChat.auth_key == null || existingChat.auth_key.length == 1)) { if (existingChat != null && existingChat instanceof TLRPC.TL_encryptedChatWaiting && (existingChat.auth_key == null || existingChat.auth_key.length == 1)) {
newChat.a_or_b = existingChat.a_or_b; newChat.a_or_b = existingChat.a_or_b;
@ -4101,7 +4114,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
private void showInAppNotification(MessageObject messageObject) { private void showInAppNotification(MessageObject messageObject) {
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
boolean globalEnabled = preferences.getBoolean("EnableAll", true); boolean globalEnabled = preferences.getBoolean("EnableAll", true);
if (!globalEnabled) { if (!globalEnabled) {
return; return;
@ -4157,7 +4170,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
NotificationCenter.Instance.postNotificationName(701, messageObject); NotificationCenter.Instance.postNotificationName(701, messageObject);
} }
if (inAppVibrate) { if (inAppVibrate) {
Vibrator v = (Vibrator)Utilities.applicationContext.getSystemService(Context.VIBRATOR_SERVICE); Vibrator v = (Vibrator)ApplicationLoader.applicationContext.getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(100); v.vibrate(100);
} }
if (inAppSounds) { if (inAppSounds) {
@ -4206,8 +4219,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
String userSoundPath = null; String userSoundPath = null;
String chatSoundPath = null; String chatSoundPath = null;
NotificationManager mNotificationManager = (NotificationManager)Utilities.applicationContext.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager mNotificationManager = (NotificationManager)ApplicationLoader.applicationContext.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(Utilities.applicationContext, LaunchActivity.class); Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
String msg; String msg;
if ((int)dialog_id != 0) { if ((int)dialog_id != 0) {
@ -4219,7 +4232,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
msg = messageObject.messageOwner.message; msg = messageObject.messageOwner.message;
} else { } else {
msg = Utilities.applicationContext.getString(R.string.YouHaveNewMessage); msg = ApplicationLoader.applicationContext.getString(R.string.YouHaveNewMessage);
} }
boolean needVibrate = false; boolean needVibrate = false;
@ -4253,10 +4266,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(Utilities.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(Utilities.applicationContext) NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ApplicationLoader.applicationContext)
.setContentTitle(Utilities.applicationContext.getString(R.string.AppName)) .setContentTitle(ApplicationLoader.applicationContext.getString(R.string.AppName))
.setSmallIcon(R.drawable.notification) .setSmallIcon(R.drawable.notification)
.setStyle(new NotificationCompat.BigTextStyle() .setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg)) .bigText(msg))
@ -4486,7 +4499,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void processAcceptedSecretChat(final TLRPC.EncryptedChat encryptedChat) { public void processAcceptedSecretChat(final TLRPC.EncryptedChat encryptedChat) {
BigInteger i_authKey = new BigInteger(1, encryptedChat.g_a_or_b); BigInteger i_authKey = new BigInteger(1, encryptedChat.g_a_or_b);
i_authKey = i_authKey.modPow(new BigInteger(1, encryptedChat.a_or_b), new BigInteger(1, UserConfig.secretPBytes)); i_authKey = i_authKey.modPow(new BigInteger(1, encryptedChat.a_or_b), new BigInteger(1, MessagesStorage.secretPBytes));
byte[] authKey = i_authKey.toByteArray(); byte[] authKey = i_authKey.toByteArray();
if (authKey.length > 256) { if (authKey.length > 256) {
@ -4553,25 +4566,25 @@ public class MessagesController implements NotificationCenter.NotificationCenter
acceptingChats.put(encryptedChat.id, encryptedChat); acceptingChats.put(encryptedChat.id, encryptedChat);
TLRPC.TL_messages_getDhConfig req = new TLRPC.TL_messages_getDhConfig(); TLRPC.TL_messages_getDhConfig req = new TLRPC.TL_messages_getDhConfig();
req.random_length = 256; req.random_length = 256;
req.version = UserConfig.lastSecretVersion; req.version = MessagesStorage.lastSecretVersion;
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) { if (error == null) {
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response; TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
if (response instanceof TLRPC.TL_messages_dhConfig) { if (response instanceof TLRPC.TL_messages_dhConfig) {
UserConfig.secretPBytes = res.p; MessagesStorage.secretPBytes = res.p;
UserConfig.secretG = res.g; MessagesStorage.secretG = res.g;
UserConfig.lastSecretVersion = res.version; MessagesStorage.lastSecretVersion = res.version;
UserConfig.saveConfig(); MessagesStorage.Instance.saveSecretParams(MessagesStorage.lastSecretVersion, MessagesStorage.secretG, MessagesStorage.secretPBytes);
} }
byte[] salt = new byte[256]; byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) { for (int a = 0; a < 256; a++) {
salt[a] = (byte)((byte)(random.nextDouble() * 255) ^ res.random[a]); salt[a] = (byte)((byte)(random.nextDouble() * 255) ^ res.random[a]);
} }
encryptedChat.a_or_b = salt; encryptedChat.a_or_b = salt;
BigInteger i_g_b = BigInteger.valueOf(UserConfig.secretG); BigInteger i_g_b = BigInteger.valueOf(MessagesStorage.secretG);
i_g_b = i_g_b.modPow(new BigInteger(1, salt), new BigInteger(1, UserConfig.secretPBytes)); i_g_b = i_g_b.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes));
byte[] g_b = i_g_b.toByteArray(); byte[] g_b = i_g_b.toByteArray();
if (g_b.length > 256) { if (g_b.length > 256) {
byte[] correctedAuth = new byte[256]; byte[] correctedAuth = new byte[256];
@ -4580,7 +4593,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
BigInteger i_authKey = new BigInteger(1, encryptedChat.g_a); BigInteger i_authKey = new BigInteger(1, encryptedChat.g_a);
i_authKey = i_authKey.modPow(new BigInteger(1, salt), new BigInteger(1, UserConfig.secretPBytes)); i_authKey = i_authKey.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes));
byte[] authKey = i_authKey.toByteArray(); byte[] authKey = i_authKey.toByteArray();
if (authKey.length > 256) { if (authKey.length > 256) {
@ -4643,24 +4656,24 @@ public class MessagesController implements NotificationCenter.NotificationCenter
progressDialog.show(); progressDialog.show();
TLRPC.TL_messages_getDhConfig req = new TLRPC.TL_messages_getDhConfig(); TLRPC.TL_messages_getDhConfig req = new TLRPC.TL_messages_getDhConfig();
req.random_length = 256; req.random_length = 256;
req.version = UserConfig.lastSecretVersion; req.version = MessagesStorage.lastSecretVersion;
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) { if (error == null) {
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response; TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
if (response instanceof TLRPC.TL_messages_dhConfig) { if (response instanceof TLRPC.TL_messages_dhConfig) {
UserConfig.secretPBytes = res.p; MessagesStorage.secretPBytes = res.p;
UserConfig.secretG = res.g; MessagesStorage.secretG = res.g;
UserConfig.lastSecretVersion = res.version; MessagesStorage.lastSecretVersion = res.version;
UserConfig.saveConfig(); MessagesStorage.Instance.saveSecretParams(MessagesStorage.lastSecretVersion, MessagesStorage.secretG, MessagesStorage.secretPBytes);
} }
final byte[] salt = new byte[256]; final byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) { for (int a = 0; a < 256; a++) {
salt[a] = (byte)((byte)(random.nextDouble() * 255) ^ res.random[a]); salt[a] = (byte)((byte)(random.nextDouble() * 255) ^ res.random[a]);
} }
BigInteger i_g_a = BigInteger.valueOf(UserConfig.secretG); BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.secretG);
i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, UserConfig.secretPBytes)); i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes));
byte[] g_a = i_g_a.toByteArray(); byte[] g_a = i_g_a.toByteArray();
if (g_a.length > 256) { if (g_a.length > 256) {
byte[] correctedAuth = new byte[256]; byte[] correctedAuth = new byte[256];
@ -4668,7 +4681,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
g_a = correctedAuth; g_a = correctedAuth;
} }
final TLRPC.User user = MessagesController.Instance.users.get(user_id); final TLRPC.User user = users.get(user_id);
TLRPC.InputUser inputUser; TLRPC.InputUser inputUser;
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) { if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
inputUser = new TLRPC.TL_inputUserForeign(); inputUser = new TLRPC.TL_inputUserForeign();
@ -4735,7 +4748,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.AppName)); builder.setTitle(context.getString(R.string.AppName));
builder.setMessage(String.format(context.getString(R.string.CreateEncryptedChatOutdatedError), user.first_name, user.first_name)); builder.setMessage(String.format(context.getString(R.string.CreateEncryptedChatOutdatedError), user.first_name, user.first_name));
builder.setPositiveButton(Utilities.applicationContext.getString(R.string.OK), null); builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), null);
builder.show().setCanceledOnTouchOutside(true); builder.show().setCanceledOnTouchOutside(true);
} }
} }

View File

@ -17,6 +17,7 @@ import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.TL.TLClassStore; import org.telegram.TL.TLClassStore;
import org.telegram.TL.TLObject; import org.telegram.TL.TLObject;
import org.telegram.TL.TLRPC; import org.telegram.TL.TLRPC;
import org.telegram.ui.ApplicationLoader;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -28,6 +29,13 @@ public class MessagesStorage {
public DispatchQueue storageQueue = new DispatchQueue("storageQueue"); public DispatchQueue storageQueue = new DispatchQueue("storageQueue");
private SQLiteDatabase database; private SQLiteDatabase database;
private File cacheFile; private File cacheFile;
public static int lastDateValue = 0;
public static int lastPtsValue = 0;
public static int lastQtsValue = 0;
public static int lastSeqValue = 0;
public static int lastSecretVersion = 0;
public static byte[] secretPBytes = null;
public static int secretG = 0;
public static final int wallpapersDidLoaded = 171; public static final int wallpapersDidLoaded = 171;
public static MessagesStorage Instance = new MessagesStorage(); public static MessagesStorage Instance = new MessagesStorage();
@ -38,7 +46,7 @@ public class MessagesStorage {
} }
public void openDatabase() { public void openDatabase() {
cacheFile = new File(Utilities.applicationContext.getFilesDir(), "cache4.db"); cacheFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "cache4.db");
boolean createTable = false; boolean createTable = false;
//cacheFile.delete(); //cacheFile.delete();
if (!cacheFile.exists()) { if (!cacheFile.exists()) {
@ -60,6 +68,8 @@ public class MessagesStorage {
database.executeFast("CREATE TABLE wallpapers(uid INTEGER PRIMARY KEY, data BLOB)").stepThis().dispose(); database.executeFast("CREATE TABLE wallpapers(uid INTEGER PRIMARY KEY, data BLOB)").stepThis().dispose();
database.executeFast("CREATE TABLE randoms(random_id INTEGER PRIMARY KEY, mid INTEGER)").stepThis().dispose(); database.executeFast("CREATE TABLE randoms(random_id INTEGER PRIMARY KEY, mid INTEGER)").stepThis().dispose();
database.executeFast("CREATE TABLE enc_tasks(date INTEGER, data BLOB)").stepThis().dispose(); database.executeFast("CREATE TABLE enc_tasks(date INTEGER, data BLOB)").stepThis().dispose();
database.executeFast("CREATE TABLE params(id INTEGER PRIMARY KEY, seq INTEGER, pts INTEGER, date INTEGER, qts INTEGER, lsv INTEGER, sg INTEGER, pbytes BLOB)").stepThis().dispose();
database.executeFast("INSERT INTO params VALUES(1, 0, 0, 0, 0, 0, 0, NULL)").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS date_idx_dialogs ON dialogs(date);").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS date_idx_dialogs ON dialogs(date);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS date_idx_enc_tasks ON enc_tasks(date);").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS date_idx_enc_tasks ON enc_tasks(date);").stepThis().dispose();
@ -69,6 +79,41 @@ public class MessagesStorage {
database.executeFast("CREATE INDEX IF NOT EXISTS uid_mid_idx_media ON media(uid, mid);").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS uid_mid_idx_media ON media(uid, mid);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS ttl_idx_messages ON messages(ttl);").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS ttl_idx_messages ON messages(ttl);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS read_state_out_idx_messages ON messages(read_state, out);").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS read_state_out_idx_messages ON messages(read_state, out);").stepThis().dispose();
} else {
SQLiteCursor cursor = database.queryFinalized("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='params'");
boolean create = false;
if (cursor.next()) {
int count = cursor.intValue(0);
if (count == 0) {
create = true;
}
} else {
create = true;
}
cursor.dispose();
if (create) {
database.executeFast("CREATE TABLE params(id INTEGER PRIMARY KEY, seq INTEGER, pts INTEGER, date INTEGER, qts INTEGER, lsv INTEGER, sg INTEGER, pbytes BLOB)").stepThis().dispose();
database.executeFast("INSERT INTO params VALUES(1, 0, 0, 0, 0, 0, 0, NULL)").stepThis().dispose();
} else {
cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1");
if (cursor.next()) {
lastSeqValue = cursor.intValue(0);
lastPtsValue = cursor.intValue(1);
lastDateValue = cursor.intValue(2);
lastQtsValue = cursor.intValue(3);
lastSecretVersion = cursor.intValue(4);
secretG = cursor.intValue(5);
if (cursor.isNull(6)) {
secretPBytes = null;
} else {
secretPBytes = cursor.byteArrayValue(6);
if (secretPBytes != null && secretPBytes.length == 1) {
secretPBytes = null;
}
}
}
cursor.dispose();
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -79,6 +124,13 @@ public class MessagesStorage {
storageQueue.postRunnable(new Runnable() { storageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
lastDateValue = 0;
lastSeqValue = 0;
lastPtsValue = 0;
lastQtsValue = 0;
lastSecretVersion = 0;
secretPBytes = null;
secretG = 0;
if (database != null) { if (database != null) {
database.close(); database.close();
database = null; database = null;
@ -88,15 +140,15 @@ public class MessagesStorage {
cacheFile = null; cacheFile = null;
} }
try { try {
File old = new File(Utilities.applicationContext.getFilesDir(), "cache.db"); File old = new File(ApplicationLoader.applicationContext.getFilesDir(), "cache.db");
if (old.exists()) { if (old.exists()) {
old.delete(); old.delete();
} }
old = new File(Utilities.applicationContext.getFilesDir(), "cache2.db"); old = new File(ApplicationLoader.applicationContext.getFilesDir(), "cache2.db");
if (old.exists()) { if (old.exists()) {
old.delete(); old.delete();
} }
old = new File(Utilities.applicationContext.getFilesDir(), "cache3.db"); old = new File(ApplicationLoader.applicationContext.getFilesDir(), "cache3.db");
if (old.exists()) { if (old.exists()) {
old.delete(); old.delete();
} }
@ -108,6 +160,47 @@ public class MessagesStorage {
}); });
} }
public void saveSecretParams(final int lsv, final int sg, final byte[] pbytes) {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
SQLitePreparedStatement state = database.executeFast("UPDATE params SET lsv = ?, sg = ?, pbytes = ? WHERE id = 1");
state.bindInteger(1, lsv);
state.bindInteger(2, sg);
if (pbytes != null) {
state.bindByteArray(3, pbytes);
} else {
state.bindByteArray(3, new byte[1]);
}
state.step();
state.dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void saveDiffParams(final int seq, final int pts, final int date, final int qts) {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
SQLitePreparedStatement state = database.executeFast("UPDATE params SET seq = ?, pts = ?, date = ?, qts = ? WHERE id = 1");
state.bindInteger(1, seq);
state.bindInteger(2, pts);
state.bindInteger(3, date);
state.bindInteger(4, qts);
state.step();
state.dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void putWallpapers(final ArrayList<TLRPC.WallPaper> wallPapers) { public void putWallpapers(final ArrayList<TLRPC.WallPaper> wallPapers) {
storageQueue.postRunnable(new Runnable() { storageQueue.postRunnable(new Runnable() {
@Override @Override

View File

@ -8,8 +8,12 @@
package org.telegram.messenger; package org.telegram.messenger;
import android.content.Context;
import android.content.SharedPreferences;
import org.telegram.TL.TLClassStore; import org.telegram.TL.TLClassStore;
import org.telegram.TL.TLRPC; import org.telegram.TL.TLRPC;
import org.telegram.ui.ApplicationLoader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -18,17 +22,10 @@ public class UserConfig {
public static TLRPC.User currentUser; public static TLRPC.User currentUser;
public static int clientUserId = 0; public static int clientUserId = 0;
public static boolean clientActivated = false; public static boolean clientActivated = false;
public static int lastDateValue = 0;
public static int lastPtsValue = 0;
public static int lastQtsValue = 0;
public static int lastSeqValue = 0;
public static boolean registeredForPush = false; public static boolean registeredForPush = false;
public static String pushString = ""; public static String pushString = "";
public static int lastSendMessageId = -1; public static int lastSendMessageId = -1;
public static int lastLocalId = -1; public static int lastLocalId = -1;
public static int lastSecretVersion = 0;
public static byte[] secretPBytes = null;
public static int secretG = 0;
public static String contactsHash = ""; public static String contactsHash = "";
public static String importHash = ""; public static String importHash = "";
private final static Integer sync = 1; private final static Integer sync = 1;
@ -43,64 +40,58 @@ public class UserConfig {
return id; return id;
} }
public static void saveConfig() { public static void saveConfig(boolean withFile) {
synchronized (sync) { synchronized (sync) {
SerializedData data = new SerializedData(); SerializedData data = new SerializedData();
if (currentUser != null) { if (currentUser != null) {
data.writeInt32(1); data.writeInt32(2);
currentUser.serializeToStream(data); currentUser.serializeToStream(data);
clientUserId = currentUser.id; clientUserId = currentUser.id;
clientActivated = true; clientActivated = true;
data.writeInt32(lastDateValue); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
data.writeInt32(lastPtsValue); SharedPreferences.Editor editor = preferences.edit();
data.writeInt32(lastSeqValue); editor.putBoolean("registeredForPush", registeredForPush);
data.writeBool(registeredForPush); editor.putString("pushString", pushString);
data.writeString(pushString); editor.putInt("lastSendMessageId", lastSendMessageId);
data.writeInt32(lastSendMessageId); editor.putInt("lastLocalId", lastLocalId);
data.writeInt32(lastLocalId); editor.putString("contactsHash", contactsHash);
data.writeString(contactsHash); editor.putString("importHash", importHash);
data.writeString(importHash); editor.putBoolean("saveIncomingPhotos", saveIncomingPhotos);
data.writeBool(saveIncomingPhotos); editor.commit();
data.writeInt32(lastQtsValue);
data.writeInt32(lastSecretVersion);
if (secretPBytes != null) {
data.writeInt32(1);
data.writeByteArray(secretPBytes);
} else {
data.writeInt32(0);
}
data.writeInt32(secretG);
} else { } else {
data.writeInt32(0); data.writeInt32(0);
} }
try { if (withFile) {
File configFile = new File(Utilities.applicationContext.getFilesDir(), "user.dat"); try {
if (!configFile.exists()) { File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "user.dat");
configFile.createNewFile(); if (!configFile.exists()) {
configFile.createNewFile();
}
FileOutputStream stream = new FileOutputStream(configFile);
stream.write(data.toByteArray());
stream.close();
} catch (Exception e) {
e.printStackTrace();
} }
FileOutputStream stream = new FileOutputStream(configFile);
stream.write(data.toByteArray());
stream.close();
} catch (Exception e) {
e.printStackTrace();
} }
} }
} }
public static void loadConfig() { public static void loadConfig() {
synchronized (sync) { synchronized (sync) {
File configFile = new File(Utilities.applicationContext.getFilesDir(), "user.dat"); File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "user.dat");
if (configFile.exists()) { if (configFile.exists()) {
try { try {
SerializedData data = new SerializedData(configFile); SerializedData data = new SerializedData(configFile);
if (data.readInt32() != 0) { int ver = data.readInt32();
if (ver == 1) {
int constructor = data.readInt32(); int constructor = data.readInt32();
currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, constructor); currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, constructor);
clientUserId = currentUser.id; clientUserId = currentUser.id;
clientActivated = true; clientActivated = true;
lastDateValue = data.readInt32(); MessagesStorage.lastDateValue = data.readInt32();
lastPtsValue = data.readInt32(); MessagesStorage.lastPtsValue = data.readInt32();
lastSeqValue = data.readInt32(); MessagesStorage.lastSeqValue = data.readInt32();
registeredForPush = data.readBool(); registeredForPush = data.readBool();
pushString = data.readString(); pushString = data.readString();
lastSendMessageId = data.readInt32(); lastSendMessageId = data.readInt32();
@ -115,13 +106,27 @@ public class UserConfig {
currentUser.status.expires = currentUser.status.was_online; currentUser.status.expires = currentUser.status.was_online;
} }
} }
lastQtsValue = data.readInt32(); MessagesStorage.lastQtsValue = data.readInt32();
lastSecretVersion = data.readInt32(); MessagesStorage.lastSecretVersion = data.readInt32();
int val = data.readInt32(); int val = data.readInt32();
if (val == 1) { if (val == 1) {
secretPBytes = data.readByteArray(); MessagesStorage.secretPBytes = data.readByteArray();
} }
secretG = data.readInt32(); MessagesStorage.secretG = data.readInt32();
} else if (ver == 2) {
int constructor = data.readInt32();
currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, constructor);
clientUserId = currentUser.id;
clientActivated = true;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
registeredForPush = preferences.getBoolean("registeredForPush", false);
pushString = preferences.getString("pushString", "");
lastSendMessageId = preferences.getInt("lastSendMessageId", -1);
lastLocalId = preferences.getInt("lastLocalId", -1);
contactsHash = preferences.getString("contactsHash", "");
importHash = preferences.getString("importHash", "");
saveIncomingPhotos = preferences.getBoolean("saveIncomingPhotos", false);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -134,15 +139,12 @@ public class UserConfig {
clientUserId = 0; clientUserId = 0;
clientActivated = false; clientActivated = false;
currentUser = null; currentUser = null;
lastDateValue = 0;
lastSeqValue = 0;
lastPtsValue = 0;
registeredForPush = false; registeredForPush = false;
contactsHash = ""; contactsHash = "";
lastLocalId = -1; lastLocalId = -1;
importHash = ""; importHash = "";
lastSendMessageId = -1; lastSendMessageId = -1;
saveIncomingPhotos = false; saveIncomingPhotos = false;
saveConfig(); saveConfig(true);
} }
} }

View File

@ -18,6 +18,7 @@ import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.text.Html; import android.text.Html;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.format.DateFormat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -25,6 +26,7 @@ import android.view.inputmethod.InputMethodManager;
import org.telegram.TL.TLClassStore; import org.telegram.TL.TLClassStore;
import org.telegram.TL.TLObject; import org.telegram.TL.TLObject;
import org.telegram.ui.ApplicationLoader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -50,7 +52,6 @@ import java.util.zip.GZIPInputStream;
import javax.crypto.Cipher; import javax.crypto.Cipher;
public class Utilities { public class Utilities {
public static Context applicationContext;
public static Handler applicationHandler; public static Handler applicationHandler;
private final static Integer lock = 1; private final static Integer lock = 1;
@ -77,10 +78,10 @@ public class Utilities {
public static File getCacheDir() { public static File getCacheDir() {
if (externalCacheNotAvailableState == 1 || externalCacheNotAvailableState == 0 && Environment.getExternalStorageState().startsWith(Environment.MEDIA_MOUNTED)) { if (externalCacheNotAvailableState == 1 || externalCacheNotAvailableState == 0 && Environment.getExternalStorageState().startsWith(Environment.MEDIA_MOUNTED)) {
externalCacheNotAvailableState = 1; externalCacheNotAvailableState = 1;
return applicationContext.getExternalCacheDir(); return ApplicationLoader.applicationContext.getExternalCacheDir();
} }
externalCacheNotAvailableState = 2; externalCacheNotAvailableState = 2;
return applicationContext.getCacheDir(); return ApplicationLoader.applicationContext.getCacheDir();
} }
public static TPFactorizedValue getFactorizedValue(long what) { public static TPFactorizedValue getFactorizedValue(long what) {
@ -230,7 +231,7 @@ public class Utilities {
synchronized (cache) { synchronized (cache) {
if (!cache.containsKey(assetPath)) { if (!cache.containsKey(assetPath)) {
try { try {
Typeface t = Typeface.createFromAsset(applicationContext.getAssets(), Typeface t = Typeface.createFromAsset(ApplicationLoader.applicationContext.getAssets(),
assetPath); assetPath);
cache.put(assetPath, t); cache.put(assetPath, t);
} catch (Exception e) { } catch (Exception e) {
@ -304,11 +305,19 @@ public class Utilities {
formatterYearMax = FastDateFormat.getInstance("dd.MM.yyyy", locale); formatterYearMax = FastDateFormat.getInstance("dd.MM.yyyy", locale);
chatDate = FastDateFormat.getInstance("d MMMM", locale); chatDate = FastDateFormat.getInstance("d MMMM", locale);
chatFullDate = FastDateFormat.getInstance("d MMMM yyyy", locale); chatFullDate = FastDateFormat.getInstance("d MMMM yyyy", locale);
if (lang != null && lang.toLowerCase().equals("ar")) { if (lang != null) {
formatterDay = FastDateFormat.getInstance("h:mm a", locale); if (DateFormat.is24HourFormat(ApplicationLoader.applicationContext)) {
formatterDay = FastDateFormat.getInstance("HH:mm", locale);
} else {
if (lang.toLowerCase().equals("ar")) {
formatterDay = FastDateFormat.getInstance("h:mm a", locale);
} else {
formatterDay = FastDateFormat.getInstance("h:mm a", Locale.US);
}
}
} else { } else {
formatterDay = FastDateFormat.getInstance("h:mm a", Locale.US);} formatterDay = FastDateFormat.getInstance("h:mm a", Locale.US);
}
} }
public static String formatDateChat(long date) { public static String formatDateChat(long date) {
@ -335,7 +344,7 @@ public class Utilities {
if (dateDay == day && year == dateYear) { if (dateDay == day && year == dateYear) {
return formatterDay.format(new Date(date * 1000)); return formatterDay.format(new Date(date * 1000));
} else if (dateDay + 1 == day && year == dateYear) { } else if (dateDay + 1 == day && year == dateYear) {
return applicationContext.getResources().getString(R.string.Yesterday); return ApplicationLoader.applicationContext.getResources().getString(R.string.Yesterday);
} else if (year == dateYear) { } else if (year == dateYear) {
return formatterMonth.format(new Date(date * 1000)); return formatterMonth.format(new Date(date * 1000));
} else { } else {
@ -352,13 +361,13 @@ public class Utilities {
int dateYear = rightNow.get(Calendar.YEAR); int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) { if (dateDay == day && year == dateYear) {
return String.format("%s %s", applicationContext.getResources().getString(R.string.TodayAt), formatterDay.format(new Date(date * 1000))); return String.format("%s %s", ApplicationLoader.applicationContext.getResources().getString(R.string.TodayAt), formatterDay.format(new Date(date * 1000)));
} else if (dateDay + 1 == day && year == dateYear) { } else if (dateDay + 1 == day && year == dateYear) {
return String.format("%s %s", applicationContext.getResources().getString(R.string.YesterdayAt), formatterDay.format(new Date(date * 1000))); return String.format("%s %s", ApplicationLoader.applicationContext.getResources().getString(R.string.YesterdayAt), formatterDay.format(new Date(date * 1000)));
} else if (year == dateYear) { } else if (year == dateYear) {
return String.format("%s %s %s", formatterMonth.format(new Date(date * 1000)), applicationContext.getResources().getString(R.string.OtherAt), formatterDay.format(new Date(date * 1000))); return String.format("%s %s %s", formatterMonth.format(new Date(date * 1000)), ApplicationLoader.applicationContext.getResources().getString(R.string.OtherAt), formatterDay.format(new Date(date * 1000)));
} else { } else {
return String.format("%s %s %s", formatterYear.format(new Date(date * 1000)), applicationContext.getResources().getString(R.string.OtherAt), formatterDay.format(new Date(date * 1000))); return String.format("%s %s %s", formatterYear.format(new Date(date * 1000)), ApplicationLoader.applicationContext.getResources().getString(R.string.OtherAt), formatterDay.format(new Date(date * 1000)));
} }
} }
@ -401,7 +410,7 @@ public class Utilities {
public static void RunOnUIThread(Runnable runnable) { public static void RunOnUIThread(Runnable runnable) {
synchronized (lock) { synchronized (lock) {
if (applicationHandler == null) { if (applicationHandler == null) {
applicationHandler = new Handler(applicationContext.getMainLooper()); applicationHandler = new Handler(ApplicationLoader.applicationContext.getMainLooper());
} }
applicationHandler.post(runnable); applicationHandler.post(runnable);
} }
@ -419,18 +428,25 @@ public class Utilities {
R.drawable.user_placeholder_orange}; R.drawable.user_placeholder_orange};
public static int[] arrGroupsAvatars = { public static int[] arrGroupsAvatars = {
R.drawable.group_placeholder_red,
R.drawable.group_placeholder_green, R.drawable.group_placeholder_green,
R.drawable.group_placeholder_yellow, R.drawable.group_placeholder_red,
R.drawable.group_placeholder_blue, R.drawable.group_placeholder_blue,
R.drawable.group_placeholder_purple, R.drawable.group_placeholder_yellow};
R.drawable.group_placeholder_pink,
R.drawable.group_placeholder_cyan,
R.drawable.group_placeholder_orange};
public static int getColorIndex(int id) { public static int getColorIndex(int id) {
int[] arr;
if (id >= 0) {
arr = arrUsersAvatars;
} else {
arr = arrGroupsAvatars;
}
try { try {
String str = String.format(Locale.US, "%d%d", id, UserConfig.clientUserId); String str;
if (id >= 0) {
str = String.format(Locale.US, "%d%d", id, UserConfig.clientUserId);
} else {
str = String.format(Locale.US, "%d", id);
}
if (str.length() > 15) { if (str.length() > 15) {
str = str.substring(0, 15); str = str.substring(0, 15);
} }
@ -440,11 +456,11 @@ public class Utilities {
if (b < 0) { if (b < 0) {
b += 256; b += 256;
} }
return Math.abs(b) % arrColors.length; return Math.abs(b) % arr.length;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return id % arrColors.length; return id % arr.length;
} }
public static int getColorForId(int id) { public static int getColorForId(int id) {
@ -462,7 +478,7 @@ public class Utilities {
} }
public static int getGroupAvatarForId(int id) { public static int getGroupAvatarForId(int id) {
return arrGroupsAvatars[getColorIndex(id)]; return arrGroupsAvatars[getColorIndex(-id)];
} }
public static String MD5(String md5) { public static String MD5(String md5) {
@ -488,7 +504,7 @@ public class Utilities {
File f = new File(fromPath); File f = new File(fromPath);
Uri contentUri = Uri.fromFile(f); Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri); mediaScanIntent.setData(contentUri);
applicationContext.sendBroadcast(mediaScanIntent); ApplicationLoader.applicationContext.sendBroadcast(mediaScanIntent);
} }
public static void addMediaToGallery(Uri uri) { public static void addMediaToGallery(Uri uri) {
@ -497,13 +513,13 @@ public class Utilities {
} }
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
mediaScanIntent.setData(uri); mediaScanIntent.setData(uri);
applicationContext.sendBroadcast(mediaScanIntent); ApplicationLoader.applicationContext.sendBroadcast(mediaScanIntent);
} }
private static File getAlbumDir() { private static File getAlbumDir() {
File storageDir = null; File storageDir = null;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), applicationContext.getResources().getString(R.string.AppName)); storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), ApplicationLoader.applicationContext.getResources().getString(R.string.AppName));
if (storageDir != null) { if (storageDir != null) {
if (! storageDir.mkdirs()) { if (! storageDir.mkdirs()) {
if (! storageDir.exists()){ if (! storageDir.exists()){
@ -578,7 +594,7 @@ public class Utilities {
/* /*
String fileName = "VID" + id + ".mp4"; String fileName = "VID" + id + ".mp4";
return new File(Utilities.applicationContext.getCacheDir(), fileName); return new File(ApplicationLoader.applicationContext.getCacheDir(), fileName);
*/ */
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -16,6 +16,7 @@ import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,57 +43,57 @@ public class MessageObject {
fromUser = MessagesController.Instance.users.get(message.from_id); fromUser = MessagesController.Instance.users.get(message.from_id);
} }
if (message.action instanceof TLRPC.TL_messageActionChatCreate) { if (message.action instanceof TLRPC.TL_messageActionChatCreate) {
messageText = Utilities.applicationContext.getResources().getString(R.string.ActionCreateGroup).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.ActionCreateGroup).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} else if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) { } else if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
if (message.action.user_id == message.from_id) { if (message.action.user_id == message.from_id) {
messageText = Utilities.applicationContext.getResources().getString(R.string.ActionLeftUser).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.ActionLeftUser).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} else { } else {
TLRPC.User who = users.get(message.action.user_id); TLRPC.User who = users.get(message.action.user_id);
String str = Utilities.applicationContext.getResources().getString(R.string.ActionKickUser); String str = ApplicationLoader.applicationContext.getResources().getString(R.string.ActionKickUser);
messageText = str.replace("un2", Utilities.formatName(who.first_name, who.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = str.replace("un2", Utilities.formatName(who.first_name, who.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} }
} else if (message.action instanceof TLRPC.TL_messageActionChatAddUser) { } else if (message.action instanceof TLRPC.TL_messageActionChatAddUser) {
TLRPC.User whoUser = users.get(message.action.user_id); TLRPC.User whoUser = users.get(message.action.user_id);
String str = Utilities.applicationContext.getResources().getString(R.string.ActionAddUser); String str = ApplicationLoader.applicationContext.getResources().getString(R.string.ActionAddUser);
messageText = str.replace("un2", Utilities.formatName(whoUser.first_name, whoUser.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = str.replace("un2", Utilities.formatName(whoUser.first_name, whoUser.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto) { } else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto) {
photoThumbs = new ArrayList<PhotoObject>(); photoThumbs = new ArrayList<PhotoObject>();
for (TLRPC.PhotoSize size : message.action.photo.sizes) { for (TLRPC.PhotoSize size : message.action.photo.sizes) {
photoThumbs.add(new PhotoObject(size)); photoThumbs.add(new PhotoObject(size));
} }
messageText = Utilities.applicationContext.getResources().getString(R.string.ActionChangedPhoto).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.ActionChangedPhoto).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} else if (message.action instanceof TLRPC.TL_messageActionChatEditTitle) { } else if (message.action instanceof TLRPC.TL_messageActionChatEditTitle) {
messageText = Utilities.applicationContext.getResources().getString(R.string.ActionChangedTitle).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)).replace("un2", message.action.title); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.ActionChangedTitle).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)).replace("un2", message.action.title);
} else if (message.action instanceof TLRPC.TL_messageActionChatDeletePhoto) { } else if (message.action instanceof TLRPC.TL_messageActionChatDeletePhoto) {
messageText = Utilities.applicationContext.getResources().getString(R.string.ActionRemovedPhoto).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.ActionRemovedPhoto).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} else if (message.action instanceof TLRPC.TL_messageActionTTLChange) { } else if (message.action instanceof TLRPC.TL_messageActionTTLChange) {
if (message.action.ttl != 0) { if (message.action.ttl != 0) {
String timeString; String timeString;
if (message.action.ttl == 2) { if (message.action.ttl == 2) {
timeString = Utilities.applicationContext.getResources().getString(R.string.MessageLifetime2s); timeString = ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetime2s);
} else if (message.action.ttl == 5) { } else if (message.action.ttl == 5) {
timeString = Utilities.applicationContext.getResources().getString(R.string.MessageLifetime5s); timeString = ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetime5s);
} else if (message.action.ttl == 60) { } else if (message.action.ttl == 60) {
timeString = Utilities.applicationContext.getResources().getString(R.string.MessageLifetime1m); timeString = ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetime1m);
} else if (message.action.ttl == 60 * 60) { } else if (message.action.ttl == 60 * 60) {
timeString = Utilities.applicationContext.getResources().getString(R.string.MessageLifetime1h); timeString = ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetime1h);
} else if (message.action.ttl == 60 * 60 * 24) { } else if (message.action.ttl == 60 * 60 * 24) {
timeString = Utilities.applicationContext.getResources().getString(R.string.MessageLifetime1d); timeString = ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetime1d);
} else if (message.action.ttl == 60 * 60 * 24 * 7) { } else if (message.action.ttl == 60 * 60 * 24 * 7) {
timeString = Utilities.applicationContext.getResources().getString(R.string.MessageLifetime1w); timeString = ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetime1w);
} else { } else {
timeString = String.format("%d", message.action.ttl); timeString = String.format("%d", message.action.ttl);
} }
if (message.from_id == UserConfig.clientUserId) { if (message.from_id == UserConfig.clientUserId) {
messageText = String.format(Utilities.applicationContext.getResources().getString(R.string.MessageLifetimeChangedOutgoing), timeString); messageText = String.format(ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetimeChangedOutgoing), timeString);
} else { } else {
messageText = String.format(Utilities.applicationContext.getResources().getString(R.string.MessageLifetimeChanged), fromUser.first_name, timeString); messageText = String.format(ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetimeChanged), fromUser.first_name, timeString);
} }
} else { } else {
if (message.from_id == UserConfig.clientUserId) { if (message.from_id == UserConfig.clientUserId) {
messageText = String.format(Utilities.applicationContext.getResources().getString(R.string.MessageLifetimeRemoved), Utilities.applicationContext.getResources().getString(R.string.FromYou)); messageText = String.format(ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetimeRemoved), ApplicationLoader.applicationContext.getResources().getString(R.string.FromYou));
} else { } else {
messageText = String.format(Utilities.applicationContext.getResources().getString(R.string.MessageLifetimeRemoved), fromUser.first_name); messageText = String.format(ApplicationLoader.applicationContext.getResources().getString(R.string.MessageLifetimeRemoved), fromUser.first_name);
} }
} }
} }
@ -107,7 +108,7 @@ public class MessageObject {
imagePreview = obj.image; imagePreview = obj.image;
} }
} }
messageText = Utilities.applicationContext.getResources().getString(R.string.AttachPhoto); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.AttachPhoto);
} else if (message.media instanceof TLRPC.TL_messageMediaVideo) { } else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
photoThumbs = new ArrayList<PhotoObject>(); photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(message.media.video.thumb); PhotoObject obj = new PhotoObject(message.media.video.thumb);
@ -115,11 +116,11 @@ public class MessageObject {
if (imagePreview == null && obj.image != null) { if (imagePreview == null && obj.image != null) {
imagePreview = obj.image; imagePreview = obj.image;
} }
messageText = Utilities.applicationContext.getResources().getString(R.string.AttachVideo); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.AttachVideo);
} else if (message.media instanceof TLRPC.TL_messageMediaGeo) { } else if (message.media instanceof TLRPC.TL_messageMediaGeo) {
messageText = Utilities.applicationContext.getResources().getString(R.string.AttachLocation); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.AttachLocation);
} else if (message.media instanceof TLRPC.TL_messageMediaContact) { } else if (message.media instanceof TLRPC.TL_messageMediaContact) {
messageText = Utilities.applicationContext.getResources().getString(R.string.AttachContact); messageText = ApplicationLoader.applicationContext.getResources().getString(R.string.AttachContact);
} }
} else { } else {
messageText = message.message; messageText = message.message;

View File

@ -76,7 +76,6 @@ public class ApplicationActivity extends SherlockFragmentActivity implements Not
} }
} }
setContentView(R.layout.application_layout); setContentView(R.layout.application_layout);
notificationView = (NotificationView) getLayoutInflater().inflate(R.layout.notification_layout, null);
shadowView = findViewById(R.id.shadow); shadowView = findViewById(R.id.shadow);
NotificationCenter.Instance.addObserver(this, 1234); NotificationCenter.Instance.addObserver(this, 1234);
NotificationCenter.Instance.addObserver(this, 658); NotificationCenter.Instance.addObserver(this, 658);
@ -342,6 +341,9 @@ public class ApplicationActivity extends SherlockFragmentActivity implements Not
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (notificationView == null && getLayoutInflater() != null) {
notificationView = (NotificationView) getLayoutInflater().inflate(R.layout.notification_layout, null);
}
fixLayout(); fixLayout();
checkForCrashes(); checkForCrashes();
checkForUpdates(); checkForUpdates();
@ -389,7 +391,7 @@ public class ApplicationActivity extends SherlockFragmentActivity implements Not
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = manager.getDefaultDisplay(); Display display = manager.getDefaultDisplay();
int rotation = display.getRotation(); int rotation = display.getRotation();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
int height; int height;
int currentActionBarHeight = getSupportActionBar().getHeight(); int currentActionBarHeight = getSupportActionBar().getHeight();
@ -575,7 +577,7 @@ public class ApplicationActivity extends SherlockFragmentActivity implements Not
ApplicationLoader.fragmentsStack.remove(ApplicationLoader.fragmentsStack.size() - 1); ApplicationLoader.fragmentsStack.remove(ApplicationLoader.fragmentsStack.size() - 1);
current.onFragmentDestroy(); current.onFragmentDestroy();
} }
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
if (animations) { if (animations) {
if (bySwipe) { if (bySwipe) {
@ -614,7 +616,7 @@ public class ApplicationActivity extends SherlockFragmentActivity implements Not
BaseFragment prev = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 2); BaseFragment prev = ApplicationLoader.fragmentsStack.get(ApplicationLoader.fragmentsStack.size() - 2);
FragmentManager fm = getSupportFragmentManager(); FragmentManager fm = getSupportFragmentManager();
FragmentTransaction fTrans = fm.beginTransaction(); FragmentTransaction fTrans = fm.beginTransaction();
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
if (animations) { if (animations) {
if (bySwipe) { if (bySwipe) {

View File

@ -47,6 +47,7 @@ public class ApplicationLoader extends Application {
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
public static long lastPauseTime; public static long lastPauseTime;
public static Bitmap cachedWallpaper = null; public static Bitmap cachedWallpaper = null;
public static Context applicationContext;
public static ApplicationLoader Instance = null; public static ApplicationLoader Instance = null;
@ -60,18 +61,19 @@ public class ApplicationLoader extends Application {
java.lang.System.setProperty("java.net.preferIPv4Stack", "true"); java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
java.lang.System.setProperty("java.net.preferIPv6Addresses", "false"); java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
Utilities.applicationContext = getApplicationContext(); applicationContext = getApplicationContext();
Utilities.getTypeface("fonts/rlight.ttf");
UserConfig.loadConfig(); UserConfig.loadConfig();
SharedPreferences preferences = getSharedPreferences("Notifications", MODE_PRIVATE); SharedPreferences preferences = getSharedPreferences("Notifications", MODE_PRIVATE);
if (UserConfig.currentUser != null) { if (UserConfig.currentUser != null) {
int value = preferences.getInt("version", 0); int value = preferences.getInt("version", 0);
if (value != 15) { if (value != 15) {
UserConfig.contactsHash = ""; UserConfig.contactsHash = "";
UserConfig.lastDateValue = 0; MessagesStorage.lastDateValue = 0;
UserConfig.lastPtsValue = 0; MessagesStorage.lastPtsValue = 0;
UserConfig.lastSeqValue = 0; MessagesStorage.lastSeqValue = 0;
UserConfig.lastQtsValue = 0; MessagesStorage.lastQtsValue = 0;
UserConfig.saveConfig(); UserConfig.saveConfig(false);
MessagesStorage.Instance.cleanUp(); MessagesStorage.Instance.cleanUp();
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>(); ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
users.add(UserConfig.currentUser); users.add(UserConfig.currentUser);
@ -80,6 +82,8 @@ public class ApplicationLoader extends Application {
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.putInt("version", 15); editor.putInt("version", 15);
editor.commit(); editor.commit();
} else {
MessagesStorage init = MessagesStorage.Instance;
} }
MessagesController.Instance.users.put(UserConfig.clientUserId, UserConfig.currentUser); MessagesController.Instance.users.put(UserConfig.clientUserId, UserConfig.currentUser);
} else { } else {
@ -102,7 +106,7 @@ public class ApplicationLoader extends Application {
if (checkPlayServices()) { if (checkPlayServices()) {
gcm = GoogleCloudMessaging.getInstance(this); gcm = GoogleCloudMessaging.getInstance(this);
regid = getRegistrationId(Utilities.applicationContext); regid = getRegistrationId(applicationContext);
if (regid.length() == 0) { if (regid.length() == 0) {
registerInBackground(); registerInBackground();
@ -171,11 +175,11 @@ public class ApplicationLoader extends Application {
String msg; String msg;
try { try {
if (gcm == null) { if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(Utilities.applicationContext); gcm = GoogleCloudMessaging.getInstance(applicationContext);
} }
regid = gcm.register(SENDER_ID); regid = gcm.register(SENDER_ID);
sendRegistrationIdToBackend(true); sendRegistrationIdToBackend(true);
storeRegistrationId(Utilities.applicationContext, regid); storeRegistrationId(applicationContext, regid);
return true; return true;
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
@ -191,7 +195,7 @@ public class ApplicationLoader extends Application {
public void run() { public void run() {
UserConfig.pushString = regid; UserConfig.pushString = regid;
UserConfig.registeredForPush = !isNew; UserConfig.registeredForPush = !isNew;
UserConfig.saveConfig(); UserConfig.saveConfig(false);
MessagesController.Instance.registerForPush(regid); MessagesController.Instance.registerForPush(regid);
} }
}); });

View File

@ -281,7 +281,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter.Instance.addObserver(this, 997); NotificationCenter.Instance.addObserver(this, 997);
loading = true; loading = true;
MessagesController.Instance.loadMessages(dialog_id, 0, 30, 0, true, 0, classGuid); MessagesController.Instance.loadMessages(dialog_id, 0, 30, 0, true, 0, classGuid);
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
fontSize = preferences.getInt("fons_size", 16); fontSize = preferences.getInt("fons_size", 16);
return true; return true;
} }
@ -360,7 +360,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
ImageView backgroundImage = (ImageView) fragmentView.findViewById(R.id.background_image); ImageView backgroundImage = (ImageView) fragmentView.findViewById(R.id.background_image);
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
int selectedBackground = preferences.getInt("selectedBackground", 1000001); int selectedBackground = preferences.getInt("selectedBackground", 1000001);
int selectedColor = preferences.getInt("selectedColor", 0); int selectedColor = preferences.getInt("selectedColor", 0);
if (selectedColor != 0) { if (selectedColor != 0) {
@ -371,7 +371,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (selectedBackground == 1000001) { if (selectedBackground == 1000001) {
backgroundImage.setImageResource(R.drawable.background_hd); backgroundImage.setImageResource(R.drawable.background_hd);
} else { } else {
File toFile = new File(Utilities.applicationContext.getFilesDir(), "wallpaper.jpg"); File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
if (toFile.exists()) { if (toFile.exists()) {
if (ApplicationLoader.cachedWallpaper != null) { if (ApplicationLoader.cachedWallpaper != null) {
backgroundImage.setImageBitmap(ApplicationLoader.cachedWallpaper); backgroundImage.setImageBitmap(ApplicationLoader.cachedWallpaper);
@ -419,11 +419,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
if (isCustomTheme) { if (isCustomTheme) {
centerProgress.setIndeterminateDrawable(Utilities.applicationContext.getResources().getDrawable(R.drawable.loading_custom_animation)); centerProgress.setIndeterminateDrawable(ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.loading_custom_animation));
emptyView.setBackgroundResource(R.drawable.day_box_custom); emptyView.setBackgroundResource(R.drawable.day_box_custom);
} else { } else {
emptyView.setBackgroundResource(R.drawable.day_box); emptyView.setBackgroundResource(R.drawable.day_box);
centerProgress.setIndeterminateDrawable(Utilities.applicationContext.getResources().getDrawable(R.drawable.loading_animation)); centerProgress.setIndeterminateDrawable(ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.loading_animation));
} }
emptyView.setPadding((int)(10 * displayDensity), (int)(26 * displayDensity), (int)(10 * displayDensity), 0); emptyView.setPadding((int)(10 * displayDensity), (int)(26 * displayDensity), (int)(10 * displayDensity), 0);
@ -681,7 +681,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
Utilities.hideKeyboard(parentActivity.getCurrentFocus()); Utilities.hideKeyboard(parentActivity.getCurrentFocus());
} }
} }
parentActivity.invalidateOptionsMenu(); if (parentActivity != null) {
parentActivity.invalidateOptionsMenu();
}
} }
private void addToLoadingFile(String path, ProgressBar bar) { private void addToLoadingFile(String path, ProgressBar bar) {
@ -833,15 +835,13 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
if (currentChat != null) { if (currentChat != null) {
currentChat = MessagesController.Instance.chats.get(currentChat.id);
actionBar.setTitle(Html.fromHtml("<font color='#006fc8'>" + currentChat.title + "</font>")); actionBar.setTitle(Html.fromHtml("<font color='#006fc8'>" + currentChat.title + "</font>"));
if (title != null) { if (title != null) {
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
title.setCompoundDrawablePadding(0); title.setCompoundDrawablePadding(0);
} }
} else if (currentUser != null) { } else if (currentUser != null) {
currentUser = MessagesController.Instance.users.get(currentUser.id); if (currentUser.id != 333000 && MessagesController.Instance.contactsDict.get(currentUser.id) == null) {
if (currentUser.id != 333000 && !MessagesController.Instance.contactsByPhones.containsKey(currentUser.phone)) {
if (currentUser.phone != null && currentUser.phone.length() != 0) { if (currentUser.phone != null && currentUser.phone.length() != 0) {
actionBar.setTitle(Html.fromHtml("<font color='#006fc8'>" + PhoneFormat.Instance.format("+" + currentUser.phone) + "</font>")); actionBar.setTitle(Html.fromHtml("<font color='#006fc8'>" + PhoneFormat.Instance.format("+" + currentUser.phone) + "</font>"));
} else { } else {
@ -1044,12 +1044,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return; return;
} }
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Video.Thumbnails.MINI_KIND); Bitmap thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Video.Thumbnails.MINI_KIND);
TLRPC.PhotoSize size; TLRPC.PhotoSize size = FileLoader.scaleAndSaveImage(thumb, 90, 90, 55, currentEncryptedChat != null);
if (currentEncryptedChat == null) {
size = FileLoader.scaleAndSaveImage(thumb, 320, 320, 87, false);
} else {
size = FileLoader.scaleAndSaveImage(thumb, 90, 90, 55, true);
}
if (size == null) { if (size == null) {
return; return;
} }
@ -1064,7 +1059,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
video.size = (int)temp.length(); video.size = (int)temp.length();
} }
UserConfig.lastLocalId--; UserConfig.lastLocalId--;
UserConfig.saveConfig(); UserConfig.saveConfig(false);
MediaPlayer mp = MediaPlayer.create(parentActivity, Uri.fromFile(new File(videoPath))); MediaPlayer mp = MediaPlayer.create(parentActivity, Uri.fromFile(new File(videoPath)));
video.duration = (int)Math.ceil(mp.getDuration() / 1000.0f); video.duration = (int)Math.ceil(mp.getDuration() / 1000.0f);
@ -1293,7 +1288,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
} }
} else if (id == MessagesController.closeChats) { } else if (id == MessagesController.closeChats) {
if (messsageEditText.isFocused()) { if (messsageEditText != null && messsageEditText.isFocused()) {
Utilities.hideKeyboard(messsageEditText); Utilities.hideKeyboard(messsageEditText);
} }
removeSelfFromStack(); removeSelfFromStack();
@ -1481,7 +1476,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (currentUser == null) { if (currentUser == null) {
topPanel.setVisibility(View.GONE); topPanel.setVisibility(View.GONE);
} else { } else {
if (currentUser.phone != null && currentUser.phone.length() != 0 && MessagesController.Instance.contactsByPhones.get(currentUser.phone) != null) { if (currentUser.phone != null && currentUser.phone.length() != 0 && MessagesController.Instance.contactsDict.get(currentUser.id) != null) {
topPanel.setVisibility(View.GONE); topPanel.setVisibility(View.GONE);
} else { } else {
topPanel.setVisibility(View.VISIBLE); topPanel.setVisibility(View.VISIBLE);
@ -1657,7 +1652,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
((ApplicationActivity)parentActivity).showActionBar(); ((ApplicationActivity)parentActivity).showActionBar();
((ApplicationActivity)parentActivity).updateActionBar(); ((ApplicationActivity)parentActivity).updateActionBar();
fixLayout(); fixLayout();
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
String lastMessageText = preferences.getString("dialog_" + dialog_id, null); String lastMessageText = preferences.getString("dialog_" + dialog_id, null);
if (lastMessageText != null) { if (lastMessageText != null) {
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
@ -1708,7 +1703,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
MessagesController.Instance.openned_dialog_id = 0; MessagesController.Instance.openned_dialog_id = 0;
if (messsageEditText != null && messsageEditText.length() != 0) { if (messsageEditText != null && messsageEditText.length() != 0) {
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.putString("dialog_" + dialog_id, messsageEditText.getText().toString()); editor.putString("dialog_" + dialog_id, messsageEditText.getText().toString());
editor.commit(); editor.commit();
@ -1725,12 +1720,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
chatListView.getViewTreeObserver().removeOnPreDrawListener(this); chatListView.getViewTreeObserver().removeOnPreDrawListener(this);
return false; return false;
} }
WindowManager manager = (WindowManager) Utilities.applicationContext.getSystemService(Activity.WINDOW_SERVICE); WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay(); Display display = manager.getDefaultDisplay();
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -2198,7 +2193,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public boolean isGoogleMapsInstalled() { public boolean isGoogleMapsInstalled() {
try { try {
ApplicationInfo info = Utilities.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0 ); ApplicationInfo info = ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0 );
return true; return true;
} catch(PackageManager.NameNotFoundException e) { } catch(PackageManager.NameNotFoundException e) {
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
@ -2216,9 +2211,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
}); });
builder.setNegativeButton(R.string.Cancel, null); builder.setNegativeButton(R.string.Cancel, null);
AlertDialog dialog = builder.create(); visibleDialog = builder.create();
dialog.setCanceledOnTouchOutside(true); visibleDialog.setCanceledOnTouchOutside(true);
dialog.show(); visibleDialog.show();
return false; return false;
} }
} }
@ -2417,9 +2412,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
ProgressBar progressBar = (ProgressBar)view.findViewById(R.id.progress); ProgressBar progressBar = (ProgressBar)view.findViewById(R.id.progress);
progressBar.setIndeterminate(true); progressBar.setIndeterminate(true);
if (isCustomTheme) { if (isCustomTheme) {
progressBar.setIndeterminateDrawable(Utilities.applicationContext.getResources().getDrawable(R.drawable.loading_custom_animation)); progressBar.setIndeterminateDrawable(ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.loading_custom_animation));
} else { } else {
progressBar.setIndeterminateDrawable(Utilities.applicationContext.getResources().getDrawable(R.drawable.loading_animation)); progressBar.setIndeterminateDrawable(ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.loading_animation));
} }
} }
return view; return view;
@ -2755,7 +2750,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
int placeHolderId = Utilities.getUserAvatarForId(contactUser.id); int placeHolderId = Utilities.getUserAvatarForId(contactUser.id);
contactAvatar.setImage(photo, "50_50", placeHolderId); contactAvatar.setImage(photo, "50_50", placeHolderId);
if (contactUser.id != UserConfig.clientUserId && !MessagesController.Instance.contactsByPhones.containsKey(contactUser.phone)) { if (contactUser.id != UserConfig.clientUserId && MessagesController.Instance.contactsDict.get(contactUser.id) == null) {
addContactView.setVisibility(View.VISIBLE); addContactView.setVisibility(View.VISIBLE);
} else { } else {
addContactView.setVisibility(View.GONE); addContactView.setVisibility(View.GONE);
@ -3234,6 +3229,19 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (forwardedUserText != null) { if (forwardedUserText != null) {
forwardedUserText.setTypeface(typeface); forwardedUserText.setTypeface(typeface);
forwardedUserText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TLRPC.User fwdUser = MessagesController.Instance.users.get(message.messageOwner.fwd_from_id);
if (fwdUser != null && fwdUser.id != UserConfig.clientUserId) {
UserProfileActivity fragment = new UserProfileActivity();
Bundle args = new Bundle();
args.putInt("user_id", fwdUser.id);
fragment.setArguments(args);
((ApplicationActivity)parentActivity).presentFragment(fragment, "user_" + fwdUser.id, false);
}
}
});
} }
if (videoTimeText != null) { if (videoTimeText != null) {
videoTimeText.setTypeface(typeface); videoTimeText.setTypeface(typeface);

View File

@ -225,7 +225,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
((ApplicationActivity)parentActivity).presentFragment(fragment, "user_" + user_id, false); ((ApplicationActivity)parentActivity).presentFragment(fragment, "user_" + user_id, false);
} else { } else {
if (size + 7 == i) { if (size + 7 == i) {
if (info.participants.size() < 100) { if (info.participants.size() < 200) {
openAddMenu(); openAddMenu();
} else { } else {
kickUser(null); kickUser(null);
@ -375,7 +375,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -539,7 +539,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
int count = 6; int count = 6;
if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) { if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) {
count += info.participants.size() + 2; count += info.participants.size() + 2;
if (info.participants.size() < 100) { if (info.participants.size() < 200) {
count++; count++;
} }
} }
@ -673,7 +673,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
TextView textView = (TextView)view.findViewById(R.id.settings_row_text); TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
View divider = view.findViewById(R.id.settings_row_divider); View divider = view.findViewById(R.id.settings_row_divider);
if (i == 2) { if (i == 2) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
String key = "notify_" + (-chat_id); String key = "notify_" + (-chat_id);
boolean value = preferences.getBoolean(key, true); boolean value = preferences.getBoolean(key, true);
ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button); ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button);
@ -696,7 +696,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
detailTextView.setTypeface(typeface); detailTextView.setTypeface(typeface);
View divider = view.findViewById(R.id.settings_row_divider); View divider = view.findViewById(R.id.settings_row_divider);
if (i == 3) { if (i == 3) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
String name = preferences.getString("sound_chat_" + chat_id, getStringEntry(R.string.Default)); String name = preferences.getString("sound_chat_" + chat_id, getStringEntry(R.string.Default));
if (name.equals("NoSound")) { if (name.equals("NoSound")) {
detailTextView.setText(getStringEntry(R.string.NoSound)); detailTextView.setText(getStringEntry(R.string.NoSound));
@ -836,7 +836,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
return 4; return 4;
} else { } else {
if (size + 7 == i) { if (size + 7 == i) {
if (info != null && info.participants.size() < 100) { if (info != null && info.participants.size() < 200) {
return 5; return 5;
} else { } else {
return 6; return 6;

View File

@ -111,7 +111,7 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -173,7 +173,7 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
} }
((ApplicationActivity)parentActivity).updateActionBar(); ((ApplicationActivity)parentActivity).updateActionBar();
fixLayout(); fixLayout();
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
if (!animations) { if (!animations) {
firstNameField.requestFocus(); firstNameField.requestFocus();

View File

@ -219,7 +219,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
((ApplicationActivity)parentActivity).updateActionBar(); ((ApplicationActivity)parentActivity).updateActionBar();
fixLayout(); fixLayout();
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
if (!animations) { if (!animations) {
firstNameField.requestFocus(); firstNameField.requestFocus();
@ -245,7 +245,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {

View File

@ -34,6 +34,8 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.widget.SearchView; import com.actionbarsherlock.widget.SearchView;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.TL.TLRPC; import org.telegram.TL.TLRPC;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
@ -231,7 +233,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
if (usePhone == null) { if (usePhone == null) {
usePhone = phone; usePhone = phone;
} }
TLRPC.TL_contact cLocal = MessagesController.Instance.contactsByPhones.get(phone); String cleanPhone = PhoneFormat.stripExceptNumbers(usePhone);
TLRPC.TL_contact cLocal = MessagesController.Instance.contactsByPhones.get(cleanPhone);
if (cLocal != null) { if (cLocal != null) {
if (cLocal.user_id == UserConfig.clientUserId) { if (cLocal.user_id == UserConfig.clientUserId) {
return; return;
@ -257,7 +260,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
try { try {
String number = "+" + arg1; String number = arg1;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", number, null)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", number, null));
intent.putExtra("sms_body", getStringEntry(R.string.InviteText)); intent.putExtra("sms_body", getStringEntry(R.string.InviteText));
startActivity(intent); startActivity(intent);
@ -347,7 +350,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -529,7 +532,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
if (s.length() != 0) { if (s.length() != 0) {
searchWas = true; searchWas = true;
if (listView != null) { if (listView != null) {
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
listView.setPadding((int)(density * 16), listView.getPaddingTop(), (int)(density * 16), listView.getPaddingBottom()); listView.setPadding((int)(density * 16), listView.getPaddingTop(), (int)(density * 16), listView.getPaddingBottom());
listView.setAdapter(searchListViewAdapter); listView.setAdapter(searchListViewAdapter);
if(android.os.Build.VERSION.SDK_INT >= 11) { if(android.os.Build.VERSION.SDK_INT >= 11) {
@ -562,7 +565,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
searchWas = false; searchWas = false;
ViewGroup group = (ViewGroup)listView.getParent(); ViewGroup group = (ViewGroup)listView.getParent();
listView.setAdapter(listViewAdapter); listView.setAdapter(listViewAdapter);
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (!isRTL) { if (!isRTL) {
listView.setPadding((int)(density * 16), listView.getPaddingTop(), (int)(density * 30), listView.getPaddingBottom()); listView.setPadding((int)(density * 16), listView.getPaddingTop(), (int)(density * 30), listView.getPaddingBottom());
} else { } else {

View File

@ -179,7 +179,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
localPagerAdapter = new LocalPagerAdapter(imagesArr, imagesByIds); localPagerAdapter = new LocalPagerAdapter(imagesArr, imagesByIds);
} }
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
mViewPager.setPageMargin((int)(20 * density)); mViewPager.setPageMargin((int)(20 * density));
mViewPager.setOffscreenPageLimit(1); mViewPager.setOffscreenPageLimit(1);

View File

@ -161,7 +161,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
} else { } else {
doneTextView.setText(getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")"); doneTextView.setText(getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")");
} }
countTextView.setText(selectedContacts.size() + "/100"); countTextView.setText(selectedContacts.size() + "/200");
listView.invalidateViews(); listView.invalidateViews();
} else { } else {
search = true; search = true;
@ -219,7 +219,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
userSelectEditText.setSelection(text.length()); userSelectEditText.setSelection(text.length());
ignoreChange = false; ignoreChange = false;
} else { } else {
if (selectedContacts.size() == 100) { if (selectedContacts.size() == 200) {
return; return;
} }
ignoreChange = true; ignoreChange = true;
@ -232,7 +232,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
} else { } else {
doneTextView.setText(getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")"); doneTextView.setText(getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")");
} }
countTextView.setText(selectedContacts.size() + "/100"); countTextView.setText(selectedContacts.size() + "/200");
if (searching || searchWas) { if (searching || searchWas) {
searching = false; searching = false;
searchWas = false; searchWas = false;
@ -280,7 +280,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {

View File

@ -156,7 +156,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {

View File

@ -133,7 +133,7 @@ public class IdenticonActivity extends BaseFragment {
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -154,7 +154,7 @@ public class IdenticonActivity extends BaseFragment {
TextView title = (TextView)parentActivity.findViewById(R.id.abs__action_bar_title); TextView title = (TextView)parentActivity.findViewById(R.id.abs__action_bar_title);
if (title == null) { if (title == null) {
final int subtitleId = Utilities.applicationContext.getResources().getIdentifier("action_bar_title", "id", "android"); final int subtitleId = ApplicationLoader.applicationContext.getResources().getIdentifier("action_bar_title", "id", "android");
title = (TextView)parentActivity.findViewById(subtitleId); title = (TextView)parentActivity.findViewById(subtitleId);
} }
if (title != null) { if (title != null) {

View File

@ -261,7 +261,7 @@ public class IntroActivity extends SherlockFragmentActivity {
WindowManager manager = (WindowManager)getSystemService(Context.WINDOW_SERVICE); WindowManager manager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay(); Display display = manager.getDefaultDisplay();
int rotation = display.getRotation(); int rotation = display.getRotation();
density = Utilities.applicationContext.getResources().getDisplayMetrics().density; density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)parentSlidingView.getLayoutParams(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)parentSlidingView.getLayoutParams();
FrameLayout.LayoutParams buttonParams = (FrameLayout.LayoutParams)startMessagingButton.getLayoutParams(); FrameLayout.LayoutParams buttonParams = (FrameLayout.LayoutParams)startMessagingButton.getLayoutParams();

View File

@ -54,10 +54,12 @@ public class LaunchActivity extends PausableActivity {
cursor.close(); cursor.close();
} }
} }
if (path.startsWith("file:")) { if (path != null) {
path = path.replace("file://", ""); if (path.startsWith("file:")) {
path = path.replace("file://", "");
}
NotificationCenter.Instance.addToMemCache(533, path);
} }
NotificationCenter.Instance.addToMemCache(533, path);
} else if (intent.getType().startsWith("video/")) { } else if (intent.getType().startsWith("video/")) {
String path = intent.getParcelableExtra(Intent.EXTRA_STREAM).toString(); String path = intent.getParcelableExtra(Intent.EXTRA_STREAM).toString();
if (path.startsWith("content:")) { if (path.startsWith("content:")) {
@ -68,10 +70,12 @@ public class LaunchActivity extends PausableActivity {
cursor.close(); cursor.close();
} }
} }
if (path.startsWith("file:")) { if (path != null) {
path = path.replace("file://", ""); if (path.startsWith("file:")) {
path = path.replace("file://", "");
}
NotificationCenter.Instance.addToMemCache(534, path);
} }
NotificationCenter.Instance.addToMemCache(534, path);
} else if (intent.getType().equals("text/plain")) { } else if (intent.getType().equals("text/plain")) {
String text = intent.getStringExtra(Intent.EXTRA_TEXT); String text = intent.getStringExtra(Intent.EXTRA_TEXT);
if (text.length() != 0) { if (text.length() != 0) {

View File

@ -227,7 +227,7 @@ public class LocationActivity extends BaseFragment implements LocationListener,
bottomView = fragmentView.findViewById(R.id.location_bottom_view); bottomView = fragmentView.findViewById(R.id.location_bottom_view);
sendButton = (TextView)fragmentView.findViewById(R.id.location_send_button); sendButton = (TextView)fragmentView.findViewById(R.id.location_send_button);
getFragmentManager().beginTransaction().replace(R.id.map_view, mapFragment).commit(); getChildFragmentManager().beginTransaction().replace(R.id.map_view, mapFragment).commit();
} else { } else {
ViewGroup parent = (ViewGroup)fragmentView.getParent(); ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) { if (parent != null) {
@ -305,14 +305,13 @@ public class LocationActivity extends BaseFragment implements LocationListener,
if (isGPSEnabled || isNetworkEnabled) { if (isGPSEnabled || isNetworkEnabled) {
if (isGPSEnabled) { if (isGPSEnabled) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000 * 3 * 1, 0, this); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000 * 3 * 1, 1, this);
if (locationManager != null) { if (locationManager != null) {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} }
} }
if (location == null && isNetworkEnabled) { if (location == null && isNetworkEnabled) {
long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000 * 3 * 1, 1, this);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000 * 3 * 1, 0, this);
if (locationManager != null) { if (locationManager != null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
} }
@ -341,9 +340,9 @@ public class LocationActivity extends BaseFragment implements LocationListener,
if (userLocation != null && distanceTextView != null) { if (userLocation != null && distanceTextView != null) {
float distance = location.distanceTo(userLocation); float distance = location.distanceTo(userLocation);
if (distance < 1000) { if (distance < 1000) {
distanceTextView.setText(String.format("%d %s", (int)(distance), Utilities.applicationContext.getString(R.string.MetersAway))); distanceTextView.setText(String.format("%d %s", (int)(distance), ApplicationLoader.applicationContext.getString(R.string.MetersAway)));
} else { } else {
distanceTextView.setText(String.format("%.2f %s", distance / 1000.0f, Utilities.applicationContext.getString(R.string.KMetersAway))); distanceTextView.setText(String.format("%.2f %s", distance / 1000.0f, ApplicationLoader.applicationContext.getString(R.string.KMetersAway)));
} }
} }
} else { } else {
@ -365,8 +364,13 @@ public class LocationActivity extends BaseFragment implements LocationListener,
} }
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(final Location location) {
positionMarker(location); Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
positionMarker(location);
}
});
} }
@Override @Override

View File

@ -76,7 +76,7 @@ public class LoginActivity extends SherlockFragmentActivity implements NonSwipea
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(LoginActivity.this.getString(R.string.AppName)); builder.setTitle(LoginActivity.this.getString(R.string.AppName));
builder.setMessage(message); builder.setMessage(message);
builder.setPositiveButton(Utilities.applicationContext.getString(R.string.OK), null); builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), null);
builder.show().setCanceledOnTouchOutside(true); builder.show().setCanceledOnTouchOutside(true);
} }
} }
@ -160,7 +160,7 @@ public class LoginActivity extends SherlockFragmentActivity implements NonSwipea
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.login_layout); setContentView(R.layout.login_layout);
Utilities.applicationContext = this.getApplicationContext(); ApplicationLoader.applicationContext = this.getApplicationContext();
ConnectionsManager inst = ConnectionsManager.Instance; ConnectionsManager inst = ConnectionsManager.Instance;
Typeface typeface = Utilities.getTypeface("fonts/rlight.ttf"); Typeface typeface = Utilities.getTypeface("fonts/rlight.ttf");

View File

@ -296,7 +296,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {

View File

@ -92,6 +92,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
NotificationCenter.Instance.addObserver(this, MessagesController.reloadSearchResults); NotificationCenter.Instance.addObserver(this, MessagesController.reloadSearchResults);
NotificationCenter.Instance.addObserver(this, MessagesController.userPrintUpdateAll); NotificationCenter.Instance.addObserver(this, MessagesController.userPrintUpdateAll);
NotificationCenter.Instance.addObserver(this, MessagesController.encryptedChatUpdated); NotificationCenter.Instance.addObserver(this, MessagesController.encryptedChatUpdated);
NotificationCenter.Instance.addObserver(this, MessagesController.contactsDidLoaded);
NotificationCenter.Instance.addObserver(this, 1234); NotificationCenter.Instance.addObserver(this, 1234);
if (getArguments() != null) { if (getArguments() != null) {
onlySelect = getArguments().getBoolean("onlySelect", false); onlySelect = getArguments().getBoolean("onlySelect", false);
@ -109,6 +110,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
NotificationCenter.Instance.removeObserver(this, MessagesController.reloadSearchResults); NotificationCenter.Instance.removeObserver(this, MessagesController.reloadSearchResults);
NotificationCenter.Instance.removeObserver(this, MessagesController.userPrintUpdateAll); NotificationCenter.Instance.removeObserver(this, MessagesController.userPrintUpdateAll);
NotificationCenter.Instance.removeObserver(this, MessagesController.encryptedChatUpdated); NotificationCenter.Instance.removeObserver(this, MessagesController.encryptedChatUpdated);
NotificationCenter.Instance.removeObserver(this, MessagesController.contactsDidLoaded);
NotificationCenter.Instance.removeObserver(this, 1234); NotificationCenter.Instance.removeObserver(this, 1234);
delegate = null; delegate = null;
} }
@ -328,7 +330,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
view = (ImageView)parentActivity.findViewById(com.actionbarsherlock.R.id.abs__home); view = (ImageView)parentActivity.findViewById(com.actionbarsherlock.R.id.abs__home);
} }
if (view != null) { if (view != null) {
view.setPadding((int)(Utilities.applicationContext.getResources().getDisplayMetrics().density * 6), 0, (int)(Utilities.applicationContext.getResources().getDisplayMetrics().density * 6), 0); view.setPadding((int)(ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density * 6), 0, (int)(ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density * 6), 0);
} }
actionBar.setHomeButtonEnabled(false); actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowTitleEnabled(true);
@ -420,6 +422,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (messagesListView != null) { if (messagesListView != null) {
updateVisibleRows(); updateVisibleRows();
} }
} else if (id == MessagesController.contactsDidLoaded) {
if (messagesListView != null) {
updateVisibleRows();
}
} }
} }
@ -453,7 +459,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
WindowManager manager = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); WindowManager manager = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay(); Display display = manager.getDefaultDisplay();
int rotation = display.getRotation(); int rotation = display.getRotation();
density = Utilities.applicationContext.getResources().getDisplayMetrics().density; density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
@ -1043,8 +1049,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
nameTextView.setText(chat.title); nameTextView.setText(chat.title);
nameTextView.setTextColor(0xff000000); nameTextView.setTextColor(0xff000000);
} else if (user != null) { } else if (user != null) {
if (user.id != 333000 && !MessagesController.Instance.contactsByPhones.containsKey(user.phone)) { if (user.id != 333000 && MessagesController.Instance.contactsDict.get(user.id) == null) {
if (MessagesController.Instance.contactsByPhones.isEmpty() && MessagesController.Instance.loadingContacts) { if (MessagesController.Instance.contactsDict.size() == 0 && MessagesController.Instance.loadingContacts) {
nameTextView.setTextColor(0xff000000); nameTextView.setTextColor(0xff000000);
nameTextView.setText(Utilities.formatName(user.first_name, user.last_name)); nameTextView.setText(Utilities.formatName(user.first_name, user.last_name));
} else { } else {

View File

@ -183,7 +183,7 @@ public class ScreenSlidePageFragmentPhone extends SlideFragment implements Adapt
} }
}); });
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(Utilities.applicationContext, R.layout.login_country_textview, countriesArray); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(ApplicationLoader.applicationContext, R.layout.login_country_textview, countriesArray);
dataAdapter.setDropDownViewResource(R.layout.login_country_dropdown); dataAdapter.setDropDownViewResource(R.layout.login_country_dropdown);
countrySpinner.setAdapter(dataAdapter); countrySpinner.setAdapter(dataAdapter);
@ -205,7 +205,7 @@ public class ScreenSlidePageFragmentPhone extends SlideFragment implements Adapt
String country = "RU"; String country = "RU";
try { try {
TelephonyManager telephonyManager = (TelephonyManager)Utilities.applicationContext.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager telephonyManager = (TelephonyManager)ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) { if (telephonyManager != null) {
country = telephonyManager.getSimCountryIso().toUpperCase(); country = telephonyManager.getSimCountryIso().toUpperCase();
} }
@ -215,7 +215,7 @@ public class ScreenSlidePageFragmentPhone extends SlideFragment implements Adapt
if (country == null || country.length() == 0) { if (country == null || country.length() == 0) {
try { try {
Locale current = Utilities.applicationContext.getResources().getConfiguration().locale; Locale current = ApplicationLoader.applicationContext.getResources().getConfiguration().locale;
country = current.getCountry().toUpperCase(); country = current.getCountry().toUpperCase();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -299,8 +299,8 @@ public class ScreenSlidePageFragmentPhone extends SlideFragment implements Adapt
TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode(); TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode();
String phone = "" + codeField.getText() + phoneField.getText(); String phone = "" + codeField.getText() + phoneField.getText();
phone = phone.replace("+", ""); phone = phone.replace("+", "");
req.api_hash = "5bce48dc7d331e62c955669eb7233217"; req.api_hash = "eb06d4abfb49dc3eeb1aeb98ae0f581e";
req.api_id = 2458; req.api_id = 6;
req.sms_type = 0; req.sms_type = 0;
req.phone_number = phone; req.phone_number = phone;
req.lang_code = Locale.getDefault().getCountry(); req.lang_code = Locale.getDefault().getCountry();
@ -330,11 +330,11 @@ public class ScreenSlidePageFragmentPhone extends SlideFragment implements Adapt
} else { } else {
if (error.text != null) { if (error.text != null) {
if (error.text.contains("PHONE_NUMBER_INVALID")) { if (error.text.contains("PHONE_NUMBER_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.InvalidPhoneNumber)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.InvalidCode)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) { } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.CodeExpired)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.CodeExpired));
} else { } else {
delegate.needShowAlert(error.text); delegate.needShowAlert(error.text);
} }

View File

@ -196,7 +196,7 @@ public class ScreenSlidePageFragmentRegister extends SlideFragment {
UserConfig.currentUser = user; UserConfig.currentUser = user;
UserConfig.clientActivated = true; UserConfig.clientActivated = true;
UserConfig.clientUserId = user.id; UserConfig.clientUserId = user.id;
UserConfig.saveConfig(); UserConfig.saveConfig(true);
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>(); ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
users.add(user); users.add(user);
MessagesStorage.Instance.putUsersAndChats(users, null, true, true); MessagesStorage.Instance.putUsersAndChats(users, null, true, true);
@ -208,15 +208,15 @@ public class ScreenSlidePageFragmentRegister extends SlideFragment {
}); });
} else { } else {
if (error.text.contains("PHONE_NUMBER_INVALID")) { if (error.text.contains("PHONE_NUMBER_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.InvalidPhoneNumber)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.InvalidCode)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) { } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.CodeExpired)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.CodeExpired));
} else if (error.text.contains("FIRSTNAME_INVALID")) { } else if (error.text.contains("FIRSTNAME_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.FirstName)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.FirstName));
} else if (error.text.contains("LASTNAME_INVALID")) { } else if (error.text.contains("LASTNAME_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.LastName)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.LastName));
} else { } else {
delegate.needShowAlert(error.text); delegate.needShowAlert(error.text);
} }

View File

@ -119,7 +119,7 @@ public class ScreenSlidePageFragmentSms extends SlideFragment implements Notific
registered = params.get("registered"); registered = params.get("registered");
String number = PhoneFormat.Instance.format(phone); String number = PhoneFormat.Instance.format(phone);
confirmTextView.setText(Html.fromHtml(String.format(Utilities.applicationContext.getResources().getString(R.string.SentSmsCode) + " <b>%s</b>", number))); confirmTextView.setText(Html.fromHtml(String.format(ApplicationLoader.applicationContext.getResources().getString(R.string.SentSmsCode) + " <b>%s</b>", number)));
Utilities.showKeyboard(codeField); Utilities.showKeyboard(codeField);
codeField.requestFocus(); codeField.requestFocus();
@ -129,7 +129,7 @@ public class ScreenSlidePageFragmentSms extends SlideFragment implements Notific
timeTimer.cancel(); timeTimer.cancel();
timeTimer = null; timeTimer = null;
} }
timeText.setText(String.format("%s 1:00", Utilities.applicationContext.getResources().getString(R.string.CallText))); timeText.setText(String.format("%s 1:00", ApplicationLoader.applicationContext.getResources().getString(R.string.CallText)));
lastCurrentTime = System.currentTimeMillis(); lastCurrentTime = System.currentTimeMillis();
timeTimer = new Timer(); timeTimer = new Timer();
timeTimer.schedule(new TimerTask() { timeTimer.schedule(new TimerTask() {
@ -145,9 +145,9 @@ public class ScreenSlidePageFragmentSms extends SlideFragment implements Notific
if (time >= 1000) { if (time >= 1000) {
int minutes = time / 1000 / 60; int minutes = time / 1000 / 60;
int seconds = time / 1000 - minutes * 60; int seconds = time / 1000 - minutes * 60;
timeText.setText(String.format("%s %d:%02d", Utilities.applicationContext.getResources().getString(R.string.CallText), minutes, seconds)); timeText.setText(String.format("%s %d:%02d", ApplicationLoader.applicationContext.getResources().getString(R.string.CallText), minutes, seconds));
} else { } else {
timeText.setText(Utilities.applicationContext.getResources().getString(R.string.Calling)); timeText.setText(ApplicationLoader.applicationContext.getResources().getString(R.string.Calling));
if (timeTimer != null) { if (timeTimer != null) {
timeTimer.cancel(); timeTimer.cancel();
timeTimer = null; timeTimer = null;
@ -201,7 +201,7 @@ public class ScreenSlidePageFragmentSms extends SlideFragment implements Notific
UserConfig.currentUser = res.user; UserConfig.currentUser = res.user;
UserConfig.clientActivated = true; UserConfig.clientActivated = true;
UserConfig.clientUserId = res.user.id; UserConfig.clientUserId = res.user.id;
UserConfig.saveConfig(); UserConfig.saveConfig(true);
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>(); ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
users.add(UserConfig.currentUser); users.add(UserConfig.currentUser);
MessagesStorage.Instance.putUsersAndChats(users, null, true, true); MessagesStorage.Instance.putUsersAndChats(users, null, true, true);
@ -229,11 +229,11 @@ public class ScreenSlidePageFragmentSms extends SlideFragment implements Notific
}); });
} else { } else {
if (error.text.contains("PHONE_NUMBER_INVALID")) { if (error.text.contains("PHONE_NUMBER_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.InvalidPhoneNumber)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.InvalidCode)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) { } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
delegate.needShowAlert(Utilities.applicationContext.getString(R.string.CodeExpired)); delegate.needShowAlert(ApplicationLoader.applicationContext.getString(R.string.CodeExpired));
} else { } else {
delegate.needShowAlert(error.text); delegate.needShowAlert(error.text);
} }

View File

@ -140,7 +140,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
builder.setItems(new CharSequence[]{String.format("%d", 16), String.format("%d", 17), String.format("%d", 18), String.format("%d", 19), String.format("%d", 20)}, new DialogInterface.OnClickListener() { builder.setItems(new CharSequence[]{String.format("%d", 16), String.format("%d", 17), String.format("%d", 18), String.format("%d", 19), String.format("%d", 20)}, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.putInt("fons_size", 16 + which); editor.putInt("fons_size", 16 + which);
editor.commit(); editor.commit();
@ -152,7 +152,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
builder.setNegativeButton(getStringEntry(R.string.Cancel), null); builder.setNegativeButton(getStringEntry(R.string.Cancel), null);
builder.show().setCanceledOnTouchOutside(true); builder.show().setCanceledOnTouchOutside(true);
} else if (i == enableAnimationsRow) { } else if (i == enableAnimationsRow) {
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("view_animations", !animations); editor.putBoolean("view_animations", !animations);
@ -270,7 +270,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -504,7 +504,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
divider.setVisibility(View.VISIBLE); divider.setVisibility(View.VISIBLE);
ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button); ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button);
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
if (animations) { if (animations) {
checkButton.setImageResource(R.drawable.btn_check_on); checkButton.setImageResource(R.drawable.btn_check_on);
@ -559,10 +559,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
detailTextView.setTypeface(typeface); detailTextView.setTypeface(typeface);
View divider = view.findViewById(R.id.settings_row_divider); View divider = view.findViewById(R.id.settings_row_divider);
if (i == textSizeRow) { if (i == textSizeRow) {
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
int size = preferences.getInt("fons_size", 16); int size = preferences.getInt("fons_size", 16);
detailTextView.setText(String.format("%d", size)); detailTextView.setText(String.format("%d", size));
textView.setText(Utilities.applicationContext.getString(R.string.TextSize)); textView.setText(ApplicationLoader.applicationContext.getString(R.string.TextSize));
divider.setVisibility(View.VISIBLE); divider.setVisibility(View.VISIBLE);
} }
} }

View File

@ -305,7 +305,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {

View File

@ -73,7 +73,7 @@ public class SettingsChangeNameActivity extends BaseFragment {
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -130,7 +130,7 @@ public class SettingsChangeNameActivity extends BaseFragment {
fixLayout(); fixLayout();
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
if (!animations) { if (!animations) {
firstNameField.requestFocus(); firstNameField.requestFocus();
@ -226,7 +226,7 @@ public class SettingsChangeNameActivity extends BaseFragment {
user.first_name = req.first_name; user.first_name = req.first_name;
user.last_name = req.last_name; user.last_name = req.last_name;
} }
UserConfig.saveConfig(); UserConfig.saveConfig(true);
NotificationCenter.Instance.postNotificationName(MessagesController.updateInterfaces, MessagesController.UPDATE_MASK_ALL); NotificationCenter.Instance.postNotificationName(MessagesController.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override

View File

@ -65,7 +65,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i == 1 || i == 6) { if (i == 1 || i == 6) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
boolean enabled = false; boolean enabled = false;
if (i == 1) { if (i == 1) {
@ -96,7 +96,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
} }
ConnectionsManager.Instance.performRpc(req, null, null, true, RPCRequest.RPCRequestClassGeneric); ConnectionsManager.Instance.performRpc(req, null, null, true, RPCRequest.RPCRequestClassGeneric);
} else if (i == 2 || i == 7) { } else if (i == 2 || i == 7) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
boolean enabledAll = true; boolean enabledAll = true;
boolean enabled = true; boolean enabled = true;
@ -130,7 +130,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
} }
ConnectionsManager.Instance.performRpc(req, null, null, true, RPCRequest.RPCRequestClassGeneric); ConnectionsManager.Instance.performRpc(req, null, null, true, RPCRequest.RPCRequestClassGeneric);
} else if (i == 3 || i == 8) { } else if (i == 3 || i == 8) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
boolean enabled; boolean enabled;
if (i == 3) { if (i == 3) {
@ -143,7 +143,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
editor.commit(); editor.commit();
listView.invalidateViews(); listView.invalidateViews();
} else if (i == 4 || i == 9) { } else if (i == 4 || i == 9) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false); tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false);
@ -196,7 +196,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
return; return;
} }
reseting = false; reseting = false;
SharedPreferences preferences = inflaterActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.clear(); editor.clear();
editor.commit(); editor.commit();
@ -208,21 +208,21 @@ public class SettingsNotificationsActivity extends BaseFragment {
} }
}, null, true, RPCRequest.RPCRequestClassGeneric); }, null, true, RPCRequest.RPCRequestClassGeneric);
} else if (i == 11) { } else if (i == 11) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnableInAppSounds", true); boolean enabled = preferences.getBoolean("EnableInAppSounds", true);
editor.putBoolean("EnableInAppSounds", !enabled); editor.putBoolean("EnableInAppSounds", !enabled);
editor.commit(); editor.commit();
listView.invalidateViews(); listView.invalidateViews();
} else if (i == 12) { } else if (i == 12) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnableInAppVibrate", true); boolean enabled = preferences.getBoolean("EnableInAppVibrate", true);
editor.putBoolean("EnableInAppVibrate", !enabled); editor.putBoolean("EnableInAppVibrate", !enabled);
editor.commit(); editor.commit();
listView.invalidateViews(); listView.invalidateViews();
} else if (i == 13) { } else if (i == 13) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnableInAppPreview", true); boolean enabled = preferences.getBoolean("EnableInAppPreview", true);
editor.putBoolean("EnableInAppPreview", !enabled); editor.putBoolean("EnableInAppPreview", !enabled);
@ -260,7 +260,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
} }
} }
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
if (requestCode == 4) { if (requestCode == 4) {
@ -342,7 +342,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -387,7 +387,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
@Override @Override
public boolean isEnabled(int i) { public boolean isEnabled(int i) {
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean enabledAll = preferences.getBoolean("EnableAll", true); boolean enabledAll = preferences.getBoolean("EnableAll", true);
return !(i != 1 && !enabledAll && i != 13) && (i > 0 && i < 5 || i > 5 && i < 10 || i > 10 && i < 14 || i == 15); return !(i != 1 && !enabledAll && i != 13) && (i > 0 && i < 5 || i > 5 && i < 10 || i > 10 && i < 14 || i == 15);
} }
@ -439,7 +439,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
View divider = view.findViewById(R.id.settings_row_divider); View divider = view.findViewById(R.id.settings_row_divider);
ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button); ImageView checkButton = (ImageView)view.findViewById(R.id.settings_row_check_button);
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean enabled = false; boolean enabled = false;
boolean enabledAll = preferences.getBoolean("EnableAll", true); boolean enabledAll = preferences.getBoolean("EnableAll", true);
@ -506,7 +506,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
TextView textView = (TextView)view.findViewById(R.id.settings_row_text); TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
TextView textViewDetail = (TextView)view.findViewById(R.id.settings_row_text_detail); TextView textViewDetail = (TextView)view.findViewById(R.id.settings_row_text_detail);
View divider = view.findViewById(R.id.settings_row_divider); View divider = view.findViewById(R.id.settings_row_divider);
SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
boolean enabledAll = preferences.getBoolean("EnableAll", true); boolean enabledAll = preferences.getBoolean("EnableAll", true);
if (i == 4 || i == 9) { if (i == 4 || i == 9) {
if (i == 4) { if (i == 4) {

View File

@ -73,7 +73,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
NotificationCenter.Instance.addObserver(this, FileLoader.FileLoadProgressChanged); NotificationCenter.Instance.addObserver(this, FileLoader.FileLoadProgressChanged);
NotificationCenter.Instance.addObserver(this, MessagesStorage.wallpapersDidLoaded); NotificationCenter.Instance.addObserver(this, MessagesStorage.wallpapersDidLoaded);
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
selectedBackground = preferences.getInt("selectedBackground", 1000001); selectedBackground = preferences.getInt("selectedBackground", 1000001);
selectedColor = preferences.getInt("selectedColor", 0); selectedColor = preferences.getInt("selectedColor", 0);
MessagesStorage.Instance.getWallpapers(); MessagesStorage.Instance.getWallpapers();
@ -94,7 +94,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
if (fragmentView == null) { if (fragmentView == null) {
fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false); fragmentView = inflater.inflate(R.layout.settings_wallpapers_layout, container, false);
listAdapter = new ListAdapter(parentActivity); listAdapter = new ListAdapter(parentActivity);
density = Utilities.applicationContext.getResources().getDisplayMetrics().density; density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
progressBar = (ProgressBar)fragmentView.findViewById(R.id.action_progress); progressBar = (ProgressBar)fragmentView.findViewById(R.id.action_progress);
backgroundImage = (ImageView)fragmentView.findViewById(R.id.background_image); backgroundImage = (ImageView)fragmentView.findViewById(R.id.background_image);
@ -154,7 +154,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, (int) (320 * density), (int) (480 * density)); TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, (int) (320 * density), (int) (480 * density));
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg"; String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
File f = new File(Utilities.getCacheDir(), fileName); File f = new File(Utilities.getCacheDir(), fileName);
File toFile = new File(Utilities.applicationContext.getFilesDir(), "wallpaper.jpg"); File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
try { try {
done = Utilities.copyFile(f, toFile); done = Utilities.copyFile(f, toFile);
} catch (Exception e) { } catch (Exception e) {
@ -166,7 +166,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
} }
if (done) { if (done) {
SharedPreferences preferences = Utilities.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.putInt("selectedBackground", selectedBackground); editor.putInt("selectedBackground", selectedBackground);
editor.putInt("selectedColor", selectedColor); editor.putInt("selectedColor", selectedColor);
@ -195,7 +195,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
Utilities.addMediaToGallery(currentPicturePath); Utilities.addMediaToGallery(currentPicturePath);
try { try {
Bitmap bitmap = FileLoader.loadBitmap(currentPicturePath, (int)(320 * density), (int)(480 * density)); Bitmap bitmap = FileLoader.loadBitmap(currentPicturePath, (int)(320 * density), (int)(480 * density));
File toFile = new File(Utilities.applicationContext.getFilesDir(), "wallpaper.jpg"); File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
FileOutputStream stream = new FileOutputStream(toFile); FileOutputStream stream = new FileOutputStream(toFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream); bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
selectedBackground = -1; selectedBackground = -1;
@ -218,7 +218,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
try { try {
Bitmap bitmap = FileLoader.loadBitmap(imageFilePath, (int)(320 * density), (int)(480 * density)); Bitmap bitmap = FileLoader.loadBitmap(imageFilePath, (int)(320 * density), (int)(480 * density));
File toFile = new File(Utilities.applicationContext.getFilesDir(), "wallpaper.jpg"); File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
FileOutputStream stream = new FileOutputStream(toFile); FileOutputStream stream = new FileOutputStream(toFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream); bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
selectedBackground = -1; selectedBackground = -1;
@ -269,7 +269,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
backgroundImage.setBackgroundColor(0); backgroundImage.setBackgroundColor(0);
selectedColor = 0; selectedColor = 0;
} else if (selectedBackground == -1) { } else if (selectedBackground == -1) {
File toFile = new File(Utilities.applicationContext.getFilesDir(), "wallpaper.jpg"); File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
if (toFile.exists()) { if (toFile.exists()) {
backgroundImage.setImageURI(Uri.fromFile(toFile)); backgroundImage.setImageURI(Uri.fromFile(toFile));
} else { } else {

View File

@ -399,7 +399,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
int rotation = display.getRotation(); int rotation = display.getRotation();
int height; int height;
int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight(); int currentActionBarHeight = parentActivity.getSupportActionBar().getHeight();
float density = Utilities.applicationContext.getResources().getDisplayMetrics().density; float density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) { if (currentActionBarHeight != 48 * density && currentActionBarHeight != 40 * density) {
height = currentActionBarHeight; height = currentActionBarHeight;
} else { } else {
@ -415,7 +415,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
if (dialog_id != 0) { if (dialog_id != 0) {
TextView title = (TextView)parentActivity.findViewById(R.id.abs__action_bar_title); TextView title = (TextView)parentActivity.findViewById(R.id.abs__action_bar_title);
if (title == null) { if (title == null) {
final int subtitleId = Utilities.applicationContext.getResources().getIdentifier("action_bar_title", "id", "android"); final int subtitleId = ApplicationLoader.applicationContext.getResources().getIdentifier("action_bar_title", "id", "android");
title = (TextView)parentActivity.findViewById(subtitleId); title = (TextView)parentActivity.findViewById(subtitleId);
} }
if (title != null) { if (title != null) {

View File

@ -118,10 +118,15 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
} else if (requestCode == 1) { } else if (requestCode == 1) {
Uri imageUri = data.getData(); Uri imageUri = data.getData();
Cursor cursor = null; Cursor cursor = null;
if (parentFragment != null) { try {
cursor = parentFragment.getSherlockActivity().getContentResolver().query(imageUri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null); if (parentFragment != null) {
} else if (parentActivity != null) { cursor = parentFragment.getSherlockActivity().getContentResolver().query(imageUri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
cursor = parentActivity.getContentResolver().query(imageUri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null); } else if (parentActivity != null) {
cursor = parentActivity.getContentResolver().query(imageUri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
}
} catch (Exception e) {
e.printStackTrace();
return;
} }
if (cursor == null) { if (cursor == null) {
return; return;
@ -149,7 +154,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
delegate.didUploadedPhoto(null, smallPhoto, bigPhoto); delegate.didUploadedPhoto(null, smallPhoto, bigPhoto);
} }
} else { } else {
UserConfig.saveConfig(); UserConfig.saveConfig(false);
uploadingAvatar = Utilities.getCacheDir() + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg"; uploadingAvatar = Utilities.getCacheDir() + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg";
NotificationCenter.Instance.addObserver(AvatarUpdater.this, FileLoader.FileDidUpload); NotificationCenter.Instance.addObserver(AvatarUpdater.this, FileLoader.FileDidUpload);
NotificationCenter.Instance.addObserver(AvatarUpdater.this, FileLoader.FileDidFailUpload); NotificationCenter.Instance.addObserver(AvatarUpdater.this, FileLoader.FileDidFailUpload);

View File

@ -17,8 +17,8 @@ import android.view.animation.AnimationUtils;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationActivity; import org.telegram.ui.ApplicationActivity;
import org.telegram.ui.ApplicationLoader;
public class BaseFragment extends SherlockFragment { public class BaseFragment extends SherlockFragment {
public int animationType = 0; public int animationType = 0;
@ -90,10 +90,11 @@ public class BaseFragment extends SherlockFragment {
public void onFragmentDestroy() { public void onFragmentDestroy() {
ConnectionsManager.Instance.cancelRpcsForClassGuid(classGuid); ConnectionsManager.Instance.cancelRpcsForClassGuid(classGuid);
removeParentOnDestroy = true; removeParentOnDestroy = true;
isFinish = true;
} }
public String getStringEntry(int res) { public String getStringEntry(int res) {
return Utilities.applicationContext.getString(res); return ApplicationLoader.applicationContext.getString(res);
} }
public void onAnimationStart() { public void onAnimationStart() {

View File

@ -29,6 +29,7 @@ import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.objects.MessageObject; import org.telegram.objects.MessageObject;
import org.telegram.ui.ApplicationLoader;
import java.util.Locale; import java.util.Locale;
import java.util.Timer; import java.util.Timer;
@ -119,11 +120,11 @@ public class NotificationView extends LinearLayout {
} }
}); });
notificationParentView = new FrameLayout(Utilities.applicationContext); notificationParentView = new FrameLayout(getContext());
notificationParentView.addView(this); notificationParentView.addView(this);
notificationParentView.setFocusable(false); notificationParentView.setFocusable(false);
setFocusable(false); setFocusable(false);
WindowManager wm = (WindowManager)Utilities.applicationContext.getSystemService(Context.WINDOW_SERVICE); final WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
notificationLayoutParams = new WindowManager.LayoutParams(); notificationLayoutParams = new WindowManager.LayoutParams();
notificationLayoutParams.height = 90; notificationLayoutParams.height = 90;
notificationLayoutParams.format = PixelFormat.TRANSLUCENT; notificationLayoutParams.format = PixelFormat.TRANSLUCENT;
@ -131,11 +132,11 @@ public class NotificationView extends LinearLayout {
notificationLayoutParams.gravity = Gravity.CLIP_HORIZONTAL | Gravity.TOP; notificationLayoutParams.gravity = Gravity.CLIP_HORIZONTAL | Gravity.TOP;
notificationLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; notificationLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
notificationLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; notificationLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
notificationLayoutParams.y = -300;
isVisible = false; isVisible = false;
wm.addView(notificationParentView, notificationLayoutParams); wm.addView(notificationParentView, notificationLayoutParams);
notificationParentView.setVisibility(View.INVISIBLE);
animHide = AnimationUtils.loadAnimation(Utilities.applicationContext, R.anim.slide_up); animHide = AnimationUtils.loadAnimation(ApplicationLoader.applicationContext, R.anim.slide_up);
animHide.setAnimationListener(new Animation.AnimationListener() { animHide.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
onScreen = false; onScreen = false;
@ -147,14 +148,13 @@ public class NotificationView extends LinearLayout {
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
setVisibility(GONE); setVisibility(GONE);
WindowManager wm = (WindowManager)Utilities.applicationContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
isVisible = false; isVisible = false;
notificationLayoutParams.y = -300; notificationParentView.setVisibility(View.INVISIBLE);
wm.updateViewLayout(notificationParentView, notificationLayoutParams);
} }
}); });
animShow = AnimationUtils.loadAnimation(Utilities.applicationContext, R.anim.slide_down); animShow = AnimationUtils.loadAnimation(ApplicationLoader.applicationContext, R.anim.slide_down);
animShow.setAnimationListener(new Animation.AnimationListener() { animShow.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
setVisibility(VISIBLE); setVisibility(VISIBLE);
@ -237,10 +237,9 @@ public class NotificationView extends LinearLayout {
} }
if (!onScreen) { if (!onScreen) {
WindowManager wm = (WindowManager)Utilities.applicationContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
isVisible = true; isVisible = true;
notificationLayoutParams.y = 0; notificationParentView.setVisibility(View.VISIBLE);
wm.updateViewLayout(notificationParentView, notificationLayoutParams);
startAnimation(animShow); startAnimation(animShow);
} }
} }
@ -261,10 +260,9 @@ public class NotificationView extends LinearLayout {
onScreen = false; onScreen = false;
setVisibility(GONE); setVisibility(GONE);
if (notificationParentView != null && notificationParentView.getParent() != null) { if (notificationParentView != null && notificationParentView.getParent() != null) {
WindowManager wm = (WindowManager)Utilities.applicationContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
isVisible = false; isVisible = false;
notificationLayoutParams.y = -300; notificationParentView.setVisibility(View.INVISIBLE);
wm.updateViewLayout(notificationParentView, notificationLayoutParams);
} }
} }
} }
@ -276,7 +274,7 @@ public class NotificationView extends LinearLayout {
notificationParentView.removeView(this); notificationParentView.removeView(this);
try { try {
if (notificationParentView.getParent() != null) { if (notificationParentView.getParent() != null) {
WindowManager wm = (WindowManager)Utilities.applicationContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
wm.removeViewImmediate(notificationParentView); wm.removeViewImmediate(notificationParentView);
} }
} catch (Exception e) { } catch (Exception e) {
@ -322,7 +320,7 @@ public class NotificationView extends LinearLayout {
if (notificationParentView != null) { if (notificationParentView != null) {
notificationLayoutParams.height = height + (int)(2 * density); notificationLayoutParams.height = height + (int)(2 * density);
if (notificationParentView.getParent() != null) { if (notificationParentView.getParent() != null) {
WindowManager wm = (WindowManager) Utilities.applicationContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
wm.updateViewLayout(notificationParentView, notificationLayoutParams); wm.updateViewLayout(notificationParentView, notificationLayoutParams);
} }
} }

View File

@ -29,7 +29,6 @@
android:gravity="right|center" android:gravity="right|center"
android:textSize="15dp" android:textSize="15dp"
android:textColor="#000000" android:textColor="#000000"
android:text="Nikolay Kudashov"
android:id="@+id/name_text_view" android:id="@+id/name_text_view"
android:paddingTop="4dp" android:paddingTop="4dp"
android:ellipsize="end" android:ellipsize="end"
@ -41,7 +40,6 @@
android:gravity="right|center" android:gravity="right|center"
android:textColor="#000000" android:textColor="#000000"
android:textSize="15dp" android:textSize="15dp"
android:text="Hello"
android:id="@+id/message_text_view" android:id="@+id/message_text_view"
android:paddingTop="24dp" android:paddingTop="24dp"
android:ellipsize="end" android:ellipsize="end"

View File

@ -24,6 +24,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="14dp" android:layout_marginRight="14dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:layout_weight="1.0" android:layout_weight="1.0"
android:gravity="right"> android:gravity="right">

View File

@ -64,7 +64,7 @@
android:textSize="16dp" android:textSize="16dp"
android:linksClickable="false" android:linksClickable="false"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:autoLink="web" android:autoLink="web|email"
android:descendantFocusability="afterDescendants" android:descendantFocusability="afterDescendants"
android:layout_marginTop="53dp" android:layout_marginTop="53dp"
android:layout_gravity="top" android:layout_gravity="top"

View File

@ -42,7 +42,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16dp" android:textSize="16dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:autoLink="web" android:autoLink="web|email"
android:linksClickable="false" android:linksClickable="false"
android:layout_marginTop="18dp" android:layout_marginTop="18dp"
android:textColor="#000000" android:textColor="#000000"

View File

@ -42,7 +42,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16dp" android:textSize="16dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:autoLink="web" android:autoLink="web|email"
android:linksClickable="false" android:linksClickable="false"
android:layout_marginTop="34dp" android:layout_marginTop="34dp"
android:descendantFocusability="afterDescendants" android:descendantFocusability="afterDescendants"

View File

@ -22,7 +22,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16dp" android:textSize="16dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:autoLink="web" android:autoLink="web|email"
android:linksClickable="false" android:linksClickable="false"
android:layout_gravity="top" android:layout_gravity="top"
android:textColor="#000000"/> android:textColor="#000000"/>

View File

@ -43,7 +43,7 @@
android:linksClickable="false" android:linksClickable="false"
android:layout_marginTop="34dp" android:layout_marginTop="34dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:autoLink="web" android:autoLink="web|email"
android:descendantFocusability="afterDescendants" android:descendantFocusability="afterDescendants"
android:layout_gravity="top" android:layout_gravity="top"
android:textColor="#000000"/> android:textColor="#000000"/>

View File

@ -20,7 +20,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16dp" android:textSize="16dp"
android:autoLink="web" android:autoLink="web|email"
android:linksClickable="false" android:linksClickable="false"
android:layout_gravity="top" android:layout_gravity="top"
android:textColor="#000000" android:textColor="#000000"

View File

@ -28,7 +28,6 @@
android:gravity="left|center" android:gravity="left|center"
android:textSize="15dp" android:textSize="15dp"
android:textColor="#000000" android:textColor="#000000"
android:text="Nikolay Kudashov"
android:id="@+id/name_text_view" android:id="@+id/name_text_view"
android:paddingTop="4dp" android:paddingTop="4dp"
android:ellipsize="end" android:ellipsize="end"
@ -39,7 +38,6 @@
android:gravity="left|center" android:gravity="left|center"
android:textColor="#000000" android:textColor="#000000"
android:textSize="15dp" android:textSize="15dp"
android:text="Hello"
android:id="@+id/message_text_view" android:id="@+id/message_text_view"
android:paddingTop="24dp" android:paddingTop="24dp"
android:ellipsize="end" android:ellipsize="end"

View File

@ -25,6 +25,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="14dp" android:layout_marginLeft="14dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:layout_marginRight="4dp"
android:layout_weight="1.0"> android:layout_weight="1.0">
<TextView android:textSize="19dp" <TextView android:textSize="19dp"

View File

@ -89,6 +89,7 @@
<string name="MessageLifetime1h">ساعة</string> <string name="MessageLifetime1h">ساعة</string>
<string name="MessageLifetime1d">يوم</string> <string name="MessageLifetime1d">يوم</string>
<string name="MessageLifetime1w">أسبوع</string> <string name="MessageLifetime1w">أسبوع</string>
<string name="YouHaveNewMessage">لديك رسالة جديدة</string>
<!--contacts view--> <!--contacts view-->
<string name="SearchContactHint">إبحث عن جهات الاتصال</string> <string name="SearchContactHint">إبحث عن جهات الاتصال</string>

View File

@ -89,6 +89,7 @@
<string name="MessageLifetime1h">1 hour</string> <string name="MessageLifetime1h">1 hour</string>
<string name="MessageLifetime1d">1 day</string> <string name="MessageLifetime1d">1 day</string>
<string name="MessageLifetime1w">1 week</string> <string name="MessageLifetime1w">1 week</string>
<string name="YouHaveNewMessage">You have a new message</string>
<!--contacts view--> <!--contacts view-->
<string name="SearchContactHint">Search contacts</string> <string name="SearchContactHint">Search contacts</string>
@ -265,4 +266,4 @@
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>