Commit 3eed85a3 authored by DrKLO's avatar DrKLO

Video editing and compression on 4.1+ (please test it and send debug info to...

Video editing and compression on 4.1+ (please test it and send debug info to me), Tablet version, a lot of other things (don't upload to markets, it's unstable)
parent 8d412f9e
...@@ -80,7 +80,7 @@ android { ...@@ -80,7 +80,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 326 versionCode 327
versionName "1.8.3" versionName "1.9.0"
} }
} }
...@@ -3,12 +3,12 @@ LOCAL_PATH := $(call my-dir) ...@@ -3,12 +3,12 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages LOCAL_MODULE := tmessages
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOG_DISABLED LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
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_LDLIBS := -ljnigraphics -llog
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
./opus/src/opus.c \ ./opus/src/opus.c \
...@@ -227,6 +227,46 @@ LOCAL_SRC_FILES += \ ...@@ -227,6 +227,46 @@ LOCAL_SRC_FILES += \
./libjpeg/jquant2.c \ ./libjpeg/jquant2.c \
./libjpeg/jutils.c ./libjpeg/jutils.c
LOCAL_SRC_FILES += \
./libyuv/source/compare_common.cc \
./libyuv/source/compare_neon.cc \
./libyuv/source/compare_posix.cc \
./libyuv/source/compare_win.cc \
./libyuv/source/compare.cc \
./libyuv/source/convert_argb.cc \
./libyuv/source/convert_from_argb.cc \
./libyuv/source/convert_from.cc \
./libyuv/source/convert_jpeg.cc \
./libyuv/source/convert_to_argb.cc \
./libyuv/source/convert_to_i420.cc \
./libyuv/source/convert.cc \
./libyuv/source/cpu_id.cc \
./libyuv/source/format_conversion.cc \
./libyuv/source/mjpeg_decoder.cc \
./libyuv/source/mjpeg_validate.cc \
./libyuv/source/planar_functions.cc \
./libyuv/source/rotate_argb.cc \
./libyuv/source/rotate_mips.cc \
./libyuv/source/rotate_neon.cc \
./libyuv/source/rotate_neon64.cc \
./libyuv/source/rotate.cc \
./libyuv/source/row_any.cc \
./libyuv/source/row_common.cc \
./libyuv/source/row_mips.cc \
./libyuv/source/row_neon.cc \
./libyuv/source/row_neon64.cc \
./libyuv/source/row_posix.cc \
./libyuv/source/row_win.cc \
./libyuv/source/scale_argb.cc \
./libyuv/source/scale_common.cc \
./libyuv/source/scale_mips.cc \
./libyuv/source/scale_neon.cc \
./libyuv/source/scale_neon64.cc \
./libyuv/source/scale_posix.cc \
./libyuv/source/scale_win.cc \
./libyuv/source/scale.cc \
./libyuv/source/video_common.cc
LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \
./jni.c \ ./jni.c \
./sqlite_cursor.c \ ./sqlite_cursor.c \
...@@ -237,6 +277,7 @@ LOCAL_SRC_FILES += \ ...@@ -237,6 +277,7 @@ LOCAL_SRC_FILES += \
./gif.c \ ./gif.c \
./utils.c \ ./utils.c \
./image.c \ ./image.c \
./video.c \
./fake.c ./fake.c
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <android/log.h> #include <android/log.h>
#include <jni.h> #include <jni.h>
#define LOG_TAG "tmessages_native" #define LOG_TAG "tmessages"
#ifndef LOG_DISABLED #ifndef LOG_DISABLED
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
......
#include <jni.h>
#include <libyuv.h>
#include <utils.h>
enum COLOR_FORMATTYPE {
COLOR_FormatMonochrome = 1,
COLOR_Format8bitRGB332 = 2,
COLOR_Format12bitRGB444 = 3,
COLOR_Format16bitARGB4444 = 4,
COLOR_Format16bitARGB1555 = 5,
COLOR_Format16bitRGB565 = 6,
COLOR_Format16bitBGR565 = 7,
COLOR_Format18bitRGB666 = 8,
COLOR_Format18bitARGB1665 = 9,
COLOR_Format19bitARGB1666 = 10,
COLOR_Format24bitRGB888 = 11,
COLOR_Format24bitBGR888 = 12,
COLOR_Format24bitARGB1887 = 13,
COLOR_Format25bitARGB1888 = 14,
COLOR_Format32bitBGRA8888 = 15,
COLOR_Format32bitARGB8888 = 16,
COLOR_FormatYUV411Planar = 17,
COLOR_FormatYUV411PackedPlanar = 18,
COLOR_FormatYUV420Planar = 19,
COLOR_FormatYUV420PackedPlanar = 20,
COLOR_FormatYUV420SemiPlanar = 21,
COLOR_FormatYUV422Planar = 22,
COLOR_FormatYUV422PackedPlanar = 23,
COLOR_FormatYUV422SemiPlanar = 24,
COLOR_FormatYCbYCr = 25,
COLOR_FormatYCrYCb = 26,
COLOR_FormatCbYCrY = 27,
COLOR_FormatCrYCbY = 28,
COLOR_FormatYUV444Interleaved = 29,
COLOR_FormatRawBayer8bit = 30,
COLOR_FormatRawBayer10bit = 31,
COLOR_FormatRawBayer8bitcompressed = 32,
COLOR_FormatL2 = 33,
COLOR_FormatL4 = 34,
COLOR_FormatL8 = 35,
COLOR_FormatL16 = 36,
COLOR_FormatL24 = 37,
COLOR_FormatL32 = 38,
COLOR_FormatYUV420PackedSemiPlanar = 39,
COLOR_FormatYUV422PackedSemiPlanar = 40,
COLOR_Format18BitBGR666 = 41,
COLOR_Format24BitARGB6666 = 42,
COLOR_Format24BitABGR6666 = 43,
COLOR_TI_FormatYUV420PackedSemiPlanar = 0x7f000100,
COLOR_FormatSurface = 0x7F000789,
COLOR_QCOM_FormatYUV420SemiPlanar = 0x7fa30c00
};
int isSemiPlanarYUV(int colorFormat) {
switch (colorFormat) {
case COLOR_FormatYUV420Planar:
case COLOR_FormatYUV420PackedPlanar:
return 0;
case COLOR_FormatYUV420SemiPlanar:
case COLOR_FormatYUV420PackedSemiPlanar:
case COLOR_TI_FormatYUV420PackedSemiPlanar:
return 1;
default:
return 0;
}
}
JNIEXPORT int Java_org_telegram_messenger_Utilities_convertVideoFrame(JNIEnv *env, jclass class, jobject src, jobject dest, int destFormat, int width, int height, int padding) {
if (!src || !dest || !destFormat) {
return 0;
}
jbyte *srcBuff = (*env)->GetDirectBufferAddress(env, src);
jbyte *destBuff = (*env)->GetDirectBufferAddress(env, dest);
int half_width = (width + 1) / 2;
int half_height = (height + 1) / 2;
if (!isSemiPlanarYUV(destFormat)) {
ARGBToI420(srcBuff, width * 4,
destBuff, width,
destBuff + width * height + half_width * half_height + padding * 5 / 4, half_width,
destBuff + width * height + padding, half_width,
width, height);
} else {
ARGBToNV21(srcBuff, width * 4,
destBuff, width,
destBuff + width * height + padding, half_width * 2,
width, height);
}
return 1;
}
...@@ -98,8 +98,7 @@ ...@@ -98,8 +98,7 @@
</activity> </activity>
<activity <activity
android:name="org.telegram.ui.IntroActivity" android:name="org.telegram.ui.IntroActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
android:screenOrientation="portrait">
</activity> </activity>
<activity <activity
android:name="org.telegram.ui.PopupNotificationActivity" android:name="org.telegram.ui.PopupNotificationActivity"
......
...@@ -23,10 +23,13 @@ import android.view.WindowManager; ...@@ -23,10 +23,13 @@ import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ApplicationLoader; import org.telegram.ui.ApplicationLoader;
import java.io.File; import java.io.File;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Locale;
public class AndroidUtilities { public class AndroidUtilities {
private static final Hashtable<String, Typeface> typefaceCache = new Hashtable<String, Typeface>(); private static final Hashtable<String, Typeface> typefaceCache = new Hashtable<String, Typeface>();
...@@ -39,13 +42,44 @@ public class AndroidUtilities { ...@@ -39,13 +42,44 @@ public class AndroidUtilities {
public static float density = 1; public static float density = 1;
public static Point displaySize = new Point(); public static Point displaySize = new Point();
public static int[] arrColors = {0xffee4928, 0xff41a903, 0xffe09602, 0xff0f94ed, 0xff8f3bf7, 0xfffc4380, 0xff00a1c4, 0xffeb7002};
public static int[] arrUsersAvatars = {
R.drawable.user_red,
R.drawable.user_green,
R.drawable.user_yellow,
R.drawable.user_blue,
R.drawable.user_violet,
R.drawable.user_pink,
R.drawable.user_aqua,
R.drawable.user_orange};
public static int[] arrGroupsAvatars = {
R.drawable.group_red,
R.drawable.group_green,
R.drawable.group_yellow,
R.drawable.group_blue,
R.drawable.group_violet,
R.drawable.group_pink,
R.drawable.group_aqua,
R.drawable.group_orange};
public static int[] arrBroadcastAvatars = {
R.drawable.broadcast_red,
R.drawable.broadcast_green,
R.drawable.broadcast_yellow,
R.drawable.broadcast_blue,
R.drawable.broadcast_violet,
R.drawable.broadcast_pink,
R.drawable.broadcast_aqua,
R.drawable.broadcast_orange};
static { static {
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density; density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
checkDisplaySize(); checkDisplaySize();
} }
public static void lockOrientation(Activity activity) { public static void lockOrientation(Activity activity) {
if (prevOrientation != -10) { if (activity == null || prevOrientation != -10) {
return; return;
} }
try { try {
...@@ -103,6 +137,9 @@ public class AndroidUtilities { ...@@ -103,6 +137,9 @@ public class AndroidUtilities {
} }
public static void unlockOrientation(Activity activity) { public static void unlockOrientation(Activity activity) {
if (activity == null) {
return;
}
try { try {
if (prevOrientation != -10) { if (prevOrientation != -10) {
activity.setRequestedOrientation(prevOrientation); activity.setRequestedOrientation(prevOrientation);
...@@ -229,4 +266,60 @@ public class AndroidUtilities { ...@@ -229,4 +266,60 @@ public class AndroidUtilities {
public static void RunOnUIThread(Runnable runnable) { public static void RunOnUIThread(Runnable runnable) {
ApplicationLoader.applicationHandler.post(runnable); ApplicationLoader.applicationHandler.post(runnable);
} }
public static boolean isTablet() {
return (ApplicationLoader.applicationContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
public static int getColorIndex(int id) {
int[] arr;
if (id >= 0) {
arr = arrUsersAvatars;
} else {
arr = arrGroupsAvatars;
}
try {
String str;
if (id >= 0) {
str = String.format(Locale.US, "%d%d", id, UserConfig.getClientUserId());
} else {
str = String.format(Locale.US, "%d", id);
}
if (str.length() > 15) {
str = str.substring(0, 15);
}
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] digest = md.digest(str.getBytes());
int b = digest[Math.abs(id % 16)];
if (b < 0) {
b += 256;
}
return Math.abs(b) % arr.length;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return id % arr.length;
}
public static int getColorForId(int id) {
if (id / 1000 == 333) {
return 0xff0f94ed;
}
return arrColors[getColorIndex(id)];
}
public static int getUserAvatarForId(int id) {
if (id / 1000 == 333 || id / 1000 == 777) {
return R.drawable.telegram_avatar;
}
return arrUsersAvatars[getColorIndex(id)];
}
public static int getGroupAvatarForId(int id) {
return arrGroupsAvatars[getColorIndex(-Math.abs(id))];
}
public static int getBroadcastAvatarForId(int id) {
return arrBroadcastAvatars[getColorIndex(-Math.abs(id))];
}
} }
...@@ -17,6 +17,7 @@ import android.database.Cursor; ...@@ -17,6 +17,7 @@ import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.provider.Settings;
import android.util.SparseArray; import android.util.SparseArray;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
...@@ -48,6 +49,7 @@ public class ContactsController { ...@@ -48,6 +49,7 @@ public class ContactsController {
private boolean contactsBookLoaded = false; private boolean contactsBookLoaded = false;
private String lastContactsVersions = ""; private String lastContactsVersions = "";
private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>(); private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
public int nameDisplayOrder = 1;
public static class Contact { public static class Contact {
public int id; public int id;
...@@ -99,6 +101,14 @@ public class ContactsController { ...@@ -99,6 +101,14 @@ public class ContactsController {
return localInstance; return localInstance;
} }
public ContactsController() {
try {
nameDisplayOrder = Settings.System.getInt(ApplicationLoader.applicationContext.getContentResolver(), "android.contacts.DISPLAY_ORDER");
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
public void cleanup() { public void cleanup() {
contactsBook.clear(); contactsBook.clear();
contactsBookSPhones.clear(); contactsBookSPhones.clear();
...@@ -1465,7 +1475,7 @@ public class ContactsController { ...@@ -1465,7 +1475,7 @@ public class ContactsController {
MessagesStorage.getInstance().putContacts(arrayList, false); MessagesStorage.getInstance().putContacts(arrayList, false);
if (u.phone != null && u.phone.length() > 0) { if (u.phone != null && u.phone.length() > 0) {
String name = Utilities.formatName(u.first_name, u.last_name); String name = formatName(u.first_name, u.last_name);
MessagesStorage.getInstance().applyPhoneBookUpdates(u.phone, ""); MessagesStorage.getInstance().applyPhoneBookUpdates(u.phone, "");
Contact contact = contactsBookSPhones.get(u.phone); Contact contact = contactsBookSPhones.get(u.phone);
if (contact != null) { if (contact != null) {
...@@ -1529,7 +1539,7 @@ public class ContactsController { ...@@ -1529,7 +1539,7 @@ public class ContactsController {
for (TLRPC.User user : users) { for (TLRPC.User user : users) {
if (user.phone != null && user.phone.length() > 0) { if (user.phone != null && user.phone.length() > 0) {
String name = Utilities.formatName(user.first_name, user.last_name); String name = ContactsController.formatName(user.first_name, user.last_name);
MessagesStorage.getInstance().applyPhoneBookUpdates(user.phone, ""); MessagesStorage.getInstance().applyPhoneBookUpdates(user.phone, "");
Contact contact = contactsBookSPhones.get(user.phone); Contact contact = contactsBookSPhones.get(user.phone);
if (contact != null) { if (contact != null) {
...@@ -1563,4 +1573,24 @@ public class ContactsController { ...@@ -1563,4 +1573,24 @@ public class ContactsController {
} }
}, true, RPCRequest.RPCRequestClassGeneric); }, true, RPCRequest.RPCRequestClassGeneric);
} }
public static String formatName(String firstName, String lastName) {
String result = null;
if (ContactsController.getInstance().nameDisplayOrder == 1) {
result = firstName;
if (result == null || result.length() == 0) {
result = lastName;
} else if (result.length() != 0 && lastName != null && lastName.length() != 0) {
result += " " + lastName;
}
} else {
result = lastName;
if (result == null || result.length() == 0) {
result = firstName;
} else if (result.length() != 0 && firstName != null && firstName.length() != 0) {
result += " " + firstName;
}
}
return result.trim();
}
} }
...@@ -214,7 +214,11 @@ public class Emoji { ...@@ -214,7 +214,11 @@ public class Emoji {
emojiFullSize = 90; emojiFullSize = 90;
} }
drawImgSize = AndroidUtilities.dp(20); drawImgSize = AndroidUtilities.dp(20);
if (AndroidUtilities.isTablet()) {
bigImgSize = AndroidUtilities.dp(40);
} else {
bigImgSize = AndroidUtilities.dp(30); bigImgSize = AndroidUtilities.dp(30);
}
for (int j = 1; j < data.length; j++) { for (int j = 1; j < data.length; j++) {
for (int i = 0; i < data[j].length; i++) { for (int i = 0; i < data[j].length; i++) {
......
...@@ -143,7 +143,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -143,7 +143,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
maxGroupCount = preferences.getInt("maxGroupCount", 200); maxGroupCount = preferences.getInt("maxGroupCount", 200);
maxBroadcastCount = preferences.getInt("maxBroadcastCount", 100); maxBroadcastCount = preferences.getInt("maxBroadcastCount", 100);
fontSize = preferences.getInt("fons_size", 16); fontSize = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16);
} }
public void updateConfig(final TLRPC.TL_config config) { public void updateConfig(final TLRPC.TL_config config) {
...@@ -1175,7 +1175,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -1175,7 +1175,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (label.length() != 0) { if (label.length() != 0) {
label += ", "; label += ", ";
} }
label += Utilities.formatName(user.first_name, user.last_name); label += ContactsController.formatName(user.first_name, user.last_name);
count++; count++;
} }
if (count == 2) { if (count == 2) {
...@@ -3462,9 +3462,23 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -3462,9 +3462,23 @@ public class MessagesController implements NotificationCenter.NotificationCenter
changed = true; changed = true;
} }
} else { } else {
boolean change = false;
if (dialog.top_message > 0 && lastMessage.messageOwner.id > 0 && lastMessage.messageOwner.id > dialog.top_message || if (dialog.top_message > 0 && lastMessage.messageOwner.id > 0 && lastMessage.messageOwner.id > dialog.top_message ||
dialog.top_message < 0 && lastMessage.messageOwner.id < 0 && lastMessage.messageOwner.id < dialog.top_message || dialog.top_message < 0 && lastMessage.messageOwner.id < 0 && lastMessage.messageOwner.id < dialog.top_message) {
dialog.last_message_date < lastMessage.messageOwner.date) { change = true;
} else {
MessageObject currentDialogMessage = dialogMessage.get(dialog.top_message);
if (currentDialogMessage != null) {
if (currentDialogMessage.messageOwner.send_state == MessageObject.MESSAGE_SEND_STATE_SENDING && lastMessage.messageOwner.send_state == MessageObject.MESSAGE_SEND_STATE_SENDING) {
change = true;
} else if (dialog.last_message_date < lastMessage.messageOwner.date || dialog.last_message_date == lastMessage.messageOwner.date && lastMessage.messageOwner.send_state == MessageObject.MESSAGE_SEND_STATE_SENDING) {
change = true;
}
} else {
change = true;
}
}
if (change) {
dialogMessage.remove(dialog.top_message); dialogMessage.remove(dialog.top_message);
dialog.top_message = lastMessage.messageOwner.id; dialog.top_message = lastMessage.messageOwner.id;
if (!isBroadcast) { if (!isBroadcast) {
......
...@@ -1253,7 +1253,7 @@ public class MessagesStorage { ...@@ -1253,7 +1253,7 @@ public class MessagesStorage {
if (user.status != null) { if (user.status != null) {
user.status.expires = cursor.intValue(7); user.status.expires = cursor.intValue(7);
} }
resultArrayNames.add(Html.fromHtml("<font color=\"#00a60e\">" + Utilities.formatName(user.first_name, user.last_name) + "</font>")); resultArrayNames.add(Html.fromHtml("<font color=\"#00a60e\">" + ContactsController.formatName(user.first_name, user.last_name) + "</font>"));
resultArray.add(chat); resultArray.add(chat);
encUsers.add(user); encUsers.add(user);
} }
......
...@@ -24,9 +24,9 @@ import java.util.zip.ZipFile; ...@@ -24,9 +24,9 @@ import java.util.zip.ZipFile;
public class NativeLoader { public class NativeLoader {
private static final long sizes[] = new long[] { private static final long sizes[] = new long[] {
811664, //armeabi 946908, //armeabi
864932, //armeabi-v7a 1028848, //armeabi-v7a
1262644, //x86 1603780, //x86
0, //mips 0, //mips
}; };
......
...@@ -38,6 +38,7 @@ public class NotificationCenter { ...@@ -38,6 +38,7 @@ public class NotificationCenter {
public static final int notificationsSettingsUpdated = 26; public static final int notificationsSettingsUpdated = 26;
public static final int pushMessagesUpdated = 27; public static final int pushMessagesUpdated = 27;
public static final int blockedUsersDidLoaded = 28; public static final int blockedUsersDidLoaded = 28;
public static final int openedChatChanged = 29;
public static final int wallpapersDidLoaded = 171; public static final int wallpapersDidLoaded = 171;
public static final int closeOtherAppActivities = 702; public static final int closeOtherAppActivities = 702;
...@@ -67,7 +68,7 @@ public class NotificationCenter { ...@@ -67,7 +68,7 @@ public class NotificationCenter {
final private HashMap<Integer, Object> removeAfterBroadcast = new HashMap<Integer, Object>(); final private HashMap<Integer, Object> removeAfterBroadcast = new HashMap<Integer, Object>();
final private HashMap<Integer, Object> addAfterBroadcast = new HashMap<Integer, Object>(); final private HashMap<Integer, Object> addAfterBroadcast = new HashMap<Integer, Object>();
private boolean broadcasting = false; private int broadcasting = 0;
private static volatile NotificationCenter Instance = null; private static volatile NotificationCenter Instance = null;
public static NotificationCenter getInstance() { public static NotificationCenter getInstance() {
...@@ -89,14 +90,15 @@ public class NotificationCenter { ...@@ -89,14 +90,15 @@ public class NotificationCenter {
public void postNotificationName(int id, Object... args) { public void postNotificationName(int id, Object... args) {
synchronized (observers) { synchronized (observers) {
broadcasting = true; broadcasting++;
ArrayList<Object> objects = observers.get(id); ArrayList<Object> objects = observers.get(id);
if (objects != null) { if (objects != null) {
for (Object obj : objects) { for (Object obj : objects) {
((NotificationCenterDelegate)obj).didReceivedNotification(id, args); ((NotificationCenterDelegate)obj).didReceivedNotification(id, args);
} }
} }
broadcasting = false; broadcasting--;
if (broadcasting == 0) {
if (!removeAfterBroadcast.isEmpty()) { if (!removeAfterBroadcast.isEmpty()) {
for (HashMap.Entry<Integer, Object> entry : removeAfterBroadcast.entrySet()) { for (HashMap.Entry<Integer, Object> entry : removeAfterBroadcast.entrySet()) {
removeObserver(entry.getValue(), entry.getKey()); removeObserver(entry.getValue(), entry.getKey());
...@@ -111,10 +113,11 @@ public class NotificationCenter { ...@@ -111,10 +113,11 @@ public class NotificationCenter {
} }
} }
} }
}
public void addObserver(Object observer, int id) { public void addObserver(Object observer, int id) {
synchronized (observers) { synchronized (observers) {
if (broadcasting) { if (broadcasting != 0) {
addAfterBroadcast.put(id, observer); addAfterBroadcast.put(id, observer);
return; return;
} }
...@@ -131,7 +134,7 @@ public class NotificationCenter { ...@@ -131,7 +134,7 @@ public class NotificationCenter {
public void removeObserver(Object observer, int id) { public void removeObserver(Object observer, int id) {
synchronized (observers) { synchronized (observers) {
if (broadcasting) { if (broadcasting != 0) {
removeAfterBroadcast.put(id, observer); removeAfterBroadcast.put(id, observer);
return; return;
} }
......
...@@ -28,6 +28,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -28,6 +28,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
private TLRPC.ChatParticipants currentChatInfo = null; private TLRPC.ChatParticipants currentChatInfo = null;
private HashMap<String, ArrayList<DelayedMessage>> delayedMessages = new HashMap<String, ArrayList<DelayedMessage>>(); private HashMap<String, ArrayList<DelayedMessage>> delayedMessages = new HashMap<String, ArrayList<DelayedMessage>>();
private HashMap<Integer, MessageObject> unsentMessages = new HashMap<Integer, MessageObject>();
private class DelayedMessage { private class DelayedMessage {
public TLObject sendRequest; public TLObject sendRequest;
...@@ -153,6 +154,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -153,6 +154,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
arr.remove(a); arr.remove(a);
a--; a--;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, obj.obj.messageOwner.id); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, obj.obj.messageOwner.id);
processSentMessage(obj.obj.messageOwner.id);
} }
} }
if (arr.isEmpty()) { if (arr.isEmpty()) {
...@@ -191,14 +193,25 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -191,14 +193,25 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
MessagesController.getInstance().deleteMessages(messages, null, null); MessagesController.getInstance().deleteMessages(messages, null, null);
} }
public boolean retrySendMessage(MessageObject messageObject) { public boolean retrySendMessage(MessageObject messageObject, boolean unsent) {
if (messageObject.messageOwner.id >= 0) { if (messageObject.messageOwner.id >= 0) {
return false; return false;
} }
if (unsent) {
unsentMessages.put(messageObject.messageOwner.id, messageObject);
}
sendMessage(messageObject); sendMessage(messageObject);
return true; return true;
} }
private void processSentMessage(int id) {
int prevSize = unsentMessages.size();
unsentMessages.remove(id);
if (prevSize != 0 && unsentMessages.size() == 0) {
checkUnsentMessages();
}
}
public void processForwardFromMyName(MessageObject messageObject, long did) { public void processForwardFromMyName(MessageObject messageObject, long did) {
if (messageObject == null) { if (messageObject == null) {
return; return;
...@@ -271,7 +284,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -271,7 +284,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
private void sendMessage(String message, double lat, double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry) { private void sendMessage(String message, double lat, double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry) {
TLRPC.Message newMsg = null; TLRPC.Message newMsg = null;
int type = -1; int type = -1;
if (retry) { if (retry) {
...@@ -394,12 +406,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -394,12 +406,12 @@ 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.out = true; newMsg.out = true;
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
} }
if (newMsg.random_id == 0) { if (newMsg.random_id == 0) {
newMsg.random_id = getNextRandomId(); newMsg.random_id = getNextRandomId();
} }
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
newMsg.unread = true; newMsg.unread = true;
newMsg.dialog_id = peer; newMsg.dialog_id = peer;
int lower_id = (int) peer; int lower_id = (int) peer;
...@@ -410,6 +422,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -410,6 +422,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (lower_id != 0) { if (lower_id != 0) {
if (high_id == 1) { if (high_id == 1) {
if (currentChatInfo == null) { if (currentChatInfo == null) {
processSentMessage(newMsg.id);
return; return;
} }
sendToPeers = new ArrayList<TLRPC.InputUser>(); sendToPeers = new ArrayList<TLRPC.InputUser>();
...@@ -434,6 +447,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -434,6 +447,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id); TLRPC.User sendToUser = MessagesController.getInstance().getUser(lower_id);
if (sendToUser == null) { if (sendToUser == null) {
processSentMessage(newMsg.id);
return; return;
} }
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) { if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
...@@ -767,6 +781,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -767,6 +781,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.messageOwner.id); MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.messageOwner.id);
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
processSentMessage(newMsgObj.messageOwner.id);
} }
} }
...@@ -855,11 +870,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -855,11 +870,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast; final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast;
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<TLRPC.Message>(); final ArrayList<TLRPC.Message> sentMessages = new ArrayList<TLRPC.Message>();
if (response instanceof TLRPC.TL_messages_sentMessage) { if (response instanceof TLRPC.messages_SentMessage) {
TLRPC.TL_messages_sentMessage res = (TLRPC.TL_messages_sentMessage) response; TLRPC.TL_messages_sentMessage res = (TLRPC.TL_messages_sentMessage) response;
newMsgObj.messageOwner.id = res.id; newMsgObj.messageOwner.id = res.id;
newMsgObj.messageOwner.date = res.date; newMsgObj.messageOwner.date = res.date;
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.date); MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.date);
//TODO link check
} else if (response instanceof TLRPC.messages_StatedMessage) { } else if (response instanceof TLRPC.messages_StatedMessage) {
TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response; TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
sentMessages.add(res.message); sentMessages.add(res.message);
...@@ -903,6 +919,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -903,6 +919,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
} }
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.messageOwner.id), newMsgObj); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.messageOwner.id), newMsgObj);
processSentMessage(oldId);
} }
}); });
} }
...@@ -914,6 +931,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -914,6 +931,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
public void run() { public void run() {
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
processSentMessage(newMsgObj.messageOwner.id);
} }
}); });
} }
...@@ -1009,6 +1027,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1009,6 +1027,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
public void run() { public void run() {
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.messageOwner.id, newMsgObj.messageOwner.id, newMsgObj); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.messageOwner.id, newMsgObj.messageOwner.id, newMsgObj);
processSentMessage(newMsgObj.messageOwner.id);
} }
}); });
} }
...@@ -1020,6 +1039,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1020,6 +1039,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
public void run() { public void run() {
newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; newMsgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.messageOwner.id);
processSentMessage(newMsgObj.messageOwner.id);
} }
}); });
} }
...@@ -1370,7 +1390,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ...@@ -1370,7 +1390,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
MessagesController.getInstance().putEncryptedChats(encryptedChats, true); MessagesController.getInstance().putEncryptedChats(encryptedChats, true);
for (TLRPC.Message message : messages) { for (TLRPC.Message message : messages) {
MessageObject messageObject = new MessageObject(message, null, 0); MessageObject messageObject = new MessageObject(message, null, 0);
retrySendMessage(messageObject); retrySendMessage(messageObject, true);
} }
} }
}); });
......
...@@ -87,7 +87,7 @@ public class MP4Builder { ...@@ -87,7 +87,7 @@ public class MP4Builder {
fos.flush(); fos.flush();
} }
public void writeSampleData(int trackIndex, ByteBuffer byteBuf, MediaCodec.BufferInfo bufferInfo) throws Exception { public boolean writeSampleData(int trackIndex, ByteBuffer byteBuf, MediaCodec.BufferInfo bufferInfo) throws Exception {
if (writeNewMdat) { if (writeNewMdat) {
mdat.setContentSize(0); mdat.setContentSize(0);
mdat.getBox(fc); mdat.getBox(fc);
...@@ -111,16 +111,18 @@ public class MP4Builder { ...@@ -111,16 +111,18 @@ public class MP4Builder {
currentMp4Movie.addSample(trackIndex, dataOffset, bufferInfo); currentMp4Movie.addSample(trackIndex, dataOffset, bufferInfo);
byteBuf.position(bufferInfo.offset); byteBuf.position(bufferInfo.offset);
byteBuf.limit(bufferInfo.offset + bufferInfo.size); byteBuf.limit(bufferInfo.offset + bufferInfo.size);
fc.write(byteBuf); fc.write(byteBuf);
dataOffset += bufferInfo.size; dataOffset += bufferInfo.size;
if (flush) { if (flush) {
fos.flush(); fos.flush();
} }
return flush;
} }
public int addTrack(MediaFormat mediaFormat, boolean isVideo) throws Exception { public int addTrack(MediaFormat mediaFormat, boolean isAudio) throws Exception {
return currentMp4Movie.addTrack(mediaFormat, isVideo); return currentMp4Movie.addTrack(mediaFormat, isAudio);
} }
public void finishMovie(boolean error) throws Exception { public void finishMovie(boolean error) throws Exception {
......
...@@ -74,8 +74,8 @@ public class Mp4Movie { ...@@ -74,8 +74,8 @@ public class Mp4Movie {
track.addSample(offset, bufferInfo); track.addSample(offset, bufferInfo);
} }
public int addTrack(MediaFormat mediaFormat, boolean isVideo) throws Exception { public int addTrack(MediaFormat mediaFormat, boolean isAudio) throws Exception {
tracks.add(new Track(tracks.size(), mediaFormat, isVideo)); tracks.add(new Track(tracks.size(), mediaFormat, isAudio));
return tracks.size() - 1; return tracks.size() - 1;
} }
} }
...@@ -18,32 +18,44 @@ package org.telegram.android.video; ...@@ -18,32 +18,44 @@ package org.telegram.android.video;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.opengl.EGL14; import android.opengl.GLES20;
import android.view.Surface; import android.view.Surface;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface; import javax.microedition.khronos.egl.EGLSurface;
@TargetApi(17) @TargetApi(16)
public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener { public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
private static final int EGL_OPENGL_ES2_BIT = 4; private static final int EGL_OPENGL_ES2_BIT = 4;
private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
private EGL10 mEGL; private EGL10 mEGL;
private EGLDisplay mEGLDisplay; private EGLDisplay mEGLDisplay = null;
private EGLContext mEGLContext; private EGLContext mEGLContext = null;
private EGLSurface mEGLSurface; private EGLSurface mEGLSurface = null;
private SurfaceTexture mSurfaceTexture; private SurfaceTexture mSurfaceTexture;
private Surface mSurface; private Surface mSurface;
private final Object mFrameSyncObject = new Object(); private final Object mFrameSyncObject = new Object();
private boolean mFrameAvailable; private boolean mFrameAvailable;
private TextureRenderer mTextureRender; private TextureRenderer mTextureRender;
private int mWidth;
private int mHeight;
private ByteBuffer mPixelBuf;
public OutputSurface(int width, int height) { public OutputSurface(int width, int height) {
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
mWidth = width;
mHeight = height;
mPixelBuf = ByteBuffer.allocateDirect(mWidth * mHeight * 4);
mPixelBuf.order(ByteOrder.LITTLE_ENDIAN);
eglSetup(width, height); eglSetup(width, height);
makeCurrent(); makeCurrent();
setup(); setup();
...@@ -64,28 +76,35 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener { ...@@ -64,28 +76,35 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
private void eglSetup(int width, int height) { private void eglSetup(int width, int height) {
mEGL = (EGL10) EGLContext.getEGL(); mEGL = (EGL10) EGLContext.getEGL();
mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
throw new RuntimeException("unable to get EGL10 display");
}
if (!mEGL.eglInitialize(mEGLDisplay, null)) { if (!mEGL.eglInitialize(mEGLDisplay, null)) {
mEGLDisplay = null;
throw new RuntimeException("unable to initialize EGL10"); throw new RuntimeException("unable to initialize EGL10");
} }
int[] attribList = { int[] attribList = {
EGL10.EGL_RED_SIZE, 8, EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_NONE EGL10.EGL_NONE
}; };
EGLConfig[] configs = new EGLConfig[1]; EGLConfig[] configs = new EGLConfig[1];
int[] numConfigs = new int[1]; int[] numConfigs = new int[1];
if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, 1, numConfigs)) { if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) {
throw new RuntimeException("unable to find RGB888+pbuffer EGL config"); throw new RuntimeException("unable to find RGB888+pbuffer EGL config");
} }
int[] attrib_list = { int[] attrib_list = {
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE EGL10.EGL_NONE
}; };
mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, attrib_list);
attrib_list);
checkEglError("eglCreateContext"); checkEglError("eglCreateContext");
if (mEGLContext == null) { if (mEGLContext == null) {
throw new RuntimeException("null context"); throw new RuntimeException("null context");
...@@ -139,7 +158,7 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener { ...@@ -139,7 +158,7 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
} }
public void awaitNewImage() { public void awaitNewImage() {
final int TIMEOUT_MS = 500; final int TIMEOUT_MS = 2500;
synchronized (mFrameSyncObject) { synchronized (mFrameSyncObject) {
while (!mFrameAvailable) { while (!mFrameAvailable) {
try { try {
...@@ -157,8 +176,8 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener { ...@@ -157,8 +176,8 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
mSurfaceTexture.updateTexImage(); mSurfaceTexture.updateTexImage();
} }
public void drawImage() { public void drawImage(boolean invert) {
mTextureRender.drawFrame(mSurfaceTexture); mTextureRender.drawFrame(mSurfaceTexture, invert);
} }
@Override @Override
...@@ -172,6 +191,12 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener { ...@@ -172,6 +191,12 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
} }
} }
public ByteBuffer getFrame() {
mPixelBuf.rewind();
GLES20.glReadPixels(0, 0, mWidth, mHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, mPixelBuf);
return mPixelBuf;
}
private void checkEglError(String msg) { private void checkEglError(String msg) {
if (mEGL.eglGetError() != EGL10.EGL_SUCCESS) { if (mEGL.eglGetError() != EGL10.EGL_SUCCESS) {
throw new RuntimeException("EGL error encountered (see log)"); throw new RuntimeException("EGL error encountered (see log)");
......
...@@ -26,20 +26,21 @@ import android.opengl.GLES11Ext; ...@@ -26,20 +26,21 @@ import android.opengl.GLES11Ext;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.Matrix; import android.opengl.Matrix;
@TargetApi(17) @TargetApi(16)
public class TextureRenderer { public class TextureRenderer {
private static final int FLOAT_SIZE_BYTES = 4; private static final int FLOAT_SIZE_BYTES = 4;
private static final int TRIANGLE_VERTICES_DATA_STRIDE_BYTES = 5 * FLOAT_SIZE_BYTES; private static final int TRIANGLE_VERTICES_DATA_STRIDE_BYTES = 5 * FLOAT_SIZE_BYTES;
private static final int TRIANGLE_VERTICES_DATA_POS_OFFSET = 0; private static final int TRIANGLE_VERTICES_DATA_POS_OFFSET = 0;
private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3; private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3;
private static final float[] mTriangleVerticesData = { private static final float[] mTriangleVerticesData = {
// X, Y, Z, U, V
-1.0f, -1.0f, 0, 0.f, 0.f, -1.0f, -1.0f, 0, 0.f, 0.f,
1.0f, -1.0f, 0, 1.f, 0.f, 1.0f, -1.0f, 0, 1.f, 0.f,
-1.0f, 1.0f, 0, 0.f, 1.f, -1.0f, 1.0f, 0, 0.f, 1.f,
1.0f, 1.0f, 0, 1.f, 1.f, 1.0f, 1.0f, 0, 1.f, 1.f,
}; };
private FloatBuffer mTriangleVertices; private FloatBuffer mTriangleVertices;
private static final String VERTEX_SHADER = private static final String VERTEX_SHADER =
"uniform mat4 uMVPMatrix;\n" + "uniform mat4 uMVPMatrix;\n" +
"uniform mat4 uSTMatrix;\n" + "uniform mat4 uSTMatrix;\n" +
...@@ -50,14 +51,16 @@ public class TextureRenderer { ...@@ -50,14 +51,16 @@ public class TextureRenderer {
" gl_Position = uMVPMatrix * aPosition;\n" + " gl_Position = uMVPMatrix * aPosition;\n" +
" vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" + " vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" +
"}\n"; "}\n";
private static final String FRAGMENT_SHADER = private static final String FRAGMENT_SHADER =
"#extension GL_OES_EGL_image_external : require\n" + "#extension GL_OES_EGL_image_external : require\n" +
"precision mediump float;\n" + // highp here doesn't seem to matter "precision mediump float;\n" +
"varying vec2 vTextureCoord;\n" + "varying vec2 vTextureCoord;\n" +
"uniform samplerExternalOES sTexture;\n" + "uniform samplerExternalOES sTexture;\n" +
"void main() {\n" + "void main() {\n" +
" gl_FragColor = texture2D(sTexture, vTextureCoord);\n" + " gl_FragColor = texture2D(sTexture, vTextureCoord);\n" +
"}\n"; "}\n";
private float[] mMVPMatrix = new float[16]; private float[] mMVPMatrix = new float[16];
private float[] mSTMatrix = new float[16]; private float[] mSTMatrix = new float[16];
private int mProgram; private int mProgram;
...@@ -77,11 +80,15 @@ public class TextureRenderer { ...@@ -77,11 +80,15 @@ public class TextureRenderer {
return mTextureID; return mTextureID;
} }
public void drawFrame(SurfaceTexture st) { public void drawFrame(SurfaceTexture st, boolean invert) {
checkGlError("onDrawFrame start"); checkGlError("onDrawFrame start");
st.getTransformMatrix(mSTMatrix); st.getTransformMatrix(mSTMatrix);
GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); if (invert) {
mSTMatrix[5] = -mSTMatrix[5];
mSTMatrix[13] = 1.0f - mSTMatrix[13];
}
GLES20.glUseProgram(mProgram); GLES20.glUseProgram(mProgram);
checkGlError("glUseProgram"); checkGlError("glUseProgram");
GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
...@@ -96,9 +103,8 @@ public class TextureRenderer { ...@@ -96,9 +103,8 @@ public class TextureRenderer {
checkGlError("glVertexAttribPointer maTextureHandle"); checkGlError("glVertexAttribPointer maTextureHandle");
GLES20.glEnableVertexAttribArray(maTextureHandle); GLES20.glEnableVertexAttribArray(maTextureHandle);
checkGlError("glEnableVertexAttribArray maTextureHandle"); checkGlError("glEnableVertexAttribArray maTextureHandle");
Matrix.setIdentityM(mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0); GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
checkGlError("glDrawArrays"); checkGlError("glDrawArrays");
GLES20.glFinish(); GLES20.glFinish();
...@@ -139,6 +145,8 @@ public class TextureRenderer { ...@@ -139,6 +145,8 @@ public class TextureRenderer {
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
checkGlError("glTexParameter"); checkGlError("glTexParameter");
Matrix.setIdentityM(mMVPMatrix, 0);
} }
public void changeFragmentShader(String fragmentShader) { public void changeFragmentShader(String fragmentShader) {
......
...@@ -67,9 +67,9 @@ public class Track { ...@@ -67,9 +67,9 @@ public class Track {
samplingFrequencyIndexMap.put(8000, 0xb); samplingFrequencyIndexMap.put(8000, 0xb);
} }
public Track(int id, MediaFormat format, boolean isVideo) throws Exception { public Track(int id, MediaFormat format, boolean isAudio) throws Exception {
trackId = id; trackId = id;
if (isVideo) { if (!isAudio) {
sampleDurations.add((long)3015); sampleDurations.add((long)3015);
duration = 3015; duration = 3015;
width = format.getInteger(MediaFormat.KEY_WIDTH); width = format.getInteger(MediaFormat.KEY_WIDTH);
...@@ -79,6 +79,8 @@ public class Track { ...@@ -79,6 +79,8 @@ public class Track {
handler = "vide"; handler = "vide";
headerBox = new VideoMediaHeaderBox(); headerBox = new VideoMediaHeaderBox();
sampleDescriptionBox = new SampleDescriptionBox(); sampleDescriptionBox = new SampleDescriptionBox();
String mime = format.getString(MediaFormat.KEY_MIME);
if (mime.equals("video/avc")) {
VisualSampleEntry visualSampleEntry = new VisualSampleEntry("avc1"); VisualSampleEntry visualSampleEntry = new VisualSampleEntry("avc1");
visualSampleEntry.setDataReferenceIndex(1); visualSampleEntry.setDataReferenceIndex(1);
visualSampleEntry.setDepth(24); visualSampleEntry.setDepth(24);
...@@ -90,6 +92,7 @@ public class Track { ...@@ -90,6 +92,7 @@ public class Track {
AvcConfigurationBox avcConfigurationBox = new AvcConfigurationBox(); AvcConfigurationBox avcConfigurationBox = new AvcConfigurationBox();
if (format.getByteBuffer("csd-0") != null) {
ArrayList<byte[]> spsArray = new ArrayList<byte[]>(); ArrayList<byte[]> spsArray = new ArrayList<byte[]>();
ByteBuffer spsBuff = format.getByteBuffer("csd-0"); ByteBuffer spsBuff = format.getByteBuffer("csd-0");
spsBuff.position(4); spsBuff.position(4);
...@@ -103,11 +106,12 @@ public class Track { ...@@ -103,11 +106,12 @@ public class Track {
byte[] ppsBytes = new byte[ppsBuff.remaining()]; byte[] ppsBytes = new byte[ppsBuff.remaining()];
ppsBuff.get(ppsBytes); ppsBuff.get(ppsBytes);
ppsArray.add(ppsBytes); ppsArray.add(ppsBytes);
avcConfigurationBox.setSequenceParameterSets(spsArray);
avcConfigurationBox.setPictureParameterSets(ppsArray);
}
//ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(spsBytes); //ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(spsBytes);
//SeqParameterSet seqParameterSet = SeqParameterSet.read(byteArrayInputStream); //SeqParameterSet seqParameterSet = SeqParameterSet.read(byteArrayInputStream);
avcConfigurationBox.setSequenceParameterSets(spsArray);
avcConfigurationBox.setPictureParameterSets(ppsArray);
avcConfigurationBox.setAvcLevelIndication(13); avcConfigurationBox.setAvcLevelIndication(13);
avcConfigurationBox.setAvcProfileIndication(100); avcConfigurationBox.setAvcProfileIndication(100);
avcConfigurationBox.setBitDepthLumaMinus8(-1); avcConfigurationBox.setBitDepthLumaMinus8(-1);
...@@ -119,6 +123,18 @@ public class Track { ...@@ -119,6 +123,18 @@ public class Track {
visualSampleEntry.addBox(avcConfigurationBox); visualSampleEntry.addBox(avcConfigurationBox);
sampleDescriptionBox.addBox(visualSampleEntry); sampleDescriptionBox.addBox(visualSampleEntry);
} else if (mime.equals("video/mp4v")) {
VisualSampleEntry visualSampleEntry = new VisualSampleEntry("mp4v");
visualSampleEntry.setDataReferenceIndex(1);
visualSampleEntry.setDepth(24);
visualSampleEntry.setFrameCount(1);
visualSampleEntry.setHorizresolution(72);
visualSampleEntry.setVertresolution(72);
visualSampleEntry.setWidth(width);
visualSampleEntry.setHeight(height);
sampleDescriptionBox.addBox(visualSampleEntry);
}
} else { } else {
sampleDurations.add((long)1024); sampleDurations.add((long)1024);
duration = 1024; duration = 1024;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
package org.telegram.messenger; package org.telegram.messenger;
import java.io.File; import java.io.File;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
...@@ -37,6 +38,7 @@ public class FileLoader { ...@@ -37,6 +38,7 @@ public class FileLoader {
private ConcurrentHashMap<String, FileUploadOperation> uploadOperationPathsEnc = new ConcurrentHashMap<String, FileUploadOperation>(); private ConcurrentHashMap<String, FileUploadOperation> uploadOperationPathsEnc = new ConcurrentHashMap<String, FileUploadOperation>();
private ConcurrentHashMap<String, FileLoadOperation> loadOperationPaths = new ConcurrentHashMap<String, FileLoadOperation>(); private ConcurrentHashMap<String, FileLoadOperation> loadOperationPaths = new ConcurrentHashMap<String, FileLoadOperation>();
private ConcurrentHashMap<String, Float> fileProgresses = new ConcurrentHashMap<String, Float>(); private ConcurrentHashMap<String, Float> fileProgresses = new ConcurrentHashMap<String, Float>();
private HashMap<String, Long> uploadSizes = new HashMap<String, Long>();
private FileLoaderDelegate delegate = null; private FileLoaderDelegate delegate = null;
...@@ -70,6 +72,7 @@ public class FileLoader { ...@@ -70,6 +72,7 @@ public class FileLoader {
} else { } else {
operation = uploadOperationPathsEnc.get(location); operation = uploadOperationPathsEnc.get(location);
} }
uploadSizes.remove(location);
if (operation != null) { if (operation != null) {
uploadOperationQueue.remove(operation); uploadOperationQueue.remove(operation);
uploadSmallOperationQueue.remove(operation); uploadSmallOperationQueue.remove(operation);
...@@ -95,6 +98,8 @@ public class FileLoader { ...@@ -95,6 +98,8 @@ public class FileLoader {
} }
if (operation != null) { if (operation != null) {
operation.checkNewDataAvailable(finalSize); operation.checkNewDataAvailable(finalSize);
} else if (finalSize != 0) {
uploadSizes.put(location, finalSize);
} }
} }
}); });
...@@ -117,7 +122,15 @@ public class FileLoader { ...@@ -117,7 +122,15 @@ public class FileLoader {
return; return;
} }
} }
FileUploadOperation operation = new FileUploadOperation(location, encrypted, estimatedSize); int esimated = estimatedSize;
if (esimated != 0) {
Long finalSize = uploadSizes.get(location);
if (finalSize != null) {
esimated = 0;
uploadSizes.remove(location);
}
}
FileUploadOperation operation = new FileUploadOperation(location, encrypted, esimated);
if (encrypted) { if (encrypted) {
uploadOperationPathsEnc.put(location, operation); uploadOperationPathsEnc.put(location, operation);
} else { } else {
......
...@@ -14,7 +14,6 @@ import android.content.ContentUris; ...@@ -14,7 +14,6 @@ import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
...@@ -51,7 +50,6 @@ import java.security.spec.RSAPublicKeySpec; ...@@ -51,7 +50,6 @@ import java.security.spec.RSAPublicKeySpec;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
...@@ -74,23 +72,6 @@ public class Utilities { ...@@ -74,23 +72,6 @@ public class Utilities {
public static volatile DispatchQueue searchQueue = new DispatchQueue("searchQueue"); public static volatile DispatchQueue searchQueue = new DispatchQueue("searchQueue");
public static volatile DispatchQueue photoBookQueue = new DispatchQueue("photoBookQueue"); public static volatile DispatchQueue photoBookQueue = new DispatchQueue("photoBookQueue");
public static int[] arrColors = {0xffee4928, 0xff41a903, 0xffe09602, 0xff0f94ed, 0xff8f3bf7, 0xfffc4380, 0xff00a1c4, 0xffeb7002};
public static int[] arrUsersAvatars = {
R.drawable.user_red,
R.drawable.user_green,
R.drawable.user_yellow,
R.drawable.user_blue,
R.drawable.user_violet,
R.drawable.user_pink,
R.drawable.user_aqua,
R.drawable.user_orange};
public static int[] arrGroupsAvatars = {
R.drawable.group_green,
R.drawable.group_red,
R.drawable.group_blue,
R.drawable.group_yellow};
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static ProgressDialog progressDialog; public static ProgressDialog progressDialog;
...@@ -132,6 +113,7 @@ public class Utilities { ...@@ -132,6 +113,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); public native static void blurBitmap(Object bitmap);
public native static int convertVideoFrame(ByteBuffer src, ByteBuffer dest, int destFormat, int width, int height, int padding);
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) {
...@@ -509,54 +491,6 @@ public class Utilities { ...@@ -509,54 +491,6 @@ public class Utilities {
return true; return true;
} }
public static int getColorIndex(int id) {
int[] arr;
if (id >= 0) {
arr = arrUsersAvatars;
} else {
arr = arrGroupsAvatars;
}
try {
String str;
if (id >= 0) {
str = String.format(Locale.US, "%d%d", id, UserConfig.getClientUserId());
} else {
str = String.format(Locale.US, "%d", id);
}
if (str.length() > 15) {
str = str.substring(0, 15);
}
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] digest = md.digest(str.getBytes());
int b = digest[Math.abs(id % 16)];
if (b < 0) {
b += 256;
}
return Math.abs(b) % arr.length;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return id % arr.length;
}
public static int getColorForId(int id) {
if (id / 1000 == 333) {
return 0xff0f94ed;
}
return arrColors[getColorIndex(id)];
}
public static int getUserAvatarForId(int id) {
if (id / 1000 == 333 || id / 1000 == 777) {
return R.drawable.telegram_avatar;
}
return arrUsersAvatars[getColorIndex(id)];
}
public static int getGroupAvatarForId(int id) {
return arrGroupsAvatars[getColorIndex(-Math.abs(id))];
}
public static String MD5(String md5) { public static String MD5(String md5) {
if (md5 == null) { if (md5 == null) {
return null; return null;
...@@ -757,16 +691,6 @@ public class Utilities { ...@@ -757,16 +691,6 @@ public class Utilities {
return null; return null;
} }
public static String formatName(String firstName, String lastName) {
String result = firstName;
if (result == null || result.length() == 0) {
result = lastName;
} else if (result.length() != 0 && lastName != null && lastName.length() != 0) {
result += " " + lastName;
}
return result.trim();
}
public static String formatFileSize(long size) { public static String formatFileSize(long size) {
if (size < 1024) { if (size < 1024) {
return String.format("%d B", size); return String.format("%d B", size);
...@@ -816,8 +740,4 @@ public class Utilities { ...@@ -816,8 +740,4 @@ public class Utilities {
UpdateManager.register(context, BuildVars.HOCKEY_APP_HASH); UpdateManager.register(context, BuildVars.HOCKEY_APP_HASH);
} }
} }
public static boolean isTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
} }
...@@ -23,7 +23,6 @@ import org.telegram.android.MediaController; ...@@ -23,7 +23,6 @@ import org.telegram.android.MediaController;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.ImageReceiver; import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.ProgressView; import org.telegram.ui.Views.ProgressView;
...@@ -355,9 +354,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -355,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(Utilities.getUserAvatarForId(uid))); avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)));
} else { } else {
avatarImage.setImage((TLRPC.FileLocation)null, "50_50", getResources().getDrawable(Utilities.getUserAvatarForId(uid))); avatarImage.setImage((TLRPC.FileLocation)null, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)));
} }
if (messageObject.isOut()) { if (messageObject.isOut()) {
......
...@@ -23,11 +23,11 @@ import android.view.SoundEffectConstants; ...@@ -23,11 +23,11 @@ import android.view.SoundEffectConstants;
import android.view.ViewConfiguration; import android.view.ViewConfiguration;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.ImageReceiver; import org.telegram.android.ImageReceiver;
...@@ -233,7 +233,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -233,7 +233,7 @@ public class ChatBaseCell extends BaseCell {
String newNameString = null; String newNameString = null;
if (drawName && isChat && newUser != null && !currentMessageObject.isOut()) { if (drawName && isChat && newUser != null && !currentMessageObject.isOut()) {
newNameString = Utilities.formatName(newUser.first_name, newUser.last_name); newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
} }
if (currentNameString == null && newNameString != null || currentNameString != null && newNameString == null || currentNameString != null && newNameString != null && !currentNameString.equals(newNameString)) { if (currentNameString == null && newNameString != null || currentNameString != null && newNameString == null || currentNameString != null && newNameString != null && !currentNameString.equals(newNameString)) {
...@@ -243,7 +243,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -243,7 +243,7 @@ public class ChatBaseCell extends BaseCell {
newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.fwd_from_id); newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.fwd_from_id);
newNameString = null; newNameString = null;
if (newUser != null && drawForwardedName && currentMessageObject.messageOwner instanceof TLRPC.TL_messageForwarded) { if (newUser != null && drawForwardedName && currentMessageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
newNameString = Utilities.formatName(newUser.first_name, newUser.last_name); newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
} }
return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString); return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString);
} }
...@@ -265,7 +265,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -265,7 +265,7 @@ public class ChatBaseCell extends BaseCell {
} else { } else {
currentPhoto = null; currentPhoto = null;
} }
avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(Utilities.getUserAvatarForId(currentUser.id))); avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(currentUser.id)));
} else { } else {
avatarImage.setImage((TLRPC.FileLocation)null, "50_50", null); avatarImage.setImage((TLRPC.FileLocation)null, "50_50", null);
} }
...@@ -287,7 +287,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -287,7 +287,7 @@ public class ChatBaseCell extends BaseCell {
namesOffset = 0; namesOffset = 0;
if (drawName && isChat && currentUser != null && !currentMessageObject.isOut()) { if (drawName && isChat && currentUser != null && !currentMessageObject.isOut()) {
currentNameString = Utilities.formatName(currentUser.first_name, currentUser.last_name); currentNameString = ContactsController.formatName(currentUser.first_name, currentUser.last_name);
nameWidth = getMaxNameWidth(); nameWidth = getMaxNameWidth();
CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
...@@ -308,7 +308,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -308,7 +308,7 @@ public class ChatBaseCell extends BaseCell {
if (drawForwardedName && messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) { if (drawForwardedName && messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
currentForwardUser = MessagesController.getInstance().getUser(messageObject.messageOwner.fwd_from_id); currentForwardUser = MessagesController.getInstance().getUser(messageObject.messageOwner.fwd_from_id);
if (currentForwardUser != null) { if (currentForwardUser != null) {
currentForwardNameString = Utilities.formatName(currentForwardUser.first_name, currentForwardUser.last_name); currentForwardNameString = ContactsController.formatName(currentForwardUser.first_name, currentForwardUser.last_name);
forwardedNameWidth = getMaxNameWidth(); forwardedNameWidth = getMaxNameWidth();
...@@ -520,7 +520,7 @@ public class ChatBaseCell extends BaseCell { ...@@ -520,7 +520,7 @@ public class ChatBaseCell extends BaseCell {
if (drawName && nameLayout != null) { if (drawName && nameLayout != null) {
canvas.save(); canvas.save();
canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10)); canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10));
namePaint.setColor(Utilities.getColorForId(currentUser.id)); namePaint.setColor(AndroidUtilities.getColorForId(currentUser.id));
nameLayout.draw(canvas); nameLayout.draw(canvas);
canvas.restore(); canvas.restore();
} }
......
...@@ -131,6 +131,21 @@ public class ChatMessageCell extends ChatBaseCell { ...@@ -131,6 +131,21 @@ public class ChatMessageCell extends ChatBaseCell {
} }
pressedLink = null; pressedLink = null;
int maxWidth; int maxWidth;
if (AndroidUtilities.isTablet()) {
int min = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
int leftWidth = min / 100 * 35;
if (leftWidth < AndroidUtilities.dp(320)) {
leftWidth = AndroidUtilities.dp(320);
}
if (isChat && !messageObject.isOut()) {
maxWidth = min - leftWidth - AndroidUtilities.dp(122);
drawName = true;
} else {
maxWidth = min - leftWidth - AndroidUtilities.dp(80);
drawName = false;
}
} else {
if (isChat && !messageObject.isOut()) { if (isChat && !messageObject.isOut()) {
maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(122); maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(122);
drawName = true; drawName = true;
...@@ -138,6 +153,7 @@ public class ChatMessageCell extends ChatBaseCell { ...@@ -138,6 +153,7 @@ public class ChatMessageCell extends ChatBaseCell {
maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(80); maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(80);
drawName = false; drawName = false;
} }
}
backgroundWidth = maxWidth; backgroundWidth = maxWidth;
......
...@@ -19,13 +19,13 @@ import android.text.TextUtils; ...@@ -19,13 +19,13 @@ import android.text.TextUtils;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.android.ImageReceiver; import org.telegram.android.ImageReceiver;
public class ChatOrUserCell extends BaseCell { public class ChatOrUserCell extends BaseCell {
...@@ -157,12 +157,16 @@ public class ChatOrUserCell extends BaseCell { ...@@ -157,12 +157,16 @@ public class ChatOrUserCell extends BaseCell {
if (user.photo != null) { if (user.photo != null) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
placeHolderId = Utilities.getUserAvatarForId(user.id); placeHolderId = AndroidUtilities.getUserAvatarForId(user.id);
} else if (chat != null) { } else if (chat != null) {
if (chat.photo != null) { if (chat.photo != null) {
photo = chat.photo.photo_small; photo = chat.photo.photo_small;
} }
placeHolderId = Utilities.getGroupAvatarForId(chat.id); if (chat.id > 0) {
placeHolderId = AndroidUtilities.getGroupAvatarForId(chat.id);
} else {
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(chat.id);
}
} }
if (mask != 0) { if (mask != 0) {
...@@ -339,7 +343,7 @@ public class ChatOrUserCell extends BaseCell { ...@@ -339,7 +343,7 @@ public class ChatOrUserCell extends BaseCell {
if (chat != null) { if (chat != null) {
nameString2 = chat.title; nameString2 = chat.title;
} else if (user != null) { } else if (user != null) {
nameString2 = Utilities.formatName(user.first_name, user.last_name); nameString2 = ContactsController.formatName(user.first_name, user.last_name);
} }
nameString = nameString2.replace("\n", " "); nameString = nameString2.replace("\n", " ");
} }
......
...@@ -27,7 +27,6 @@ import org.telegram.android.Emoji; ...@@ -27,7 +27,6 @@ import org.telegram.android.Emoji;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.ImageReceiver; import org.telegram.android.ImageReceiver;
...@@ -155,6 +154,10 @@ public class DialogCell extends BaseCell { ...@@ -155,6 +154,10 @@ public class DialogCell extends BaseCell {
update(0); update(0);
} }
public TLRPC.TL_dialog getDialog() {
return currentDialog;
}
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
...@@ -249,12 +252,16 @@ public class DialogCell extends BaseCell { ...@@ -249,12 +252,16 @@ public class DialogCell extends BaseCell {
if (user.photo != null) { if (user.photo != null) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
placeHolderId = Utilities.getUserAvatarForId(user.id); placeHolderId = AndroidUtilities.getUserAvatarForId(user.id);
} else if (chat != null) { } else if (chat != null) {
if (chat.photo != null) { if (chat.photo != null) {
photo = chat.photo.photo_small; photo = chat.photo.photo_small;
} }
placeHolderId = Utilities.getGroupAvatarForId(chat.id); if (chat.id > 0) {
placeHolderId = AndroidUtilities.getGroupAvatarForId(chat.id);
} else {
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));
...@@ -564,17 +571,17 @@ public class DialogCell extends BaseCell { ...@@ -564,17 +571,17 @@ public class DialogCell extends BaseCell {
} else if (user != null) { } else if (user != null) {
if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) { if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) {
if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) { if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) {
nameString = Utilities.formatName(user.first_name, user.last_name); nameString = ContactsController.formatName(user.first_name, user.last_name);
} else { } else {
if (user.phone != null && user.phone.length() != 0) { if (user.phone != null && user.phone.length() != 0) {
nameString = PhoneFormat.getInstance().format("+" + user.phone); nameString = PhoneFormat.getInstance().format("+" + user.phone);
} else { } else {
currentNamePaint = nameUnknownPaint; currentNamePaint = nameUnknownPaint;
nameString = Utilities.formatName(user.first_name, user.last_name); nameString = ContactsController.formatName(user.first_name, user.last_name);
} }
} }
} else { } else {
nameString = Utilities.formatName(user.first_name, user.last_name); nameString = ContactsController.formatName(user.first_name, user.last_name);
} }
if (encryptedChat != null) { if (encryptedChat != null) {
currentNamePaint = nameEncryptedPaint; currentNamePaint = nameEncryptedPaint;
......
...@@ -641,7 +641,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -641,7 +641,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
photo = chat.photo.photo_small; photo = chat.photo.photo_small;
photoBig = chat.photo.photo_big; photoBig = chat.photo.photo_big;
} }
avatarImage.setImage(photo, "50_50", Utilities.getGroupAvatarForId(chat.id)); avatarImage.setImage(photo, "50_50", chat_id > 0 ? AndroidUtilities.getGroupAvatarForId(chat.id) : AndroidUtilities.getBroadcastAvatarForId(chat.id));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
return view; return view;
} else if (type == 1) { } else if (type == 1) {
......
...@@ -29,7 +29,6 @@ import org.telegram.messenger.TLRPC; ...@@ -29,7 +29,6 @@ import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.BackupImageView; import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.ActionBar.BaseFragment;
...@@ -165,7 +164,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent ...@@ -165,7 +164,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
if (user.photo != null) { if (user.photo != null) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
avatarImage.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id)); avatarImage.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
} }
public void didReceivedNotification(int id, Object... args) { public void didReceivedNotification(int id, Object... args) {
......
...@@ -349,7 +349,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter ...@@ -349,7 +349,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
} }
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name))); builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
final EditText editText = new EditText(getParentActivity()); final EditText editText = new EditText(getParentActivity());
if (android.os.Build.VERSION.SDK_INT < 11) { if (android.os.Build.VERSION.SDK_INT < 11) {
editText.setBackgroundResource(android.R.drawable.editbox_background_normal); editText.setBackgroundResource(android.R.drawable.editbox_background_normal);
......
...@@ -332,7 +332,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -332,7 +332,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
LayoutInflater lf = (LayoutInflater)ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); LayoutInflater lf = (LayoutInflater)ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View textView = lf.inflate(R.layout.group_create_bubble, null); View textView = lf.inflate(R.layout.group_create_bubble, null);
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view); TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
String name = Utilities.formatName(user.first_name, user.last_name); String name = ContactsController.formatName(user.first_name, user.last_name);
if (name.length() == 0 && user.phone != null && user.phone.length() != 0) { if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
name = PhoneFormat.getInstance().format("+" + user.phone); name = PhoneFormat.getInstance().format("+" + user.phone);
} }
...@@ -539,7 +539,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -539,7 +539,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (searchWas && searching) { if (searchWas && searching) {
holder.nameTextView.setText(searchResultNames.get(position)); holder.nameTextView.setText(searchResultNames.get(position));
} else { } else {
String name = Utilities.formatName(user.first_name, user.last_name); String name = ContactsController.formatName(user.first_name, user.last_name);
if (name.length() == 0) { if (name.length() == 0) {
if (user.phone != null && user.phone.length() != 0) { if (user.phone != null && user.phone.length() != 0) {
name = PhoneFormat.getInstance().format("+" + user.phone); name = PhoneFormat.getInstance().format("+" + user.phone);
...@@ -554,7 +554,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -554,7 +554,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (user.photo != null) { if (user.photo != null) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
int placeHolderId = Utilities.getUserAvatarForId(user.id); int placeHolderId = AndroidUtilities.getUserAvatarForId(user.id);
holder.avatarImage.setImage(photo, "50_50", placeHolderId); holder.avatarImage.setImage(photo, "50_50", placeHolderId);
holder.messageTextView.setText(LocaleController.formatUserStatus(user)); holder.messageTextView.setText(LocaleController.formatUserStatus(user));
......
...@@ -10,6 +10,7 @@ package org.telegram.ui; ...@@ -10,6 +10,7 @@ package org.telegram.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.DataSetObserver; import android.database.DataSetObserver;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
...@@ -24,6 +25,7 @@ import android.view.animation.AnimationUtils; ...@@ -24,6 +25,7 @@ import android.view.animation.AnimationUtils;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
...@@ -46,7 +48,12 @@ public class IntroActivity extends Activity { ...@@ -46,7 +48,12 @@ public class IntroActivity extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
if (AndroidUtilities.isTablet()) {
setContentView(R.layout.intro_layout_tablet);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.intro_layout); setContentView(R.layout.intro_layout);
}
if (LocaleController.isRTL) { if (LocaleController.isRTL) {
icons = new int[] { icons = new int[] {
......
...@@ -125,7 +125,7 @@ public class LanguageSelectActivity extends BaseFragment { ...@@ -125,7 +125,7 @@ public class LanguageSelectActivity extends BaseFragment {
} }
if (localeInfo != null) { if (localeInfo != null) {
LocaleController.getInstance().applyLanguage(localeInfo, true); LocaleController.getInstance().applyLanguage(localeInfo, true);
getParentActivity().rebuildAllFragmentViews(); parentLayout.rebuildAllFragmentViews(false);
} }
finishFragment(); finishFragment();
} }
......
...@@ -27,6 +27,8 @@ import com.google.android.gms.maps.model.LatLng; ...@@ -27,6 +27,8 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
...@@ -34,7 +36,6 @@ import org.telegram.android.MessageObject; ...@@ -34,7 +36,6 @@ import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.ActionBar.ActionBarLayer; import org.telegram.ui.Views.ActionBar.ActionBarLayer;
import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
...@@ -235,8 +236,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter ...@@ -235,8 +236,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (user.photo != null) { if (user.photo != null) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
avatarImageView.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id)); avatarImageView.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
nameTextView.setText(Utilities.formatName(user.first_name, user.last_name)); nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
} }
userLocation = new Location("network"); userLocation = new Location("network");
userLocation.setLatitude(messageObject.messageOwner.media.geo.lat); userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
...@@ -284,8 +285,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter ...@@ -284,8 +285,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (user.photo != null) { if (user.photo != null) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
avatarImageView.setImage(photo, null, Utilities.getUserAvatarForId(user.id)); avatarImageView.setImage(photo, null, AndroidUtilities.getUserAvatarForId(user.id));
nameTextView.setText(Utilities.formatName(user.first_name, user.last_name)); nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
} }
} }
} }
......
...@@ -326,15 +326,21 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No ...@@ -326,15 +326,21 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
int rotation = manager.getDefaultDisplay().getRotation(); int rotation = manager.getDefaultDisplay().getRotation();
if (AndroidUtilities.isTablet()) {
listView.setNumColumns(4);
itemWidth = AndroidUtilities.dp(490) / 4 - AndroidUtilities.dp(2) * 3;
listView.setColumnWidth(itemWidth);
} else {
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
listView.setNumColumns(6); listView.setNumColumns(6);
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 6 - AndroidUtilities.dp(2) * 5; itemWidth = AndroidUtilities.displaySize.x / 6 - AndroidUtilities.dp(2) * 5;
listView.setColumnWidth(itemWidth); listView.setColumnWidth(itemWidth);
} else { } else {
listView.setNumColumns(4); listView.setNumColumns(4);
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 4 - AndroidUtilities.dp(2) * 3; itemWidth = AndroidUtilities.displaySize.x / 4 - AndroidUtilities.dp(2) * 3;
listView.setColumnWidth(itemWidth); listView.setColumnWidth(itemWidth);
} }
}
listView.setPadding(listView.getPaddingLeft(), AndroidUtilities.dp(4), listView.getPaddingRight(), listView.getPaddingBottom()); listView.setPadding(listView.getPaddingLeft(), AndroidUtilities.dp(4), listView.getPaddingRight(), listView.getPaddingBottom());
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
......
...@@ -68,6 +68,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -68,6 +68,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
private MessagesActivityDelegate delegate; private MessagesActivityDelegate delegate;
private long openedDialogId = 0;
private final static int messages_list_menu_new_messages = 1; private final static int messages_list_menu_new_messages = 1;
private final static int messages_list_menu_new_chat = 2; private final static int messages_list_menu_new_chat = 2;
private final static int messages_list_menu_other = 6; private final static int messages_list_menu_other = 6;
...@@ -94,6 +96,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -94,6 +96,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated); NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.openedChatChanged);
if (getArguments() != null) { if (getArguments() != null) {
onlySelect = arguments.getBoolean("onlySelect", false); onlySelect = arguments.getBoolean("onlySelect", false);
serverOnly = arguments.getBoolean("serverOnly", false); serverOnly = arguments.getBoolean("serverOnly", false);
...@@ -116,6 +119,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -116,6 +119,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.openedChatChanged);
delegate = null; delegate = null;
} }
...@@ -224,6 +228,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -224,6 +228,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view); messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
messagesListView.setAdapter(messagesListViewAdapter); messagesListView.setAdapter(messagesListViewAdapter);
if (delegate == null && AndroidUtilities.isTablet()) {
messagesListView.setDivider(inflater.getContext().getResources().getDrawable(R.drawable.messages_list_divider2));
messagesListView.setDividerHeight(1);
}
progressView = fragmentView.findViewById(R.id.progressLayout); progressView = fragmentView.findViewById(R.id.progressLayout);
messagesListViewAdapter.notifyDataSetChanged(); messagesListViewAdapter.notifyDataSetChanged();
...@@ -305,7 +313,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -305,7 +313,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else { } else {
args.putInt("enc_id", high_id); args.putInt("enc_id", high_id);
} }
if (AndroidUtilities.isTablet()) {
if (openedDialogId == dialog_id) {
return;
}
openedDialogId = dialog_id;
}
presentFragment(new ChatActivity(args)); presentFragment(new ChatActivity(args));
updateVisibleRows(0);
} }
} }
}); });
...@@ -469,6 +484,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -469,6 +484,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
updateVisibleRows(0); updateVisibleRows(0);
} else if (id == NotificationCenter.contactsDidLoaded) { } else if (id == NotificationCenter.contactsDidLoaded) {
updateVisibleRows(0); updateVisibleRows(0);
} else if (id == NotificationCenter.openedChatChanged) {
if (!serverOnly && AndroidUtilities.isTablet()) {
openedDialogId = (Long)args[0];
updateVisibleRows(0);
}
} }
} }
...@@ -480,7 +500,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -480,7 +500,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
for (int a = 0; a < count; a++) { for (int a = 0; a < count; a++) {
View child = messagesListView.getChildAt(a); View child = messagesListView.getChildAt(a);
if (child instanceof DialogCell) { if (child instanceof DialogCell) {
((DialogCell) child).update(mask); DialogCell cell = (DialogCell) child;
if (!serverOnly && AndroidUtilities.isTablet() && cell.getDialog() != null) {
if (cell.getDialog().id == openedDialogId) {
child.setBackgroundColor(0x0f000000);
} else {
child.setBackgroundColor(0);
}
}
cell.update(mask);
} else if (child instanceof ChatOrUserCell) { } else if (child instanceof ChatOrUserCell) {
((ChatOrUserCell) child).update(mask); ((ChatOrUserCell) child).update(mask);
} }
...@@ -491,6 +519,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -491,6 +519,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
this.delegate = delegate; this.delegate = delegate;
} }
public MessagesActivityDelegate getDelegate() {
return delegate;
}
private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) { private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) {
if (useAlert && selectAlertString != null) { if (useAlert && selectAlertString != null) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
...@@ -513,7 +545,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -513,7 +545,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (user == null) { if (user == null) {
return; return;
} }
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name))); builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
} else if (lower_part < 0) { } else if (lower_part < 0) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_part); TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_part);
if (chat == null) { if (chat == null) {
...@@ -528,7 +560,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -528,7 +560,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (user == null) { if (user == null) {
return; return;
} }
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name))); builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
} }
CheckBox checkBox = null; CheckBox checkBox = null;
/*if (delegate instanceof ChatActivity) { /*if (delegate instanceof ChatActivity) {
...@@ -713,7 +745,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -713,7 +745,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (serverOnly) { if (serverOnly) {
((DialogCell)view).setDialog(MessagesController.getInstance().dialogsServerOnly.get(i)); ((DialogCell)view).setDialog(MessagesController.getInstance().dialogsServerOnly.get(i));
} else { } else {
((DialogCell)view).setDialog(MessagesController.getInstance().dialogs.get(i)); TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs.get(i);
if (AndroidUtilities.isTablet()) {
if (dialog.id == openedDialogId) {
view.setBackgroundColor(0x0f000000);
} else {
view.setBackgroundColor(0);
}
}
((DialogCell)view).setDialog(dialog);
} }
return view; return view;
......
...@@ -12,17 +12,14 @@ import android.content.Context; ...@@ -12,17 +12,14 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.Display;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
...@@ -302,14 +299,12 @@ public class PhotoCropActivity extends BaseFragment { ...@@ -302,14 +299,12 @@ public class PhotoCropActivity extends BaseFragment {
return false; return false;
} }
} }
Point displaySize = new Point(); int size = 0;
Display display = ((WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); if (AndroidUtilities.isTablet()) {
if(android.os.Build.VERSION.SDK_INT < 13) { size = AndroidUtilities.dp(520);
displaySize.set(display.getWidth(), display.getHeight());
} else { } else {
display.getSize(displaySize); size = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
} }
int size = Math.max(displaySize.x, displaySize.y);
imageToCrop = ImageLoader.loadBitmap(photoPath, photoUri, size, size); imageToCrop = ImageLoader.loadBitmap(photoPath, photoUri, size, size);
if (imageToCrop == null) { if (imageToCrop == null) {
return false; return false;
......
...@@ -394,18 +394,26 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen ...@@ -394,18 +394,26 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
int columnsCount = 2; int columnsCount = 2;
if (selectedAlbum != null) { if (selectedAlbum != null) {
if (AndroidUtilities.isTablet()) {
columnsCount = 3;
} else {
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
columnsCount = 5; columnsCount = 5;
} else { } else {
columnsCount = 3; columnsCount = 3;
} }
}
} else { } else {
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
columnsCount = 4; columnsCount = 4;
} }
} }
listView.setNumColumns(columnsCount); listView.setNumColumns(columnsCount);
itemWidth = (getParentActivity().getResources().getDisplayMetrics().widthPixels - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount; if (AndroidUtilities.isTablet()) {
itemWidth = (AndroidUtilities.dp(490) - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
} else {
itemWidth = (AndroidUtilities.displaySize.x - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
}
listView.setColumnWidth(itemWidth); listView.setColumnWidth(itemWidth);
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
......
...@@ -47,6 +47,7 @@ import android.widget.Scroller; ...@@ -47,6 +47,7 @@ import android.widget.Scroller;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.MessagesStorage; import org.telegram.android.MessagesStorage;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
...@@ -62,7 +63,6 @@ import org.telegram.messenger.Utilities; ...@@ -62,7 +63,6 @@ import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.PhotoObject; import org.telegram.android.PhotoObject;
import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBar;
import org.telegram.ui.Views.ActionBar.ActionBarActivity;
import org.telegram.ui.Views.ActionBar.ActionBarLayer; import org.telegram.ui.Views.ActionBar.ActionBarLayer;
import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
...@@ -521,7 +521,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -521,7 +521,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
closePhoto(false); closePhoto(false);
Bundle args2 = new Bundle(); Bundle args2 = new Bundle();
args2.putLong("dialog_id", currentDialogId); args2.putLong("dialog_id", currentDialogId);
((ActionBarActivity)parentActivity).presentFragment(new MediaActivity(args2), false, true); ((LaunchActivity)parentActivity).presentFragment(new MediaActivity(args2), false, true);
} }
} else if (id == gallery_menu_send) { } else if (id == gallery_menu_send) {
/*Intent intent = new Intent(this, MessagesActivity.class); /*Intent intent = new Intent(this, MessagesActivity.class);
...@@ -1219,7 +1219,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ...@@ -1219,7 +1219,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
currentMessageObject = imagesArr.get(currentIndex); currentMessageObject = imagesArr.get(currentIndex);
TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id); TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id);
if (user != null) { if (user != null) {
nameTextView.setText(Utilities.formatName(user.first_name, user.last_name)); nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
} else { } else {
nameTextView.setText(""); nameTextView.setText("");
} }
......
...@@ -13,7 +13,6 @@ import android.app.KeyguardManager; ...@@ -13,7 +13,6 @@ import android.app.KeyguardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.util.AttributeSet; import android.util.AttributeSet;
...@@ -43,7 +42,6 @@ import org.telegram.messenger.FileLog; ...@@ -43,7 +42,6 @@ import org.telegram.messenger.FileLog;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.PhotoObject; import org.telegram.android.PhotoObject;
import org.telegram.ui.Views.ActionBar.ActionBar; import org.telegram.ui.Views.ActionBar.ActionBar;
...@@ -53,6 +51,7 @@ import org.telegram.ui.Views.BackupImageView; ...@@ -53,6 +51,7 @@ import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ChatActivityEnterView; import org.telegram.ui.Views.ChatActivityEnterView;
import org.telegram.ui.Views.FrameLayoutFixed; import org.telegram.ui.Views.FrameLayoutFixed;
import org.telegram.ui.Views.PopupAudioView; import org.telegram.ui.Views.PopupAudioView;
import org.telegram.ui.Views.TypingDotsDrawable;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -71,6 +70,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -71,6 +70,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
private ArrayList<ViewGroup> imageViews = new ArrayList<ViewGroup>(); private ArrayList<ViewGroup> imageViews = new ArrayList<ViewGroup>();
private ArrayList<ViewGroup> audioViews = new ArrayList<ViewGroup>(); private ArrayList<ViewGroup> audioViews = new ArrayList<ViewGroup>();
private VelocityTracker velocityTracker = null; private VelocityTracker velocityTracker = null;
private TypingDotsDrawable typingDotsDrawable;
private int classGuid; private int classGuid;
private TLRPC.User currentUser; private TLRPC.User currentUser;
...@@ -151,6 +151,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -151,6 +151,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
typingDotsDrawable = new TypingDotsDrawable();
chatActivityEnterView = new ChatActivityEnterView(); chatActivityEnterView = new ChatActivityEnterView();
chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() { chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
@Override @Override
...@@ -624,7 +626,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -624,7 +626,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
messageContainer.getViewTreeObserver().removeOnPreDrawListener(this); messageContainer.getViewTreeObserver().removeOnPreDrawListener(this);
if (!checkTransitionAnimation() && !startedMoving) { if (!checkTransitionAnimation() && !startedMoving) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)messageContainer.getLayoutParams(); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)messageContainer.getLayoutParams();
if (!Utilities.isTablet(PopupNotificationActivity.this) && PopupNotificationActivity.this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && PopupNotificationActivity.this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
layoutParams.topMargin = AndroidUtilities.dp(40); layoutParams.topMargin = AndroidUtilities.dp(40);
} else { } else {
layoutParams.topMargin = AndroidUtilities.dp(48); layoutParams.topMargin = AndroidUtilities.dp(48);
...@@ -739,10 +741,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -739,10 +741,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if (currentChat != null && currentUser != null) { if (currentChat != null && currentUser != null) {
actionBarLayer.setTitle(currentChat.title); actionBarLayer.setTitle(currentChat.title);
actionBarLayer.setSubtitle(Utilities.formatName(currentUser.first_name, currentUser.last_name)); actionBarLayer.setSubtitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
actionBarLayer.setTitleIcon(0, 0); actionBarLayer.setTitleIcon(0, 0);
} else if (currentUser != null) { } else if (currentUser != null) {
actionBarLayer.setTitle(Utilities.formatName(currentUser.first_name, currentUser.last_name)); actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
if ((int)dialog_id == 0) { if ((int)dialog_id == 0) {
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4)); actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
} else { } else {
...@@ -767,10 +769,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -767,10 +769,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if (currentUser.phone != null && currentUser.phone.length() != 0) { if (currentUser.phone != null && currentUser.phone.length() != 0) {
actionBarLayer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); actionBarLayer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone));
} else { } else {
actionBarLayer.setTitle(Utilities.formatName(currentUser.first_name, currentUser.last_name)); actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
} }
} else { } else {
actionBarLayer.setTitle(Utilities.formatName(currentUser.first_name, currentUser.last_name)); actionBarLayer.setTitle(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
} }
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId()); CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId());
if (printString == null || printString.length() == 0) { if (printString == null || printString.length() == 0) {
...@@ -800,7 +802,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -800,7 +802,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if (currentChat.photo != null) { if (currentChat.photo != null) {
newPhoto = currentChat.photo.photo_small; newPhoto = currentChat.photo.photo_small;
} }
placeHolderId = Utilities.getGroupAvatarForId(currentChat.id); placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
} else if (currentUser != null) { } else if (currentUser != null) {
TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id); TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id);
if (user == null) { if (user == null) {
...@@ -810,7 +812,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -810,7 +812,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if (currentUser.photo != null) { if (currentUser.photo != null) {
newPhoto = currentUser.photo.photo_small; newPhoto = currentUser.photo.photo_small;
} }
placeHolderId = Utilities.getUserAvatarForId(currentUser.id); placeHolderId = AndroidUtilities.getUserAvatarForId(currentUser.id);
} }
if (avatarImageView != null) { if (avatarImageView != null) {
avatarImageView.setImage(newPhoto, "50_50", placeHolderId); avatarImageView.setImage(newPhoto, "50_50", placeHolderId);
...@@ -823,15 +825,14 @@ public class PopupNotificationActivity extends Activity implements NotificationC ...@@ -823,15 +825,14 @@ public class PopupNotificationActivity extends Activity implements NotificationC
} }
if (start) { if (start) {
try { try {
actionBarLayer.setSubTitleIcon(R.drawable.typing_dots, AndroidUtilities.dp(4)); actionBarLayer.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4));
AnimationDrawable mAnim = (AnimationDrawable)actionBarLayer.getSubTitleIcon(); typingDotsDrawable.start();
mAnim.setAlpha(200);
mAnim.start();
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} else { } else {
actionBarLayer.setSubTitleIcon(0, 0); actionBarLayer.setSubTitleIcon(0, null, 0);
typingDotsDrawable.stop();
} }
} }
......
...@@ -52,7 +52,6 @@ import org.telegram.android.NotificationCenter; ...@@ -52,7 +52,6 @@ import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest; import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.PhotoObject; import org.telegram.android.PhotoObject;
import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.BaseFragmentAdapter;
...@@ -817,7 +816,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -817,7 +816,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
user = UserConfig.getCurrentUser(); user = UserConfig.getCurrentUser();
} }
if (user != null) { if (user != null) {
textView.setText(Utilities.formatName(user.first_name, user.last_name)); textView.setText(ContactsController.formatName(user.first_name, user.last_name));
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image); BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
avatarImage.processDetach = false; avatarImage.processDetach = false;
TLRPC.FileLocation photo = null; TLRPC.FileLocation photo = null;
...@@ -826,7 +825,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -826,7 +825,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
photo = user.photo.photo_small; photo = user.photo.photo_small;
photoBig = user.photo.photo_big; photoBig = user.photo.photo_big;
} }
avatarImage.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id)); avatarImage.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
} }
return view; return view;
...@@ -979,7 +978,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -979,7 +978,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
View divider = view.findViewById(R.id.settings_row_divider); View divider = view.findViewById(R.id.settings_row_divider);
if (i == textSizeRow) { if (i == textSizeRow) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
int size = preferences.getInt("fons_size", 16); int size = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16);
detailTextView.setText(String.format("%d", size)); detailTextView.setText(String.format("%d", size));
textView.setText(LocaleController.getString("TextSize", R.string.TextSize)); textView.setText(LocaleController.getString("TextSize", R.string.TextSize));
divider.setVisibility(View.VISIBLE); divider.setVisibility(View.VISIBLE);
......
...@@ -34,7 +34,6 @@ import org.telegram.android.MessagesController; ...@@ -34,7 +34,6 @@ import org.telegram.android.MessagesController;
import org.telegram.android.MessagesStorage; import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Views.ActionBar.ActionBarLayer; import org.telegram.ui.Views.ActionBar.ActionBarLayer;
...@@ -542,7 +541,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -542,7 +541,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf"); Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
textView.setTypeface(typeface); textView.setTypeface(typeface);
textView.setText(Utilities.formatName(user.first_name, user.last_name)); textView.setText(ContactsController.formatName(user.first_name, user.last_name));
onlineText.setText(LocaleController.formatUserStatus(user)); onlineText.setText(LocaleController.formatUserStatus(user));
TLRPC.FileLocation photo = null; TLRPC.FileLocation photo = null;
...@@ -551,7 +550,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -551,7 +550,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
photo = user.photo.photo_small; photo = user.photo.photo_small;
photoBig = user.photo.photo_big; photoBig = user.photo.photo_big;
} }
avatarImage.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id)); avatarImage.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
return view; return view;
} else if (type == 1) { } else if (type == 1) {
......
...@@ -21,7 +21,6 @@ import android.widget.FrameLayout; ...@@ -21,7 +21,6 @@ import android.widget.FrameLayout;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -171,7 +170,7 @@ public class ActionBar extends FrameLayout { ...@@ -171,7 +170,7 @@ public class ActionBar extends FrameLayout {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(40), MeasureSpec.EXACTLY)); super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(40), MeasureSpec.EXACTLY));
} else { } else {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY)); super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
......
...@@ -23,7 +23,6 @@ import android.widget.TextView; ...@@ -23,7 +23,6 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
public class ActionBarLayer extends FrameLayout { public class ActionBarLayer extends FrameLayout {
...@@ -55,6 +54,7 @@ public class ActionBarLayer extends FrameLayout { ...@@ -55,6 +54,7 @@ public class ActionBarLayer extends FrameLayout {
private boolean isBackOverlayVisible; private boolean isBackOverlayVisible;
protected BaseFragment parentFragment; protected BaseFragment parentFragment;
public ActionBarMenuOnItemClick actionBarMenuOnItemClick; public ActionBarMenuOnItemClick actionBarMenuOnItemClick;
private int leftMargin = 0;
public ActionBarLayer(Context context, ActionBar actionBar) { public ActionBarLayer(Context context, ActionBar actionBar) {
super(context); super(context);
...@@ -94,13 +94,17 @@ public class ActionBarLayer extends FrameLayout { ...@@ -94,13 +94,17 @@ public class ActionBarLayer extends FrameLayout {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
} }
public void setExtraLeftMargin(int margin) {
leftMargin = margin;
}
private void positionBackImage(int height) { private void positionBackImage(int height) {
if (backButtonImageView != null) { if (backButtonImageView != null) {
LayoutParams layoutParams = (LayoutParams)backButtonImageView.getLayoutParams(); LayoutParams layoutParams = (LayoutParams)backButtonImageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
layoutParams.setMargins(AndroidUtilities.dp(3), (height - backButtonImageView.getDrawable().getIntrinsicHeight()) / 2, 0, 0); layoutParams.setMargins(AndroidUtilities.dp(3 + leftMargin), (height - backButtonImageView.getDrawable().getIntrinsicHeight()) / 2, 0, 0);
backButtonImageView.setLayoutParams(layoutParams); backButtonImageView.setLayoutParams(layoutParams);
} }
} }
...@@ -108,7 +112,7 @@ public class ActionBarLayer extends FrameLayout { ...@@ -108,7 +112,7 @@ public class ActionBarLayer extends FrameLayout {
private void positionLogoImage(int height) { private void positionLogoImage(int height) {
if (logoImageView != null) { if (logoImageView != null) {
LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams(); LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams();
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
layoutParams.width = (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f); layoutParams.width = (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
layoutParams.height = (int)(logoImageView.getDrawable().getIntrinsicHeight() / 1.3f); layoutParams.height = (int)(logoImageView.getDrawable().getIntrinsicHeight() / 1.3f);
layoutParams.setMargins(AndroidUtilities.dp(12), (height - layoutParams.height) / 2, 0, 0); layoutParams.setMargins(AndroidUtilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
...@@ -124,7 +128,7 @@ public class ActionBarLayer extends FrameLayout { ...@@ -124,7 +128,7 @@ public class ActionBarLayer extends FrameLayout {
private void positionTitle(int width, int height) { private void positionTitle(int width, int height) {
int offset = AndroidUtilities.dp(2); int offset = AndroidUtilities.dp(2);
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
offset = AndroidUtilities.dp(1); offset = AndroidUtilities.dp(1);
} }
int maxTextWidth = 0; int maxTextWidth = 0;
...@@ -132,7 +136,7 @@ public class ActionBarLayer extends FrameLayout { ...@@ -132,7 +136,7 @@ public class ActionBarLayer extends FrameLayout {
LayoutParams layoutParams = null; LayoutParams layoutParams = null;
if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) { if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) {
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
titleTextView.setTextSize(16); titleTextView.setTextSize(16);
} else { } else {
titleTextView.setTextSize(18); titleTextView.setTextSize(18);
...@@ -147,7 +151,7 @@ public class ActionBarLayer extends FrameLayout { ...@@ -147,7 +151,7 @@ public class ActionBarLayer extends FrameLayout {
maxTextWidth = titleTextView.getMeasuredWidth(); maxTextWidth = titleTextView.getMeasuredWidth();
} }
if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) { if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) {
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
subTitleTextView.setTextSize(12); subTitleTextView.setTextSize(12);
} else { } else {
subTitleTextView.setTextSize(14); subTitleTextView.setTextSize(14);
...@@ -164,12 +168,12 @@ public class ActionBarLayer extends FrameLayout { ...@@ -164,12 +168,12 @@ public class ActionBarLayer extends FrameLayout {
int x = 0; int x = 0;
if (logoImageView == null || logoImageView.getVisibility() == GONE) { if (logoImageView == null || logoImageView.getVisibility() == GONE) {
x = AndroidUtilities.dp(16); x = AndroidUtilities.dp(16 + leftMargin);
} else { } else {
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
x = AndroidUtilities.dp(22) + (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f); x = AndroidUtilities.dp(22 + leftMargin) + (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
} else { } else {
x = AndroidUtilities.dp(22) + logoImageView.getDrawable().getIntrinsicWidth(); x = AndroidUtilities.dp(22 + leftMargin) + logoImageView.getDrawable().getIntrinsicWidth();
} }
} }
...@@ -258,8 +262,8 @@ public class ActionBarLayer extends FrameLayout { ...@@ -258,8 +262,8 @@ public class ActionBarLayer extends FrameLayout {
} }
} }
public void setSubTitleIcon(int resourceId, int padding) { public void setSubTitleIcon(int resourceId, Drawable drawable, int padding) {
if (resourceId != 0 && subTitleTextView == null) { if ((resourceId != 0 || drawable != null) && subTitleTextView == null) {
subTitleTextView = new TextView(getContext()); subTitleTextView = new TextView(getContext());
backButtonFrameLayout.addView(subTitleTextView); backButtonFrameLayout.addView(subTitleTextView);
subTitleTextView.setGravity(Gravity.LEFT); subTitleTextView.setGravity(Gravity.LEFT);
...@@ -271,7 +275,11 @@ public class ActionBarLayer extends FrameLayout { ...@@ -271,7 +275,11 @@ public class ActionBarLayer extends FrameLayout {
positionTitle(getMeasuredWidth(), getMeasuredHeight()); positionTitle(getMeasuredWidth(), getMeasuredHeight());
} }
if (subTitleTextView != null) { if (subTitleTextView != null) {
if (drawable != null) {
subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
} else {
subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0); subTitleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0);
}
subTitleTextView.setCompoundDrawablePadding(padding); subTitleTextView.setCompoundDrawablePadding(padding);
} }
} }
...@@ -479,7 +487,7 @@ public class ActionBarLayer extends FrameLayout { ...@@ -479,7 +487,7 @@ public class ActionBarLayer extends FrameLayout {
} }
isBackOverlayVisible = visible; isBackOverlayVisible = visible;
if (visible) { if (visible) {
((ActionBarActivity)getContext()).onOverlayShow(actionOverlay, parentFragment); parentFragment.parentLayout.onOverlayShow(actionOverlay, parentFragment);
} }
positionBackOverlay(getMeasuredWidth(), getMeasuredHeight()); positionBackOverlay(getMeasuredWidth(), getMeasuredHeight());
} }
......
...@@ -61,7 +61,11 @@ public class ActionBarMenu extends LinearLayout { ...@@ -61,7 +61,11 @@ public class ActionBarMenu extends LinearLayout {
} }
public ActionBarMenuItem addItem(int id, int icon) { public ActionBarMenuItem addItem(int id, int icon) {
ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, parentActionBar, parentActionBarLayer.itemsBackgroundResourceId); return addItem(id, icon, parentActionBarLayer.itemsBackgroundResourceId);
}
public ActionBarMenuItem addItem(int id, int icon, int backgroundResource) {
ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, parentActionBar, backgroundResource);
menuItem.setTag(id); menuItem.setTag(id);
menuItem.setScaleType(ImageView.ScaleType.CENTER); menuItem.setScaleType(ImageView.ScaleType.CENTER);
menuItem.setImageResource(icon); menuItem.setImageResource(icon);
......
...@@ -14,8 +14,12 @@ import android.os.Build; ...@@ -14,8 +14,12 @@ import android.os.Build;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.ContextMenu;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
...@@ -28,7 +32,6 @@ import android.widget.TextView; ...@@ -28,7 +32,6 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import java.lang.reflect.Field; import java.lang.reflect.Field;
...@@ -257,6 +260,30 @@ public class ActionBarMenuItem extends ImageView { ...@@ -257,6 +260,30 @@ public class ActionBarMenuItem extends ImageView {
searchField.setBackgroundResource(R.drawable.search_light_states); searchField.setBackgroundResource(R.drawable.search_light_states);
searchField.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), 0); searchField.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), 0);
searchField.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS); searchField.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
if (android.os.Build.VERSION.SDK_INT < 11) {
searchField.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
menu.clear();
}
});
} else {
searchField.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
public void onDestroyActionMode(ActionMode mode) {
}
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
});
}
searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() { searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override @Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
package org.telegram.ui.Views.ActionBar; package org.telegram.ui.Views.ActionBar;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
...@@ -23,7 +24,7 @@ import org.telegram.messenger.R; ...@@ -23,7 +24,7 @@ import org.telegram.messenger.R;
public class BaseFragment { public class BaseFragment {
private boolean isFinished = false; private boolean isFinished = false;
protected View fragmentView; protected View fragmentView;
private ActionBarActivity parentActivity; protected ActionBarLayout parentLayout;
protected ActionBarLayer actionBarLayer; protected ActionBarLayer actionBarLayer;
protected int classGuid = 0; protected int classGuid = 0;
protected Bundle arguments; protected Bundle arguments;
...@@ -47,9 +48,9 @@ public class BaseFragment { ...@@ -47,9 +48,9 @@ public class BaseFragment {
return arguments; return arguments;
} }
public void setParentActivity(ActionBarActivity activity) { public void setParentLayout(ActionBarLayout layout) {
if (parentActivity != activity) { if (parentLayout != layout) {
parentActivity = activity; parentLayout = layout;
if (fragmentView != null) { if (fragmentView != null) {
ViewGroup parent = (ViewGroup) fragmentView.getParent(); ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) { if (parent != null) {
...@@ -57,11 +58,11 @@ public class BaseFragment { ...@@ -57,11 +58,11 @@ public class BaseFragment {
} }
fragmentView = null; fragmentView = null;
} }
if (parentActivity != null) { if (parentLayout != null) {
if (actionBarLayer != null) { if (actionBarLayer != null) {
actionBarLayer.onDestroy(); actionBarLayer.onDestroy();
} }
actionBarLayer = parentActivity.getInternalActionBar().createLayer(); actionBarLayer = parentLayout.getInternalActionBar().createLayer();
actionBarLayer.parentFragment = this; actionBarLayer.parentFragment = this;
actionBarLayer.setBackgroundResource(R.color.header); actionBarLayer.setBackgroundResource(R.color.header);
actionBarLayer.setItemsBackground(R.drawable.bar_selector); actionBarLayer.setItemsBackground(R.drawable.bar_selector);
...@@ -74,17 +75,17 @@ public class BaseFragment { ...@@ -74,17 +75,17 @@ public class BaseFragment {
} }
public void finishFragment(boolean animated) { public void finishFragment(boolean animated) {
if (isFinished || parentActivity == null) { if (isFinished || parentLayout == null) {
return; return;
} }
parentActivity.closeLastFragment(animated); parentLayout.closeLastFragment(animated);
} }
public void removeSelfFromStack() { public void removeSelfFromStack() {
if (isFinished || parentActivity == null) { if (isFinished || parentLayout == null) {
return; return;
} }
parentActivity.removeFragmentFromStack(this); parentLayout.removeFragmentFromStack(this);
} }
public boolean onFragmentCreate() { public boolean onFragmentCreate() {
...@@ -139,39 +140,39 @@ public class BaseFragment { ...@@ -139,39 +140,39 @@ public class BaseFragment {
} }
public void presentFragment(BaseFragment fragment) { public void presentFragment(BaseFragment fragment) {
if (parentActivity == null) { if (parentLayout == null) {
return; return;
} }
parentActivity.presentFragment(fragment); parentLayout.presentFragment(fragment);
} }
public void presentFragment(BaseFragment fragment, boolean removeLast) { public void presentFragment(BaseFragment fragment, boolean removeLast) {
if (parentActivity == null) { if (parentLayout == null) {
return; return;
} }
parentActivity.presentFragment(fragment, removeLast); parentLayout.presentFragment(fragment, removeLast);
} }
public void presentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation) { public void presentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation) {
if (parentActivity == null) { if (parentLayout == null) {
return; return;
} }
parentActivity.presentFragment(fragment, removeLast, forceWithoutAnimation); parentLayout.presentFragment(fragment, removeLast, forceWithoutAnimation);
} }
public ActionBarActivity getParentActivity() { public Activity getParentActivity() {
return parentActivity; return parentLayout.parentActivity;
} }
public void showActionBar() { public void showActionBar() {
if (parentActivity != null) { if (parentLayout != null) {
parentActivity.showActionBar(); parentLayout.showActionBar();
} }
} }
public void hideActionBar() { public void hideActionBar() {
if (parentActivity != null) { if (parentLayout != null) {
parentActivity.hideActionBar(); parentLayout.hideActionBar();
} }
} }
...@@ -198,7 +199,7 @@ public class BaseFragment { ...@@ -198,7 +199,7 @@ public class BaseFragment {
} }
protected void showAlertDialog(AlertDialog.Builder builder) { protected void showAlertDialog(AlertDialog.Builder builder) {
if (parentActivity == null || parentActivity.checkTransitionAnimation() || parentActivity.animationInProgress || parentActivity.startedTracking) { if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) {
return; return;
} }
try { try {
......
...@@ -451,7 +451,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen ...@@ -451,7 +451,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
} }
emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY)); emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY));
if (sizeNotifierRelativeLayout != null) { if (sizeNotifierRelativeLayout != null) {
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(sizeNotifierRelativeLayout.getWidth(), View.MeasureSpec.EXACTLY)); emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.EXACTLY));
} }
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), 83, 0, 0); emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), 83, 0, 0);
...@@ -585,7 +585,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen ...@@ -585,7 +585,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
if (emojiPopup != null && emojiPopup.isShowing()) { if (emojiPopup != null && emojiPopup.isShowing()) {
WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams)emojiPopup.getContentView().getLayoutParams(); final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams)emojiPopup.getContentView().getLayoutParams();
layoutParams.width = sizeNotifierRelativeLayout.getWidth(); layoutParams.width = AndroidUtilities.displaySize.x;
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
layoutParams.height = keyboardHeightLand; layoutParams.height = keyboardHeightLand;
} else { } else {
......
...@@ -104,7 +104,11 @@ public class EmojiView extends LinearLayout { ...@@ -104,7 +104,11 @@ public class EmojiView extends LinearLayout {
setOrientation(LinearLayout.VERTICAL); setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < Emoji.data.length; i++) { for (int i = 0; i < Emoji.data.length; i++) {
GridView gridView = new GridView(getContext()); GridView gridView = new GridView(getContext());
gridView.setColumnWidth(AndroidUtilities.dpf(45.0f)); if (AndroidUtilities.isTablet()) {
gridView.setColumnWidth(AndroidUtilities.dp(60));
} else {
gridView.setColumnWidth(AndroidUtilities.dp(45));
}
gridView.setNumColumns(-1); gridView.setNumColumns(-1);
views.add(gridView); views.add(gridView);
...@@ -122,7 +126,7 @@ public class EmojiView extends LinearLayout { ...@@ -122,7 +126,7 @@ public class EmojiView extends LinearLayout {
tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorColor(0xff33b5e5);
tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f)); tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f));
tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f));
tabs.setUnderlineColor(1711276032); tabs.setUnderlineColor(0x66000000);
tabs.setTabBackground(0); tabs.setTabBackground(0);
LinearLayout localLinearLayout = new LinearLayout(getContext()); LinearLayout localLinearLayout = new LinearLayout(getContext());
localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
...@@ -138,7 +142,7 @@ public class EmojiView extends LinearLayout { ...@@ -138,7 +142,7 @@ public class EmojiView extends LinearLayout {
} }
} }
}); });
localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT));
recentsWrap = new FrameLayout(getContext()); recentsWrap = new FrameLayout(getContext());
recentsWrap.addView(views.get(0)); recentsWrap.addView(views.get(0));
TextView localTextView = new TextView(getContext()); TextView localTextView = new TextView(getContext());
......
/*
* 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(2));
paint.setAntiAlias(true);
}
public void setColor(int color) {
paint.setColor(color);
}
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);
}
}
...@@ -65,13 +65,13 @@ public class SizeNotifierRelativeLayout extends RelativeLayout { ...@@ -65,13 +65,13 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
if (backgroundDrawable != null) { if (backgroundDrawable != null) {
float scaleX = (float)AndroidUtilities.displaySize.x / (float)backgroundDrawable.getIntrinsicWidth(); float scaleX = (float)getMeasuredWidth() / (float)backgroundDrawable.getIntrinsicWidth();
float scaleY = (float)AndroidUtilities.displaySize.y / (float)backgroundDrawable.getIntrinsicHeight(); float scaleY = (float)getMeasuredHeight() / (float)backgroundDrawable.getIntrinsicHeight();
float scale = scaleX < scaleY ? scaleY : scaleX; float scale = scaleX < scaleY ? scaleY : scaleX;
int width = (int)Math.ceil(backgroundDrawable.getIntrinsicWidth() * scale); int width = (int)Math.ceil(backgroundDrawable.getIntrinsicWidth() * scale);
int height = (int)Math.ceil(backgroundDrawable.getIntrinsicHeight() * scale); int height = (int)Math.ceil(backgroundDrawable.getIntrinsicHeight() * scale);
int x = (AndroidUtilities.displaySize.x - width) / 2; int x = (getMeasuredWidth() - width) / 2;
int y = (AndroidUtilities.displaySize.y - height) / 2; int y = (getMeasuredHeight() - height) / 2;
backgroundDrawable.setBounds(x, y, x + width, y + height); backgroundDrawable.setBounds(x, y, x + width, y + height);
backgroundDrawable.draw(canvas); backgroundDrawable.draw(canvas);
} else { } else {
......
...@@ -22,7 +22,6 @@ import org.telegram.messenger.R; ...@@ -22,7 +22,6 @@ import org.telegram.messenger.R;
public class VideoSeekBarView extends View { public class VideoSeekBarView extends View {
private static Drawable thumbDrawable1; private static Drawable thumbDrawable1;
private static Drawable thumbDrawablePressed1;
private static Paint innerPaint1 = new Paint(); private static Paint innerPaint1 = new Paint();
private static int thumbWidth; private static int thumbWidth;
private static int thumbHeight; private static int thumbHeight;
...@@ -37,8 +36,7 @@ public class VideoSeekBarView extends View { ...@@ -37,8 +36,7 @@ public class VideoSeekBarView extends View {
private void init(Context context) { private void init(Context context) {
if (thumbDrawable1 == null) { if (thumbDrawable1 == null) {
thumbDrawable1 = context.getResources().getDrawable(R.drawable.playback); thumbDrawable1 = context.getResources().getDrawable(R.drawable.videolapse);
thumbDrawablePressed1 = context.getResources().getDrawable(R.drawable.playback_active);
innerPaint1.setColor(0x99999999); innerPaint1.setColor(0x99999999);
thumbWidth = thumbDrawable1.getIntrinsicWidth(); thumbWidth = thumbDrawable1.getIntrinsicWidth();
thumbHeight = thumbDrawable1.getIntrinsicHeight(); thumbHeight = thumbDrawable1.getIntrinsicHeight();
...@@ -118,16 +116,10 @@ public class VideoSeekBarView extends View { ...@@ -118,16 +116,10 @@ public class VideoSeekBarView extends View {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
Drawable thumb = null;
if (!pressed) {
thumb = thumbDrawable1;
} else {
thumb = thumbDrawablePressed1;
}
int y = (getMeasuredHeight() - thumbHeight) / 2; int y = (getMeasuredHeight() - thumbHeight) / 2;
int thumbX = (int)((getMeasuredWidth() - thumbWidth) * progress); int thumbX = (int)((getMeasuredWidth() - thumbWidth) * progress);
canvas.drawRect(thumbWidth / 2, getMeasuredHeight() / 2 - AndroidUtilities.dp(1), getMeasuredWidth() - thumbWidth / 2, getMeasuredHeight() / 2 + AndroidUtilities.dp(1), innerPaint1); canvas.drawRect(thumbWidth / 2, getMeasuredHeight() / 2 - AndroidUtilities.dp(1), getMeasuredWidth() - thumbWidth / 2, getMeasuredHeight() / 2 + AndroidUtilities.dp(1), innerPaint1);
thumb.setBounds(thumbX, y, thumbX + thumbWidth, y + thumbHeight); thumbDrawable1.setBounds(thumbX, y, thumbX + thumbWidth, y + thumbHeight);
thumb.draw(canvas); thumbDrawable1.draw(canvas);
} }
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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