mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Optimized battery consumption, fixed blurry photos on some devices, added option to auto download media only via WiFi, changed way of contacts changes monitoring
https://github.com/DrKLO/Telegram/pull/422 https://github.com/rubenlagus/Telegram/commit/d96ce3c140bd49c5c8c63cea2b c9afad8a16b8bb
This commit is contained in:
parent
f68ace0fd6
commit
644fc7ccea
27 changed files with 457 additions and 301 deletions
|
@ -82,7 +82,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 231
|
||||
versionName "1.4.13"
|
||||
versionCode 233
|
||||
versionName "1.4.14"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class PyroSelector {
|
|||
}
|
||||
|
||||
public void select() {
|
||||
this.select(10);
|
||||
this.select(0);
|
||||
}
|
||||
|
||||
public void select(long eventTimeout) {
|
||||
|
|
|
@ -42,18 +42,18 @@ public class BuffersStorage {
|
|||
for (int a = 0; a < 5; a++) {
|
||||
freeBuffers128.add(new ByteBufferDesc(128));
|
||||
}
|
||||
for (int a = 0; a < 5; a++) {
|
||||
freeBuffers1024.add(new ByteBufferDesc(1024 + 200));
|
||||
}
|
||||
for (int a = 0; a < 2; a++) {
|
||||
freeBuffers4096.add(new ByteBufferDesc(4096 + 200));
|
||||
}
|
||||
for (int a = 0; a < 2; a++) {
|
||||
freeBuffers16384.add(new ByteBufferDesc(16384 + 200));
|
||||
}
|
||||
for (int a = 0; a < 2; a++) {
|
||||
freeBuffers32768.add(new ByteBufferDesc(40000));
|
||||
}
|
||||
// for (int a = 0; a < 5; a++) {
|
||||
// freeBuffers1024.add(new ByteBufferDesc(1024 + 200));
|
||||
// }
|
||||
// for (int a = 0; a < 2; a++) {
|
||||
// freeBuffers4096.add(new ByteBufferDesc(4096 + 200));
|
||||
// }
|
||||
// for (int a = 0; a < 2; a++) {
|
||||
// freeBuffers16384.add(new ByteBufferDesc(16384 + 200));
|
||||
// }
|
||||
// for (int a = 0; a < 2; a++) {
|
||||
// freeBuffers32768.add(new ByteBufferDesc(40000));
|
||||
// }
|
||||
}
|
||||
|
||||
public ByteBufferDesc getFreeBuffer(int size) {
|
||||
|
|
|
@ -23,8 +23,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -64,8 +62,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
private boolean registeringForPush = false;
|
||||
|
||||
private boolean paused = false;
|
||||
private Runnable stageRunnable;
|
||||
private Runnable pingRunnable;
|
||||
private long lastPingTime = System.currentTimeMillis();
|
||||
private long lastPushPingTime = System.currentTimeMillis();
|
||||
private int nextSleepTimeout = 30000;
|
||||
|
@ -84,6 +80,89 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
return localInstance;
|
||||
}
|
||||
|
||||
static long t = System.currentTimeMillis();
|
||||
private Runnable stageRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.stageQueue.handler.removeCallbacks(stageRunnable);
|
||||
t = System.currentTimeMillis();
|
||||
if (datacenters != null) {
|
||||
if (lastPushPingTime < System.currentTimeMillis() - 29000) {
|
||||
lastPushPingTime = System.currentTimeMillis();
|
||||
Datacenter datacenter = datacenterWithId(currentDatacenterId);
|
||||
if (datacenter != null) {
|
||||
generatePing(datacenter, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (ApplicationLoader.lastPauseTime != 0 && ApplicationLoader.lastPauseTime < currentTime - nextSleepTimeout) {
|
||||
boolean dontSleep = false;
|
||||
for (RPCRequest request : runningRequests) {
|
||||
if (request.retryCount < 10 && (request.runningStartTime + 60 > (int)(currentTime / 1000)) && ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0)) {
|
||||
dontSleep = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!dontSleep) {
|
||||
for (RPCRequest request : requestQueue) {
|
||||
if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) {
|
||||
dontSleep = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dontSleep) {
|
||||
if (!paused) {
|
||||
FileLog.e("tmessages", "pausing network and timers by sleep time = " + nextSleepTimeout);
|
||||
for (Datacenter datacenter : datacenters.values()) {
|
||||
if (datacenter.connection != null) {
|
||||
datacenter.connection.suspendConnection(true);
|
||||
}
|
||||
if (datacenter.uploadConnection != null) {
|
||||
datacenter.uploadConnection.suspendConnection(true);
|
||||
}
|
||||
if (datacenter.downloadConnection != null) {
|
||||
datacenter.downloadConnection.suspendConnection(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
paused = true;
|
||||
Utilities.stageQueue.postRunnable(stageRunnable, 1000);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else {
|
||||
ApplicationLoader.lastPauseTime += 30 * 1000;
|
||||
FileLog.e("tmessages", "don't sleep 30 seconds because of upload or download request");
|
||||
}
|
||||
}
|
||||
if (paused) {
|
||||
paused = false;
|
||||
FileLog.e("tmessages", "resume network and timers");
|
||||
}
|
||||
|
||||
if (datacenters != null) {
|
||||
MessagesController.getInstance().updateTimerProc();
|
||||
if (datacenterWithId(currentDatacenterId).authKey != null) {
|
||||
if (lastPingTime < System.currentTimeMillis() - 19000) {
|
||||
lastPingTime = System.currentTimeMillis();
|
||||
generatePing();
|
||||
}
|
||||
if (!updatingDcSettings && lastDcUpdateTime < (int)(System.currentTimeMillis() / 1000) - DC_UPDATE_TIME) {
|
||||
updateDcSettings(0);
|
||||
}
|
||||
processRequestQueue(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Utilities.stageQueue.postRunnable(stageRunnable, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
public ConnectionsManager() {
|
||||
currentAppVersion = ApplicationLoader.getAppVersion();
|
||||
lastOutgoingMessageId = 0;
|
||||
|
@ -94,89 +173,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
connectionState = 1;
|
||||
}
|
||||
|
||||
Timer serviceTimer = new Timer();
|
||||
serviceTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (datacenters != null) {
|
||||
if (lastPushPingTime < System.currentTimeMillis() - 29000) {
|
||||
lastPushPingTime = System.currentTimeMillis();
|
||||
Datacenter datacenter = datacenterWithId(currentDatacenterId);
|
||||
if (datacenter != null) {
|
||||
generatePing(datacenter, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (ApplicationLoader.lastPauseTime != 0 && ApplicationLoader.lastPauseTime < currentTime - nextSleepTimeout) {
|
||||
boolean dontSleep = false;
|
||||
for (RPCRequest request : runningRequests) {
|
||||
if (request.retryCount < 10 && (request.runningStartTime + 60 > (int)(currentTime / 1000)) && ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0)) {
|
||||
dontSleep = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!dontSleep) {
|
||||
for (RPCRequest request : requestQueue) {
|
||||
if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) {
|
||||
dontSleep = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dontSleep) {
|
||||
if (!paused) {
|
||||
FileLog.e("tmessages", "pausing network and timers by sleep time = " + nextSleepTimeout);
|
||||
for (Datacenter datacenter : datacenters.values()) {
|
||||
if (datacenter.connection != null) {
|
||||
datacenter.connection.suspendConnection(true);
|
||||
}
|
||||
if (datacenter.uploadConnection != null) {
|
||||
datacenter.uploadConnection.suspendConnection(true);
|
||||
}
|
||||
if (datacenter.downloadConnection != null) {
|
||||
datacenter.downloadConnection.suspendConnection(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
paused = true;
|
||||
Thread.sleep(500);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else {
|
||||
ApplicationLoader.lastPauseTime += 30 * 1000;
|
||||
FileLog.e("tmessages", "don't sleep 30 seconds because of upload or download request");
|
||||
}
|
||||
}
|
||||
if (paused) {
|
||||
paused = false;
|
||||
FileLog.e("tmessages", "resume network and timers");
|
||||
}
|
||||
|
||||
if (datacenters != null) {
|
||||
MessagesController.getInstance().updateTimerProc();
|
||||
if (datacenterWithId(currentDatacenterId).authKey != null) {
|
||||
if (lastPingTime < System.currentTimeMillis() - 19000) {
|
||||
lastPingTime = System.currentTimeMillis();
|
||||
generatePing();
|
||||
}
|
||||
if (!updatingDcSettings && lastDcUpdateTime < (int)(System.currentTimeMillis() / 1000) - DC_UPDATE_TIME) {
|
||||
updateDcSettings(0);
|
||||
}
|
||||
processRequestQueue(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1000, 1000);
|
||||
Utilities.stageQueue.postRunnable(stageRunnable, 1000);
|
||||
}
|
||||
|
||||
public void resumeNetworkMaybe() {
|
||||
|
@ -196,6 +193,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
}
|
||||
|
||||
public void applicationMovedToForeground() {
|
||||
Utilities.stageQueue.postRunnable(stageRunnable);
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -848,23 +846,36 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
}
|
||||
|
||||
public static boolean isNetworkOnline() {
|
||||
boolean status = false;
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo netInfo = cm.getNetworkInfo(0);
|
||||
NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
|
||||
status = true;
|
||||
return true;
|
||||
} else {
|
||||
netInfo = cm.getNetworkInfo(1);
|
||||
netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
if(netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
|
||||
status = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
return true;
|
||||
}
|
||||
return status;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isConnectedToWiFi() {
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
|
||||
return true;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getCurrentTime() {
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.accounts.AccountManager;
|
|||
import android.content.ContentProviderOperation;
|
||||
import android.content.ContentProviderResult;
|
||||
import android.content.ContentResolver;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
|
@ -37,6 +36,10 @@ public class ContactsController {
|
|||
private final Integer observerLock = 1;
|
||||
public boolean contactsLoaded = false;
|
||||
private boolean contactsBookLoaded = false;
|
||||
private int lastContactsPhonesCount = -1;
|
||||
private int lastContactsPhonesMaxId = -1;
|
||||
private int lastContactsNamesCount = -1;
|
||||
private int lastContactsNamesMaxId = -1;
|
||||
private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
|
||||
|
||||
public static class Contact {
|
||||
|
@ -75,37 +78,6 @@ public class ContactsController {
|
|||
|
||||
public HashMap<String, TLRPC.TL_contact> contactsByPhone = new HashMap<String, TLRPC.TL_contact>();
|
||||
|
||||
private class MyContentObserver extends ContentObserver {
|
||||
|
||||
public MyContentObserver() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
super.onChange(selfChange);
|
||||
synchronized (observerLock) {
|
||||
if (ignoreChanges) {
|
||||
FileLog.e("tmessages", "contacts changed - ignore");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().scheduleContactsReload = System.currentTimeMillis() + 2000;
|
||||
FileLog.e("tmessages", "contacts changed schedule - apply in " + MessagesController.getInstance().scheduleContactsReload);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deliverSelfNotifications() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile ContactsController Instance = null;
|
||||
public static ContactsController getInstance() {
|
||||
ContactsController localInstance = Instance;
|
||||
|
@ -120,15 +92,6 @@ public class ContactsController {
|
|||
return localInstance;
|
||||
}
|
||||
|
||||
public ContactsController() {
|
||||
Utilities.globalQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationLoader.applicationContext.getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, new MyContentObserver());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
contactsBook.clear();
|
||||
contactsBookSPhones.clear();
|
||||
|
@ -145,6 +108,10 @@ public class ContactsController {
|
|||
contactsSyncInProgress = false;
|
||||
contactsLoaded = false;
|
||||
contactsBookLoaded = false;
|
||||
lastContactsPhonesCount = -1;
|
||||
lastContactsPhonesMaxId = -1;
|
||||
lastContactsNamesCount = -1;
|
||||
lastContactsNamesMaxId = -1;
|
||||
}
|
||||
|
||||
public void checkAppAccount() {
|
||||
|
@ -183,6 +150,85 @@ public class ContactsController {
|
|||
}
|
||||
}
|
||||
|
||||
public void checkContacts() {
|
||||
Utilities.globalQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (checkContactsInternal()) {
|
||||
FileLog.e("tmessages", "detected contacts change");
|
||||
ContactsController.getInstance().performSyncPhoneBook(ContactsController.getInstance().getContactsCopy(ContactsController.getInstance().contactsBook), true, false, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkContactsInternal() {
|
||||
boolean reload = false;
|
||||
try {
|
||||
ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();
|
||||
Cursor pCur = null;
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._ID}, null, null, ContactsContract.CommonDataKinds.Phone._ID + " desc LIMIT 1");
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsPhonesMaxId != -1 && value != lastContactsPhonesMaxId) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsPhonesMaxId = value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._COUNT}, null, null, null);
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsPhonesCount != -1 && value != lastContactsPhonesCount) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsPhonesCount = value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._COUNT}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, null);
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsNamesCount != -1 && value != lastContactsNamesCount) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsNamesCount = value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
try {
|
||||
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._ID}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, ContactsContract.Data._ID + " desc LIMIT 1");
|
||||
if (pCur != null) {
|
||||
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
|
||||
int value = pCur.getInt(0);
|
||||
if (lastContactsNamesMaxId != -1 && value != lastContactsNamesMaxId) {
|
||||
reload = true;
|
||||
}
|
||||
lastContactsNamesMaxId = value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return reload;
|
||||
}
|
||||
|
||||
public void readContacts() {
|
||||
if (loadingContacts) {
|
||||
return;
|
||||
|
@ -414,6 +460,9 @@ public class ContactsController {
|
|||
}
|
||||
|
||||
FileLog.e("tmessages", "start read contacts from phone");
|
||||
if (!schedule) {
|
||||
checkContactsInternal();
|
||||
}
|
||||
final HashMap<Integer, Contact> contactsMap = readContactsFromPhoneBook();
|
||||
final HashMap<String, Contact> contactsBookShort = new HashMap<String, Contact>();
|
||||
int oldCount = contactHashMap.size();
|
||||
|
|
|
@ -95,7 +95,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
private int sound;
|
||||
public boolean enableJoined = true;
|
||||
public int fontSize = Utilities.dp(16);
|
||||
public long scheduleContactsReload = 0;
|
||||
|
||||
public MessageObject currentPushMessage;
|
||||
|
||||
|
@ -300,7 +299,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
|
||||
updatesStartWaitTime = 0;
|
||||
currentDeletingTaskTime = 0;
|
||||
scheduleContactsReload = 0;
|
||||
currentDeletingTaskMids = null;
|
||||
gettingNewDeleteTask = false;
|
||||
currentDeletingTask = null;
|
||||
|
@ -763,11 +761,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
checkDeletingTask();
|
||||
|
||||
if (UserConfig.clientUserId != 0) {
|
||||
if (scheduleContactsReload != 0 && currentTime > scheduleContactsReload) {
|
||||
ContactsController.getInstance().performSyncPhoneBook(ContactsController.getInstance().getContactsCopy(ContactsController.getInstance().contactsBook), true, false, true);
|
||||
scheduleContactsReload = 0;
|
||||
}
|
||||
|
||||
if (ApplicationLoader.lastPauseTime == 0) {
|
||||
if (statusSettingState != 1 && (lastStatusUpdateTime == 0 || lastStatusUpdateTime <= System.currentTimeMillis() - 55000 || offlineSent)) {
|
||||
statusSettingState = 1;
|
||||
|
@ -820,8 +813,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
FileLog.e("tmessages", "UPDATES WAIT TIMEOUT - CHECK QUEUE");
|
||||
processUpdatesQueue(false);
|
||||
}
|
||||
} else {
|
||||
scheduleContactsReload = 0;
|
||||
}
|
||||
if (!printingUsers.isEmpty() || lastPrintingStringCount != printingUsers.size()) {
|
||||
boolean updated = false;
|
||||
|
|
|
@ -997,8 +997,6 @@ public class MessagesStorage {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
database.executeFast("DELETE FROM user_contacts_v6 WHERE 1").stepThis().dispose();
|
||||
database.executeFast("DELETE FROM user_phones_v6 WHERE 1").stepThis().dispose();
|
||||
database.beginTransaction();
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO user_contacts_v6 VALUES(?, ?, ?)");
|
||||
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO user_phones_v6 VALUES(?, ?, ?, ?)");
|
||||
|
|
|
@ -47,9 +47,7 @@ import java.io.OutputStream;
|
|||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.PublicKey;
|
||||
|
|
|
@ -340,16 +340,7 @@ public class MessageObject {
|
|||
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes;
|
||||
if (sizes.size() > 0) {
|
||||
int width = (int)(Math.min(Utilities.displaySize.x, Utilities.displaySize.y) * 0.7f);
|
||||
int height = width + Utilities.dp(100);
|
||||
if (width > 800) {
|
||||
width = 800;
|
||||
}
|
||||
if (height > 800) {
|
||||
height = 800;
|
||||
}
|
||||
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
|
||||
if (sizeFull != null) {
|
||||
return getAttachFileName(sizeFull);
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
|
|||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.google.android.gms.common.ConnectionResult;
|
|||
import com.google.android.gms.common.GooglePlayServicesUtil;
|
||||
import com.google.android.gms.gcm.GoogleCloudMessaging;
|
||||
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.NotificationsService;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
|
@ -197,6 +198,9 @@ public class ApplicationLoader extends Application {
|
|||
}
|
||||
|
||||
public static void resetLastPauseTime() {
|
||||
if (lastPauseTime != 0 && System.currentTimeMillis() - lastPauseTime > 5000) {
|
||||
ContactsController.getInstance().checkContacts();
|
||||
}
|
||||
lastPauseTime = 0;
|
||||
ConnectionsManager.getInstance().applicationMovedToForeground();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.view.MotionEvent;
|
|||
import android.view.SoundEffectConstants;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.MediaController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
|
@ -57,7 +58,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
private String currentPhotoFilter;
|
||||
private ImageReceiver photoImage;
|
||||
private ProgressView progressView;
|
||||
public boolean downloadPhotos = true;
|
||||
public int downloadPhotos = 0;
|
||||
private boolean progressVisible = false;
|
||||
|
||||
private int TAG;
|
||||
|
@ -350,12 +351,22 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
photoHeight = 800;
|
||||
}
|
||||
|
||||
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, photoWidth, photoHeight);
|
||||
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, 800, 800);
|
||||
if (currentPhotoObject != null) {
|
||||
float scale = (float) currentPhotoObject.photoOwner.w / (float) photoWidth;
|
||||
|
||||
int w = (int) (currentPhotoObject.photoOwner.w / scale);
|
||||
int h = (int) (currentPhotoObject.photoOwner.h / scale);
|
||||
if (w == 0) {
|
||||
if (messageObject.type == 3) {
|
||||
w = infoWidth + infoOffset + Utilities.dp(16);
|
||||
} else {
|
||||
w = Utilities.dp(100);
|
||||
}
|
||||
}
|
||||
if (h == 0) {
|
||||
h = Utilities.dp(100);
|
||||
}
|
||||
if (h > photoHeight) {
|
||||
float scale2 = h;
|
||||
h = photoHeight;
|
||||
|
@ -387,7 +398,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
MediaController.getInstance().removeLoadingFileObserver(this);
|
||||
}
|
||||
}
|
||||
if (photoExist || downloadPhotos) {
|
||||
if (photoExist || downloadPhotos == 0 || downloadPhotos == 2 && ConnectionsManager.isConnectedToWiFi()) {
|
||||
if (messageObject.imagePreview != null) {
|
||||
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), currentPhotoObject.photoOwner.size);
|
||||
} else {
|
||||
|
@ -458,7 +469,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
if (!cacheFile.exists()) {
|
||||
MediaController.getInstance().addLoadingFileObserver(fileName, this);
|
||||
if (!FileLoader.getInstance().isLoadingFile(fileName)) {
|
||||
if (currentMessageObject.type != 1 || !downloadPhotos) {
|
||||
if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
|
||||
buttonState = 0;
|
||||
progressVisible = false;
|
||||
} else {
|
||||
|
@ -467,7 +478,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
}
|
||||
progressView.setProgress(0);
|
||||
} else {
|
||||
if (currentMessageObject.type != 1 || !downloadPhotos) {
|
||||
if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
|
||||
buttonState = 1;
|
||||
} else {
|
||||
buttonState = -1;
|
||||
|
|
|
@ -147,8 +147,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
public boolean scrollToTopOnResume = false;
|
||||
private boolean scrollToTopUnReadOnResume = false;
|
||||
private boolean isCustomTheme = false;
|
||||
private boolean downloadPhotos = true;
|
||||
private boolean downloadAudios = true;
|
||||
private int downloadPhotos = 0;
|
||||
private int downloadAudios = 0;
|
||||
private ImageView topPlaneClose;
|
||||
private View pagedownButton;
|
||||
private TextView topPanelText;
|
||||
|
@ -442,14 +442,14 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
sendByEnter = preferences.getBoolean("send_by_enter", false);
|
||||
|
||||
if (currentChat != null) {
|
||||
downloadPhotos = preferences.getBoolean("photo_download_chat", true);
|
||||
downloadPhotos = preferences.getInt("photo_download_chat2", 0);
|
||||
} else {
|
||||
downloadPhotos = preferences.getBoolean("photo_download_user", true);
|
||||
downloadPhotos = preferences.getInt("photo_download_user2", 0);
|
||||
}
|
||||
if (currentChat != null) {
|
||||
downloadAudios = preferences.getBoolean("audio_download_chat", true);
|
||||
downloadAudios = preferences.getInt("audio_download_chat2", 0);
|
||||
} else {
|
||||
downloadAudios = preferences.getBoolean("audio_download_user", true);
|
||||
downloadAudios = preferences.getInt("audio_download_user2", 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3844,7 +3844,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
((ChatBaseCell)view).isChat = currentChat != null;
|
||||
((ChatBaseCell)view).setMessageObject(message);
|
||||
((ChatBaseCell)view).setCheckPressed(!disableSelection, disableSelection && selected);
|
||||
if (view instanceof ChatAudioCell && downloadAudios) {
|
||||
if (view instanceof ChatAudioCell && (downloadAudios == 0 || downloadAudios == 2 && ConnectionsManager.isConnectedToWiFi())) {
|
||||
((ChatAudioCell)view).downloadAudioIfNeed();
|
||||
} else if (view instanceof ChatMediaCell) {
|
||||
((ChatMediaCell)view).downloadPhotos = downloadPhotos;
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -196,7 +197,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (section == 0) {
|
||||
|
@ -294,6 +294,19 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||
if (parent != null) {
|
||||
|
@ -432,6 +445,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -440,7 +454,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
if (searchListViewAdapter == null) {
|
||||
return true;
|
||||
}
|
||||
searchListViewAdapter.searchDialogs(s);
|
||||
if (s.length() != 0) {
|
||||
searchWas = true;
|
||||
if (listView != null) {
|
||||
|
@ -456,6 +469,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||
}
|
||||
}
|
||||
searchListViewAdapter.searchDialogs(s);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
@ -148,6 +149,19 @@ public class CountrySelectActivity extends ActionBarActivity {
|
|||
}
|
||||
});
|
||||
|
||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
}
|
||||
});
|
||||
|
||||
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
|
||||
}
|
||||
|
||||
|
@ -220,6 +234,7 @@ public class CountrySelectActivity extends ActionBarActivity {
|
|||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -533,16 +533,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
|
|||
}
|
||||
}
|
||||
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
int width = (int)(Math.min(displaySize.x, displaySize.y) * 0.7f);
|
||||
int height = width + Utilities.dp(100);
|
||||
if (width > 800) {
|
||||
width = 800;
|
||||
}
|
||||
if (height > 800) {
|
||||
height = 800;
|
||||
}
|
||||
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, width, height);
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 800, 800);
|
||||
if (sizeFull != null) {
|
||||
TLRPC.TL_inputFileLocation location = new TLRPC.TL_inputFileLocation();
|
||||
location.local_id = sizeFull.location.local_id;
|
||||
|
@ -591,16 +582,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
|
|||
} else {
|
||||
ArrayList<TLRPC.PhotoSize> sizes = obj.messageOwner.action.photo.sizes;
|
||||
if (sizes.size() > 0) {
|
||||
int width = (int)(Math.min(displaySize.x, displaySize.y) * 0.7f);
|
||||
int height = width + Utilities.dp(100);
|
||||
if (width > 800) {
|
||||
width = 800;
|
||||
}
|
||||
if (height > 800) {
|
||||
height = 800;
|
||||
}
|
||||
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
|
||||
if (sizeFull != null) {
|
||||
currentFileName = sizeFull.location.volume_id + "_" + sizeFull.location.local_id + ".jpg";
|
||||
}
|
||||
|
@ -990,16 +972,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
|
|||
ArrayList<TLRPC.PhotoSize> sizes = message.messageOwner.media.photo.sizes;
|
||||
iv.isVideo = false;
|
||||
if (sizes.size() > 0) {
|
||||
int width = (int)(Math.min(displaySize.x, displaySize.y) * 0.7f);
|
||||
int height = width + Utilities.dp(100);
|
||||
if (width > 800) {
|
||||
width = 800;
|
||||
}
|
||||
if (height > 800) {
|
||||
height = 800;
|
||||
}
|
||||
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
|
||||
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
|
||||
if (message.imagePreview != null) {
|
||||
iv.setImage(sizeFull.location, null, message.imagePreview, sizeFull.size);
|
||||
} else {
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
|
@ -279,6 +280,19 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL) {
|
||||
Utilities.hideKeyboard(userSelectEditText);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
||||
if (parent != null) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
@ -178,6 +179,19 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
}
|
||||
});
|
||||
|
||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
}
|
||||
});
|
||||
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
} else {
|
||||
|
@ -281,6 +295,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
messagesListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -498,13 +500,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
public void run() {
|
||||
for (TLObject obj : result) {
|
||||
if (obj instanceof TLRPC.User) {
|
||||
TLRPC.User user = (TLRPC.User)obj;
|
||||
TLRPC.User user = (TLRPC.User) obj;
|
||||
MessagesController.getInstance().users.putIfAbsent(user.id, user);
|
||||
} else if (obj instanceof TLRPC.Chat) {
|
||||
TLRPC.Chat chat = (TLRPC.Chat)obj;
|
||||
TLRPC.Chat chat = (TLRPC.Chat) obj;
|
||||
MessagesController.getInstance().chats.putIfAbsent(chat.id, chat);
|
||||
} else if (obj instanceof TLRPC.EncryptedChat) {
|
||||
TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)obj;
|
||||
TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) obj;
|
||||
MessagesController.getInstance().encryptedChats.putIfAbsent(chat.id, chat);
|
||||
}
|
||||
}
|
||||
|
@ -593,6 +595,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
Utilities.hideKeyboard(searchView);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
private int telegramFaqRow;
|
||||
private int languageRow;
|
||||
private int versionRow;
|
||||
private int contactsSectionRow;
|
||||
private int contactsReimportRow;
|
||||
private int contactsSortRow;
|
||||
private int rowCount;
|
||||
|
||||
private static class LinkMovementMethodMy extends LinkMovementMethod {
|
||||
|
@ -192,6 +195,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
messagesSectionRow = rowCount++;
|
||||
textSizeRow = rowCount++;
|
||||
sendByEnterRow = rowCount++;
|
||||
//contactsSectionRow = rowCount++;
|
||||
//contactsSortRow = rowCount++;
|
||||
//contactsReimportRow = rowCount++;
|
||||
supportSectionRow = rowCount++;
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
sendLogsRow = rowCount++;
|
||||
|
@ -228,7 +234,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
listView.setAdapter(listAdapter);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||
if (parentActivity == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -328,42 +334,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.show().setCanceledOnTouchOutside(true);
|
||||
} else if (i == photoDownloadChatRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean value = preferences.getBoolean("photo_download_chat", true);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("photo_download_chat", !value);
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
} else if (i == photoDownloadPrivateRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean value = preferences.getBoolean("photo_download_user", true);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("photo_download_user", !value);
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
} else if (i == audioDownloadChatRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean value = preferences.getBoolean("audio_download_chat", true);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("audio_download_chat", !value);
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
} else if (i == audioDownloadPrivateRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean value = preferences.getBoolean("audio_download_user", true);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("audio_download_user", !value);
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
} else if (i == languageRow) {
|
||||
((LaunchActivity)parentActivity).presentFragment(new LanguageSelectActivity(), "settings_lang", false);
|
||||
} else if (i == switchBackendButtonRow) {
|
||||
|
@ -385,6 +355,58 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else if (i == contactsReimportRow) {
|
||||
|
||||
} else if (i == contactsSortRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setTitle(LocaleController.getString("SortBy", R.string.SortBy));
|
||||
builder.setItems(new CharSequence[] {
|
||||
LocaleController.getString("Default", R.string.Default),
|
||||
LocaleController.getString("SortFirstName", R.string.SortFirstName),
|
||||
LocaleController.getString("SortLastName", R.string.SortLastName)
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("sortContactsBy", which);
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.show().setCanceledOnTouchOutside(true);
|
||||
} else if (i == photoDownloadChatRow || i == photoDownloadPrivateRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder.setItems(new CharSequence[] {
|
||||
LocaleController.getString("Enabled", R.string.Enabled),
|
||||
LocaleController.getString("Disabled", R.string.Disabled),
|
||||
LocaleController.getString("WiFiOnly", R.string.WiFiOnly)
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
if (i == photoDownloadChatRow) {
|
||||
editor.putInt("photo_download_chat2", which);
|
||||
} else if (i == photoDownloadPrivateRow) {
|
||||
editor.putInt("photo_download_user2", which);
|
||||
} else if (i == audioDownloadChatRow) {
|
||||
editor.putInt("audio_download_chat2", which);
|
||||
} else if (i == audioDownloadPrivateRow) {
|
||||
editor.putInt("audio_download_user2", which);
|
||||
}
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.show().setCanceledOnTouchOutside(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -617,7 +639,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
return i == textSizeRow || i == enableAnimationsRow || i == blockedRow || i == notificationRow || i == backgroundRow ||
|
||||
i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == photoDownloadPrivateRow ||
|
||||
i == photoDownloadChatRow || i == clearLogsRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow || i == languageRow ||
|
||||
i == switchBackendButtonRow || i == telegramFaqRow;
|
||||
i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -789,6 +811,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
textView.setText(LocaleController.getString("AutomaticPhotoDownload", R.string.AutomaticPhotoDownload));
|
||||
} else if (i == audioDownloadSection) {
|
||||
textView.setText(LocaleController.getString("AutomaticAudioDownload", R.string.AutomaticAudioDownload));
|
||||
} else if (i == contactsSectionRow) {
|
||||
textView.setText(LocaleController.getString("Contacts", R.string.Contacts).toUpperCase());
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (view == null) {
|
||||
|
@ -832,6 +856,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
} else if (i == telegramFaqRow) {
|
||||
textView.setText(LocaleController.getString("TelegramFAQ", R.string.TelegramFaq));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
} else if (i == contactsReimportRow) {
|
||||
textView.setText(LocaleController.getString("ImportContacts", R.string.ImportContacts));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else if (type == 3) {
|
||||
if (view == null) {
|
||||
|
@ -860,42 +887,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
} else {
|
||||
checkButton.setImageResource(R.drawable.btn_check_off);
|
||||
}
|
||||
} else if (i == photoDownloadChatRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadGroups", R.string.AutomaticPhotoDownloadGroups));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
boolean enabled = preferences.getBoolean("photo_download_chat", true);
|
||||
if (enabled) {
|
||||
checkButton.setImageResource(R.drawable.btn_check_on);
|
||||
} else {
|
||||
checkButton.setImageResource(R.drawable.btn_check_off);
|
||||
}
|
||||
} else if (i == photoDownloadPrivateRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadPrivateChats", R.string.AutomaticPhotoDownloadPrivateChats));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
boolean enabled = preferences.getBoolean("photo_download_user", true);
|
||||
if (enabled) {
|
||||
checkButton.setImageResource(R.drawable.btn_check_on);
|
||||
} else {
|
||||
checkButton.setImageResource(R.drawable.btn_check_off);
|
||||
}
|
||||
} else if (i == audioDownloadChatRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadGroups", R.string.AutomaticPhotoDownloadGroups));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
boolean enabled = preferences.getBoolean("audio_download_chat", true);
|
||||
if (enabled) {
|
||||
checkButton.setImageResource(R.drawable.btn_check_on);
|
||||
} else {
|
||||
checkButton.setImageResource(R.drawable.btn_check_off);
|
||||
}
|
||||
} else if (i == audioDownloadPrivateRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadPrivateChats", R.string.AutomaticPhotoDownloadPrivateChats));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
boolean enabled = preferences.getBoolean("audio_download_user", true);
|
||||
if (enabled) {
|
||||
checkButton.setImageResource(R.drawable.btn_check_on);
|
||||
} else {
|
||||
checkButton.setImageResource(R.drawable.btn_check_off);
|
||||
}
|
||||
}
|
||||
// if (i == 7) {
|
||||
// textView.setText(LocaleController.getString(R.string.SaveIncomingPhotos));
|
||||
|
@ -952,6 +943,66 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
detailTextView.setText(LocaleController.getCurrentLanguageName());
|
||||
textView.setText(LocaleController.getString("Language", R.string.Language));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
} else if (i == contactsSortRow) {
|
||||
textView.setText(LocaleController.getString("SortBy", R.string.SortBy));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int sort = preferences.getInt("sortContactsBy", 0);
|
||||
if (sort == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
||||
} else if (sort == 1) {
|
||||
detailTextView.setText(LocaleController.getString("FirstName", R.string.SortFirstName));
|
||||
} else if (sort == 2) {
|
||||
detailTextView.setText(LocaleController.getString("LastName", R.string.SortLastName));
|
||||
}
|
||||
} else if (i == photoDownloadChatRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadGroups", R.string.AutomaticPhotoDownloadGroups));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("photo_download_chat2", 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("WiFiOnly", R.string.WiFiOnly));
|
||||
}
|
||||
} else if (i == photoDownloadPrivateRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadPrivateChats", R.string.AutomaticPhotoDownloadPrivateChats));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("photo_download_user2", 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("WiFiOnly", R.string.WiFiOnly));
|
||||
}
|
||||
} else if (i == audioDownloadChatRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadGroups", R.string.AutomaticPhotoDownloadGroups));
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("audio_download_chat2", 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("WiFiOnly", R.string.WiFiOnly));
|
||||
}
|
||||
} else if (i == audioDownloadPrivateRow) {
|
||||
textView.setText(LocaleController.getString("AutomaticPhotoDownloadPrivateChats", R.string.AutomaticPhotoDownloadPrivateChats));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int value = preferences.getInt("audio_download_user2", 0);
|
||||
if (value == 0) {
|
||||
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
||||
} else if (value == 1) {
|
||||
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
||||
} else if (value == 2) {
|
||||
detailTextView.setText(LocaleController.getString("WiFiOnly", R.string.WiFiOnly));
|
||||
}
|
||||
}
|
||||
} else if (type == 6) {
|
||||
if (view == null) {
|
||||
|
@ -973,13 +1024,13 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
public int getItemViewType(int i) {
|
||||
if (i == profileRow) {
|
||||
return 0;
|
||||
} else if (i == numberSectionRow || i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == photoDownloadSection || i == audioDownloadSection) {
|
||||
} else if (i == numberSectionRow || i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == photoDownloadSection || i == audioDownloadSection || i == contactsSectionRow) {
|
||||
return 1;
|
||||
} else if (i == textSizeRow || i == languageRow) {
|
||||
} else if (i == textSizeRow || i == languageRow || i == contactsSortRow || i == photoDownloadChatRow || i == photoDownloadPrivateRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow) {
|
||||
return 5;
|
||||
} else if (i == enableAnimationsRow || i == sendByEnterRow || i == photoDownloadChatRow || i == photoDownloadPrivateRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow) {
|
||||
} else if (i == enableAnimationsRow || i == sendByEnterRow) {
|
||||
return 3;
|
||||
} else if (i == numberRow || i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow) {
|
||||
} else if (i == numberRow || i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow) {
|
||||
return 2;
|
||||
} else if (i == logoutRow) {
|
||||
return 4;
|
||||
|
|
|
@ -11,7 +11,6 @@ package org.telegram.ui.Views;
|
|||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
|
||||
|
@ -223,5 +222,4 @@ public abstract class SectionedBaseAdapter extends BaseFragmentAdapter implement
|
|||
mSectionCount = getSectionCount();
|
||||
return mSectionCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -267,6 +267,9 @@
|
|||
<string name="Disabled">Disabled</string>
|
||||
<string name="NotificationsService">Notifications Service</string>
|
||||
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
||||
<string name="SortBy">Sort By</string>
|
||||
<string name="ImportContacts">Import Contacts</string>
|
||||
<string name="WiFiOnly">via WiFi only</string>
|
||||
|
||||
<!--media view-->
|
||||
<string name="NoMedia">لا توجد وسائط بعد</string>
|
||||
|
|
|
@ -267,6 +267,9 @@
|
|||
<string name="Disabled">Disabled</string>
|
||||
<string name="NotificationsService">Notifications Service</string>
|
||||
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
||||
<string name="SortBy">Sort By</string>
|
||||
<string name="ImportContacts">Import Contacts</string>
|
||||
<string name="WiFiOnly">via WiFi only</string>
|
||||
|
||||
<!--media view-->
|
||||
<string name="NoMedia">Noch keine geteilten Medien vorhanden</string>
|
||||
|
|
|
@ -267,6 +267,9 @@
|
|||
<string name="Disabled">Disabled</string>
|
||||
<string name="NotificationsService">Notifications Service</string>
|
||||
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
||||
<string name="SortBy">Sort By</string>
|
||||
<string name="ImportContacts">Import Contacts</string>
|
||||
<string name="WiFiOnly">via WiFi only</string>
|
||||
|
||||
<!--media view-->
|
||||
<string name="NoMedia">No hay fotos ni vídeos compartidos aún</string>
|
||||
|
|
|
@ -267,6 +267,9 @@
|
|||
<string name="Disabled">Disabled</string>
|
||||
<string name="NotificationsService">Notifications Service</string>
|
||||
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
||||
<string name="SortBy">Sort By</string>
|
||||
<string name="ImportContacts">Import Contacts</string>
|
||||
<string name="WiFiOnly">via WiFi only</string>
|
||||
|
||||
<!--media view-->
|
||||
<string name="NoMedia">Nessun media condiviso</string>
|
||||
|
|
|
@ -267,6 +267,9 @@
|
|||
<string name="Disabled">Disabled</string>
|
||||
<string name="NotificationsService">Notifications Service</string>
|
||||
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
||||
<string name="SortBy">Sort By</string>
|
||||
<string name="ImportContacts">Import Contacts</string>
|
||||
<string name="WiFiOnly">via WiFi only</string>
|
||||
|
||||
<!--media view-->
|
||||
<string name="NoMedia">Nog geen media gedeeld</string>
|
||||
|
|
|
@ -267,6 +267,11 @@
|
|||
<string name="Disabled">Disabled</string>
|
||||
<string name="NotificationsService">Notifications Service</string>
|
||||
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
|
||||
<string name="SortBy">Sort By</string>
|
||||
<string name="ImportContacts">Import Contacts</string>
|
||||
<string name="WiFiOnly">via WiFi only</string>
|
||||
<string name="SortFirstName">First name</string>
|
||||
<string name="SortLastName">Last name</string>
|
||||
|
||||
<!--media view-->
|
||||
<string name="NoMedia">No shared media yet</string>
|
||||
|
|
Loading…
Reference in a new issue