Commit 90d8e8a3 authored by DrKLO's avatar DrKLO

update to 1.2.7

parent 27b74b53
...@@ -32,18 +32,18 @@ tasks.withType(Compile) { ...@@ -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
} }
} }
<?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 @@ ...@@ -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 @@ ...@@ -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" />
......
...@@ -228,7 +228,6 @@ ...@@ -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
......
...@@ -24,7 +24,7 @@ ...@@ -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 { ...@@ -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;
......
...@@ -150,7 +150,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -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. ...@@ -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. ...@@ -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;
......
...@@ -27,6 +27,8 @@ import android.view.View; ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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;
......
...@@ -18,6 +18,7 @@ import android.view.View; ...@@ -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 { ...@@ -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;
......
...@@ -198,7 +198,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver { ...@@ -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))
......
...@@ -17,6 +17,7 @@ import org.telegram.SQLite.SQLitePreparedStatement; ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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
......
...@@ -8,8 +8,12 @@ ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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);
} }
} }
...@@ -18,6 +18,7 @@ import android.os.Environment; ...@@ -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; ...@@ -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; ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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();
......
...@@ -76,7 +76,6 @@ public class ApplicationActivity extends SherlockFragmentActivity implements Not ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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) {
......
...@@ -47,6 +47,7 @@ public class ApplicationLoader extends Application { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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);
} }
}); });
......
...@@ -225,7 +225,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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;
......
...@@ -111,7 +111,7 @@ public class ChatProfileChangeNameActivity extends BaseFragment { ...@@ -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 { ...@@ -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();
......
...@@ -219,7 +219,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent ...@@ -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 ...@@ -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 {
......
...@@ -34,6 +34,8 @@ import com.actionbarsherlock.view.Menu; ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 {
......
...@@ -179,7 +179,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif ...@@ -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);
......
...@@ -161,7 +161,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 {
......
...@@ -156,7 +156,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati ...@@ -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 {
......
...@@ -133,7 +133,7 @@ public class IdenticonActivity extends BaseFragment { ...@@ -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 { ...@@ -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) {
......
...@@ -261,7 +261,7 @@ public class IntroActivity extends SherlockFragmentActivity { ...@@ -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();
......
...@@ -54,10 +54,12 @@ public class LaunchActivity extends PausableActivity { ...@@ -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 { ...@@ -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) {
......
...@@ -227,7 +227,7 @@ public class LocationActivity extends BaseFragment implements LocationListener, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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
......
...@@ -76,7 +76,7 @@ public class LoginActivity extends SherlockFragmentActivity implements NonSwipea ...@@ -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 ...@@ -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");
......
...@@ -296,7 +296,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No ...@@ -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 {
......
...@@ -92,6 +92,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 {
......
...@@ -183,7 +183,7 @@ public class ScreenSlidePageFragmentPhone extends SlideFragment implements Adapt ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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);
} }
......
...@@ -196,7 +196,7 @@ public class ScreenSlidePageFragmentRegister extends SlideFragment { ...@@ -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 { ...@@ -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);
} }
......
...@@ -119,7 +119,7 @@ public class ScreenSlidePageFragmentSms extends SlideFragment implements Notific ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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);
} }
......
...@@ -140,7 +140,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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);
} }
} }
......
...@@ -305,7 +305,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe ...@@ -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 {
......
...@@ -73,7 +73,7 @@ public class SettingsChangeNameActivity extends BaseFragment { ...@@ -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 { ...@@ -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 { ...@@ -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
......
...@@ -65,7 +65,7 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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) {
......
...@@ -73,7 +73,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 {
......
...@@ -399,7 +399,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -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 ...@@ -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) {
......
...@@ -118,10 +118,15 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg ...@@ -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 ...@@ -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);
......
...@@ -17,8 +17,8 @@ import android.view.animation.AnimationUtils; ...@@ -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 { ...@@ -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() {
......
...@@ -29,6 +29,7 @@ import org.telegram.messenger.NotificationCenter; ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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);
} }
} }
......
...@@ -29,7 +29,6 @@ ...@@ -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 @@ ...@@ -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"
......
...@@ -24,6 +24,7 @@ ...@@ -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">
......
...@@ -64,7 +64,7 @@ ...@@ -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"
......
...@@ -42,7 +42,7 @@ ...@@ -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"
......
...@@ -42,7 +42,7 @@ ...@@ -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"
......
...@@ -22,7 +22,7 @@ ...@@ -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"/>
......
...@@ -43,7 +43,7 @@ ...@@ -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"/>
......
...@@ -20,7 +20,7 @@ ...@@ -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"
......
...@@ -28,7 +28,6 @@ ...@@ -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 @@ ...@@ -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"
......
...@@ -25,6 +25,7 @@ ...@@ -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"
......
...@@ -89,6 +89,7 @@ ...@@ -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>
......
...@@ -89,6 +89,7 @@ ...@@ -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 @@ ...@@ -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>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment