Commit 91ae97e2 authored by DrKLO's avatar DrKLO

Broadcasts, updated gif lib, blur image\video preview

Note: untested, don’t upload to market
parent e5cb3685
...@@ -83,7 +83,7 @@ android { ...@@ -83,7 +83,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 290 versionCode 291
versionName "1.6.2" versionName "1.7.0"
} }
} }
...@@ -8,6 +8,7 @@ LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA ...@@ -8,6 +8,7 @@ LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT
LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops
#LOCAL_LDLIBS := -llog #LOCAL_LDLIBS := -llog
LOCAL_LDLIBS := -ljnigraphics
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
./opus/src/opus.c \ ./opus/src/opus.c \
......
This diff is collapsed.
...@@ -2,8 +2,101 @@ ...@@ -2,8 +2,101 @@
#include <stdio.h> #include <stdio.h>
#include <setjmp.h> #include <setjmp.h>
#include <libjpeg/jpeglib.h> #include <libjpeg/jpeglib.h>
#include <android/bitmap.h>
#include "utils.h" #include "utils.h"
static inline uint64_t get_colors (const uint8_t *p) {
return p[0] + (p[1] << 16) + ((uint64_t)p[2] << 32);
}
static void fastBlur(int imageWidth, int imageHeight, int imageStride, void *pixels) {
uint8_t *pix = (uint8_t *)pixels;
const int w = imageWidth;
const int h = imageHeight;
const int stride = imageStride;
const int radius = 3;
const int r1 = radius + 1;
const int div = radius * 2 + 1;
if (radius > 15 || div >= w || div >= h) {
return;
}
uint64_t rgb[imageStride * imageHeight];
int x, y, i;
int yw = 0;
const int we = w - r1;
for (y = 0; y < h; y++) {
uint64_t cur = get_colors (&pix[yw]);
uint64_t rgballsum = -radius * cur;
uint64_t rgbsum = cur * ((r1 * (r1 + 1)) >> 1);
for (i = 1; i <= radius; i++) {
uint64_t cur = get_colors (&pix[yw + i * 4]);
rgbsum += cur * (r1 - i);
rgballsum += cur;
}
x = 0;
#define update(start, middle, end) \
rgb[y * w + x] = (rgbsum >> 4) & 0x00FF00FF00FF00FFLL; \
rgballsum += get_colors (&pix[yw + (start) * 4]) - 2 * get_colors (&pix[yw + (middle) * 4]) + get_colors (&pix[yw + (end) * 4]); \
rgbsum += rgballsum; \
x++; \
while (x < r1) {
update (0, x, x + r1);
}
while (x < we) {
update (x - r1, x, x + r1);
}
while (x < w) {
update (x - r1, x, w - 1);
}
#undef update
yw += stride;
}
const int he = h - r1;
for (x = 0; x < w; x++) {
uint64_t rgballsum = -radius * rgb[x];
uint64_t rgbsum = rgb[x] * ((r1 * (r1 + 1)) >> 1);
for (i = 1; i <= radius; i++) {
rgbsum += rgb[i * w + x] * (r1 - i);
rgballsum += rgb[i * w + x];
}
y = 0;
int yi = x * 4;
#define update(start, middle, end) \
int64_t res = rgbsum >> 4; \
pix[yi] = res; \
pix[yi + 1] = res >> 16; \
pix[yi + 2] = res >> 32; \
rgballsum += rgb[x + (start) * w] - 2 * rgb[x + (middle) * w] + rgb[x + (end) * w]; \
rgbsum += rgballsum; \
y++; \
yi += stride;
while (y < r1) {
update (0, y, y + r1);
}
while (y < he) {
update (y - r1, y, y + r1);
}
while (y < h) {
update (y - r1, y, h - 1);
}
#undef update
}
}
typedef struct my_error_mgr { typedef struct my_error_mgr {
struct jpeg_error_mgr pub; struct jpeg_error_mgr pub;
jmp_buf setjmp_buffer; jmp_buf setjmp_buffer;
...@@ -16,6 +109,15 @@ METHODDEF(void) my_error_exit(j_common_ptr cinfo) { ...@@ -16,6 +109,15 @@ METHODDEF(void) my_error_exit(j_common_ptr cinfo) {
longjmp(myerr->setjmp_buffer, 1); longjmp(myerr->setjmp_buffer, 1);
} }
JNIEXPORT void Java_org_telegram_messenger_Utilities_blurBitmap(JNIEnv *env, jclass class, jobject bitmap, int width, int height, int stride) {
void *pixels = 0;
if (AndroidBitmap_lockPixels(env, bitmap, &pixels) < 0) {
return;
}
fastBlur(width, height, stride, pixels);
AndroidBitmap_unlockPixels(env, bitmap);
}
JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jintArray bitmap, int scale, int format, int width, int height) { JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jintArray bitmap, int scale, int format, int width, int height) {
int i; int i;
......
...@@ -367,6 +367,7 @@ public class MessagesStorage { ...@@ -367,6 +367,7 @@ public class MessagesStorage {
database.executeFast("DELETE FROM dialogs WHERE did = " + did).stepThis().dispose(); database.executeFast("DELETE FROM dialogs WHERE did = " + did).stepThis().dispose();
database.executeFast("DELETE FROM chat_settings WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM chat_settings WHERE uid = " + did).stepThis().dispose();
} }
database.executeFast("UPDATE dialogs SET unread_count = 0 WHERE did = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media_counts WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_counts WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM messages WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM messages WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media WHERE uid = " + did).stepThis().dispose();
...@@ -1808,7 +1809,7 @@ public class MessagesStorage { ...@@ -1808,7 +1809,7 @@ public class MessagesStorage {
} }
} }
private void putMessagesInternal(final ArrayList<TLRPC.Message> messages, final boolean withTransaction) { private void putMessagesInternal(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, final boolean isBroadcast) {
try { try {
if (withTransaction) { if (withTransaction) {
database.beginTransaction(); database.beginTransaction();
...@@ -1949,10 +1950,21 @@ public class MessagesStorage { ...@@ -1949,10 +1950,21 @@ public class MessagesStorage {
state.dispose(); state.dispose();
state2.dispose(); state2.dispose();
state3.dispose(); state3.dispose();
state = database.executeFast("REPLACE INTO dialogs VALUES(?, ?, ifnull((SELECT unread_count FROM dialogs WHERE did = ?), 0) + ?, ?)");
state = database.executeFast("REPLACE INTO dialogs VALUES(?, ?, ?, ?)");
for (HashMap.Entry<Long, TLRPC.Message> pair : messagesMap.entrySet()) { for (HashMap.Entry<Long, TLRPC.Message> pair : messagesMap.entrySet()) {
state.requery();
Long key = pair.getKey(); Long key = pair.getKey();
int dialog_date = 0;
int old_unread_count = 0;
SQLiteCursor cursor = database.queryFinalized("SELECT date, unread_count FROM dialogs WHERE did = " + key);
if (cursor.next()) {
dialog_date = cursor.intValue(0);
old_unread_count = cursor.intValue(1);
}
cursor.dispose();
state.requery();
TLRPC.Message value = pair.getValue(); TLRPC.Message value = pair.getValue();
Integer unread_count = messagesCounts.get(key); Integer unread_count = messagesCounts.get(key);
if (unread_count == null) { if (unread_count == null) {
...@@ -1963,10 +1975,13 @@ public class MessagesStorage { ...@@ -1963,10 +1975,13 @@ public class MessagesStorage {
messageId = value.local_id; messageId = value.local_id;
} }
state.bindLong(1, key); state.bindLong(1, key);
state.bindInteger(2, value.date); if (!isBroadcast) {
state.bindLong(3, key); state.bindInteger(2, value.date);
state.bindInteger(4, unread_count); } else {
state.bindInteger(5, messageId); state.bindInteger(2, dialog_date != 0 ? dialog_date : value.date);
}
state.bindInteger(3, unread_count);
state.bindInteger(4, messageId);
state.step(); state.step();
} }
state.dispose(); state.dispose();
...@@ -2002,7 +2017,7 @@ public class MessagesStorage { ...@@ -2002,7 +2017,7 @@ public class MessagesStorage {
} }
} }
public void putMessages(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, boolean useQueue) { public void putMessages(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, boolean useQueue, final boolean isBroadcast) {
if (messages.size() == 0) { if (messages.size() == 0) {
return; return;
} }
...@@ -2010,11 +2025,11 @@ public class MessagesStorage { ...@@ -2010,11 +2025,11 @@ public class MessagesStorage {
storageQueue.postRunnable(new Runnable() { storageQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
putMessagesInternal(messages, withTransaction); putMessagesInternal(messages, withTransaction, isBroadcast);
} }
}); });
} else { } else {
putMessagesInternal(messages, withTransaction); putMessagesInternal(messages, withTransaction, isBroadcast);
} }
} }
...@@ -2425,9 +2440,15 @@ public class MessagesStorage { ...@@ -2425,9 +2440,15 @@ public class MessagesStorage {
} }
} }
} else { } else {
int encryptedId = (int)(dialog.id >> 32); int high_id = (int)(dialog.id >> 32);
if (!encryptedToLoad.contains(encryptedId)) { if (high_id > 0) {
encryptedToLoad.add(encryptedId); if (!encryptedToLoad.contains(high_id)) {
encryptedToLoad.add(high_id);
}
} else {
if (!chatsToLoad.contains(high_id)) {
chatsToLoad.add(high_id);
}
} }
} }
} }
...@@ -2692,9 +2713,15 @@ public class MessagesStorage { ...@@ -2692,9 +2713,15 @@ public class MessagesStorage {
} }
} }
} else { } else {
int encryptedId = (int)(dialog.id >> 32); int high_id = (int)(dialog.id >> 32);
if (!encryptedToLoad.contains(encryptedId)) { if (high_id > 0) {
encryptedToLoad.add(encryptedId); if (!encryptedToLoad.contains(high_id)) {
encryptedToLoad.add(high_id);
}
} else {
if (!chatsToLoad.contains(high_id)) {
chatsToLoad.add(high_id);
}
} }
} }
} }
......
...@@ -25,8 +25,8 @@ public class NativeLoader { ...@@ -25,8 +25,8 @@ public class NativeLoader {
private static final long sizes[] = new long[] { private static final long sizes[] = new long[] {
799376, //armeabi 799376, //armeabi
848548, //armeabi-v7a 852644, //armeabi-v7a
1246260, //x86 1250356, //x86
0, //mips 0, //mips
}; };
......
...@@ -400,7 +400,7 @@ public class NotificationsController { ...@@ -400,7 +400,7 @@ public class NotificationsController {
} }
if (photoPath != null) { if (photoPath != null) {
Bitmap img = FileLoader.getInstance().getImageFromMemory(photoPath, null, null, "50_50", false); Bitmap img = FileLoader.getInstance().getImageFromMemory(photoPath, null, null, "50_50");
if (img != null) { if (img != null) {
mBuilder.setLargeIcon(img); mBuilder.setLargeIcon(img);
} }
...@@ -536,7 +536,7 @@ public class NotificationsController { ...@@ -536,7 +536,7 @@ public class NotificationsController {
Boolean value = settingsCache.get(dialog_id); Boolean value = settingsCache.get(dialog_id);
boolean isChat = (int)dialog_id < 0; boolean isChat = (int)dialog_id < 0;
popup = preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); popup = (int)dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
if (value == null) { if (value == null) {
int notify_override = preferences.getInt("notify2_" + dialog_id, 0); int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
......
...@@ -850,7 +850,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -850,7 +850,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId, final boolean runQueue) { public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId, final boolean runQueue) {
if (!UserConfig.isClientActivated() && (requestClass & RPCRequest.RPCRequestClassWithoutLogin) == 0) { if (rpc == null || !UserConfig.isClientActivated() && (requestClass & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
FileLog.e("tmessages", "can't do request without login " + rpc); FileLog.e("tmessages", "can't do request without login " + rpc);
return 0; return 0;
} }
......
...@@ -248,10 +248,14 @@ public class FileLoadOperation { ...@@ -248,10 +248,14 @@ public class FileLoadOperation {
float w_filter = 0; float w_filter = 0;
float h_filter = 0; float h_filter = 0;
boolean blur = false;
if (filter != null) { if (filter != null) {
String args[] = filter.split("_"); String args[] = filter.split("_");
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density; w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density; h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
if (args.length > 2) {
blur = true;
}
opts.inJustDecodeBounds = true; opts.inJustDecodeBounds = true;
if (mediaIdFinal != null) { if (mediaIdFinal != null) {
...@@ -270,7 +274,7 @@ public class FileLoadOperation { ...@@ -270,7 +274,7 @@ public class FileLoadOperation {
opts.inSampleSize = (int)scaleFactor; opts.inSampleSize = (int)scaleFactor;
} }
if (filter == null) { if (filter == null || blur) {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888; opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
} else { } else {
opts.inPreferredConfig = Bitmap.Config.RGB_565; opts.inPreferredConfig = Bitmap.Config.RGB_565;
...@@ -300,7 +304,9 @@ public class FileLoadOperation { ...@@ -300,7 +304,9 @@ public class FileLoadOperation {
image = scaledBitmap; image = scaledBitmap;
} }
} }
if (image != null && blur && bitmapH < 100 && bitmapW < 100) {
Utilities.blurBitmap(image, (int)bitmapW, (int)bitmapH, image.getRowBytes());
}
} }
if (FileLoader.getInstance().runtimeHack != null) { if (FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight()); FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
...@@ -494,10 +500,14 @@ public class FileLoadOperation { ...@@ -494,10 +500,14 @@ public class FileLoadOperation {
float w_filter = 0; float w_filter = 0;
float h_filter; float h_filter;
boolean blur = false;
if (filter != null) { if (filter != null) {
String args[] = filter.split("_"); String args[] = filter.split("_");
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density; w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density; h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
if (args.length > 2) {
blur = true;
}
opts.inJustDecodeBounds = true; opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(cacheFileFinal.getAbsolutePath(), opts); BitmapFactory.decodeFile(cacheFileFinal.getAbsolutePath(), opts);
...@@ -511,7 +521,7 @@ public class FileLoadOperation { ...@@ -511,7 +521,7 @@ public class FileLoadOperation {
opts.inSampleSize = (int) scaleFactor; opts.inSampleSize = (int) scaleFactor;
} }
if (filter == null) { if (filter == null || blur) {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888; opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
} else { } else {
opts.inPreferredConfig = Bitmap.Config.RGB_565; opts.inPreferredConfig = Bitmap.Config.RGB_565;
...@@ -540,7 +550,9 @@ public class FileLoadOperation { ...@@ -540,7 +550,9 @@ public class FileLoadOperation {
image = scaledBitmap; image = scaledBitmap;
} }
} }
if (image != null && blur && bitmapH < 100 && bitmapW < 100) {
Utilities.blurBitmap(image, (int)bitmapW, (int)bitmapH, image.getRowBytes());
}
} }
if (image != null && FileLoader.getInstance().runtimeHack != null) { if (image != null && FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight()); FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
......
...@@ -64,7 +64,7 @@ public class FileLoader { ...@@ -64,7 +64,7 @@ public class FileLoader {
private long lastProgressUpdateTime = 0; private long lastProgressUpdateTime = 0;
private HashMap<String, Integer> BitmapUseCounts = new HashMap<String, Integer>(); private HashMap<String, Integer> BitmapUseCounts = new HashMap<String, Integer>();
int lastImageNum; private int lastImageNum = 0;
public static final int FileDidUpload = 10000; public static final int FileDidUpload = 10000;
public static final int FileDidFailUpload = 10001; public static final int FileDidFailUpload = 10001;
...@@ -717,15 +717,15 @@ public class FileLoader { ...@@ -717,15 +717,15 @@ public class FileLoader {
}); });
} }
public Bitmap getImageFromMemory(TLRPC.FileLocation url, ImageReceiver imageView, String filter, boolean cancel) { public Bitmap getImageFromMemory(TLRPC.FileLocation url, ImageReceiver imageView, String filter) {
return getImageFromMemory(url, null, imageView, filter, cancel); return getImageFromMemory(url, null, imageView, filter);
} }
public Bitmap getImageFromMemory(String url, ImageReceiver imageView, String filter, boolean cancel) { public Bitmap getImageFromMemory(String url, ImageReceiver imageView, String filter) {
return getImageFromMemory(null, url, imageView, filter, cancel); return getImageFromMemory(null, url, imageView, filter);
} }
public Bitmap getImageFromMemory(TLRPC.FileLocation url, String httpUrl, ImageReceiver imageView, String filter, boolean cancel) { public Bitmap getImageFromMemory(TLRPC.FileLocation url, String httpUrl, ImageReceiver imageView, String filter) {
if (url == null && httpUrl == null) { if (url == null && httpUrl == null) {
return null; return null;
} }
...@@ -739,11 +739,7 @@ public class FileLoader { ...@@ -739,11 +739,7 @@ public class FileLoader {
key += "@" + filter; key += "@" + filter;
} }
Bitmap img = imageFromKey(key); return imageFromKey(key);
if (imageView != null && img != null && cancel) {
cancelLoadingForImageView(imageView);
}
return img;
} }
private void performReplace(String oldKey, String newKey) { private void performReplace(String oldKey, String newKey) {
......
...@@ -439,6 +439,7 @@ public class TLClassStore { ...@@ -439,6 +439,7 @@ public class TLClassStore {
classStore.put(TLRPC.TL_decryptedMessageMediaAudio_old.constructor, TLRPC.TL_decryptedMessageMediaAudio_old.class); classStore.put(TLRPC.TL_decryptedMessageMediaAudio_old.constructor, TLRPC.TL_decryptedMessageMediaAudio_old.class);
classStore.put(TLRPC.TL_audio_old.constructor, TLRPC.TL_audio_old.class); classStore.put(TLRPC.TL_audio_old.constructor, TLRPC.TL_audio_old.class);
classStore.put(TLRPC.TL_video_old.constructor, TLRPC.TL_video_old.class); classStore.put(TLRPC.TL_video_old.constructor, TLRPC.TL_video_old.class);
classStore.put(TLRPC.TL_messageActionCreatedBroadcastList.constructor, TLRPC.TL_messageActionCreatedBroadcastList.class);
} }
static TLClassStore store = null; static TLClassStore store = null;
......
...@@ -8996,6 +8996,17 @@ public class TLRPC { ...@@ -8996,6 +8996,17 @@ public class TLRPC {
} }
} }
public static class TL_messageActionCreatedBroadcastList extends MessageAction {
public static int constructor = 0x55555557;
public void readParams(AbsSerializedData stream) {
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
}
}
public static class TL_documentEncrypted extends TL_document { public static class TL_documentEncrypted extends TL_document {
public static int constructor = 0x55555556; public static int constructor = 0x55555556;
......
...@@ -24,6 +24,7 @@ public class UserConfig { ...@@ -24,6 +24,7 @@ public class UserConfig {
public static String pushString = ""; public static String pushString = "";
public static int lastSendMessageId = -210000; public static int lastSendMessageId = -210000;
public static int lastLocalId = -210000; public static int lastLocalId = -210000;
public static int lastBroadcastId = -1;
public static String contactsHash = ""; public static String contactsHash = "";
public static String importHash = ""; public static String importHash = "";
private final static Integer sync = 1; private final static Integer sync = 1;
...@@ -56,6 +57,7 @@ public class UserConfig { ...@@ -56,6 +57,7 @@ public class UserConfig {
editor.putString("importHash", importHash); editor.putString("importHash", importHash);
editor.putBoolean("saveIncomingPhotos", saveIncomingPhotos); editor.putBoolean("saveIncomingPhotos", saveIncomingPhotos);
editor.putInt("contactsVersion", contactsVersion); editor.putInt("contactsVersion", contactsVersion);
editor.putInt("lastBroadcastId", lastBroadcastId);
editor.putBoolean("registeredForInternalPush", registeredForInternalPush); editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
if (currentUser != null) { if (currentUser != null) {
if (withFile) { if (withFile) {
...@@ -174,6 +176,7 @@ public class UserConfig { ...@@ -174,6 +176,7 @@ public class UserConfig {
importHash = preferences.getString("importHash", ""); importHash = preferences.getString("importHash", "");
saveIncomingPhotos = preferences.getBoolean("saveIncomingPhotos", false); saveIncomingPhotos = preferences.getBoolean("saveIncomingPhotos", false);
contactsVersion = preferences.getInt("contactsVersion", 0); contactsVersion = preferences.getInt("contactsVersion", 0);
lastBroadcastId = preferences.getInt("lastBroadcastId", -1);
registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false); registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false);
String user = preferences.getString("user", null); String user = preferences.getString("user", null);
if (user != null) { if (user != null) {
...@@ -196,6 +199,7 @@ public class UserConfig { ...@@ -196,6 +199,7 @@ public class UserConfig {
lastLocalId = -210000; lastLocalId = -210000;
lastSendMessageId = -210000; lastSendMessageId = -210000;
contactsVersion = 1; contactsVersion = 1;
lastBroadcastId = -1;
saveIncomingPhotos = false; saveIncomingPhotos = false;
saveConfig(true); saveConfig(true);
} }
......
...@@ -132,6 +132,7 @@ public class Utilities { ...@@ -132,6 +132,7 @@ public class Utilities {
public native static long doPQNative(long _what); public native static long doPQNative(long _what);
public native static void loadBitmap(String path, int[] bitmap, int scale, int format, int width, int height); public native static void loadBitmap(String path, int[] bitmap, int scale, int format, int width, int height);
public native static void blurBitmap(Object bitmap, int width, int height, int stride);
private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length); private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length);
public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) { public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) {
...@@ -139,6 +140,9 @@ public class Utilities { ...@@ -139,6 +140,9 @@ public class Utilities {
} }
public static Integer parseInt(String value) { public static Integer parseInt(String value) {
if (value == null) {
return 0;
}
Integer val = 0; Integer val = 0;
try { try {
Matcher matcher = pattern.matcher(value); Matcher matcher = pattern.matcher(value);
...@@ -548,7 +552,7 @@ public class Utilities { ...@@ -548,7 +552,7 @@ public class Utilities {
} }
public static int getGroupAvatarForId(int id) { public static int getGroupAvatarForId(int id) {
return arrGroupsAvatars[getColorIndex(-id)]; return arrGroupsAvatars[getColorIndex(-Math.abs(id))];
} }
public static String MD5(String md5) { public static String MD5(String md5) {
......
...@@ -63,6 +63,10 @@ public class MessageObject { ...@@ -63,6 +63,10 @@ public class MessageObject {
public ArrayList<TextLayoutBlock> textLayoutBlocks; public ArrayList<TextLayoutBlock> textLayoutBlocks;
public MessageObject(TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users) { public MessageObject(TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users) {
this(message, users, 1);
}
public MessageObject(TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users, int preview) {
if (textPaint == null) { if (textPaint == null) {
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(0xff000000); textPaint.setColor(0xff000000);
...@@ -136,7 +140,7 @@ public class MessageObject { ...@@ -136,7 +140,7 @@ public class MessageObject {
} else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto) { } else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto) {
photoThumbs = new ArrayList<PhotoObject>(); photoThumbs = new ArrayList<PhotoObject>();
for (TLRPC.PhotoSize size : message.action.photo.sizes) { for (TLRPC.PhotoSize size : message.action.photo.sizes) {
photoThumbs.add(new PhotoObject(size)); photoThumbs.add(new PhotoObject(size, preview));
} }
if (isFromMe()) { if (isFromMe()) {
messageText = LocaleController.getString("ActionYouChangedPhoto", R.string.ActionYouChangedPhoto); messageText = LocaleController.getString("ActionYouChangedPhoto", R.string.ActionYouChangedPhoto);
...@@ -232,13 +236,15 @@ public class MessageObject { ...@@ -232,13 +236,15 @@ public class MessageObject {
} }
} }
} }
} else if (message.action instanceof TLRPC.TL_messageActionCreatedBroadcastList) {
messageText = LocaleController.formatString("YouCreatedBroadcastList", R.string.YouCreatedBroadcastList);
} }
} }
} else if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty)) { } else if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty)) {
if (message.media instanceof TLRPC.TL_messageMediaPhoto) { if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
photoThumbs = new ArrayList<PhotoObject>(); photoThumbs = new ArrayList<PhotoObject>();
for (TLRPC.PhotoSize size : message.media.photo.sizes) { for (TLRPC.PhotoSize size : message.media.photo.sizes) {
PhotoObject obj = new PhotoObject(size); PhotoObject obj = new PhotoObject(size, preview);
photoThumbs.add(obj); photoThumbs.add(obj);
if (imagePreview == null && obj.image != null) { if (imagePreview == null && obj.image != null) {
imagePreview = obj.image; imagePreview = obj.image;
...@@ -247,7 +253,7 @@ public class MessageObject { ...@@ -247,7 +253,7 @@ public class MessageObject {
messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto); messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto);
} else if (message.media instanceof TLRPC.TL_messageMediaVideo) { } else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
photoThumbs = new ArrayList<PhotoObject>(); photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(message.media.video.thumb); PhotoObject obj = new PhotoObject(message.media.video.thumb, preview);
photoThumbs.add(obj); photoThumbs.add(obj);
if (imagePreview == null && obj.image != null) { if (imagePreview == null && obj.image != null) {
imagePreview = obj.image; imagePreview = obj.image;
...@@ -262,7 +268,7 @@ public class MessageObject { ...@@ -262,7 +268,7 @@ public class MessageObject {
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
if (!(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) { if (!(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
photoThumbs = new ArrayList<PhotoObject>(); photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(message.media.document.thumb); PhotoObject obj = new PhotoObject(message.media.document.thumb, preview);
photoThumbs.add(obj); photoThumbs.add(obj);
} }
messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument); messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument);
......
...@@ -13,6 +13,7 @@ import android.graphics.BitmapFactory; ...@@ -13,6 +13,7 @@ import android.graphics.BitmapFactory;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.Utilities;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -20,18 +21,23 @@ public class PhotoObject { ...@@ -20,18 +21,23 @@ public class PhotoObject {
public TLRPC.PhotoSize photoOwner; public TLRPC.PhotoSize photoOwner;
public Bitmap image; public Bitmap image;
public PhotoObject(TLRPC.PhotoSize photo) { public PhotoObject(TLRPC.PhotoSize photo, int preview) {
photoOwner = photo; photoOwner = photo;
if (photo instanceof TLRPC.TL_photoCachedSize) { if (preview != 0 && photo instanceof TLRPC.TL_photoCachedSize) {
BitmapFactory.Options opts = new BitmapFactory.Options(); BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGB_565; opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
opts.inDither = false; opts.inDither = false;
opts.outWidth = photo.w; opts.outWidth = photo.w;
opts.outHeight = photo.h; opts.outHeight = photo.h;
image = BitmapFactory.decodeByteArray(photoOwner.bytes, 0, photoOwner.bytes.length, opts); image = BitmapFactory.decodeByteArray(photoOwner.bytes, 0, photoOwner.bytes.length, opts);
if (image != null && FileLoader.getInstance().runtimeHack != null) { if (image != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight()); if (preview == 2) {
Utilities.blurBitmap(image, image.getWidth(), image.getHeight(), image.getRowBytes());
}
if (FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
}
} }
} }
} }
......
...@@ -31,7 +31,7 @@ import org.telegram.objects.PhotoObject; ...@@ -31,7 +31,7 @@ import org.telegram.objects.PhotoObject;
import org.telegram.ui.PhotoViewer; import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Views.GifDrawable; import org.telegram.ui.Views.GifDrawable;
import org.telegram.ui.Views.ImageReceiver; import org.telegram.ui.Views.ImageReceiver;
import org.telegram.ui.Views.ProgressView; import org.telegram.ui.Views.RoundProgressView;
import java.io.File; import java.io.File;
import java.util.Locale; import java.util.Locale;
...@@ -45,7 +45,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -45,7 +45,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private static Drawable placeholderInDrawable; private static Drawable placeholderInDrawable;
private static Drawable placeholderOutDrawable; private static Drawable placeholderOutDrawable;
private static Drawable videoIconDrawable; private static Drawable videoIconDrawable;
private static Drawable[][] buttonStatesDrawables = new Drawable[4][2]; private static Drawable[] buttonStatesDrawables = new Drawable[4];
private static TextPaint infoPaint; private static TextPaint infoPaint;
private static MessageObject lastDownloadedGifMessage = null; private static MessageObject lastDownloadedGifMessage = null;
...@@ -57,10 +57,11 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -57,10 +57,11 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private String currentUrl; private String currentUrl;
private String currentPhotoFilter; private String currentPhotoFilter;
private ImageReceiver photoImage; private ImageReceiver photoImage;
private ProgressView progressView; private RoundProgressView progressView;
public int downloadPhotos = 0; public int downloadPhotos = 0;
private boolean progressVisible = false; private boolean progressVisible = false;
private boolean photoNotSet = false; private boolean photoNotSet = false;
private boolean cancelLoading = false;
private int TAG; private int TAG;
...@@ -83,14 +84,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -83,14 +84,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (placeholderInDrawable == null) { if (placeholderInDrawable == null) {
placeholderInDrawable = getResources().getDrawable(R.drawable.photo_placeholder_in); placeholderInDrawable = getResources().getDrawable(R.drawable.photo_placeholder_in);
placeholderOutDrawable = getResources().getDrawable(R.drawable.photo_placeholder_out); placeholderOutDrawable = getResources().getDrawable(R.drawable.photo_placeholder_out);
buttonStatesDrawables[0][0] = getResources().getDrawable(R.drawable.photoload); buttonStatesDrawables[0] = getResources().getDrawable(R.drawable.photoload);
buttonStatesDrawables[0][1] = getResources().getDrawable(R.drawable.photoload_pressed); buttonStatesDrawables[1] = getResources().getDrawable(R.drawable.photocancel);
buttonStatesDrawables[1][0] = getResources().getDrawable(R.drawable.photocancel); buttonStatesDrawables[2] = getResources().getDrawable(R.drawable.photogif);
buttonStatesDrawables[1][1] = getResources().getDrawable(R.drawable.photocancel_pressed); buttonStatesDrawables[3] = getResources().getDrawable(R.drawable.playvideo);
buttonStatesDrawables[2][0] = getResources().getDrawable(R.drawable.photogif);
buttonStatesDrawables[2][1] = getResources().getDrawable(R.drawable.photogif_pressed);
buttonStatesDrawables[3][0] = getResources().getDrawable(R.drawable.playvideo);
buttonStatesDrawables[3][1] = getResources().getDrawable(R.drawable.playvideo_pressed);
videoIconDrawable = getResources().getDrawable(R.drawable.ic_video); videoIconDrawable = getResources().getDrawable(R.drawable.ic_video);
infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
...@@ -102,8 +99,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -102,8 +99,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoImage = new ImageReceiver(); photoImage = new ImageReceiver();
photoImage.parentView = this; photoImage.parentView = this;
progressView = new ProgressView(); progressView = new RoundProgressView();
progressView.setProgressColors(0x802a2a2a, 0xffffffff);
} }
public void clearGifImage() { public void clearGifImage() {
...@@ -225,6 +221,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -225,6 +221,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private void didPressedButton() { private void didPressedButton() {
if (buttonState == 0) { if (buttonState == 0) {
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);
...@@ -246,6 +243,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -246,6 +243,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
delegate.didPressedCancelSendButton(this); delegate.didPressedCancelSendButton(this);
} }
} else { } else {
cancelLoading = true;
if (currentMessageObject.type == 1) { if (currentMessageObject.type == 1) {
FileLoader.getInstance().cancelLoadingForImageView(photoImage); FileLoader.getInstance().cancelLoadingForImageView(photoImage);
} else if (currentMessageObject.type == 8) { } else if (currentMessageObject.type == 8) {
...@@ -304,6 +302,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -304,6 +302,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
public void setMessageObject(MessageObject messageObject) { public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || isUserDataChanged()) { if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || isUserDataChanged()) {
super.setMessageObject(messageObject); super.setMessageObject(messageObject);
cancelLoading = false;
progressVisible = false; progressVisible = false;
buttonState = -1; buttonState = -1;
...@@ -395,6 +394,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -395,6 +394,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoHeight = h; photoHeight = h;
backgroundWidth = w + AndroidUtilities.dp(12); backgroundWidth = w + AndroidUtilities.dp(12);
currentPhotoFilter = String.format(Locale.US, "%d_%d", (int) (w / AndroidUtilities.density), (int) (h / AndroidUtilities.density)); currentPhotoFilter = String.format(Locale.US, "%d_%d", (int) (w / AndroidUtilities.density), (int) (h / AndroidUtilities.density));
if (messageObject.photoThumbs.size() > 1) {
currentPhotoFilter += "_b";
}
if (currentPhotoObject.image != null) { if (currentPhotoObject.image != null) {
photoImage.setImageBitmap(currentPhotoObject.image); photoImage.setImageBitmap(currentPhotoObject.image);
...@@ -485,20 +487,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -485,20 +487,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (!cacheFile.exists()) { if (!cacheFile.exists()) {
MediaController.getInstance().addLoadingFileObserver(fileName, this); MediaController.getInstance().addLoadingFileObserver(fileName, this);
if (!FileLoader.getInstance().isLoadingFile(fileName)) { if (!FileLoader.getInstance().isLoadingFile(fileName)) {
if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) { if (cancelLoading || currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
buttonState = 0; buttonState = 0;
progressVisible = false; progressVisible = false;
} else { } else {
buttonState = -1; buttonState = 1;
progressVisible = true; progressVisible = true;
} }
progressView.setProgress(0); progressView.setProgress(0);
} else { } else {
if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) { buttonState = 1;
buttonState = 1;
} else {
buttonState = -1;
}
progressVisible = true; progressVisible = true;
Float progress = FileLoader.getInstance().fileProgresses.get(fileName); Float progress = FileLoader.getInstance().fileProgresses.get(fileName);
if (progress != null) { if (progress != null) {
...@@ -544,13 +542,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -544,13 +542,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoImage.imageW = photoWidth; photoImage.imageW = photoWidth;
photoImage.imageH = photoHeight; photoImage.imageH = photoHeight;
progressView.width = timeX - photoImage.imageX - AndroidUtilities.dpf(23.0f);
progressView.height = AndroidUtilities.dp(3);
progressView.progressHeight = AndroidUtilities.dp(3);
int size = AndroidUtilities.dp(44); int size = AndroidUtilities.dp(44);
buttonX = (int)(photoImage.imageX + (photoWidth - size) / 2.0f); buttonX = (int)(photoImage.imageX + (photoWidth - size) / 2.0f);
buttonY = (int)(photoImage.imageY + (photoHeight - size) / 2.0f); buttonY = (int)(photoImage.imageY + (photoHeight - size) / 2.0f);
progressView.rect.set(buttonX + AndroidUtilities.dp(2), buttonY + AndroidUtilities.dp(2), buttonX + AndroidUtilities.dp(42), buttonY + AndroidUtilities.dp(42));
} }
@Override @Override
...@@ -566,22 +561,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -566,22 +561,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
drawTime = photoImage.getVisible(); drawTime = photoImage.getVisible();
} }
if (progressVisible) {
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + AndroidUtilities.dp(4), layoutHeight - AndroidUtilities.dpf(27.5f), progressView.width + AndroidUtilities.dp(12), AndroidUtilities.dpf(16.5f));
mediaBackgroundDrawable.draw(canvas);
canvas.save();
canvas.translate(photoImage.imageX + AndroidUtilities.dp(10), layoutHeight - AndroidUtilities.dpf(21.0f));
progressView.draw(canvas);
canvas.restore();
}
if (buttonState >= 0 && buttonState < 4) { if (buttonState >= 0 && buttonState < 4) {
Drawable currentButtonDrawable = buttonStatesDrawables[buttonState][buttonPressed]; Drawable currentButtonDrawable = buttonStatesDrawables[buttonState];
setDrawableBounds(currentButtonDrawable, buttonX, buttonY); setDrawableBounds(currentButtonDrawable, buttonX, buttonY);
currentButtonDrawable.draw(canvas); currentButtonDrawable.draw(canvas);
} }
if (progressVisible) {
progressView.draw(canvas);
}
if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3)) { if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3)) {
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + AndroidUtilities.dp(4), photoImage.imageY + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dpf(16.5f)); setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + AndroidUtilities.dp(4), photoImage.imageY + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dpf(16.5f));
mediaBackgroundDrawable.draw(canvas); mediaBackgroundDrawable.draw(canvas);
......
...@@ -46,6 +46,7 @@ public class DialogCell extends BaseCell { ...@@ -46,6 +46,7 @@ public class DialogCell extends BaseCell {
private static Drawable lockDrawable; private static Drawable lockDrawable;
private static Drawable countDrawable; private static Drawable countDrawable;
private static Drawable groupDrawable; private static Drawable groupDrawable;
private static Drawable broadcastDrawable;
private TLRPC.TL_dialog currentDialog; private TLRPC.TL_dialog currentDialog;
private ImageReceiver avatarImage; private ImageReceiver avatarImage;
...@@ -130,6 +131,10 @@ public class DialogCell extends BaseCell { ...@@ -130,6 +131,10 @@ public class DialogCell extends BaseCell {
groupDrawable = getResources().getDrawable(R.drawable.grouplist); groupDrawable = getResources().getDrawable(R.drawable.grouplist);
} }
if (broadcastDrawable == null) {
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
}
if (avatarImage == null) { if (avatarImage == null) {
avatarImage = new ImageReceiver(); avatarImage = new ImageReceiver();
avatarImage.parentView = this; avatarImage.parentView = this;
...@@ -227,9 +232,14 @@ public class DialogCell extends BaseCell { ...@@ -227,9 +232,14 @@ public class DialogCell extends BaseCell {
user = MessagesController.getInstance().users.get(lower_id); user = MessagesController.getInstance().users.get(lower_id);
} }
} else { } else {
encryptedChat = MessagesController.getInstance().encryptedChats.get((int)(currentDialog.id >> 32)); int high_id = (int)(currentDialog.id >> 32);
if (encryptedChat != null) { if (high_id > 0) {
user = MessagesController.getInstance().users.get(encryptedChat.user_id); encryptedChat = MessagesController.getInstance().encryptedChats.get(high_id);
if (encryptedChat != null) {
user = MessagesController.getInstance().users.get(encryptedChat.user_id);
}
} else {
chat = MessagesController.getInstance().chats.get(high_id);
} }
} }
...@@ -274,6 +284,9 @@ public class DialogCell extends BaseCell { ...@@ -274,6 +284,9 @@ public class DialogCell extends BaseCell {
} else if (cellLayout.drawNameGroup) { } else if (cellLayout.drawNameGroup) {
setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop); setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
groupDrawable.draw(canvas); groupDrawable.draw(canvas);
} else if (cellLayout.drawNameBroadcast) {
setDrawableBounds(broadcastDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
broadcastDrawable.draw(canvas);
} }
canvas.save(); canvas.save();
...@@ -328,6 +341,7 @@ public class DialogCell extends BaseCell { ...@@ -328,6 +341,7 @@ public class DialogCell extends BaseCell {
private StaticLayout nameLayout; private StaticLayout nameLayout;
private boolean drawNameLock; private boolean drawNameLock;
private boolean drawNameGroup; private boolean drawNameGroup;
private boolean drawNameBroadcast;
private int nameLockLeft; private int nameLockLeft;
private int nameLockTop; private int nameLockTop;
...@@ -372,9 +386,12 @@ public class DialogCell extends BaseCell { ...@@ -372,9 +386,12 @@ public class DialogCell extends BaseCell {
TextPaint currentMessagePaint = messagePaint; TextPaint currentMessagePaint = messagePaint;
boolean checkMessage = true; boolean checkMessage = true;
drawNameGroup = false;
drawNameBroadcast = false;
drawNameLock = false;
if (encryptedChat != null) { if (encryptedChat != null) {
drawNameLock = true; drawNameLock = true;
drawNameGroup = false;
nameLockTop = AndroidUtilities.dp(13); nameLockTop = AndroidUtilities.dp(13);
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(77); nameLockLeft = AndroidUtilities.dp(77);
...@@ -384,19 +401,21 @@ public class DialogCell extends BaseCell { ...@@ -384,19 +401,21 @@ public class DialogCell extends BaseCell {
nameLeft = AndroidUtilities.dp(14); nameLeft = AndroidUtilities.dp(14);
} }
} else { } else {
drawNameLock = false;
if (chat != null) { if (chat != null) {
drawNameGroup = true; if (chat.id < 0) {
drawNameBroadcast = true;
} else {
drawNameGroup = true;
}
nameLockTop = AndroidUtilities.dp(14); nameLockTop = AndroidUtilities.dp(14);
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(77); nameLockLeft = AndroidUtilities.dp(77);
nameLeft = AndroidUtilities.dp(81) + groupDrawable.getIntrinsicWidth(); nameLeft = AndroidUtilities.dp(81) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
} else { } else {
nameLockLeft = width - AndroidUtilities.dp(77) - groupDrawable.getIntrinsicWidth(); nameLockLeft = width - AndroidUtilities.dp(77) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
nameLeft = AndroidUtilities.dp(14); nameLeft = AndroidUtilities.dp(14);
} }
} else { } else {
drawNameGroup = false;
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(77); nameLeft = AndroidUtilities.dp(77);
} else { } else {
...@@ -461,7 +480,7 @@ public class DialogCell extends BaseCell { ...@@ -461,7 +480,7 @@ public class DialogCell extends BaseCell {
messageString = message.messageText; messageString = message.messageText;
currentMessagePaint = messagePrintingPaint; currentMessagePaint = messagePrintingPaint;
} else { } else {
if (chat != null) { if (chat != null && chat.id > 0) {
String name = ""; String name = "";
if (message.isFromMe()) { if (message.isFromMe()) {
name = LocaleController.getString("FromYou", R.string.FromYou); name = LocaleController.getString("FromYou", R.string.FromYou);
...@@ -505,7 +524,7 @@ public class DialogCell extends BaseCell { ...@@ -505,7 +524,7 @@ public class DialogCell extends BaseCell {
} }
} }
if (message.isFromMe()) { if (message.isFromMe() && message.isOut()) {
if (message.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SENDING) { if (message.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SENDING) {
drawCheck1 = false; drawCheck1 = false;
drawCheck2 = false; drawCheck2 = false;
...@@ -579,6 +598,8 @@ public class DialogCell extends BaseCell { ...@@ -579,6 +598,8 @@ public class DialogCell extends BaseCell {
nameWidth -= AndroidUtilities.dp(4) + lockDrawable.getIntrinsicWidth(); nameWidth -= AndroidUtilities.dp(4) + lockDrawable.getIntrinsicWidth();
} else if (drawNameGroup) { } else if (drawNameGroup) {
nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth(); nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth();
} else if (drawNameBroadcast) {
nameWidth -= AndroidUtilities.dp(4) + broadcastDrawable.getIntrinsicWidth();
} }
if (drawClock) { if (drawClock) {
int w = clockDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2); int w = clockDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2);
......
...@@ -212,7 +212,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -212,7 +212,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
MessagesController.getInstance().loadChatInfo(currentChat.id); MessagesController.getInstance().loadChatInfo(currentChat.id);
dialog_id = -chatId; if (chatId > 0) {
dialog_id = -chatId;
} else {
dialog_id = ((long)chatId) << 32;
}
} else if (userId != 0) { } else if (userId != 0) {
currentUser = MessagesController.getInstance().users.get(userId); currentUser = MessagesController.getInstance().users.get(userId);
if (currentUser == null) { if (currentUser == null) {
...@@ -528,6 +532,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -528,6 +532,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentEncryptedChat != null) { if (currentEncryptedChat != null) {
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
} else if (currentChat != null && currentChat.id < 0) {
actionBarLayer.setTitleIcon(R.drawable.broadcast2, AndroidUtilities.dp(4));
} }
ActionBarMenu menu = actionBarLayer.createMenu(); ActionBarMenu menu = actionBarLayer.createMenu();
...@@ -1045,7 +1051,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -1045,7 +1051,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private int getMessageType(MessageObject messageObject) { private int getMessageType(MessageObject messageObject) {
if (currentEncryptedChat == null) { if (currentEncryptedChat == null) {
if (messageObject.messageOwner.id <= 0 && messageObject.isOut()) { boolean isBroadcastError = (int)dialog_id == 0 && messageObject.messageOwner.id <= 0 && messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR;
if ((int)dialog_id != 0 && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
if (messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) { if (messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) {
if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
return 0; return 0;
...@@ -1771,7 +1778,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -1771,7 +1778,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messArr.size() != count) { if (messArr.size() != count) {
if (isCache) { if (isCache) {
cacheEndReaced = true; cacheEndReaced = true;
if (currentEncryptedChat != null) { if ((int)dialog_id == 0) {
endReached = true; endReached = true;
} }
} else { } else {
...@@ -2897,24 +2904,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -2897,24 +2904,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private void forwardSelectedMessages(long did, boolean fromMyName) { private void forwardSelectedMessages(long did, boolean fromMyName) {
if (forwaringMessage != null) { if (forwaringMessage != null) {
if (forwaringMessage.messageOwner.id > 0) { if (!fromMyName) {
if (!fromMyName) { if (forwaringMessage.messageOwner.id > 0) {
MessagesController.getInstance().sendMessage(forwaringMessage, did); MessagesController.getInstance().sendMessage(forwaringMessage, did);
} else {
processForwardFromMe(forwaringMessage, did);
} }
} else {
processForwardFromMe(forwaringMessage, did);
} }
forwaringMessage = null; forwaringMessage = null;
} else { } else {
ArrayList<Integer> ids = new ArrayList<Integer>(selectedMessagesIds.keySet()); ArrayList<Integer> ids = new ArrayList<Integer>(selectedMessagesIds.keySet());
Collections.sort(ids); Collections.sort(ids);
for (Integer id : ids) { for (Integer id : ids) {
if (id > 0) { if (!fromMyName) {
if (!fromMyName) { if (id > 0) {
MessagesController.getInstance().sendMessage(selectedMessagesIds.get(id), did); MessagesController.getInstance().sendMessage(selectedMessagesIds.get(id), did);
} else {
processForwardFromMe(selectedMessagesIds.get(id), did);
} }
} else {
processForwardFromMe(selectedMessagesIds.get(id), did);
} }
} }
selectedMessagesCanCopyIds.clear(); selectedMessagesCanCopyIds.clear();
...@@ -2925,7 +2932,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -2925,7 +2932,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override @Override
public void didSelectDialog(MessagesActivity activity, long did, boolean param) { public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) { if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
if ((int)dialog_id == 0 && currentEncryptedChat == null) {
param = true;
}
if (did != dialog_id) { if (did != dialog_id) {
int lower_part = (int)did; int lower_part = (int)did;
if (lower_part != 0) { if (lower_part != 0) {
......
...@@ -90,6 +90,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -90,6 +90,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
private TextView emptyTextView; private TextView emptyTextView;
private EditText userSelectEditText; private EditText userSelectEditText;
private boolean ignoreChange = false; private boolean ignoreChange = false;
private boolean isBroadcast = false;
private HashMap<Integer, XImageSpan> selectedContacts = new HashMap<Integer, XImageSpan>(); private HashMap<Integer, XImageSpan> selectedContacts = new HashMap<Integer, XImageSpan>();
private ArrayList<XImageSpan> allSpans = new ArrayList<XImageSpan>(); private ArrayList<XImageSpan> allSpans = new ArrayList<XImageSpan>();
...@@ -105,6 +106,15 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -105,6 +106,15 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
private final static int done_button = 1; private final static int done_button = 1;
public GroupCreateActivity() {
super();
}
public GroupCreateActivity(Bundle args) {
super(args);
isBroadcast = args.getBoolean("broadcast", false);
}
@Override @Override
public boolean onFragmentCreate() { public boolean onFragmentCreate() {
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded); NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
...@@ -126,7 +136,11 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -126,7 +136,11 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setBackOverlay(R.layout.updating_state_layout); actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); if (isBroadcast) {
actionBarLayer.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
} else {
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
}
actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200)); actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
...@@ -140,6 +154,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -140,6 +154,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
result.addAll(selectedContacts.keySet()); result.addAll(selectedContacts.keySet());
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putIntegerArrayList("result", result); args.putIntegerArrayList("result", result);
args.putBoolean("broadcast", isBroadcast);
presentFragment(new GroupCreateFinalActivity(args)); presentFragment(new GroupCreateFinalActivity(args));
} }
} }
......
...@@ -458,7 +458,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen ...@@ -458,7 +458,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
args.putInt("chat_id", -lower_part); args.putInt("chat_id", -lower_part);
} }
} else { } else {
args.putInt("enc_id", (int)(dialog_id >> 32)); int high_id = (int)(dialog_id >> 32);
if (high_id > 0) {
args.putInt("enc_id", high_id);
} else {
args.putInt("chat_id", high_id);
}
} }
ChatActivity fragment = new ChatActivity(args); ChatActivity fragment = new ChatActivity(args);
presentFragment(fragment, true); presentFragment(fragment, true);
......
...@@ -74,6 +74,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -74,6 +74,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
private final static int messages_list_menu_new_secret_chat = 3; private final static int messages_list_menu_new_secret_chat = 3;
private final static int messages_list_menu_contacts = 4; private final static int messages_list_menu_contacts = 4;
private final static int messages_list_menu_settings = 5; private final static int messages_list_menu_settings = 5;
private final static int messages_list_menu_new_broadcast = 6;
public static interface MessagesActivityDelegate { public static interface MessagesActivityDelegate {
public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id, boolean param); public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id, boolean param);
...@@ -175,6 +176,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -175,6 +176,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
item.addSubItem(messages_list_menu_new_chat, LocaleController.getString("NewGroup", R.string.NewGroup), 0); item.addSubItem(messages_list_menu_new_chat, LocaleController.getString("NewGroup", R.string.NewGroup), 0);
item.addSubItem(messages_list_menu_new_secret_chat, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), 0); item.addSubItem(messages_list_menu_new_secret_chat, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), 0);
item.addSubItem(messages_list_menu_new_broadcast, LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), 0);
item.addSubItem(messages_list_menu_contacts, LocaleController.getString("Contacts", R.string.Contacts), 0); item.addSubItem(messages_list_menu_contacts, LocaleController.getString("Contacts", R.string.Contacts), 0);
item.addSubItem(messages_list_menu_settings, LocaleController.getString("Settings", R.string.Settings), 0); item.addSubItem(messages_list_menu_settings, LocaleController.getString("Settings", R.string.Settings), 0);
} }
...@@ -206,6 +208,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -206,6 +208,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (onlySelect) { if (onlySelect) {
finishFragment(); finishFragment();
} }
} else if (id == messages_list_menu_new_broadcast) {
Bundle args = new Bundle();
args.putBoolean("broadcast", true);
presentFragment(new GroupCreateActivity(args));
} }
} }
}); });
...@@ -289,7 +295,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -289,7 +295,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
args.putInt("chat_id", -lower_part); args.putInt("chat_id", -lower_part);
} }
} else { } else {
args.putInt("enc_id", (int)(dialog_id >> 32)); int high_id = (int)(dialog_id >> 32);
if (high_id > 0) {
args.putInt("enc_id", high_id);
} else {
args.putInt("chat_id", high_id);
}
} }
presentFragment(new ChatActivity(args)); presentFragment(new ChatActivity(args));
} }
...@@ -497,13 +508,21 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -497,13 +508,21 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title)); builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
} }
} else { } else {
int chat_id = (int)(dialog_id >> 32); int high_id = (int)(dialog_id >> 32);
TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(chat_id); if (high_id > 0) {
TLRPC.User user = MessagesController.getInstance().users.get(chat.user_id); TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(high_id);
if (user == null) { TLRPC.User user = MessagesController.getInstance().users.get(chat.user_id);
return; if (user == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} else {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(high_id);
if (chat == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
} }
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} }
CheckBox checkBox = null; CheckBox checkBox = null;
/*if (delegate instanceof ChatActivity) { /*if (delegate instanceof ChatActivity) {
......
...@@ -874,9 +874,6 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -874,9 +874,6 @@ public class PopupNotificationActivity extends Activity implements NotificationC
chatActivityEnterView.setFieldFocused(false); chatActivityEnterView.setFieldFocused(false);
} }
ConnectionsManager.getInstance().setAppPaused(true, false); ConnectionsManager.getInstance().setAppPaused(true, false);
if (wakeLock.isHeld()) {
wakeLock.release();
}
} }
@Override @Override
......
...@@ -568,6 +568,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -568,6 +568,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
users.add(res.user);
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
MessagesController.getInstance().users.put(res.user.id, res.user); MessagesController.getInstance().users.put(res.user.id, res.user);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt("user_id", res.user.id); args.putInt("user_id", res.user.id);
......
...@@ -406,7 +406,8 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif ...@@ -406,7 +406,8 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
} }
public void updateServerNotificationsSettings(boolean group) { public void updateServerNotificationsSettings(boolean group) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); //disable global settings sync
/*SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings(); TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
req.settings = new TLRPC.TL_inputPeerNotifySettings(); req.settings = new TLRPC.TL_inputPeerNotifySettings();
req.settings.sound = "default"; req.settings.sound = "default";
...@@ -425,7 +426,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif ...@@ -425,7 +426,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
} }
}); });*/
} }
@Override @Override
......
...@@ -467,18 +467,15 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C ...@@ -467,18 +467,15 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
List<Track> tracks = movie.getTracks(); List<Track> tracks = movie.getTracks();
movie.setTracks(new LinkedList<Track>()); movie.setTracks(new LinkedList<Track>());
double startTime = videoTimelineView.getLeftProgress() * videoPlayer.getDuration() / 1000.0; double startTime = 0;
double endTime = videoTimelineView.getRightProgress() * videoPlayer.getDuration() / 1000.0; double endTime = 0;
boolean timeCorrected = false;
for (Track track : tracks) { for (Track track : tracks) {
if (track.getSyncSamples() != null && track.getSyncSamples().length > 0) { if (track.getSyncSamples() != null && track.getSyncSamples().length > 0) {
if (timeCorrected) { double duration = (double)track.getDuration() / (double)track.getTrackMetaData().getTimescale();
throw new RuntimeException("The startTime has already been corrected by another track with SyncSample. Not Supported."); startTime = correctTimeToSyncSample(track, videoTimelineView.getLeftProgress() * duration, false);
} endTime = videoTimelineView.getRightProgress() * duration;
startTime = correctTimeToSyncSample(track, startTime, false); break;
endTime = correctTimeToSyncSample(track, endTime, true);
timeCorrected = true;
} }
} }
...@@ -486,7 +483,7 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C ...@@ -486,7 +483,7 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
long currentSample = 0; long currentSample = 0;
double currentTime = 0; double currentTime = 0;
double lastTime = 0; double lastTime = 0;
long startSample = -1; long startSample = 0;
long endSample = -1; long endSample = -1;
for (int i = 0; i < track.getSampleDurations().length; i++) { for (int i = 0; i < track.getSampleDurations().length; i++) {
...@@ -503,9 +500,7 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C ...@@ -503,9 +500,7 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
} }
movie.addTrack(new CroppedTrack(track, startSample, endSample)); movie.addTrack(new CroppedTrack(track, startSample, endSample));
} }
long start1 = System.currentTimeMillis();
Container out = new DefaultMp4Builder().build(movie); Container out = new DefaultMp4Builder().build(movie);
long start2 = System.currentTimeMillis();
String fileName = Integer.MIN_VALUE + "_" + UserConfig.lastLocalId + ".mp4"; String fileName = Integer.MIN_VALUE + "_" + UserConfig.lastLocalId + ".mp4";
UserConfig.lastLocalId--; UserConfig.lastLocalId--;
...@@ -524,6 +519,11 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C ...@@ -524,6 +519,11 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
} }
} }
// private void startEncodeVideo() {
// MediaExtractor mediaExtractor = new MediaExtractor();
// mediaExtractor.s
// }
private static double correctTimeToSyncSample(Track track, double cutHere, boolean next) { private static double correctTimeToSyncSample(Track track, double cutHere, boolean next) {
double[] timeOfSyncSamples = new double[track.getSyncSamples().length]; double[] timeOfSyncSamples = new double[track.getSyncSamples().length];
long currentSample = 0; long currentSample = 0;
......
...@@ -46,7 +46,7 @@ public class GifDrawable extends Drawable implements Animatable, MediaController ...@@ -46,7 +46,7 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
private static native void renderFrame(int[] pixels, int gifFileInPtr, int[] metaData); private static native void renderFrame(int[] pixels, int gifFileInPtr, int[] metaData);
private static native int openFile(int[] metaData, String filePath); private static native int openFile(int[] metaData, String filePath);
private static native void free(int gifFileInPtr); private static native void free(int gifFileInPtr);
private static native boolean reset(int gifFileInPtr); private static native void reset(int gifFileInPtr);
private static native void setSpeedFactor(int gifFileInPtr, float factor); private static native void setSpeedFactor(int gifFileInPtr, float factor);
private static native String getComment(int gifFileInPtr); private static native String getComment(int gifFileInPtr);
private static native int getLoopCount(int gifFileInPtr); private static native int getLoopCount(int gifFileInPtr);
......
...@@ -75,17 +75,20 @@ public class ImageReceiver { ...@@ -75,17 +75,20 @@ public class ImageReceiver {
if (filter != null) { if (filter != null) {
key += "@" + filter; key += "@" + filter;
} }
Bitmap img; Bitmap img = null;
if (currentPath != null) { if (currentPath != null) {
if (currentPath.equals(key)) { if (currentPath.equals(key)) {
return; if (currentImage != null) {
return;
} else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
}
} else { } else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter, true); img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
recycleBitmap(img); recycleBitmap(img);
} }
} else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter, true);
} }
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
currentPath = key; currentPath = key;
last_path = path; last_path = path;
last_httpUrl = httpUrl; last_httpUrl = httpUrl;
......
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Views;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import org.telegram.android.AndroidUtilities;
public class RoundProgressView {
private Paint paint;
public float currentProgress = 0;
public RectF rect = new RectF();
public RoundProgressView() {
paint = new Paint();
paint.setColor(0xffffffff);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(AndroidUtilities.dp(1));
paint.setAntiAlias(true);
}
public void setProgress(float progress) {
currentProgress = progress;
if (currentProgress < 0) {
currentProgress = 0;
} else if (currentProgress > 1) {
currentProgress = 1;
}
}
public void draw(Canvas canvas) {
canvas.drawArc(rect, -90, 360 * currentProgress, false, paint);
}
}
TMessagesProj/src/main/res/drawable-hdpi/playvideo.png

2.59 KB | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/playvideo.png

2.3 KB | W: | H:

TMessagesProj/src/main/res/drawable-hdpi/playvideo.png
TMessagesProj/src/main/res/drawable-hdpi/playvideo.png
TMessagesProj/src/main/res/drawable-hdpi/playvideo.png
TMessagesProj/src/main/res/drawable-hdpi/playvideo.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-ldpi/playvideo.png

785 Bytes | W: | H:

TMessagesProj/src/main/res/drawable-ldpi/playvideo.png

1.59 KB | W: | H:

TMessagesProj/src/main/res/drawable-ldpi/playvideo.png
TMessagesProj/src/main/res/drawable-ldpi/playvideo.png
TMessagesProj/src/main/res/drawable-ldpi/playvideo.png
TMessagesProj/src/main/res/drawable-ldpi/playvideo.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-mdpi/playvideo.png

1.78 KB | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/playvideo.png

1.84 KB | W: | H:

TMessagesProj/src/main/res/drawable-mdpi/playvideo.png
TMessagesProj/src/main/res/drawable-mdpi/playvideo.png
TMessagesProj/src/main/res/drawable-mdpi/playvideo.png
TMessagesProj/src/main/res/drawable-mdpi/playvideo.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png

3.45 KB | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png

2.74 KB | W: | H:

TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png
TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png
TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png
TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png
  • 2-up
  • Swipe
  • Onion skin
TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png

5.23 KB | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png

3.63 KB | W: | H:

TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png
TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png
TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png
TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">الاسم مخفي</string> <string name="HiddenName">الاسم مخفي</string>
<string name="SelectChat">اختر محادثة</string> <string name="SelectChat">اختر محادثة</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">اختر ملف</string> <string name="SelectFile">اختر ملف</string>
<string name="FreeOfTotal">متاح %1$s من %2$s</string> <string name="FreeOfTotal">متاح %1$s من %2$s</string>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">Versteckter Name</string> <string name="HiddenName">Versteckter Name</string>
<string name="SelectChat">Chat auswählen</string> <string name="SelectChat">Chat auswählen</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">Datei auswählen</string> <string name="SelectFile">Datei auswählen</string>
<string name="FreeOfTotal">Freier Speicher: %1$s von %2$s</string> <string name="FreeOfTotal">Freier Speicher: %1$s von %2$s</string>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">Nombre oculto</string> <string name="HiddenName">Nombre oculto</string>
<string name="SelectChat">Selecciona el chat</string> <string name="SelectChat">Selecciona el chat</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">Seleccionar archivo</string> <string name="SelectFile">Seleccionar archivo</string>
<string name="FreeOfTotal">%1$s de %2$s libres</string> <string name="FreeOfTotal">%1$s de %2$s libres</string>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">Nome nascosto</string> <string name="HiddenName">Nome nascosto</string>
<string name="SelectChat">Seleziona chat</string> <string name="SelectChat">Seleziona chat</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">Seleziona file</string> <string name="SelectFile">Seleziona file</string>
<string name="FreeOfTotal">Liberi %1$s di %2$s</string> <string name="FreeOfTotal">Liberi %1$s di %2$s</string>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">Verborgen naam</string> <string name="HiddenName">Verborgen naam</string>
<string name="SelectChat">Kies een gesprek</string> <string name="SelectChat">Kies een gesprek</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">Kies een bestand</string> <string name="SelectFile">Kies een bestand</string>
<string name="FreeOfTotal">Vrij: %1$s van %2$s</string> <string name="FreeOfTotal">Vrij: %1$s van %2$s</string>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">Nome oculto</string> <string name="HiddenName">Nome oculto</string>
<string name="SelectChat">Selecione uma Conversa</string> <string name="SelectChat">Selecione uma Conversa</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">Selecione um Arquivo</string> <string name="SelectFile">Selecione um Arquivo</string>
<string name="FreeOfTotal">Disponível %1$s de %2$s</string> <string name="FreeOfTotal">Disponível %1$s de %2$s</string>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">Nome oculto</string> <string name="HiddenName">Nome oculto</string>
<string name="SelectChat">Selecionar chat</string> <string name="SelectChat">Selecionar chat</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">Selecionar ficheiro</string> <string name="SelectFile">Selecionar ficheiro</string>
<string name="FreeOfTotal">%1$s de %2$s livres</string> <string name="FreeOfTotal">%1$s de %2$s livres</string>
......
...@@ -57,6 +57,14 @@ ...@@ -57,6 +57,14 @@
<string name="HiddenName">Hidden Name</string> <string name="HiddenName">Hidden Name</string>
<string name="SelectChat">Select Chat</string> <string name="SelectChat">Select Chat</string>
<!--broadcasts-->
<string name="BroadcastList">Broadcast List</string>
<string name="NewBroadcastList">New Broadcast List</string>
<string name="EnterListName">Enter list name</string>
<string name="YouCreatedBroadcastList">You created a broadcast list</string>
<string name="AddRecipient">Add Recipient</string>
<string name="KickFromBroadcast">Remove from broadcast list</string>
<!--documents view--> <!--documents view-->
<string name="SelectFile">Select File</string> <string name="SelectFile">Select File</string>
<string name="FreeOfTotal">Free %1$s of %2$s</string> <string name="FreeOfTotal">Free %1$s of %2$s</string>
...@@ -150,7 +158,7 @@ ...@@ -150,7 +158,7 @@
<string name="NotificationGroupKickYou">%1$s removed you from the group %2$s</string> <string name="NotificationGroupKickYou">%1$s removed you from the group %2$s</string>
<string name="NotificationGroupLeftMember">%1$s has left the group %2$s</string> <string name="NotificationGroupLeftMember">%1$s has left the group %2$s</string>
<string name="NotificationContactJoined">%1$s joined Telegram!</string> <string name="NotificationContactJoined">%1$s joined Telegram!</string>
<string name="NotificationUnrecognizedDevice">%1$s,\nWe detected a login into your account from a new device on %2$s\n\nDevice: %3$s\nLocation: %4$s\n\nIf this wasn’t you, you can go to Settings – Terminate all sessions.\n\nThanks,\nThe Telegram Team</string> <string name="NotificationUnrecognizedDevice">%1$s,\nWe detected a login into your account from a new device on %2$s\n\nDevice: %3$s\nLocation: %4$s\n\nIf this wasn\'t you, you can go to Settings - Terminate all sessions.\n\nSincerely,\nThe Telegram Team</string>
<string name="NotificationContactNewPhoto">%1$s updated profile photo</string> <string name="NotificationContactNewPhoto">%1$s updated profile photo</string>
<!--contacts view--> <!--contacts view-->
...@@ -263,19 +271,19 @@ ...@@ -263,19 +271,19 @@
<string name="Enabled">Enabled</string> <string name="Enabled">Enabled</string>
<string name="Disabled">Disabled</string> <string name="Disabled">Disabled</string>
<string name="NotificationsService">Notifications Service</string> <string name="NotificationsService">Notifications Service</string>
<string name="NotificationsServiceDisableInfo">If google play services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string> <string name="NotificationsServiceDisableInfo">If Google Play Services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications.</string>
<string name="SortBy">Sort By</string> <string name="SortBy">Sort By</string>
<string name="ImportContacts">Import Contacts</string> <string name="ImportContacts">Import Contacts</string>
<string name="WiFiOnly">Via WiFi only</string> <string name="WiFiOnly">Via WiFi only</string>
<string name="SortFirstName">First name</string> <string name="SortFirstName">First name</string>
<string name="SortLastName">Last name</string> <string name="SortLastName">Last name</string>
<string name="LedColor">LED Color</string> <string name="LedColor">LED Color</string>
<string name="PopupNotification">Popup Notification</string> <string name="PopupNotification">Popup Notifications</string>
<string name="NoPopup">No popup</string> <string name="NoPopup">No popup</string>
<string name="OnlyWhenScreenOn">Only when screen "on"</string> <string name="OnlyWhenScreenOn">Only when screen "on"</string>
<string name="OnlyWhenScreenOff">Only when screen "off"</string> <string name="OnlyWhenScreenOff">Only when screen "off"</string>
<string name="AlwaysShowPopup">Always show popup</string> <string name="AlwaysShowPopup">Always show popup</string>
<string name="BadgeNumber">Badge Number</string> <string name="BadgeNumber">Badge Counter</string>
<!--media view--> <!--media view-->
<string name="NoMedia">No shared media yet</string> <string name="NoMedia">No shared media yet</string>
...@@ -362,8 +370,8 @@ ...@@ -362,8 +370,8 @@
<string name="InvalidLastName">Invalid last name</string> <string name="InvalidLastName">Invalid last name</string>
<string name="Loading">Loading...</string> <string name="Loading">Loading...</string>
<string name="NoPlayerInstalled">You don\'t have a video player, please install one to continue</string> <string name="NoPlayerInstalled">You don\'t have a video player, please install one to continue</string>
<string name="NoMailInstalled">Please send an email to sms@telegram.org and explain your problem.</string> <string name="NoMailInstalled">Please send an email to sms@telegram.org and tell us about your problem.</string>
<string name="NoHandleAppInstalled">You don\'t have any application that can handle with mime type \'%1$s\', please install one to continue</string> <string name="NoHandleAppInstalled">You don\'t have applications that can handle the file type \'%1$s\', please install one to continue</string>
<string name="InviteUser">This user does not have Telegram yet, send an invitation?</string> <string name="InviteUser">This user does not have Telegram yet, send an invitation?</string>
<string name="AreYouSure">Are you sure?</string> <string name="AreYouSure">Are you sure?</string>
<string name="AddContactQ">Add contact?</string> <string name="AddContactQ">Add contact?</string>
...@@ -371,15 +379,15 @@ ...@@ -371,15 +379,15 @@
<string name="ForwardMessagesTo">Forward messages to %1$s?</string> <string name="ForwardMessagesTo">Forward messages to %1$s?</string>
<string name="DeleteChatQuestion">Delete this chat?</string> <string name="DeleteChatQuestion">Delete this chat?</string>
<string name="SendMessagesTo">Send messages to %1$s?</string> <string name="SendMessagesTo">Send messages to %1$s?</string>
<string name="AreYouSureLogout">Are you sure you want to logout?</string> <string name="AreYouSureLogout">Are you sure you want to log out?</string>
<string name="AreYouSureSessions">Are you sure you want to terminate all other sessions?</string> <string name="AreYouSureSessions">Are you sure you want to terminate all other sessions?</string>
<string name="AreYouSureDeleteAndExit">Are you sure you want to delete and leave group?</string> <string name="AreYouSureDeleteAndExit">Are you sure you want to delete and leave the group?</string>
<string name="AreYouSureDeleteThisChat">Are you sure you want to delete this chat?</string> <string name="AreYouSureDeleteThisChat">Are you sure you want to delete this chat?</string>
<string name="AreYouSureShareMyContactInfo">Are you sure that you want to share your contact info?</string> <string name="AreYouSureShareMyContactInfo">Are you sure you want to share your contact info?</string>
<string name="AreYouSureBlockContact">Are you sure you want to block this contact?</string> <string name="AreYouSureBlockContact">Are you sure you want to block this contact?</string>
<string name="AreYouSureUnblockContact">Are you sure you want to unblock this contact?</string> <string name="AreYouSureUnblockContact">Are you sure you want to unblock this contact?</string>
<string name="AreYouSureDeleteContact">Are you sure you want to delete this contact?</string> <string name="AreYouSureDeleteContact">Are you sure you want to delete this contact?</string>
<string name="AreYouSureSecretChat">Are you sure you want to start secret chat?</string> <string name="AreYouSureSecretChat">Are you sure you want to start a secret chat?</string>
<string name="ForwardFromMyName">forward from my name</string> <string name="ForwardFromMyName">forward from my name</string>
<!--Intro view--> <!--Intro view-->
......
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