Commit ad0188ba authored by DrKLO's avatar DrKLO

Update locales, bug fixes

parent 01e0b7ae
...@@ -81,7 +81,7 @@ android { ...@@ -81,7 +81,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 250 versionCode 251
versionName "1.5.0" versionName "1.5.0"
} }
} }
...@@ -17,7 +17,7 @@ import java.util.Map; ...@@ -17,7 +17,7 @@ import java.util.Map;
public class SQLiteDatabase { public class SQLiteDatabase {
private final int sqliteHandle; private final int sqliteHandle;
private final Map<String, SQLitePreparedStatement> preparedMap; private final Map<String, SQLitePreparedStatement> preparedMap = new HashMap<String, SQLitePreparedStatement>();
private boolean isOpen = false; private boolean isOpen = false;
private boolean inTransaction = false; private boolean inTransaction = false;
...@@ -28,7 +28,6 @@ public class SQLiteDatabase { ...@@ -28,7 +28,6 @@ public class SQLiteDatabase {
public SQLiteDatabase(String fileName) throws SQLiteException { public SQLiteDatabase(String fileName) throws SQLiteException {
sqliteHandle = opendb(fileName, ApplicationLoader.applicationContext.getFilesDir().getPath()); sqliteHandle = opendb(fileName, ApplicationLoader.applicationContext.getFilesDir().getPath());
isOpen = true; isOpen = true;
preparedMap = new HashMap<String, SQLitePreparedStatement>();
} }
public boolean tableExists(String tableName) throws SQLiteException { public boolean tableExists(String tableName) throws SQLiteException {
...@@ -47,7 +46,7 @@ public class SQLiteDatabase { ...@@ -47,7 +46,7 @@ public class SQLiteDatabase {
} }
} }
public SQLitePreparedStatement executeFast(String sql) throws SQLiteException{ public SQLitePreparedStatement executeFast(String sql) throws SQLiteException {
return new SQLitePreparedStatement(this, sql, true); return new SQLitePreparedStatement(this, sql, true);
} }
...@@ -64,29 +63,6 @@ public class SQLiteDatabase { ...@@ -64,29 +63,6 @@ public class SQLiteDatabase {
} }
} }
public int executeIntOrThrow(String sql, Object... args) throws SQLiteException, SQLiteNoRowException {
checkOpened();
Integer val = executeInt(sql, args);
if (val != null) {
return val;
}
throw new SQLiteNoRowException();
}
public String executeString(String sql, Object... args) throws SQLiteException {
checkOpened();
SQLiteCursor cursor = query(sql, args);
try {
if (!cursor.next()) {
return null;
}
return cursor.stringValue(0);
} finally {
cursor.dispose();
}
}
public SQLiteCursor query(String sql, Object... args) throws SQLiteException { public SQLiteCursor query(String sql, Object... args) throws SQLiteException {
checkOpened(); checkOpened();
SQLitePreparedStatement stmt = preparedMap.get(sql); SQLitePreparedStatement stmt = preparedMap.get(sql);
...@@ -110,6 +86,7 @@ public class SQLiteDatabase { ...@@ -110,6 +86,7 @@ public class SQLiteDatabase {
for (SQLitePreparedStatement stmt : preparedMap.values()) { for (SQLitePreparedStatement stmt : preparedMap.values()) {
stmt.finalizeQuery(); stmt.finalizeQuery();
} }
commitTransaction();
closedb(sqliteHandle); closedb(sqliteHandle);
} catch (SQLiteException e) { } catch (SQLiteException e) {
FileLog.e("tmessages", e.getMessage(), e); FileLog.e("tmessages", e.getMessage(), e);
...@@ -139,6 +116,9 @@ public class SQLiteDatabase { ...@@ -139,6 +116,9 @@ public class SQLiteDatabase {
} }
public void commitTransaction() { public void commitTransaction() {
if (!inTransaction) {
return;
}
inTransaction = false; inTransaction = false;
commitTransaction(sqliteHandle); commitTransaction(sqliteHandle);
} }
......
...@@ -334,7 +334,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -334,7 +334,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
} }
if (currentDatacenterId != 0 && UserConfig.clientActivated) { if (currentDatacenterId != 0 && UserConfig.isClientActivated()) {
Datacenter datacenter = datacenterWithId(currentDatacenterId); Datacenter datacenter = datacenterWithId(currentDatacenterId);
if (datacenter.authKey == null) { if (datacenter.authKey == null) {
currentDatacenterId = 0; currentDatacenterId = 0;
...@@ -632,7 +632,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -632,7 +632,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter.pushConnection.connect(); datacenter.pushConnection.connect();
generatePing(datacenter, true); generatePing(datacenter, true);
} else { } else {
if (UserConfig.clientActivated && !UserConfig.registeredForInternalPush) { if (UserConfig.isClientActivated() && !UserConfig.registeredForInternalPush) {
registerForPush(); registerForPush();
} }
} }
...@@ -722,7 +722,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -722,7 +722,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
updatingDcSettings = false; updatingDcSettings = false;
} }
}, null, true, RPCRequest.RPCRequestClassEnableUnauthorized | RPCRequest.RPCRequestClassGeneric, dcNum == 0 ? currentDatacenterId : dcNum); }, null, true, RPCRequest.RPCRequestClassEnableUnauthorized | RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin, dcNum == 0 ? currentDatacenterId : dcNum);
} }
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCProgressDelegate progressBlock, boolean requiresCompletion, int requestClass) { public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCProgressDelegate progressBlock, boolean requiresCompletion, int requestClass) {
...@@ -782,8 +782,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -782,8 +782,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
return object; return object;
} }
public static volatile long nextCallToken = 0; public static volatile long nextCallToken = 1;
long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCProgressDelegate progressBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId) { long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCProgressDelegate progressBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId) {
if (!UserConfig.isClientActivated() && (requestClass & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
FileLog.e("tmessages", "can't do request without login " + rpc);
return 0;
}
final long requestToken = nextCallToken++; final long requestToken = nextCallToken++;
...@@ -819,6 +823,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -819,6 +823,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
public void cancelRpc(final long token, final boolean notifyServer) { public void cancelRpc(final long token, final boolean notifyServer) {
if (token == 0) {
return;
}
Utilities.stageQueue.postRunnable(new Runnable() { Utilities.stageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -1510,7 +1517,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1510,7 +1517,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
for (int num : unauthorizedDatacenterIds) { for (int num : unauthorizedDatacenterIds) {
if (num != currentDatacenterId && num != movingToDatacenterId && UserConfig.clientUserId != 0) { if (num != currentDatacenterId && num != movingToDatacenterId && UserConfig.isClientActivated()) {
boolean notFound = true; boolean notFound = true;
for (Action actor : actionQueue) { for (Action actor : actionQueue) {
if (actor instanceof ExportAuthorizationAction) { if (actor instanceof ExportAuthorizationAction) {
...@@ -1786,7 +1793,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1786,7 +1793,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
saveSession(); saveSession();
} }
} }
}, null, true, RPCRequest.RPCRequestClassGeneric, datacenter.datacenterId); }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin, datacenter.datacenterId);
} }
void messagesConfirmed(final long requestMsgId) { void messagesConfirmed(final long requestMsgId) {
...@@ -1918,11 +1925,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1918,11 +1925,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
saveSession(); saveSession();
if (datacenter.datacenterId == currentDatacenterId && UserConfig.clientActivated) { if (datacenter.datacenterId == currentDatacenterId && UserConfig.isClientActivated()) {
if ((connection.transportRequestClass & RPCRequest.RPCRequestClassGeneric) != 0) { if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
MessagesController.getInstance().getDifference();
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
registerForPush(); registerForPush();
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassGeneric) != 0) {
MessagesController.getInstance().getDifference();
} }
} }
connection.addProcessedSession(newSession.unique_id); connection.addProcessedSession(newSession.unique_id);
...@@ -1947,7 +1954,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1947,7 +1954,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
connection.addProcessedMessageId(innerMessageId); connection.addProcessedMessageId(innerMessageId);
} }
} else if (message instanceof TLRPC.TL_pong) { } else if (message instanceof TLRPC.TL_pong) {
if (UserConfig.clientActivated && !UserConfig.registeredForInternalPush && (connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) { if (UserConfig.isClientActivated() && !UserConfig.registeredForInternalPush && (connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
registerForPush(); registerForPush();
} }
TLRPC.TL_pong pong = (TLRPC.TL_pong)message; TLRPC.TL_pong pong = (TLRPC.TL_pong)message;
...@@ -2159,7 +2166,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2159,7 +2166,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
isError = true; isError = true;
if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) { if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) {
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) { if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) {
if (UserConfig.clientActivated) { if (UserConfig.isClientActivated()) {
UserConfig.clearConfig(); UserConfig.clearConfig();
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@Override @Override
...@@ -2721,7 +2728,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2721,7 +2728,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
clearRequestsForRequestClass(RPCRequest.RPCRequestClassDownloadMedia, currentDatacenter); clearRequestsForRequestClass(RPCRequest.RPCRequestClassDownloadMedia, currentDatacenter);
clearRequestsForRequestClass(RPCRequest.RPCRequestClassUploadMedia, currentDatacenter); clearRequestsForRequestClass(RPCRequest.RPCRequestClassUploadMedia, currentDatacenter);
if (UserConfig.clientUserId != 0) { if (UserConfig.isClientActivated()) {
TLRPC.TL_auth_exportAuthorization exportAuthorization = new TLRPC.TL_auth_exportAuthorization(); TLRPC.TL_auth_exportAuthorization exportAuthorization = new TLRPC.TL_auth_exportAuthorization();
exportAuthorization.dc_id = datacenterId; exportAuthorization.dc_id = datacenterId;
...@@ -2732,7 +2739,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2732,7 +2739,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
movingAuthorization = (TLRPC.TL_auth_exportedAuthorization)response; movingAuthorization = (TLRPC.TL_auth_exportedAuthorization)response;
authorizeOnMovingDatacenter(); authorizeOnMovingDatacenter();
} else { } else {
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.stageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
moveToDatacenter(datacenterId); moveToDatacenter(datacenterId);
...@@ -2740,7 +2747,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2740,7 +2747,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}, 1000); }, 1000);
} }
} }
}, null, true, RPCRequest.RPCRequestClassGeneric, currentDatacenterId); }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin, currentDatacenterId);
} else { } else {
authorizeOnMovingDatacenter(); authorizeOnMovingDatacenter();
} }
...@@ -2778,7 +2785,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2778,7 +2785,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (movingAuthorization != null) { if (movingAuthorization != null) {
TLRPC.TL_auth_importAuthorization importAuthorization = new TLRPC.TL_auth_importAuthorization(); TLRPC.TL_auth_importAuthorization importAuthorization = new TLRPC.TL_auth_importAuthorization();
importAuthorization.id = UserConfig.clientUserId; importAuthorization.id = UserConfig.getClientUserId();
importAuthorization.bytes = movingAuthorization.bytes; importAuthorization.bytes = movingAuthorization.bytes;
performRpc(importAuthorization, new RPCRequest.RPCRequestDelegate() { performRpc(importAuthorization, new RPCRequest.RPCRequestDelegate() {
@Override @Override
...@@ -2790,7 +2797,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2790,7 +2797,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
moveToDatacenter(movingToDatacenterId); moveToDatacenter(movingToDatacenterId);
} }
} }
}, null, true, RPCRequest.RPCRequestClassGeneric, datacenter.datacenterId); }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin, datacenter.datacenterId);
} else { } else {
authorizedOnMovingDatacenter(); authorizedOnMovingDatacenter();
} }
......
...@@ -30,7 +30,8 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -30,7 +30,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class ContactsController { public class ContactsController {
private Account currentAccount; private Account currentAccount;
public boolean loadingContacts = false; private boolean loadingContacts = false;
private static final Integer loadContactsSync = 1;
private boolean ignoreChanges = false; private boolean ignoreChanges = false;
private boolean contactsSyncInProgress = false; private boolean contactsSyncInProgress = false;
private final Integer observerLock = 1; private final Integer observerLock = 1;
...@@ -118,10 +119,10 @@ public class ContactsController { ...@@ -118,10 +119,10 @@ public class ContactsController {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
Account[] accounts = am.getAccountsByType("org.telegram.account"); Account[] accounts = am.getAccountsByType("org.telegram.account");
boolean recreateAccount = false; boolean recreateAccount = false;
if (UserConfig.currentUser != null) { if (UserConfig.isClientActivated()) {
if (accounts.length == 1) { if (accounts.length == 1) {
Account acc = accounts[0]; Account acc = accounts[0];
if (!acc.name.equals(UserConfig.currentUser.phone)) { if (!acc.name.equals(UserConfig.getCurrentUser().phone)) {
recreateAccount = true; recreateAccount = true;
} else { } else {
currentAccount = acc; currentAccount = acc;
...@@ -139,9 +140,9 @@ public class ContactsController { ...@@ -139,9 +140,9 @@ public class ContactsController {
for (Account c : accounts) { for (Account c : accounts) {
am.removeAccount(c, null, null); am.removeAccount(c, null, null);
} }
if (UserConfig.currentUser != null) { if (UserConfig.isClientActivated()) {
try { try {
currentAccount = new Account(UserConfig.currentUser.phone, "org.telegram.account"); currentAccount = new Account(UserConfig.getCurrentUser().phone, "org.telegram.account");
am.addAccountExplicitly(currentAccount, "", null); am.addAccountExplicitly(currentAccount, "", null);
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
...@@ -230,13 +231,20 @@ public class ContactsController { ...@@ -230,13 +231,20 @@ public class ContactsController {
} }
public void readContacts() { public void readContacts() {
if (loadingContacts) { synchronized (loadContactsSync) {
return; if (loadingContacts) {
return;
}
loadingContacts = true;
} }
Utilities.stageQueue.postRunnable(new Runnable() { Utilities.stageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!contacts.isEmpty() || contactsLoaded) { if (!contacts.isEmpty() || contactsLoaded) {
synchronized (loadContactsSync) {
loadingContacts = false;
}
return; return;
} }
loadContacts(true, false); loadContacts(true, false);
...@@ -423,15 +431,15 @@ public class ContactsController { ...@@ -423,15 +431,15 @@ public class ContactsController {
public void run() { public void run() {
boolean disableDeletion = true; //disable contacts deletion, because phone numbers can't be compared due to different numbers format boolean disableDeletion = true; //disable contacts deletion, because phone numbers can't be compared due to different numbers format
if (schedule) { /*if (schedule) {
try { try {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
Account[] accounts = am.getAccountsByType("org.telegram.account"); Account[] accounts = am.getAccountsByType("org.telegram.account");
boolean recreateAccount = false; boolean recreateAccount = false;
if (UserConfig.currentUser != null) { if (UserConfig.isClientActivated()) {
if (accounts.length != 1) { if (accounts.length != 1) {
FileLog.e("tmessages", "detected account deletion!"); FileLog.e("tmessages", "detected account deletion!");
currentAccount = new Account(UserConfig.currentUser.phone, "org.telegram.account"); currentAccount = new Account(UserConfig.getCurrentUser().phone, "org.telegram.account");
am.addAccountExplicitly(currentAccount, "", null); am.addAccountExplicitly(currentAccount, "", null);
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@Override @Override
...@@ -444,7 +452,7 @@ public class ContactsController { ...@@ -444,7 +452,7 @@ public class ContactsController {
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }*/
boolean request = requ; boolean request = requ;
if (request && first) { if (request && first) {
...@@ -748,13 +756,16 @@ public class ContactsController { ...@@ -748,13 +756,16 @@ public class ContactsController {
}); });
} }
public boolean isLoadingContacts() {
synchronized (loadContactsSync) {
return loadingContacts;
}
}
public void loadContacts(boolean fromCache, boolean cacheEmpty) { public void loadContacts(boolean fromCache, boolean cacheEmpty) {
Utilities.RunOnUIThread(new Runnable() { synchronized (loadContactsSync) {
@Override loadingContacts = true;
public void run() { }
loadingContacts = true;
}
});
if (fromCache) { if (fromCache) {
FileLog.e("tmessages", "load contacts from cache"); FileLog.e("tmessages", "load contacts from cache");
MessagesStorage.getInstance().getContacts(); MessagesStorage.getInstance().getContacts();
...@@ -776,7 +787,9 @@ public class ContactsController { ...@@ -776,7 +787,9 @@ public class ContactsController {
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
loadingContacts = false; synchronized (loadContactsSync) {
loadingContacts = false;
}
NotificationCenter.getInstance().postNotificationName(MessagesController.contactsDidLoaded); NotificationCenter.getInstance().postNotificationName(MessagesController.contactsDidLoaded);
} }
}); });
...@@ -800,8 +813,8 @@ public class ContactsController { ...@@ -800,8 +813,8 @@ public class ContactsController {
MessagesController.getInstance().users.putIfAbsent(user.id, user); MessagesController.getInstance().users.putIfAbsent(user.id, user);
} else { } else {
MessagesController.getInstance().users.put(user.id, user); MessagesController.getInstance().users.put(user.id, user);
if (user.id == UserConfig.clientUserId) { if (user.id == UserConfig.getClientUserId()) {
UserConfig.currentUser = user; UserConfig.setCurrentUser(user);
} }
} }
} }
...@@ -840,7 +853,7 @@ public class ContactsController { ...@@ -840,7 +853,7 @@ public class ContactsController {
} }
for (TLRPC.TL_contact contact : contactsArr) { for (TLRPC.TL_contact contact : contactsArr) {
if (usersDict.get(contact.user_id) == null && contact.user_id != UserConfig.clientUserId) { if (usersDict.get(contact.user_id) == null && contact.user_id != UserConfig.getClientUserId()) {
loadContacts(false, true); loadContacts(false, true);
FileLog.e("tmessages", "contacts are broken, load from server"); FileLog.e("tmessages", "contacts are broken, load from server");
return; return;
...@@ -953,7 +966,9 @@ public class ContactsController { ...@@ -953,7 +966,9 @@ public class ContactsController {
usersSectionsDict = sectionsDict; usersSectionsDict = sectionsDict;
sortedUsersSectionsArray = sortedSectionsArray; sortedUsersSectionsArray = sortedSectionsArray;
if (from != 2) { if (from != 2) {
loadingContacts = false; synchronized (loadContactsSync) {
loadingContacts = false;
}
} }
performWriteContactsToPhoneBook(); performWriteContactsToPhoneBook();
updateUnregisteredContacts(contactsArr); updateUnregisteredContacts(contactsArr);
...@@ -1180,7 +1195,7 @@ public class ContactsController { ...@@ -1180,7 +1195,7 @@ public class ContactsController {
private void performWriteContactsToPhoneBook() { private void performWriteContactsToPhoneBook() {
final ArrayList<TLRPC.TL_contact> contactsArray = new ArrayList<TLRPC.TL_contact>(); final ArrayList<TLRPC.TL_contact> contactsArray = new ArrayList<TLRPC.TL_contact>();
contactsArray.addAll(contacts); contactsArray.addAll(contacts);
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.photoBookQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
performWriteContactsToPhoneBookInternal(contactsArray); performWriteContactsToPhoneBookInternal(contactsArray);
...@@ -1237,7 +1252,7 @@ public class ContactsController { ...@@ -1237,7 +1252,7 @@ public class ContactsController {
} }
for (final Integer uid : contactsTD) { for (final Integer uid : contactsTD) {
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.photoBookQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
deleteContactFromPhoneBook(uid); deleteContactFromPhoneBook(uid);
...@@ -1467,7 +1482,7 @@ public class ContactsController { ...@@ -1467,7 +1482,7 @@ public class ContactsController {
// } // }
for (final TLRPC.User u : res.users) { for (final TLRPC.User u : res.users) {
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.photoBookQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
addContactToPhoneBook(u, true); addContactToPhoneBook(u, true);
...@@ -1533,7 +1548,7 @@ public class ContactsController { ...@@ -1533,7 +1548,7 @@ public class ContactsController {
return; return;
} }
MessagesStorage.getInstance().deleteContacts(uids); MessagesStorage.getInstance().deleteContacts(uids);
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.photoBookQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
for (TLRPC.User user : users) { for (TLRPC.User user : users) {
......
...@@ -85,6 +85,6 @@ public class ExportAuthorizationAction extends Action { ...@@ -85,6 +85,6 @@ public class ExportAuthorizationAction extends Action {
} }
} }
} }
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassEnableUnauthorized, datacenter.datacenterId); }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassEnableUnauthorized | RPCRequest.RPCRequestClassWithoutLogin, datacenter.datacenterId);
} }
} }
...@@ -209,7 +209,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti ...@@ -209,7 +209,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
ByteBuffer data = ByteBuffer.wrap(resPq.pq); ByteBuffer data = ByteBuffer.wrap(resPq.pq);
final long pqf = data.getLong(); final long pqf = data.getLong();
final long messageIdf = messageId; final long messageIdf = messageId;
Utilities.globalQueue.postRunnable(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -281,7 +281,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti ...@@ -281,7 +281,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
} }
}); });
} }
}); }).start();
} else { } else {
FileLog.e("tmessages", "***** Error: invalid handshake nonce"); FileLog.e("tmessages", "***** Error: invalid handshake nonce");
beginHandshake(false); beginHandshake(false);
......
...@@ -1143,7 +1143,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1143,7 +1143,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
recordingAudio = new TLRPC.TL_audio(); recordingAudio = new TLRPC.TL_audio();
recordingAudio.dc_id = Integer.MIN_VALUE; recordingAudio.dc_id = Integer.MIN_VALUE;
recordingAudio.id = UserConfig.lastLocalId; recordingAudio.id = UserConfig.lastLocalId;
recordingAudio.user_id = UserConfig.clientUserId; recordingAudio.user_id = UserConfig.getClientUserId();
UserConfig.lastLocalId--; UserConfig.lastLocalId--;
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
...@@ -1352,7 +1352,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1352,7 +1352,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
final ProgressDialog finalProgress = progressDialog; final ProgressDialog finalProgress = progressDialog;
Utilities.globalQueue.postRunnable(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
...@@ -1427,7 +1427,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1427,7 +1427,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}); });
} }
} }
}); }).start();
} }
} }
......
...@@ -781,7 +781,7 @@ public class MessagesStorage { ...@@ -781,7 +781,7 @@ public class MessagesStorage {
if (userData != null) { if (userData != null) {
SerializedData data = new SerializedData(userData); SerializedData data = new SerializedData(userData);
TLRPC.User user = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); TLRPC.User user = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data, data.readInt32());
if (user.id == UserConfig.clientUserId) { if (user.id == UserConfig.getClientUserId()) {
continue; continue;
} }
if (user.status != null) { if (user.status != null) {
...@@ -1018,7 +1018,7 @@ public class MessagesStorage { ...@@ -1018,7 +1018,7 @@ public class MessagesStorage {
String uids = ""; String uids = "";
while (cursor.next()) { while (cursor.next()) {
int user_id = cursor.intValue(0); int user_id = cursor.intValue(0);
if (user_id == UserConfig.clientUserId) { if (user_id == UserConfig.getClientUserId()) {
continue; continue;
} }
TLRPC.TL_contact contact = new TLRPC.TL_contact(); TLRPC.TL_contact contact = new TLRPC.TL_contact();
...@@ -2484,7 +2484,7 @@ public class MessagesStorage { ...@@ -2484,7 +2484,7 @@ public class MessagesStorage {
ArrayList<TLRPC.EncryptedChat> encryptedChats = new ArrayList<TLRPC.EncryptedChat>(); ArrayList<TLRPC.EncryptedChat> encryptedChats = new ArrayList<TLRPC.EncryptedChat>();
try { try {
ArrayList<Integer> usersToLoad = new ArrayList<Integer>(); ArrayList<Integer> usersToLoad = new ArrayList<Integer>();
usersToLoad.add(UserConfig.clientUserId); usersToLoad.add(UserConfig.getClientUserId());
ArrayList<Integer> chatsToLoad = new ArrayList<Integer>(); ArrayList<Integer> chatsToLoad = new ArrayList<Integer>();
ArrayList<Integer> encryptedToLoad = new ArrayList<Integer>(); ArrayList<Integer> encryptedToLoad = new ArrayList<Integer>();
SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT d.did, d.last_mid, d.unread_count, d.date, m.data, m.read_state, m.mid, m.send_state FROM dialogs as d LEFT JOIN messages as m ON d.last_mid = m.mid ORDER BY d.date DESC LIMIT %d,%d", offset, count)); SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT d.did, d.last_mid, d.unread_count, d.date, m.data, m.read_state, m.mid, m.send_state FROM dialogs as d LEFT JOIN messages as m ON d.last_mid = m.mid ORDER BY d.date DESC LIMIT %d,%d", offset, count));
......
...@@ -28,6 +28,7 @@ public class RPCRequest { ...@@ -28,6 +28,7 @@ public class RPCRequest {
public static int RPCRequestClassFailOnServerErrors = 16; public static int RPCRequestClassFailOnServerErrors = 16;
public static int RPCRequestClassCanCompress = 32; public static int RPCRequestClassCanCompress = 32;
public static int RPCRequestClassPush = 64; public static int RPCRequestClassPush = 64;
public static int RPCRequestClassWithoutLogin = 128;
static int RPCRequestClassTransportMask = (RPCRequestClassGeneric | RPCRequestClassDownloadMedia | RPCRequestClassUploadMedia); static int RPCRequestClassTransportMask = (RPCRequestClassGeneric | RPCRequestClassDownloadMedia | RPCRequestClassUploadMedia);
......
...@@ -17,9 +17,7 @@ import org.telegram.ui.ApplicationLoader; ...@@ -17,9 +17,7 @@ import org.telegram.ui.ApplicationLoader;
import java.io.File; import java.io.File;
public class UserConfig { public class UserConfig {
public static TLRPC.User currentUser; private static TLRPC.User currentUser;
public static int clientUserId = 0;
public static boolean clientActivated = false;
public static boolean registeredForPush = false; public static boolean registeredForPush = false;
public static boolean registeredForInternalPush = false; public static boolean registeredForInternalPush = false;
public static String pushString = ""; public static String pushString = "";
...@@ -62,8 +60,6 @@ public class UserConfig { ...@@ -62,8 +60,6 @@ public class UserConfig {
if (withFile) { if (withFile) {
SerializedData data = new SerializedData(); SerializedData data = new SerializedData();
currentUser.serializeToStream(data); currentUser.serializeToStream(data);
clientUserId = currentUser.id;
clientActivated = true;
String userString = Base64.encodeToString(data.toByteArray(), Base64.DEFAULT); String userString = Base64.encodeToString(data.toByteArray(), Base64.DEFAULT);
editor.putString("user", userString); editor.putString("user", userString);
} }
...@@ -80,6 +76,30 @@ public class UserConfig { ...@@ -80,6 +76,30 @@ public class UserConfig {
} }
} }
public static boolean isClientActivated() {
synchronized (sync) {
return currentUser != null;
}
}
public static int getClientUserId() {
synchronized (sync) {
return currentUser != null ? currentUser.id : 0;
}
}
public static TLRPC.User getCurrentUser() {
synchronized (sync) {
return currentUser;
}
}
public static void setCurrentUser(TLRPC.User user) {
synchronized (sync) {
currentUser = user;
}
}
public static void loadConfig() { public static void loadConfig() {
synchronized (sync) { synchronized (sync) {
final File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "user.dat"); final File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "user.dat");
...@@ -90,8 +110,6 @@ public class UserConfig { ...@@ -90,8 +110,6 @@ public class UserConfig {
if (ver == 1) { 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;
clientActivated = true;
MessagesStorage.lastDateValue = data.readInt32(); MessagesStorage.lastDateValue = data.readInt32();
MessagesStorage.lastPtsValue = data.readInt32(); MessagesStorage.lastPtsValue = data.readInt32();
MessagesStorage.lastSeqValue = data.readInt32(); MessagesStorage.lastSeqValue = data.readInt32();
...@@ -119,8 +137,6 @@ public class UserConfig { ...@@ -119,8 +137,6 @@ public class UserConfig {
} else if (ver == 2) { } else if (ver == 2) {
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;
clientActivated = true;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
registeredForPush = preferences.getBoolean("registeredForPush", false); registeredForPush = preferences.getBoolean("registeredForPush", false);
...@@ -164,21 +180,13 @@ public class UserConfig { ...@@ -164,21 +180,13 @@ public class UserConfig {
if (userBytes != null) { if (userBytes != null) {
SerializedData data = new SerializedData(userBytes); SerializedData data = new SerializedData(userBytes);
currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, data.readInt32());
clientUserId = currentUser.id;
clientActivated = true;
} }
} }
if (currentUser == null) {
clientActivated = false;
clientUserId = 0;
}
} }
} }
} }
public static void clearConfig() { public static void clearConfig() {
clientUserId = 0;
clientActivated = false;
currentUser = null; currentUser = null;
registeredForInternalPush = false; registeredForInternalPush = false;
registeredForPush = false; registeredForPush = false;
......
...@@ -87,6 +87,8 @@ public class Utilities { ...@@ -87,6 +87,8 @@ public class Utilities {
public static volatile DispatchQueue stageQueue = new DispatchQueue("stageQueue"); public static volatile DispatchQueue stageQueue = new DispatchQueue("stageQueue");
public static volatile DispatchQueue globalQueue = new DispatchQueue("globalQueue"); public static volatile DispatchQueue globalQueue = new DispatchQueue("globalQueue");
public static volatile DispatchQueue searchQueue = new DispatchQueue("searchQueue");
public static volatile DispatchQueue photoBookQueue = new DispatchQueue("photoBookQueue");
public static int[] arrColors = {0xffee4928, 0xff41a903, 0xffe09602, 0xff0f94ed, 0xff8f3bf7, 0xfffc4380, 0xff00a1c4, 0xffeb7002}; public static int[] arrColors = {0xffee4928, 0xff41a903, 0xffe09602, 0xff0f94ed, 0xff8f3bf7, 0xfffc4380, 0xff00a1c4, 0xffeb7002};
public static int[] arrUsersAvatars = { public static int[] arrUsersAvatars = {
...@@ -668,7 +670,7 @@ public class Utilities { ...@@ -668,7 +670,7 @@ public class Utilities {
try { try {
String str; String str;
if (id >= 0) { if (id >= 0) {
str = String.format(Locale.US, "%d%d", id, UserConfig.clientUserId); str = String.format(Locale.US, "%d%d", id, UserConfig.getClientUserId());
} else { } else {
str = String.format(Locale.US, "%d", id); str = String.format(Locale.US, "%d", id);
} }
......
...@@ -107,7 +107,7 @@ public class MessageObject { ...@@ -107,7 +107,7 @@ public class MessageObject {
if (who != null && fromUser != null) { if (who != null && fromUser != null) {
if (isFromMe()) { if (isFromMe()) {
messageText = LocaleController.getString("ActionYouKickUser", R.string.ActionYouKickUser).replace("un2", Utilities.formatName(who.first_name, who.last_name)); messageText = LocaleController.getString("ActionYouKickUser", R.string.ActionYouKickUser).replace("un2", Utilities.formatName(who.first_name, who.last_name));
} else if (message.action.user_id == UserConfig.clientUserId) { } else if (message.action.user_id == UserConfig.getClientUserId()) {
messageText = LocaleController.getString("ActionKickUserYou", R.string.ActionKickUserYou).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = LocaleController.getString("ActionKickUserYou", R.string.ActionKickUserYou).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} else { } else {
messageText = LocaleController.getString("ActionKickUser", R.string.ActionKickUser).replace("un2", Utilities.formatName(who.first_name, who.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = LocaleController.getString("ActionKickUser", R.string.ActionKickUser).replace("un2", Utilities.formatName(who.first_name, who.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
...@@ -124,7 +124,7 @@ public class MessageObject { ...@@ -124,7 +124,7 @@ public class MessageObject {
if (whoUser != null && fromUser != null) { if (whoUser != null && fromUser != null) {
if (isFromMe()) { if (isFromMe()) {
messageText = LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser).replace("un2", Utilities.formatName(whoUser.first_name, whoUser.last_name)); messageText = LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser).replace("un2", Utilities.formatName(whoUser.first_name, whoUser.last_name));
} else if (message.action.user_id == UserConfig.clientUserId) { } else if (message.action.user_id == UserConfig.getClientUserId()) {
messageText = LocaleController.getString("ActionAddUserYou", R.string.ActionAddUserYou).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = LocaleController.getString("ActionAddUserYou", R.string.ActionAddUserYou).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
} else { } else {
messageText = LocaleController.getString("ActionAddUser", R.string.ActionAddUser).replace("un2", Utilities.formatName(whoUser.first_name, whoUser.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = LocaleController.getString("ActionAddUser", R.string.ActionAddUser).replace("un2", Utilities.formatName(whoUser.first_name, whoUser.last_name)).replace("un1", Utilities.formatName(fromUser.first_name, fromUser.last_name));
...@@ -206,7 +206,7 @@ public class MessageObject { ...@@ -206,7 +206,7 @@ public class MessageObject {
} }
} else if (message.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) { } else if (message.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
String date = String.format("%s %s %s", LocaleController.formatterYear.format(((long)message.date) * 1000), LocaleController.getString("OtherAt", R.string.OtherAt), LocaleController.formatterDay.format(((long)message.date) * 1000)); String date = String.format("%s %s %s", LocaleController.formatterYear.format(((long)message.date) * 1000), LocaleController.getString("OtherAt", R.string.OtherAt), LocaleController.formatterDay.format(((long)message.date) * 1000));
messageText = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, UserConfig.currentUser.first_name, date, message.action.title, message.action.address); messageText = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, UserConfig.getCurrentUser().first_name, date, message.action.title, message.action.address);
} else if (message.action instanceof TLRPC.TL_messageActionUserJoined) { } else if (message.action instanceof TLRPC.TL_messageActionUserJoined) {
if (fromUser != null) { if (fromUser != null) {
messageText = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, Utilities.formatName(fromUser.first_name, fromUser.last_name)); messageText = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, Utilities.formatName(fromUser.first_name, fromUser.last_name));
...@@ -537,6 +537,6 @@ public class MessageObject { ...@@ -537,6 +537,6 @@ public class MessageObject {
} }
public boolean isFromMe() { public boolean isFromMe() {
return messageOwner.from_id == UserConfig.clientUserId; return messageOwner.from_id == UserConfig.getClientUserId();
} }
} }
...@@ -72,7 +72,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { ...@@ -72,7 +72,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
public void run() { public void run() {
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>(); final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
contactsCopy.addAll(ContactsController.getInstance().contacts); contactsCopy.addAll(ContactsController.getInstance().contacts);
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.searchQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
String q = query.trim().toLowerCase(); String q = query.trim().toLowerCase();
...@@ -87,7 +87,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { ...@@ -87,7 +87,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
for (TLRPC.TL_contact contact : contactsCopy) { for (TLRPC.TL_contact contact : contactsCopy) {
TLRPC.User user = MessagesController.getInstance().users.get(contact.user_id); TLRPC.User user = MessagesController.getInstance().users.get(contact.user_id);
if (user.first_name != null && user.first_name.toLowerCase().startsWith(q) || user.last_name != null && user.last_name.toLowerCase().startsWith(q)) { if (user.first_name != null && user.first_name.toLowerCase().startsWith(q) || user.last_name != null && user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.clientUserId) { if (user.id == UserConfig.getClientUserId()) {
continue; continue;
} }
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q)); resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
......
...@@ -93,7 +93,7 @@ public class ApplicationLoader extends Application { ...@@ -93,7 +93,7 @@ public class ApplicationLoader extends Application {
} }
UserConfig.loadConfig(); UserConfig.loadConfig();
if (UserConfig.currentUser != null) { if (UserConfig.getCurrentUser() != null) {
boolean changed = false; boolean changed = false;
SharedPreferences preferences = applicationContext.getSharedPreferences("Notifications", MODE_PRIVATE); SharedPreferences preferences = applicationContext.getSharedPreferences("Notifications", MODE_PRIVATE);
int v = preferences.getInt("v", 0); int v = preferences.getInt("v", 0);
...@@ -122,8 +122,8 @@ public class ApplicationLoader extends Application { ...@@ -122,8 +122,8 @@ public class ApplicationLoader extends Application {
editor.commit(); editor.commit();
} }
MessagesController.getInstance().users.put(UserConfig.clientUserId, UserConfig.currentUser); MessagesController.getInstance().users.put(UserConfig.getClientUserId(), UserConfig.getCurrentUser());
ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.currentUser.phone); ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone);
ConnectionsManager.getInstance().initPushConnection(); ConnectionsManager.getInstance().initPushConnection();
} }
......
...@@ -16,7 +16,6 @@ import android.text.Layout; ...@@ -16,7 +16,6 @@ import android.text.Layout;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
...@@ -28,8 +27,6 @@ import org.telegram.messenger.UserConfig; ...@@ -28,8 +27,6 @@ import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.ImageReceiver; import org.telegram.ui.Views.ImageReceiver;
import java.lang.ref.WeakReference;
public class ChatOrUserCell extends BaseCell { public class ChatOrUserCell extends BaseCell {
private static TextPaint namePaint; private static TextPaint namePaint;
private static TextPaint nameEncryptedPaint; private static TextPaint nameEncryptedPaint;
...@@ -347,7 +344,7 @@ public class ChatOrUserCell extends BaseCell { ...@@ -347,7 +344,7 @@ public class ChatOrUserCell extends BaseCell {
onlineString = subLabel; onlineString = subLabel;
} else { } else {
onlineString = LocaleController.formatUserStatus(user); onlineString = LocaleController.formatUserStatus(user);
if (user != null && (user.id == UserConfig.clientUserId || user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) { if (user != null && (user.id == UserConfig.getClientUserId() || user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) {
currentOnlinePaint = onlinePaint; currentOnlinePaint = onlinePaint;
onlineString = LocaleController.getString("Online", R.string.Online); onlineString = LocaleController.getString("Online", R.string.Online);
} }
......
...@@ -423,7 +423,7 @@ public class DialogCell extends BaseCell { ...@@ -423,7 +423,7 @@ public class DialogCell extends BaseCell {
} else if (encryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) { } else if (encryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) {
messageString = LocaleController.getString("EncryptionRejected", R.string.EncryptionRejected); messageString = LocaleController.getString("EncryptionRejected", R.string.EncryptionRejected);
} else if (encryptedChat instanceof TLRPC.TL_encryptedChat) { } else if (encryptedChat instanceof TLRPC.TL_encryptedChat) {
if (encryptedChat.admin_id == UserConfig.clientUserId) { if (encryptedChat.admin_id == UserConfig.getClientUserId()) {
if (user != null && user.first_name != null) { if (user != null && user.first_name != null) {
messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, user.first_name); messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, user.first_name);
} else { } else {
...@@ -547,7 +547,7 @@ public class DialogCell extends BaseCell { ...@@ -547,7 +547,7 @@ public class DialogCell extends BaseCell {
nameString = chat.title; nameString = chat.title;
} else if (user != null) { } else if (user != null) {
if (user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) { if (user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) {
if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().loadingContacts)) { if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) {
nameString = Utilities.formatName(user.first_name, user.last_name); nameString = Utilities.formatName(user.first_name, user.last_name);
} else { } else {
if (user.phone != null && user.phone.length() != 0) { if (user.phone != null && user.phone.length() != 0) {
......
...@@ -686,7 +686,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -686,7 +686,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
View v = contentView.findViewById(R.id.secret_placeholder); View v = contentView.findViewById(R.id.secret_placeholder);
v.setVisibility(View.VISIBLE); v.setVisibility(View.VISIBLE);
if (currentEncryptedChat.admin_id == UserConfig.clientUserId) { if (currentEncryptedChat.admin_id == UserConfig.getClientUserId()) {
if (currentUser.first_name.length() > 0) { if (currentUser.first_name.length() > 0) {
secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleOutgoing", R.string.EncryptedPlaceholderTitleOutgoing, currentUser.first_name)); secretViewStatusTextView.setText(LocaleController.formatString("EncryptedPlaceholderTitleOutgoing", R.string.EncryptedPlaceholderTitleOutgoing, currentUser.first_name));
} else { } else {
...@@ -1337,7 +1337,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -1337,7 +1337,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
int currentTime = ConnectionsManager.getInstance().getCurrentTime(); int currentTime = ConnectionsManager.getInstance().getCurrentTime();
for (TLRPC.TL_chatParticipant participant : info.participants) { for (TLRPC.TL_chatParticipant participant : info.participants) {
TLRPC.User user = MessagesController.getInstance().users.get(participant.user_id); TLRPC.User user = MessagesController.getInstance().users.get(participant.user_id);
if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.clientUserId) && user.status.expires > 10000) { if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getClientUserId()) && user.status.expires > 10000) {
onlineCount++; onlineCount++;
} }
} }
...@@ -1495,7 +1495,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -1495,7 +1495,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (currentChat != null) { if (currentChat != null) {
actionBarLayer.setTitle(currentChat.title); actionBarLayer.setTitle(currentChat.title);
} else if (currentUser != null) { } else if (currentUser != null) {
if (currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().loadingContacts)) { if (currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) {
if (currentUser.phone != null && currentUser.phone.length() != 0) { if (currentUser.phone != null && currentUser.phone.length() != 0) {
actionBarLayer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); actionBarLayer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone));
} else { } else {
...@@ -1782,7 +1782,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -1782,7 +1782,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
TLRPC.TL_document document = new TLRPC.TL_document(); TLRPC.TL_document document = new TLRPC.TL_document();
document.id = 0; document.id = 0;
document.user_id = UserConfig.clientUserId; document.user_id = UserConfig.getClientUserId();
document.date = ConnectionsManager.getInstance().getCurrentTime(); document.date = ConnectionsManager.getInstance().getCurrentTime();
document.file_name = name; document.file_name = name;
document.size = (int)f.length(); document.size = (int)f.length();
...@@ -2517,7 +2517,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -2517,7 +2517,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|| currentUser instanceof TLRPC.TL_userEmpty || currentUser instanceof TLRPC.TL_userDeleted || currentUser instanceof TLRPC.TL_userEmpty || currentUser instanceof TLRPC.TL_userDeleted
|| (currentUser.phone != null && currentUser.phone.length() != 0 && || (currentUser.phone != null && currentUser.phone.length() != 0 &&
ContactsController.getInstance().contactsDict.get(currentUser.id) != null && ContactsController.getInstance().contactsDict.get(currentUser.id) != null &&
(ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().loadingContacts))) { (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts()))) {
topPanel.setVisibility(View.GONE); topPanel.setVisibility(View.GONE);
} else { } else {
topPanel.setVisibility(View.VISIBLE); topPanel.setVisibility(View.VISIBLE);
...@@ -2568,7 +2568,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -2568,7 +2568,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
MessagesController.getInstance().hidenAddToContacts.put(currentUser.id, currentUser); MessagesController.getInstance().hidenAddToContacts.put(currentUser.id, currentUser);
topPanel.setVisibility(View.GONE); topPanel.setVisibility(View.GONE);
MessagesController.getInstance().sendMessage(UserConfig.currentUser, dialog_id); MessagesController.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id);
chatListView.post(new Runnable() { chatListView.post(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -3137,7 +3137,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -3137,7 +3137,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
activity.finishFragment(); activity.finishFragment();
TLRPC.TL_document document = new TLRPC.TL_document(); TLRPC.TL_document document = new TLRPC.TL_document();
document.id = 0; document.id = 0;
document.user_id = UserConfig.clientUserId; document.user_id = UserConfig.getClientUserId();
document.date = ConnectionsManager.getInstance().getCurrentTime(); document.date = ConnectionsManager.getInstance().getCurrentTime();
document.file_name = name; document.file_name = name;
document.size = (int)size; document.size = (int)size;
...@@ -3573,7 +3573,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -3573,7 +3573,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
((ChatBaseCell)view).delegate = new ChatBaseCell.ChatBaseCellDelegate() { ((ChatBaseCell)view).delegate = new ChatBaseCell.ChatBaseCellDelegate() {
@Override @Override
public void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user) { public void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user) {
if (user != null && user.id != UserConfig.clientUserId) { if (user != null && user.id != UserConfig.getClientUserId()) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt("user_id", user.id); args.putInt("user_id", user.id);
presentFragment(new UserProfileActivity(args)); presentFragment(new UserProfileActivity(args));
...@@ -3784,7 +3784,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -3784,7 +3784,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
int placeHolderId = Utilities.getUserAvatarForId(contactUser.id); int placeHolderId = Utilities.getUserAvatarForId(contactUser.id);
contactAvatar.setImage(photo, "50_50", placeHolderId); contactAvatar.setImage(photo, "50_50", placeHolderId);
if (contactUser.id != UserConfig.clientUserId && ContactsController.getInstance().contactsDict.get(contactUser.id) == null) { if (contactUser.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(contactUser.id) == null) {
addContactView.setVisibility(View.VISIBLE); addContactView.setVisibility(View.VISIBLE);
} else { } else {
addContactView.setVisibility(View.GONE); addContactView.setVisibility(View.GONE);
...@@ -4090,7 +4090,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa ...@@ -4090,7 +4090,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
processRowSelect(view); processRowSelect(view);
return; return;
} }
if (message.messageOwner.media.user_id != UserConfig.clientUserId) { if (message.messageOwner.media.user_id != UserConfig.getClientUserId()) {
TLRPC.User user = null; TLRPC.User user = null;
if (message.messageOwner.media.user_id != 0) { if (message.messageOwner.media.user_id != 0) {
user = MessagesController.getInstance().users.get(message.messageOwner.media.user_id); user = MessagesController.getInstance().users.get(message.messageOwner.media.user_id);
......
...@@ -173,10 +173,10 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -173,10 +173,10 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) { public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i > membersSectionRow && i < addMemberRow) { if (i > membersSectionRow && i < addMemberRow) {
TLRPC.TL_chatParticipant user = info.participants.get(sortedUsers.get(i - membersSectionRow - 1)); TLRPC.TL_chatParticipant user = info.participants.get(sortedUsers.get(i - membersSectionRow - 1));
if (user.user_id == UserConfig.clientUserId) { if (user.user_id == UserConfig.getClientUserId()) {
return false; return false;
} }
if (info.admin_id != UserConfig.clientUserId && user.inviter_id != UserConfig.clientUserId) { if (info.admin_id != UserConfig.getClientUserId() && user.inviter_id != UserConfig.getClientUserId()) {
return false; return false;
} }
selectedUser = user; selectedUser = user;
...@@ -240,7 +240,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -240,7 +240,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
openAddMenu(); openAddMenu();
} else if (i > membersSectionRow && i < addMemberRow) { } else if (i > membersSectionRow && i < addMemberRow) {
int user_id = info.participants.get(sortedUsers.get(i - membersSectionRow - 1)).user_id; int user_id = info.participants.get(sortedUsers.get(i - membersSectionRow - 1)).user_id;
if (user_id == UserConfig.clientUserId) { if (user_id == UserConfig.getClientUserId()) {
return; return;
} }
Bundle args = new Bundle(); Bundle args = new Bundle();
...@@ -458,7 +458,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -458,7 +458,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
int i = 0; int i = 0;
for (TLRPC.TL_chatParticipant participant : info.participants) { for (TLRPC.TL_chatParticipant participant : info.participants) {
TLRPC.User user = MessagesController.getInstance().users.get(participant.user_id); TLRPC.User user = MessagesController.getInstance().users.get(participant.user_id);
if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.clientUserId) && user.status.expires > 10000) { if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getClientUserId()) && user.status.expires > 10000) {
onlineCount++; onlineCount++;
} }
sortedUsers.add(i); sortedUsers.add(i);
...@@ -473,14 +473,14 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -473,14 +473,14 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
Integer status1 = 0; Integer status1 = 0;
Integer status2 = 0; Integer status2 = 0;
if (user1 != null && user1.status != null) { if (user1 != null && user1.status != null) {
if (user1.id == UserConfig.clientUserId) { if (user1.id == UserConfig.getClientUserId()) {
status1 = ConnectionsManager.getInstance().getCurrentTime() + 50000; status1 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
} else { } else {
status1 = user1.status.expires; status1 = user1.status.expires;
} }
} }
if (user2 != null && user2.status != null) { if (user2 != null && user2.status != null) {
if (user2.id == UserConfig.clientUserId) { if (user2.id == UserConfig.getClientUserId()) {
status2 = ConnectionsManager.getInstance().getCurrentTime() + 50000; status2 = ConnectionsManager.getInstance().getCurrentTime() + 50000;
} else { } else {
status2 = user2.status.expires; status2 = user2.status.expires;
...@@ -535,7 +535,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -535,7 +535,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
} else { } else {
NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats); NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats);
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats); NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().users.get(UserConfig.clientUserId), info); MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().users.get(UserConfig.getClientUserId()), info);
MessagesController.getInstance().deleteDialog(-chat_id, 0, false); MessagesController.getInstance().deleteDialog(-chat_id, 0, false);
finishFragment(); finishFragment();
} }
......
...@@ -205,7 +205,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter ...@@ -205,7 +205,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (searching && searchWas) { if (searching && searchWas) {
TLRPC.User user = searchListViewAdapter.getItem(i); TLRPC.User user = searchListViewAdapter.getItem(i);
if (user == null || user.id == UserConfig.clientUserId) { if (user == null || user.id == UserConfig.getClientUserId()) {
return; return;
} }
if (returnAsResult) { if (returnAsResult) {
...@@ -263,7 +263,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter ...@@ -263,7 +263,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
} }
if (user != null) { if (user != null) {
if (user.id == UserConfig.clientUserId) { if (user.id == UserConfig.getClientUserId()) {
return; return;
} }
if (returnAsResult) { if (returnAsResult) {
......
...@@ -280,7 +280,7 @@ public class CountrySelectActivity extends BaseFragment { ...@@ -280,7 +280,7 @@ public class CountrySelectActivity extends BaseFragment {
} }
private void processSearch(final String query) { private void processSearch(final String query) {
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.searchQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
......
...@@ -382,7 +382,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -382,7 +382,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
public void run() { public void run() {
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>(); final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
contactsCopy.addAll(ContactsController.getInstance().contacts); contactsCopy.addAll(ContactsController.getInstance().contacts);
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.searchQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
if (query.length() == 0) { if (query.length() == 0) {
...@@ -397,7 +397,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -397,7 +397,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
for (TLRPC.TL_contact contact : contactsCopy) { for (TLRPC.TL_contact contact : contactsCopy) {
TLRPC.User user = MessagesController.getInstance().users.get(contact.user_id); TLRPC.User user = MessagesController.getInstance().users.get(contact.user_id);
if (user.first_name.toLowerCase().startsWith(q) || user.last_name.toLowerCase().startsWith(q)) { if (user.first_name.toLowerCase().startsWith(q) || user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.clientUserId) { if (user.id == UserConfig.getClientUserId()) {
continue; continue;
} }
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q)); resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
......
...@@ -232,7 +232,7 @@ public class LanguageSelectActivity extends BaseFragment { ...@@ -232,7 +232,7 @@ public class LanguageSelectActivity extends BaseFragment {
} }
private void processSearch(final String query) { private void processSearch(final String query) {
Utilities.globalQueue.postRunnable(new Runnable() { Utilities.searchQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
......
...@@ -64,7 +64,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen ...@@ -64,7 +64,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
ApplicationLoader.postInitApplication(); ApplicationLoader.postInitApplication();
if (!UserConfig.clientActivated) { if (!UserConfig.isClientActivated()) {
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) { if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
super.onCreateFinish(savedInstanceState); super.onCreateFinish(savedInstanceState);
...@@ -101,7 +101,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen ...@@ -101,7 +101,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
NotificationCenter.getInstance().addObserver(this, 703); NotificationCenter.getInstance().addObserver(this, 703);
if (fragmentsStack.isEmpty()) { if (fragmentsStack.isEmpty()) {
if (!UserConfig.clientActivated) { if (!UserConfig.isClientActivated()) {
addFragmentToStack(new LoginActivity()); addFragmentToStack(new LoginActivity());
} else { } else {
addFragmentToStack(new MessagesActivity(null)); addFragmentToStack(new MessagesActivity(null));
...@@ -417,7 +417,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen ...@@ -417,7 +417,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
} }
if (push_user_id != 0) { if (push_user_id != 0) {
if (push_user_id == UserConfig.clientUserId) { if (push_user_id == UserConfig.getClientUserId()) {
open_settings = 1; open_settings = 1;
} else { } else {
Bundle args = new Bundle(); Bundle args = new Bundle();
......
...@@ -10,6 +10,7 @@ package org.telegram.ui; ...@@ -10,6 +10,7 @@ package org.telegram.ui;
import android.animation.Animator; import android.animation.Animator;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
...@@ -34,6 +35,7 @@ import java.util.Set; ...@@ -34,6 +35,7 @@ import java.util.Set;
public class LoginActivity extends BaseFragment implements SlideView.SlideViewDelegate { public class LoginActivity extends BaseFragment implements SlideView.SlideViewDelegate {
private int currentViewNum = 0; private int currentViewNum = 0;
private SlideView[] views = new SlideView[3]; private SlideView[] views = new SlideView[3];
private ProgressDialog progressDialog;
private final static int done_button = 1; private final static int done_button = 1;
...@@ -205,29 +207,38 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe ...@@ -205,29 +207,38 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe
@Override @Override
public void needShowAlert(final String text) { public void needShowAlert(final String text) {
if (text == null) { if (text == null || getParentActivity() == null) {
return; return;
} }
getParentActivity().runOnUiThread(new Runnable() { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
@Override builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
public void run() { builder.setMessage(text);
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); showAlertDialog(builder);
builder.setMessage(text);
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showAlertDialog(builder);
}
});
} }
@Override @Override
public void needShowProgress() { public void needShowProgress() {
Utilities.ShowProgressDialog(getParentActivity(), LocaleController.getString("Loading", R.string.Loading)); if (getParentActivity() == null || getParentActivity().isFinishing() || progressDialog != null) {
return;
}
progressDialog = new ProgressDialog(getParentActivity());
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.show();
} }
@Override @Override
public void needHideProgress() { public void needHideProgress() {
Utilities.HideProgressDialog(getParentActivity()); if (progressDialog == null) {
return;
}
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} }
public void setPage(int page, boolean animated, Bundle params, boolean back) { public void setPage(int page, boolean animated, Bundle params, boolean back) {
......
...@@ -57,6 +57,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI ...@@ -57,6 +57,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
private boolean ignoreSelection = false; private boolean ignoreSelection = false;
private boolean ignoreOnTextChange = false; private boolean ignoreOnTextChange = false;
private boolean ignoreOnPhoneChange = false; private boolean ignoreOnPhoneChange = false;
private boolean nextPressed = false;
public LoginActivityPhoneView(Context context) { public LoginActivityPhoneView(Context context) {
super(context); super(context);
...@@ -319,6 +320,9 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI ...@@ -319,6 +320,9 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
@Override @Override
public void onNextPressed() { public void onNextPressed() {
if (nextPressed) {
return;
}
if (countryState == 1) { if (countryState == 1) {
delegate.needShowAlert(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); delegate.needShowAlert(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
return; return;
...@@ -345,48 +349,47 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI ...@@ -345,48 +349,47 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
final Bundle params = new Bundle(); final Bundle params = new Bundle();
params.putString("phone", "+" + codeField.getText() + phoneField.getText()); params.putString("phone", "+" + codeField.getText() + phoneField.getText());
params.putString("phoneFormated", phone); params.putString("phoneFormated", phone);
nextPressed = true;
delegate.needShowProgress(); delegate.needShowProgress();
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(final TLObject response, final TLRPC.TL_error error) {
if (error == null) { Utilities.RunOnUIThread(new Runnable() {
final TLRPC.TL_auth_sentCode res = (TLRPC.TL_auth_sentCode)response; @Override
params.putString("phoneHash", res.phone_code_hash); public void run() {
params.putInt("calltime", res.send_call_timeout * 1000); nextPressed = false;
if (res.phone_registered) { if (error == null) {
params.putString("registered", "true"); final TLRPC.TL_auth_sentCode res = (TLRPC.TL_auth_sentCode)response;
} params.putString("phoneHash", res.phone_code_hash);
Utilities.RunOnUIThread(new Runnable() { params.putInt("calltime", res.send_call_timeout * 1000);
@Override if (res.phone_registered) {
public void run() { params.putString("registered", "true");
}
if (delegate != null) { if (delegate != null) {
delegate.setPage(1, true, params, false); delegate.setPage(1, true, params, false);
} }
} } else {
}); if (delegate != null && error.text != null) {
} else { if (error.text.contains("PHONE_NUMBER_INVALID")) {
if (delegate != null) { delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
if (error.text != null) { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
if (error.text.contains("PHONE_NUMBER_INVALID")) { delegate.needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode));
delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { delegate.needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired));
delegate.needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode)); } else if (error.text.startsWith("FLOOD_WAIT")) {
} else if (error.text.contains("PHONE_CODE_EXPIRED")) { delegate.needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait));
delegate.needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired)); } else {
} else if (error.text.contains("FLOOD_WAIT")) { delegate.needShowAlert(error.text);
delegate.needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait)); }
} else {
delegate.needShowAlert(error.text);
} }
} }
if (delegate != null) {
delegate.needHideProgress();
}
} }
} });
if (delegate != null) {
delegate.needHideProgress();
}
} }
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
} }
@Override @Override
......
...@@ -39,6 +39,7 @@ public class LoginActivityRegisterView extends SlideView { ...@@ -39,6 +39,7 @@ public class LoginActivityRegisterView extends SlideView {
private String phoneHash; private String phoneHash;
private String phoneCode; private String phoneCode;
private Bundle currentParams; private Bundle currentParams;
private boolean nextPressed = false;
public LoginActivityRegisterView(Context context) { public LoginActivityRegisterView(Context context) {
super(context); super(context);
...@@ -122,32 +123,37 @@ public class LoginActivityRegisterView extends SlideView { ...@@ -122,32 +123,37 @@ public class LoginActivityRegisterView extends SlideView {
@Override @Override
public void onNextPressed() { public void onNextPressed() {
if (nextPressed) {
return;
}
nextPressed = true;
TLRPC.TL_auth_signUp req = new TLRPC.TL_auth_signUp(); TLRPC.TL_auth_signUp req = new TLRPC.TL_auth_signUp();
req.phone_code = phoneCode; req.phone_code = phoneCode;
req.phone_code_hash = phoneHash; req.phone_code_hash = phoneHash;
req.phone_number = requestPhone; req.phone_number = requestPhone;
req.first_name = firstNameField.getText().toString(); req.first_name = firstNameField.getText().toString();
req.last_name = lastNameField.getText().toString(); req.last_name = lastNameField.getText().toString();
delegate.needShowProgress(); if (delegate != null) {
delegate.needShowProgress();
}
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(final TLObject response, final TLRPC.TL_error error) {
if (delegate != null) { Utilities.RunOnUIThread(new Runnable() {
delegate.needHideProgress(); @Override
} public void run() {
if (error == null) { nextPressed = false;
final TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response; if (delegate != null) {
Utilities.RunOnUIThread(new Runnable() { delegate.needHideProgress();
@Override }
public void run() { if (error == null) {
final TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response;
TLRPC.TL_userSelf user = (TLRPC.TL_userSelf)res.user; TLRPC.TL_userSelf user = (TLRPC.TL_userSelf)res.user;
UserConfig.clearConfig(); UserConfig.clearConfig();
MessagesStorage.getInstance().cleanUp(); MessagesStorage.getInstance().cleanUp();
MessagesController.getInstance().cleanUp(); MessagesController.getInstance().cleanUp();
ConnectionsManager.getInstance().cleanUp(); ConnectionsManager.getInstance().cleanUp();
UserConfig.currentUser = user; UserConfig.setCurrentUser(user);
UserConfig.clientActivated = true;
UserConfig.clientUserId = user.id;
UserConfig.saveConfig(true); 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);
...@@ -159,27 +165,27 @@ public class LoginActivityRegisterView extends SlideView { ...@@ -159,27 +165,27 @@ public class LoginActivityRegisterView extends SlideView {
delegate.needFinishActivity(); delegate.needFinishActivity();
} }
ConnectionsManager.getInstance().initPushConnection(); ConnectionsManager.getInstance().initPushConnection();
}
});
} else {
if (delegate != null) {
if (error.text.contains("PHONE_NUMBER_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) {
delegate.needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired));
} else if (error.text.contains("FIRSTNAME_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidFirstName", R.string.InvalidFirstName));
} else if (error.text.contains("LASTNAME_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidLastName", R.string.InvalidLastName));
} else { } else {
delegate.needShowAlert(error.text); if (delegate != null) {
if (error.text.contains("PHONE_NUMBER_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) {
delegate.needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired));
} else if (error.text.contains("FIRSTNAME_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidFirstName", R.string.InvalidFirstName));
} else if (error.text.contains("LASTNAME_INVALID")) {
delegate.needShowAlert(LocaleController.getString("InvalidLastName", R.string.InvalidLastName));
} else {
delegate.needShowAlert(error.text);
}
}
} }
} }
} });
} }
}, null, true, RPCRequest.RPCRequestClassGeneric); }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin);
} }
@Override @Override
......
...@@ -324,7 +324,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -324,7 +324,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (which == 0) { if (which == 0) {
MessagesController.getInstance().deleteDialog(selectedDialog, 0, true); MessagesController.getInstance().deleteDialog(selectedDialog, 0, true);
} else if (which == 1) { } else if (which == 1) {
MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().users.get(UserConfig.clientUserId), null); MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().users.get(UserConfig.getClientUserId()), null);
MessagesController.getInstance().deleteDialog(selectedDialog, 0, false); MessagesController.getInstance().deleteDialog(selectedDialog, 0, false);
} }
} }
......
...@@ -1038,7 +1038,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -1038,7 +1038,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (messageObject.messageOwner.to_id.chat_id != 0) { if (messageObject.messageOwner.to_id.chat_id != 0) {
currentDialogId = -messageObject.messageOwner.to_id.chat_id; currentDialogId = -messageObject.messageOwner.to_id.chat_id;
} else { } else {
if (messageObject.messageOwner.to_id.user_id == UserConfig.clientUserId) { if (messageObject.messageOwner.to_id.user_id == UserConfig.getClientUserId()) {
currentDialogId = messageObject.messageOwner.from_id; currentDialogId = messageObject.messageOwner.from_id;
} else { } else {
currentDialogId = messageObject.messageOwner.to_id.user_id; currentDialogId = messageObject.messageOwner.to_id.user_id;
...@@ -1076,7 +1076,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -1076,7 +1076,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (messageObject.messageOwner.to_id.chat_id != 0) { if (messageObject.messageOwner.to_id.chat_id != 0) {
currentDialogId = -messageObject.messageOwner.to_id.chat_id; currentDialogId = -messageObject.messageOwner.to_id.chat_id;
} else { } else {
if (messageObject.messageOwner.to_id.user_id == UserConfig.clientUserId) { if (messageObject.messageOwner.to_id.user_id == UserConfig.getClientUserId()) {
currentDialogId = messageObject.messageOwner.from_id; currentDialogId = messageObject.messageOwner.from_id;
} else { } else {
currentDialogId = messageObject.messageOwner.to_id.user_id; currentDialogId = messageObject.messageOwner.to_id.user_id;
......
...@@ -127,15 +127,15 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -127,15 +127,15 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) { if (error == null) {
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
user = UserConfig.currentUser; user = UserConfig.getCurrentUser();
if (user == null) { if (user == null) {
return; return;
} }
MessagesController.getInstance().users.put(user.id, user); MessagesController.getInstance().users.put(user.id, user);
} else { } else {
UserConfig.currentUser = user; UserConfig.setCurrentUser(user);
} }
if (user == null) { if (user == null) {
return; return;
...@@ -418,7 +418,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -418,7 +418,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (fileLocation == null) { if (fileLocation == null) {
return null; return null;
} }
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user != null && user.photo != null && user.photo.photo_big != null) { if (user != null && user.photo != null && user.photo.photo_big != null) {
TLRPC.FileLocation photoBig = user.photo.photo_big; TLRPC.FileLocation photoBig = user.photo.photo_big;
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) { if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
...@@ -434,7 +434,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -434,7 +434,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
object.viewY = coords[1] - Utilities.statusBarHeight; object.viewY = coords[1] - Utilities.statusBarHeight;
object.parentView = listView; object.parentView = listView;
object.imageReceiver = avatarImage.imageReceiver; object.imageReceiver = avatarImage.imageReceiver;
object.user_id = UserConfig.clientUserId; object.user_id = UserConfig.getClientUserId();
object.thumb = object.imageReceiver.getBitmap(); object.thumb = object.imageReceiver.getBitmap();
object.size = -1; object.size = -1;
return object; return object;
...@@ -671,9 +671,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -671,9 +671,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
CharSequence[] items; CharSequence[] items;
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
user = UserConfig.currentUser; user = UserConfig.getCurrentUser();
} }
if (user == null) { if (user == null) {
return; return;
...@@ -691,7 +691,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -691,7 +691,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0 && full) { if (i == 0 && full) {
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user != null && user.photo != null && user.photo.photo_big != null) { if (user != null && user.photo != null && user.photo.photo_big != null) {
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this); PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this);
} }
...@@ -703,28 +703,28 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -703,28 +703,28 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
TLRPC.TL_photos_updateProfilePhoto req = new TLRPC.TL_photos_updateProfilePhoto(); TLRPC.TL_photos_updateProfilePhoto req = new TLRPC.TL_photos_updateProfilePhoto();
req.id = new TLRPC.TL_inputPhotoEmpty(); req.id = new TLRPC.TL_inputPhotoEmpty();
req.crop = new TLRPC.TL_inputPhotoCropAuto(); req.crop = new TLRPC.TL_inputPhotoCropAuto();
UserConfig.currentUser.photo = new TLRPC.TL_userProfilePhotoEmpty(); UserConfig.getCurrentUser().photo = new TLRPC.TL_userProfilePhotoEmpty();
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
user = UserConfig.currentUser; user = UserConfig.getCurrentUser();
} }
if (user == null) { if (user == null) {
return; return;
} }
if (user != null) { if (user != null) {
user.photo = UserConfig.currentUser.photo; user.photo = UserConfig.getCurrentUser().photo;
} }
NotificationCenter.getInstance().postNotificationName(MessagesController.updateInterfaces, MessagesController.UPDATE_MASK_ALL); NotificationCenter.getInstance().postNotificationName(MessagesController.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) { if (error == null) {
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
user = UserConfig.currentUser; user = UserConfig.getCurrentUser();
MessagesController.getInstance().users.put(user.id, user); MessagesController.getInstance().users.put(user.id, user);
} else { } else {
UserConfig.currentUser = user; UserConfig.setCurrentUser(user);
} }
if (user == null) { if (user == null) {
return; return;
...@@ -757,9 +757,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -757,9 +757,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
textView = (TextView)view.findViewById(R.id.settings_name); textView = (TextView)view.findViewById(R.id.settings_name);
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf"); Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
textView.setTypeface(typeface); textView.setTypeface(typeface);
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
user = UserConfig.currentUser; user = UserConfig.getCurrentUser();
} }
if (user != null) { if (user != null) {
textView.setText(Utilities.formatName(user.first_name, user.last_name)); textView.setText(Utilities.formatName(user.first_name, user.last_name));
...@@ -804,7 +804,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -804,7 +804,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
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 == numberRow) { if (i == numberRow) {
TLRPC.User user = UserConfig.currentUser; TLRPC.User user = UserConfig.getCurrentUser();
if (user != null && user.phone != null && user.phone.length() != 0) { if (user != null && user.phone != null && user.phone.length() != 0) {
textView.setText(PhoneFormat.getInstance().format("+" + user.phone)); textView.setText(PhoneFormat.getInstance().format("+" + user.phone));
} else { } else {
...@@ -898,10 +898,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -898,10 +898,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
NotificationCenter.getInstance().postNotificationName(1234); NotificationCenter.getInstance().postNotificationName(1234);
MessagesController.getInstance().unregistedPush(); MessagesController.getInstance().unregistedPush();
MessagesController.getInstance().logOut();
UserConfig.clearConfig();
MessagesStorage.getInstance().cleanUp(); MessagesStorage.getInstance().cleanUp();
MessagesController.getInstance().cleanUp(); MessagesController.getInstance().cleanUp();
ConnectionsManager.getInstance().cleanUp();
UserConfig.clearConfig();
} }
}); });
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
......
...@@ -65,9 +65,9 @@ public class SettingsChangeNameActivity extends BaseFragment { ...@@ -65,9 +65,9 @@ public class SettingsChangeNameActivity extends BaseFragment {
fragmentView = inflater.inflate(R.layout.settings_change_name_layout, container, false); fragmentView = inflater.inflate(R.layout.settings_change_name_layout, container, false);
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user == null) { if (user == null) {
user = UserConfig.currentUser; user = UserConfig.getCurrentUser();
} }
firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field); firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field);
...@@ -126,12 +126,12 @@ public class SettingsChangeNameActivity extends BaseFragment { ...@@ -126,12 +126,12 @@ public class SettingsChangeNameActivity extends BaseFragment {
private void saveName() { private void saveName() {
TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile(); TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile();
if (UserConfig.currentUser == null || lastNameField.getText() == null || firstNameField.getText() == null) { if (UserConfig.getCurrentUser() == null || lastNameField.getText() == null || firstNameField.getText() == null) {
return; return;
} }
UserConfig.currentUser.first_name = req.first_name = firstNameField.getText().toString(); UserConfig.getCurrentUser().first_name = req.first_name = firstNameField.getText().toString();
UserConfig.currentUser.last_name = req.last_name = lastNameField.getText().toString(); UserConfig.getCurrentUser().last_name = req.last_name = lastNameField.getText().toString();
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId); TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
if (user != null) { if (user != null) {
user.first_name = req.first_name; user.first_name = req.first_name;
user.last_name = req.last_name; user.last_name = req.last_name;
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<string name="NoFiles">لا يوجد ملفات بعد...</string> <string name="NoFiles">لا يوجد ملفات بعد...</string>
<string name="FileUploadLimit">حجم الملف لا يمكن أن يكون أكبر من %1$s</string> <string name="FileUploadLimit">حجم الملف لا يمكن أن يكون أكبر من %1$s</string>
<string name="NotMounted">الذاكرة غير مثبتة</string> <string name="NotMounted">الذاكرة غير مثبتة</string>
<string name="UsbActive">نقل اليو إس بي مفعل</string> <string name="UsbActive">نقل USB مفعل</string>
<string name="InternalStorage">الذاكرة الداخلية</string> <string name="InternalStorage">الذاكرة الداخلية</string>
<string name="ExternalStorage">الذاكرة الخارجية</string> <string name="ExternalStorage">الذاكرة الخارجية</string>
<string name="SystemRoot">جذر النظام</string> <string name="SystemRoot">جذر النظام</string>
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
<string name="Message">الرسالة</string> <string name="Message">الرسالة</string>
<string name="TypeMessage">أكتب رسالة</string> <string name="TypeMessage">أكتب رسالة</string>
<string name="DOWNLOAD">تحميل</string> <string name="DOWNLOAD">تحميل</string>
<string name="Selected">محددة: %d</string> <string name="Selected">تم تحديد : %d</string>
<string name="ShareMyContactInfo">شارك جهة الاتصال الخاصة بي</string> <string name="ShareMyContactInfo">شارك جهة الاتصال الخاصة بي</string>
<string name="AddToContacts">أضف لجهات الاتصال</string> <string name="AddToContacts">أضف لجهات الاتصال</string>
<string name="EncryptedPlaceholderTitleIncoming">%s قام بدعوتك لمحادثة سرية</string> <string name="EncryptedPlaceholderTitleIncoming">%s قام بدعوتك لمحادثة سرية</string>
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<string name="FewNewMessages">%1$d رسائل جديدة</string> <string name="FewNewMessages">%1$d رسائل جديدة</string>
<string name="YouWereKicked">لقد تم إخراجك من هذه المجموعة</string> <string name="YouWereKicked">لقد تم إخراجك من هذه المجموعة</string>
<string name="YouLeft">لقد قمت بمغادرة المجموعة</string> <string name="YouLeft">لقد قمت بمغادرة المجموعة</string>
<string name="DeleteThisGroup">حذف المجموعة</string> <string name="DeleteThisGroup">حذف هذه المجموعة</string>
<string name="DeleteThisChat">حذف هذه الدردشة</string> <string name="DeleteThisChat">حذف هذه الدردشة</string>
<string name="SlideToCancel">قم بالسحب للإلغاء</string> <string name="SlideToCancel">قم بالسحب للإلغاء</string>
<string name="SaveToDownloads">حفظ في الجهاز</string> <string name="SaveToDownloads">حفظ في الجهاز</string>
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<string name="NotificationMessagePhoto">%1$s قام بإرسال صورة لك</string> <string name="NotificationMessagePhoto">%1$s قام بإرسال صورة لك</string>
<string name="NotificationMessageVideo">%1$s قام بإرسال مقطع مرئي لك</string> <string name="NotificationMessageVideo">%1$s قام بإرسال مقطع مرئي لك</string>
<string name="NotificationMessageContact">%1$s قام بإرسال جهة اتصال لك</string> <string name="NotificationMessageContact">%1$s قام بإرسال جهة اتصال لك</string>
<string name="NotificationMessageMap">%1$s قام بإرسال خريطة لك</string> <string name="NotificationMessageMap">%1$s قام بإرسال موقع لك</string>
<string name="NotificationMessageDocument">%1$s قام بإرسال مستند لك</string> <string name="NotificationMessageDocument">%1$s قام بإرسال مستند لك</string>
<string name="NotificationMessageAudio">%1$s قام بإرسال مقطع صوتي لك</string> <string name="NotificationMessageAudio">%1$s قام بإرسال مقطع صوتي لك</string>
<string name="NotificationMessageGroupText">%1$s @ %2$s: %3$s</string> <string name="NotificationMessageGroupText">%1$s @ %2$s: %3$s</string>
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
<string name="NotificationMessageGroupPhoto">%1$s قام بإرسال صورة للمجموعة %2$s</string> <string name="NotificationMessageGroupPhoto">%1$s قام بإرسال صورة للمجموعة %2$s</string>
<string name="NotificationMessageGroupVideo">%1$s قام بإرسال مقطع مرئي للمجموعة %2$s</string> <string name="NotificationMessageGroupVideo">%1$s قام بإرسال مقطع مرئي للمجموعة %2$s</string>
<string name="NotificationMessageGroupContact">%1$s قام بإرسال جهة اتصال للمجموعة %2$s</string> <string name="NotificationMessageGroupContact">%1$s قام بإرسال جهة اتصال للمجموعة %2$s</string>
<string name="NotificationMessageGroupMap">%1$s قام بإرسال خريطة للمجموعة %2$s</string> <string name="NotificationMessageGroupMap">%1$s قام بإرسال موقع للمجموعة %2$s</string>
<string name="NotificationMessageGroupDocument">%1$s قام بإرسال مستند للمجموعة %2$s</string> <string name="NotificationMessageGroupDocument">%1$s قام بإرسال مستند للمجموعة %2$s</string>
<string name="NotificationMessageGroupAudio">%1$s قام بإرسال مقطع صوتي للمجموعة %2$s</string> <string name="NotificationMessageGroupAudio">%1$s قام بإرسال مقطع صوتي للمجموعة %2$s</string>
<string name="NotificationInvitedToGroup">%1$s قام بدعوتك للمجموعة %2$s</string> <string name="NotificationInvitedToGroup">%1$s قام بدعوتك للمجموعة %2$s</string>
...@@ -250,14 +250,14 @@ ...@@ -250,14 +250,14 @@
<string name="SendByEnter">أرسل بزر الإدخال</string> <string name="SendByEnter">أرسل بزر الإدخال</string>
<string name="TerminateAllSessions">سجل الخروج من كافة الأجهزة الأخرى</string> <string name="TerminateAllSessions">سجل الخروج من كافة الأجهزة الأخرى</string>
<string name="AutomaticPhotoDownload">تنزيل الصور تلقائيًا</string> <string name="AutomaticPhotoDownload">تنزيل الصور تلقائيًا</string>
<string name="AutomaticAudioDownload">تنزيل رسائل الصوت تلقائيا</string> <string name="AutomaticAudioDownload">تنزيل رسائل الصوت تلقائياً</string>
<string name="AutomaticPhotoDownloadGroups">المجموعات</string> <string name="AutomaticPhotoDownloadGroups">المجموعات</string>
<string name="AutomaticPhotoDownloadPrivateChats">المحادثات</string> <string name="AutomaticPhotoDownloadPrivateChats">المحادثات</string>
<string name="Events">الأحداث</string> <string name="Events">الأحداث</string>
<string name="ContactJoined">اشترك صديق في تيليجرام</string> <string name="ContactJoined">اشترك صديق في تيليجرام</string>
<string name="Pebble">PEBBLE</string> <string name="Pebble">PEBBLE</string>
<string name="Language">اللغة</string> <string name="Language">اللغة</string>
<string name="AskAQuestionInfo">نرجو الأخذ بالعلم أن الدعم الفني في تيليجرام يقوم به مجموعة من المتطوعين. نحاول الرد بسرعة قدر المستطاع، لكن ربما نستغرق القليل من الوقت.<![CDATA[<br><br>]]>يرجى الإطلاع على <![CDATA[<a href="http://telegram.org/faq/ar">صفحة الأسئلة الأكثر شيوعًا</a>]]>: يوجد بها حلول للمشاكل وإجابات لمعظم الأسئلة.</string> <string name="AskAQuestionInfo">نرجو الأخذ بالعلم أن الدعم الفني في تيليجرام يقوم به مجموعة من المتطوعين. نحاول الرد بسرعة قدر المستطاع، لكن ربما نستغرق القليل من الوقت.<![CDATA[<br><br>]]>يرجى الإطلاع على <![CDATA[<a href="http://telegram.org/faq/ar">الأسئلة الشائعة عن تيليجرام</a>]]>: يوجد بها حلول للمشاكل وإجابات لمعظم الأسئلة.</string>
<string name="AskButton">اسأل أحد المتطوعين</string> <string name="AskButton">اسأل أحد المتطوعين</string>
<string name="TelegramFaq">الأسئلة الشائعة عن تيليجرام</string> <string name="TelegramFaq">الأسئلة الشائعة عن تيليجرام</string>
<string name="TelegramFaqUrl">https://telegram.org/faq/ar</string> <string name="TelegramFaqUrl">https://telegram.org/faq/ar</string>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
<string name="Enabled">تمكين</string> <string name="Enabled">تمكين</string>
<string name="Disabled">تعطيل</string> <string name="Disabled">تعطيل</string>
<string name="NotificationsService">خدمة الإشعارات</string> <string name="NotificationsService">خدمة الإشعارات</string>
<string name="NotificationsServiceDisableInfo">إذا كانت خدمات Google play كافية بالنسبة لك لتلقي الإشعارات ، يمكنك تعطيل " خدمة الإشعارات " . ومع ذلك نحن نوصي بترك هذه الخدمة مفعلة للحفاظ على تشغيل التطبيق في الخلفية ، ولتلقي إشعارات الدردشة .</string> <string name="NotificationsServiceDisableInfo">إذا كانت خدمات Google play كافية بالنسبة لك لتلقي الإشعارات ، يمكنك تعطيل \" خدمة الإشعارات \" . ومع ذلك نحن نوصي بترك هذه الخدمة مفعلة للحفاظ على تشغيل التطبيق في الخلفية ، ولتلقي إشعارات الدردشة .</string>
<string name="SortBy">فرز حسب</string> <string name="SortBy">فرز حسب</string>
<string name="ImportContacts">استيراد جهات الاتصال</string> <string name="ImportContacts">استيراد جهات الاتصال</string>
<string name="WiFiOnly">بواسطة WiFi فقط</string> <string name="WiFiOnly">بواسطة WiFi فقط</string>
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
<string name="OK">موافق</string> <string name="OK">موافق</string>
<!--messages--> <!--messages-->
<string name="ActionKickUser">un1 قام بإخراج un2</string> <string name="ActionKickUser">un1 أزال un2</string>
<string name="ActionLeftUser">غادر المجموعة العضو un1</string> <string name="ActionLeftUser">غادر المجموعة العضو un1</string>
<string name="ActionAddUser">un1 قام بإضافة un2</string> <string name="ActionAddUser">un1 قام بإضافة un2</string>
<string name="ActionRemovedPhoto">تمت إزالة صورة المجموعة من قِبَل un1</string> <string name="ActionRemovedPhoto">تمت إزالة صورة المجموعة من قِبَل un1</string>
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
<string name="ActionYouCreateGroup">لقد قمت بإنشاء المجموعة</string> <string name="ActionYouCreateGroup">لقد قمت بإنشاء المجموعة</string>
<string name="ActionKickUserYou">un1 قام بإخراجك</string> <string name="ActionKickUserYou">un1 قام بإخراجك</string>
<string name="ActionAddUserYou">un1 قام بإضافتك</string> <string name="ActionAddUserYou">un1 قام بإضافتك</string>
<string name="UnsuppotedMedia">نسخة تيليجرام التي تستخدمها لا تدعم هذه الرسالة</string> <string name="UnsuppotedMedia">نسخة تيليجرام الموجودة لديك لا تدعم هذه الرسالة. الرجاء التحديث لأحدث نسخة:\nhttp://telegram.org/update</string>
<string name="AttachPhoto">صورة</string> <string name="AttachPhoto">صورة</string>
<string name="AttachVideo">مقطع مرئي</string> <string name="AttachVideo">مقطع مرئي</string>
<string name="AttachLocation">موقع</string> <string name="AttachLocation">موقع</string>
...@@ -356,10 +356,10 @@ ...@@ -356,10 +356,10 @@
<string name="NoHandleAppInstalled">لا يوجد لديك تطبيق يمكنه فتح \'%1$s\'، يرجى تنزيل تطبيق مناسب للإستمرار</string> <string name="NoHandleAppInstalled">لا يوجد لديك تطبيق يمكنه فتح \'%1$s\'، يرجى تنزيل تطبيق مناسب للإستمرار</string>
<string name="InviteUser">هذا المستخدم ليس لديه تيليجرام بعد ، هل ترغب في دعوته الآن؟</string> <string name="InviteUser">هذا المستخدم ليس لديه تيليجرام بعد ، هل ترغب في دعوته الآن؟</string>
<string name="AreYouSure">هل أنت متأكد؟</string> <string name="AreYouSure">هل أنت متأكد؟</string>
<string name="DeleteChatQuestion">هل تريد حذف هذه الدردشة؟</string>
<string name="AddContactQ">هل تريد إضافة جهة اتصال؟</string> <string name="AddContactQ">هل تريد إضافة جهة اتصال؟</string>
<string name="AddToTheGroup">إلى المجموعة؟ %1$s هل تريد إضافة</string> <string name="AddToTheGroup">إلى المجموعة؟ %1$s هل تريد إضافة</string>
<string name="ForwardMessagesTo">؟%1$s هل تريد إعادة توجيه الرسائل إلى</string> <string name="ForwardMessagesTo">؟%1$s هل تريد إعادة توجيه الرسائل إلى</string>
<string name="DeleteChatQuestion">هل تريد حذف هذه الدردشة؟</string>
<!--Intro view--> <!--Intro view-->
<string name="Page1Title">تيليجرام</string> <string name="Page1Title">تيليجرام</string>
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
<string name="Message">Messaggio</string> <string name="Message">Messaggio</string>
<string name="TypeMessage">Scrivi il messaggio</string> <string name="TypeMessage">Scrivi il messaggio</string>
<string name="DOWNLOAD">Scarica</string> <string name="DOWNLOAD">Scarica</string>
<string name="Selected">Selezionato: %d</string> <string name="Selected">Selezionati: %d</string>
<string name="ShareMyContactInfo">CONDIVIDI LE MIE INFORMAZIONI DI CONTATTO</string> <string name="ShareMyContactInfo">CONDIVIDI LE MIE INFORMAZIONI DI CONTATTO</string>
<string name="AddToContacts">AGGIUNGI AI CONTATTI</string> <string name="AddToContacts">AGGIUNGI AI CONTATTI</string>
<string name="EncryptedPlaceholderTitleIncoming">%s ti ha mandato un invito a una chat privata.</string> <string name="EncryptedPlaceholderTitleIncoming">%s ti ha mandato un invito a una chat privata.</string>
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
<string name="NotificationsServiceDisableInfo">Se i servizi di Google Play ti bastano per ricevere le notifiche, puoi disabilitare il Servizio notifiche. Tuttavia sarebbe meglio lasciarlo abilitato al fine di mantenere l\'applicazione attiva in background e ricevere notifiche istantanee.</string> <string name="NotificationsServiceDisableInfo">Se i servizi di Google Play ti bastano per ricevere le notifiche, puoi disabilitare il Servizio notifiche. Tuttavia sarebbe meglio lasciarlo abilitato al fine di mantenere l\'applicazione attiva in background e ricevere notifiche istantanee.</string>
<string name="SortBy">Ordina per</string> <string name="SortBy">Ordina per</string>
<string name="ImportContacts">Importa contatti</string> <string name="ImportContacts">Importa contatti</string>
<string name="WiFiOnly">solo tramite WiFi</string> <string name="WiFiOnly">Solo tramite WiFi</string>
<string name="SortFirstName">Nome</string> <string name="SortFirstName">Nome</string>
<string name="SortLastName">Cognome</string> <string name="SortLastName">Cognome</string>
...@@ -292,8 +292,8 @@ ...@@ -292,8 +292,8 @@
<string name="SaveToGallery">Salva nella galleria</string> <string name="SaveToGallery">Salva nella galleria</string>
<string name="Of">%1$d di %2$d</string> <string name="Of">%1$d di %2$d</string>
<string name="Gallery">Galleria</string> <string name="Gallery">Galleria</string>
<string name="AllPhotos">All Photos</string> <string name="AllPhotos">Tutte le foto</string>
<string name="NoPhotos">No photos yet</string> <string name="NoPhotos">Ancora nessuna foto</string>
<!--button titles--> <!--button titles-->
<string name="Next">Avanti</string> <string name="Next">Avanti</string>
......
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