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:
DrKLO 2014-05-25 02:47:05 +04:00
parent f68ace0fd6
commit 644fc7ccea
27 changed files with 457 additions and 301 deletions

View file

@ -82,7 +82,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 231 versionCode 233
versionName "1.4.13" versionName "1.4.14"
} }
} }

View file

@ -83,7 +83,7 @@ public class PyroSelector {
} }
public void select() { public void select() {
this.select(10); this.select(0);
} }
public void select(long eventTimeout) { public void select(long eventTimeout) {

View file

@ -42,18 +42,18 @@ public class BuffersStorage {
for (int a = 0; a < 5; a++) { for (int a = 0; a < 5; a++) {
freeBuffers128.add(new ByteBufferDesc(128)); freeBuffers128.add(new ByteBufferDesc(128));
} }
for (int a = 0; a < 5; a++) { // for (int a = 0; a < 5; a++) {
freeBuffers1024.add(new ByteBufferDesc(1024 + 200)); // freeBuffers1024.add(new ByteBufferDesc(1024 + 200));
} // }
for (int a = 0; a < 2; a++) { // for (int a = 0; a < 2; a++) {
freeBuffers4096.add(new ByteBufferDesc(4096 + 200)); // freeBuffers4096.add(new ByteBufferDesc(4096 + 200));
} // }
for (int a = 0; a < 2; a++) { // for (int a = 0; a < 2; a++) {
freeBuffers16384.add(new ByteBufferDesc(16384 + 200)); // freeBuffers16384.add(new ByteBufferDesc(16384 + 200));
} // }
for (int a = 0; a < 2; a++) { // for (int a = 0; a < 2; a++) {
freeBuffers32768.add(new ByteBufferDesc(40000)); // freeBuffers32768.add(new ByteBufferDesc(40000));
} // }
} }
public ByteBufferDesc getFreeBuffer(int size) { public ByteBufferDesc getFreeBuffer(int size) {

View file

@ -23,8 +23,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -64,8 +62,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
private boolean registeringForPush = false; private boolean registeringForPush = false;
private boolean paused = false; private boolean paused = false;
private Runnable stageRunnable;
private Runnable pingRunnable;
private long lastPingTime = System.currentTimeMillis(); private long lastPingTime = System.currentTimeMillis();
private long lastPushPingTime = System.currentTimeMillis(); private long lastPushPingTime = System.currentTimeMillis();
private int nextSleepTimeout = 30000; private int nextSleepTimeout = 30000;
@ -84,23 +80,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
return localInstance; return localInstance;
} }
public ConnectionsManager() { static long t = System.currentTimeMillis();
currentAppVersion = ApplicationLoader.getAppVersion(); private Runnable stageRunnable = new Runnable() {
lastOutgoingMessageId = 0;
movingToDatacenterId = DEFAULT_DATACENTER_ID;
loadSession();
if (!isNetworkOnline()) {
connectionState = 1;
}
Timer serviceTimer = new Timer();
serviceTimer.schedule(new TimerTask() {
@Override
public void run() {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
Utilities.stageQueue.handler.removeCallbacks(stageRunnable);
t = System.currentTimeMillis();
if (datacenters != null) { if (datacenters != null) {
if (lastPushPingTime < System.currentTimeMillis() - 29000) { if (lastPushPingTime < System.currentTimeMillis() - 29000) {
lastPushPingTime = System.currentTimeMillis(); lastPushPingTime = System.currentTimeMillis();
@ -145,7 +130,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
try { try {
paused = true; paused = true;
Thread.sleep(500); Utilities.stageQueue.postRunnable(stageRunnable, 1000);
return; return;
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
@ -173,10 +158,22 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
processRequestQueue(0, 0); processRequestQueue(0, 0);
} }
} }
Utilities.stageQueue.postRunnable(stageRunnable, 1000);
} }
}); };
public ConnectionsManager() {
currentAppVersion = ApplicationLoader.getAppVersion();
lastOutgoingMessageId = 0;
movingToDatacenterId = DEFAULT_DATACENTER_ID;
loadSession();
if (!isNetworkOnline()) {
connectionState = 1;
} }
}, 1000, 1000);
Utilities.stageQueue.postRunnable(stageRunnable, 1000);
} }
public void resumeNetworkMaybe() { public void resumeNetworkMaybe() {
@ -196,6 +193,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
public void applicationMovedToForeground() { public void applicationMovedToForeground() {
Utilities.stageQueue.postRunnable(stageRunnable);
Utilities.stageQueue.postRunnable(new Runnable() { Utilities.stageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -848,23 +846,36 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
public static boolean isNetworkOnline() { public static boolean isNetworkOnline() {
boolean status = false;
try { try {
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); 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) { if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
status = true; return true;
} else { } else {
netInfo = cm.getNetworkInfo(1); netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if(netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) { if(netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
status = true; return true;
} }
} }
} catch(Exception e) { } catch(Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
return true; 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() { public int getCurrentTime() {

View file

@ -13,7 +13,6 @@ import android.accounts.AccountManager;
import android.content.ContentProviderOperation; import android.content.ContentProviderOperation;
import android.content.ContentProviderResult; import android.content.ContentProviderResult;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.database.ContentObserver;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.BaseColumns; import android.provider.BaseColumns;
@ -37,6 +36,10 @@ public class ContactsController {
private final Integer observerLock = 1; private final Integer observerLock = 1;
public boolean contactsLoaded = false; public boolean contactsLoaded = false;
private boolean contactsBookLoaded = 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>(); private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
public static class Contact { public static class Contact {
@ -75,37 +78,6 @@ public class ContactsController {
public HashMap<String, TLRPC.TL_contact> contactsByPhone = new HashMap<String, TLRPC.TL_contact>(); 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; private static volatile ContactsController Instance = null;
public static ContactsController getInstance() { public static ContactsController getInstance() {
ContactsController localInstance = Instance; ContactsController localInstance = Instance;
@ -120,15 +92,6 @@ public class ContactsController {
return localInstance; 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() { public void cleanup() {
contactsBook.clear(); contactsBook.clear();
contactsBookSPhones.clear(); contactsBookSPhones.clear();
@ -145,6 +108,10 @@ public class ContactsController {
contactsSyncInProgress = false; contactsSyncInProgress = false;
contactsLoaded = false; contactsLoaded = false;
contactsBookLoaded = false; contactsBookLoaded = false;
lastContactsPhonesCount = -1;
lastContactsPhonesMaxId = -1;
lastContactsNamesCount = -1;
lastContactsNamesMaxId = -1;
} }
public void checkAppAccount() { 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() { public void readContacts() {
if (loadingContacts) { if (loadingContacts) {
return; return;
@ -414,6 +460,9 @@ public class ContactsController {
} }
FileLog.e("tmessages", "start read contacts from phone"); FileLog.e("tmessages", "start read contacts from phone");
if (!schedule) {
checkContactsInternal();
}
final HashMap<Integer, Contact> contactsMap = readContactsFromPhoneBook(); final HashMap<Integer, Contact> contactsMap = readContactsFromPhoneBook();
final HashMap<String, Contact> contactsBookShort = new HashMap<String, Contact>(); final HashMap<String, Contact> contactsBookShort = new HashMap<String, Contact>();
int oldCount = contactHashMap.size(); int oldCount = contactHashMap.size();

View file

@ -95,7 +95,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
private int sound; private int sound;
public boolean enableJoined = true; public boolean enableJoined = true;
public int fontSize = Utilities.dp(16); public int fontSize = Utilities.dp(16);
public long scheduleContactsReload = 0;
public MessageObject currentPushMessage; public MessageObject currentPushMessage;
@ -300,7 +299,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
updatesStartWaitTime = 0; updatesStartWaitTime = 0;
currentDeletingTaskTime = 0; currentDeletingTaskTime = 0;
scheduleContactsReload = 0;
currentDeletingTaskMids = null; currentDeletingTaskMids = null;
gettingNewDeleteTask = false; gettingNewDeleteTask = false;
currentDeletingTask = null; currentDeletingTask = null;
@ -763,11 +761,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
checkDeletingTask(); checkDeletingTask();
if (UserConfig.clientUserId != 0) { 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 (ApplicationLoader.lastPauseTime == 0) {
if (statusSettingState != 1 && (lastStatusUpdateTime == 0 || lastStatusUpdateTime <= System.currentTimeMillis() - 55000 || offlineSent)) { if (statusSettingState != 1 && (lastStatusUpdateTime == 0 || lastStatusUpdateTime <= System.currentTimeMillis() - 55000 || offlineSent)) {
statusSettingState = 1; statusSettingState = 1;
@ -820,8 +813,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
FileLog.e("tmessages", "UPDATES WAIT TIMEOUT - CHECK QUEUE"); FileLog.e("tmessages", "UPDATES WAIT TIMEOUT - CHECK QUEUE");
processUpdatesQueue(false); processUpdatesQueue(false);
} }
} else {
scheduleContactsReload = 0;
} }
if (!printingUsers.isEmpty() || lastPrintingStringCount != printingUsers.size()) { if (!printingUsers.isEmpty() || lastPrintingStringCount != printingUsers.size()) {
boolean updated = false; boolean updated = false;

View file

@ -997,8 +997,6 @@ public class MessagesStorage {
@Override @Override
public void run() { public void run() {
try { 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(); database.beginTransaction();
SQLitePreparedStatement state = database.executeFast("REPLACE INTO user_contacts_v6 VALUES(?, ?, ?)"); SQLitePreparedStatement state = database.executeFast("REPLACE INTO user_contacts_v6 VALUES(?, ?, ?)");
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO user_phones_v6 VALUES(?, ?, ?, ?)"); SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO user_phones_v6 VALUES(?, ?, ?, ?)");

View file

@ -47,9 +47,7 @@ import java.io.OutputStream;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.PublicKey; import java.security.PublicKey;

View file

@ -340,16 +340,7 @@ public class MessageObject {
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) { } else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes; ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes;
if (sizes.size() > 0) { if (sizes.size() > 0) {
int width = (int)(Math.min(Utilities.displaySize.x, Utilities.displaySize.y) * 0.7f); TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
int height = width + Utilities.dp(100);
if (width > 800) {
width = 800;
}
if (height > 800) {
height = 800;
}
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
if (sizeFull != null) { if (sizeFull != null) {
return getAttachFileName(sizeFull); return getAttachFileName(sizeFull);
} }

View file

@ -148,7 +148,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
@Override @Override
public boolean hasStableIds() { public boolean hasStableIds() {
return false; return true;
} }
@Override @Override

View file

@ -30,6 +30,7 @@ import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging; import com.google.android.gms.gcm.GoogleCloudMessaging;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.NotificationsService; import org.telegram.messenger.NotificationsService;
import org.telegram.messenger.BuildVars; import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
@ -197,6 +198,9 @@ public class ApplicationLoader extends Application {
} }
public static void resetLastPauseTime() { public static void resetLastPauseTime() {
if (lastPauseTime != 0 && System.currentTimeMillis() - lastPauseTime > 5000) {
ContactsController.getInstance().checkContacts();
}
lastPauseTime = 0; lastPauseTime = 0;
ConnectionsManager.getInstance().applicationMovedToForeground(); ConnectionsManager.getInstance().applicationMovedToForeground();
} }

View file

@ -20,6 +20,7 @@ import android.view.MotionEvent;
import android.view.SoundEffectConstants; import android.view.SoundEffectConstants;
import android.view.View; import android.view.View;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.MediaController; import org.telegram.messenger.MediaController;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
@ -57,7 +58,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private String currentPhotoFilter; private String currentPhotoFilter;
private ImageReceiver photoImage; private ImageReceiver photoImage;
private ProgressView progressView; private ProgressView progressView;
public boolean downloadPhotos = true; public int downloadPhotos = 0;
private boolean progressVisible = false; private boolean progressVisible = false;
private int TAG; private int TAG;
@ -350,12 +351,22 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoHeight = 800; photoHeight = 800;
} }
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, photoWidth, photoHeight); currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, 800, 800);
if (currentPhotoObject != null) { if (currentPhotoObject != null) {
float scale = (float) currentPhotoObject.photoOwner.w / (float) photoWidth; float scale = (float) currentPhotoObject.photoOwner.w / (float) photoWidth;
int w = (int) (currentPhotoObject.photoOwner.w / scale); int w = (int) (currentPhotoObject.photoOwner.w / scale);
int h = (int) (currentPhotoObject.photoOwner.h / 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) { if (h > photoHeight) {
float scale2 = h; float scale2 = h;
h = photoHeight; h = photoHeight;
@ -387,7 +398,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
MediaController.getInstance().removeLoadingFileObserver(this); MediaController.getInstance().removeLoadingFileObserver(this);
} }
} }
if (photoExist || downloadPhotos) { if (photoExist || downloadPhotos == 0 || downloadPhotos == 2 && ConnectionsManager.isConnectedToWiFi()) {
if (messageObject.imagePreview != null) { if (messageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), currentPhotoObject.photoOwner.size); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), currentPhotoObject.photoOwner.size);
} else { } else {
@ -458,7 +469,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (!cacheFile.exists()) { if (!cacheFile.exists()) {
MediaController.getInstance().addLoadingFileObserver(fileName, this); MediaController.getInstance().addLoadingFileObserver(fileName, this);
if (!FileLoader.getInstance().isLoadingFile(fileName)) { if (!FileLoader.getInstance().isLoadingFile(fileName)) {
if (currentMessageObject.type != 1 || !downloadPhotos) { if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
buttonState = 0; buttonState = 0;
progressVisible = false; progressVisible = false;
} else { } else {
@ -467,7 +478,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} }
progressView.setProgress(0); progressView.setProgress(0);
} else { } else {
if (currentMessageObject.type != 1 || !downloadPhotos) { if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
buttonState = 1; buttonState = 1;
} else { } else {
buttonState = -1; buttonState = -1;

View file

@ -147,8 +147,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public boolean scrollToTopOnResume = false; public boolean scrollToTopOnResume = false;
private boolean scrollToTopUnReadOnResume = false; private boolean scrollToTopUnReadOnResume = false;
private boolean isCustomTheme = false; private boolean isCustomTheme = false;
private boolean downloadPhotos = true; private int downloadPhotos = 0;
private boolean downloadAudios = true; private int downloadAudios = 0;
private ImageView topPlaneClose; private ImageView topPlaneClose;
private View pagedownButton; private View pagedownButton;
private TextView topPanelText; private TextView topPanelText;
@ -442,14 +442,14 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
sendByEnter = preferences.getBoolean("send_by_enter", false); sendByEnter = preferences.getBoolean("send_by_enter", false);
if (currentChat != null) { if (currentChat != null) {
downloadPhotos = preferences.getBoolean("photo_download_chat", true); downloadPhotos = preferences.getInt("photo_download_chat2", 0);
} else { } else {
downloadPhotos = preferences.getBoolean("photo_download_user", true); downloadPhotos = preferences.getInt("photo_download_user2", 0);
} }
if (currentChat != null) { if (currentChat != null) {
downloadAudios = preferences.getBoolean("audio_download_chat", true); downloadAudios = preferences.getInt("audio_download_chat2", 0);
} else { } else {
downloadAudios = preferences.getBoolean("audio_download_user", true); downloadAudios = preferences.getInt("audio_download_user2", 0);
} }
return true; return true;
@ -3844,7 +3844,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
((ChatBaseCell)view).isChat = currentChat != null; ((ChatBaseCell)view).isChat = currentChat != null;
((ChatBaseCell)view).setMessageObject(message); ((ChatBaseCell)view).setMessageObject(message);
((ChatBaseCell)view).setCheckPressed(!disableSelection, disableSelection && selected); ((ChatBaseCell)view).setCheckPressed(!disableSelection, disableSelection && selected);
if (view instanceof ChatAudioCell && downloadAudios) { if (view instanceof ChatAudioCell && (downloadAudios == 0 || downloadAudios == 2 && ConnectionsManager.isConnectedToWiFi())) {
((ChatAudioCell)view).downloadAudioIfNeed(); ((ChatAudioCell)view).downloadAudioIfNeed();
} else if (view instanceof ChatMediaCell) { } else if (view instanceof ChatMediaCell) {
((ChatMediaCell)view).downloadPhotos = downloadPhotos; ((ChatMediaCell)view).downloadPhotos = downloadPhotos;

View file

@ -25,6 +25,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -196,7 +197,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
} else { } else {
return; return;
} }
} }
} else { } else {
if (section == 0) { 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 { } else {
ViewGroup parent = (ViewGroup)fragmentView.getParent(); ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) { if (parent != null) {
@ -432,6 +445,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String s) { public boolean onQueryTextSubmit(String s) {
Utilities.hideKeyboard(searchView);
return true; return true;
} }
@ -440,7 +454,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
if (searchListViewAdapter == null) { if (searchListViewAdapter == null) {
return true; return true;
} }
searchListViewAdapter.searchDialogs(s);
if (s.length() != 0) { if (s.length() != 0) {
searchWas = true; searchWas = true;
if (listView != null) { if (listView != null) {
@ -456,6 +469,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult)); emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
} }
} }
searchListViewAdapter.searchDialogs(s);
return true; return true;
} }
}); });

View file

@ -21,6 +21,7 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView; 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); getWindow().setBackgroundDrawableResource(R.drawable.transparent);
} }
@ -220,6 +234,7 @@ public class CountrySelectActivity extends ActionBarActivity {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String s) { public boolean onQueryTextSubmit(String s) {
Utilities.hideKeyboard(searchView);
return true; return true;
} }

View file

@ -533,16 +533,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
} }
} }
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) { } else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
int width = (int)(Math.min(displaySize.x, displaySize.y) * 0.7f); TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 800, 800);
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);
if (sizeFull != null) { if (sizeFull != null) {
TLRPC.TL_inputFileLocation location = new TLRPC.TL_inputFileLocation(); TLRPC.TL_inputFileLocation location = new TLRPC.TL_inputFileLocation();
location.local_id = sizeFull.location.local_id; location.local_id = sizeFull.location.local_id;
@ -591,16 +582,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
} else { } else {
ArrayList<TLRPC.PhotoSize> sizes = obj.messageOwner.action.photo.sizes; ArrayList<TLRPC.PhotoSize> sizes = obj.messageOwner.action.photo.sizes;
if (sizes.size() > 0) { if (sizes.size() > 0) {
int width = (int)(Math.min(displaySize.x, displaySize.y) * 0.7f); TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
int height = width + Utilities.dp(100);
if (width > 800) {
width = 800;
}
if (height > 800) {
height = 800;
}
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
if (sizeFull != null) { if (sizeFull != null) {
currentFileName = sizeFull.location.volume_id + "_" + sizeFull.location.local_id + ".jpg"; 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; ArrayList<TLRPC.PhotoSize> sizes = message.messageOwner.media.photo.sizes;
iv.isVideo = false; iv.isVideo = false;
if (sizes.size() > 0) { if (sizes.size() > 0) {
int width = (int)(Math.min(displaySize.x, displaySize.y) * 0.7f); TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
int height = width + Utilities.dp(100);
if (width > 800) {
width = 800;
}
if (height > 800) {
height = 800;
}
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, width, height);
if (message.imagePreview != null) { if (message.imagePreview != null) {
iv.setImage(sizeFull.location, null, message.imagePreview, sizeFull.size); iv.setImage(sizeFull.location, null, message.imagePreview, sizeFull.size);
} else { } else {

View file

@ -31,6 +31,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; 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 { } else {
ViewGroup parent = (ViewGroup)fragmentView.getParent(); ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) { if (parent != null) {

View file

@ -22,6 +22,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView; 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; searching = false;
searchWas = false; searchWas = false;
} else { } else {
@ -281,6 +295,7 @@ public class LanguageSelectActivity extends BaseFragment {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String s) { public boolean onQueryTextSubmit(String s) {
Utilities.hideKeyboard(searchView);
return true; return true;
} }

View file

@ -274,7 +274,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
messagesListView.setOnScrollListener(new AbsListView.OnScrollListener() { messagesListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override @Override
public void onScrollStateChanged(AbsListView absListView, int i) { public void onScrollStateChanged(AbsListView absListView, int i) {
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
Utilities.hideKeyboard(searchView);
}
} }
@Override @Override
@ -593,6 +595,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String s) { public boolean onQueryTextSubmit(String s) {
Utilities.hideKeyboard(searchView);
return true; return true;
} }

View file

@ -96,6 +96,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
private int telegramFaqRow; private int telegramFaqRow;
private int languageRow; private int languageRow;
private int versionRow; private int versionRow;
private int contactsSectionRow;
private int contactsReimportRow;
private int contactsSortRow;
private int rowCount; private int rowCount;
private static class LinkMovementMethodMy extends LinkMovementMethod { private static class LinkMovementMethodMy extends LinkMovementMethod {
@ -192,6 +195,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
messagesSectionRow = rowCount++; messagesSectionRow = rowCount++;
textSizeRow = rowCount++; textSizeRow = rowCount++;
sendByEnterRow = rowCount++; sendByEnterRow = rowCount++;
//contactsSectionRow = rowCount++;
//contactsSortRow = rowCount++;
//contactsReimportRow = rowCount++;
supportSectionRow = rowCount++; supportSectionRow = rowCount++;
if (BuildVars.DEBUG_VERSION) { if (BuildVars.DEBUG_VERSION) {
sendLogsRow = rowCount++; sendLogsRow = rowCount++;
@ -228,7 +234,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
listView.setAdapter(listAdapter); listView.setAdapter(listAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @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) { if (parentActivity == null) {
return; return;
} }
@ -328,42 +334,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}); });
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.show().setCanceledOnTouchOutside(true); 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) { } else if (i == languageRow) {
((LaunchActivity)parentActivity).presentFragment(new LanguageSelectActivity(), "settings_lang", false); ((LaunchActivity)parentActivity).presentFragment(new LanguageSelectActivity(), "settings_lang", false);
} else if (i == switchBackendButtonRow) { } else if (i == switchBackendButtonRow) {
@ -385,6 +355,58 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", 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 || return i == textSizeRow || i == enableAnimationsRow || i == blockedRow || i == notificationRow || i == backgroundRow ||
i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == photoDownloadPrivateRow || i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == photoDownloadPrivateRow ||
i == photoDownloadChatRow || i == clearLogsRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow || i == languageRow || i == photoDownloadChatRow || i == clearLogsRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow || i == languageRow ||
i == switchBackendButtonRow || i == telegramFaqRow; i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow;
} }
@Override @Override
@ -789,6 +811,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
textView.setText(LocaleController.getString("AutomaticPhotoDownload", R.string.AutomaticPhotoDownload)); textView.setText(LocaleController.getString("AutomaticPhotoDownload", R.string.AutomaticPhotoDownload));
} else if (i == audioDownloadSection) { } else if (i == audioDownloadSection) {
textView.setText(LocaleController.getString("AutomaticAudioDownload", R.string.AutomaticAudioDownload)); 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) { } else if (type == 2) {
if (view == null) { if (view == null) {
@ -832,6 +856,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} else if (i == telegramFaqRow) { } else if (i == telegramFaqRow) {
textView.setText(LocaleController.getString("TelegramFAQ", R.string.TelegramFaq)); textView.setText(LocaleController.getString("TelegramFAQ", R.string.TelegramFaq));
divider.setVisibility(View.VISIBLE); divider.setVisibility(View.VISIBLE);
} else if (i == contactsReimportRow) {
textView.setText(LocaleController.getString("ImportContacts", R.string.ImportContacts));
divider.setVisibility(View.INVISIBLE);
} }
} else if (type == 3) { } else if (type == 3) {
if (view == null) { if (view == null) {
@ -860,42 +887,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} else { } else {
checkButton.setImageResource(R.drawable.btn_check_off); 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) { // if (i == 7) {
// textView.setText(LocaleController.getString(R.string.SaveIncomingPhotos)); // textView.setText(LocaleController.getString(R.string.SaveIncomingPhotos));
@ -952,6 +943,66 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
detailTextView.setText(LocaleController.getCurrentLanguageName()); detailTextView.setText(LocaleController.getCurrentLanguageName());
textView.setText(LocaleController.getString("Language", R.string.Language)); textView.setText(LocaleController.getString("Language", R.string.Language));
divider.setVisibility(View.VISIBLE); 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) { } else if (type == 6) {
if (view == null) { if (view == null) {
@ -973,13 +1024,13 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
public int getItemViewType(int i) { public int getItemViewType(int i) {
if (i == profileRow) { if (i == profileRow) {
return 0; 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; 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; return 5;
} else if (i == enableAnimationsRow || i == sendByEnterRow || i == photoDownloadChatRow || i == photoDownloadPrivateRow || i == audioDownloadChatRow || i == audioDownloadPrivateRow) { } else if (i == enableAnimationsRow || i == sendByEnterRow) {
return 3; 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; return 2;
} else if (i == logoutRow) { } else if (i == logoutRow) {
return 4; return 4;

View file

@ -11,7 +11,6 @@ package org.telegram.ui.Views;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter;
import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.BaseFragmentAdapter;
@ -223,5 +222,4 @@ public abstract class SectionedBaseAdapter extends BaseFragmentAdapter implement
mSectionCount = getSectionCount(); mSectionCount = getSectionCount();
return mSectionCount; return mSectionCount;
} }
} }

View file

@ -267,6 +267,9 @@
<string name="Disabled">Disabled</string> <string name="Disabled">Disabled</string>
<string name="NotificationsService">Notifications Service</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="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--> <!--media view-->
<string name="NoMedia">لا توجد وسائط بعد</string> <string name="NoMedia">لا توجد وسائط بعد</string>

View file

@ -267,6 +267,9 @@
<string name="Disabled">Disabled</string> <string name="Disabled">Disabled</string>
<string name="NotificationsService">Notifications Service</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="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--> <!--media view-->
<string name="NoMedia">Noch keine geteilten Medien vorhanden</string> <string name="NoMedia">Noch keine geteilten Medien vorhanden</string>

View file

@ -267,6 +267,9 @@
<string name="Disabled">Disabled</string> <string name="Disabled">Disabled</string>
<string name="NotificationsService">Notifications Service</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="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--> <!--media view-->
<string name="NoMedia">No hay fotos ni vídeos compartidos aún</string> <string name="NoMedia">No hay fotos ni vídeos compartidos aún</string>

View file

@ -267,6 +267,9 @@
<string name="Disabled">Disabled</string> <string name="Disabled">Disabled</string>
<string name="NotificationsService">Notifications Service</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="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--> <!--media view-->
<string name="NoMedia">Nessun media condiviso</string> <string name="NoMedia">Nessun media condiviso</string>

View file

@ -267,6 +267,9 @@
<string name="Disabled">Disabled</string> <string name="Disabled">Disabled</string>
<string name="NotificationsService">Notifications Service</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="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--> <!--media view-->
<string name="NoMedia">Nog geen media gedeeld</string> <string name="NoMedia">Nog geen media gedeeld</string>

View file

@ -267,6 +267,11 @@
<string name="Disabled">Disabled</string> <string name="Disabled">Disabled</string>
<string name="NotificationsService">Notifications Service</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="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--> <!--media view-->
<string name="NoMedia">No shared media yet</string> <string name="NoMedia">No shared media yet</string>