Commit 9c4835e6 authored by DrKLO's avatar DrKLO

Merge branch 'dev'

parents 62635da2 43674c48
...@@ -3,7 +3,7 @@ buildscript { ...@@ -3,7 +3,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:0.12.+' classpath 'com.android.tools.build:gradle:0.13.+'
} }
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
...@@ -25,7 +25,7 @@ dependencies { ...@@ -25,7 +25,7 @@ dependencies {
android { android {
compileSdkVersion 19 compileSdkVersion 19
buildToolsVersion '19.1.0' buildToolsVersion '20.0.0'
signingConfigs { signingConfigs {
debug { debug {
...@@ -80,7 +80,7 @@ android { ...@@ -80,7 +80,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 346 versionCode 355
versionName "1.9.3" versionName "1.9.4"
} }
} }
...@@ -36,7 +36,6 @@ public class AndroidUtilities { ...@@ -36,7 +36,6 @@ public class AndroidUtilities {
private static int prevOrientation = -10; private static int prevOrientation = -10;
private static boolean waitingForSms = false; private static boolean waitingForSms = false;
private static final Object smsLock = new Object(); private static final Object smsLock = new Object();
public static int externalCacheNotAvailableState = 0;
public static int statusBarHeight = 0; public static int statusBarHeight = 0;
public static float density = 1; public static float density = 1;
...@@ -211,8 +210,7 @@ public class AndroidUtilities { ...@@ -211,8 +210,7 @@ public class AndroidUtilities {
} }
public static File getCacheDir() { public static File getCacheDir() {
if (externalCacheNotAvailableState == 1 || externalCacheNotAvailableState == 0 && Environment.getExternalStorageState().startsWith(Environment.MEDIA_MOUNTED)) { if (Environment.getExternalStorageState().startsWith(Environment.MEDIA_MOUNTED)) {
externalCacheNotAvailableState = 1;
try { try {
File file = ApplicationLoader.applicationContext.getExternalCacheDir(); File file = ApplicationLoader.applicationContext.getExternalCacheDir();
if (file != null) { if (file != null) {
...@@ -222,7 +220,6 @@ public class AndroidUtilities { ...@@ -222,7 +220,6 @@ public class AndroidUtilities {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }
externalCacheNotAvailableState = 2;
try { try {
File file = ApplicationLoader.applicationContext.getCacheDir(); File file = ApplicationLoader.applicationContext.getCacheDir();
if (file != null) { if (file != null) {
......
...@@ -640,54 +640,77 @@ public class ImageLoader { ...@@ -640,54 +640,77 @@ public class ImageLoader {
try { try {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
telegramPath = new File(Environment.getExternalStorageDirectory(), LocaleController.getString("AppName", R.string.AppName)); telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
telegramPath.mkdirs(); telegramPath.mkdirs();
if (telegramPath.isDirectory()) {
try { boolean canRename = false;
File imagePath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Images");
imagePath.mkdir(); try {
if (imagePath.isDirectory()) { for (int a = 0; a < 5; a++) {
mediaDirs.put(FileLoader.MEDIA_DIR_IMAGE, imagePath); File srcFile = new File(cachePath, "temp.file");
FileLog.e("tmessages", "image path = " + imagePath); srcFile.createNewFile();
File dstFile = new File(telegramPath, "temp.file");
canRename = srcFile.renameTo(dstFile);
srcFile.delete();
dstFile.delete();
if (canRename) {
break;
} }
} catch (Exception e) {
FileLog.e("tmessages", e);
} }
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try { if (canRename) {
File videoPath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Video"); if (telegramPath.isDirectory()) {
videoPath.mkdir(); try {
if (videoPath.isDirectory()) { File imagePath = new File(telegramPath, "Telegram Images");
mediaDirs.put(FileLoader.MEDIA_DIR_VIDEO, videoPath); imagePath.mkdir();
FileLog.e("tmessages", "video path = " + videoPath); if (imagePath.isDirectory()) {
mediaDirs.put(FileLoader.MEDIA_DIR_IMAGE, imagePath);
FileLog.e("tmessages", "image path = " + imagePath);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} }
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try { try {
File audioPath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Audio"); File videoPath = new File(telegramPath, "Telegram Video");
audioPath.mkdir(); videoPath.mkdir();
if (audioPath.isDirectory()) { if (videoPath.isDirectory()) {
new File(audioPath, ".nomedia").createNewFile(); mediaDirs.put(FileLoader.MEDIA_DIR_VIDEO, videoPath);
mediaDirs.put(FileLoader.MEDIA_DIR_AUDIO, audioPath); FileLog.e("tmessages", "video path = " + videoPath);
FileLog.e("tmessages", "audio path = " + audioPath); }
} catch (Exception e) {
FileLog.e("tmessages", e);
} }
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try { try {
File documentPath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Documents"); File audioPath = new File(telegramPath, "Telegram Audio");
documentPath.mkdir(); audioPath.mkdir();
if (documentPath.isDirectory()) { if (audioPath.isDirectory()) {
new File(documentPath, ".nomedia").createNewFile(); new File(audioPath, ".nomedia").createNewFile();
mediaDirs.put(FileLoader.MEDIA_DIR_DOCUMENT, documentPath); mediaDirs.put(FileLoader.MEDIA_DIR_AUDIO, audioPath);
FileLog.e("tmessages", "documents path = " + documentPath); FileLog.e("tmessages", "audio path = " + audioPath);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
File documentPath = new File(telegramPath, "Telegram Documents");
documentPath.mkdir();
if (documentPath.isDirectory()) {
new File(documentPath, ".nomedia").createNewFile();
mediaDirs.put(FileLoader.MEDIA_DIR_DOCUMENT, documentPath);
FileLog.e("tmessages", "documents path = " + documentPath);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} }
} catch (Exception e) {
FileLog.e("tmessages", e);
} }
} else {
FileLog.e("tmessages", "this Android can't rename files");
} }
} }
MediaController.getInstance().checkSaveToGalleryFiles(); MediaController.getInstance().checkSaveToGalleryFiles();
...@@ -809,7 +832,7 @@ public class ImageLoader { ...@@ -809,7 +832,7 @@ public class ImageLoader {
}); });
} }
public void loadImage(final TLRPC.FileLocation fileLocation, final String httpUrl, final ImageReceiver imageView, final int size) { public void loadImage(final TLRPC.FileLocation fileLocation, final String httpUrl, final ImageReceiver imageView, final int size, final boolean cacheOnly) {
if ((fileLocation == null && httpUrl == null) || imageView == null || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) { if ((fileLocation == null && httpUrl == null) || imageView == null || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) {
return; return;
} }
...@@ -861,7 +884,7 @@ public class ImageLoader { ...@@ -861,7 +884,7 @@ public class ImageLoader {
if (!added) { if (!added) {
boolean onlyCache = false; boolean onlyCache = false;
File cacheFile = null; File cacheFile = null;
if (size == 0 || httpUrl != null || fileLocation != null && (fileLocation.key != null || fileLocation.volume_id == Integer.MIN_VALUE && fileLocation.local_id < 0)) { if (cacheOnly || size == 0 || httpUrl != null || fileLocation != null && (fileLocation.key != null || fileLocation.volume_id == Integer.MIN_VALUE && fileLocation.local_id < 0)) {
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), url); cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), url);
} else { } else {
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_IMAGE), url); cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_IMAGE), url);
...@@ -898,7 +921,7 @@ public class ImageLoader { ...@@ -898,7 +921,7 @@ public class ImageLoader {
img.addImageView(imageView); img.addImageView(imageView);
imageLoadingByUrl.put(url, img); imageLoadingByUrl.put(url, img);
if (httpUrl == null) { if (httpUrl == null) {
FileLoader.getInstance().loadFile(fileLocation, size, size == 0 || fileLocation.key != null); FileLoader.getInstance().loadFile(fileLocation, size, size == 0 || fileLocation.key != null || cacheOnly);
} else { } else {
String file = Utilities.MD5(httpUrl); String file = Utilities.MD5(httpUrl);
File cacheDir = FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE); File cacheDir = FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE);
......
...@@ -34,6 +34,7 @@ public class ImageReceiver { ...@@ -34,6 +34,7 @@ public class ImageReceiver {
private Rect drawRegion = new Rect(); private Rect drawRegion = new Rect();
private boolean isVisible = true; private boolean isVisible = true;
private boolean isAspectFit = false; private boolean isAspectFit = false;
private boolean lastCacheOnly = false;
public ImageReceiver() { public ImageReceiver() {
...@@ -43,19 +44,19 @@ public class ImageReceiver { ...@@ -43,19 +44,19 @@ public class ImageReceiver {
parentView = view; parentView = view;
} }
public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder) { public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder, boolean cacheOnly) {
setImage(path, null, filter, placeholder, 0); setImage(path, null, filter, placeholder, 0, cacheOnly);
} }
public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder, int size) { public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder, int size, boolean cacheOnly) {
setImage(path, null, filter, placeholder, size); setImage(path, null, filter, placeholder, size, cacheOnly);
} }
public void setImage(String path, String filter, Drawable placeholder) { public void setImage(String path, String filter, Drawable placeholder) {
setImage(null, path, filter, placeholder, 0); setImage(null, path, filter, placeholder, 0, true);
} }
public void setImage(TLRPC.FileLocation fileLocation, String httpUrl, String filter, Drawable placeholder, int size) { public void setImage(TLRPC.FileLocation fileLocation, String httpUrl, String filter, Drawable placeholder, int size, boolean cacheOnly) {
if ((fileLocation == null && httpUrl == null) || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) { if ((fileLocation == null && httpUrl == null) || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) {
recycleBitmap(null); recycleBitmap(null);
currentPath = null; currentPath = null;
...@@ -63,6 +64,7 @@ public class ImageReceiver { ...@@ -63,6 +64,7 @@ public class ImageReceiver {
last_path = null; last_path = null;
last_httpUrl = null; last_httpUrl = null;
last_filter = null; last_filter = null;
lastCacheOnly = false;
last_placeholder = placeholder; last_placeholder = placeholder;
last_size = 0; last_size = 0;
currentImage = null; currentImage = null;
...@@ -101,9 +103,10 @@ public class ImageReceiver { ...@@ -101,9 +103,10 @@ public class ImageReceiver {
last_filter = filter; last_filter = filter;
last_placeholder = placeholder; last_placeholder = placeholder;
last_size = size; last_size = size;
lastCacheOnly = cacheOnly;
if (img == null) { if (img == null) {
isPlaceholder = true; isPlaceholder = true;
ImageLoader.getInstance().loadImage(fileLocation, httpUrl, this, size); ImageLoader.getInstance().loadImage(fileLocation, httpUrl, this, size, cacheOnly);
} else { } else {
setImageBitmap(img, currentPath); setImageBitmap(img, currentPath);
} }
...@@ -136,6 +139,7 @@ public class ImageReceiver { ...@@ -136,6 +139,7 @@ public class ImageReceiver {
last_filter = null; last_filter = null;
currentImage = null; currentImage = null;
last_size = 0; last_size = 0;
lastCacheOnly = false;
if (parentView != null) { if (parentView != null) {
parentView.invalidate(); parentView.invalidate();
} }
...@@ -152,6 +156,7 @@ public class ImageReceiver { ...@@ -152,6 +156,7 @@ public class ImageReceiver {
last_httpUrl = null; last_httpUrl = null;
last_filter = null; last_filter = null;
last_size = 0; last_size = 0;
lastCacheOnly = false;
if (parentView != null) { if (parentView != null) {
parentView.invalidate(); parentView.invalidate();
} }
...@@ -213,7 +218,7 @@ public class ImageReceiver { ...@@ -213,7 +218,7 @@ public class ImageReceiver {
ImageLoader.getInstance().removeImage(currentPath); ImageLoader.getInstance().removeImage(currentPath);
currentPath = null; currentPath = null;
} }
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size); setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size, lastCacheOnly);
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
canvas.restore(); canvas.restore();
...@@ -238,7 +243,7 @@ public class ImageReceiver { ...@@ -238,7 +243,7 @@ public class ImageReceiver {
ImageLoader.getInstance().removeImage(currentPath); ImageLoader.getInstance().removeImage(currentPath);
currentPath = null; currentPath = null;
} }
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size); setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size, lastCacheOnly);
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }
...@@ -255,7 +260,7 @@ public class ImageReceiver { ...@@ -255,7 +260,7 @@ public class ImageReceiver {
ImageLoader.getInstance().removeImage(currentPath); ImageLoader.getInstance().removeImage(currentPath);
currentPath = null; currentPath = null;
} }
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size); setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size, lastCacheOnly);
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }
...@@ -273,7 +278,7 @@ public class ImageReceiver { ...@@ -273,7 +278,7 @@ public class ImageReceiver {
ImageLoader.getInstance().removeImage(currentPath); ImageLoader.getInstance().removeImage(currentPath);
currentPath = null; currentPath = null;
} }
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size); setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size, lastCacheOnly);
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }
......
...@@ -216,6 +216,14 @@ public class LocaleController { ...@@ -216,6 +216,14 @@ public class LocaleController {
sortedLanguages.add(localeInfo); sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo); languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "한국어";
localeInfo.nameEnglish = "Korean";
localeInfo.shortName = "ko";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
loadOtherLanguages(); loadOtherLanguages();
for (LocaleInfo locale : otherLanguages) { for (LocaleInfo locale : otherLanguages) {
...@@ -510,6 +518,19 @@ public class LocaleController { ...@@ -510,6 +518,19 @@ public class LocaleController {
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
editor.remove("language"); editor.remove("language");
editor.commit(); editor.commit();
if (newLocale != null) {
LocaleInfo info = null;
if (newLocale.getLanguage() != null) {
info = languagesDict.get(newLocale.getLanguage());
}
if (info == null) {
info = languagesDict.get(getLocaleString(newLocale));
}
if (info == null) {
newLocale = Locale.US;
}
}
} }
if (newLocale != null) { if (newLocale != null) {
if (localeInfo.pathToFile == null) { if (localeInfo.pathToFile == null) {
...@@ -672,7 +693,10 @@ public class LocaleController { ...@@ -672,7 +693,10 @@ public class LocaleController {
} }
public void recreateFormatters() { public void recreateFormatters() {
Locale locale = Locale.getDefault(); Locale locale = currentLocale;
if (locale == null) {
locale = Locale.getDefault();
}
String lang = locale.getLanguage(); String lang = locale.getLanguage();
if (lang == null) { if (lang == null) {
lang = "en"; lang = "en";
...@@ -727,7 +751,11 @@ public class LocaleController { ...@@ -727,7 +751,11 @@ public class LocaleController {
formatString = "h:mm a"; formatString = "h:mm a";
} }
} }
formatterDay = FastDateFormat.getInstance(formatString, locale); if (lang.toLowerCase().equals("ar") || lang.toLowerCase().equals("ko")) {
formatterDay = FastDateFormat.getInstance(formatString, locale);
} else {
formatterDay = FastDateFormat.getInstance(formatString, Locale.US);
}
} }
public static String stringForMessageListDate(long date) { public static String stringForMessageListDate(long date) {
......
...@@ -144,7 +144,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -144,7 +144,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} }
} }
private final static String MIME_TYPE = "video/avc"; public final static String MIME_TYPE = "video/avc";
private final static int PROCESSOR_TYPE_OTHER = 0; private final static int PROCESSOR_TYPE_OTHER = 0;
private final static int PROCESSOR_TYPE_QCOM = 1; private final static int PROCESSOR_TYPE_QCOM = 1;
private final static int PROCESSOR_TYPE_INTEL = 2; private final static int PROCESSOR_TYPE_INTEL = 2;
...@@ -1799,10 +1799,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1799,10 +1799,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public void checkSaveToGalleryFiles() { public void checkSaveToGalleryFiles() {
try { try {
File telegramPath = new File(Environment.getExternalStorageDirectory(), LocaleController.getString("AppName", R.string.AppName)); File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
File imagePath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Images"); File imagePath = new File(telegramPath, "Telegram Images");
imagePath.mkdir(); imagePath.mkdir();
File videoPath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Video"); File videoPath = new File(telegramPath, "Telegram Video");
videoPath.mkdir(); videoPath.mkdir();
if (saveToGallery) { if (saveToGallery) {
...@@ -1946,7 +1946,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1946,7 +1946,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} }
} }
private static MediaCodecInfo selectCodec(String mimeType) { public static MediaCodecInfo selectCodec(String mimeType) {
int numCodecs = MediaCodecList.getCodecCount(); int numCodecs = MediaCodecList.getCodecCount();
MediaCodecInfo lastCodecInfo = null; MediaCodecInfo lastCodecInfo = null;
for (int i = 0; i < numCodecs; i++) { for (int i = 0; i < numCodecs; i++) {
...@@ -1982,7 +1982,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1982,7 +1982,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} }
} }
private static int selectColorFormat(MediaCodecInfo codecInfo, String mimeType) { public static int selectColorFormat(MediaCodecInfo codecInfo, String mimeType) {
MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mimeType); MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mimeType);
int lastColorFormat = 0; int lastColorFormat = 0;
for (int i = 0; i < capabilities.colorFormats.length; i++) { for (int i = 0; i < capabilities.colorFormats.length; i++) {
......
...@@ -1241,7 +1241,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -1241,7 +1241,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
return; return;
} }
} }
req.typing = true; req.action = new TLRPC.TL_sendMessageTypingAction();
sendingTypings.put(dialog_id, true); sendingTypings.put(dialog_id, true);
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
...@@ -1668,6 +1668,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -1668,6 +1668,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
req.max_id = max_positive_id; req.max_id = max_positive_id;
req.offset = offset; req.offset = offset;
req.read_contents = true;
if (offset == 0) { if (offset == 0) {
MessagesStorage.getInstance().processPendingRead(dialog_id, max_positive_id, max_date, false); MessagesStorage.getInstance().processPendingRead(dialog_id, max_positive_id, max_date, false);
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() { MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
...@@ -1712,17 +1713,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -1712,17 +1713,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
}); });
} }
if (offset == 0) {
TLRPC.TL_messages_receivedMessages req2 = new TLRPC.TL_messages_receivedMessages();
req2.max_id = max_positive_id;
ConnectionsManager.getInstance().performRpc(req2, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
}
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
}
} else { } else {
if (max_date == 0) { if (max_date == 0) {
return; return;
...@@ -1967,7 +1957,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -1967,7 +1957,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
} }
public void deleteUserFromChat(int chat_id, final TLRPC.User user, final TLRPC.ChatParticipants info) { public void deleteUserFromChat(final int chat_id, final TLRPC.User user, final TLRPC.ChatParticipants info) {
if (user == null) { if (user == null) {
return; return;
} }
...@@ -2008,9 +1998,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -2008,9 +1998,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
} }
if (changed) { if (changed) {
MessagesStorage.getInstance().updateChatInfo(info.chat_id, info, true); MessagesStorage.getInstance().updateChatInfo(chat_id, info, true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, info.chat_id, info); NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, info.chat_id, info);
} else {
MessagesStorage.getInstance().updateChatInfo(chat_id, user.id, true, 0, 0);
} }
} else {
MessagesStorage.getInstance().updateChatInfo(chat_id, user.id, true, 0, 0);
} }
} }
}); });
...@@ -2575,6 +2569,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -2575,6 +2569,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
message.to_id.chat_id = updates.chat_id; message.to_id.chat_id = updates.chat_id;
message.message = updates.message; message.message = updates.message;
message.date = updates.date; message.date = updates.date;
message.flags = TLRPC.MESSAGE_FLAG_UNREAD;
message.unread = true; message.unread = true;
message.media = new TLRPC.TL_messageMediaEmpty(); message.media = new TLRPC.TL_messageMediaEmpty();
MessagesStorage.lastSeqValue = updates.seq; MessagesStorage.lastSeqValue = updates.seq;
...@@ -2641,6 +2636,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -2641,6 +2636,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
message.message = updates.message; message.message = updates.message;
message.date = updates.date; message.date = updates.date;
message.unread = true; message.unread = true;
message.flags = TLRPC.MESSAGE_FLAG_UNREAD;
message.media = new TLRPC.TL_messageMediaEmpty(); message.media = new TLRPC.TL_messageMediaEmpty();
MessagesStorage.lastSeqValue = updates.seq; MessagesStorage.lastSeqValue = updates.seq;
MessagesStorage.lastPtsValue = updates.pts; MessagesStorage.lastPtsValue = updates.pts;
...@@ -2873,7 +2869,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -2873,7 +2869,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else if (update instanceof TLRPC.TL_updateRestoreMessages) { } else if (update instanceof TLRPC.TL_updateRestoreMessages) {
MessagesStorage.lastPtsValue = update.pts; MessagesStorage.lastPtsValue = update.pts;
} else if (update instanceof TLRPC.TL_updateUserTyping || update instanceof TLRPC.TL_updateChatUserTyping) { } else if (update instanceof TLRPC.TL_updateUserTyping || update instanceof TLRPC.TL_updateChatUserTyping) {
if (update.user_id != UserConfig.getClientUserId()) { if (update.action instanceof TLRPC.TL_sendMessageTypingAction && update.user_id != UserConfig.getClientUserId()) {
long uid = -update.chat_id; long uid = -update.chat_id;
if (uid == 0) { if (uid == 0) {
uid = update.user_id; uid = update.user_id;
...@@ -2919,6 +2915,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -2919,6 +2915,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMessage.local_id = newMessage.id = UserConfig.getNewMessageId(); newMessage.local_id = newMessage.id = UserConfig.getNewMessageId();
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
newMessage.unread = true; newMessage.unread = true;
newMessage.flags = TLRPC.MESSAGE_FLAG_UNREAD;
newMessage.date = update.date; newMessage.date = update.date;
newMessage.from_id = update.user_id; newMessage.from_id = update.user_id;
newMessage.to_id = new TLRPC.TL_peerUser(); newMessage.to_id = new TLRPC.TL_peerUser();
...@@ -2964,6 +2961,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -2964,6 +2961,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMessage.local_id = newMessage.id = UserConfig.getNewMessageId(); newMessage.local_id = newMessage.id = UserConfig.getNewMessageId();
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
newMessage.unread = true; newMessage.unread = true;
newMessage.flags = TLRPC.MESSAGE_FLAG_UNREAD;
newMessage.date = update.date; newMessage.date = update.date;
newMessage.from_id = 777000; newMessage.from_id = 777000;
newMessage.to_id = new TLRPC.TL_peerUser(); newMessage.to_id = new TLRPC.TL_peerUser();
...@@ -3509,6 +3507,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -3509,6 +3507,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMessage.to_id = new TLRPC.TL_peerUser(); newMessage.to_id = new TLRPC.TL_peerUser();
newMessage.random_id = message.random_id; newMessage.random_id = message.random_id;
newMessage.to_id.user_id = UserConfig.getClientUserId(); newMessage.to_id.user_id = UserConfig.getClientUserId();
newMessage.flags = TLRPC.MESSAGE_FLAG_UNREAD;
newMessage.out = false; newMessage.out = false;
newMessage.unread = true; newMessage.unread = true;
newMessage.dialog_id = ((long)chat.id) << 32; newMessage.dialog_id = ((long)chat.id) << 32;
...@@ -3657,6 +3656,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -3657,6 +3656,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
newMessage.local_id = newMessage.id = UserConfig.getNewMessageId(); newMessage.local_id = newMessage.id = UserConfig.getNewMessageId();
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
newMessage.flags = TLRPC.MESSAGE_FLAG_UNREAD;
newMessage.unread = true; newMessage.unread = true;
newMessage.date = message.date; newMessage.date = message.date;
newMessage.from_id = from_id; newMessage.from_id = from_id;
......
...@@ -1213,23 +1213,19 @@ public class MessagesStorage { ...@@ -1213,23 +1213,19 @@ public class MessagesStorage {
SQLiteCursor cursor = database.queryFinalized("SELECT u.data, u.status, u.name FROM users as u INNER JOIN contacts as c ON u.uid = c.uid"); SQLiteCursor cursor = database.queryFinalized("SELECT u.data, u.status, u.name FROM users as u INNER JOIN contacts as c ON u.uid = c.uid");
while (cursor.next()) { while (cursor.next()) {
String name = cursor.stringValue(2); String name = cursor.stringValue(2);
String[] args = name.split(" "); if (name.startsWith(q) || name.contains(" " + q)) {
for (String str : args) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0));
if (str.startsWith(q)) { if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); TLRPC.User user = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data, data.readInt32());
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { if (user.id != UserConfig.getClientUserId()) {
TLRPC.User user = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data, data.readInt32()); if (user.status != null) {
if (user.id != UserConfig.getClientUserId()) { user.status.expires = cursor.intValue(1);
if (user.status != null) {
user.status.expires = cursor.intValue(1);
}
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
resultArray.add(user);
} }
resultArrayNames.add(Utilities.generateSearchName(user.first_name, user.last_name, q));
resultArray.add(user);
} }
buffersStorage.reuseFreeBuffer(data);
break;
} }
buffersStorage.reuseFreeBuffer(data);
} }
} }
cursor.dispose(); cursor.dispose();
...@@ -1238,30 +1234,26 @@ public class MessagesStorage { ...@@ -1238,30 +1234,26 @@ public class MessagesStorage {
cursor = database.queryFinalized("SELECT q.data, q.name, q.user, q.g, q.authkey, q.ttl, u.data, u.status FROM enc_chats as q INNER JOIN dialogs as d ON (q.uid << 32) = d.did INNER JOIN users as u ON q.user = u.uid"); cursor = database.queryFinalized("SELECT q.data, q.name, q.user, q.g, q.authkey, q.ttl, u.data, u.status FROM enc_chats as q INNER JOIN dialogs as d ON (q.uid << 32) = d.did INNER JOIN users as u ON q.user = u.uid");
while (cursor.next()) { while (cursor.next()) {
String name = cursor.stringValue(1); String name = cursor.stringValue(1);
String[] args = name.split(" "); if (name.startsWith(q) || name.contains(" " + q)) {
for (String arg : args) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0));
if (arg.startsWith(q)) { ByteBufferDesc data2 = buffersStorage.getFreeBuffer(cursor.byteArrayLength(6));
ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0 && cursor.byteBufferValue(6, data2.buffer) != 0) {
ByteBufferDesc data2 = buffersStorage.getFreeBuffer(cursor.byteArrayLength(6)); TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0 && cursor.byteBufferValue(6, data2.buffer) != 0) { chat.user_id = cursor.intValue(2);
TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); chat.a_or_b = cursor.byteArrayValue(3);
chat.user_id = cursor.intValue(2); chat.auth_key = cursor.byteArrayValue(4);
chat.a_or_b = cursor.byteArrayValue(3); chat.ttl = cursor.intValue(5);
chat.auth_key = cursor.byteArrayValue(4);
chat.ttl = cursor.intValue(5); TLRPC.User user = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data2, data2.readInt32());
if (user.status != null) {
TLRPC.User user = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data2, data2.readInt32()); user.status.expires = cursor.intValue(7);
if (user.status != null) {
user.status.expires = cursor.intValue(7);
}
resultArrayNames.add(Html.fromHtml("<font color=\"#00a60e\">" + ContactsController.formatName(user.first_name, user.last_name) + "</font>"));
resultArray.add(chat);
encUsers.add(user);
} }
buffersStorage.reuseFreeBuffer(data); resultArrayNames.add(Html.fromHtml("<font color=\"#00a60e\">" + ContactsController.formatName(user.first_name, user.last_name) + "</font>"));
buffersStorage.reuseFreeBuffer(data2); resultArray.add(chat);
break; encUsers.add(user);
} }
buffersStorage.reuseFreeBuffer(data);
buffersStorage.reuseFreeBuffer(data2);
} }
} }
cursor.dispose(); cursor.dispose();
...@@ -1271,20 +1263,17 @@ public class MessagesStorage { ...@@ -1271,20 +1263,17 @@ public class MessagesStorage {
while (cursor.next()) { while (cursor.next()) {
String name = cursor.stringValue(1); String name = cursor.stringValue(1);
String[] args = name.split(" "); String[] args = name.split(" ");
for (String arg : args) { if (name.startsWith(q) || name.contains(" " + q)) {
if (arg.startsWith(q)) { ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0));
ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0)); if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) { TLRPC.Chat chat = (TLRPC.Chat) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
TLRPC.Chat chat = (TLRPC.Chat) TLClassStore.Instance().TLdeserialize(data, data.readInt32()); if (!needEncrypted && chat.id < 0) {
if (!needEncrypted && chat.id < 0) { continue;
continue;
}
resultArrayNames.add(Utilities.generateSearchName(chat.title, null, q));
resultArray.add(chat);
} }
buffersStorage.reuseFreeBuffer(data); resultArrayNames.add(Utilities.generateSearchName(chat.title, null, q));
break; resultArray.add(chat);
} }
buffersStorage.reuseFreeBuffer(data);
} }
} }
cursor.dispose(); cursor.dispose();
......
...@@ -486,6 +486,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -486,6 +486,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
newMsg.local_id = newMsg.id = UserConfig.getNewMessageId(); newMsg.local_id = newMsg.id = UserConfig.getNewMessageId();
newMsg.from_id = UserConfig.getClientUserId(); newMsg.from_id = UserConfig.getClientUserId();
newMsg.flags |= TLRPC.MESSAGE_FLAG_OUT;
newMsg.out = true; newMsg.out = true;
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
} }
...@@ -493,6 +494,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -493,6 +494,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg.random_id = getNextRandomId(); newMsg.random_id = getNextRandomId();
} }
newMsg.date = ConnectionsManager.getInstance().getCurrentTime(); newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD;
newMsg.unread = true; newMsg.unread = true;
newMsg.dialog_id = peer; newMsg.dialog_id = peer;
int lower_id = (int) peer; int lower_id = (int) peer;
...@@ -581,7 +583,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -581,7 +583,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
performSendMessageRequest(reqSend, newMsgObj, null); performSendMessageRequest(reqSend, newMsgObj, null);
} }
} else { } else {
TLRPC.TL_decryptedMessage reqSend = new TLRPC.TL_decryptedMessage(); TLRPC.TL_decryptedMessage_old reqSend = new TLRPC.TL_decryptedMessage_old();
reqSend.random_id = newMsg.random_id; reqSend.random_id = newMsg.random_id;
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
...@@ -733,7 +735,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -733,7 +735,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
} }
} else { } else {
TLRPC.TL_decryptedMessage reqSend = new TLRPC.TL_decryptedMessage(); TLRPC.TL_decryptedMessage_old reqSend = new TLRPC.TL_decryptedMessage_old();
reqSend.random_id = newMsg.random_id; reqSend.random_id = newMsg.random_id;
reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
...@@ -1407,7 +1409,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1407,7 +1409,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) { if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return; return;
} }
TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService(); TLRPC.TL_decryptedMessageService_old reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_id = getNextRandomId(); reqSend.random_id = getNextRandomId();
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
...@@ -1420,7 +1422,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1420,7 +1422,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) { if (!(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return; return;
} }
TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService(); TLRPC.TL_decryptedMessageService_old reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_id = getNextRandomId(); reqSend.random_id = getNextRandomId();
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
...@@ -1439,6 +1441,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1439,6 +1441,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg.local_id = newMsg.id = UserConfig.getNewMessageId(); newMsg.local_id = newMsg.id = UserConfig.getNewMessageId();
newMsg.from_id = UserConfig.getClientUserId(); newMsg.from_id = UserConfig.getClientUserId();
newMsg.unread = true; newMsg.unread = true;
newMsg.flags = TLRPC.MESSAGE_FLAG_UNREAD | TLRPC.MESSAGE_FLAG_OUT;
newMsg.dialog_id = ((long)encryptedChat.id) << 32; newMsg.dialog_id = ((long)encryptedChat.id) << 32;
newMsg.to_id = new TLRPC.TL_peerUser(); newMsg.to_id = new TLRPC.TL_peerUser();
if (encryptedChat.participant_id == UserConfig.getClientUserId()) { if (encryptedChat.participant_id == UserConfig.getClientUserId()) {
...@@ -1461,7 +1464,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1461,7 +1464,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
MessagesController.getInstance().updateInterfaceWithMessages(newMsg.dialog_id, objArr); MessagesController.getInstance().updateInterfaceWithMessages(newMsg.dialog_id, objArr);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService(); TLRPC.TL_decryptedMessageService_old reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_id = newMsg.random_id; reqSend.random_id = newMsg.random_id;
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
...@@ -1486,6 +1489,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1486,6 +1489,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg.local_id = newMsg.id = UserConfig.getNewMessageId(); newMsg.local_id = newMsg.id = UserConfig.getNewMessageId();
newMsg.from_id = UserConfig.getClientUserId(); newMsg.from_id = UserConfig.getClientUserId();
newMsg.unread = true; newMsg.unread = true;
newMsg.flags = TLRPC.MESSAGE_FLAG_UNREAD | TLRPC.MESSAGE_FLAG_OUT;
newMsg.dialog_id = ((long)encryptedChat.id) << 32; newMsg.dialog_id = ((long)encryptedChat.id) << 32;
newMsg.to_id = new TLRPC.TL_peerUser(); newMsg.to_id = new TLRPC.TL_peerUser();
if (encryptedChat.participant_id == UserConfig.getClientUserId()) { if (encryptedChat.participant_id == UserConfig.getClientUserId()) {
...@@ -1508,7 +1512,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1508,7 +1512,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
MessagesController.getInstance().updateInterfaceWithMessages(newMsg.dialog_id, objArr); MessagesController.getInstance().updateInterfaceWithMessages(newMsg.dialog_id, objArr);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
TLRPC.TL_decryptedMessageService reqSend = new TLRPC.TL_decryptedMessageService(); TLRPC.TL_decryptedMessageService_old reqSend = new TLRPC.TL_decryptedMessageService_old();
reqSend.random_id = newMsg.random_id; reqSend.random_id = newMsg.random_id;
reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))]; reqSend.random_bytes = new byte[Math.max(1, (int)Math.ceil(Utilities.random.nextDouble() * 16))];
Utilities.random.nextBytes(reqSend.random_bytes); Utilities.random.nextBytes(reqSend.random_bytes);
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
package org.telegram.messenger; package org.telegram.messenger;
public class BuildVars { public class BuildVars {
public static boolean DEBUG_VERSION = true; public static boolean DEBUG_VERSION = false;
public static int APP_ID = 2458; public static int APP_ID = 0; //obtaion your own APP_ID at https://core.telegram.org/api/obtaining_api_id
public static String APP_HASH = "5bce48dc7d331e62c955669eb7233217"; public static String APP_HASH = ""; //obtaion your own APP_HASH at https://core.telegram.org/api/obtaining_api_id
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here"; public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";
public static String GCM_SENDER_ID = "760348033672"; public static String GCM_SENDER_ID = "760348033672";
public static String SEND_LOGS_EMAIL = "email@gmail.com"; public static String SEND_LOGS_EMAIL = "email@gmail.com";
......
...@@ -833,7 +833,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -833,7 +833,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
object = invoke; object = invoke;
} }
TLRPC.invokeWithLayer14 invoke = new TLRPC.invokeWithLayer14(); TLRPC.invokeWithLayer17 invoke = new TLRPC.invokeWithLayer17();
invoke.query = object; invoke.query = object;
FileLog.d("wrap in layer", "" + object); FileLog.d("wrap in layer", "" + object);
return invoke; return invoke;
...@@ -1604,12 +1604,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1604,12 +1604,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
TLRPC.TL_protoMessage message = networkMessage.protoMessage; TLRPC.TL_protoMessage message = networkMessage.protoMessage;
if (BuildVars.DEBUG_VERSION) { if (BuildVars.DEBUG_VERSION) {
if (message.body instanceof TLRPC.invokeWithLayer14) { if (message.body instanceof TLRPC.invokeWithLayer17) {
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)message.body).query); FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)message.body).query);
} else if (message.body instanceof TLRPC.initConnection) { } else if (message.body instanceof TLRPC.initConnection) {
TLRPC.initConnection r = (TLRPC.initConnection)message.body; TLRPC.initConnection r = (TLRPC.initConnection)message.body;
if (r.query instanceof TLRPC.invokeWithLayer14) { if (r.query instanceof TLRPC.invokeWithLayer17) {
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)r.query).query); FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)r.query).query);
} else { } else {
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query);
} }
...@@ -1644,12 +1644,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -1644,12 +1644,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
TLRPC.TL_protoMessage message = networkMessage.protoMessage; TLRPC.TL_protoMessage message = networkMessage.protoMessage;
containerMessages.add(message); containerMessages.add(message);
if (BuildVars.DEBUG_VERSION) { if (BuildVars.DEBUG_VERSION) {
if (message.body instanceof TLRPC.invokeWithLayer14) { if (message.body instanceof TLRPC.invokeWithLayer17) {
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)message.body).query); FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)message.body).query);
} else if (message.body instanceof TLRPC.initConnection) { } else if (message.body instanceof TLRPC.initConnection) {
TLRPC.initConnection r = (TLRPC.initConnection)message.body; TLRPC.initConnection r = (TLRPC.initConnection)message.body;
if (r.query instanceof TLRPC.invokeWithLayer14) { if (r.query instanceof TLRPC.invokeWithLayer17) {
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)r.query).query); FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer17)r.query).query);
} else { } else {
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query); FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query);
} }
......
...@@ -593,38 +593,42 @@ public class FileLoader { ...@@ -593,38 +593,42 @@ public class FileLoader {
} }
public static File getPathToAttach(TLObject attach) { public static File getPathToAttach(TLObject attach) {
return getPathToAttach(attach, false);
}
public static File getPathToAttach(TLObject attach, boolean forceCache) {
File dir = null; File dir = null;
if (attach instanceof TLRPC.Video) { if (attach instanceof TLRPC.Video) {
TLRPC.Video video = (TLRPC.Video)attach; TLRPC.Video video = (TLRPC.Video)attach;
if (video.key != null) { if (forceCache || video.key != null) {
dir = getInstance().getDirectory(MEDIA_DIR_CACHE); dir = getInstance().getDirectory(MEDIA_DIR_CACHE);
} else { } else {
dir = getInstance().getDirectory(MEDIA_DIR_VIDEO); dir = getInstance().getDirectory(MEDIA_DIR_VIDEO);
} }
} else if (attach instanceof TLRPC.Document) { } else if (attach instanceof TLRPC.Document) {
TLRPC.Document document = (TLRPC.Document)attach; TLRPC.Document document = (TLRPC.Document)attach;
if (document.key != null) { if (forceCache || document.key != null) {
dir = getInstance().getDirectory(MEDIA_DIR_CACHE); dir = getInstance().getDirectory(MEDIA_DIR_CACHE);
} else { } else {
dir = getInstance().getDirectory(MEDIA_DIR_DOCUMENT); dir = getInstance().getDirectory(MEDIA_DIR_DOCUMENT);
} }
} else if (attach instanceof TLRPC.PhotoSize) { } else if (attach instanceof TLRPC.PhotoSize) {
TLRPC.PhotoSize photoSize = (TLRPC.PhotoSize)attach; TLRPC.PhotoSize photoSize = (TLRPC.PhotoSize)attach;
if (photoSize.location == null || photoSize.location.key != null || photoSize.location.volume_id == Integer.MIN_VALUE && photoSize.location.local_id < 0) { if (forceCache || photoSize.location == null || photoSize.location.key != null || photoSize.location.volume_id == Integer.MIN_VALUE && photoSize.location.local_id < 0) {
dir = getInstance().getDirectory(MEDIA_DIR_CACHE); dir = getInstance().getDirectory(MEDIA_DIR_CACHE);
} else { } else {
dir = getInstance().getDirectory(MEDIA_DIR_IMAGE); dir = getInstance().getDirectory(MEDIA_DIR_IMAGE);
} }
} else if (attach instanceof TLRPC.Audio) { } else if (attach instanceof TLRPC.Audio) {
TLRPC.Audio audio = (TLRPC.Audio)attach; TLRPC.Audio audio = (TLRPC.Audio)attach;
if (audio.key != null) { if (forceCache || audio.key != null) {
dir = getInstance().getDirectory(MEDIA_DIR_CACHE); dir = getInstance().getDirectory(MEDIA_DIR_CACHE);
} else { } else {
dir = getInstance().getDirectory(MEDIA_DIR_AUDIO); dir = getInstance().getDirectory(MEDIA_DIR_AUDIO);
} }
} else if (attach instanceof TLRPC.FileLocation) { } else if (attach instanceof TLRPC.FileLocation) {
TLRPC.FileLocation fileLocation = (TLRPC.FileLocation)attach; TLRPC.FileLocation fileLocation = (TLRPC.FileLocation)attach;
if (fileLocation.key != null || fileLocation.volume_id == Integer.MIN_VALUE && fileLocation.local_id < 0) { if (forceCache || fileLocation.key != null || fileLocation.volume_id == Integer.MIN_VALUE && fileLocation.local_id < 0) {
dir = getInstance().getDirectory(MEDIA_DIR_CACHE); dir = getInstance().getDirectory(MEDIA_DIR_CACHE);
} else { } else {
dir = getInstance().getDirectory(MEDIA_DIR_IMAGE); dir = getInstance().getDirectory(MEDIA_DIR_IMAGE);
......
...@@ -530,7 +530,7 @@ public class Utilities { ...@@ -530,7 +530,7 @@ public class Utilities {
private static File getAlbumDir() { private static File getAlbumDir() {
File storageDir = null; File storageDir = null;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), LocaleController.getString("AppName", R.string.AppName)); storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Telegram");
if (storageDir != null) { if (storageDir != null) {
if (!storageDir.mkdirs()) { if (!storageDir.mkdirs()) {
if (!storageDir.exists()){ if (!storageDir.exists()){
...@@ -644,7 +644,6 @@ public class Utilities { ...@@ -644,7 +644,6 @@ public class Utilities {
if (name == null && name2 == null) { if (name == null && name2 == null) {
return ""; return "";
} }
int index;
SpannableStringBuilder builder = new SpannableStringBuilder(); SpannableStringBuilder builder = new SpannableStringBuilder();
String wholeString = name; String wholeString = name;
if (wholeString == null || wholeString.length() == 0) { if (wholeString == null || wholeString.length() == 0) {
...@@ -653,28 +652,34 @@ public class Utilities { ...@@ -653,28 +652,34 @@ public class Utilities {
wholeString += " " + name2; wholeString += " " + name2;
} }
wholeString = wholeString.trim(); wholeString = wholeString.trim();
String[] args = wholeString.split(" "); String lower = " " + wholeString.toLowerCase();
for (String arg : args) { int index = -1;
String str = arg; int lastIndex = 0;
if (str != null) { while ((index = lower.indexOf(" " + q, lastIndex)) != -1) {
String lower = str.toLowerCase(); int idx = index - (index == 0 ? 0 : 1);
if (lower.startsWith(q)) { int end = q.length() + (index == 0 ? 0 : 1) + idx;
if (builder.length() != 0) {
builder.append(" "); if (lastIndex != 0 && lastIndex != idx + 1) {
} builder.append(wholeString.substring(lastIndex, idx));
String query = str.substring(0, q.length()); } else if (lastIndex == 0 && idx != 0) {
builder.append(Html.fromHtml("<font color=\"#357aa8\">" + query + "</font>")); builder.append(wholeString.substring(0, idx));
str = str.substring(q.length()); }
builder.append(str);
} else { String query = wholeString.substring(idx, end);
if (builder.length() != 0) { if (query.startsWith(" ")) {
builder.append(" "); builder.append(" ");
}
builder.append(str);
}
} }
query.trim();
builder.append(Html.fromHtml("<font color=\"#357aa8\">" + query + "</font>"));
lastIndex = end;
}
if (lastIndex != -1 && lastIndex != wholeString.length()) {
builder.append(wholeString.substring(lastIndex, wholeString.length()));
} }
return builder; return builder;
} }
......
...@@ -87,7 +87,8 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { ...@@ -87,7 +87,8 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
for (TLRPC.TL_contact contact : contactsCopy) { for (TLRPC.TL_contact contact : contactsCopy) {
TLRPC.User user = MessagesController.getInstance().getUser(contact.user_id); TLRPC.User user = MessagesController.getInstance().getUser(contact.user_id);
if (user.first_name != null && user.first_name.toLowerCase().startsWith(q) || user.last_name != null && user.last_name.toLowerCase().startsWith(q)) { String name = ContactsController.formatName(user.first_name, user.last_name).toLowerCase();
if (name.startsWith(q) || name.contains(" " + q)) {
if (user.id == UserConfig.getClientUserId()) { if (user.id == UserConfig.getClientUserId()) {
continue; continue;
} }
......
...@@ -354,9 +354,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -354,9 +354,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
if (audioUser.photo != null) { if (audioUser.photo != null) {
currentPhoto = audioUser.photo.photo_small; currentPhoto = audioUser.photo.photo_small;
} }
avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid))); avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false);
} else { } else {
avatarImage.setImage((TLRPC.FileLocation)null, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid))); avatarImage.setImage((TLRPC.FileLocation)null, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false);
} }
if (messageObject.isOut()) { if (messageObject.isOut()) {
......
...@@ -265,9 +265,9 @@ public class ChatBaseCell extends BaseCell { ...@@ -265,9 +265,9 @@ public class ChatBaseCell extends BaseCell {
} else { } else {
currentPhoto = null; currentPhoto = null;
} }
avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(currentUser.id))); avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(currentUser.id)), false);
} else { } else {
avatarImage.setImage((TLRPC.FileLocation)null, "50_50", null); avatarImage.setImage(null, "50_50", null, false);
} }
} }
......
...@@ -310,9 +310,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -310,9 +310,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
cancelLoading = false; cancelLoading = false;
if (currentMessageObject.type == 1) { if (currentMessageObject.type == 1) {
if (currentMessageObject.imagePreview != null) { if (currentMessageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(currentMessageObject.imagePreview), currentPhotoObject.photoOwner.size); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(currentMessageObject.imagePreview), currentPhotoObject.photoOwner.size, false);
} else { } else {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, currentMessageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, currentPhotoObject.photoOwner.size); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, currentMessageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, currentPhotoObject.photoOwner.size, false);
} }
} else if (currentMessageObject.type == 8 || currentMessageObject.type == 9) { } else if (currentMessageObject.type == 8 || currentMessageObject.type == 9) {
FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true); FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true);
...@@ -479,7 +479,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -479,7 +479,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoImage.setImageBitmap(currentPhotoObject.image); photoImage.setImageBitmap(currentPhotoObject.image);
} else { } else {
currentPhotoFilter = String.format(Locale.US, "%d_%d_b", photoWidth, photoHeight); currentPhotoFilter = String.format(Locale.US, "%d_%d_b", photoWidth, photoHeight);
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, null, 0); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, null, 0, false);
} }
} else { } else {
photoImage.setImageBitmap((BitmapDrawable)null); photoImage.setImageBitmap((BitmapDrawable)null);
...@@ -572,9 +572,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -572,9 +572,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} }
if (photoExist || MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO)) { if (photoExist || MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO)) {
if (messageObject.imagePreview != null) { if (messageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), noSize ? 0 : currentPhotoObject.photoOwner.size); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(messageObject.imagePreview), noSize ? 0 : currentPhotoObject.photoOwner.size, false);
} else { } else {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, noSize ? 0 : currentPhotoObject.photoOwner.size); photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable, noSize ? 0 : currentPhotoObject.photoOwner.size, false);
} }
} else { } else {
photoNotSet = true; photoNotSet = true;
......
...@@ -215,7 +215,7 @@ public class ChatOrUserCell extends BaseCell { ...@@ -215,7 +215,7 @@ public class ChatOrUserCell extends BaseCell {
lastAvatar = photo; lastAvatar = photo;
avatarImage.setImage(photo, "50_50", placeHolderId == 0 ? null : getResources().getDrawable(placeHolderId)); avatarImage.setImage(photo, "50_50", placeHolderId == 0 ? null : getResources().getDrawable(placeHolderId), false);
if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) { if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
buildLayout(); buildLayout();
......
...@@ -263,7 +263,7 @@ public class DialogCell extends BaseCell { ...@@ -263,7 +263,7 @@ public class DialogCell extends BaseCell {
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(chat.id); placeHolderId = AndroidUtilities.getBroadcastAvatarForId(chat.id);
} }
} }
avatarImage.setImage(photo, "50_50", placeHolderId == 0 ? null : getResources().getDrawable(placeHolderId)); avatarImage.setImage(photo, "50_50", placeHolderId == 0 ? null : getResources().getDrawable(placeHolderId), false);
if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) { if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
buildLayout(); buildLayout();
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
package org.telegram.ui; package org.telegram.ui;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
...@@ -114,6 +116,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -114,6 +116,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private View bottomOverlayChat; private View bottomOverlayChat;
private TypingDotsDrawable typingDotsDrawable; private TypingDotsDrawable typingDotsDrawable;
private View emptyViewContainer; private View emptyViewContainer;
private ArrayList<View> actionModeViews = new ArrayList<View>();
private TextView bottomOverlayText; private TextView bottomOverlayText;
...@@ -574,8 +577,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -574,8 +577,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
item.addSubItem(attach_location, LocaleController.getString("ChatLocation", R.string.ChatLocation), R.drawable.ic_attach_location); item.addSubItem(attach_location, LocaleController.getString("ChatLocation", R.string.ChatLocation), R.drawable.ic_attach_location);
menuItem = item; menuItem = item;
actionModeViews.clear();
ActionBarMenu actionMode = actionBarLayer.createActionMode(); ActionBarMenu actionMode = actionBarLayer.createActionMode();
actionMode.addItem(-2, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode); actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode));
FrameLayout layout = new FrameLayout(actionMode.getContext()); FrameLayout layout = new FrameLayout(actionMode.getContext());
layout.setBackgroundColor(0xffe5e5e5); layout.setBackgroundColor(0xffe5e5e5);
...@@ -587,6 +592,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -587,6 +592,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams.bottomMargin = AndroidUtilities.dp(12); layoutParams.bottomMargin = AndroidUtilities.dp(12);
layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.gravity = Gravity.CENTER_VERTICAL;
layout.setLayoutParams(layoutParams); layout.setLayoutParams(layoutParams);
actionModeViews.add(layout);
selectedMessagesCountTextView = new TextView(actionMode.getContext()); selectedMessagesCountTextView = new TextView(actionMode.getContext());
selectedMessagesCountTextView.setTextSize(18); selectedMessagesCountTextView.setTextSize(18);
...@@ -610,12 +616,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -610,12 +616,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedMessagesCountTextView.setLayoutParams(layoutParams); selectedMessagesCountTextView.setLayoutParams(layoutParams);
if (currentEncryptedChat == null) { if (currentEncryptedChat == null) {
actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, R.drawable.bar_selector_mode); actionModeViews.add(actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, R.drawable.bar_selector_mode));
actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, R.drawable.bar_selector_mode); actionModeViews.add(actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, R.drawable.bar_selector_mode));
actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode); actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode));
} else { } else {
actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, R.drawable.bar_selector_mode); actionModeViews.add(actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, R.drawable.bar_selector_mode));
actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode); actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode));
} }
actionMode.getItem(copy).setVisibility(selectedMessagesCanCopyIds.size() != 0 ? View.VISIBLE : View.GONE); actionMode.getItem(copy).setVisibility(selectedMessagesCanCopyIds.size() != 0 ? View.VISIBLE : View.GONE);
...@@ -2886,6 +2892,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -2886,6 +2892,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
actionBarLayer.showActionMode(); actionBarLayer.showActionMode();
if (Build.VERSION.SDK_INT >= 11) {
AnimatorSet animatorSet = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<Animator>();
for (int a = 0; a < actionModeViews.size(); a++) {
View view = actionModeViews.get(a);
if (a < 2) {
animators.add(ObjectAnimator.ofFloat(view, "translationX", -AndroidUtilities.dp(56), 0));
} else {
animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f));
}
}
animatorSet.playTogether(animators);
animatorSet.setDuration(250);
animatorSet.start();
}
addToSelectedMessages(message); addToSelectedMessages(message);
updateActionModeTitle(); updateActionModeTitle();
updateVisibleRows(); updateVisibleRows();
......
...@@ -630,7 +630,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -630,7 +630,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
} }
if (count != 0 && onlineCount > 1) { if (count != 0 && onlineCount > 1) {
onlineText.setText(Html.fromHtml(String.format("%s, <font color='#357aa8'>%d %s</font>", LocaleController.formatPluralString("Members", count), onlineCount, LocaleController.formatPluralString("Online", onlineCount)))); onlineText.setText(Html.fromHtml(String.format("%s, <font color='#357aa8'>%s</font>", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))));
} else { } else {
onlineText.setText(LocaleController.formatPluralString("Members", count)); onlineText.setText(LocaleController.formatPluralString("Members", count));
} }
......
...@@ -18,6 +18,7 @@ import android.os.Bundle; ...@@ -18,6 +18,7 @@ import android.os.Bundle;
import android.text.InputType; import android.text.InputType;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
...@@ -202,6 +203,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter ...@@ -202,6 +203,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView); listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextView);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listViewAdapter = new ContactsActivityAdapter(getParentActivity(), onlyUsers, usersAsSections, ignoreUsers); listViewAdapter = new ContactsActivityAdapter(getParentActivity(), onlyUsers, usersAsSections, ignoreUsers);
......
...@@ -10,6 +10,7 @@ package org.telegram.ui; ...@@ -10,6 +10,7 @@ package org.telegram.ui;
import android.content.Context; import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
...@@ -193,6 +194,12 @@ public class CountrySelectActivity extends BaseFragment { ...@@ -193,6 +194,12 @@ public class CountrySelectActivity extends BaseFragment {
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView); listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextView);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity())); listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
......
...@@ -17,6 +17,7 @@ import android.os.Build; ...@@ -17,6 +17,7 @@ import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.os.StatFs; import android.os.StatFs;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
...@@ -151,6 +152,12 @@ public class DocumentSelectActivity extends BaseFragment { ...@@ -151,6 +152,12 @@ public class DocumentSelectActivity extends BaseFragment {
fragmentView = inflater.inflate(R.layout.document_select_layout, container, false); fragmentView = inflater.inflate(R.layout.document_select_layout, container, false);
listAdapter = new ListAdapter(getParentActivity()); listAdapter = new ListAdapter(getParentActivity());
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
listView = (ListView)fragmentView.findViewById(R.id.listView); listView = (ListView)fragmentView.findViewById(R.id.listView);
listView.setEmptyView(emptyView); listView.setEmptyView(emptyView);
listView.setAdapter(listAdapter); listView.setAdapter(listAdapter);
...@@ -400,10 +407,10 @@ public class DocumentSelectActivity extends BaseFragment { ...@@ -400,10 +407,10 @@ public class DocumentSelectActivity extends BaseFragment {
items.add(fs); items.add(fs);
try { try {
File telegramPath = new File(Environment.getExternalStorageDirectory(), LocaleController.getString("AppName", R.string.AppName)); File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
if (telegramPath.exists()) { if (telegramPath.exists()) {
fs = new ListItem(); fs = new ListItem();
fs.title = LocaleController.getString("AppName", R.string.AppName); fs.title = "Telegram";
fs.subtitle = telegramPath.toString(); fs.subtitle = telegramPath.toString();
fs.icon = R.drawable.ic_directory; fs.icon = R.drawable.ic_directory;
fs.file = telegramPath; fs.file = telegramPath;
......
...@@ -24,6 +24,7 @@ import android.text.SpannableStringBuilder; ...@@ -24,6 +24,7 @@ import android.text.SpannableStringBuilder;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
...@@ -175,6 +176,12 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -175,6 +176,12 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts)); emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
userSelectEditText = (EditText)fragmentView.findViewById(R.id.bubble_input_text); userSelectEditText = (EditText)fragmentView.findViewById(R.id.bubble_input_text);
userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo)); userSelectEditText.setHint(LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
if (Build.VERSION.SDK_INT >= 11) { if (Build.VERSION.SDK_INT >= 11) {
......
...@@ -12,6 +12,7 @@ import android.app.AlertDialog; ...@@ -12,6 +12,7 @@ import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
...@@ -108,6 +109,12 @@ public class LanguageSelectActivity extends BaseFragment { ...@@ -108,6 +109,12 @@ public class LanguageSelectActivity extends BaseFragment {
listView.setAdapter(listAdapter); listView.setAdapter(listAdapter);
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextView);
emptyTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
searchListViewAdapter = new SearchAdapter(getParentActivity()); searchListViewAdapter = new SearchAdapter(getParentActivity());
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
......
...@@ -583,6 +583,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa ...@@ -583,6 +583,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (PhotoViewer.getInstance().isVisible()) { if (PhotoViewer.getInstance().isVisible()) {
PhotoViewer.getInstance().closePhoto(false); PhotoViewer.getInstance().closePhoto(false);
} }
if (AndroidUtilities.isTablet()) {
actionBarLayout.showLastFragment();
rightActionBarLayout.showLastFragment();
}
} }
if (open_settings != 0) { if (open_settings != 0) {
actionBarLayout.presentFragment(new SettingsActivity(), false, true, true); actionBarLayout.presentFragment(new SettingsActivity(), false, true, true);
...@@ -745,6 +750,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa ...@@ -745,6 +750,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() == 2) { if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() == 2) {
BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1); BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1);
chatFragment.onPause();
actionBarLayout.fragmentsStack.remove(1); actionBarLayout.fragmentsStack.remove(1);
actionBarLayout.showLastFragment(); actionBarLayout.showLastFragment();
rightActionBarLayout.fragmentsStack.add(chatFragment); rightActionBarLayout.fragmentsStack.add(chatFragment);
...@@ -770,6 +776,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa ...@@ -770,6 +776,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (rightActionBarLayout.fragmentsStack.size() == 1) { if (rightActionBarLayout.fragmentsStack.size() == 1) {
BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(0); BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(0);
chatFragment.onPause();
rightActionBarLayout.fragmentsStack.remove(0); rightActionBarLayout.fragmentsStack.remove(0);
actionBarLayout.presentFragment(chatFragment, false, true, false); actionBarLayout.presentFragment(chatFragment, false, true, false);
} }
......
...@@ -13,6 +13,7 @@ import android.content.Context; ...@@ -13,6 +13,7 @@ import android.content.Context;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface; import android.view.Surface;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -107,6 +108,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No ...@@ -107,6 +108,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
emptyView.setText(LocaleController.getString("NoMedia", R.string.NoMedia)); emptyView.setText(LocaleController.getString("NoMedia", R.string.NoMedia));
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
listView = (GridView)fragmentView.findViewById(R.id.media_grid); listView = (GridView)fragmentView.findViewById(R.id.media_grid);
progressView = fragmentView.findViewById(R.id.progressLayout); progressView = fragmentView.findViewById(R.id.progressLayout);
......
...@@ -13,6 +13,7 @@ import android.content.Context; ...@@ -13,6 +13,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
...@@ -51,7 +52,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -51,7 +52,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
private MessagesAdapter messagesListViewAdapter; private MessagesAdapter messagesListViewAdapter;
private TextView searchEmptyView; private TextView searchEmptyView;
private View progressView; private View progressView;
private View empryView; private View emptyView;
private String selectAlertString; private String selectAlertString;
private String selectAlertStringGroup; private String selectAlertStringGroup;
private boolean serverOnly = false; private boolean serverOnly = false;
...@@ -136,8 +137,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -136,8 +137,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (messagesListView != null) { if (messagesListView != null) {
messagesListView.setEmptyView(searchEmptyView); messagesListView.setEmptyView(searchEmptyView);
} }
if (empryView != null) { if (emptyView != null) {
empryView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
} }
} }
...@@ -147,7 +148,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -147,7 +148,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
searching = false; searching = false;
searchWas = false; searchWas = false;
if (messagesListView != null) { if (messagesListView != null) {
messagesListView.setEmptyView(empryView); messagesListView.setEmptyView(emptyView);
searchEmptyView.setVisibility(View.GONE); searchEmptyView.setVisibility(View.GONE);
} }
if (messagesListViewAdapter != null) { if (messagesListViewAdapter != null) {
...@@ -166,7 +167,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -166,7 +167,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} }
if (searchEmptyView != null) { if (searchEmptyView != null) {
messagesListView.setEmptyView(searchEmptyView); messagesListView.setEmptyView(searchEmptyView);
empryView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
} }
} }
} }
...@@ -238,8 +239,20 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -238,8 +239,20 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
progressView = fragmentView.findViewById(R.id.progressLayout); progressView = fragmentView.findViewById(R.id.progressLayout);
messagesListViewAdapter.notifyDataSetChanged(); messagesListViewAdapter.notifyDataSetChanged();
searchEmptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); searchEmptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult)); searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
empryView = fragmentView.findViewById(R.id.list_empty_view); emptyView = fragmentView.findViewById(R.id.list_empty_view);
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1); TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1);
textView.setText(LocaleController.getString("NoChats", R.string.NoChats)); textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2); textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2);
...@@ -248,14 +261,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -248,14 +261,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) { if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
messagesListView.setEmptyView(null); messagesListView.setEmptyView(null);
searchEmptyView.setVisibility(View.GONE); searchEmptyView.setVisibility(View.GONE);
empryView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
progressView.setVisibility(View.VISIBLE); progressView.setVisibility(View.VISIBLE);
} else { } else {
if (searching && searchWas) { if (searching && searchWas) {
messagesListView.setEmptyView(searchEmptyView); messagesListView.setEmptyView(searchEmptyView);
empryView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
} else { } else {
messagesListView.setEmptyView(empryView); messagesListView.setEmptyView(emptyView);
searchEmptyView.setVisibility(View.GONE); searchEmptyView.setVisibility(View.GONE);
} }
progressView.setVisibility(View.GONE); progressView.setVisibility(View.GONE);
...@@ -460,15 +473,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -460,15 +473,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
messagesListView.setEmptyView(null); messagesListView.setEmptyView(null);
} }
searchEmptyView.setVisibility(View.GONE); searchEmptyView.setVisibility(View.GONE);
empryView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
progressView.setVisibility(View.VISIBLE); progressView.setVisibility(View.VISIBLE);
} else { } else {
if (messagesListView.getEmptyView() == null) { if (messagesListView.getEmptyView() == null) {
if (searching && searchWas) { if (searching && searchWas) {
messagesListView.setEmptyView(searchEmptyView); messagesListView.setEmptyView(searchEmptyView);
empryView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
} else { } else {
messagesListView.setEmptyView(empryView); messagesListView.setEmptyView(emptyView);
searchEmptyView.setVisibility(View.GONE); searchEmptyView.setVisibility(View.GONE);
} }
} }
......
...@@ -12,6 +12,7 @@ import android.app.Activity; ...@@ -12,6 +12,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface; import android.view.Surface;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -119,6 +120,12 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen ...@@ -119,6 +120,12 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
fragmentView = inflater.inflate(R.layout.photo_picker_layout, container, false); fragmentView = inflater.inflate(R.layout.photo_picker_layout, container, false);
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
listView = (GridView)fragmentView.findViewById(R.id.media_grid); listView = (GridView)fragmentView.findViewById(R.id.media_grid);
progressView = fragmentView.findViewById(R.id.progressLayout); progressView = fragmentView.findViewById(R.id.progressLayout);
......
...@@ -513,7 +513,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -513,7 +513,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (currentMessageObject != null) { if (currentMessageObject != null) {
f = FileLoader.getPathToMessage(currentMessageObject.messageOwner); f = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
} else if (currentFileLocation != null) { } else if (currentFileLocation != null) {
f = FileLoader.getPathToAttach(currentFileLocation); f = FileLoader.getPathToAttach(currentFileLocation, avatarsUserId != 0);
} }
if (f != null && f.exists()) { if (f != null && f.exists()) {
...@@ -572,7 +572,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -572,7 +572,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return true; return true;
} }
} else if (currentFileLocation != null) { } else if (currentFileLocation != null) {
File f = FileLoader.getPathToAttach(currentFileLocation); File f = FileLoader.getPathToAttach(currentFileLocation, avatarsUserId != 0);
if (f.exists()) { if (f.exists()) {
return true; return true;
} }
...@@ -616,7 +616,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -616,7 +616,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (fileLocation == null) { if (fileLocation == null) {
return; return;
} }
File f = FileLoader.getPathToAttach(fileLocation); File f = FileLoader.getPathToAttach(fileLocation, avatarsUserId != 0);
if (f.exists()) { if (f.exists()) {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
if (f.toString().endsWith("mp4")) { if (f.toString().endsWith("mp4")) {
...@@ -1341,7 +1341,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -1341,7 +1341,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (currentMessageObject != null) { if (currentMessageObject != null) {
f = FileLoader.getPathToMessage(currentMessageObject.messageOwner); f = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
} else if (currentFileLocation != null) { } else if (currentFileLocation != null) {
f = FileLoader.getPathToAttach(currentFileLocation); f = FileLoader.getPathToAttach(currentFileLocation, avatarsUserId != 0);
} }
if (f.exists()) { if (f.exists()) {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
...@@ -1399,7 +1399,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -1399,7 +1399,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (currentThumb != null && imageReceiver == centerImage) { if (currentThumb != null && imageReceiver == centerImage) {
placeHolder = currentThumb; placeHolder = currentThumb;
} }
imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, 0); imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, 0, true);
} else { } else {
imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder)); imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder));
} }
...@@ -1414,7 +1414,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -1414,7 +1414,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (size[0] == 0) { if (size[0] == 0) {
size[0] = -1; size[0] = -1;
} }
imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]); imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0], avatarsUserId != 0);
} }
} else { } else {
if (size[0] == 0) { if (size[0] == 0) {
......
...@@ -13,6 +13,7 @@ import android.content.Context; ...@@ -13,6 +13,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
...@@ -88,6 +89,12 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi ...@@ -88,6 +89,12 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
listView = (ListView)fragmentView.findViewById(R.id.listView); listView = (ListView)fragmentView.findViewById(R.id.listView);
progressView = fragmentView.findViewById(R.id.progressLayout); progressView = fragmentView.findViewById(R.id.progressLayout);
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
emptyView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked)); emptyView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
if (MessagesController.getInstance().loadingBlockedUsers) { if (MessagesController.getInstance().loadingBlockedUsers) {
progressView.setVisibility(View.VISIBLE); progressView.setVisibility(View.VISIBLE);
......
...@@ -13,6 +13,7 @@ import android.app.Activity; ...@@ -13,6 +13,7 @@ import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.media.MediaCodecInfo;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
...@@ -41,6 +42,7 @@ import com.googlecode.mp4parser.util.Path; ...@@ -41,6 +42,7 @@ import com.googlecode.mp4parser.util.Path;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MediaController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
...@@ -234,7 +236,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur ...@@ -234,7 +236,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
} }
} }
if (delegate != null) { if (delegate != null) {
if (compressVideo.getVisibility() == View.VISIBLE && !compressVideo.isChecked()) { if (compressVideo.getVisibility() == View.GONE || compressVideo.getVisibility() == View.VISIBLE && !compressVideo.isChecked()) {
delegate.didFinishEditVideo(videoPath, startTime, endTime, originalWidth, originalHeight, rotationValue, originalWidth, originalHeight, bitrate, estimatedSize, esimatedDuration); delegate.didFinishEditVideo(videoPath, startTime, endTime, originalWidth, originalHeight, rotationValue, originalWidth, originalHeight, bitrate, estimatedSize, esimatedDuration);
} else { } else {
delegate.didFinishEditVideo(videoPath, startTime, endTime, resultWidth, resultHeight, rotationValue, originalWidth, originalHeight, bitrate, estimatedSize, esimatedDuration); delegate.didFinishEditVideo(videoPath, startTime, endTime, resultWidth, resultHeight, rotationValue, originalWidth, originalHeight, bitrate, estimatedSize, esimatedDuration);
...@@ -272,6 +274,27 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur ...@@ -272,6 +274,27 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
updateVideoEditedInfo(); updateVideoEditedInfo();
} }
}); });
if (Build.VERSION.SDK_INT < 18) {
MediaCodecInfo codecInfo = MediaController.selectCodec(MediaController.MIME_TYPE);
if (codecInfo == null) {
compressVideo.setVisibility(View.GONE);
} else {
String name = codecInfo.getName();
if (name.equals("OMX.google.h264.encoder") ||
name.equals("OMX.ST.VFM.H264Enc") ||
name.equals("OMX.Exynos.avc.enc") ||
name.equals("OMX.MARVELL.VIDEO.HW.CODA7542ENCODER") ||
name.equals("OMX.MARVELL.VIDEO.H264ENCODER")) {
compressVideo.setVisibility(View.GONE);
} else {
if (MediaController.selectColorFormat(codecInfo, MediaController.MIME_TYPE) == 0) {
compressVideo.setVisibility(View.GONE);
}
}
}
}
TextView titleTextView = (TextView) fragmentView.findViewById(R.id.original_title); TextView titleTextView = (TextView) fragmentView.findViewById(R.id.original_title);
titleTextView.setText(LocaleController.getString("OriginalVideo", R.string.OriginalVideo)); titleTextView.setText(LocaleController.getString("OriginalVideo", R.string.OriginalVideo));
titleTextView = (TextView) fragmentView.findViewById(R.id.edited_title); titleTextView = (TextView) fragmentView.findViewById(R.id.edited_title);
...@@ -457,7 +480,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur ...@@ -457,7 +480,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
int width = 0; int width = 0;
int height = 0; int height = 0;
if (compressVideo.getVisibility() == View.VISIBLE && !compressVideo.isChecked()) { if (compressVideo.getVisibility() == View.GONE || compressVideo.getVisibility() == View.VISIBLE && !compressVideo.isChecked()) {
width = rotationValue == 90 || rotationValue == 270 ? originalHeight : originalWidth; width = rotationValue == 90 || rotationValue == 270 ? originalHeight : originalWidth;
height = rotationValue == 90 || rotationValue == 270 ? originalWidth : originalHeight; height = rotationValue == 90 || rotationValue == 270 ? originalWidth : originalHeight;
estimatedSize = (int)(originalSize * ((float)esimatedDuration / videoDuration)); estimatedSize = (int)(originalSize * ((float)esimatedDuration / videoDuration));
......
...@@ -69,7 +69,7 @@ public class BackupImageView extends View { ...@@ -69,7 +69,7 @@ public class BackupImageView extends View {
} else if (placeholder != 0) { } else if (placeholder != 0) {
placeholderDrawable = getResources().getDrawable(placeholder); placeholderDrawable = getResources().getDrawable(placeholder);
} }
imageReceiver.setImage(path, httpUrl, filter, placeholderDrawable, size); imageReceiver.setImage(path, httpUrl, filter, placeholderDrawable, size, false);
} }
public void setImageBitmap(Bitmap bitmap) { public void setImageBitmap(Bitmap bitmap) {
......
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_send_disabled" android:state_enabled="false" />
<item android:drawable="@drawable/ic_send" />
</selector>
\ No newline at end of file
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/chat_text_edit" android:layout_alignBottom="@+id/chat_text_edit"
android:enabled="false" android:enabled="false"
android:src="@drawable/send_button_states" android:src="@drawable/ic_send"
android:background="@android:color/transparent"/> android:background="@android:color/transparent"/>
<EditText <EditText
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/chat_text_edit" android:layout_alignBottom="@+id/chat_text_edit"
android:enabled="false" android:enabled="false"
android:src="@drawable/send_button_states" android:src="@drawable/ic_send"
android:background="@android:color/transparent"/> android:background="@android:color/transparent"/>
<EditText <EditText
......
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'الساعة\' %2$s</string> <string name="formatDateAtTime">%1$s الساعة %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'um\' %2$s</string> <string name="formatDateAtTime">%1$s um %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'a las\' %2$s</string> <string name="formatDateAtTime">%1$s a las %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'alle\' %2$s</string> <string name="formatDateAtTime">%1$s alle %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
This diff is collapsed.
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'om\' %2$s</string> <string name="formatDateAtTime">%1$s om %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'às\' %2$s</string> <string name="formatDateAtTime">%1$s às %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'às\' %2$s</string> <string name="formatDateAtTime">%1$s às %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
...@@ -443,7 +443,7 @@ ...@@ -443,7 +443,7 @@
<string name="formatterWeek">EEE</string> <string name="formatterWeek">EEE</string>
<string name="formatterDay24H">HH:mm</string> <string name="formatterDay24H">HH:mm</string>
<string name="formatterDay12H">h:mm a</string> <string name="formatterDay12H">h:mm a</string>
<string name="formatDateAtTime">%1$s \'at\' %2$s</string> <string name="formatDateAtTime">%1$s at %2$s</string>
<!--Don't change this! Not for localization!--> <!--Don't change this! Not for localization!-->
<string name="CacheTag">CACHE_TAG</string> <string name="CacheTag">CACHE_TAG</string>
</resources> </resources>
\ No newline at end of file
#Mon Jun 09 01:00:32 MSK 2014 #Mon Oct 06 17:04:43 MSK 2014
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment