diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index bd3d3a7f4..682d05af2 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -5,7 +5,7 @@ repositories { } dependencies { - compile 'com.android.support:support-v4:23.2.1' + compile 'com.android.support:support-v4:23.3.0' compile "com.google.android.gms:play-services-gcm:8.4.0" compile "com.google.android.gms:play-services-maps:8.4.0" compile 'net.hockeyapp.android:HockeySDK:3.6.+' @@ -14,7 +14,7 @@ dependencies { android { compileSdkVersion 23 - buildToolsVersion '23.0.2' + buildToolsVersion '23.0.3' useLibrary 'org.apache.http.legacy' defaultConfig.applicationId = "org.telegram.messenger" @@ -63,7 +63,7 @@ android { } } - defaultConfig.versionCode = 767 + defaultConfig.versionCode = 787 sourceSets.main { jniLibs.srcDir 'libs' @@ -114,6 +114,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 23 - versionName "3.7.0" + versionName "3.8.1" } } + +apply plugin: 'com.google.gms.google-services' diff --git a/TMessagesProj/google-services.json b/TMessagesProj/google-services.json new file mode 100644 index 000000000..0002195c2 --- /dev/null +++ b/TMessagesProj/google-services.json @@ -0,0 +1,75 @@ +{ + "project_info": { + "project_id": "tmessages2", + "project_number": "760348033671", + "name": "Telegram" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:760348033671:android:f6afd7b67eae3860", + "client_id": "android:org.telegram.messenger", + "client_type": 1, + "android_client_info": { + "package_name": "org.telegram.messenger", + "certificate_hash": [] + } + }, + "oauth_client": [], + "api_key": [], + "services": { + "analytics_service": { + "status": 1 + }, + "cloud_messaging_service": { + "status": 2, + "apns_config": [] + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "google_signin_service": { + "status": 1 + }, + "ads_service": { + "status": 1 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:760348033671:android:dc022572c167a16c", + "client_id": "android:org.telegram.messenger.beta", + "client_type": 1, + "android_client_info": { + "package_name": "org.telegram.messenger.beta", + "certificate_hash": [] + } + }, + "oauth_client": [], + "api_key": [], + "services": { + "analytics_service": { + "status": 1 + }, + "cloud_messaging_service": { + "status": 2, + "apns_config": [] + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "google_signin_service": { + "status": 1 + }, + "ads_service": { + "status": 1 + } + } + } + ], + "client_info": [], + "ARTIFACT_VERSION": "1" +} \ No newline at end of file diff --git a/TMessagesProj/jni/Android.mk b/TMessagesProj/jni/Android.mk index b783ad8eb..e5ca2a519 100755 --- a/TMessagesProj/jni/Android.mk +++ b/TMessagesProj/jni/Android.mk @@ -235,12 +235,12 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := tmessages.20 +LOCAL_MODULE := tmessages.21 LOCAL_CFLAGS := -w -std=c11 -Os -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 += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math -D__STDC_CONSTANT_MACROS LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -Os -funroll-loops -std=c++11 -LOCAL_LDLIBS := -ljnigraphics -llog -lz +LOCAL_LDLIBS := -ljnigraphics -llog -lz -latomic LOCAL_STATIC_LIBRARIES := webp sqlite tgnet breakpad avformat avcodec avutil LOCAL_SRC_FILES := \ diff --git a/TMessagesProj/jni/TgNetWrapper.cpp b/TMessagesProj/jni/TgNetWrapper.cpp index a83920bf4..decb50bd9 100644 --- a/TMessagesProj/jni/TgNetWrapper.cpp +++ b/TMessagesProj/jni/TgNetWrapper.cpp @@ -157,6 +157,10 @@ void setNetworkAvailable(JNIEnv *env, jclass c, jboolean value) { ConnectionsManager::getInstance().setNetworkAvailable(value); } +void setPushConnectionEnabled(JNIEnv *env, jclass c, jboolean value) { + ConnectionsManager::getInstance().setPushConnectionEnabled(value); +} + class Delegate : public ConnectiosManagerDelegate { void onUpdate() { @@ -194,7 +198,7 @@ class Delegate : public ConnectiosManagerDelegate { } }; -void init(JNIEnv *env, jclass c, jint version, jint layer, jint apiId, jstring deviceModel, jstring systemVersion, jstring appVersion, jstring langCode, jstring configPath, jstring logPath, jint userId) { +void init(JNIEnv *env, jclass c, jint version, jint layer, jint apiId, jstring deviceModel, jstring systemVersion, jstring appVersion, jstring langCode, jstring configPath, jstring logPath, jint userId, jboolean enablePushConnection) { const char *deviceModelStr = env->GetStringUTFChars(deviceModel, 0); const char *systemVersionStr = env->GetStringUTFChars(systemVersion, 0); const char *appVersionStr = env->GetStringUTFChars(appVersion, 0); @@ -202,7 +206,7 @@ void init(JNIEnv *env, jclass c, jint version, jint layer, jint apiId, jstring d const char *configPathStr = env->GetStringUTFChars(configPath, 0); const char *logPathStr = env->GetStringUTFChars(logPath, 0); - ConnectionsManager::getInstance().init(version, layer, apiId, std::string(deviceModelStr), std::string(systemVersionStr), std::string(appVersionStr), std::string(langCodeStr), std::string(configPathStr), std::string(logPathStr), userId, true); + ConnectionsManager::getInstance().init(version, layer, apiId, std::string(deviceModelStr), std::string(systemVersionStr), std::string(appVersionStr), std::string(langCodeStr), std::string(configPathStr), std::string(logPathStr), userId, true, enablePushConnection); if (deviceModelStr != 0) { env->ReleaseStringUTFChars(deviceModel, deviceModelStr); @@ -242,13 +246,14 @@ static JNINativeMethod ConnectionsManagerMethods[] = { {"native_applyDatacenterAddress", "(ILjava/lang/String;I)V", (void *) applyDatacenterAddress}, {"native_getConnectionState", "()I", (void *) getConnectionState}, {"native_setUserId", "(I)V", (void *) setUserId}, - {"native_init", "(IIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V", (void *) init}, + {"native_init", "(IIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)V", (void *) init}, {"native_switchBackend", "()V", (void *) switchBackend}, {"native_pauseNetwork", "()V", (void *) pauseNetwork}, {"native_resumeNetwork", "(Z)V", (void *) resumeNetwork}, {"native_updateDcSettings", "()V", (void *) updateDcSettings}, {"native_setUseIpv6", "(Z)V", (void *) setUseIpv6}, {"native_setNetworkAvailable", "(Z)V", (void *) setNetworkAvailable}, + {"native_setPushConnectionEnabled", "(Z)V", (void *) setPushConnectionEnabled}, {"native_setJava", "(Z)V", (void *) setJava} }; diff --git a/TMessagesProj/jni/image.c b/TMessagesProj/jni/image.c index f7a2cfefa..5f1d78dee 100644 --- a/TMessagesProj/jni/image.c +++ b/TMessagesProj/jni/image.c @@ -397,13 +397,13 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_calcCDT(JNIEnv *env, jclass JNIEXPORT int Java_org_telegram_messenger_Utilities_pinBitmap(JNIEnv *env, jclass class, jobject bitmap) { if (bitmap == NULL) { - return; + return 0; } unsigned char *pixels; return AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0 ? 1 : 0; } -JNIEXPORT int Java_org_telegram_messenger_Utilities_unpinBitmap(JNIEnv *env, jclass class, jobject bitmap) { +JNIEXPORT void Java_org_telegram_messenger_Utilities_unpinBitmap(JNIEnv *env, jclass class, jobject bitmap) { if (bitmap == NULL) { return; } diff --git a/TMessagesProj/jni/tgnet/Connection.cpp b/TMessagesProj/jni/tgnet/Connection.cpp index 1a51abe54..9ea752b8d 100644 --- a/TMessagesProj/jni/tgnet/Connection.cpp +++ b/TMessagesProj/jni/tgnet/Connection.cpp @@ -394,7 +394,7 @@ void Connection::onDisconnected(int reason) { ConnectionsManager::getInstance().onConnectionClosed(this); uint32_t datacenterId = currentDatacenter->getDatacenterId(); - if (connectionState == TcpConnectionStageIdle && connectionType == ConnectionTypeGeneric && (datacenterId == ConnectionsManager::getInstance().currentDatacenterId || datacenterId == ConnectionsManager::getInstance().movingToDatacenterId)) { + if (connectionState == TcpConnectionStageIdle && connectionType == ConnectionTypeGeneric && (currentDatacenter->isHandshaking() || datacenterId == ConnectionsManager::getInstance().currentDatacenterId || datacenterId == ConnectionsManager::getInstance().movingToDatacenterId)) { connectionState = TcpConnectionStageReconnecting; failedConnectionCount++; if (failedConnectionCount == 1) { diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 1b8a85b74..3e6f07689 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -170,22 +170,24 @@ void ConnectionsManager::select() { } Datacenter *datacenter = getDatacenterWithId(currentDatacenterId); - if ((sendingPushPing && abs(now - lastPushPingTime) >= 30000) || abs(now - lastPushPingTime) >= 60000 * 3 + 10000) { - lastPushPingTime = 0; - sendingPushPing = false; - if (datacenter != nullptr) { - Connection *connection = datacenter->getPushConnection(false); - if (connection != nullptr) { - connection->suspendConnection(); + if (pushConnectionEnabled) { + if ((sendingPushPing && abs(now - lastPushPingTime) >= 30000) || abs(now - lastPushPingTime) >= 60000 * 3 + 10000) { + lastPushPingTime = 0; + sendingPushPing = false; + if (datacenter != nullptr) { + Connection *connection = datacenter->getPushConnection(false); + if (connection != nullptr) { + connection->suspendConnection(); + } } + DEBUG_D("push ping timeout"); } - DEBUG_D("push ping timeout"); - } - if (abs(now - lastPushPingTime) >= 60000 * 3) { - DEBUG_D("time for push ping"); - lastPushPingTime = now; - if (datacenter != nullptr) { - sendPing(datacenter, true); + if (abs(now - lastPushPingTime) >= 60000 * 3) { + DEBUG_D("time for push ping"); + lastPushPingTime = now; + if (datacenter != nullptr) { + sendPing(datacenter, true); + } } } @@ -220,7 +222,7 @@ void ConnectionsManager::select() { return; } else { lastPauseTime = now; - DEBUG_D("don't sleep 30 seconds because of salt, upload or download request"); + DEBUG_D("don't sleep because of salt, upload or download request"); } } if (networkPaused) { @@ -285,7 +287,7 @@ void *ConnectionsManager::ThreadProc(void *data) { javaVm->AttachCurrentThread(&jniEnv, NULL); #endif ConnectionsManager *networkManager = (ConnectionsManager *) (data); - if (networkManager->currentUserId != 0) { + if (networkManager->currentUserId != 0 && networkManager->pushConnectionEnabled) { Datacenter *datacenter = networkManager->getDatacenterWithId(networkManager->currentDatacenterId); if (datacenter != nullptr) { datacenter->createPushConnection()->setSessionId(networkManager->pushSessionId); @@ -595,7 +597,6 @@ void ConnectionsManager::onConnectionConnected(Connection *connection) { } else { if (networkPaused && lastPauseTime != 0) { lastPauseTime = getCurrentTimeMillis(); - nextSleepTimeout = 30000; } processRequestQueue(connection->getConnectionType(), datacenter->getDatacenterId()); } @@ -1210,7 +1211,6 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag if (connection->connectionType == ConnectionTypePush) { if (networkPaused) { lastPauseTime = getCurrentTimeMillis(); - nextSleepTimeout = 30000; DEBUG_D("received internal push: wakeup network in background"); } else if (lastPauseTime != 0) { lastPauseTime = getCurrentTimeMillis(); @@ -1234,7 +1234,7 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag } void ConnectionsManager::sendPing(Datacenter *datacenter, bool usePushConnection) { - if (usePushConnection && currentUserId == 0) { + if (usePushConnection && (currentUserId == 0 || !usePushConnection)) { return; } Connection *connection = nullptr; @@ -1401,7 +1401,7 @@ void ConnectionsManager::sendRequest(TLObject *object, onCompleteFunc onComplete request->ptr1 = ptr1; request->ptr2 = ptr2; request->rpcRequest = wrapInLayer(object, getDatacenterWithId(datacenterId), request); - DEBUG_D("send request wrapped %p - %s", request->rpcRequest.get(), typeid(*request->rpcRequest.get()).name()); + DEBUG_D("send request wrapped %p - %s", request->rpcRequest.get(), typeid(*(request->rpcRequest.get())).name()); requestsQueue.push_back(std::unique_ptr(request)); if (immediate) { processRequestQueue(0, 0); @@ -1452,7 +1452,7 @@ void ConnectionsManager::setUserId(int32_t userId) { if (currentUserId != userId && userId != 0) { updateDcSettings(0); } - if (currentUserId != 0) { + if (currentUserId != 0 && pushConnectionEnabled) { Datacenter *datacenter = getDatacenterWithId(currentDatacenterId); if (datacenter != nullptr) { datacenter->createPushConnection()->setSessionId(pushSessionId); @@ -2121,7 +2121,7 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t request->outgoingQuery = message->outgoingBody; message->outgoingBody = nullptr; } else { - DEBUG_D("wrap body(%p, %s) to TL_invokeAfterMsg", message->body.get(), typeid(*message->body.get()).name()); + DEBUG_D("wrap body(%p, %s) to TL_invokeAfterMsg", message->body.get(), typeid(*(message->body.get())).name()); request->query = std::move(message->body); } message->body = std::unique_ptr(request); @@ -2390,7 +2390,23 @@ void ConnectionsManager::setDelegate(ConnectiosManagerDelegate *connectiosManage delegate = connectiosManagerDelegate; } -void ConnectionsManager::init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string configPath, std::string logPath, int32_t userId, bool isPaused) { +void ConnectionsManager::setPushConnectionEnabled(bool value) { + pushConnectionEnabled = value; + Datacenter *datacenter = getDatacenterWithId(currentDatacenterId); + if (datacenter != nullptr) { + if (!pushConnectionEnabled) { + Connection *connection = datacenter->getPushConnection(false); + if (connection != nullptr) { + connection->suspendConnection(); + } + } else { + datacenter->createPushConnection()->setSessionId(pushSessionId); + sendPing(datacenter, true); + } + } +} + +void ConnectionsManager::init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string configPath, std::string logPath, int32_t userId, bool isPaused, bool enablePushConnection) { currentVersion = version; currentLayer = layer; currentApiId = apiId; @@ -2401,6 +2417,7 @@ void ConnectionsManager::init(uint32_t version, int32_t layer, int32_t apiId, st currentLangCode = langCode; currentUserId = userId; currentLogPath = logPath; + pushConnectionEnabled = enablePushConnection; if (isPaused) { lastPauseTime = getCurrentTimeMillis(); } @@ -2423,7 +2440,6 @@ void ConnectionsManager::resumeNetwork(bool partial) { if (partial) { if (networkPaused) { lastPauseTime = getCurrentTimeMillis(); - nextSleepTimeout = 30000; networkPaused = false; DEBUG_D("wakeup network in background"); } else if (lastPauseTime != 0) { diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.h b/TMessagesProj/jni/tgnet/ConnectionsManager.h index d389cb32f..ecfad29d1 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.h +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.h @@ -60,8 +60,9 @@ public: void pauseNetwork(); void setNetworkAvailable(bool value); void setUseIpv6(bool value); - void init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string configPath, std::string logPath, int32_t userId, bool isPaused); + void init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string configPath, std::string logPath, int32_t userId, bool isPaused, bool enablePushConnection); void updateDcSettings(uint32_t datacenterId); + void setPushConnectionEnabled(bool value); #ifdef ANDROID void sendRequest(TLObject *object, onCompleteFunc onComplete, onQuickAckFunc onQuickAck, uint32_t flags, uint32_t datacenterId, ConnectionType connetionType, bool immediate, int32_t requestToken, jobject ptr1, jobject ptr2); @@ -133,7 +134,7 @@ private: int32_t lastDcUpdateTime = 0; int64_t lastPingTime = getCurrentTimeMillis(); bool networkPaused = false; - int32_t nextSleepTimeout = 30000; + int32_t nextSleepTimeout = CONNECTION_BACKGROUND_KEEP_TIME; int64_t lastPauseTime = 0; ConnectionState connectionState = ConnectionStateConnecting; std::unique_ptr movingAuthorization; @@ -172,6 +173,7 @@ private: std::string currentLogPath; int32_t currentUserId = 0; bool registeredForInternalPush = false; + bool pushConnectionEnabled = true; ConnectiosManagerDelegate *delegate; diff --git a/TMessagesProj/jni/tgnet/Defines.h b/TMessagesProj/jni/tgnet/Defines.h index 5490180be..168199bdb 100644 --- a/TMessagesProj/jni/tgnet/Defines.h +++ b/TMessagesProj/jni/tgnet/Defines.h @@ -17,10 +17,11 @@ #define USE_DEBUG_SESSION false #define READ_BUFFER_SIZE 1024 * 128 -#define DEBUG_VERSION +//#define DEBUG_VERSION #define DEFAULT_DATACENTER_ID INT_MAX #define DC_UPDATE_TIME 60 * 60 #define DOWNLOAD_CONNECTIONS_COUNT 2 +#define CONNECTION_BACKGROUND_KEEP_TIME 10000 class TLObject; class TL_error; diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index 766336f01..f16acf716 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -213,6 +213,8 @@ + + diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java index c68c62db2..6ab2e575d 100755 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java @@ -77,7 +77,6 @@ public class SQLiteDatabase { close(); } - private StackTraceElement[] temp; public void beginTransaction() throws SQLiteException { if (inTransaction) { throw new SQLiteException("database already in transaction"); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index 4dd43713c..133433214 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -11,7 +11,6 @@ package org.telegram.messenger; import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; -import android.app.PendingIntent; import android.content.ContentUris; import android.content.Context; import android.content.DialogInterface; @@ -20,21 +19,19 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.Cursor; -import android.graphics.BitmapFactory; +import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Typeface; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; -import android.os.Bundle; import android.os.Environment; -import android.os.Parcelable; -import android.provider.Browser; import android.provider.DocumentsContract; import android.provider.MediaStore; -import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; @@ -62,6 +59,7 @@ import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.AnimationCompat.ViewProxy; +import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Components.ForegroundDetector; import org.telegram.ui.Components.NumberPicker; import org.telegram.ui.Components.TypefaceSpan; @@ -129,14 +127,111 @@ public class AndroidUtilities { } } - - static { density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density; leftBaseline = isTablet() ? 80 : 72; checkDisplaySize(); } + public static int[] calcDrawableColor(Drawable drawable) { + int bitmapColor = 0xff000000; + int result[] = new int[2]; + try { + if (drawable instanceof BitmapDrawable) { + Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); + if (bitmap != null) { + Bitmap b = Bitmaps.createScaledBitmap(bitmap, 1, 1, true); + if (b != null) { + bitmapColor = b.getPixel(0, 0); + b.recycle(); + } + } + } else if (drawable instanceof ColorDrawable) { + if (Build.VERSION.SDK_INT >= 11) { + bitmapColor = ((ColorDrawable) drawable).getColor(); + } else { + bitmapColor = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getInt("selectedColor", 0xff000000); + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + double[] hsv = rgbToHsv((bitmapColor >> 16) & 0xff, (bitmapColor >> 8) & 0xff, bitmapColor & 0xff); + hsv[1] = Math.min(1.0, hsv[1] + 0.05 + 0.1 * (1.0 - hsv[1])); + hsv[2] = Math.max(0, hsv[2] * 0.65); + int rgb[] = hsvToRgb(hsv[0], hsv[1], hsv[2]); + result[0] = Color.argb(0x66, rgb[0], rgb[1], rgb[2]); + result[1] = Color.argb(0x88, rgb[0], rgb[1], rgb[2]); + return result; + } + + private static double[] rgbToHsv(int r, int g, int b) { + double rf = r / 255.0; + double gf = g / 255.0; + double bf = b / 255.0; + double max = (rf > gf && rf > bf) ? rf : (gf > bf) ? gf : bf; + double min = (rf < gf && rf < bf) ? rf : (gf < bf) ? gf : bf; + double h, s; + double d = max - min; + s = max == 0 ? 0 : d / max; + if (max == min) { + h = 0; + } else { + if (rf > gf && rf > bf) { + h = (gf - bf) / d + (gf < bf ? 6 : 0); + } else if (gf > bf) { + h = (bf - rf) / d + 2; + } else { + h = (rf - gf) / d + 4; + } + h /= 6; + } + return new double[]{h, s, max}; + } + + private static int[] hsvToRgb(double h, double s, double v) { + double r = 0, g = 0, b = 0; + double i = (int) Math.floor(h * 6); + double f = h * 6 - i; + double p = v * (1 - s); + double q = v * (1 - f * s); + double t = v * (1 - (1 - f) * s); + switch ((int) i % 6) { + case 0: + r = v; + g = t; + b = p; + break; + case 1: + r = q; + g = v; + b = p; + break; + case 2: + r = p; + g = v; + b = t; + break; + case 3: + r = p; + g = q; + b = v; + break; + case 4: + r = t; + g = p; + b = v; + break; + case 5: + r = v; + g = p; + b = q; + break; + } + return new int[]{(int) (r * 255), (int) (g * 255), (int) (b * 255)}; + } + public static void requestAdjustResize(Activity activity, int classGuid) { if (activity == null || isTablet()) { return; @@ -154,8 +249,36 @@ public class AndroidUtilities { } } + public static boolean isGoogleMapsInstalled(final BaseFragment fragment) { + try { + ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0); + return true; + } catch (PackageManager.NameNotFoundException e) { + if (fragment.getParentActivity() == null) { + return false; + } + AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity()); + builder.setMessage("Install Google Maps?"); + builder.setCancelable(true); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + try { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps")); + fragment.getParentActivity().startActivityForResult(intent, 500); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + fragment.showDialog(builder.create()); + return false; + } + } + public static void lockOrientation(Activity activity) { - if (activity == null || prevOrientation != -10 || Build.VERSION.SDK_INT < 9) { + if (activity == null || prevOrientation != -10) { return; } try { @@ -164,22 +287,16 @@ public class AndroidUtilities { if (manager != null && manager.getDefaultDisplay() != null) { int rotation = manager.getDefaultDisplay().getRotation(); int orientation = activity.getResources().getConfiguration().orientation; - int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8; - int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9; - if (Build.VERSION.SDK_INT < 9) { - SCREEN_ORIENTATION_REVERSE_LANDSCAPE = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; - SCREEN_ORIENTATION_REVERSE_PORTRAIT = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; - } if (rotation == Surface.ROTATION_270) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { - activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_LANDSCAPE); + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } } else if (rotation == Surface.ROTATION_90) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { - activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_PORTRAIT); + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } @@ -191,9 +308,9 @@ public class AndroidUtilities { } } else { if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_LANDSCAPE); + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else { - activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_PORTRAIT); + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } } } @@ -203,7 +320,7 @@ public class AndroidUtilities { } public static void unlockOrientation(Activity activity) { - if (activity == null || Build.VERSION.SDK_INT < 9) { + if (activity == null) { return; } try { @@ -430,46 +547,6 @@ public class AndroidUtilities { } } - public static void openUrl(Context context, String url) { - if (context == null || url == null) { - return; - } - openUrl(context, Uri.parse(url)); - } - - public static void openUrl(Context context, Uri uri) { - if (context == null || uri == null) { - return; - } - - try { - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - if (MediaController.getInstance().canCustomTabs()) { - intent.putExtra("android.support.customtabs.extra.SESSION", (Parcelable) null); - intent.putExtra("android.support.customtabs.extra.TOOLBAR_COLOR", 0xff54759e); - intent.putExtra("android.support.customtabs.extra.TITLE_VISIBILITY", 1); - - Intent actionIntent = new Intent(Intent.ACTION_SEND); - actionIntent.setType("text/plain"); - actionIntent.putExtra(Intent.EXTRA_TEXT, uri.toString()); - actionIntent.putExtra(Intent.EXTRA_SUBJECT, ""); - PendingIntent pendingIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, actionIntent, PendingIntent.FLAG_ONE_SHOT); - - Bundle bundle = new Bundle(); - bundle.putInt("android.support.customtabs.customaction.ID", 0); - bundle.putParcelable("android.support.customtabs.customaction.ICON", BitmapFactory.decodeResource(context.getResources(), R.drawable.abc_ic_menu_share_mtrl_alpha)); - bundle.putString("android.support.customtabs.customaction.DESCRIPTION", LocaleController.getString("ShareFile", R.string.ShareFile)); - bundle.putParcelable("android.support.customtabs.customaction.PENDING_INTENT", pendingIntent); - intent.putExtra("android.support.customtabs.extra.ACTION_BUTTON_BUNDLE", bundle); - intent.putExtra("android.support.customtabs.extra.TINT_ACTION_BUTTON", false); - } - intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); - context.startActivity(intent); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - public static int getPhotoSize() { if (photoSize == null) { if (Build.VERSION.SDK_INT >= 16) { @@ -685,11 +762,11 @@ public class AndroidUtilities { public static final int FLAG_TAG_COLOR = 4; public static final int FLAG_TAG_ALL = FLAG_TAG_BR | FLAG_TAG_BOLD | FLAG_TAG_COLOR; - public static Spannable replaceTags(String str) { + public static SpannableStringBuilder replaceTags(String str) { return replaceTags(str, FLAG_TAG_ALL); } - public static Spannable replaceTags(String str, int flag) { + public static SpannableStringBuilder replaceTags(String str, int flag) { try { int start; int end; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index 944477f0d..6ed4862d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -20,6 +20,9 @@ import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.res.Configuration; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Build; @@ -37,8 +40,6 @@ import org.telegram.ui.Components.ForegroundDetector; import java.io.File; import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.Locale; public class ApplicationLoader extends Application { @@ -47,6 +48,9 @@ public class ApplicationLoader extends Application { private static boolean isCustomTheme; private static final Object sync = new Object(); + private static int serviceMessageColor; + private static int serviceSelectedMessageColor; + public static volatile Context applicationContext; public static volatile Handler applicationHandler; private static volatile boolean applicationInited = false; @@ -64,9 +68,27 @@ public class ApplicationLoader extends Application { public static void reloadWallpaper() { cachedWallpaper = null; + serviceMessageColor = 0; + ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit().remove("serviceMessageColor").commit(); loadWallpaper(); } + private static void calcBackgroundColor() { + int result[] = AndroidUtilities.calcDrawableColor(cachedWallpaper); + serviceMessageColor = result[0]; + serviceSelectedMessageColor = result[1]; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + preferences.edit().putInt("serviceMessageColor", serviceMessageColor).putInt("serviceSelectedMessageColor", serviceSelectedMessageColor).commit(); + } + + public static int getServiceMessageColor() { + return serviceMessageColor; + } + + public static int getServiceSelectedMessageColor() { + return serviceSelectedMessageColor; + } + public static void loadWallpaper() { if (cachedWallpaper != null) { return; @@ -80,6 +102,8 @@ public class ApplicationLoader extends Application { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int selectedBackground = preferences.getInt("selectedBackground", 1000001); selectedColor = preferences.getInt("selectedColor", 0); + serviceMessageColor = preferences.getInt("serviceMessageColor", 0); + serviceSelectedMessageColor = preferences.getInt("serviceSelectedMessageColor", 0); if (selectedColor == 0) { if (selectedBackground == 1000001) { cachedWallpaper = applicationContext.getResources().getDrawable(R.drawable.background_hd); @@ -104,6 +128,9 @@ public class ApplicationLoader extends Application { } cachedWallpaper = new ColorDrawable(selectedColor); } + if (serviceMessageColor == 0) { + calcBackgroundColor(); + } } } }); @@ -215,7 +242,7 @@ public class ApplicationLoader extends Application { String configPath = getFilesDirFixed().toString(); try { - langCode = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + langCode = LocaleController.getLocaleStringIso639(); deviceModel = Build.MANUFACTURER + Build.MODEL; PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); appVersion = pInfo.versionName + " (" + pInfo.versionCode + ")"; @@ -239,8 +266,11 @@ public class ApplicationLoader extends Application { systemVersion = "SDK Unknown"; } + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + boolean enablePushConnection = preferences.getBoolean("pushConnection", true); + MessagesController.getInstance(); - ConnectionsManager.getInstance().init(BuildVars.BUILD_VERSION, TLRPC.LAYER, BuildVars.APP_ID, deviceModel, systemVersion, appVersion, langCode, configPath, FileLog.getNetworkLogPath(), UserConfig.getClientUserId()); + ConnectionsManager.getInstance().init(BuildVars.BUILD_VERSION, TLRPC.LAYER, BuildVars.APP_ID, deviceModel, systemVersion, appVersion, langCode, configPath, FileLog.getNetworkLogPath(), UserConfig.getClientUserId(), enablePushConnection); if (UserConfig.getCurrentUser() != null) { MessagesController.getInstance().putUser(UserConfig.getCurrentUser(), true); ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone); @@ -323,13 +353,18 @@ public class ApplicationLoader extends Application { @Override public void run() { if (checkPlayServices()) { - if (UserConfig.pushString == null || UserConfig.pushString.length() == 0) { + if (UserConfig.pushString != null && UserConfig.pushString.length() != 0) { + FileLog.d("tmessages", "GCM regId = " + UserConfig.pushString); + } else { FileLog.d("tmessages", "GCM Registration not found."); + } + + //if (UserConfig.pushString == null || UserConfig.pushString.length() == 0) { Intent intent = new Intent(applicationContext, GcmRegistrationIntentService.class); startService(intent); - } else { - FileLog.d("tmessages", "GCM regId = " + UserConfig.pushString); - } + //} else { + // FileLog.d("tmessages", "GCM regId = " + UserConfig.pushString); + //} } else { FileLog.d("tmessages", "No valid Google Play Services APK found."); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageHeardReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageHeardReceiver.java index dd3baa741..a00576b78 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageHeardReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageHeardReceiver.java @@ -16,6 +16,7 @@ public class AutoMessageHeardReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + ApplicationLoader.postInitApplication(); long dialog_id = intent.getLongExtra("dialog_id", 0); int max_id = intent.getIntExtra("max_id", 0); if (dialog_id == 0 || max_id == 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageReplyReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageReplyReceiver.java index ba91e0f0a..1635bd37b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageReplyReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageReplyReceiver.java @@ -18,6 +18,7 @@ public class AutoMessageReplyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + ApplicationLoader.postInitApplication(); Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) { return; @@ -31,7 +32,7 @@ public class AutoMessageReplyReceiver extends BroadcastReceiver { if (dialog_id == 0 || max_id == 0) { return; } - SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false, null, null); + SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false, null, null, null); MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false); } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 74e2ab8aa..347eef541 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -10,8 +10,8 @@ package org.telegram.messenger; public class BuildVars { public static boolean DEBUG_VERSION = false; - public static int BUILD_VERSION = 767; - public static String BUILD_VERSION_STRING = "3.7"; + public static int BUILD_VERSION = 787; + public static String BUILD_VERSION_STRING = "3.8"; public static int APP_ID = 0; //obtain your own APP_ID at https://core.telegram.org/api/obtaining_api_id public static String APP_HASH = ""; //obtain your own APP_HASH at https://core.telegram.org/api/obtaining_api_id public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ClearCacheService.java b/TMessagesProj/src/main/java/org/telegram/messenger/ClearCacheService.java index 044f80dcc..fb45992d5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ClearCacheService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ClearCacheService.java @@ -27,6 +27,8 @@ public class ClearCacheService extends IntentService { @Override protected void onHandleIntent(Intent intent) { + ApplicationLoader.postInitApplication(); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); final int keepMedia = preferences.getInt("keep_media", 2); if (keepMedia == 2) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java index 4831c12b5..376ba2ede 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java @@ -173,7 +173,7 @@ public class ContactsController { if (!updatingInviteText && (inviteText == null || time + 86400 < (int)(System.currentTimeMillis() / 1000))) { updatingInviteText = true; TLRPC.TL_help_getInviteText req = new TLRPC.TL_help_getInviteText(); - req.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + req.lang_code = LocaleController.getLocaleStringIso639(); if (req.lang_code.length() == 0) { req.lang_code = "en"; } @@ -1652,7 +1652,8 @@ public class ContactsController { } }*/ - for (final TLRPC.User u : res.users) { + for (int a = 0; a < res.users.size(); a++) { + final TLRPC.User u = res.users.get(a); Utilities.phoneBookQueue.postRunnable(new Runnable() { @Override public void run() { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java index 420b76718..2521e1d22 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -115,7 +115,7 @@ public class FileLoadOperation { } ext = FileLoader.getDocumentFileName(documentLocation); int idx; - if (ext == null || (idx = ext.lastIndexOf(".")) == -1) { + if (ext == null || (idx = ext.lastIndexOf('.')) == -1) { ext = ""; } else { ext = ext.substring(idx); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index a902ad76f..f07c29e17 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -593,7 +593,9 @@ public class FileLoader { } } } else if (message.media instanceof TLRPC.TL_messageMediaWebPage) { - if (message.media.webpage.photo != null) { + if (message.media.webpage.document != null) { + return getPathToAttach(message.media.webpage.document); + } else if (message.media.webpage.photo != null) { ArrayList sizes = message.media.webpage.photo.sizes; if (sizes.size() > 0) { TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize()); @@ -601,8 +603,6 @@ public class FileLoader { return getPathToAttach(sizeFull); } } - } else if (message.media.webpage.document != null) { - return getPathToAttach(message.media.webpage.document); } } } @@ -667,7 +667,8 @@ public class FileLoader { } int lastSide = 0; TLRPC.PhotoSize closestObject = null; - for (TLRPC.PhotoSize obj : sizes) { + for (int a = 0; a < sizes.size(); a++) { + TLRPC.PhotoSize obj = sizes.get(a); if (obj == null) { continue; } @@ -691,7 +692,7 @@ public class FileLoader { public static String getFileExtension(File file) { String name = file.getName(); try { - return name.substring(name.lastIndexOf(".") + 1); + return name.substring(name.lastIndexOf('.') + 1); } catch (Exception e) { return ""; } @@ -714,7 +715,7 @@ public class FileLoader { public static String getDocumentExtension(TLRPC.Document document) { String fileName = getDocumentFileName(document); - int idx = fileName.lastIndexOf("."); + int idx = fileName.lastIndexOf('.'); String ext = null; if (idx != -1) { ext = fileName.substring(idx + 1); @@ -740,7 +741,7 @@ public class FileLoader { if (docExt == null) { docExt = getDocumentFileName(document); int idx; - if (docExt == null || (idx = docExt.lastIndexOf(".")) == -1) { + if (docExt == null || (idx = docExt.lastIndexOf('.')) == -1) { docExt = ""; } else { docExt = docExt.substring(idx); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java index f39780957..6f0b6dc6c 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java @@ -138,8 +138,8 @@ public class FileLog { try { getInstance().streamWriter.write(getInstance().dateFormat.format(System.currentTimeMillis()) + " E/" + tag + "﹕ " + e + "\n"); StackTraceElement[] stack = e.getStackTrace(); - for (StackTraceElement el : stack) { - getInstance().streamWriter.write(getInstance().dateFormat.format(System.currentTimeMillis()) + " E/" + tag + "﹕ " + el + "\n"); + for (int a = 0; a < stack.length; a++) { + getInstance().streamWriter.write(getInstance().dateFormat.format(System.currentTimeMillis()) + " E/" + tag + "﹕ " + stack[a] + "\n"); } getInstance().streamWriter.flush(); } catch (Exception e) { @@ -194,6 +194,9 @@ public class FileLog { public static void cleanupLogs() { File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null); + if (sdCard == null) { + return; + } File dir = new File (sdCard.getAbsolutePath() + "/logs"); File[] files = dir.listFiles(); if (files != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java b/TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java index f683a7251..e02a2d1e5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java @@ -46,6 +46,7 @@ public class GcmPushListenerService extends GcmListenerService { FileLog.e("tmessages", e); } + ConnectionsManager.onInternalPushReceived(); ConnectionsManager.getInstance().resumeNetworkMaybe(); } }); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/GcmRegistrationIntentService.java b/TMessagesProj/src/main/java/org/telegram/messenger/GcmRegistrationIntentService.java index c135cce48..f99e711f5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/GcmRegistrationIntentService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/GcmRegistrationIntentService.java @@ -24,9 +24,15 @@ public class GcmRegistrationIntentService extends IntentService { protected void onHandleIntent(Intent intent) { try { InstanceID instanceID = InstanceID.getInstance(this); - String token = instanceID.getToken(BuildVars.GCM_SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); + final String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); FileLog.d("tmessages", "GCM Registration Token: " + token); - sendRegistrationToServer(token); + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + ApplicationLoader.postInitApplication(); + sendRegistrationToServer(token); + } + }); } catch (Exception e) { FileLog.e("tmessages", e); final int failCount = intent.getIntExtra("failCount", 0); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java index 52d87aa35..079514d34 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java @@ -1809,7 +1809,7 @@ public class ImageLoader { key = document.dc_id + "_" + document.id; String docExt = FileLoader.getDocumentFileName(document); int idx; - if (docExt == null || (idx = docExt.lastIndexOf(".")) == -1) { + if (docExt == null || (idx = docExt.lastIndexOf('.')) == -1) { docExt = ""; } else { docExt = docExt.substring(idx); @@ -1946,21 +1946,12 @@ public class ImageLoader { } } - public void loadHttpFile(String url, String extension) { + public void loadHttpFile(String url, String defaultExt) { if (url == null || url.length() == 0 || httpFileLoadTasksByKeys.containsKey(url)) { return; } - String ext = extension; - if (ext == null) { - int idx = url.lastIndexOf("."); - if (idx != -1) { - ext = url.substring(idx + 1); - } - if (ext == null || ext.length() == 0 || ext.length() > 4) { - ext = "jpg"; - } - } - File file = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(url) + "_temp." + getHttpUrlExtension(url, extension)); + String ext = getHttpUrlExtension(url, defaultExt); + File file = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(url) + "_temp." + ext); file.delete(); HttpFileTask task = new HttpFileTask(url, file, ext); @@ -2276,7 +2267,7 @@ public class ImageLoader { public static String getHttpUrlExtension(String url, String defaultExt) { String ext = null; - int idx = url.lastIndexOf("."); + int idx = url.lastIndexOf('.'); if (idx != -1) { ext = url.substring(idx + 1); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java index 340d5f120..b7d156e08 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java @@ -50,6 +50,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg private Integer thumbTag; private MessageObject parentMessageObject; private boolean canceledLoading; + private static PorterDuffColorFilter selectedColorFilter = new PorterDuffColorFilter(0xffdddddd, PorterDuff.Mode.MULTIPLY); private SetImageBackup setImageBackup; @@ -79,10 +80,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg private boolean forcePreview; private int roundRadius; private BitmapShader bitmapShader; - private Paint roundPaint; - private RectF roundRect; - private RectF bitmapRect; - private Matrix shaderMatrix; + private BitmapShader bitmapShaderThumb; + private static Paint roundPaint; + private RectF roundRect = new RectF(); + private RectF bitmapRect = new RectF(); + private Matrix shaderMatrix = new Matrix(); private float overrideAlpha = 1.0f; private boolean isPressed; private int orientation; @@ -95,11 +97,14 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg private ColorFilter colorFilter; public ImageReceiver() { - + this(null); } public ImageReceiver(View view) { parentView = view; + if (roundPaint == null) { + roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + } } public void cancelLoadImage() { @@ -156,6 +161,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg currentSize = 0; currentImage = null; bitmapShader = null; + bitmapShaderThumb = null; ImageLoader.getInstance().cancelLoadingForImageReceiver(this, 0); if (parentView != null) { if (invalidateAll) { @@ -228,6 +234,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg currentThumbLocation = thumbLocation; staticThumb = thumb; bitmapShader = null; + bitmapShaderThumb = null; currentAlpha = 1.0f; if (delegate != null) { @@ -300,6 +307,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg currentSize = 0; currentCacheOnly = false; bitmapShader = null; + bitmapShaderThumb = null; if (setImageBackup != null) { setImageBackup.fileLocation = null; setImageBackup.httpUrl = null; @@ -356,33 +364,40 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg return false; } - private void drawDrawable(Canvas canvas, Drawable drawable, int alpha) { + private void drawDrawable(Canvas canvas, Drawable drawable, int alpha, BitmapShader shader) { if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; - Paint paint = bitmapDrawable.getPaint(); + Paint paint; + if (shader != null) { + paint = roundPaint; + } else { + paint = bitmapDrawable.getPaint(); + } boolean hasFilter = paint != null && paint.getColorFilter() != null; if (hasFilter && !isPressed) { - bitmapDrawable.setColorFilter(null); + if (shader != null) { + roundPaint.setColorFilter(null); + } else { + bitmapDrawable.setColorFilter(null); + } } else if (!hasFilter && isPressed) { - bitmapDrawable.setColorFilter(new PorterDuffColorFilter(0xffdddddd, PorterDuff.Mode.MULTIPLY)); + if (shader != null) { + roundPaint.setColorFilter(selectedColorFilter); + } else { + bitmapDrawable.setColorFilter(selectedColorFilter); + } } if (colorFilter != null) { - bitmapDrawable.setColorFilter(colorFilter); - } - if (bitmapShader != null) { - drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); - if (isVisible) { - roundRect.set(drawRegion); - shaderMatrix.reset(); - shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL); - bitmapShader.setLocalMatrix(shaderMatrix); - roundPaint.setAlpha(alpha); - canvas.drawRoundRect(roundRect, roundRadius, roundRadius, roundPaint); + if (shader != null) { + roundPaint.setColorFilter(colorFilter); + } else { + bitmapDrawable.setColorFilter(colorFilter); } - } else { - int bitmapW; - int bitmapH; + } + int bitmapW; + int bitmapH; + if (bitmapDrawable instanceof AnimatedFileDrawable) { if (orientation % 360 == 90 || orientation % 360 == 270) { bitmapW = bitmapDrawable.getIntrinsicHeight(); bitmapH = bitmapDrawable.getIntrinsicWidth(); @@ -390,9 +405,47 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg bitmapW = bitmapDrawable.getIntrinsicWidth(); bitmapH = bitmapDrawable.getIntrinsicHeight(); } - float scaleW = bitmapW / (float) imageW; - float scaleH = bitmapH / (float) imageH; + } else { + if (orientation % 360 == 90 || orientation % 360 == 270) { + bitmapW = bitmapDrawable.getBitmap().getHeight(); + bitmapH = bitmapDrawable.getBitmap().getWidth(); + } else { + bitmapW = bitmapDrawable.getBitmap().getWidth(); + bitmapH = bitmapDrawable.getBitmap().getHeight(); + } + } + float scaleW = bitmapW / (float) imageW; + float scaleH = bitmapH / (float) imageH; + if (shader != null) { + roundPaint.setShader(shader); + float scale = Math.min(scaleW, scaleH); + roundRect.set(imageX, imageY, imageX + imageW, imageY + imageH); + shaderMatrix.reset(); + if (Math.abs(scaleW - scaleH) > 0.00001f) { + if (bitmapW / scaleH > imageW) { + drawRegion.set(imageX - ((int) (bitmapW / scaleH) - imageW) / 2, imageY, imageX + ((int) (bitmapW / scaleH) + imageW) / 2, imageY + imageH); + } else { + drawRegion.set(imageX, imageY - ((int) (bitmapH / scaleW) - imageH) / 2, imageX + imageW, imageY + ((int) (bitmapH / scaleW) + imageH) / 2); + } + } else { + drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); + } + if (isVisible) { + if (Math.abs(scaleW - scaleH) > 0.00001f) { + int w = (int) Math.floor(imageW * scale); + int h = (int) Math.floor(imageH * scale); + bitmapRect.set((bitmapW - w) / 2, (bitmapH - h) / 2, (bitmapW + w) / 2, (bitmapH + h) / 2); + shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.START); + } else { + bitmapRect.set(0, 0, bitmapW, bitmapH); + shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL); + } + shader.setLocalMatrix(shaderMatrix); + roundPaint.setAlpha(alpha); + canvas.drawRoundRect(roundRect, roundRadius, roundRadius, roundPaint); + } + } else { if (isAspectFit) { float scale = Math.max(scaleW, scaleH); canvas.save(); @@ -428,12 +481,16 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } } - if (bitmapW / scaleH > imageW) { - bitmapW /= scaleH; - drawRegion.set(imageX - (bitmapW - imageW) / 2, imageY, imageX + (bitmapW + imageW) / 2, imageY + imageH); + if (bitmapDrawable instanceof AnimatedFileDrawable) { + drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH); } else { - bitmapH /= scaleW; - drawRegion.set(imageX, imageY - (bitmapH - imageH) / 2, imageX + imageW, imageY + (bitmapH + imageH) / 2); + if (bitmapW / scaleH > imageW) { + bitmapW /= scaleH; + drawRegion.set(imageX - (bitmapW - imageW) / 2, imageY, imageX + (bitmapW + imageW) / 2, imageY + imageH); + } else { + bitmapH /= scaleW; + drawRegion.set(imageX, imageY - (bitmapH - imageH) / 2, imageX + imageW, imageY + (bitmapH + imageH) / 2); + } } if (orientation % 360 == 90 || orientation % 360 == 270) { int width = (drawRegion.right - drawRegion.left) / 2; @@ -519,7 +576,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg if (currentAlpha != 1) { if (!skip) { long currentTime = System.currentTimeMillis(); - currentAlpha += (currentTime - lastUpdateAlphaTime) / 150.0f; + long dt = currentTime - lastUpdateAlphaTime; + if (dt > 18) { + dt = 18; + } + currentAlpha += dt / 150.0f; if (currentAlpha > 1) { currentAlpha = 1; } @@ -539,17 +600,20 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg try { Drawable drawable = null; boolean animationNotReady = currentImage instanceof AnimatedFileDrawable && !((AnimatedFileDrawable) currentImage).hasBitmap(); + boolean isThumb = false; if (!forcePreview && currentImage != null && !animationNotReady) { drawable = currentImage; } else if (staticThumb instanceof BitmapDrawable) { drawable = staticThumb; + isThumb = true; } else if (currentThumb != null) { drawable = currentThumb; + isThumb = true; } if (drawable != null) { if (crossfadeAlpha != 0) { if (crossfadeWithThumb && animationNotReady) { - drawDrawable(canvas, drawable, (int) (overrideAlpha * 255)); + drawDrawable(canvas, drawable, (int) (overrideAlpha * 255), bitmapShaderThumb); } else { if (crossfadeWithThumb && currentAlpha != 1.0f) { Drawable thumbDrawable = null; @@ -565,19 +629,19 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg } } if (thumbDrawable != null) { - drawDrawable(canvas, thumbDrawable, (int) (overrideAlpha * 255)); + drawDrawable(canvas, thumbDrawable, (int) (overrideAlpha * 255), bitmapShaderThumb); } } - drawDrawable(canvas, drawable, (int) (overrideAlpha * currentAlpha * 255)); + drawDrawable(canvas, drawable, (int) (overrideAlpha * currentAlpha * 255), isThumb ? bitmapShaderThumb : bitmapShader); } } else { - drawDrawable(canvas, drawable, (int) (overrideAlpha * 255)); + drawDrawable(canvas, drawable, (int) (overrideAlpha * 255), isThumb ? bitmapShaderThumb : bitmapShader); } checkAlphaAnimation(animationNotReady && crossfadeWithThumb); return true; } else if (staticThumb != null) { - drawDrawable(canvas, staticThumb, 255); + drawDrawable(canvas, staticThumb, 255, null); checkAlphaAnimation(animationNotReady); return true; } else { @@ -753,19 +817,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg public void setRoundRadius(int value) { roundRadius = value; - if (roundRadius != 0) { - if (roundPaint == null) { - roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - roundRect = new RectF(); - shaderMatrix = new Matrix(); - bitmapRect = new RectF(); - } - } else { - roundPaint = null; - roundRect = null; - shaderMatrix = null; - bitmapRect = null; - } } public int getRoundRadius() { @@ -853,11 +904,15 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg ImageLoader.getInstance().incrementUseCount(currentKey); } currentImage = bitmap; - if (roundRadius != 0) { - Bitmap object = bitmap.getBitmap(); - bitmapShader = new BitmapShader(object, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); - roundPaint.setShader(bitmapShader); - bitmapRect.set(0, 0, object.getWidth(), object.getHeight()); + if (roundRadius != 0 && bitmap instanceof BitmapDrawable) { + if (bitmap instanceof AnimatedFileDrawable) { + ((AnimatedFileDrawable) bitmap).setRoundRadius(roundRadius); + } else { + Bitmap object = bitmap.getBitmap(); + bitmapShader = new BitmapShader(object, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + } + } else { + bitmapShader = null; } if (!memCache && !forcePreview) { @@ -892,6 +947,17 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg currentThumb = bitmap; + if (roundRadius != 0 && currentImage == null && bitmap instanceof BitmapDrawable) { + if (bitmap instanceof AnimatedFileDrawable) { + ((AnimatedFileDrawable) bitmap).setRoundRadius(roundRadius); + } else { + Bitmap object = bitmap.getBitmap(); + bitmapShaderThumb = new BitmapShader(object, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + } + } else { + bitmapShaderThumb = null; + } + if (!memCache && crossfadeAlpha != 2) { currentAlpha = 0.0f; lastUpdateAlphaTime = System.currentTimeMillis(); @@ -961,6 +1027,12 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg ImageLoader.getInstance().incrementUseCount(currentThumbKey); } currentThumb = (BitmapDrawable) args[0]; + if (roundRadius != 0 && currentImage == null && currentThumb instanceof BitmapDrawable && !(currentThumb instanceof AnimatedFileDrawable)) { + Bitmap object = ((BitmapDrawable) currentThumb).getBitmap(); + bitmapShaderThumb = new BitmapShader(object, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + } else { + bitmapShaderThumb = null; + } if (staticThumb instanceof BitmapDrawable) { staticThumb = null; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java index 1968f81e6..a34e0a076 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java @@ -309,7 +309,31 @@ public class LocaleController { return systemDefaultLocale; } - public static String getLocaleString(Locale locale) { + private String getLocaleString(Locale locale) { + if (locale == null) { + return "en"; + } + String languageCode = locale.getLanguage(); + String countryCode = locale.getCountry(); + String variantCode = locale.getVariant(); + if (languageCode.length() == 0 && countryCode.length() == 0) { + return "en"; + } + StringBuilder result = new StringBuilder(11); + result.append(languageCode); + if (countryCode.length() > 0 || variantCode.length() > 0) { + result.append('_'); + } + result.append(countryCode); + if (variantCode.length() > 0) { + result.append('_'); + } + result.append(variantCode); + return result.toString(); + } + + public static String getLocaleStringIso639() { + Locale locale = getInstance().getSystemDefaultLocale(); if (locale == null) { return "en"; } @@ -583,7 +607,11 @@ public class LocaleController { private String getStringInternal(String key, int res) { String value = localeValues.get(key); if (value == null) { - value = ApplicationLoader.applicationContext.getString(res); + try { + value = ApplicationLoader.applicationContext.getString(res); + } catch (Exception e) { + FileLog.e("tmessages", e); + } } if (value == null) { value = "LOC_ERR:" + key; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index b3b8517c4..ef7b89218 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -12,6 +12,7 @@ import android.Manifest; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; +import android.app.DownloadManager; import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -236,7 +237,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, private float[] gravityFast = new float[3]; private float[] linearAcceleration = new float[3]; - private boolean hasAudioFocus; + private int hasAudioFocus; private boolean callInProgress; private ArrayList videoConvertQueue = new ArrayList<>(); @@ -279,6 +280,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, public static AlbumEntry allPhotosAlbumEntry; private HashMap>> loadingFileObservers = new HashMap<>(); + private HashMap> loadingFileMessagesObservers = new HashMap<>(); private HashMap observersByTag = new HashMap<>(); private boolean listenerInProgress = false; private HashMap addLaterArray = new HashMap<>(); @@ -694,7 +696,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (MediaController.getInstance().isPlayingAudio(MediaController.getInstance().getPlayingMessageObject()) && !MediaController.getInstance().isAudioPaused()) { MediaController.getInstance().pauseAudio(MediaController.getInstance().getPlayingMessageObject()); } - hasAudioFocus = false; + hasAudioFocus = 0; } else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) { //MediaController.getInstance().playAudio(MediaController.getInstance().getPlayingMessageObject()); } @@ -1161,6 +1163,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } public void addLoadingFileObserver(String fileName, FileDownloadProgressListener observer) { + addLoadingFileObserver(fileName, null, observer); + } + + public void addLoadingFileObserver(String fileName, MessageObject messageObject, FileDownloadProgressListener observer) { if (listenerInProgress) { addLaterArray.put(fileName, observer); return; @@ -1173,6 +1179,14 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, loadingFileObservers.put(fileName, arrayList); } arrayList.add(new WeakReference<>(observer)); + if (messageObject != null) { + ArrayList messageObjects = loadingFileMessagesObservers.get(fileName); + if (messageObjects == null) { + messageObjects = new ArrayList<>(); + loadingFileMessagesObservers.put(fileName, messageObjects); + } + messageObjects.add(messageObject); + } observersByTag.put(observer.getObserverTag(), fileName); } @@ -1203,7 +1217,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, private void processLaterArrays() { for (HashMap.Entry listener : addLaterArray.entrySet()) { - addLoadingFileObserver(listener.getKey(), listener.getValue()); + addLoadingFileObserver(listener.getKey(), listener.getValue()); //TODO } addLaterArray.clear(); for (FileDownloadProgressListener listener : deleteLaterArray) { @@ -1218,9 +1232,11 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (id == NotificationCenter.FileDidFailedLoad) { listenerInProgress = true; String fileName = (String) args[0]; + loadingFileMessagesObservers.get(fileName); ArrayList> arrayList = loadingFileObservers.get(fileName); if (arrayList != null) { - for (WeakReference reference : arrayList) { + for (int a = 0; a < arrayList.size(); a++) { + WeakReference reference = arrayList.get(a); if (reference.get() != null) { reference.get().onFailedDownload(fileName); observersByTag.remove(reference.get().getObserverTag()); @@ -1235,15 +1251,24 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, listenerInProgress = true; String fileName = (String) args[0]; if (downloadingCurrentMessage && playingMessageObject != null) { - String file = FileLoader.getAttachFileName(playingMessageObject.messageOwner.media.document); + String file = FileLoader.getAttachFileName(playingMessageObject.getDocument()); if (file.equals(fileName)) { playMusicAgain = true; playAudio(playingMessageObject); } } + ArrayList messageObjects = loadingFileMessagesObservers.get(fileName); + if (messageObjects != null) { + for (int a = 0; a < messageObjects.size(); a++) { + MessageObject messageObject = messageObjects.get(a); + messageObject.mediaExists = true; + } + loadingFileMessagesObservers.remove(fileName); + } ArrayList> arrayList = loadingFileObservers.get(fileName); if (arrayList != null) { - for (WeakReference reference : arrayList) { + for (int a = 0; a < arrayList.size(); a++) { + WeakReference reference = arrayList.get(a); if (reference.get() != null) { reference.get().onSuccessDownload(fileName); observersByTag.remove(reference.get().getObserverTag()); @@ -1588,14 +1613,14 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, startRecording(raiseChat.getDialogId(), null, false); } ignoreOnPause = true; - if (proximityWakeLock != null && !proximityWakeLock.isHeld()) { + if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) { proximityWakeLock.acquire(); } } } else if (playingMessageObject != null && playingMessageObject.isVoice()) { if (!useFrontSpeaker) { FileLog.e("tmessages", "start listen"); - if (proximityWakeLock != null && !proximityWakeLock.isHeld()) { + if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) { proximityWakeLock.acquire(); } useFrontSpeaker = true; @@ -1610,7 +1635,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (playingMessageObject != null && playingMessageObject.isVoice()) { if (!useFrontSpeaker) { FileLog.e("tmessages", "start listen by proximity only"); - if (proximityWakeLock != null && !proximityWakeLock.isHeld()) { + if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) { proximityWakeLock.acquire(); } useFrontSpeaker = true; @@ -1624,7 +1649,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, stopRecording(2); raiseToEarRecord = false; ignoreOnPause = false; - if (proximityWakeLock != null && proximityWakeLock.isHeld()) { + if (proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) { proximityWakeLock.release(); } } else if (useFrontSpeaker) { @@ -1632,7 +1657,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, useFrontSpeaker = false; startAudioAgain(true); ignoreOnPause = false; - if (proximityWakeLock != null && proximityWakeLock.isHeld()) { + if (proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) { proximityWakeLock.release(); } } @@ -1758,7 +1783,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, sensorManager.unregisterListener(MediaController.this, proximitySensor); } }); - if (proximityWakeLock != null && proximityWakeLock.isHeld()) { + if (proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) { proximityWakeLock.release(); } } @@ -1807,7 +1832,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, isPaused = false; if (playingMessageObject != null) { if (downloadingCurrentMessage) { - FileLoader.getInstance().cancelLoadFile(playingMessageObject.messageOwner.media.document); + FileLoader.getInstance().cancelLoadFile(playingMessageObject.getDocument()); } MessageObject lastFile = playingMessageObject; playingMessageObject.audioProgress = 0.0f; @@ -1816,6 +1841,8 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, playingMessageObject = null; downloadingCurrentMessage = false; if (notify) { + NotificationsController.getInstance().audioManager.abandonAudioFocus(this); + hasAudioFocus = 0; if (voiceMessagesPlaylist != null) { if (byVoiceEnd && voiceMessagesPlaylist.get(0) == lastFile) { voiceMessagesPlaylist.remove(0); @@ -1944,7 +1971,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (currentPlaylistNum == -1) { playlist.clear(); shuffledPlaylist.clear(); - return false; + playlist.add(current); } if (current.isMusic()) { if (shuffleMusic) { @@ -2062,7 +2089,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, final File cacheFile = file != null ? file : FileLoader.getPathToMessage(nextAudio.messageOwner); boolean exist = cacheFile != null && cacheFile.exists(); if (cacheFile != null && cacheFile != file && !cacheFile.exists() && nextAudio.isMusic()) { - FileLoader.getInstance().loadFile(nextAudio.messageOwner.media.document, false, false); + FileLoader.getInstance().loadFile(nextAudio.getDocument(), false, false); } } @@ -2078,6 +2105,27 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } } + private void checkAudioFocus(MessageObject messageObject) { + int neededAudioFocus; + if (messageObject.isVoice()) { + if (useFrontSpeaker) { + neededAudioFocus = 3; + } else { + neededAudioFocus = 2; + } + } else { + neededAudioFocus = 1; + } + if (hasAudioFocus != neededAudioFocus) { + hasAudioFocus = neededAudioFocus; + if (neededAudioFocus == 3) { + NotificationsController.getInstance().audioManager.requestAudioFocus(this, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN); + } else { + NotificationsController.getInstance().audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, neededAudioFocus == 2 ? AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK : AudioManager.AUDIOFOCUS_GAIN); + } + } + } + public boolean playAudio(final MessageObject messageObject) { if (messageObject == null) { return false; @@ -2109,14 +2157,14 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } final File cacheFile = file != null ? file : FileLoader.getPathToMessage(messageObject.messageOwner); if (cacheFile != null && cacheFile != file && !cacheFile.exists() && messageObject.isMusic()) { - FileLoader.getInstance().loadFile(messageObject.messageOwner.media.document, false, false); + FileLoader.getInstance().loadFile(messageObject.getDocument(), false, false); downloadingCurrentMessage = true; isPaused = false; lastProgress = 0; lastPlayPcm = 0; audioInfo = null; playingMessageObject = messageObject; - if (playingMessageObject.messageOwner.media.document != null) { + if (playingMessageObject.getDocument() != null) { Intent intent = new Intent(ApplicationLoader.applicationContext, MusicPlayerService.class); ApplicationLoader.applicationContext.startService(intent); } else { @@ -2221,10 +2269,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, return false; } } - if (!hasAudioFocus) { - hasAudioFocus = true; - NotificationsController.getInstance().audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); - } + checkAudioFocus(messageObject); isPaused = false; lastProgress = 0; @@ -2403,10 +2448,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, audioTrackPlayer.play(); checkPlayerQueue(); } - if (!hasAudioFocus) { - hasAudioFocus = true; - NotificationsController.getInstance().audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); - } + checkAudioFocus(messageObject); isPaused = false; NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioPlayStateChanged, playingMessageObject.getId()); } catch (Exception e) { @@ -2548,8 +2590,8 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, return; } if (waveform != null) { - for (int a = 0; a < messageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = messageObject.messageOwner.media.document.attributes.get(a); + for (int a = 0; a < messageObject.getDocument().attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = messageObject.getDocument().attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { attribute.waveform = waveform; attribute.flags |= 4; @@ -2593,7 +2635,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, audioToSend.attributes.add(attributeAudio); if (duration > 700) { if (send == 1) { - SendMessagesHelper.getInstance().sendMessage(audioToSend, null, recordingAudioFileToSend.getAbsolutePath(), recordDialogId, recordReplyingMessageObject, recordAsAdmin, null); + SendMessagesHelper.getInstance().sendMessage(audioToSend, null, recordingAudioFileToSend.getAbsolutePath(), recordDialogId, recordReplyingMessageObject, recordAsAdmin, null, null); } NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidSent, send == 2 ? audioToSend : null, send == 2 ? recordingAudioFileToSend.getAbsolutePath() : null); } else { @@ -2655,7 +2697,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, }); } - public static void saveFile(String fullPath, Context context, final int type, final String name) { + public static void saveFile(String fullPath, Context context, final int type, final String name, final String mime) { if (fullPath == null) { return; } @@ -2752,8 +2794,15 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } } - if (result && (type == 0 || type == 1 || type == 3)) { - AndroidUtilities.addMediaToGallery(Uri.fromFile(destFile)); + if (result) { + if (type == 2) { + if (Build.VERSION.SDK_INT >= 12) { + DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE); + downloadManager.addCompletedDownload(destFile.getName(), destFile.getName(), false, mime, destFile.getAbsolutePath(), destFile.length(), true); + } + } else { + AndroidUtilities.addMediaToGallery(Uri.fromFile(destFile)); + } } } catch (Exception e) { FileLog.e("tmessages", e); @@ -2985,7 +3034,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } public static void loadGalleryPhotosAlbums(final int guid) { - new Thread(new Runnable() { + Thread thread = new Thread(new Runnable() { @Override public void run() { final ArrayList albumsSorted = new ArrayList<>(); @@ -3130,7 +3179,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } }); } - }).start(); + }); + thread.setPriority(Thread.MIN_PRIORITY); + thread.start(); } public void scheduleVideoConvert(MessageObject messageObject) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 4033311a7..234a5f8a5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -23,12 +23,14 @@ import android.text.util.Linkify; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.TypefaceSpan; import org.telegram.ui.Components.URLSpanBotCommand; import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.Components.URLSpanNoUnderlineBold; import org.telegram.ui.Components.URLSpanReplacement; +import java.io.File; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Calendar; @@ -47,7 +49,7 @@ public class MessageObject { public CharSequence linkDescription; public CharSequence caption; public MessageObject replyMessageObject; - public int type; + public int type = 1000; public int contentType; public String dateKey; public String monthKey; @@ -57,8 +59,14 @@ public class MessageObject { public ArrayList photoThumbs; public VideoEditedInfo videoEditedInfo; public boolean viewsReloaded; + public int wantedBotKeyboardWidth; + public boolean attachPathExists; + public boolean mediaExists; + + public boolean forceUpdate; private static TextPaint textPaint; + private static TextPaint botButtonPaint; public int lastLineWidth; public int textWidth; public int textHeight; @@ -86,8 +94,8 @@ public class MessageObject { public MessageObject(TLRPC.Message message, AbstractMap users, AbstractMap chats, boolean generateLayout) { if (textPaint == null) { textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - textPaint.setColor(0xff000000); - textPaint.linkColor = 0xff316f9f; + textPaint.setColor(Theme.MSG_TEXT_COLOR); + textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR; } textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize)); @@ -348,68 +356,8 @@ public class MessageObject { messageText = ""; } - if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded_old2) { - if (isMediaEmpty()) { - contentType = 0; - type = 0; - if (messageText == null || messageText.length() == 0) { - messageText = "Empty message"; - } - } else if (message.media instanceof TLRPC.TL_messageMediaPhoto) { - contentType = 0; - type = 1; - } else if (message.media instanceof TLRPC.TL_messageMediaGeo || message.media instanceof TLRPC.TL_messageMediaVenue) { - contentType = 0; - type = 4; - } else if (isVideo()) { - contentType = 0; - type = 3; - } else if (isVoice()) { - contentType = 2; - type = 2; - } else if (message.media instanceof TLRPC.TL_messageMediaContact) { - contentType = 3; - type = 12; - } else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) { - contentType = 0; - type = 0; - } else if (message.media instanceof TLRPC.TL_messageMediaDocument) { - contentType = 0; - if (message.media.document.mime_type != null) { - if (isGifDocument(message.media.document)) { - type = 8; - } else if (message.media.document.mime_type.equals("image/webp") && isSticker()) { - type = 13; - } else if (isMusic()) { - type = 14; - contentType = 8; - } else { - type = 9; - } - } else { - type = 9; - } - } - } else if (message instanceof TLRPC.TL_messageService) { - if (message.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) { - contentType = 0; - type = 0; - } else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto || message.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) { - contentType = 4; - type = 11; - } else if (message.action instanceof TLRPC.TL_messageEncryptedAction) { - if (message.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || message.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) { - contentType = 4; - type = 10; - } else { - contentType = -1; - type = -1; - } - } else { - contentType = 4; - type = 10; - } - } + setType(); + measureInlineBotButtons(); Calendar rightNow = new GregorianCalendar(); rightNow.setTimeInMillis((long) (messageOwner.date) * 1000); @@ -417,11 +365,7 @@ public class MessageObject { int dateYear = rightNow.get(Calendar.YEAR); int dateMonth = rightNow.get(Calendar.MONTH); dateKey = String.format("%d_%02d_%02d", dateYear, dateMonth, dateDay); - if (contentType == 2 || contentType == 0 || contentType == 8) { - monthKey = String.format("%d_%02d", dateYear, dateMonth); - } else if (contentType == 9) { - //dateKey = "0_0_0"; - } + monthKey = String.format("%d_%02d", dateYear, dateMonth); if (messageOwner.message != null && messageOwner.id < 0 && messageOwner.message.length() > 6 && isVideo()) { videoEditedInfo = new VideoEditedInfo(); @@ -435,13 +379,14 @@ public class MessageObject { } layoutCreated = generateLayout; generateThumbs(false); + checkMediaExistance(); } public static TextPaint getTextPaint() { if (textPaint == null) { textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - textPaint.setColor(0xff000000); - textPaint.linkColor = 0xff316f9f; + textPaint.setColor(Theme.MSG_TEXT_COLOR); + textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR; textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize)); } return textPaint; @@ -482,6 +427,7 @@ public class MessageObject { if (mess.length() > 20) { mess = mess.subSequence(0, 20) + "..."; } + mess = Emoji.replaceEmoji(mess, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false); messageText = replaceWithLink(LocaleController.formatString("ActionPinnedText", R.string.ActionPinnedText, mess), "un1", fromUser != null ? fromUser : chat); } else { messageText = replaceWithLink(LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText), "un1", fromUser != null ? fromUser : chat); @@ -489,6 +435,86 @@ public class MessageObject { } } + private void measureInlineBotButtons() { + wantedBotKeyboardWidth = 0; + if (!(messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup)) { + return; + } + if (botButtonPaint == null) { + botButtonPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + botButtonPaint.setTextSize(AndroidUtilities.dp(15)); + botButtonPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + } + for (int a = 0; a < messageOwner.reply_markup.rows.size(); a++) { + TLRPC.TL_keyboardButtonRow row = messageOwner.reply_markup.rows.get(a); + int maxButtonSize = 0; + int size = row.buttons.size(); + for (int b = 0; b < size; b++) { + CharSequence text = Emoji.replaceEmoji(row.buttons.get(b).text, botButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(15), false); + StaticLayout staticLayout = new StaticLayout(text, botButtonPaint, AndroidUtilities.dp(2000), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + if (staticLayout.getLineCount() > 0) { + maxButtonSize = Math.max(maxButtonSize, (int) Math.ceil(staticLayout.getLineWidth(0) - staticLayout.getLineLeft(0)) + AndroidUtilities.dp(4)); + } + } + wantedBotKeyboardWidth = Math.max(wantedBotKeyboardWidth, (maxButtonSize + AndroidUtilities.dp(12)) * size + AndroidUtilities.dp(5) * (size - 1)); + } + } + + public void setType() { + if (messageOwner instanceof TLRPC.TL_message || messageOwner instanceof TLRPC.TL_messageForwarded_old2) { + if (isMediaEmpty()) { + type = 0; + if (messageText == null || messageText.length() == 0) { + messageText = "Empty message"; + } + } else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) { + type = 1; + } else if (messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageOwner.media instanceof TLRPC.TL_messageMediaVenue) { + type = 4; + } else if (isVideo()) { + type = 3; + } else if (isVoice()) { + type = 2; + } else if (isMusic()) { + type = 14; + } else if (messageOwner.media instanceof TLRPC.TL_messageMediaContact) { + type = 12; + } else if (messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported) { + type = 0; + } else if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { + if (messageOwner.media.document.mime_type != null) { + if (isGifDocument(messageOwner.media.document)) { + type = 8; + } else if (messageOwner.media.document.mime_type.equals("image/webp") && isSticker()) { + type = 13; + } else { + type = 9; + } + } else { + type = 9; + } + } + } else if (messageOwner instanceof TLRPC.TL_messageService) { + if (messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) { + type = 0; + } else if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) { + contentType = 1; + type = 11; + } else if (messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) { + if (messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) { + contentType = 1; + type = 10; + } else { + contentType = -1; + type = -1; + } + } else { + contentType = 1; + type = 10; + } + } + } + public void checkLayout() { if (!layoutCreated) { layoutCreated = true; @@ -564,6 +590,8 @@ public class MessageObject { } else if (photoThumbs != null && !photoThumbs.isEmpty() && messageOwner.media.document.thumb != null) { TLRPC.PhotoSize photoObject = photoThumbs.get(0); photoObject.location = messageOwner.media.document.thumb.location; + photoObject.w = messageOwner.media.document.thumb.w; + photoObject.h = messageOwner.media.document.thumb.h; } } } else if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) { @@ -585,6 +613,16 @@ public class MessageObject { } } } + } else if (messageOwner.media.webpage.document != null) { + if (!(messageOwner.media.webpage.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) { + if (!update) { + photoThumbs = new ArrayList<>(); + photoThumbs.add(messageOwner.media.webpage.document.thumb); + } else if (photoThumbs != null && !photoThumbs.isEmpty() && messageOwner.media.webpage.document.thumb != null) { + TLRPC.PhotoSize photoObject = photoThumbs.get(0); + photoObject.location = messageOwner.media.webpage.document.thumb.location; + } + } } } } @@ -641,7 +679,7 @@ public class MessageObject { public String getExtension() { String fileName = getFileName(); - int idx = fileName.lastIndexOf("."); + int idx = fileName.lastIndexOf('.'); String ext = null; if (idx != -1) { ext = fileName.substring(idx + 1); @@ -1251,6 +1289,18 @@ public class MessageObject { return false; } + public static boolean isMusicDocument(TLRPC.Document document) { + if (document != null) { + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + return !attribute.voice; + } + } + } + return false; + } + public static boolean isVideoDocument(TLRPC.Document document) { if (document != null) { boolean isAnimated = false; @@ -1268,29 +1318,36 @@ public class MessageObject { return false; } + public TLRPC.Document getDocument() { + if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) { + return messageOwner.media.webpage.document; + } + return messageOwner.media != null ? messageOwner.media.document : null; + } + public static boolean isStickerMessage(TLRPC.Message message) { return message.media != null && message.media.document != null && isStickerDocument(message.media.document); } public static boolean isMusicMessage(TLRPC.Message message) { - if (message.media != null && message.media.document != null) { - for (int a = 0; a < message.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = message.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - return !attribute.voice; - } - } + if (message.media instanceof TLRPC.TL_messageMediaWebPage) { + return isMusicDocument(message.media.webpage.document); } - return false; + return message.media != null && message.media.document != null && isMusicDocument(message.media.document); } public static boolean isVoiceMessage(TLRPC.Message message) { + if (message.media instanceof TLRPC.TL_messageMediaWebPage) { + return isVoiceDocument(message.media.webpage.document); + } return message.media != null && message.media.document != null && isVoiceDocument(message.media.document); } public static boolean isVideoMessage(TLRPC.Message message) { + if (message.media instanceof TLRPC.TL_messageMediaWebPage) { + return isVideoDocument(message.media.webpage.document); + } return message.media != null && message.media.document != null && isVideoDocument(message.media.document); - /* && message.media.document.mime_type.equals("video/mp4")*/ } public static TLRPC.InputStickerSet getInputStickerSet(TLRPC.Message message) { @@ -1320,17 +1377,25 @@ public class MessageObject { public int getApproximateHeight() { if (type == 0) { - return textHeight; - } else if (contentType == 2) { - return AndroidUtilities.dp(68); - } else if (contentType == 3) { + int height = textHeight + (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageOwner.media.webpage instanceof TLRPC.TL_webPage ? AndroidUtilities.dp(100) : 0); + if (isReply()) { + height += AndroidUtilities.dp(42); + } + return height; + } else if (type == 2) { + return AndroidUtilities.dp(72); + } else if (type == 12) { return AndroidUtilities.dp(71); } else if (type == 9) { return AndroidUtilities.dp(100); } else if (type == 4) { return AndroidUtilities.dp(114); } else if (type == 14) { - return AndroidUtilities.dp(78); + return AndroidUtilities.dp(82); + } else if (type == 10) { + return AndroidUtilities.dp(30); + } else if (type == 11) { + return AndroidUtilities.dp(50); } else if (type == 13) { float maxHeight = AndroidUtilities.displaySize.y * 0.4f; float maxWidth; @@ -1403,6 +1468,9 @@ public class MessageObject { } public boolean isSticker() { + if (type != 1000) { + return type == 13; + } return isStickerMessage(messageOwner); } @@ -1431,15 +1499,21 @@ public class MessageObject { } public String getMusicTitle() { - for (int a = 0; a < messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = messageOwner.media.document.attributes.get(a); + TLRPC.Document document; + if (type == 0) { + document = messageOwner.media.webpage.document; + } else { + document = messageOwner.media.document; + } + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { if (attribute.voice) { return LocaleController.formatDateAudio(messageOwner.date); } String title = attribute.title; if (title == null || title.length() == 0) { - title = FileLoader.getDocumentFileName(messageOwner.media.document); + title = FileLoader.getDocumentFileName(document); if (title == null || title.length() == 0) { title = LocaleController.getString("AudioUnknownTitle", R.string.AudioUnknownTitle); } @@ -1451,8 +1525,14 @@ public class MessageObject { } public String getMusicAuthor() { - for (int a = 0; a < messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = messageOwner.media.document.attributes.get(a); + TLRPC.Document document; + if (type == 0) { + document = messageOwner.media.webpage.document; + } else { + document = messageOwner.media.document; + } + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { if (attribute.voice) { if (isOutOwner() || messageOwner.fwd_from != null && messageOwner.fwd_from.from_id == UserConfig.getClientUserId()) { @@ -1514,14 +1594,21 @@ public class MessageObject { } public static boolean canEditMessage(TLRPC.Message message, TLRPC.Chat chat) { - if (message == null || message.to_id == null || message.to_id.channel_id == 0 || message.action != null && !(message.action instanceof TLRPC.TL_messageActionEmpty) || isForwardedMessage(message) || message.via_bot_id != 0 || message.id < 0 || Math.abs(message.date - ConnectionsManager.getInstance().getCurrentTime()) > MessagesController.getInstance().maxEditTime) { + if (message == null || message.to_id == null || message.action != null && !(message.action instanceof TLRPC.TL_messageActionEmpty) || isForwardedMessage(message) || message.via_bot_id != 0 || message.id < 0 || Math.abs(message.date - ConnectionsManager.getInstance().getCurrentTime()) > MessagesController.getInstance().maxEditTime) { return false; } + if (message.to_id.channel_id == 0) { + return message.out && (message.media instanceof TLRPC.TL_messageMediaPhoto || + message.media instanceof TLRPC.TL_messageMediaDocument && (isVideoMessage(message) || isGifDocument(message.media.document)) || + message.media instanceof TLRPC.TL_messageMediaEmpty || + message.media instanceof TLRPC.TL_messageMediaWebPage || + message.media == null); + } if (chat == null && message.to_id.channel_id != 0) { chat = MessagesController.getInstance().getChat(message.to_id.channel_id); - } - if (chat == null) { - return false; + if (chat == null) { + return false; + } } if (chat.megagroup && message.out || !chat.megagroup && (chat.creator || chat.editor && isOut(message)) && isImportant(message)) { if (message.media instanceof TLRPC.TL_messageMediaPhoto || @@ -1583,4 +1670,35 @@ public class MessageObject { } return null; } + + public void checkMediaExistance() { + File cacheFile = null; + if (type == 1) { + TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, AndroidUtilities.getPhotoSize()); + if (currentPhotoObject != null) { + mediaExists = FileLoader.getPathToMessage(messageOwner).exists(); + } + } else if (type == 8 || type == 3 || type == 9 || type == 2 || type == 14) { + if (messageOwner.attachPath != null && messageOwner.attachPath.length() > 0) { + File f = new File(messageOwner.attachPath); + attachPathExists = f.exists(); + } + if (!attachPathExists) { + mediaExists = FileLoader.getPathToMessage(messageOwner).exists(); + } + } else { + TLRPC.Document document = getDocument(); + if (document != null) { + mediaExists = FileLoader.getPathToAttach(document).exists(); + } else if (type == 0) { + TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, AndroidUtilities.getPhotoSize()); + if (currentPhotoObject == null) { + return; + } + if (currentPhotoObject != null) { + mediaExists = FileLoader.getPathToAttach(currentPhotoObject, true).exists(); + } + } + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index c38da3644..4c01cc31a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -629,20 +629,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (user.min) { if (oldUser != null) { if (!fromCache) { - if (user.first_name != null) { - oldUser.first_name = user.first_name; - oldUser.flags |= 2; - } else { - oldUser.first_name = null; - oldUser.flags = oldUser.flags &~ 2; - } - if (user.last_name != null) { - oldUser.last_name = user.last_name; - oldUser.flags |= 4; - } else { - oldUser.last_name = null; - oldUser.flags = oldUser.flags &~ 4; - } if (user.username != null) { oldUser.username = user.username; oldUser.flags |= 8; @@ -675,20 +661,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter users.put(user.id, user); } else if (oldUser.min) { user.min = false; - if (oldUser.first_name != null) { - user.first_name = oldUser.first_name; - user.flags |= 2; - } else { - user.first_name = null; - user.flags = user.flags &~ 2; - } - if (oldUser.last_name != null) { - user.last_name = oldUser.last_name; - user.flags |= 4; - } else { - user.last_name = null; - user.flags = user.flags &~ 4; - } if (oldUser.username != null) { user.username = oldUser.username; user.flags |= 8; @@ -2029,13 +2001,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (user == null) { return; } - if (pu.action instanceof TLRPC.TL_sendMessageUploadAudioAction || pu.action instanceof TLRPC.TL_sendMessageRecordAudioAction) { + if (pu.action instanceof TLRPC.TL_sendMessageRecordAudioAction) { if (lower_id < 0) { newPrintingStrings.put(key, LocaleController.formatString("IsRecordingAudio", R.string.IsRecordingAudio, getUserNameForTyping(user))); } else { newPrintingStrings.put(key, LocaleController.getString("RecordingAudio", R.string.RecordingAudio)); } newPrintingStringsTypes.put(key, 1); + } else if (pu.action instanceof TLRPC.TL_sendMessageUploadAudioAction) { + if (lower_id < 0) { + newPrintingStrings.put(key, LocaleController.formatString("IsSendingAudio", R.string.IsSendingAudio, getUserNameForTyping(user))); + } else { + newPrintingStrings.put(key, LocaleController.getString("SendingAudio", R.string.SendingAudio)); + } + newPrintingStringsTypes.put(key, 2); } else if (pu.action instanceof TLRPC.TL_sendMessageUploadVideoAction || pu.action instanceof TLRPC.TL_sendMessageRecordVideoAction) { if (lower_id < 0) { newPrintingStrings.put(key, LocaleController.formatString("IsSendingVideo", R.string.IsSendingVideo, getUserNameForTyping(user))); @@ -2213,6 +2192,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } public void loadMessages(final long dialog_id, final int count, final int max_id, boolean fromCache, int midDate, final int classGuid, final int load_type, final int last_message_id, final int important, final int loadIndex, final int first_unread, final int unread_count, final int last_date, final boolean queryFromServer) { + FileLog.e("tmessages", "load messages in chat " + dialog_id + " count " + count + " max_id " + max_id + " cache " + fromCache + " mindate = " + midDate + " guid " + classGuid + " load_type " + load_type + " last_message_id " + last_message_id + " imp " + important + " index " + loadIndex + " firstUnread " + first_unread + " underad count " + unread_count + " last_date " + last_date + " queryFromServer " + queryFromServer); int lower_part = (int) dialog_id; if (fromCache || lower_part == 0) { MessagesStorage.getInstance().getMessages(dialog_id, count, max_id, midDate, classGuid, load_type, important, loadIndex); @@ -2323,6 +2303,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter public void processLoadedMessages(final TLRPC.messages_Messages messagesRes, final long dialog_id, final int count, final int max_id, final boolean isCache, final int classGuid, final int first_unread, final int last_message_id, final int unread_count, final int last_date, final int load_type, final int important, final boolean isEnd, final int loadIndex, final boolean queryFromServer) { + FileLog.e("tmessages", "processLoadedMessages size " + messagesRes.messages.size() + " in chat " + dialog_id + " count " + count + " max_id " + max_id + " cache " + isCache + " guid " + classGuid + " load_type " + load_type + " last_message_id " + last_message_id + " imp " + important + " index " + loadIndex + " firstUnread " + first_unread + " underad count " + unread_count + " last_date " + last_date + " queryFromServer " + queryFromServer); Utilities.stageQueue.postRunnable(new Runnable() { @Override public void run() { @@ -2998,7 +2979,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter MessagesStorage.getInstance().setDialogFlags(dialog_id, ((long) until << 32) | 1); NotificationsController.getInstance().removeNotificationsForDialog(dialog_id); } else { - if (currentValue != 0) { + if (currentValue != 0 && currentValue != 1) { updated = true; if (dialog != null) { dialog.notify_settings.mute_until = 0; @@ -4172,7 +4153,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter TLRPC.TL_help_getAppChangelog req = new TLRPC.TL_help_getAppChangelog(); req.app_version = BuildVars.BUILD_VERSION_STRING; try { - req.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + req.lang_code = LocaleController.getLocaleStringIso639(); req.device_model = Build.MANUFACTURER + Build.MODEL; req.system_version = "SDK " + Build.VERSION.SDK_INT; } catch (Exception e) { @@ -4221,7 +4202,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter req.token = regid; req.app_sandbox = false; try { - req.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + req.lang_code = LocaleController.getLocaleStringIso639(); if (req.lang_code.length() == 0) { req.lang_code = "en"; } @@ -4250,25 +4231,23 @@ public class MessagesController implements NotificationCenter.NotificationCenter req.system_version = "SDK Unknown"; } - if (req.app_version != null) { - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(TLObject response, TLRPC.TL_error error) { - if (response instanceof TLRPC.TL_boolTrue) { - FileLog.e("tmessages", "registered for push"); - UserConfig.registeredForPush = true; - UserConfig.pushString = regid; - UserConfig.saveConfig(false); - } - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - registeringForPush = false; - } - }); + ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(TLObject response, TLRPC.TL_error error) { + if (response instanceof TLRPC.TL_boolTrue) { + FileLog.e("tmessages", "registered for push"); + UserConfig.registeredForPush = true; + UserConfig.pushString = regid; + UserConfig.saveConfig(false); } - }); - } + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + registeringForPush = false; + } + }); + } + }); } public void loadCurrentState() { @@ -4848,6 +4827,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { @Override public void run() { + MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, false); if (!msgUpdates.isEmpty()) { final HashMap corrected = new HashMap<>(); for (TLRPC.TL_updateMessageID update : msgUpdates) { @@ -4953,10 +4933,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } }); } - MessagesStorage.getInstance().startTransaction(false); - MessagesStorage.getInstance().putMessages(res.new_messages, false, false, false, MediaController.getInstance().getAutodownloadMask()); - MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, false, false); - MessagesStorage.getInstance().commitTransaction(false); + MessagesStorage.getInstance().putMessages(res.new_messages, true, false, false, MediaController.getInstance().getAutodownloadMask()); } }); @@ -4991,8 +4968,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } MessagesStorage.getInstance().saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue); - FileLog.e("tmessages", "received difference with date = " + MessagesStorage.lastDateValue + " pts = " + MessagesStorage.lastPtsValue + " seq = " + MessagesStorage.lastSeqValue); - FileLog.e("tmessages", "messages = " + res.new_messages.size() + " users = " + res.users.size() + " chats = " + res.chats.size() + " other updates = " + res.other_updates.size()); + FileLog.e("tmessages", "received difference with date = " + MessagesStorage.lastDateValue + " pts = " + MessagesStorage.lastPtsValue + " seq = " + MessagesStorage.lastSeqValue + " messages = " + res.new_messages.size() + " users = " + res.users.size() + " chats = " + res.chats.size() + " other updates = " + res.other_updates.size()); } }); } @@ -5147,7 +5123,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter private int getUpdateType(TLRPC.Update update) { if (update instanceof TLRPC.TL_updateNewMessage || update instanceof TLRPC.TL_updateReadMessagesContents || update instanceof TLRPC.TL_updateReadHistoryInbox || - update instanceof TLRPC.TL_updateReadHistoryOutbox || update instanceof TLRPC.TL_updateDeleteMessages || update instanceof TLRPC.TL_updateWebPage) { + update instanceof TLRPC.TL_updateReadHistoryOutbox || update instanceof TLRPC.TL_updateDeleteMessages || update instanceof TLRPC.TL_updateWebPage || + update instanceof TLRPC.TL_updateEditMessage) { return 0; } else if (update instanceof TLRPC.TL_updateNewEncryptedMessage) { return 1; @@ -5174,8 +5151,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter TLRPC.User user3 = null; TLRPC.Chat channel = null; - if (user == null) { + if (user == null || user.min) { //TODO user = MessagesStorage.getInstance().getUserSync(user_id); + if (user != null && user.min) { + user = null; + } putUser(user, true); } @@ -5646,7 +5626,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter ConcurrentHashMap chatsDict; if (usersArr != null) { usersDict = new ConcurrentHashMap<>(); - for (TLRPC.User user : usersArr) { + for (int a = 0; a < usersArr.size(); a++) { + TLRPC.User user = usersArr.get(a); usersDict.put(user.id, user); } } else { @@ -5655,7 +5636,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter } if (chatsArr != null) { chatsDict = new ConcurrentHashMap<>(); - for (TLRPC.Chat chat : chatsArr) { + for (int a = 0; a < chatsArr.size(); a++) { + TLRPC.Chat chat = chatsArr.get(a); chatsDict.put(chat.id, chat); } } else { @@ -5683,14 +5665,20 @@ public class MessagesController implements NotificationCenter.NotificationCenter message = ((TLRPC.TL_updateNewMessage) update).message; } else { message = ((TLRPC.TL_updateNewChannelMessage) update).message; + if (!message.out && message.from_id == UserConfig.getClientUserId()) { //TODO remove later + message.out = true; + } } TLRPC.Chat chat = null; if (checkForUsers) { int chat_id = 0; + int user_id = 0; if (message.to_id.channel_id != 0) { chat_id = message.to_id.channel_id; } else if (message.to_id.chat_id != 0) { chat_id = message.to_id.chat_id; + } else if (message.to_id.user_id != 0) { + user_id = message.to_id.user_id; } if (chat_id != 0) { chat = chatsDict.get(chat_id); @@ -5708,14 +5696,30 @@ public class MessagesController implements NotificationCenter.NotificationCenter message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP; } } - if (message.from_id > 0) { - TLRPC.User user = getUser(message.from_id); - if (usersDict.get(message.from_id) == null && user == null) { - return false; + + for (int a = 0; a < 3; a++) { + if (a != 0) { + user_id = a == 1 ? message.from_id : (message.fwd_from != null ? message.fwd_from.from_id : 0); } - if (user != null && user.status != null && user.status.expires <= 0) { - onlinePrivacy.put(message.from_id, ConnectionsManager.getInstance().getCurrentTime()); - interfaceUpdateMask |= UPDATE_MASK_STATUS; + if (user_id > 0) { + TLRPC.User user = usersDict.get(user_id); + if (user == null || user.min) { + user = getUser(user_id); + } + if (user == null || user.min) { + user = MessagesStorage.getInstance().getUserSync(user_id); + if (user != null && user.min) { + user = null; + } + putUser(user, true); + } + if (user == null) { + return false; + } + if (a == 1 && user.status != null && user.status.expires <= 0) { + onlinePrivacy.put(user_id, ConnectionsManager.getInstance().getCurrentTime()); + interfaceUpdateMask |= UPDATE_MASK_STATUS; + } } } } @@ -6103,12 +6107,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter } else if (update instanceof TLRPC.TL_updateChannel) { updatesOnMainThread.add(update); } else if (update instanceof TLRPC.TL_updateChannelMessageViews) { + TLRPC.TL_updateChannelMessageViews updateChannelMessageViews = (TLRPC.TL_updateChannelMessageViews) update; SparseIntArray array = channelViews.get(update.channel_id); if (array == null) { array = new SparseIntArray(); channelViews.put(update.channel_id, array); } - array.put(update.id, update.views); + array.put(updateChannelMessageViews.id, update.views); } else if (update instanceof TLRPC.TL_updateChatParticipantAdmin) { MessagesStorage.getInstance().updateChatInfo(update.chat_id, update.user_id, 2, update.is_admin ? 1 : 0, update.version); } else if (update instanceof TLRPC.TL_updateChatAdmins) { @@ -6121,8 +6126,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter updatesOnMainThread.add(update); } else if (update instanceof TLRPC.TL_updateSavedGifs) { updatesOnMainThread.add(update); - } else if (update instanceof TLRPC.TL_updateEditChannelMessage) { - TLRPC.Message message = ((TLRPC.TL_updateEditChannelMessage) update).message; + } else if (update instanceof TLRPC.TL_updateEditChannelMessage || update instanceof TLRPC.TL_updateEditMessage) { + TLRPC.Message message; + if (update instanceof TLRPC.TL_updateEditChannelMessage) { + message = ((TLRPC.TL_updateEditChannelMessage) update).message; + } else { + message = ((TLRPC.TL_updateEditMessage) update).message; + } if (message.to_id.channel_id != 0 && !message.out) { message.unread = true; if (message.post || (message.flags & TLRPC.MESSAGE_FLAG_MEGAGROUP) != 0) { @@ -6130,14 +6140,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } - long dialog_id = -update.channel_id; - Integer value = dialogs_read_inbox_max.get(dialog_id); - if (value == null) { - value = MessagesStorage.getInstance().getChannelReadInboxMax(update.channel_id); - } - if (value >= message.id) { - message.unread = false; - message.media_unread = false; + if (update instanceof TLRPC.TL_updateEditChannelMessage) { + long dialog_id = -update.channel_id; + Integer value = dialogs_read_inbox_max.get(dialog_id); + if (value == null) { + value = MessagesStorage.getInstance().getChannelReadInboxMax(update.channel_id); + } + if (value >= message.id) { + message.unread = false; + message.media_unread = false; + } //TODO unread for updateEditMessage? } ImageLoader.saveMessageThumbs(message); @@ -6161,7 +6173,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter } arr.add(obj); } else if (update instanceof TLRPC.TL_updateChannelPinnedMessage) { - MessagesStorage.getInstance().updateChannelPinnedMessage(update.channel_id, update.id); + TLRPC.TL_updateChannelPinnedMessage updateChannelPinnedMessage = (TLRPC.TL_updateChannelPinnedMessage) update; + MessagesStorage.getInstance().updateChannelPinnedMessage(update.channel_id, updateChannelPinnedMessage.id); } } if (!messages.isEmpty()) { @@ -6839,10 +6852,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter return; } String reason = null; + boolean closeLast = false; if (chat != null) { reason = getRestrictionReason(chat.restriction_reason); } else if (user != null) { reason = getRestrictionReason(user.restriction_reason); + if (user.bot) { + type = 1; + closeLast = true; + } } if (reason != null) { showCantOpenAlert(fragment, reason); @@ -6856,7 +6874,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (type == 0) { fragment.presentFragment(new ProfileActivity(args)); } else { - fragment.presentFragment(new ChatActivity(args)/*, fragment instanceof ChatActivity*/); + fragment.presentFragment(new ChatActivity(args), closeLast); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index a1dd92f52..11ec02096 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -423,7 +423,7 @@ public class MessagesStorage { while (cursor.next()) { int chat_id = cursor.intValue(0); NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(1)); - if (data != null && cursor.byteBufferValue(1, data) != 0) { + if (cursor.byteBufferValue(1, data) != 0) { TLRPC.ChatParticipants participants = TLRPC.ChatParticipants.TLdeserialize(data, data.readInt32(false), false); if (participants != null) { TLRPC.TL_chatFull chatFull = new TLRPC.TL_chatFull(); @@ -663,7 +663,7 @@ public class MessagesStorage { cursor = database.queryFinalized("SELECT read_state, data, send_state, mid, date, uid FROM messages WHERE uid IN (" + ids.toString() + ") AND out = 0 AND read_state IN(0,2) ORDER BY date DESC LIMIT 50"); while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(1)); - if (data != null && cursor.byteBufferValue(1, data) != 0) { + if (cursor.byteBufferValue(1, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); MessageObject.setUnreadFlags(message, cursor.intValue(0)); message.id = cursor.intValue(3); @@ -793,7 +793,7 @@ public class MessagesStorage { searchImage.date = cursor.intValue(7); if (!cursor.isNull(8)) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(8)); - if (data != null && cursor.byteBufferValue(8, data) != 0) { + if (cursor.byteBufferValue(8, data) != 0) { searchImage.document = TLRPC.Document.TLdeserialize(data, data.readInt32(false), false); } data.reuse(); @@ -937,7 +937,7 @@ public class MessagesStorage { final ArrayList wallPapers = new ArrayList<>(); while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.WallPaper wallPaper = TLRPC.WallPaper.TLdeserialize(data, data.readInt32(false), false); wallPapers.add(wallPaper); } @@ -1040,7 +1040,7 @@ public class MessagesStorage { try { while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message != null && message.from_id == uid && message.id != 1) { mids.add(message.id); @@ -1104,7 +1104,7 @@ public class MessagesStorage { try { while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message != null && message.media != null) { if (message.media instanceof TLRPC.TL_messageMediaPhoto) { @@ -1163,7 +1163,7 @@ public class MessagesStorage { try { while (cursor2.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor2.byteArrayLength(0)); - if (data != null && cursor2.byteBufferValue(0, data) != 0) { + if (cursor2.byteBufferValue(0, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message != null) { arrayList.add(message); @@ -1240,7 +1240,7 @@ public class MessagesStorage { while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.Photo photo = TLRPC.Photo.TLdeserialize(data, data.readInt32(false), false); res.photos.add(photo); } @@ -1514,7 +1514,7 @@ public class MessagesStorage { ArrayList loadedUsers = new ArrayList<>(); if (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { info = TLRPC.ChatFull.TLdeserialize(data, data.readInt32(false), false); info.pinned_msg_id = cursor.intValue(1); } @@ -1696,7 +1696,7 @@ public class MessagesStorage { ArrayList loadedUsers = new ArrayList<>(); if (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { info = TLRPC.ChatFull.TLdeserialize(data, data.readInt32(false), false); info.pinned_msg_id = cursor.intValue(1); } @@ -1783,7 +1783,7 @@ public class MessagesStorage { ArrayList loadedUsers = new ArrayList<>(); if (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { info = TLRPC.ChatFull.TLdeserialize(data, data.readInt32(false), false); } data.reuse(); @@ -1814,13 +1814,14 @@ public class MessagesStorage { storageQueue.postRunnable(new Runnable() { @Override public void run() { + MessageObject pinnedMessageObject = null; + TLRPC.ChatFull info = null; + ArrayList loadedUsers = new ArrayList<>(); try { SQLiteCursor cursor = database.queryFinalized("SELECT info, pinned FROM chat_settings_v2 WHERE uid = " + chat_id); - TLRPC.ChatFull info = null; - ArrayList loadedUsers = new ArrayList<>(); if (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { info = TLRPC.ChatFull.TLdeserialize(data, data.readInt32(false), false); info.pinned_msg_id = cursor.intValue(1); } @@ -1847,7 +1848,7 @@ public class MessagesStorage { try { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); NativeByteBuffer data2 = new NativeByteBuffer(cursor.byteArrayLength(2)); - if (data != null && cursor.byteBufferValue(0, data) != 0 && data2 != null && cursor.byteBufferValue(2, data2) != 0) { + if (cursor.byteBufferValue(0, data) != 0 && cursor.byteBufferValue(2, data2) != 0) { TLRPC.User user = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); TLRPC.ChannelParticipant participant = TLRPC.ChannelParticipant.TLdeserialize(data2, data2.readInt32(false), false); if (user != null && participant != null) { @@ -1886,15 +1887,13 @@ public class MessagesStorage { if (semaphore != null) { semaphore.release(); } - MessageObject pinnedMessageObject = null; if (info instanceof TLRPC.TL_channelFull && info.pinned_msg_id != 0) { pinnedMessageObject = MessagesQuery.loadPinnedMessage(chat_id, info.pinned_msg_id, false); } - MessagesController.getInstance().processChatInfo(chat_id, info, loadedUsers, true, force, byChannelUsers, pinnedMessageObject); - } catch (Exception e) { FileLog.e("tmessages", e); } finally { + MessagesController.getInstance().processChatInfo(chat_id, info, loadedUsers, true, force, byChannelUsers, pinnedMessageObject); if (semaphore != null) { semaphore.release(); } @@ -2162,7 +2161,7 @@ public class MessagesStorage { SQLiteCursor cursor = database.queryFinalized("SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.uid, s.seq_in, s.seq_out, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid LEFT JOIN messages_seq as s ON m.mid = s.mid WHERE m.mid < 0 AND m.send_state = 1 ORDER BY m.mid DESC LIMIT " + count); while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(1)); - if (data != null && cursor.byteBufferValue(1, data) != 0) { + if (cursor.byteBufferValue(1, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (!messageHashMap.containsKey(message.id)) { MessageObject.setUnreadFlags(message, cursor.intValue(0)); @@ -2306,6 +2305,7 @@ public class MessagesStorage { messageMaxId |= ((long) channelId) << 32; } boolean isEnd = false; + int num = dialog_id == 777000 ? 4 : 1; try { ArrayList usersToLoad = new ArrayList<>(); ArrayList chatsToLoad = new ArrayList<>(); @@ -2346,12 +2346,26 @@ public class MessagesStorage { } cursor.dispose(); } + } else if (max_id_query == 0) { + int existingUnreadCount = 0; + cursor = database.queryFinalized(String.format(Locale.US, "SELECT COUNT(*) FROM messages WHERE uid = %d AND mid > 0 " + imp + "AND out = 0 AND read_state IN(0,2)", dialog_id)); + if (cursor.next()) { + existingUnreadCount = cursor.intValue(0); + } + cursor.dispose(); + if (existingUnreadCount == count_unread) { + cursor = database.queryFinalized(String.format(Locale.US, "SELECT min(mid) FROM messages WHERE uid = %d AND out = 0 AND read_state IN(0,2) AND mid > 0" + imp, dialog_id)); + if (cursor.next()) { + messageMaxId = max_id_query = min_unread_id = cursor.intValue(0); + } + cursor.dispose(); + } } } - if (count_query > count_unread || count_unread < 4) { + if (count_query > count_unread || count_unread < num) { count_query = Math.max(count_query, count_unread + 10); - if (count_unread < 4) { + if (count_unread < num) { count_unread = 0; min_unread_id = 0; messageMaxId = 0; @@ -2393,12 +2407,14 @@ public class MessagesStorage { } cursor.dispose(); - boolean containMessage = true; - cursor = database.queryFinalized(String.format(Locale.US, "SELECT start FROM " + holesTable + " WHERE uid = %d AND start < %d AND end > %d", dialog_id, max_id_query, max_id_query)); - if (cursor.next()) { - containMessage = false; + boolean containMessage = max_id_query != 0; + if (containMessage) { + cursor = database.queryFinalized(String.format(Locale.US, "SELECT start FROM " + holesTable + " WHERE uid = %d AND start < %d AND end > %d", dialog_id, max_id_query, max_id_query)); + if (cursor.next()) { + containMessage = false; + } + cursor.dispose(); } - cursor.dispose(); if (containMessage) { long holeMessageMaxId = 0; @@ -2430,11 +2446,11 @@ public class MessagesStorage { holeMessageMaxId |= ((long) channelId) << 32; } } - cursor = database.queryFinalized(String.format(Locale.US, "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid <= %d AND m.mid >= %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d) UNION " + - "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d AND m.mid <= %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d)", dialog_id, messageMaxId, holeMessageMinId, count_query / 2, dialog_id, messageMaxId, holeMessageMaxId, count_query / 2)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid <= %d AND m.mid >= %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d) UNION " + + "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d AND m.mid <= %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d)", dialog_id, messageMaxId, holeMessageMinId, count_query / 2, dialog_id, messageMaxId, holeMessageMaxId, count_query / 2)); } else { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid <= %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d) UNION " + - "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d)", dialog_id, messageMaxId, count_query / 2, dialog_id, messageMaxId, count_query / 2)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid <= %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d) UNION " + + "SELECT * FROM (SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d)", dialog_id, messageMaxId, count_query / 2, dialog_id, messageMaxId, count_query / 2)); } } else { cursor = null; @@ -2450,9 +2466,9 @@ public class MessagesStorage { } cursor.dispose(); if (holeMessageId != 0) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date >= %d AND m.mid > %d AND m.mid <= %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d", dialog_id, minDate, messageMaxId, holeMessageId, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date >= %d AND m.mid > %d AND m.mid <= %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d", dialog_id, minDate, messageMaxId, holeMessageId, count_query)); } else { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date >= %d AND m.mid > %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d", dialog_id, minDate, messageMaxId, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date >= %d AND m.mid > %d " + imp + "ORDER BY m.date ASC, m.mid ASC LIMIT %d", dialog_id, minDate, messageMaxId, count_query)); } } else if (minDate != 0) { if (messageMaxId != 0) { @@ -2466,12 +2482,12 @@ public class MessagesStorage { } cursor.dispose(); if (holeMessageId != 0) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d AND m.mid < %d AND (m.mid >= %d OR m.mid < 0) " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d", dialog_id, minDate, messageMaxId, holeMessageId, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d AND m.mid < %d AND (m.mid >= %d OR m.mid < 0) " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d", dialog_id, minDate, messageMaxId, holeMessageId, count_query)); } else { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d AND m.mid < %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d", dialog_id, minDate, messageMaxId, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d AND m.mid < %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d", dialog_id, minDate, messageMaxId, count_query)); } } else { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query)); } } else { cursor = database.queryFinalized(String.format(Locale.US, "SELECT max(mid) FROM messages WHERE uid = %d AND mid > 0", dialog_id)); @@ -2490,20 +2506,20 @@ public class MessagesStorage { } cursor.dispose(); if (holeMessageId != 0) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND (m.mid >= %d OR m.mid < 0) " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, holeMessageId, offset_query, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND (m.mid >= %d OR m.mid < 0) " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, holeMessageId, offset_query, count_query)); } else { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, offset_query, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d " + imp + "ORDER BY m.date DESC, m.mid DESC LIMIT %d,%d", dialog_id, offset_query, count_query)); } } } else { isEnd = true; if (load_type == 1) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid < %d ORDER BY m.mid DESC LIMIT %d", dialog_id, max_id, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid < %d ORDER BY m.mid DESC LIMIT %d", dialog_id, max_id, count_query)); } else if (minDate != 0) { if (max_id != 0) { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d ORDER BY m.mid ASC LIMIT %d", dialog_id, max_id, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.mid > %d ORDER BY m.mid ASC LIMIT %d", dialog_id, max_id, count_query)); } else { - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d AND m.date <= %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, minDate, offset_query, count_query)); } } else { if (load_type == 2) { @@ -2528,9 +2544,9 @@ public class MessagesStorage { } } - if (count_query > count_unread || count_unread < 4) { + if (count_query > count_unread || count_unread < num) { count_query = Math.max(count_query, count_unread + 10); - if (count_unread < 4) { + if (count_unread < num) { count_unread = 0; min_unread_id = 0; last_message_id = 0; @@ -2539,13 +2555,13 @@ public class MessagesStorage { offset_query = count_unread - count_query; count_query += 10; } - cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, offset_query, count_query)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT m.read_state, m.data, m.send_state, m.mid, m.date, r.random_id, m.replydata, m.media, m.ttl FROM messages as m LEFT JOIN randoms as r ON r.mid = m.mid WHERE m.uid = %d ORDER BY m.mid ASC LIMIT %d,%d", dialog_id, offset_query, count_query)); } } if (cursor != null) { while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(1)); - if (data != null && cursor.byteBufferValue(1, data) != 0) { + if (cursor.byteBufferValue(1, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); MessageObject.setUnreadFlags(message, cursor.intValue(0)); message.id = cursor.intValue(3); @@ -2554,6 +2570,7 @@ public class MessagesStorage { if ((message.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { message.views = cursor.intValue(7); } + message.ttl = cursor.intValue(8); res.messages.add(message); addUsersAndChatsFromMessage(message, usersToLoad, chatsToLoad); @@ -2561,7 +2578,7 @@ public class MessagesStorage { if (message.reply_to_msg_id != 0 || message.reply_to_random_id != 0) { if (!cursor.isNull(6)) { NativeByteBuffer data2 = new NativeByteBuffer(cursor.byteArrayLength(6)); - if (data2 != null && cursor.byteBufferValue(6, data2) != 0) { + if (cursor.byteBufferValue(6, data2) != 0) { message.replyMessage = TLRPC.Message.TLdeserialize(data2, data2.readInt32(false), false); if (message.replyMessage != null) { addUsersAndChatsFromMessage(message.replyMessage, usersToLoad, chatsToLoad); @@ -2685,7 +2702,7 @@ public class MessagesStorage { } while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); message.id = cursor.intValue(1); message.date = cursor.intValue(2); @@ -2800,7 +2817,7 @@ public class MessagesStorage { SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT data FROM sent_files_v2 WHERE uid = '%s' AND type = %d", id, type)); if (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLObject file = TLRPC.MessageMedia.TLdeserialize(data, data.readInt32(false), false); if (file instanceof TLRPC.TL_messageMediaDocument) { result.add(((TLRPC.TL_messageMediaDocument) file).document); @@ -3170,23 +3187,9 @@ public class MessagesStorage { if (cursor.next()) { try { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.User oldUser = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); if (oldUser != null) { - if (user.first_name != null) { - oldUser.first_name = user.first_name; - oldUser.flags |= 2; - } else { - oldUser.first_name = null; - oldUser.flags = oldUser.flags &~ 2; - } - if (user.last_name != null) { - oldUser.last_name = user.last_name; - oldUser.flags |= 4; - } else { - oldUser.last_name = null; - oldUser.flags = oldUser.flags &~ 4; - } if (user.username != null) { oldUser.username = user.username; oldUser.flags |= 8; @@ -3246,7 +3249,7 @@ public class MessagesStorage { if (cursor.next()) { try { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.Chat oldChat = TLRPC.Chat.TLdeserialize(data, data.readInt32(false), false); if (oldChat != null) { oldChat.title = chat.title; @@ -3296,7 +3299,7 @@ public class MessagesStorage { while (cursor.next()) { try { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.User user = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); if (user != null) { if (user.status != null) { @@ -3321,7 +3324,7 @@ public class MessagesStorage { while (cursor.next()) { try { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.Chat chat = TLRPC.Chat.TLdeserialize(data, data.readInt32(false), false); if (chat != null) { result.add(chat); @@ -3343,7 +3346,7 @@ public class MessagesStorage { while (cursor.next()) { try { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.EncryptedChat chat = TLRPC.EncryptedChat.TLdeserialize(data, data.readInt32(false), false); if (chat != null) { chat.user_id = cursor.intValue(1); @@ -3460,7 +3463,7 @@ public class MessagesStorage { downloadObject.type = cursor.intValue(1); downloadObject.id = cursor.longValue(0); NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(2)); - if (data != null && cursor.byteBufferValue(2, data) != 0) { + if (cursor.byteBufferValue(2, data) != 0) { TLRPC.MessageMedia messageMedia = TLRPC.MessageMedia.TLdeserialize(data, data.readInt32(false), false); if (messageMedia.document != null) { downloadObject.object = messageMedia.document; @@ -3522,7 +3525,7 @@ public class MessagesStorage { while (cursor.next()) { int mid = cursor.intValue(0); NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(1)); - if (data != null && cursor.byteBufferValue(1, data) != 0) { + if (cursor.byteBufferValue(1, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message.media instanceof TLRPC.TL_messageMediaWebPage) { message.id = mid; @@ -3679,6 +3682,10 @@ public class MessagesStorage { }); } + private boolean isValidKeyboardToSave(TLRPC.Message message) { + return message.reply_markup != null && !(message.reply_markup instanceof TLRPC.TL_replyInlineMarkup) && (!message.reply_markup.selective || message.mentioned); + } + private void putMessagesInternal(final ArrayList messages, final boolean withTransaction, final boolean doNotUpdateDialogDate, final int downloadMask) { try { if (withTransaction) { @@ -3759,7 +3766,7 @@ public class MessagesStorage { messagesMediaIdsMap.put(messageId, message.dialog_id); mediaTypes.put(messageId, SharedMediaQuery.getMediaType(message)); } - if (message.reply_markup != null && (!message.reply_markup.selective || message.mentioned)) { + if (isValidKeyboardToSave(message)) { TLRPC.Message oldMessage = botKeyboards.get(message.dialog_id); if (oldMessage == null || oldMessage.id < message.id) { botKeyboards.put(message.dialog_id, message); @@ -4556,7 +4563,7 @@ public class MessagesStorage { continue; } NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(1)); - if (data != null && cursor.byteBufferValue(1, data) != 0) { + if (cursor.byteBufferValue(1, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message != null && message.media != null) { if (message.media instanceof TLRPC.TL_messageMediaPhoto) { @@ -4671,7 +4678,7 @@ public class MessagesStorage { dialogs.dialogs.add(dialog); NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(4)); - if (data != null && cursor.byteBufferValue(4, data) != 0) { + if (cursor.byteBufferValue(4, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); MessageObject.setUnreadFlags(message, cursor.intValue(5)); message.id = cursor.intValue(6); @@ -5096,7 +5103,7 @@ public class MessagesStorage { state3.bindInteger(5, message.id); state3.bindInteger(6, 0); state3.bindLong(7, messageId); - state3.bindInteger(8, load_type < 0 ? message.ttl : 0); + state3.bindInteger(8, message.ttl); state3.bindInteger(9, messages.pts); state3.bindInteger(10, message.date); state3.step(); @@ -5157,7 +5164,7 @@ public class MessagesStorage { } data.reuse(); - if (load_type == 0 && message.reply_markup != null && (!message.reply_markup.selective || message.mentioned)) { + if (load_type == 0 && isValidKeyboardToSave(message)) { if (botKeyboard == null || botKeyboard.id < message.id) { botKeyboard = message; } @@ -5338,7 +5345,7 @@ public class MessagesStorage { dialogs.dialogs.add(dialog); NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(4)); - if (data != null && cursor.byteBufferValue(4, data) != 0) { + if (cursor.byteBufferValue(4, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); if (message != null) { MessageObject.setUnreadFlags(message, cursor.intValue(5)); @@ -5413,7 +5420,7 @@ public class MessagesStorage { cursor = database.queryFinalized(String.format(Locale.US, "SELECT data, mid, date, uid FROM messages WHERE mid IN(%s)", TextUtils.join(",", replyMessages))); while (cursor.next()) { NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(0)); - if (data != null && cursor.byteBufferValue(0, data) != 0) { + if (cursor.byteBufferValue(0, data) != 0) { TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); message.id = cursor.intValue(1); message.date = cursor.intValue(2); @@ -5594,7 +5601,7 @@ public class MessagesStorage { } isMegagroup = MessageObject.isMegagroup(message); - if (message.reply_markup != null && (!message.reply_markup.selective || message.mentioned)) { + if (isValidKeyboardToSave(message)) { BotQuery.putBotKeyboard(dialog.id, message); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java index 79f523711..48baf9503 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java @@ -23,7 +23,7 @@ import java.util.zip.ZipFile; public class NativeLoader { - private final static int LIB_VERSION = 20; + private final static int LIB_VERSION = 21; private final static String LIB_NAME = "tmessages." + LIB_VERSION; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so"; private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java index 6a37d46ae..70c73aff6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java @@ -70,6 +70,7 @@ public class NotificationCenter { public static final int needReloadRecentDialogsSearch = totalEvents++; public static final int locationPermissionGranted = totalEvents++; public static final int peerSettingsDidLoaded = totalEvents++; + public static final int wasUnableToFindCurrentLocation = totalEvents++; public static final int httpFileDidLoaded = totalEvents++; public static final int httpFileDidFailedLoad = totalEvents++; @@ -115,6 +116,8 @@ public class NotificationCenter { private int broadcasting = 0; private boolean animationInProgress; + private int[] allowedNotifications; + public interface NotificationCenterDelegate { void didReceivedNotification(int id, Object... args); } @@ -145,6 +148,10 @@ public class NotificationCenter { return localInstance; } + public void setAllowedNotificationsDutingAnimation(int notifications[]) { + allowedNotifications = notifications; + } + public void setAnimationInProgress(boolean value) { animationInProgress = value; if (!animationInProgress && !delayedPosts.isEmpty()) { @@ -157,8 +164,13 @@ public class NotificationCenter { public void postNotificationName(int id, Object... args) { boolean allowDuringAnimation = false; - if (id == chatInfoDidLoaded || id == dialogsNeedReload || id == closeChats || id == messagesDidLoaded || id == mediaCountDidLoaded || id == mediaDidLoaded || id == botInfoDidLoaded || id == botKeyboardDidLoaded) { - allowDuringAnimation = true; + if (allowedNotifications != null) { + for (int a = 0; a < allowedNotifications.length; a++) { + if (allowedNotifications[a] == id) { + allowDuringAnimation = true; + break; + } + } } postNotificationNameInternal(id, allowDuringAnimation, args); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index 865cd616e..d911f513c 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -380,6 +380,7 @@ public class NotificationsController { int oldCount = popupArray.size(); HashMap settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); + boolean allowPinned = preferences.getBoolean("PinnedMessages", true); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { @@ -398,6 +399,9 @@ public class NotificationsController { continue; } if (messageObject.messageOwner.mentioned) { + if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { + continue; + } dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { @@ -683,7 +687,7 @@ public class NotificationsController { int chat_id = messageObject.messageOwner.to_id.chat_id != 0 ? messageObject.messageOwner.to_id.chat_id : messageObject.messageOwner.to_id.channel_id; int from_id = messageObject.messageOwner.to_id.user_id; if (from_id == 0) { - if (messageObject.isFromUser()) { + if (messageObject.isFromUser() || messageObject.getId() < 0) { from_id = messageObject.messageOwner.from_id; } else { from_id = -chat_id; @@ -725,7 +729,7 @@ public class NotificationsController { } String msg = null; - if ((int)dialog_id == 0 || AndroidUtilities.needShowPasscode(false) || UserConfig.isWaitingForPasscodeEnter) { + if ((int) dialog_id == 0 || AndroidUtilities.needShowPasscode(false) || UserConfig.isWaitingForPasscodeEnter) { msg = LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage); } else { if (chat_id == 0 && from_id != 0) { @@ -787,12 +791,6 @@ public class NotificationsController { } if (singleUserId != 0) { if (messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) { - TLRPC.User user = MessagesController.getInstance().getUser(singleUserId); - if (user != null) { - name = UserObject.getUserName(user); - } else { - name = ""; - } msg = LocaleController.formatString("ChannelAddedByNotification", R.string.ChannelAddedByNotification, name, chat.title); } else { if (singleUserId == UserConfig.getClientUserId()) { @@ -1513,7 +1511,7 @@ public class NotificationsController { if (silent != 1 && !notifyDisabled) { if (ApplicationLoader.mainInterfacePaused || inAppPreview) { if (lastMessage.length() > 100) { - lastMessage = lastMessage.substring(0, 100).replace("\n", " ").trim() + "..."; + lastMessage = lastMessage.substring(0, 100).replace('\n', ' ').trim() + "..."; } mBuilder.setTicker(lastMessage); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java index 8878ebaaa..1420bf6aa 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java @@ -849,6 +849,36 @@ public class SecretChatHelper { }); } + private void applyPeerLayer(final TLRPC.EncryptedChat chat, int newPeerLayer) { + int currentPeerLayer = AndroidUtilities.getPeerLayerVersion(chat.layer); + if (newPeerLayer <= currentPeerLayer) { + return; + } + if (chat.key_hash.length == 16 && currentPeerLayer >= 46) { + try { + byte[] sha256 = Utilities.computeSHA256(chat.auth_key, 0, chat.auth_key.length); + byte[] key_hash = new byte[36]; + System.arraycopy(chat.key_hash, 0, key_hash, 0, 16); + System.arraycopy(sha256, 0, key_hash, 16, 20); + chat.key_hash = key_hash; + MessagesStorage.getInstance().updateEncryptedChat(chat); + } catch (Throwable e) { + FileLog.e("tmessages", e); + } + } + chat.layer = AndroidUtilities.setPeerLayerVersion(chat.layer, newPeerLayer); + MessagesStorage.getInstance().updateEncryptedChatLayer(chat); + if (currentPeerLayer < CURRENT_SECRET_CHAT_LAYER) { + sendNotifyLayerMessage(chat, null); + } + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + NotificationCenter.getInstance().postNotificationName(NotificationCenter.encryptedChatUpdated, chat); + } + }); + } + public TLRPC.Message processDecryptedObject(final TLRPC.EncryptedChat chat, final TLRPC.EncryptedFile file, int date, long random_id, TLObject object, boolean new_key_used) { if (object != null) { int from_id = chat.admin_id; @@ -1156,30 +1186,7 @@ public class SecretChatHelper { MessagesStorage.getInstance().createTaskForSecretChat(chat.id, time, time, 1, serviceMessage.action.random_ids); } } else if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionNotifyLayer) { - int currentPeerLayer = AndroidUtilities.getPeerLayerVersion(chat.layer); - if (chat.key_hash.length == 16 && currentPeerLayer >= 46) { - try { - byte[] sha256 = Utilities.computeSHA256(chat.auth_key, 0, chat.auth_key.length); - byte[] key_hash = new byte[36]; - System.arraycopy(chat.key_hash, 0, key_hash, 0, 16); - System.arraycopy(sha256, 0, key_hash, 16, 20); - chat.key_hash = key_hash; - MessagesStorage.getInstance().updateEncryptedChat(chat); - } catch (Throwable e) { - FileLog.e("tmessages", e); - } - } - chat.layer = AndroidUtilities.setPeerLayerVersion(chat.layer, serviceMessage.action.layer); - MessagesStorage.getInstance().updateEncryptedChatLayer(chat); - if (currentPeerLayer < CURRENT_SECRET_CHAT_LAYER) { - sendNotifyLayerMessage(chat, null); - } - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - NotificationCenter.getInstance().postNotificationName(NotificationCenter.encryptedChatUpdated, chat); - } - }); + applyPeerLayer(chat, serviceMessage.action.layer); } else if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionRequestKey) { if (chat.exchange_id != 0) { if (chat.exchange_id > serviceMessage.action.exchange_id) { @@ -1374,6 +1381,7 @@ public class SecretChatHelper { for (int a = 0; a < holes.size(); a++) { TL_decryptedMessageHolder holder = holes.get(a); if (holder.layer.out_seq_no == chat.seq_in || chat.seq_in == holder.layer.out_seq_no - 2) { + applyPeerLayer(chat, holder.layer.layer); chat.seq_in = holder.layer.out_seq_no; holes.remove(a); a--; @@ -1493,6 +1501,7 @@ public class SecretChatHelper { arr.add(holder); return null; } + applyPeerLayer(chat, layer.layer); chat.seq_in = layer.out_seq_no; MessagesStorage.getInstance().updateEncryptedChatSeq(chat); object = layer.message; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index 35c22b854..30f1b95e0 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -11,14 +11,19 @@ package org.telegram.messenger; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; import android.media.MediaMetadataRetriever; import android.media.MediaPlayer; import android.media.ThumbnailUtils; import android.net.Uri; import android.os.Build; +import android.os.Bundle; import android.provider.MediaStore; import android.webkit.MimeTypeMap; import android.widget.Toast; @@ -31,6 +36,7 @@ import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ChatActivity; import java.io.File; import java.io.RandomAccessFile; @@ -45,6 +51,148 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter private HashMap> delayedMessages = new HashMap<>(); private HashMap unsentMessages = new HashMap<>(); private HashMap sendingMessages = new HashMap<>(); + private HashMap waitingForLocation = new HashMap<>(); + private HashMap waitingForCallback = new HashMap<>(); + + private LocationProvider locationProvider = new LocationProvider(new LocationProvider.LocationProviderDelegate() { + @Override + public void onLocationAcquired(Location location) { + sendLocation(location); + waitingForLocation.clear(); + } + + @Override + public void onUnableLocationAcquire() { + HashMap waitingForLocationCopy = new HashMap<>(waitingForLocation); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.wasUnableToFindCurrentLocation, waitingForLocationCopy); + waitingForLocation.clear(); + } + }); + + public static class LocationProvider { + + public interface LocationProviderDelegate { + void onLocationAcquired(Location location); + void onUnableLocationAcquire(); + } + + private LocationProviderDelegate delegate; + private LocationManager locationManager; + private GpsLocationListener gpsLocationListener = new GpsLocationListener(); + private GpsLocationListener networkLocationListener = new GpsLocationListener(); + private Runnable locationQueryCancelRunnable; + private Location lastKnownLocation; + + private class GpsLocationListener implements LocationListener { + + @Override + public void onLocationChanged(Location location) { + if (location == null || locationQueryCancelRunnable == null) { + return; + } + FileLog.e("tmessages", "found location " + location); + lastKnownLocation = location; + if (location.getAccuracy() < 100) { + if (delegate != null) { + delegate.onLocationAcquired(location); + } + if (locationQueryCancelRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(locationQueryCancelRunnable); + } + cleanup(); + } + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + + } + + @Override + public void onProviderEnabled(String provider) { + + } + + @Override + public void onProviderDisabled(String provider) { + + } + } + + public LocationProvider() { + + } + + public LocationProvider(LocationProviderDelegate locationProviderDelegate) { + delegate = locationProviderDelegate; + } + + public void setDelegate(LocationProviderDelegate locationProviderDelegate) { + delegate = locationProviderDelegate; + } + + private void cleanup() { + locationManager.removeUpdates(gpsLocationListener); + locationManager.removeUpdates(networkLocationListener); + lastKnownLocation = null; + locationQueryCancelRunnable = null; + } + + public void start() { + if (locationManager == null) { + locationManager = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE); + } + try { + locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 0, gpsLocationListener); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + try { + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 0, networkLocationListener); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + try { + lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + if (lastKnownLocation == null) { + lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + if (locationQueryCancelRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(locationQueryCancelRunnable); + } + locationQueryCancelRunnable = new Runnable() { + @Override + public void run() { + if (locationQueryCancelRunnable != this) { + return; + } + if (delegate != null) { + if (lastKnownLocation != null) { + delegate.onLocationAcquired(lastKnownLocation); + } else { + delegate.onUnableLocationAcquire(); + } + } + cleanup(); + } + }; + AndroidUtilities.runOnUIThread(locationQueryCancelRunnable, 5000); + } + + public void stop() { + if (locationManager == null) { + return; + } + if (locationQueryCancelRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(locationQueryCancelRunnable); + + } + cleanup(); + } + } protected class DelayedMessage { public TLObject sendRequest; @@ -90,7 +238,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter delayedMessages.clear(); unsentMessages.clear(); sendingMessages.clear(); + waitingForLocation.clear(); + waitingForCallback.clear(); currentChatInfo = null; + locationProvider.stop(); } public void setCurrentChatInfo(TLRPC.ChatFull info) { @@ -259,7 +410,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter for (int a = 0; a < arr.size(); a++) { final DelayedMessage message = arr.get(a); if (message.type == 0) { - String md5 = Utilities.MD5(message.httpLocation) + ".jpg"; + String md5 = Utilities.MD5(message.httpLocation) + "." + ImageLoader.getHttpUrlExtension(message.httpLocation, "file"); final File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5); Utilities.globalQueue.postRunnable(new Runnable() { @Override @@ -455,18 +606,18 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage)) { if (messageObject.messageOwner.media.photo instanceof TLRPC.TL_photo) { - sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, did, messageObject.replyMessageObject, asAdmin, null); + sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, did, messageObject.replyMessageObject, asAdmin, null, null); } else if (messageObject.messageOwner.media.document instanceof TLRPC.TL_document) { - sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, asAdmin, null); + sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, asAdmin, null, null); } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) { - sendMessage(messageObject.messageOwner.media, did, messageObject.replyMessageObject, asAdmin); + sendMessage(messageObject.messageOwner.media, did, messageObject.replyMessageObject, asAdmin, null, null); } else if (messageObject.messageOwner.media.phone_number != null) { TLRPC.User user = new TLRPC.TL_userContact_old2(); user.phone = messageObject.messageOwner.media.phone_number; user.first_name = messageObject.messageOwner.media.first_name; user.last_name = messageObject.messageOwner.media.last_name; user.id = messageObject.messageOwner.media.user_id; - sendMessage(user, did, messageObject.replyMessageObject, asAdmin); + sendMessage(user, did, messageObject.replyMessageObject, asAdmin, null, null); } else { ArrayList arrayList = new ArrayList<>(); arrayList.add(messageObject); @@ -477,7 +628,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) { webPage = messageObject.messageOwner.media.webpage; } - sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject, webPage, true, asAdmin, messageObject.messageOwner.entities, null); + sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject, webPage, true, asAdmin, messageObject.messageOwner.entities, null, null); } else { ArrayList arrayList = new ArrayList<>(); arrayList.add(messageObject); @@ -528,34 +679,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } } } - for (int a = 0; a < document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeSticker) { - if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) < 46) { - document.attributes.remove(a); - document.attributes.add(new TLRPC.TL_documentAttributeSticker_old()); - } else { - if (attribute.stickerset != null) { - String name = StickersQuery.getStickerSetName(attribute.stickerset.id); - if (name != null && name.length() > 0) { - attribute.stickerset = new TLRPC.TL_inputStickerSetShortName(); - attribute.stickerset.short_name = name; - } else { - attribute.stickerset = new TLRPC.TL_inputStickerSetEmpty(); - } - } else { - attribute.stickerset = new TLRPC.TL_inputStickerSetEmpty(); - } - } - break; - } - } } - SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, peer, replyingMessageObject, asAdmin, null); - } - - public void sendMessage(TLRPC.User user, long peer, MessageObject reply_to_msg, boolean asAdmin) { - sendMessage(null, null, null, null, user, null, peer, null, reply_to_msg, null, true, asAdmin, null, null, null); + SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, peer, replyingMessageObject, asAdmin, null, null); } public void sendMessage(ArrayList messages, final long peer, boolean asAdmin) { @@ -680,6 +805,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter putToSendingMessages(newMsg); boolean differentDialog = false; + if (BuildVars.DEBUG_VERSION) { + FileLog.e("tmessages", "forward message user_id = " + inputPeer.user_id + " chat_id = " + inputPeer.chat_id + " channel_id = " + inputPeer.channel_id + " access_hash = " + inputPeer.access_hash); + } + if (arr.size() == 100 || a == messages.size() - 1 || a != messages.size() - 1 && messages.get(a + 1).getDialogId() != msgObj.getDialogId()) { MessagesStorage.getInstance().putMessages(new ArrayList<>(arr), false, true, false, 0); MessagesController.getInstance().updateInterfaceWithMessages(peer, objArr); @@ -688,9 +817,16 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter TLRPC.TL_messages_forwardMessages req = new TLRPC.TL_messages_forwardMessages(); req.to_peer = inputPeer; - if (msgObj.messageOwner.to_id instanceof TLRPC.TL_peerChannel) { - req.from_peer = MessagesController.getInputPeer(-msgObj.messageOwner.to_id.channel_id); + if (req.to_peer instanceof TLRPC.TL_inputPeerChannel) { req.silent = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).getBoolean("silent_" + peer, false); + } + if (msgObj.messageOwner.to_id instanceof TLRPC.TL_peerChannel) { + TLRPC.Chat chat = MessagesController.getInstance().getChat(msgObj.messageOwner.to_id.channel_id); + req.from_peer = new TLRPC.TL_inputPeerChannel(); + req.from_peer.channel_id = msgObj.messageOwner.to_id.channel_id; + if (chat != null) { + req.from_peer.access_hash = chat.access_hash; + } } else { req.from_peer = new TLRPC.TL_inputPeerEmpty(); } @@ -713,7 +849,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter for (int a = 0; a < updates.updates.size(); a++) { TLRPC.Update update = updates.updates.get(a); if (update instanceof TLRPC.TL_updateMessageID) { - newMessagesByIds.put(update.id, update.random_id); + TLRPC.TL_updateMessageID updateMessageID = (TLRPC.TL_updateMessageID) update; + newMessagesByIds.put(updateMessageID.id, updateMessageID.random_id); updates.updates.remove(a); a--; } @@ -815,12 +952,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); - TLRPC.TL_channels_editMessage req = new TLRPC.TL_channels_editMessage(); - req.channel = MessagesController.getInputChannel(messageObject.messageOwner.to_id.channel_id); + TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage(); + req.peer = MessagesController.getInputPeer((int) messageObject.getDialogId()); req.message = message; + req.flags |= 2048; req.id = messageObject.getId(); req.no_webpage = !searchLinks; - FileLog.d("tmessages", "try to edit message " + req.id + " in channel " + req.channel.channel_id + " hash " + req.channel.access_hash + " message " + req.message); final int reqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { @@ -872,31 +1009,104 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } } + private void sendLocation(Location location) { + TLRPC.TL_messageMediaGeo mediaGeo = new TLRPC.TL_messageMediaGeo(); + mediaGeo.geo = new TLRPC.TL_geoPoint(); + mediaGeo.geo.lat = location.getLatitude(); + mediaGeo.geo._long = location.getLongitude(); + for (HashMap.Entry entry : waitingForLocation.entrySet()) { + MessageObject messageObject = entry.getValue(); + SendMessagesHelper.getInstance().sendMessage(mediaGeo, messageObject.getDialogId(), messageObject, false, null, null); + } + } + + public void sendCurrentLocation(final MessageObject messageObject, final TLRPC.KeyboardButton button) { + final String key = messageObject.getId() + "_" + Utilities.bytesToHex(button.data); + waitingForLocation.put(key, messageObject); + locationProvider.start(); + } + + public boolean isSendingCurrentLocation(MessageObject messageObject, TLRPC.KeyboardButton button) { + return !(messageObject == null || button == null) && waitingForLocation.containsKey(messageObject.getId() + "_" + Utilities.bytesToHex(button.data)); + } + + public void sendCallback(final MessageObject messageObject, final TLRPC.KeyboardButton button, final ChatActivity parentFragment) { + if (messageObject == null || button == null || parentFragment == null) { + return; + } + final String key = messageObject.getId() + "_" + Utilities.bytesToHex(button.data); + waitingForCallback.put(key, messageObject); + TLRPC.TL_messages_getBotCallbackAnswer req = new TLRPC.TL_messages_getBotCallbackAnswer(); + req.peer = MessagesController.getInputPeer((int) messageObject.getDialogId()); + req.msg_id = messageObject.getId(); + req.data = button.data; + ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(final TLObject response, TLRPC.TL_error error) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (response != null) { + TLRPC.TL_messages_botCallbackAnswer res = (TLRPC.TL_messages_botCallbackAnswer) response; + if (res.message != null) { + if (res.alert) { + if (parentFragment.getParentActivity() == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(parentFragment.getParentActivity()); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + builder.setMessage(res.message); + parentFragment.showDialog(builder.create()); + } else { + int uid = messageObject.messageOwner.from_id; + if (messageObject.messageOwner.via_bot_id != 0) { + uid = messageObject.messageOwner.via_bot_id; + } + TLRPC.User user = MessagesController.getInstance().getUser(uid); + if (user == null) { + return; + } + parentFragment.showAlert(user, res.message); + } + } + } + waitingForCallback.remove(key); + } + }); + } + }, ConnectionsManager.RequestFlagFailOnServerErrors); + } + + public boolean isSendingCallback(MessageObject messageObject, TLRPC.KeyboardButton button) { + return !(messageObject == null || button == null) && waitingForCallback.containsKey(messageObject.getId() + "_" + Utilities.bytesToHex(button.data)); + } + public void sendMessage(MessageObject retryMessageObject, boolean asAdmin) { - sendMessage(null, null, null, null, null, null, retryMessageObject.getDialogId(), retryMessageObject.messageOwner.attachPath, null, null, true, asAdmin, retryMessageObject, null, retryMessageObject.messageOwner.params); + sendMessage(null, null, null, null, null, null, retryMessageObject.getDialogId(), retryMessageObject.messageOwner.attachPath, null, null, true, asAdmin, retryMessageObject, null, retryMessageObject.messageOwner.reply_markup, retryMessageObject.messageOwner.params); } - public void sendMessage(TLRPC.TL_document document, VideoEditedInfo videoEditedInfo, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, HashMap params) { - sendMessage(null, null, null, videoEditedInfo, null, document, peer, path, reply_to_msg, null, true, asAdmin, null, null, params); + public void sendMessage(TLRPC.User user, long peer, MessageObject reply_to_msg, boolean asAdmin, TLRPC.ReplyMarkup replyMarkup, HashMap params) { + sendMessage(null, null, null, null, user, null, peer, null, reply_to_msg, null, true, asAdmin, null, null, replyMarkup, params); } - public void sendMessage(String message, long peer, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin, ArrayList entities, HashMap params) { - sendMessage(message, null, null, null, null, null, peer, null, reply_to_msg, webPage, searchLinks, asAdmin, null, entities, params); + public void sendMessage(TLRPC.TL_document document, VideoEditedInfo videoEditedInfo, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, TLRPC.ReplyMarkup replyMarkup, HashMap params) { + sendMessage(null, null, null, videoEditedInfo, null, document, peer, path, reply_to_msg, null, true, asAdmin, null, null, replyMarkup, params); } - public void sendMessage(TLRPC.MessageMedia location, long peer, MessageObject reply_to_msg, boolean asAdmin) { - sendMessage(null, location, null, null, null, null, peer, null, reply_to_msg, null, true, asAdmin, null, null, null); + public void sendMessage(String message, long peer, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin, ArrayList entities, TLRPC.ReplyMarkup replyMarkup, HashMap params) { + sendMessage(message, null, null, null, null, null, peer, null, reply_to_msg, webPage, searchLinks, asAdmin, null, entities, replyMarkup, params); } - public void sendMessage(TLRPC.TL_photo photo, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, HashMap params) { - sendMessage(null, null, photo, null, null, null, peer, path, reply_to_msg, null, true, asAdmin, null, null, params); + public void sendMessage(TLRPC.MessageMedia location, long peer, MessageObject reply_to_msg, boolean asAdmin, TLRPC.ReplyMarkup replyMarkup, HashMap params) { + sendMessage(null, location, null, null, null, null, peer, null, reply_to_msg, null, true, asAdmin, null, null, replyMarkup, params); } - /*public void sendMessage(TLRPC.TL_video video, VideoEditedInfo videoEditedInfo, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, HashMap params) { - sendMessage(null, null, null, video, videoEditedInfo, null, null, null, peer, path, reply_to_msg, null, true, asAdmin, null, null, params); - }*/ + public void sendMessage(TLRPC.TL_photo photo, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, TLRPC.ReplyMarkup replyMarkup, HashMap params) { + sendMessage(null, null, photo, null, null, null, peer, path, reply_to_msg, null, true, asAdmin, null, null, replyMarkup, params); + } - private void sendMessage(String message, TLRPC.MessageMedia location, TLRPC.TL_photo photo, VideoEditedInfo videoEditedInfo, TLRPC.User user, TLRPC.TL_document document, long peer, String path, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin, MessageObject retryMessageObject, ArrayList entities, HashMap params) { + private void sendMessage(String message, TLRPC.MessageMedia location, TLRPC.TL_photo photo, VideoEditedInfo videoEditedInfo, TLRPC.User user, TLRPC.TL_document document, long peer, String path, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin, MessageObject retryMessageObject, ArrayList entities, TLRPC.ReplyMarkup replyMarkup, HashMap params) { if (peer == 0) { return; } @@ -935,27 +1145,18 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter try { if (retryMessageObject != null) { newMsg = retryMessageObject.messageOwner; - if (retryMessageObject.isForwarded()) { type = 4; } else { if (retryMessageObject.type == 0) { message = newMsg.message; - if (params != null && params.containsKey("query_id")) { - type = 9; - } else { - type = 0; - } + type = 0; } else if (retryMessageObject.type == 4) { location = newMsg.media; type = 1; } else if (retryMessageObject.type == 1) { photo = (TLRPC.TL_photo) newMsg.media.photo; - if (params != null && params.containsKey("query_id")) { - type = 9; - } else { - type = 2; - } + type = 2; } else if (retryMessageObject.type == 3) { type = 3; document = (TLRPC.TL_document) newMsg.media.document; @@ -966,17 +1167,16 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter user.last_name = newMsg.media.last_name; user.id = newMsg.media.user_id; type = 6; - } else if (retryMessageObject.type == 8 || retryMessageObject.type == 9 || retryMessageObject.type == 13) { + } else if (retryMessageObject.type == 8 || retryMessageObject.type == 9 || retryMessageObject.type == 13 || retryMessageObject.type == 14) { document = (TLRPC.TL_document) newMsg.media.document; - if (params != null && params.containsKey("query_id")) { - type = 9; - } else { - type = 7; - } + type = 7; } else if (retryMessageObject.type == 2) { document = (TLRPC.TL_document) newMsg.media.document; type = 8; } + if (params != null && params.containsKey("query_id")) { + type = 9; + } } } else { if (message != null) { @@ -1017,7 +1217,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } newMsg.media = location; newMsg.message = ""; - type = 1; + if (params != null && params.containsKey("query_id")) { + type = 9; + } else { + type = 1; + } } else if (photo != null) { if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { newMsg = new TLRPC.TL_message_secret(); @@ -1057,7 +1261,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter user.last_name = newMsg.media.last_name = ""; } newMsg.message = ""; - type = 6; + if (params != null && params.containsKey("query_id")) { + type = 9; + } else { + type = 6; + } } else if (document != null) { if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { newMsg = new TLRPC.TL_message_secret(); @@ -1067,12 +1275,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter newMsg.media = new TLRPC.TL_messageMediaDocument(); newMsg.media.caption = document.caption != null ? document.caption : ""; newMsg.media.document = document; - if (MessageObject.isVideoDocument(document)) { + if (params != null && params.containsKey("query_id")) { + type = 9; + } else if (MessageObject.isVideoDocument(document)) { type = 3; } else if (MessageObject.isVoiceDocument(document)) { type = 8; - } else if (params != null && params.containsKey("query_id")) { - type = 9; } else { type = 7; } @@ -1086,6 +1294,30 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } else { newMsg.attachPath = path; } + if (encryptedChat != null && MessageObject.isStickerDocument(document)) { + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeSticker) { + if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) < 46) { + document.attributes.remove(a); + document.attributes.add(new TLRPC.TL_documentAttributeSticker_old()); + } else { + if (attribute.stickerset != null) { + String name = StickersQuery.getStickerSetName(attribute.stickerset.id); + if (name != null && name.length() > 0) { + attribute.stickerset = new TLRPC.TL_inputStickerSetShortName(); + attribute.stickerset.short_name = name; + } else { + attribute.stickerset = new TLRPC.TL_inputStickerSetEmpty(); + } + } else { + attribute.stickerset = new TLRPC.TL_inputStickerSetEmpty(); + } + } + break; + } + } + } } if (newMsg.attachPath == null) { newMsg.attachPath = ""; @@ -1146,6 +1378,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } newMsg.reply_to_msg_id = reply_to_msg.getId(); } + if (replyMarkup != null && encryptedChat == null) { + newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_MARKUP; + newMsg.reply_markup = replyMarkup; + } if (lower_id != 0) { if (high_id == 1) { if (currentChatInfo == null) { @@ -1225,6 +1461,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter MessagesController.getInstance().updateInterfaceWithMessages(peer, objArr); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); + if (BuildVars.DEBUG_VERSION) { + if (sendToPeer != null) { + FileLog.e("tmessages", "send message user_id = " + sendToPeer.user_id + " chat_id = " + sendToPeer.chat_id + " channel_id = " + sendToPeer.channel_id + " access_hash = " + sendToPeer.access_hash); + } + } + if (type == 0 || type == 9 && message != null && encryptedChat != null) { if (encryptedChat == null) { if (sendToPeers != null) { @@ -1524,6 +1766,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } else if (type == 2 || type == 9 && photo != null) { TLRPC.PhotoSize small = photo.sizes.get(0); TLRPC.PhotoSize big = photo.sizes.get(photo.sizes.size() - 1); + ImageLoader.fillPhotoSizeWithBytes(small); if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 46) { reqSend.media = new TLRPC.TL_decryptedMessageMediaPhoto(); reqSend.media.caption = photo.caption != null ? photo.caption : ""; @@ -1540,7 +1783,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter ((TLRPC.TL_decryptedMessageMediaPhoto_layer8) reqSend.media).thumb = new byte[0]; } } - ImageLoader.fillPhotoSizeWithBytes(small); reqSend.media.thumb_h = small.h; reqSend.media.thumb_w = small.w; reqSend.media.w = big.w; @@ -1747,7 +1989,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter TLRPC.TL_messages_forwardMessages reqSend = new TLRPC.TL_messages_forwardMessages(); reqSend.to_peer = sendToPeer; if (retryMessageObject.messageOwner.ttl != 0) { - reqSend.from_peer = MessagesController.getInputPeer(retryMessageObject.messageOwner.ttl); + TLRPC.Chat chat = MessagesController.getInstance().getChat(-retryMessageObject.messageOwner.ttl); + reqSend.from_peer = new TLRPC.TL_inputPeerChannel(); + reqSend.from_peer.channel_id = -retryMessageObject.messageOwner.ttl; + if (chat != null) { + reqSend.from_peer.access_hash = chat.access_hash; + } } else { reqSend.from_peer = new TLRPC.TL_inputPeerEmpty(); } @@ -1797,13 +2044,23 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter if (message.type == 0) { if (message.httpLocation != null) { putToDelayedMessages(message.httpLocation, message); - ImageLoader.getInstance().loadHttpFile(message.httpLocation, "jpg"); + ImageLoader.getInstance().loadHttpFile(message.httpLocation, "file"); } else { - String location = FileLoader.getPathToAttach(message.location, true).toString(); - putToDelayedMessages(location, message); if (message.sendRequest != null) { + String location = FileLoader.getPathToAttach(message.location).toString(); + putToDelayedMessages(location, message); FileLoader.getInstance().uploadFile(location, false, true); } else { + String location = FileLoader.getPathToAttach(message.location).toString(); + if (message.sendEncryptedRequest != null && message.location.dc_id != 0) { + File file = new File(location); + if (!file.exists()) { + putToDelayedMessages(FileLoader.getAttachFileName(message.location), message); + FileLoader.getInstance().loadFile(message.location, "jpg", 0, false); + return; + } + } + putToDelayedMessages(location, message); FileLoader.getInstance().uploadFile(location, true, true); } } @@ -2139,8 +2396,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter size2.location = size.location; size2.size = size.size; } - } else if (MessageObject.isStickerMessage(sentMessage) && size2 != null && size2.location != null) { + } else if (size2 != null && MessageObject.isStickerMessage(sentMessage) && size2.location != null) { size.location = size2.location; + } else if (size2 != null && size2.location instanceof TLRPC.TL_fileLocationUnavailable) { + newMsg.media.document.thumb = sentMessage.media.document.thumb; } newMsg.media.document.dc_id = sentMessage.media.document.dc_id; @@ -2291,7 +2550,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter String name = f.getName(); String ext = ""; - int idx = path.lastIndexOf("."); + int idx = path.lastIndexOf('.'); if (idx != -1) { ext = path.substring(idx + 1); } @@ -2390,25 +2649,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter FileLog.e("tmessages", e); } if (bmOptions.outWidth != 0 && bmOptions.outHeight != 0 && bmOptions.outWidth <= 800 && bmOptions.outHeight <= 800) { - TLRPC.TL_documentAttributeSticker attributeSticker; - if (isEncrypted) { - int high_id = (int) (dialog_id >> 32); - TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(high_id); - if (encryptedChat == null) { - return false; - } - if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 46) { - attributeSticker = new TLRPC.TL_documentAttributeSticker(); - attributeSticker.alt = ""; - attributeSticker.stickerset = new TLRPC.TL_inputStickerSetEmpty(); - } else { - attributeSticker = new TLRPC.TL_documentAttributeSticker_old(); - } - } else { - attributeSticker = new TLRPC.TL_documentAttributeSticker(); - attributeSticker.alt = ""; - attributeSticker.stickerset = new TLRPC.TL_inputStickerSetEmpty(); - } + TLRPC.TL_documentAttributeSticker attributeSticker = new TLRPC.TL_documentAttributeSticker(); + attributeSticker.alt = ""; + attributeSticker.stickerset = new TLRPC.TL_inputStickerSetEmpty(); document.attributes.add(attributeSticker); TLRPC.TL_documentAttributeImageSize attributeImageSize = new TLRPC.TL_documentAttributeImageSize(); attributeImageSize.w = bmOptions.outWidth; @@ -2432,7 +2675,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - SendMessagesHelper.getInstance().sendMessage(documentFinal, null, pathFinal, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(documentFinal, null, pathFinal, dialog_id, reply_to_msg, asAdmin, null, params); } }); return true; @@ -2505,7 +2748,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - SendMessagesHelper.getInstance().sendMessage(documentFinal, null, messageObject.messageOwner.attachPath, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(documentFinal, null, messageObject.messageOwner.attachPath, dialog_id, reply_to_msg, asAdmin, null, params); } }); } @@ -2582,74 +2825,177 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter String finalPath = null; TLRPC.TL_document document = null; TLRPC.TL_photo photo = null; - if (result instanceof TLRPC.TL_botInlineMediaResultDocument) { + if (result instanceof TLRPC.TL_botInlineMediaResult) { if (result.document != null) { if (result.document instanceof TLRPC.TL_document) { document = (TLRPC.TL_document) result.document; } - } - } else if (result instanceof TLRPC.TL_botInlineMediaResultPhoto) { - if (result.photo != null) { + } else if (result.photo != null) { if (result.photo instanceof TLRPC.TL_photo) { photo = (TLRPC.TL_photo) result.photo; } } } else { - if (result.content_url != null) { - finalPath = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(result.content_url) + "." + ImageLoader.getHttpUrlExtension(result.content_url, "jpg")).getAbsolutePath(); - if (result.type.equals("gif")){ - document = new TLRPC.TL_document(); - document.id = 0; - document.date = ConnectionsManager.getInstance().getCurrentTime(); - TLRPC.TL_documentAttributeFilename fileName = new TLRPC.TL_documentAttributeFilename(); - fileName.file_name = "animation.gif"; - document.attributes.add(fileName); - document.size = 0; - document.dc_id = 0; - if (finalPath.endsWith("mp4")) { - document.mime_type = "video/mp4"; - document.attributes.add(new TLRPC.TL_documentAttributeAnimated()); - } else { - document.mime_type = "image/gif"; - } - try { - Bitmap bitmap; - if (finalPath.endsWith("mp4")) { - bitmap = ThumbnailUtils.createVideoThumbnail(finalPath, MediaStore.Video.Thumbnails.MINI_KIND); - } else { - bitmap = ImageLoader.loadBitmap(finalPath, null, 90, 90, true); + File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(result.content_url) + "." + ImageLoader.getHttpUrlExtension(result.content_url, "file")); + if (f.exists()) { + finalPath = f.getAbsolutePath(); + } else { + finalPath = result.content_url; + } + switch (result.type) { + case "audio": + case "voice": + case "file": + case "video": + case "sticker": + case "gif": { + document = new TLRPC.TL_document(); + document.id = 0; + document.size = 0; + document.dc_id = 0; + document.mime_type = result.content_type; + document.date = ConnectionsManager.getInstance().getCurrentTime(); + TLRPC.TL_documentAttributeFilename fileName = new TLRPC.TL_documentAttributeFilename(); + document.attributes.add(fileName); + + switch (result.type) { + case "gif": { + fileName.file_name = "animation.gif"; + if (finalPath.endsWith("mp4")) { + document.mime_type = "video/mp4"; + document.attributes.add(new TLRPC.TL_documentAttributeAnimated()); + } else { + document.mime_type = "image/gif"; + } + try { + Bitmap bitmap; + if (finalPath.endsWith("mp4")) { + bitmap = ThumbnailUtils.createVideoThumbnail(finalPath, MediaStore.Video.Thumbnails.MINI_KIND); + } else { + bitmap = ImageLoader.loadBitmap(finalPath, null, 90, 90, true); + } + if (bitmap != null) { + document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, false); + bitmap.recycle(); + } + } catch (Throwable e) { + FileLog.e("tmessages", e); + } + break; + } + case "voice": { + TLRPC.TL_documentAttributeAudio audio = new TLRPC.TL_documentAttributeAudio(); + audio.duration = result.duration; + audio.voice = true; + fileName.file_name = "audio.ogg"; + document.attributes.add(audio); + + document.thumb = new TLRPC.TL_photoSizeEmpty(); + document.thumb.type = "s"; + + break; + } + case "audio": { + TLRPC.TL_documentAttributeAudio audio = new TLRPC.TL_documentAttributeAudio(); + audio.duration = result.duration; + audio.title = result.title; + audio.flags |= 1; + if (result.description != null) { + audio.performer = result.description; + audio.flags |= 2; + } + fileName.file_name = "audio.mp3"; + document.attributes.add(audio); + + document.thumb = new TLRPC.TL_photoSizeEmpty(); + document.thumb.type = "s"; + + break; + } + case "file": { + int idx = result.content_type.indexOf('/'); + if (idx != -1) { + fileName.file_name = "file." + result.content_type.substring(idx + 1); + } else { + fileName.file_name = "file"; + } + break; + } + case "video": { + fileName.file_name = "video.mp4"; + TLRPC.TL_documentAttributeVideo attributeVideo = new TLRPC.TL_documentAttributeVideo(); + attributeVideo.w = result.w; + attributeVideo.h = result.h; + attributeVideo.duration = result.duration; + document.attributes.add(attributeVideo); + try { + String thumbPath = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(result.thumb_url) + "." + ImageLoader.getHttpUrlExtension(result.thumb_url, "jpg")).getAbsolutePath(); + Bitmap bitmap = ImageLoader.loadBitmap(thumbPath, null, 90, 90, true); + if (bitmap != null) { + document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, false); + bitmap.recycle(); + } + } catch (Throwable e) { + FileLog.e("tmessages", e); + } + break; + } + case "sticker": { + TLRPC.TL_documentAttributeSticker attributeSticker = new TLRPC.TL_documentAttributeSticker(); + attributeSticker.alt = ""; + attributeSticker.stickerset = new TLRPC.TL_inputStickerSetEmpty(); + document.attributes.add(attributeSticker); + TLRPC.TL_documentAttributeImageSize attributeImageSize = new TLRPC.TL_documentAttributeImageSize(); + attributeImageSize.w = result.w; + attributeImageSize.h = result.h; + document.attributes.add(attributeImageSize); + fileName.file_name = "sticker.webp"; + try { + String thumbPath = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(result.thumb_url) + "." + ImageLoader.getHttpUrlExtension(result.thumb_url, "webp")).getAbsolutePath(); + Bitmap bitmap = ImageLoader.loadBitmap(thumbPath, null, 90, 90, true); //TODO support on old androids + if (bitmap != null) { + document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, false); + bitmap.recycle(); + } + } catch (Throwable e) { + FileLog.e("tmessages", e); + } + break; + } } - if (bitmap != null) { - document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, false); - bitmap.recycle(); + if (fileName.file_name == null) { + fileName.file_name = "file"; } - } catch (Exception e) { - FileLog.e("tmessages", e); + if (document.mime_type == null) { + document.mime_type = "application/octet-stream"; + } + if (document.thumb == null) { + document.thumb = new TLRPC.TL_photoSize(); + document.thumb.w = result.w; + document.thumb.h = result.h; + document.thumb.size = 0; + document.thumb.location = new TLRPC.TL_fileLocationUnavailable(); + document.thumb.type = "x"; + } + break; } - if (document.thumb == null) { - document.thumb = new TLRPC.TL_photoSize(); - document.thumb.w = result.w; - document.thumb.h = result.h; - document.thumb.size = 0; - document.thumb.location = new TLRPC.TL_fileLocationUnavailable(); - document.thumb.type = "x"; - } - } else if (result.type.equals("photo")) { - File cacheFile = new File(finalPath); - if (cacheFile.exists()) { - photo = SendMessagesHelper.getInstance().generatePhotoSizes(cacheFile.toString(), null); - } - if (photo == null) { - photo = new TLRPC.TL_photo(); - photo.date = ConnectionsManager.getInstance().getCurrentTime(); - TLRPC.TL_photoSize photoSize = new TLRPC.TL_photoSize(); - photoSize.w = result.w; - photoSize.h = result.h; - photoSize.size = 1; - photoSize.location = new TLRPC.TL_fileLocationUnavailable(); - photoSize.type = "x"; - photo.sizes.add(photoSize); + case "photo": { + if (f.exists()) { + photo = SendMessagesHelper.getInstance().generatePhotoSizes(finalPath, null); + } + if (photo == null) { + photo = new TLRPC.TL_photo(); + photo.date = ConnectionsManager.getInstance().getCurrentTime(); + TLRPC.TL_photoSize photoSize = new TLRPC.TL_photoSize(); + photoSize.w = result.w; + photoSize.h = result.h; + photoSize.size = 1; + photoSize.location = new TLRPC.TL_fileLocationUnavailable(); + photoSize.type = "x"; + photo.sizes.add(photoSize); + } + break; } } } @@ -2665,17 +3011,35 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter public void run() { if (finalDocument != null) { finalDocument.caption = result.send_message.caption; - SendMessagesHelper.getInstance().sendMessage(finalDocument, null, finalPathFinal, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(finalDocument, null, finalPathFinal, dialog_id, reply_to_msg, asAdmin, result.send_message.reply_markup, params); } else if (finalPhoto != null) { finalPhoto.caption = result.send_message.caption; - SendMessagesHelper.getInstance().sendMessage(finalPhoto, result.content_url, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(finalPhoto, result.content_url, dialog_id, reply_to_msg, asAdmin, result.send_message.reply_markup, params); } } }); } }).run(); } else if (result.send_message instanceof TLRPC.TL_botInlineMessageText) { - SendMessagesHelper.getInstance().sendMessage(result.send_message.message, dialog_id, reply_to_msg, null, !result.send_message.no_webpage, asAdmin, result.send_message.entities, params); + SendMessagesHelper.getInstance().sendMessage(result.send_message.message, dialog_id, reply_to_msg, null, !result.send_message.no_webpage, asAdmin, result.send_message.entities, result.send_message.reply_markup, params); + } else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue) { + TLRPC.TL_messageMediaVenue venue = new TLRPC.TL_messageMediaVenue(); + venue.geo = result.send_message.geo; + venue.address = result.send_message.address; + venue.title = result.send_message.title; + venue.provider = result.send_message.provider; + venue.venue_id = result.send_message.venue_id; + SendMessagesHelper.getInstance().sendMessage(venue, dialog_id, reply_to_msg, asAdmin, result.send_message.reply_markup, params); + } else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo) { + TLRPC.TL_messageMediaGeo location = new TLRPC.TL_messageMediaGeo(); + location.geo = result.send_message.geo; + SendMessagesHelper.getInstance().sendMessage(location, dialog_id, reply_to_msg, asAdmin, result.send_message.reply_markup, params); + } else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaContact) { + TLRPC.User user = new TLRPC.TL_user(); + user.phone = result.send_message.phone_number; + user.first_name = result.send_message.first_name; + user.last_name = result.send_message.last_name; + SendMessagesHelper.getInstance().sendMessage(user, dialog_id, reply_to_msg, asAdmin, result.send_message.reply_markup, params); } } @@ -2775,7 +3139,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - SendMessagesHelper.getInstance().sendMessage(documentFinal, null, pathFinal, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(documentFinal, null, pathFinal, dialog_id, reply_to_msg, asAdmin, null, params); } }); } else { @@ -2825,7 +3189,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - SendMessagesHelper.getInstance().sendMessage(photoFinal, needDownloadHttpFinal ? searchImage.imageUrl : null, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(photoFinal, needDownloadHttpFinal ? searchImage.imageUrl : null, dialog_id, reply_to_msg, asAdmin, null, params); } }); } @@ -2864,7 +3228,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter int count = (int) Math.ceil(textFinal.length() / 4096.0f); for (int a = 0; a < count; a++) { String mess = textFinal.substring(a * 4096, Math.min((a + 1) * 4096, textFinal.length())); - SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, null, null, true, asAdmin, null, null); + SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, null, null, true, asAdmin, null, null, null); } } } @@ -2973,7 +3337,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - SendMessagesHelper.getInstance().sendMessage(photoFinal, null, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(photoFinal, null, dialog_id, reply_to_msg, asAdmin, null, params); } }); } @@ -3103,7 +3467,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - SendMessagesHelper.getInstance().sendMessage(videoFinal, videoEditedInfo, finalPath, dialog_id, reply_to_msg, asAdmin, params); + SendMessagesHelper.getInstance().sendMessage(videoFinal, videoEditedInfo, finalPath, dialog_id, reply_to_msg, asAdmin, null, params); } }); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ShareBroadcastReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/ShareBroadcastReceiver.java new file mode 100644 index 000000000..ab6b11638 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ShareBroadcastReceiver.java @@ -0,0 +1,29 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.messenger; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class ShareBroadcastReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + String url = intent.getDataString(); + if (url != null) { + Intent shareIntent = new Intent(Intent.ACTION_SEND); + shareIntent.setType("text/plain"); + shareIntent.putExtra(Intent.EXTRA_TEXT, url); + Intent chooserIntent = Intent.createChooser(shareIntent, LocaleController.getString("ShareLink", R.string.ShareLink)); + chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(chooserIntent); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java index 694180579..15bf1bb2d 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java @@ -47,7 +47,7 @@ public class Utilities { public native static void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride); public native static int pinBitmap(Bitmap bitmap); - public native static int unpinBitmap(Bitmap bitmap); + public native static void unpinBitmap(Bitmap bitmap); public native static void blurBitmap(Object bitmap, int radius, int unpin, int width, int height, int stride); public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer); public native static boolean loadWebpImage(Bitmap bitmap, ByteBuffer buffer, int len, BitmapFactory.Options options, boolean unpin); @@ -255,8 +255,8 @@ public class Utilities { java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); byte[] array = md.digest(md5.getBytes()); StringBuilder sb = new StringBuilder(); - for (byte anArray : array) { - sb.append(Integer.toHexString((anArray & 0xFF) | 0x100).substring(1, 3)); + for (int a = 0; a < array.length; a++) { + sb.append(Integer.toHexString((array[a] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } catch (java.security.NoSuchAlgorithmException e) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/WearReplyReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/WearReplyReceiver.java index 46371c2bf..911daf078 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/WearReplyReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/WearReplyReceiver.java @@ -18,6 +18,7 @@ public class WearReplyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + ApplicationLoader.postInitApplication(); Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) { return; @@ -31,7 +32,7 @@ public class WearReplyReceiver extends BroadcastReceiver { if (dialog_id == 0 || max_id == 0) { return; } - SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false, null, null); + SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false, null, null, null); MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false); } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java new file mode 100644 index 000000000..ae01ce9a2 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java @@ -0,0 +1,188 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.messenger.browser; + +import android.app.Activity; +import android.app.PendingIntent; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.text.TextUtils; + +import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; +import org.telegram.messenger.MediaController; +import org.telegram.messenger.R; +import org.telegram.messenger.ShareBroadcastReceiver; +import org.telegram.messenger.support.customtabs.CustomTabsCallback; +import org.telegram.messenger.support.customtabs.CustomTabsClient; +import org.telegram.messenger.support.customtabs.CustomTabsIntent; +import org.telegram.messenger.support.customtabs.CustomTabsServiceConnection; +import org.telegram.messenger.support.customtabs.CustomTabsSession; +import org.telegram.messenger.support.customtabsclient.shared.CustomTabsHelper; +import org.telegram.messenger.support.customtabsclient.shared.ServiceConnection; +import org.telegram.messenger.support.customtabsclient.shared.ServiceConnectionCallback; +import org.telegram.ui.ActionBar.Theme; +import org.telegram.ui.LaunchActivity; + +import java.lang.ref.WeakReference; + +public class Browser { + + private static WeakReference customTabsCurrentSession; + private static CustomTabsSession customTabsSession; + private static CustomTabsClient customTabsClient; + private static CustomTabsServiceConnection customTabsServiceConnection; + private static String customTabsPackageToBind; + private static WeakReference currentCustomTabsActivity; + + private static CustomTabsSession getCurrentSession() { + return customTabsCurrentSession == null ? null : customTabsCurrentSession.get(); + } + + private static void setCurrentSession(CustomTabsSession session) { + customTabsCurrentSession = new WeakReference<>(session); + } + + private static CustomTabsSession getSession() { + if (customTabsClient == null) { + customTabsSession = null; + } else if (customTabsSession == null) { + customTabsSession = customTabsClient.newSession(new NavigationCallback()); + setCurrentSession(customTabsSession); + } + return customTabsSession; + } + + public static void bindCustomTabsService(Activity activity) { + if (Build.VERSION.SDK_INT < 15) { + return; + } + Activity currentActivity = currentCustomTabsActivity == null ? null : currentCustomTabsActivity.get(); + if (currentActivity != null && currentActivity != activity) { + unbindCustomTabsService(currentActivity); + } + if (customTabsClient != null) { + return; + } + currentCustomTabsActivity = new WeakReference<>(activity); + try { + if (TextUtils.isEmpty(customTabsPackageToBind)) { + customTabsPackageToBind = CustomTabsHelper.getPackageNameToUse(activity); + if (customTabsPackageToBind == null) { + return; + } + } + customTabsServiceConnection = new ServiceConnection(new ServiceConnectionCallback() { + @Override + public void onServiceConnected(CustomTabsClient client) { + customTabsClient = client; + if (customTabsClient != null) { + customTabsClient.warmup(0); + } + } + + @Override + public void onServiceDisconnected() { + customTabsClient = null; + } + }); + if (!CustomTabsClient.bindCustomTabsService(activity, customTabsPackageToBind, customTabsServiceConnection)) { + customTabsServiceConnection = null; + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + + public static void unbindCustomTabsService(Activity activity) { + if (Build.VERSION.SDK_INT < 15 || customTabsServiceConnection == null) { + return; + } + Activity currentActivity = currentCustomTabsActivity == null ? null : currentCustomTabsActivity.get(); + if (currentActivity == activity) { + currentCustomTabsActivity.clear(); + } + try { + activity.unbindService(customTabsServiceConnection); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + customTabsClient = null; + customTabsSession = null; + } + + private static class NavigationCallback extends CustomTabsCallback { + @Override + public void onNavigationEvent(int navigationEvent, Bundle extras) { + FileLog.e("tmessages", "code = " + navigationEvent + " extras " + extras); + } + } + + public static void openUrl(Context context, String url) { + openUrl(context, Uri.parse(url), true); + } + + public static void openUrl(Context context, Uri uri) { + openUrl(context, uri, true); + } + + public static void openUrl(Context context, String url, boolean allowCustom) { + if (context == null || url == null) { + return; + } + openUrl(context, Uri.parse(url), allowCustom); + } + + public static void openUrl(Context context, Uri uri, boolean allowCustom) { + if (context == null || uri == null) { + return; + } + + try { + boolean internalUri = isInternalUri(uri); + if (Build.VERSION.SDK_INT >= 15 && allowCustom && MediaController.getInstance().canCustomTabs() && !internalUri) { + Intent share = new Intent(ApplicationLoader.applicationContext, ShareBroadcastReceiver.class); + share.setAction(Intent.ACTION_SEND); + + CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getSession()); + builder.setToolbarColor(Theme.ACTION_BAR_COLOR); + builder.setShowTitle(true); + builder.setActionButton(BitmapFactory.decodeResource(context.getResources(), R.drawable.abc_ic_menu_share_mtrl_alpha), LocaleController.getString("ShareFile", R.string.ShareFile), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, share, 0), false); + CustomTabsIntent intent = builder.build(); + intent.launchUrl((Activity) context, uri); + } else { + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + if (internalUri) { + ComponentName componentName = new ComponentName(context.getPackageName(), LaunchActivity.class.getName()); + intent.setComponent(componentName); + } + intent.putExtra(android.provider.Browser.EXTRA_APPLICATION_ID, context.getPackageName()); + context.startActivity(intent); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + + public static boolean isInternalUrl(String url) { + return isInternalUri(Uri.parse(url)); + } + + public static boolean isInternalUri(Uri uri) { + String host = uri.getHost(); + host = host != null ? host.toLowerCase() : ""; + return "tg".equals(uri.getScheme()) || "telegram.me".equals(host) || "telegram.dog".equals(host); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java b/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java index ee2a33f4c..2a1841784 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java @@ -144,12 +144,14 @@ public class SharedMediaQuery { if (message == null) { return -1; } - if (message.media instanceof TLRPC.TL_messageMediaPhoto || MessageObject.isVideoMessage(message)) { + if (message.media instanceof TLRPC.TL_messageMediaPhoto) { return MEDIA_PHOTOVIDEO; - } else if (MessageObject.isVoiceMessage(message)) { - return MEDIA_AUDIO; } else if (message.media instanceof TLRPC.TL_messageMediaDocument) { - if (MessageObject.isStickerMessage(message)) { + if (MessageObject.isVoiceMessage(message)) { + return MEDIA_AUDIO; + } else if (MessageObject.isVideoMessage(message)) { + return MEDIA_PHOTOVIDEO; + } else if (MessageObject.isStickerMessage(message)) { return -1; } else if (MessageObject.isMusicMessage(message)) { return MEDIA_MUSIC; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/query/StickersQuery.java b/TMessagesProj/src/main/java/org/telegram/messenger/query/StickersQuery.java index c20586648..bbc794bb2 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/query/StickersQuery.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/query/StickersQuery.java @@ -8,11 +8,7 @@ package org.telegram.messenger.query; -import android.app.AlertDialog; -import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; -import android.os.Message; import android.widget.Toast; import org.telegram.SQLite.SQLiteCursor; @@ -29,8 +25,6 @@ import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.Utilities; -import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.Components.StickersAlert; import java.util.ArrayList; import java.util.Collections; @@ -85,6 +79,14 @@ public class StickersQuery { return document; } + public static TLRPC.TL_messages_stickerSet getStickerSetByName(String name) { + return stickerSetsByName.get(name); + } + + public static TLRPC.TL_messages_stickerSet getStickerSetById(Long id) { + return stickerSetsById.get(id); + } + public static HashMap> getAllStickers() { return allStickers; } @@ -441,100 +443,6 @@ public class StickersQuery { }); } - public static void loadStickers(final BaseFragment fragment, final TLRPC.InputStickerSet stickerSet) { - if (fragment == null || stickerSet == null) { - return; - } - - final ProgressDialog progressDialog = new ProgressDialog(fragment.getParentActivity()); - progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); - progressDialog.setCanceledOnTouchOutside(false); - progressDialog.setCancelable(false); - - TLRPC.TL_messages_getStickerSet req = new TLRPC.TL_messages_getStickerSet(); - req.stickerset = stickerSet; - - final int reqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(final TLObject response, final TLRPC.TL_error error) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - try { - progressDialog.dismiss(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - if (fragment.getParentActivity() != null && !fragment.getParentActivity().isFinishing()) { - if (error == null) { - final TLRPC.TL_messages_stickerSet res = (TLRPC.TL_messages_stickerSet) response; - - StickersAlert alert = new StickersAlert(fragment.getParentActivity(), res); - if (res.set == null || !StickersQuery.isStickerPackInstalled(res.set.id)) { - alert.setButton(AlertDialog.BUTTON_POSITIVE, LocaleController.getString("AddStickers", R.string.AddStickers), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - TLRPC.TL_messages_installStickerSet req = new TLRPC.TL_messages_installStickerSet(); - req.stickerset = stickerSet; - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(TLObject response, final TLRPC.TL_error error) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - if (fragment.getParentActivity() != null) { - if (error == null) { - Toast.makeText(fragment.getParentActivity(), LocaleController.getString("AddStickersInstalled", R.string.AddStickersInstalled), Toast.LENGTH_SHORT).show(); - } else { - if (error.text.equals("STICKERSETS_TOO_MUCH")) { - Toast.makeText(fragment.getParentActivity(), LocaleController.getString("TooMuchStickersets", R.string.TooMuchStickersets), Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(fragment.getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred), Toast.LENGTH_SHORT).show(); - } - } - } - loadStickers(false, true); - } - }); - } - }); - } - }); - } else { - alert.setButton(AlertDialog.BUTTON_NEUTRAL, LocaleController.getString("StickersRemove", R.string.StickersRemove), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - removeStickersSet(fragment.getParentActivity(), res.set, 0); - } - }); - } - alert.setButton(AlertDialog.BUTTON_NEGATIVE, LocaleController.getString("Close", R.string.Close), (Message) null); - fragment.setVisibleDialog(alert); - alert.show(); - } else { - Toast.makeText(fragment.getParentActivity(), LocaleController.getString("AddStickersNotFound", R.string.AddStickersNotFound), Toast.LENGTH_SHORT).show(); - } - } - } - }); - } - }); - - progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - ConnectionsManager.getInstance().cancelRequest(reqId, true); - try { - dialog.dismiss(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - }); - fragment.setVisibleDialog(progressDialog); - progressDialog.show(); - } - public static void removeStickersSet(final Context context, TLRPC.StickerSet stickerSet, int hide) { TLRPC.TL_inputStickerSetID stickerSetID = new TLRPC.TL_inputStickerSetID(); stickerSetID.access_hash = stickerSet.access_hash; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsCallback.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsCallback.java new file mode 100755 index 000000000..f5cb4a320 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsCallback.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.os.Bundle; + +/** + * A callback class for custom tabs client to get messages regarding events in their custom tabs. + */ +public class CustomTabsCallback { + public static final int NAVIGATION_STARTED = 1; + public static final int NAVIGATION_FINISHED = 2; + public static final int NAVIGATION_FAILED = 3; + public static final int NAVIGATION_ABORTED = 4; + public static final int TAB_SHOWN = 5; + public static final int TAB_HIDDEN = 6; + + public CustomTabsCallback() { + } + + public void onNavigationEvent(int navigationEvent, Bundle extras) { + } + + public void extraCallback(String callbackName, Bundle args) { + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsClient.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsClient.java new file mode 100755 index 000000000..d80d30b54 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsClient.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.RemoteException; +import android.text.TextUtils; + +public class CustomTabsClient { + private final ICustomTabsService mService; + private final ComponentName mServiceComponentName; + + CustomTabsClient(ICustomTabsService service, ComponentName componentName) { + this.mService = service; + this.mServiceComponentName = componentName; + } + + public static boolean bindCustomTabsService(Context context, String packageName, CustomTabsServiceConnection connection) { + Intent intent = new Intent("android.support.customtabs.action.CustomTabsService"); + if (!TextUtils.isEmpty(packageName)) { + intent.setPackage(packageName); + } + + return context.bindService(intent, connection, 33); + } + + public boolean warmup(long flags) { + try { + return this.mService.warmup(flags); + } catch (RemoteException var4) { + return false; + } + } + + public CustomTabsSession newSession(final CustomTabsCallback callback) { + ICustomTabsCallback.Stub wrapper = new ICustomTabsCallback.Stub() { + public void onNavigationEvent(int navigationEvent, Bundle extras) { + if (callback != null) { + callback.onNavigationEvent(navigationEvent, extras); + } + + } + + public void extraCallback(String callbackName, Bundle args) throws RemoteException { + if (callback != null) { + callback.extraCallback(callbackName, args); + } + + } + }; + + try { + if (!this.mService.newSession(wrapper)) { + return null; + } + } catch (RemoteException var4) { + return null; + } + + return new CustomTabsSession(this.mService, wrapper, this.mServiceComponentName); + } + + public Bundle extraCommand(String commandName, Bundle args) { + try { + return this.mService.extraCommand(commandName, args); + } catch (RemoteException var4) { + return null; + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsIntent.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsIntent.java new file mode 100755 index 000000000..16bf9526f --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsIntent.java @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.app.Activity; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.support.annotation.AnimRes; +import android.support.annotation.ColorInt; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; +import android.support.v4.app.BundleCompat; + +import java.util.ArrayList; + +/** + * Class holding the {@link Intent} and start bundle for a Custom Tabs Activity. + * + *

+ * Note: The constants below are public for the browser implementation's benefit. + * You are strongly encouraged to use {@link CustomTabsIntent.Builder}.

+ */ +public final class CustomTabsIntent { + public static final String EXTRA_SESSION = "android.support.customtabs.extra.SESSION"; + public static final String EXTRA_TOOLBAR_COLOR = "android.support.customtabs.extra.TOOLBAR_COLOR"; + public static final String EXTRA_ENABLE_URLBAR_HIDING = "android.support.customtabs.extra.ENABLE_URLBAR_HIDING"; + public static final String EXTRA_CLOSE_BUTTON_ICON = "android.support.customtabs.extra.CLOSE_BUTTON_ICON"; + public static final String EXTRA_TITLE_VISIBILITY_STATE = "android.support.customtabs.extra.TITLE_VISIBILITY"; + public static final int NO_TITLE = 0; + public static final int SHOW_PAGE_TITLE = 1; + public static final String EXTRA_ACTION_BUTTON_BUNDLE = "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE"; + public static final String EXTRA_TOOLBAR_ITEMS = "android.support.customtabs.extra.TOOLBAR_ITEMS"; + public static final String EXTRA_SECONDARY_TOOLBAR_COLOR = "android.support.customtabs.extra.SECONDARY_TOOLBAR_COLOR"; + public static final String KEY_ICON = "android.support.customtabs.customaction.ICON"; + public static final String KEY_DESCRIPTION = "android.support.customtabs.customaction.DESCRIPTION"; + public static final String KEY_PENDING_INTENT = "android.support.customtabs.customaction.PENDING_INTENT"; + public static final String EXTRA_TINT_ACTION_BUTTON = "android.support.customtabs.extra.TINT_ACTION_BUTTON"; + public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS"; + public static final String KEY_MENU_ITEM_TITLE = "android.support.customtabs.customaction.MENU_ITEM_TITLE"; + public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE"; + public static final String EXTRA_DEFAULT_SHARE_MENU_ITEM = "android.support.customtabs.extra.SHARE_MENU_ITEM"; + public static final String KEY_ID = "android.support.customtabs.customaction.ID"; + public static final int TOOLBAR_ACTION_BUTTON_ID = 0; + private static final int MAX_TOOLBAR_ITEMS = 5; + @NonNull + public final Intent intent; + @Nullable + public final Bundle startAnimationBundle; + + public void launchUrl(Activity context, Uri url) { + this.intent.setData(url); + ActivityCompat.startActivity(context, this.intent, this.startAnimationBundle); + } + + private CustomTabsIntent(Intent intent, Bundle startAnimationBundle) { + this.intent = intent; + this.startAnimationBundle = startAnimationBundle; + } + + public static int getMaxToolbarItems() { + return 5; + } + + public static final class Builder { + private final Intent mIntent; + private ArrayList mMenuItems; + private Bundle mStartAnimationBundle; + private ArrayList mActionButtons; + + public Builder() { + this(null); + } + + public Builder(@Nullable CustomTabsSession session) { + this.mIntent = new Intent("android.intent.action.VIEW"); + this.mMenuItems = null; + this.mStartAnimationBundle = null; + this.mActionButtons = null; + if (session != null) { + this.mIntent.setPackage(session.getComponentName().getPackageName()); + } + + Bundle bundle = new Bundle(); + BundleCompat.putBinder(bundle, "android.support.customtabs.extra.SESSION", session == null ? null : session.getBinder()); + this.mIntent.putExtras(bundle); + } + + public CustomTabsIntent.Builder setToolbarColor(@ColorInt int color) { + this.mIntent.putExtra("android.support.customtabs.extra.TOOLBAR_COLOR", color); + return this; + } + + public CustomTabsIntent.Builder enableUrlBarHiding() { + this.mIntent.putExtra("android.support.customtabs.extra.ENABLE_URLBAR_HIDING", true); + return this; + } + + public CustomTabsIntent.Builder setCloseButtonIcon(@NonNull Bitmap icon) { + this.mIntent.putExtra("android.support.customtabs.extra.CLOSE_BUTTON_ICON", icon); + return this; + } + + public CustomTabsIntent.Builder setShowTitle(boolean showTitle) { + this.mIntent.putExtra("android.support.customtabs.extra.TITLE_VISIBILITY", showTitle ? 1 : 0); + return this; + } + + public CustomTabsIntent.Builder addMenuItem(@NonNull String label, @NonNull PendingIntent pendingIntent) { + if (this.mMenuItems == null) { + this.mMenuItems = new ArrayList(); + } + + Bundle bundle = new Bundle(); + bundle.putString("android.support.customtabs.customaction.MENU_ITEM_TITLE", label); + bundle.putParcelable("android.support.customtabs.customaction.PENDING_INTENT", pendingIntent); + this.mMenuItems.add(bundle); + return this; + } + + public CustomTabsIntent.Builder addDefaultShareMenuItem() { + this.mIntent.putExtra("android.support.customtabs.extra.SHARE_MENU_ITEM", true); + return this; + } + + public CustomTabsIntent.Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, @NonNull PendingIntent pendingIntent, boolean shouldTint) { + Bundle bundle = new Bundle(); + bundle.putInt("android.support.customtabs.customaction.ID", 0); + bundle.putParcelable("android.support.customtabs.customaction.ICON", icon); + bundle.putString("android.support.customtabs.customaction.DESCRIPTION", description); + bundle.putParcelable("android.support.customtabs.customaction.PENDING_INTENT", pendingIntent); + this.mIntent.putExtra("android.support.customtabs.extra.ACTION_BUTTON_BUNDLE", bundle); + this.mIntent.putExtra("android.support.customtabs.extra.TINT_ACTION_BUTTON", shouldTint); + return this; + } + + public CustomTabsIntent.Builder setActionButton(@NonNull Bitmap icon, @NonNull String description, @NonNull PendingIntent pendingIntent) { + return this.setActionButton(icon, description, pendingIntent, false); + } + + public CustomTabsIntent.Builder addToolbarItem(int id, @NonNull Bitmap icon, @NonNull String description, PendingIntent pendingIntent) throws IllegalStateException { + if (this.mActionButtons == null) { + this.mActionButtons = new ArrayList(); + } + + if (this.mActionButtons.size() >= 5) { + throw new IllegalStateException("Exceeded maximum toolbar item count of 5"); + } else { + Bundle bundle = new Bundle(); + bundle.putInt("android.support.customtabs.customaction.ID", id); + bundle.putParcelable("android.support.customtabs.customaction.ICON", icon); + bundle.putString("android.support.customtabs.customaction.DESCRIPTION", description); + bundle.putParcelable("android.support.customtabs.customaction.PENDING_INTENT", pendingIntent); + this.mActionButtons.add(bundle); + return this; + } + } + + public CustomTabsIntent.Builder setSecondaryToolbarColor(@ColorInt int color) { + this.mIntent.putExtra("android.support.customtabs.extra.SECONDARY_TOOLBAR_COLOR", color); + return this; + } + + public CustomTabsIntent.Builder setStartAnimations(@NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId) { + this.mStartAnimationBundle = ActivityOptionsCompat.makeCustomAnimation(context, enterResId, exitResId).toBundle(); + return this; + } + + public CustomTabsIntent.Builder setExitAnimations(@NonNull Context context, @AnimRes int enterResId, @AnimRes int exitResId) { + Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(context, enterResId, exitResId).toBundle(); + this.mIntent.putExtra("android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE", bundle); + return this; + } + + public CustomTabsIntent build() { + if (this.mMenuItems != null) { + this.mIntent.putParcelableArrayListExtra("android.support.customtabs.extra.MENU_ITEMS", this.mMenuItems); + } + + if (this.mActionButtons != null) { + this.mIntent.putParcelableArrayListExtra("android.support.customtabs.extra.TOOLBAR_ITEMS", this.mActionButtons); + } + + return new CustomTabsIntent(this.mIntent, this.mStartAnimationBundle); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsService.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsService.java new file mode 100755 index 000000000..aa60199f9 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsService.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.app.Service; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.IBinder; +import android.os.IBinder.DeathRecipient; +import android.os.RemoteException; +import android.support.v4.util.ArrayMap; + +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +public abstract class CustomTabsService extends Service { + public static final String ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService"; + public static final String KEY_URL = "android.support.customtabs.otherurls.URL"; + private final Map mDeathRecipientMap = new ArrayMap(); + private ICustomTabsService.Stub mBinder = new ICustomTabsService.Stub() { + public boolean warmup(long flags) { + return CustomTabsService.this.warmup(flags); + } + + public boolean newSession(ICustomTabsCallback callback) { + final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback); + + try { + DeathRecipient e = new DeathRecipient() { + public void binderDied() { + CustomTabsService.this.cleanUpSession(sessionToken); + } + }; + synchronized (CustomTabsService.this.mDeathRecipientMap) { + callback.asBinder().linkToDeath(e, 0); + CustomTabsService.this.mDeathRecipientMap.put(callback.asBinder(), e); + } + + return CustomTabsService.this.newSession(sessionToken); + } catch (RemoteException var7) { + return false; + } + } + + public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, Bundle extras, List otherLikelyBundles) { + return CustomTabsService.this.mayLaunchUrl(new CustomTabsSessionToken(callback), url, extras, otherLikelyBundles); + } + + public Bundle extraCommand(String commandName, Bundle args) { + return CustomTabsService.this.extraCommand(commandName, args); + } + + public boolean updateVisuals(ICustomTabsCallback callback, Bundle bundle) { + return CustomTabsService.this.updateVisuals(new CustomTabsSessionToken(callback), bundle); + } + }; + + public CustomTabsService() { + } + + public IBinder onBind(Intent intent) { + return this.mBinder; + } + + protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) { + try { + Map e = this.mDeathRecipientMap; + synchronized (this.mDeathRecipientMap) { + IBinder binder = sessionToken.getCallbackBinder(); + DeathRecipient deathRecipient = this.mDeathRecipientMap.get(binder); + binder.unlinkToDeath(deathRecipient, 0); + this.mDeathRecipientMap.remove(binder); + return true; + } + } catch (NoSuchElementException var7) { + return false; + } + } + + protected abstract boolean warmup(long var1); + + protected abstract boolean newSession(CustomTabsSessionToken var1); + + protected abstract boolean mayLaunchUrl(CustomTabsSessionToken var1, Uri var2, Bundle var3, List var4); + + protected abstract Bundle extraCommand(String var1, Bundle var2); + + protected abstract boolean updateVisuals(CustomTabsSessionToken var1, Bundle var2); +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsServiceConnection.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsServiceConnection.java new file mode 100755 index 000000000..7998b02dd --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsServiceConnection.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.content.ComponentName; +import android.content.ServiceConnection; +import android.os.IBinder; + +public abstract class CustomTabsServiceConnection implements ServiceConnection { + public CustomTabsServiceConnection() { + } + + public final void onServiceConnected(final ComponentName name, IBinder service) { + this.onCustomTabsServiceConnected(name, new CustomTabsClient(ICustomTabsService.Stub.asInterface(service), name) { + }); + } + + public abstract void onCustomTabsServiceConnected(ComponentName var1, CustomTabsClient var2); +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsSession.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsSession.java new file mode 100755 index 000000000..a84755a4f --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsSession.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.content.ComponentName; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.os.IBinder; +import android.os.RemoteException; +import android.support.annotation.NonNull; + +import java.util.List; + +/** + * A class to be used for Custom Tabs related communication. Clients that want to launch Custom Tabs + * can use this class exclusively to handle all related communication. + */ +public final class CustomTabsSession { + private static final String TAG = "CustomTabsSession"; + private final ICustomTabsService mService; + private final ICustomTabsCallback mCallback; + private final ComponentName mComponentName; + + CustomTabsSession(ICustomTabsService service, ICustomTabsCallback callback, ComponentName componentName) { + this.mService = service; + this.mCallback = callback; + this.mComponentName = componentName; + } + + public boolean mayLaunchUrl(Uri url, Bundle extras, List otherLikelyBundles) { + try { + return this.mService.mayLaunchUrl(this.mCallback, url, extras, otherLikelyBundles); + } catch (RemoteException var5) { + return false; + } + } + + public boolean setActionButton(@NonNull Bitmap icon, @NonNull String description) { + return this.setToolbarItem(0, icon, description); + } + + public boolean setToolbarItem(int id, @NonNull Bitmap icon, @NonNull String description) { + Bundle bundle = new Bundle(); + bundle.putInt("android.support.customtabs.customaction.ID", id); + bundle.putParcelable("android.support.customtabs.customaction.ICON", icon); + bundle.putString("android.support.customtabs.customaction.DESCRIPTION", description); + Bundle metaBundle = new Bundle(); + metaBundle.putBundle("android.support.customtabs.extra.ACTION_BUTTON_BUNDLE", bundle); + + try { + return this.mService.updateVisuals(this.mCallback, metaBundle); + } catch (RemoteException var7) { + return false; + } + } + + IBinder getBinder() { + return this.mCallback.asBinder(); + } + + ComponentName getComponentName() { + return this.mComponentName; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsSessionToken.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsSessionToken.java new file mode 100755 index 000000000..007081773 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/CustomTabsSessionToken.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.content.Intent; +import android.os.Bundle; +import android.os.IBinder; +import android.os.RemoteException; +import android.support.v4.app.BundleCompat; +import android.util.Log; + +/** + * Wrapper class that can be used as a unique identifier for a session. Also contains an accessor + * for the {@link CustomTabsCallback} for the session if there was any. + */ +public class CustomTabsSessionToken { + private static final String TAG = "CustomTabsSessionToken"; + private final ICustomTabsCallback mCallbackBinder; + private final CustomTabsCallback mCallback; + + public static CustomTabsSessionToken getSessionTokenFromIntent(Intent intent) { + Bundle b = intent.getExtras(); + IBinder binder = BundleCompat.getBinder(b, "android.support.customtabs.extra.SESSION"); + return binder == null ? null : new CustomTabsSessionToken(ICustomTabsCallback.Stub.asInterface(binder)); + } + + CustomTabsSessionToken(ICustomTabsCallback callbackBinder) { + this.mCallbackBinder = callbackBinder; + this.mCallback = new CustomTabsCallback() { + public void onNavigationEvent(int navigationEvent, Bundle extras) { + try { + CustomTabsSessionToken.this.mCallbackBinder.onNavigationEvent(navigationEvent, extras); + } catch (RemoteException var4) { + Log.e("CustomTabsSessionToken", "RemoteException during ICustomTabsCallback transaction"); + } + + } + }; + } + + IBinder getCallbackBinder() { + return this.mCallbackBinder.asBinder(); + } + + public int hashCode() { + return this.getCallbackBinder().hashCode(); + } + + public boolean equals(Object o) { + if (!(o instanceof CustomTabsSessionToken)) { + return false; + } else { + CustomTabsSessionToken token = (CustomTabsSessionToken) o; + return token.getCallbackBinder().equals(this.mCallbackBinder.asBinder()); + } + } + + public CustomTabsCallback getCallback() { + return this.mCallback; + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/ICustomTabsCallback.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/ICustomTabsCallback.java new file mode 100755 index 000000000..2d311a4d5 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/ICustomTabsCallback.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.os.Binder; +import android.os.Bundle; +import android.os.IBinder; +import android.os.IInterface; +import android.os.Parcel; +import android.os.RemoteException; + +public interface ICustomTabsCallback extends IInterface { + void onNavigationEvent(int var1, Bundle var2) throws RemoteException; + + void extraCallback(String var1, Bundle var2) throws RemoteException; + + abstract class Stub extends Binder implements ICustomTabsCallback { + private static final String DESCRIPTOR = "android.support.customtabs.ICustomTabsCallback"; + static final int TRANSACTION_onNavigationEvent = 2; + static final int TRANSACTION_extraCallback = 3; + + public Stub() { + this.attachInterface(this, "android.support.customtabs.ICustomTabsCallback"); + } + + public static ICustomTabsCallback asInterface(IBinder obj) { + if (obj == null) { + return null; + } else { + IInterface iin = obj.queryLocalInterface("android.support.customtabs.ICustomTabsCallback"); + return (iin != null && iin instanceof ICustomTabsCallback ? (ICustomTabsCallback) iin : new ICustomTabsCallback.Stub.Proxy(obj)); + } + } + + public IBinder asBinder() { + return this; + } + + public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { + Bundle _arg1; + switch (code) { + case 2: + data.enforceInterface("android.support.customtabs.ICustomTabsCallback"); + int _arg01 = data.readInt(); + if (0 != data.readInt()) { + _arg1 = Bundle.CREATOR.createFromParcel(data); + } else { + _arg1 = null; + } + + this.onNavigationEvent(_arg01, _arg1); + return true; + case 3: + data.enforceInterface("android.support.customtabs.ICustomTabsCallback"); + String _arg0 = data.readString(); + if (0 != data.readInt()) { + _arg1 = Bundle.CREATOR.createFromParcel(data); + } else { + _arg1 = null; + } + + this.extraCallback(_arg0, _arg1); + return true; + case 1598968902: + reply.writeString("android.support.customtabs.ICustomTabsCallback"); + return true; + default: + return super.onTransact(code, data, reply, flags); + } + } + + private static class Proxy implements ICustomTabsCallback { + private IBinder mRemote; + + Proxy(IBinder remote) { + this.mRemote = remote; + } + + public IBinder asBinder() { + return this.mRemote; + } + + public String getInterfaceDescriptor() { + return "android.support.customtabs.ICustomTabsCallback"; + } + + public void onNavigationEvent(int navigationEvent, Bundle extras) throws RemoteException { + Parcel _data = Parcel.obtain(); + + try { + _data.writeInterfaceToken("android.support.customtabs.ICustomTabsCallback"); + _data.writeInt(navigationEvent); + if (extras != null) { + _data.writeInt(1); + extras.writeToParcel(_data, 0); + } else { + _data.writeInt(0); + } + + this.mRemote.transact(2, _data, null, 1); + } finally { + _data.recycle(); + } + + } + + public void extraCallback(String callbackName, Bundle args) throws RemoteException { + Parcel _data = Parcel.obtain(); + + try { + _data.writeInterfaceToken("android.support.customtabs.ICustomTabsCallback"); + _data.writeString(callbackName); + if (args != null) { + _data.writeInt(1); + args.writeToParcel(_data, 0); + } else { + _data.writeInt(0); + } + + this.mRemote.transact(3, _data, null, 1); + } finally { + _data.recycle(); + } + + } + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/ICustomTabsService.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/ICustomTabsService.java new file mode 100755 index 000000000..fefde3666 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabs/ICustomTabsService.java @@ -0,0 +1,291 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.telegram.messenger.support.customtabs; + +import android.net.Uri; +import android.os.Binder; +import android.os.Bundle; +import android.os.IBinder; +import android.os.IInterface; +import android.os.Parcel; +import android.os.RemoteException; + +import java.util.ArrayList; +import java.util.List; + +public interface ICustomTabsService extends IInterface { + boolean warmup(long var1) throws RemoteException; + + boolean newSession(ICustomTabsCallback var1) throws RemoteException; + + boolean mayLaunchUrl(ICustomTabsCallback var1, Uri var2, Bundle var3, List var4) throws RemoteException; + + Bundle extraCommand(String var1, Bundle var2) throws RemoteException; + + boolean updateVisuals(ICustomTabsCallback var1, Bundle var2) throws RemoteException; + + abstract class Stub extends Binder implements ICustomTabsService { + private static final String DESCRIPTOR = "android.support.customtabs.ICustomTabsService"; + static final int TRANSACTION_warmup = 2; + static final int TRANSACTION_newSession = 3; + static final int TRANSACTION_mayLaunchUrl = 4; + static final int TRANSACTION_extraCommand = 5; + static final int TRANSACTION_updateVisuals = 6; + + public Stub() { + this.attachInterface(this, "android.support.customtabs.ICustomTabsService"); + } + + public static ICustomTabsService asInterface(IBinder obj) { + if (obj == null) { + return null; + } else { + IInterface iin = obj.queryLocalInterface("android.support.customtabs.ICustomTabsService"); + return (iin != null && iin instanceof ICustomTabsService ? (ICustomTabsService) iin : new ICustomTabsService.Stub.Proxy(obj)); + } + } + + public IBinder asBinder() { + return this; + } + + public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { + ICustomTabsCallback _arg0; + Bundle _arg1; + boolean _result; + Bundle _result2; + switch (code) { + case 2: + data.enforceInterface("android.support.customtabs.ICustomTabsService"); + long _arg02 = data.readLong(); + _result = this.warmup(_arg02); + reply.writeNoException(); + reply.writeInt(_result ? 1 : 0); + return true; + case 3: + data.enforceInterface("android.support.customtabs.ICustomTabsService"); + _arg0 = ICustomTabsCallback.Stub.asInterface(data.readStrongBinder()); + boolean _arg12 = this.newSession(_arg0); + reply.writeNoException(); + reply.writeInt(_arg12 ? 1 : 0); + return true; + case 4: + data.enforceInterface("android.support.customtabs.ICustomTabsService"); + _arg0 = ICustomTabsCallback.Stub.asInterface(data.readStrongBinder()); + Uri _arg11; + if (0 != data.readInt()) { + _arg11 = Uri.CREATOR.createFromParcel(data); + } else { + _arg11 = null; + } + + if (0 != data.readInt()) { + _result2 = Bundle.CREATOR.createFromParcel(data); + } else { + _result2 = null; + } + + ArrayList _arg3 = data.createTypedArrayList(Bundle.CREATOR); + boolean _result1 = this.mayLaunchUrl(_arg0, _arg11, _result2, _arg3); + reply.writeNoException(); + reply.writeInt(_result1 ? 1 : 0); + return true; + case 5: + data.enforceInterface("android.support.customtabs.ICustomTabsService"); + String _arg01 = data.readString(); + if (0 != data.readInt()) { + _arg1 = Bundle.CREATOR.createFromParcel(data); + } else { + _arg1 = null; + } + + _result2 = this.extraCommand(_arg01, _arg1); + reply.writeNoException(); + if (_result2 != null) { + reply.writeInt(1); + _result2.writeToParcel(reply, 1); + } else { + reply.writeInt(0); + } + + return true; + case 6: + data.enforceInterface("android.support.customtabs.ICustomTabsService"); + _arg0 = ICustomTabsCallback.Stub.asInterface(data.readStrongBinder()); + if (0 != data.readInt()) { + _arg1 = Bundle.CREATOR.createFromParcel(data); + } else { + _arg1 = null; + } + + _result = this.updateVisuals(_arg0, _arg1); + reply.writeNoException(); + reply.writeInt(_result ? 1 : 0); + return true; + case 1598968902: + reply.writeString("android.support.customtabs.ICustomTabsService"); + return true; + default: + return super.onTransact(code, data, reply, flags); + } + } + + private static class Proxy implements ICustomTabsService { + private IBinder mRemote; + + Proxy(IBinder remote) { + this.mRemote = remote; + } + + public IBinder asBinder() { + return this.mRemote; + } + + public String getInterfaceDescriptor() { + return "android.support.customtabs.ICustomTabsService"; + } + + public boolean warmup(long flags) throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + + boolean _result; + try { + _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService"); + _data.writeLong(flags); + this.mRemote.transact(2, _data, _reply, 0); + _reply.readException(); + _result = 0 != _reply.readInt(); + } finally { + _reply.recycle(); + _data.recycle(); + } + + return _result; + } + + public boolean newSession(ICustomTabsCallback callback) throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + + boolean _result; + try { + _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService"); + _data.writeStrongBinder(callback != null ? callback.asBinder() : null); + this.mRemote.transact(3, _data, _reply, 0); + _reply.readException(); + _result = 0 != _reply.readInt(); + } finally { + _reply.recycle(); + _data.recycle(); + } + + return _result; + } + + public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, Bundle extras, List otherLikelyBundles) throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + + boolean _result; + try { + _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService"); + _data.writeStrongBinder(callback != null ? callback.asBinder() : null); + if (url != null) { + _data.writeInt(1); + url.writeToParcel(_data, 0); + } else { + _data.writeInt(0); + } + + if (extras != null) { + _data.writeInt(1); + extras.writeToParcel(_data, 0); + } else { + _data.writeInt(0); + } + + _data.writeTypedList(otherLikelyBundles); + this.mRemote.transact(4, _data, _reply, 0); + _reply.readException(); + _result = 0 != _reply.readInt(); + } finally { + _reply.recycle(); + _data.recycle(); + } + + return _result; + } + + public Bundle extraCommand(String commandName, Bundle args) throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + + Bundle _result; + try { + _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService"); + _data.writeString(commandName); + if (args != null) { + _data.writeInt(1); + args.writeToParcel(_data, 0); + } else { + _data.writeInt(0); + } + + this.mRemote.transact(5, _data, _reply, 0); + _reply.readException(); + if (0 != _reply.readInt()) { + _result = Bundle.CREATOR.createFromParcel(_reply); + } else { + _result = null; + } + } finally { + _reply.recycle(); + _data.recycle(); + } + + return _result; + } + + public boolean updateVisuals(ICustomTabsCallback callback, Bundle bundle) throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + + boolean _result; + try { + _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService"); + _data.writeStrongBinder(callback != null ? callback.asBinder() : null); + if (bundle != null) { + _data.writeInt(1); + bundle.writeToParcel(_data, 0); + } else { + _data.writeInt(0); + } + + this.mRemote.transact(6, _data, _reply, 0); + _reply.readException(); + _result = 0 != _reply.readInt(); + } finally { + _reply.recycle(); + _data.recycle(); + } + + return _result; + } + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/CustomTabsHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/CustomTabsHelper.java new file mode 100755 index 000000000..e40bcd4f0 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/CustomTabsHelper.java @@ -0,0 +1,142 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.telegram.messenger.support.customtabsclient.shared; + +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.net.Uri; +import android.text.TextUtils; +import android.util.Log; + +import java.util.ArrayList; +import java.util.List; + +/** + * Helper class for Custom Tabs. + */ +public class CustomTabsHelper { + private static final String TAG = "CustomTabsHelper"; + static final String STABLE_PACKAGE = "com.android.chrome"; + static final String BETA_PACKAGE = "com.chrome.beta"; + static final String DEV_PACKAGE = "com.chrome.dev"; + static final String LOCAL_PACKAGE = "com.google.android.apps.chrome"; + private static final String EXTRA_CUSTOM_TABS_KEEP_ALIVE = + "android.support.customtabs.extra.KEEP_ALIVE"; + private static final String ACTION_CUSTOM_TABS_CONNECTION = + "android.support.customtabs.action.CustomTabsService"; + + private static String sPackageNameToUse; + + private CustomTabsHelper() {} + + public static void addKeepAliveExtra(Context context, Intent intent) { + Intent keepAliveIntent = new Intent().setClassName( + context.getPackageName(), KeepAliveService.class.getCanonicalName()); + intent.putExtra(EXTRA_CUSTOM_TABS_KEEP_ALIVE, keepAliveIntent); + } + + /** + * Goes through all apps that handle VIEW intents and have a warmup service. Picks + * the one chosen by the user if there is one, otherwise makes a best effort to return a + * valid package name. + * + * This is not threadsafe. + * + * @param context {@link Context} to use for accessing {@link PackageManager}. + * @return The package name recommended to use for connecting to custom tabs related components. + */ + public static String getPackageNameToUse(Context context) { + if (sPackageNameToUse != null) return sPackageNameToUse; + + PackageManager pm = context.getPackageManager(); + // Get default VIEW intent handler. + Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); + ResolveInfo defaultViewHandlerInfo = pm.resolveActivity(activityIntent, 0); + String defaultViewHandlerPackageName = null; + if (defaultViewHandlerInfo != null) { + defaultViewHandlerPackageName = defaultViewHandlerInfo.activityInfo.packageName; + } + + // Get all apps that can handle VIEW intents. + List resolvedActivityList = pm.queryIntentActivities(activityIntent, 0); + List packagesSupportingCustomTabs = new ArrayList<>(); + for (ResolveInfo info : resolvedActivityList) { + Intent serviceIntent = new Intent(); + serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION); + serviceIntent.setPackage(info.activityInfo.packageName); + if (pm.resolveService(serviceIntent, 0) != null) { + packagesSupportingCustomTabs.add(info.activityInfo.packageName); + } + } + + // Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents + // and service calls. + if (packagesSupportingCustomTabs.isEmpty()) { + sPackageNameToUse = null; + } else if (packagesSupportingCustomTabs.size() == 1) { + sPackageNameToUse = packagesSupportingCustomTabs.get(0); + } else if (!TextUtils.isEmpty(defaultViewHandlerPackageName) + && !hasSpecializedHandlerIntents(context, activityIntent) + && packagesSupportingCustomTabs.contains(defaultViewHandlerPackageName)) { + sPackageNameToUse = defaultViewHandlerPackageName; + } else if (packagesSupportingCustomTabs.contains(STABLE_PACKAGE)) { + sPackageNameToUse = STABLE_PACKAGE; + } else if (packagesSupportingCustomTabs.contains(BETA_PACKAGE)) { + sPackageNameToUse = BETA_PACKAGE; + } else if (packagesSupportingCustomTabs.contains(DEV_PACKAGE)) { + sPackageNameToUse = DEV_PACKAGE; + } else if (packagesSupportingCustomTabs.contains(LOCAL_PACKAGE)) { + sPackageNameToUse = LOCAL_PACKAGE; + } + return sPackageNameToUse; + } + + /** + * Used to check whether there is a specialized handler for a given intent. + * @param intent The intent to check with. + * @return Whether there is a specialized handler for the given intent. + */ + private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) { + try { + PackageManager pm = context.getPackageManager(); + List handlers = pm.queryIntentActivities( + intent, + PackageManager.GET_RESOLVED_FILTER); + if (handlers == null || handlers.size() == 0) { + return false; + } + for (ResolveInfo resolveInfo : handlers) { + IntentFilter filter = resolveInfo.filter; + if (filter == null) continue; + if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue; + if (resolveInfo.activityInfo == null) continue; + return true; + } + } catch (RuntimeException e) { + Log.e(TAG, "Runtime exception while getting specialized handlers"); + } + return false; + } + + /** + * @return All possible chrome package names that provide custom tabs feature. + */ + public static String[] getPackages() { + return new String[]{"", STABLE_PACKAGE, BETA_PACKAGE, DEV_PACKAGE, LOCAL_PACKAGE}; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/KeepAliveService.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/KeepAliveService.java new file mode 100755 index 000000000..0285190e6 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/KeepAliveService.java @@ -0,0 +1,29 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.telegram.messenger.support.customtabsclient.shared; + +import android.app.Service; +import android.content.Intent; +import android.os.Binder; +import android.os.IBinder; + +public class KeepAliveService extends Service { + private static final Binder sBinder = new Binder(); + + @Override + public IBinder onBind(Intent intent) { + return sBinder; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/ServiceConnection.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/ServiceConnection.java new file mode 100755 index 000000000..86f1b8797 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/ServiceConnection.java @@ -0,0 +1,42 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.telegram.messenger.support.customtabsclient.shared; + +import android.content.ComponentName; + +import org.telegram.messenger.support.customtabs.CustomTabsClient; +import org.telegram.messenger.support.customtabs.CustomTabsServiceConnection; + +import java.lang.ref.WeakReference; + +public class ServiceConnection extends CustomTabsServiceConnection { + private WeakReference mConnectionCallback; + + public ServiceConnection(ServiceConnectionCallback connectionCallback) { + mConnectionCallback = new WeakReference<>(connectionCallback); + } + + @Override + public void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client) { + ServiceConnectionCallback connectionCallback = mConnectionCallback.get(); + if (connectionCallback != null) connectionCallback.onServiceConnected(client); + } + + @Override + public void onServiceDisconnected(ComponentName name) { + ServiceConnectionCallback connectionCallback = mConnectionCallback.get(); + if (connectionCallback != null) connectionCallback.onServiceDisconnected(); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/ServiceConnectionCallback.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/ServiceConnectionCallback.java new file mode 100755 index 000000000..7f9ade6b3 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/customtabsclient/shared/ServiceConnectionCallback.java @@ -0,0 +1,33 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.telegram.messenger.support.customtabsclient.shared; + +import org.telegram.messenger.support.customtabs.CustomTabsClient; + +/** + * Callback for events when connecting and disconnecting from Custom Tabs Service. + */ +public interface ServiceConnectionCallback { + /** + * Called when the service is connected. + * @param client a CustomTabsClient + */ + void onServiceConnected(CustomTabsClient client); + + /** + * Called when the service is disconnected. + */ + void onServiceDisconnected(); +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/LinearLayoutManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/LinearLayoutManager.java index 9d83de9c5..b12110689 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/LinearLayoutManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/LinearLayoutManager.java @@ -540,7 +540,7 @@ public class LinearLayoutManager extends RecyclerView.LayoutManager implements onAnchorReady(recycler, state, mAnchorInfo, firstLayoutDirection); detachAndScrapAttachedViews(recycler); - mLayoutState.mInfinite = mOrientationHelper.getMode() == View.MeasureSpec.UNSPECIFIED; + mLayoutState.mInfinite = resolveIsInfinite(); mLayoutState.mIsPreLayout = state.isPreLayout(); if (mAnchorInfo.mLayoutFromEnd) { // fill towards start @@ -1128,7 +1128,8 @@ public class LinearLayoutManager extends RecyclerView.LayoutManager implements private void updateLayoutState(int layoutDirection, int requiredSpace, boolean canUseExistingSpace, RecyclerView.State state) { - mLayoutState.mInfinite = mOrientationHelper.getMode() == View.MeasureSpec.UNSPECIFIED; + // If parent provides a hint, don't measure unlimited. + mLayoutState.mInfinite = resolveIsInfinite(); mLayoutState.mExtra = getExtraLayoutSpace(state); mLayoutState.mLayoutDirection = layoutDirection; int scrollingOffset; @@ -1162,6 +1163,11 @@ public class LinearLayoutManager extends RecyclerView.LayoutManager implements mLayoutState.mScrollingOffset = scrollingOffset; } + boolean resolveIsInfinite() { + return mOrientationHelper.getMode() == View.MeasureSpec.UNSPECIFIED + && mOrientationHelper.getEnd() == 0; + } + int scrollBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { if (getChildCount() == 0 || dy == 0) { return 0; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/RecyclerView.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/RecyclerView.java index 8f224ea24..5db54056b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/RecyclerView.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/RecyclerView.java @@ -59,6 +59,7 @@ import android.view.FocusFinder; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; +import android.view.View.MeasureSpec; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewParent; @@ -152,6 +153,9 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro private static final boolean DEBUG = false; + private static final int[] NESTED_SCROLLING_ATTRS + = {16843830 /* android.R.attr.nestedScrollingEnabled */}; + /** * On Kitkat and JB MR2, there is a bug which prevents DisplayList from being invalidated if * a View is two levels deep(wrt to ViewHolder.itemView). DisplayList can be invalidated by @@ -161,8 +165,14 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro */ private static final boolean FORCE_INVALIDATE_DISPLAY_LIST = Build.VERSION.SDK_INT == 18 || Build.VERSION.SDK_INT == 19 || Build.VERSION.SDK_INT == 20; + /** + * On M+, an unspecified measure spec may include a hint which we can use. On older platforms, + * this value might be garbage. To save LayoutManagers from it, RecyclerView sets the size to + * 0 when mode is unspecified. + */ + static final boolean ALLOW_SIZE_IN_UNSPECIFIED_SPEC = Build.VERSION.SDK_INT >= 23; - private static final boolean DISPATCH_TEMP_DETACH = false; + static final boolean DISPATCH_TEMP_DETACH = false; public static final int HORIZONTAL = 0; public static final int VERTICAL = 1; @@ -392,7 +402,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro // preserved not to create a new one in each layout pass private final int[] mMinMaxLayoutPositions = new int[2]; - private final NestedScrollingChildHelper mScrollingChildHelper; + private NestedScrollingChildHelper mScrollingChildHelper; private final int[] mScrollOffset = new int[2]; private final int[] mScrollConsumed = new int[2]; private final int[] mNestedOffsets = new int[2]; @@ -485,8 +495,9 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro mAccessibilityManager = (AccessibilityManager) getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); setAccessibilityDelegateCompat(new RecyclerViewAccessibilityDelegate(this)); + // Create the layoutManager if specified. - mScrollingChildHelper = new NestedScrollingChildHelper(this); + // Re-set whether nested scrolling is enabled so that it is set on all API levels setNestedScrollingEnabled(true); } @@ -568,7 +579,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro if (className.charAt(0) == '.') { return context.getPackageName() + className; } - if (className.contains(".")) { + if (className.indexOf('.') != -1) { return className; } return RecyclerView.class.getPackage().getName() + '.' + className; @@ -1037,6 +1048,11 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro @Override protected void onRestoreInstanceState(Parcelable state) { + if (!(state instanceof SavedState)) { + super.onRestoreInstanceState(state); + return; + } + mPendingSavedState = (SavedState) state; super.onRestoreInstanceState(mPendingSavedState.getSuperState()); if (mLayout != null && mPendingSavedState.mLayoutState != null) { @@ -1327,6 +1343,14 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro } } + /** + * Convenience method to scroll to a certain position. + * + * RecyclerView does not implement scrolling logic, rather forwards the call to + * {@link android.support.v7.widget.RecyclerView.LayoutManager#scrollToPosition(int)} + * @param position Scroll to this adapter position + * @see android.support.v7.widget.RecyclerView.LayoutManager#scrollToPosition(int) + */ public void scrollToPosition(int position) { if (mLayoutFrozen) { return; @@ -3188,17 +3212,10 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro if (count == 0) { return minPositionPreLayout != 0 || maxPositionPreLayout != 0; } - for (int i = 0; i < count; ++i) { - final ViewHolder holder = getChildViewHolderInt(mChildHelper.getChildAt(i)); - if (holder.shouldIgnore()) { - continue; - } - final int pos = holder.getLayoutPosition(); - if (pos < minPositionPreLayout || pos > maxPositionPreLayout) { - return true; - } - } - return false; + // get the new min max + findMinMaxChildLayoutPositions(mMinMaxLayoutPositions); + return mMinMaxLayoutPositions[0] != minPositionPreLayout || + mMinMaxLayoutPositions[1] != maxPositionPreLayout; } @Override @@ -5990,28 +6007,43 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro * onMeasure method OR fake measure specs created by the RecyclerView. * For example, when a layout is run, RecyclerView always sets these specs to be * EXACTLY because a LayoutManager cannot resize RecyclerView during a layout pass. + *

+ * Also, to be able to use the hint in unspecified measure specs, RecyclerView checks the + * API level and sets the size to 0 pre-M to avoid any issue that might be caused by + * corrupt values. Older platforms have no responsibility to provide a size if they set + * mode to unspecified. */ - private int mWidthSpec, mHeightSpec; + private int mWidthMode, mHeightMode; + private int mWidth, mHeight; void setRecyclerView(RecyclerView recyclerView) { if (recyclerView == null) { mRecyclerView = null; mChildHelper = null; - mWidthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.EXACTLY); - mHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.EXACTLY); + mWidth = 0; + mHeight = 0; } else { mRecyclerView = recyclerView; mChildHelper = recyclerView.mChildHelper; - mWidthSpec = MeasureSpec - .makeMeasureSpec(recyclerView.getWidth(), MeasureSpec.EXACTLY); - mHeightSpec = MeasureSpec - .makeMeasureSpec(recyclerView.getHeight(), MeasureSpec.EXACTLY); + mWidth = recyclerView.getWidth(); + mHeight = recyclerView.getHeight(); } + mWidthMode = MeasureSpec.EXACTLY; + mHeightMode = MeasureSpec.EXACTLY; } void setMeasureSpecs(int wSpec, int hSpec) { - mWidthSpec = wSpec; - mHeightSpec = hSpec; + mWidth = MeasureSpec.getSize(wSpec); + mWidthMode = MeasureSpec.getMode(wSpec); + if (mWidthMode == MeasureSpec.UNSPECIFIED && !ALLOW_SIZE_IN_UNSPECIFIED_SPEC) { + mWidth = 0; + } + + mHeight = MeasureSpec.getSize(hSpec); + mHeightMode = MeasureSpec.getMode(hSpec); + if (mHeightMode == MeasureSpec.UNSPECIFIED && !ALLOW_SIZE_IN_UNSPECIFIED_SPEC) { + mHeight = 0; + } } /** @@ -7054,7 +7086,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro * @see View#onMeasure(int, int) */ public int getWidthMode() { - return MeasureSpec.getMode(mWidthSpec); + return mWidthMode; } /** @@ -7072,7 +7104,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro * @see View#onMeasure(int, int) */ public int getHeightMode() { - return MeasureSpec.getMode(mHeightSpec); + return mHeightMode; } /** @@ -7081,7 +7113,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro * @return Width in pixels */ public int getWidth() { - return MeasureSpec.getSize(mWidthSpec); + return mWidth; } /** @@ -7090,7 +7122,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro * @return Height in pixels */ public int getHeight() { - return MeasureSpec.getSize(mHeightSpec); + return mHeight; } /** @@ -7567,6 +7599,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro } } + //noinspection WrongConstant return MeasureSpec.makeMeasureSpec(resultSize, resultMode); } @@ -9310,49 +9343,49 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro @Override public void setNestedScrollingEnabled(boolean enabled) { - mScrollingChildHelper.setNestedScrollingEnabled(enabled); + getScrollingChildHelper().setNestedScrollingEnabled(enabled); } @Override public boolean isNestedScrollingEnabled() { - return mScrollingChildHelper.isNestedScrollingEnabled(); + return getScrollingChildHelper().isNestedScrollingEnabled(); } @Override public boolean startNestedScroll(int axes) { - return mScrollingChildHelper.startNestedScroll(axes); + return getScrollingChildHelper().startNestedScroll(axes); } @Override public void stopNestedScroll() { - mScrollingChildHelper.stopNestedScroll(); + getScrollingChildHelper().stopNestedScroll(); } @Override public boolean hasNestedScrollingParent() { - return mScrollingChildHelper.hasNestedScrollingParent(); + return getScrollingChildHelper().hasNestedScrollingParent(); } @Override public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow) { - return mScrollingChildHelper.dispatchNestedScroll(dxConsumed, dyConsumed, + return getScrollingChildHelper().dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, offsetInWindow); } @Override public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow) { - return mScrollingChildHelper.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow); + return getScrollingChildHelper().dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow); } @Override public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) { - return mScrollingChildHelper.dispatchNestedFling(velocityX, velocityY, consumed); + return getScrollingChildHelper().dispatchNestedFling(velocityX, velocityY, consumed); } @Override public boolean dispatchNestedPreFling(float velocityX, float velocityY) { - return mScrollingChildHelper.dispatchNestedPreFling(velocityX, velocityY); + return getScrollingChildHelper().dispatchNestedPreFling(velocityX, velocityY); } /** @@ -11056,4 +11089,11 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro */ int onGetChildDrawingOrder(int childCount, int i); } + + private NestedScrollingChildHelper getScrollingChildHelper() { + if (mScrollingChildHelper == null) { + mScrollingChildHelper = new NestedScrollingChildHelper(this); + } + return mScrollingChildHelper; + } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/StaggeredGridLayoutManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/StaggeredGridLayoutManager.java index dd24ad425..f93af4fd8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/StaggeredGridLayoutManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/StaggeredGridLayoutManager.java @@ -27,6 +27,7 @@ import android.graphics.PointF; import android.graphics.Rect; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.view.ViewCompat; import android.support.v4.view.accessibility.AccessibilityEventCompat; @@ -110,7 +111,9 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { * Primary orientation is the layout's orientation, secondary orientation is the orientation * for spans. Having both makes code much cleaner for calculations. */ + @NonNull OrientationHelper mPrimaryOrientation; + @NonNull OrientationHelper mSecondaryOrientation; private int mOrientation; @@ -120,7 +123,8 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { */ private int mSizePerSpan; - private LayoutState mLayoutState; + @NonNull + private final LayoutState mLayoutState; private boolean mReverseLayout = false; @@ -221,6 +225,8 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { setSpanCount(properties.spanCount); setReverseLayout(properties.reverseLayout); setAutoMeasureEnabled(mGapStrategy != GAP_HANDLING_NONE); + mLayoutState = new LayoutState(); + createOrientationHelpers(); } /** @@ -234,6 +240,14 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { mOrientation = orientation; setSpanCount(spanCount); setAutoMeasureEnabled(mGapStrategy != GAP_HANDLING_NONE); + mLayoutState = new LayoutState(); + createOrientationHelpers(); + } + + private void createOrientationHelpers() { + mPrimaryOrientation = OrientationHelper.createOrientationHelper(this, mOrientation); + mSecondaryOrientation = OrientationHelper + .createOrientationHelper(this, 1 - mOrientation); } /** @@ -426,12 +440,9 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { return; } mOrientation = orientation; - if (mPrimaryOrientation != null && mSecondaryOrientation != null) { - // swap - OrientationHelper tmp = mPrimaryOrientation; - mPrimaryOrientation = mSecondaryOrientation; - mSecondaryOrientation = tmp; - } + OrientationHelper tmp = mPrimaryOrientation; + mPrimaryOrientation = mSecondaryOrientation; + mSecondaryOrientation = tmp; requestLayout(); } @@ -526,15 +537,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { requestLayout(); } - private void ensureOrientationHelper() { - if (mPrimaryOrientation == null) { - mPrimaryOrientation = OrientationHelper.createOrientationHelper(this, mOrientation); - mSecondaryOrientation = OrientationHelper - .createOrientationHelper(this, 1 - mOrientation); - mLayoutState = new LayoutState(); - } - } - /** * Calculates the views' layout order. (e.g. from end to start or start to end) * RTL layout support is applied automatically. So if layout is RTL and @@ -593,7 +595,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { private void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state, boolean shouldCheckForGaps) { - ensureOrientationHelper(); final AnchorInfo anchorInfo = mAnchorInfo; anchorInfo.reset(); @@ -1036,7 +1037,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { if (getChildCount() == 0) { return 0; } - ensureOrientationHelper(); return ScrollbarHelper.computeScrollOffset(state, mPrimaryOrientation, findFirstVisibleItemClosestToStart(!mSmoothScrollbarEnabled, true) , findFirstVisibleItemClosestToEnd(!mSmoothScrollbarEnabled, true), @@ -1057,7 +1057,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { if (getChildCount() == 0) { return 0; } - ensureOrientationHelper(); return ScrollbarHelper.computeScrollExtent(state, mPrimaryOrientation, findFirstVisibleItemClosestToStart(!mSmoothScrollbarEnabled, true) , findFirstVisibleItemClosestToEnd(!mSmoothScrollbarEnabled, true), @@ -1078,7 +1077,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { if (getChildCount() == 0) { return 0; } - ensureOrientationHelper(); return ScrollbarHelper.computeScrollRange(state, mPrimaryOrientation, findFirstVisibleItemClosestToStart(!mSmoothScrollbarEnabled, true) , findFirstVisibleItemClosestToEnd(!mSmoothScrollbarEnabled, true), @@ -1175,7 +1173,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { } if (getChildCount() > 0) { - ensureOrientationHelper(); state.mAnchorPosition = mLastLayoutFromEnd ? getLastChildPosition() : getFirstChildPosition(); state.mVisibleAnchorPosition = findFirstVisibleItemPositionInt(); @@ -1288,7 +1285,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { * children order. */ View findFirstVisibleItemClosestToStart(boolean fullyVisible, boolean acceptPartiallyVisible) { - ensureOrientationHelper(); final int boundsStart = mPrimaryOrientation.getStartAfterPadding(); final int boundsEnd = mPrimaryOrientation.getEndAfterPadding(); final int limit = getChildCount(); @@ -1319,7 +1315,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { * children order. */ View findFirstVisibleItemClosestToEnd(boolean fullyVisible, boolean acceptPartiallyVisible) { - ensureOrientationHelper(); final int boundsStart = mPrimaryOrientation.getStartAfterPadding(); final int boundsEnd = mPrimaryOrientation.getEndAfterPadding(); View partiallyVisible = null; @@ -1407,7 +1402,8 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { } mLayoutState.mStopInFocusable = false; mLayoutState.mRecycle = true; - mLayoutState.mInfinite = mPrimaryOrientation.getMode() == View.MeasureSpec.UNSPECIFIED; + mLayoutState.mInfinite = mPrimaryOrientation.getMode() == View.MeasureSpec.UNSPECIFIED && + mPrimaryOrientation.getEnd() == 0; } private void setLayoutStateDirection(int direction) { @@ -2046,7 +2042,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { } int scrollBy(int dt, RecyclerView.Recycler recycler, RecyclerView.State state) { - ensureOrientationHelper(); final int referenceChildPosition; final int layoutDir; if (dt > 0) { // layout towards end @@ -2124,6 +2119,7 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { return 0; } + @SuppressWarnings("deprecation") @Override public RecyclerView.LayoutParams generateDefaultLayoutParams() { if (mOrientation == HORIZONTAL) { @@ -2171,7 +2167,6 @@ public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager { return null; } - ensureOrientationHelper(); resolveShouldLayoutReverse(); final int layoutDir = convertFocusDirectionToLayoutDirection(direction); if (layoutDir == LayoutState.INVALID_LAYOUT) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/ViewInfoStore.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/ViewInfoStore.java index 923319f4e..938fe42f3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/ViewInfoStore.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/ViewInfoStore.java @@ -32,7 +32,11 @@ import static org.telegram.messenger.support.widget.ViewInfoStore.InfoRecord.FLA import static org.telegram.messenger.support.widget.ViewInfoStore.InfoRecord.FLAG_APPEAR; import static org.telegram.messenger.support.widget.ViewInfoStore.InfoRecord.FLAG_PRE; import static org.telegram.messenger.support.widget.ViewInfoStore.InfoRecord.FLAG_POST; - +/** + * This class abstracts all tracking for Views to run animations + * + * @hide + */ class ViewInfoStore { private static final boolean DEBUG = false; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/helper/ItemTouchHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/helper/ItemTouchHelper.java index 4d458fed8..46b6f9d2a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/helper/ItemTouchHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/support/widget/helper/ItemTouchHelper.java @@ -1384,7 +1384,7 @@ public class ItemTouchHelper extends RecyclerView.ItemDecoration /** * Drag scroll speed keeps accelerating until this many milliseconds before being capped. */ - private static final long DRAG_SCROLL_ACCELERATION_LIMIT_TIME_MS = 2000; + private static final long DRAG_SCROLL_ACCELERATION_LIMIT_TIME_MS = 500; private int mCachedMaxScrollSpeed = -1; diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java index 8b6cf27d6..e6a5f08b0 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java @@ -201,8 +201,12 @@ public class ConnectionsManager { native_setNetworkAvailable(isNetworkOnline()); } - public void init(int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String configPath, String logPath, int userId) { - native_init(version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, configPath, logPath, userId); + public void setPushConnectionEnabled(boolean value) { + native_setPushConnectionEnabled(value); + } + + public void init(int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String configPath, String logPath, int userId, boolean enablePushConnection) { + native_init(version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, configPath, logPath, userId, enablePushConnection); checkConnection(); BroadcastReceiver networkStateReceiver = new BroadcastReceiver() { @Override @@ -342,8 +346,10 @@ public class ConnectionsManager { @Override public void run() { try { - getInstance().wakeLock.acquire(20000); - FileLog.d("tmessages", "acquire wakelock"); + if (!getInstance().wakeLock.isHeld()) { + getInstance().wakeLock.acquire(10000); + FileLog.d("tmessages", "acquire wakelock"); + } } catch (Exception e) { FileLog.e("tmessages", e); } @@ -368,8 +374,9 @@ public class ConnectionsManager { public static native void native_applyDatacenterAddress(int datacenterId, String ipAddress, int port); public static native int native_getConnectionState(); public static native void native_setUserId(int id); - public static native void native_init(int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String configPath, String logPath, int userId); + public static native void native_init(int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String configPath, String logPath, int userId, boolean enablePushConnection); public static native void native_setJava(boolean useJavaByteBuffers); + public static native void native_setPushConnectionEnabled(boolean value); public int generateClassGuid() { return lastClassGuid++; diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index 09729b980..4418191aa 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -56,7 +56,7 @@ public class TLRPC { public static final int MESSAGE_FLAG_HAS_BOT_ID = 0x00000800; public static final int MESSAGE_FLAG_MEGAGROUP = 0x80000000; - public static final int LAYER = 50; + public static final int LAYER = 51; public static class ChatPhoto extends TLObject { public FileLocation photo_small; @@ -642,6 +642,44 @@ public class TLRPC { } } + public static class TL_messages_botCallbackAnswer extends TLObject { + public static int constructor = 0x1264f1c6; + + public int flags; + public boolean alert; + public String message; + + public static TL_messages_botCallbackAnswer TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { + if (TL_messages_botCallbackAnswer.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_messages_botCallbackAnswer", constructor)); + } else { + return null; + } + } + TL_messages_botCallbackAnswer result = new TL_messages_botCallbackAnswer(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + alert = (flags & 2) != 0; + if ((flags & 1) != 0) { + message = stream.readString(exception); + } + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + flags = alert ? (flags | 2) : (flags &~ 2); + stream.writeInt32(flags); + if ((flags & 1) != 0) { + stream.writeString(message); + } + } + } + public static class TL_contactStatus extends TLObject { public static int constructor = 0xd3680c61; @@ -2742,12 +2780,9 @@ public class TLRPC { } public static class BotInlineResult extends TLObject { + public int flags; public String id; public String type; - public Photo photo; - public BotInlineMessage send_message; - public Document document; - public int flags; public String title; public String description; public String url; @@ -2757,20 +2792,20 @@ public class TLRPC { public int w; public int h; public int duration; + public BotInlineMessage send_message; + public Photo photo; + public Document document; public long query_id; public static BotInlineResult TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { BotInlineResult result = null; switch(constructor) { - case 0xc5528587: - result = new TL_botInlineMediaResultPhoto(); - break; - case 0xf897d33e: - result = new TL_botInlineMediaResultDocument(); - break; case 0x9bebaeb9: result = new TL_botInlineResult(); break; + case 0x17db940b: + result = new TL_botInlineMediaResult(); + break; } if (result == null && exception) { throw new RuntimeException(String.format("can't parse magic %x in BotInlineResult", constructor)); @@ -2782,46 +2817,6 @@ public class TLRPC { } } - public static class TL_botInlineMediaResultPhoto extends BotInlineResult { - public static int constructor = 0xc5528587; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - id = stream.readString(exception); - type = stream.readString(exception); - photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); - send_message = BotInlineMessage.TLdeserialize(stream, stream.readInt32(exception), exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(id); - stream.writeString(type); - photo.serializeToStream(stream); - send_message.serializeToStream(stream); - } - } - - public static class TL_botInlineMediaResultDocument extends BotInlineResult { - public static int constructor = 0xf897d33e; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - id = stream.readString(exception); - type = stream.readString(exception); - document = Document.TLdeserialize(stream, stream.readInt32(exception), exception); - send_message = BotInlineMessage.TLdeserialize(stream, stream.readInt32(exception), exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(id); - stream.writeString(type); - document.serializeToStream(stream); - send_message.serializeToStream(stream); - } - } - public static class TL_botInlineResult extends BotInlineResult { public static int constructor = 0x9bebaeb9; @@ -2896,6 +2891,50 @@ public class TLRPC { } } + public static class TL_botInlineMediaResult extends BotInlineResult { + public static int constructor = 0x17db940b; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + id = stream.readString(exception); + type = stream.readString(exception); + if ((flags & 1) != 0) { + photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception); + } + if ((flags & 2) != 0) { + document = Document.TLdeserialize(stream, stream.readInt32(exception), exception); + } + if ((flags & 4) != 0) { + title = stream.readString(exception); + } + if ((flags & 8) != 0) { + description = stream.readString(exception); + } + send_message = BotInlineMessage.TLdeserialize(stream, stream.readInt32(exception), exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(flags); + stream.writeString(id); + stream.writeString(type); + if ((flags & 1) != 0) { + photo.serializeToStream(stream); + } + if ((flags & 2) != 0) { + document.serializeToStream(stream); + } + if ((flags & 4) != 0) { + stream.writeString(title); + } + if ((flags & 8) != 0) { + stream.writeString(description); + } + send_message.serializeToStream(stream); + } + } + public static class PeerNotifySettings extends TLObject { public int flags; public boolean silent; @@ -3605,24 +3644,27 @@ public class TLRPC { } public static class ReplyMarkup extends TLObject { + public ArrayList rows = new ArrayList<>(); public int flags; public boolean selective; - public boolean resize; public boolean single_use; - public ArrayList rows = new ArrayList<>(); + public boolean resize; public static ReplyMarkup TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { ReplyMarkup result = null; switch(constructor) { + case 0x48a30254: + result = new TL_replyInlineMarkup(); + break; case 0xa03e5b85: result = new TL_replyKeyboardHide(); break; - case 0x3502758c: - result = new TL_replyKeyboardMarkup(); - break; case 0xf4108aa0: result = new TL_replyKeyboardForceReply(); break; + case 0x3502758c: + result = new TL_replyKeyboardMarkup(); + break; } if (result == null && exception) { throw new RuntimeException(String.format("can't parse magic %x in ReplyMarkup", constructor)); @@ -3634,6 +3676,39 @@ public class TLRPC { } } + public static class TL_replyInlineMarkup extends ReplyMarkup { + public static int constructor = 0x48a30254; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + int magic = stream.readInt32(exception); + if (magic != 0x1cb5c415) { + if (exception) { + throw new RuntimeException(String.format("wrong Vector magic, got %x", magic)); + } + return; + } + int count = stream.readInt32(exception); + for (int a = 0; a < count; a++) { + TL_keyboardButtonRow object = TL_keyboardButtonRow.TLdeserialize(stream, stream.readInt32(exception), exception); + if (object == null) { + return; + } + rows.add(object); + } + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(0x1cb5c415); + int count = rows.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + rows.get(a).serializeToStream(stream); + } + } + } + public static class TL_replyKeyboardHide extends ReplyMarkup { public static int constructor = 0xa03e5b85; @@ -3650,6 +3725,24 @@ public class TLRPC { } } + public static class TL_replyKeyboardForceReply extends ReplyMarkup { + public static int constructor = 0xf4108aa0; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + single_use = (flags & 2) != 0; + selective = (flags & 4) != 0; + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + flags = single_use ? (flags | 2) : (flags &~ 2); + flags = selective ? (flags | 4) : (flags &~ 4); + stream.writeInt32(flags); + } + } + public static class TL_replyKeyboardMarkup extends ReplyMarkup { public static int constructor = 0x3502758c; @@ -3691,24 +3784,6 @@ public class TLRPC { } } - public static class TL_replyKeyboardForceReply extends ReplyMarkup { - public static int constructor = 0xf4108aa0; - - - public void readParams(AbstractSerializedData stream, boolean exception) { - flags = stream.readInt32(exception); - single_use = (flags & 2) != 0; - selective = (flags & 4) != 0; - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - flags = single_use ? (flags | 2) : (flags &~ 2); - flags = selective ? (flags | 4) : (flags &~ 4); - stream.writeInt32(flags); - } - } - public static class contacts_Contacts extends TLObject { public ArrayList contacts = new ArrayList<>(); public ArrayList users = new ArrayList<>(); @@ -4408,23 +4483,123 @@ public class TLRPC { } } - public static class TL_keyboardButton extends TLObject { + public static class KeyboardButton extends TLObject { + public String text; + public String query; + public byte[] data; + public String url; + + public static KeyboardButton TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { + KeyboardButton result = null; + switch(constructor) { + case 0xa2fa4880: + result = new TL_keyboardButton(); + break; + case 0xea1b7a14: + result = new TL_keyboardButtonSwitchInline(); + break; + case 0xb16a6c29: + result = new TL_keyboardButtonRequestPhone(); + break; + case 0x683a5e46: + result = new TL_keyboardButtonCallback(); + break; + case 0x258aff05: + result = new TL_keyboardButtonUrl(); + break; + case 0xfc796b3f: + result = new TL_keyboardButtonRequestGeoLocation(); + break; + } + if (result == null && exception) { + throw new RuntimeException(String.format("can't parse magic %x in KeyboardButton", constructor)); + } + if (result != null) { + result.readParams(stream, exception); + } + return result; + } + } + + public static class TL_keyboardButton extends KeyboardButton { public static int constructor = 0xa2fa4880; - public String text; - public static TL_keyboardButton TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - if (TL_keyboardButton.constructor != constructor) { - if (exception) { - throw new RuntimeException(String.format("can't parse magic %x in TL_keyboardButton", constructor)); - } else { - return null; - } - } - TL_keyboardButton result = new TL_keyboardButton(); - result.readParams(stream, exception); - return result; - } + public void readParams(AbstractSerializedData stream, boolean exception) { + text = stream.readString(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(text); + } + } + + public static class TL_keyboardButtonSwitchInline extends KeyboardButton { + public static int constructor = 0xea1b7a14; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + text = stream.readString(exception); + query = stream.readString(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(text); + stream.writeString(query); + } + } + + public static class TL_keyboardButtonRequestPhone extends KeyboardButton { + public static int constructor = 0xb16a6c29; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + text = stream.readString(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(text); + } + } + + public static class TL_keyboardButtonCallback extends KeyboardButton { + public static int constructor = 0x683a5e46; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + text = stream.readString(exception); + data = stream.readByteArray(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(text); + stream.writeByteArray(data); + } + } + + public static class TL_keyboardButtonUrl extends KeyboardButton { + public static int constructor = 0x258aff05; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + text = stream.readString(exception); + url = stream.readString(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(text); + stream.writeString(url); + } + } + + public static class TL_keyboardButtonRequestGeoLocation extends KeyboardButton { + public static int constructor = 0xfc796b3f; + public void readParams(AbstractSerializedData stream, boolean exception) { text = stream.readString(exception); @@ -4437,21 +4612,39 @@ public class TLRPC { } public static class BotInlineMessage extends TLObject { - public String caption; public int flags; + public GeoPoint geo; + public ReplyMarkup reply_markup; + public String caption; public boolean no_webpage; public String message; public ArrayList entities = new ArrayList<>(); + public String phone_number; + public String first_name; + public String last_name; + public String title; + public String address; + public String provider; + public String venue_id; public static BotInlineMessage TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { BotInlineMessage result = null; switch(constructor) { - case 0xfc56e87d: + case 0x3a8fd8b8: + result = new TL_botInlineMessageMediaGeo(); + break; + case 0xa74b15b: result = new TL_botInlineMessageMediaAuto(); break; - case 0xa56197a9: + case 0x8c7f65e2: result = new TL_botInlineMessageText(); break; + case 0x35edb4d4: + result = new TL_botInlineMessageMediaContact(); + break; + case 0x4366232e: + result = new TL_botInlineMessageMediaVenue(); + break; } if (result == null && exception) { throw new RuntimeException(String.format("can't parse magic %x in BotInlineMessage", constructor)); @@ -4463,22 +4656,52 @@ public class TLRPC { } } - public static class TL_botInlineMessageMediaAuto extends BotInlineMessage { - public static int constructor = 0xfc56e87d; + public static class TL_botInlineMessageMediaGeo extends BotInlineMessage { + public static int constructor = 0x3a8fd8b8; public void readParams(AbstractSerializedData stream, boolean exception) { - caption = stream.readString(exception); + flags = stream.readInt32(exception); + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + if ((flags & 4) != 0) { + reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); + } } public void serializeToStream(AbstractSerializedData stream) { stream.writeInt32(constructor); + stream.writeInt32(flags); + geo.serializeToStream(stream); + if ((flags & 4) != 0) { + reply_markup.serializeToStream(stream); + } + } + } + + public static class TL_botInlineMessageMediaAuto extends BotInlineMessage { + public static int constructor = 0xa74b15b; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + caption = stream.readString(exception); + if ((flags & 4) != 0) { + reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); + } + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(flags); stream.writeString(caption); + if ((flags & 4) != 0) { + reply_markup.serializeToStream(stream); + } } } public static class TL_botInlineMessageText extends BotInlineMessage { - public static int constructor = 0xa56197a9; + public static int constructor = 0x8c7f65e2; public void readParams(AbstractSerializedData stream, boolean exception) { @@ -4502,6 +4725,9 @@ public class TLRPC { entities.add(object); } } + if ((flags & 4) != 0) { + reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); + } } public void serializeToStream(AbstractSerializedData stream) { @@ -4517,13 +4743,72 @@ public class TLRPC { entities.get(a).serializeToStream(stream); } } + if ((flags & 4) != 0) { + reply_markup.serializeToStream(stream); + } + } + } + + public static class TL_botInlineMessageMediaContact extends BotInlineMessage { + public static int constructor = 0x35edb4d4; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + phone_number = stream.readString(exception); + first_name = stream.readString(exception); + last_name = stream.readString(exception); + if ((flags & 4) != 0) { + reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); + } + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(flags); + stream.writeString(phone_number); + stream.writeString(first_name); + stream.writeString(last_name); + if ((flags & 4) != 0) { + reply_markup.serializeToStream(stream); + } + } + } + + public static class TL_botInlineMessageMediaVenue extends BotInlineMessage { + public static int constructor = 0x4366232e; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + title = stream.readString(exception); + address = stream.readString(exception); + provider = stream.readString(exception); + venue_id = stream.readString(exception); + if ((flags & 4) != 0) { + reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); + } + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(flags); + geo.serializeToStream(stream); + stream.writeString(title); + stream.writeString(address); + stream.writeString(provider); + stream.writeString(venue_id); + if ((flags & 4) != 0) { + reply_markup.serializeToStream(stream); + } } } public static class TL_keyboardButtonRow extends TLObject { public static int constructor = 0x77608b83; - public ArrayList buttons = new ArrayList<>(); + public ArrayList buttons = new ArrayList<>(); public static TL_keyboardButtonRow TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { if (TL_keyboardButtonRow.constructor != constructor) { @@ -4548,7 +4833,7 @@ public class TLRPC { } int count = stream.readInt32(exception); for (int a = 0; a < count; a++) { - TL_keyboardButton object = TL_keyboardButton.TLdeserialize(stream, stream.readInt32(exception), exception); + KeyboardButton object = KeyboardButton.TLdeserialize(stream, stream.readInt32(exception), exception); if (object == null) { return; } @@ -5208,6 +5493,7 @@ public class TLRPC { public int bot_info_version; public boolean restricted; public boolean min; + public boolean bot_inline_geo; public String restriction_reason; public String bot_inline_placeholder; @@ -5655,6 +5941,7 @@ public class TLRPC { verified = (flags & 131072) != 0; restricted = (flags & 262144) != 0; min = (flags & 1048576) != 0; + bot_inline_geo = (flags & 2097152) != 0; id = stream.readInt32(exception); if ((flags & 1) != 0) { access_hash = stream.readInt64(exception); @@ -5700,6 +5987,7 @@ public class TLRPC { flags = verified ? (flags | 131072) : (flags &~ 131072); flags = restricted ? (flags | 262144) : (flags &~ 262144); flags = min ? (flags | 1048576) : (flags &~ 1048576); + flags = bot_inline_geo ? (flags | 2097152) : (flags &~ 2097152); stream.writeInt32(flags); stream.writeInt32(id); if ((flags & 1) != 0) { @@ -8221,6 +8509,37 @@ public class TLRPC { } } + public static class TL_messages_messageEditData extends TLObject { + public static int constructor = 0x26b5dde6; + + public int flags; + public boolean caption; + + public static TL_messages_messageEditData TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { + if (TL_messages_messageEditData.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_messages_messageEditData", constructor)); + } else { + return null; + } + } + TL_messages_messageEditData result = new TL_messages_messageEditData(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + caption = (flags & 1) != 0; + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + flags = caption ? (flags | 1) : (flags &~ 1); + stream.writeInt32(flags); + } + } + public static class TL_contacts_importedContacts extends TLObject { public static int constructor = 0xad524315; @@ -8339,12 +8658,51 @@ public class TLRPC { } } + public static class TL_inlineBotSwitchPM extends TLObject { + public static int constructor = 0x3c20629f; + + public String text; + public String start_param; + + public static TL_inlineBotSwitchPM TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { + if (TL_inlineBotSwitchPM.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inlineBotSwitchPM", constructor)); + } else { + return null; + } + } + TL_inlineBotSwitchPM result = new TL_inlineBotSwitchPM(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbstractSerializedData stream, boolean exception) { + text = stream.readString(exception); + start_param = stream.readString(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(text); + stream.writeString(start_param); + } + } + public static class Update extends TLObject { public int chat_id; public int user_id; public int inviter_id; public int date; public int version; + public int pts; + public int pts_count; + public long query_id; + public byte[] data; + public int flags; + public String query; + public GeoPoint geo; + public String offset; public PeerNotifySettings notify_settings; public int channel_id; public SendMessageAction action; @@ -8355,9 +8713,6 @@ public class TLRPC { public int max_id; public int qts; public boolean enabled; - public int pts; - public int pts_count; - public int id; public long random_id; public ArrayList dc_options = new ArrayList<>(); public ChatParticipants participants; @@ -8365,7 +8720,6 @@ public class TLRPC { public ArrayList rules = new ArrayList<>(); public UserStatus status; public int views; - public int flags; public String type; public MessageMedia media; public boolean popup; @@ -8380,8 +8734,8 @@ public class TLRPC { public ArrayList messages = new ArrayList<>(); public String phone; public WebPage webpage; - public ArrayList order = new ArrayList<>(); public EncryptedChat chat; + public ArrayList order = new ArrayList<>(); public int max_date; public UserProfilePhoto photo; public boolean previous; @@ -8398,6 +8752,12 @@ public class TLRPC { case 0x1b3f4df7: result = new TL_updateEditChannelMessage(); break; + case 0xa68c688c: + result = new TL_updateBotCallbackQuery(); + break; + case 0x54826690: + result = new TL_updateBotInlineQuery(); + break; case 0xbec268ef: result = new TL_updateNotifySettings(); break; @@ -8446,6 +8806,9 @@ public class TLRPC { case 0xee3b272a: result = new TL_updatePrivacy(); break; + case 0x2cbd95af: + result = new TL_updateInlineBotCallbackQuery(); + break; case 0x1710f156: result = new TL_updateEncryptedChatTyping(); break; @@ -8482,6 +8845,12 @@ public class TLRPC { case 0xa7332b73: result = new TL_updateUserName(); break; + case 0xe48f964: + result = new TL_updateBotInlineSend(); + break; + case 0xe40370a3: + result = new TL_updateEditMessage(); + break; case 0x98592475: result = new TL_updateChannelPinnedMessage(); break; @@ -8582,6 +8951,58 @@ public class TLRPC { } } + public static class TL_updateBotCallbackQuery extends Update { + public static int constructor = 0xa68c688c; + + public Peer peer; + public int msg_id; + + public void readParams(AbstractSerializedData stream, boolean exception) { + query_id = stream.readInt64(exception); + user_id = stream.readInt32(exception); + peer = Peer.TLdeserialize(stream, stream.readInt32(exception), exception); + msg_id = stream.readInt32(exception); + data = stream.readByteArray(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(query_id); + stream.writeInt32(user_id); + peer.serializeToStream(stream); + stream.writeInt32(msg_id); + stream.writeByteArray(data); + } + } + + public static class TL_updateBotInlineQuery extends Update { + public static int constructor = 0x54826690; + + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + query_id = stream.readInt64(exception); + user_id = stream.readInt32(exception); + query = stream.readString(exception); + if ((flags & 1) != 0) { + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + } + offset = stream.readString(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(flags); + stream.writeInt64(query_id); + stream.writeInt32(user_id); + stream.writeString(query); + if ((flags & 1) != 0) { + geo.serializeToStream(stream); + } + stream.writeString(offset); + } + } + public static class TL_updateNotifySettings extends Update { public static int constructor = 0xbec268ef; @@ -8732,15 +9153,6 @@ public class TLRPC { } } - public static class TL_updateSavedGifs extends Update { - public static int constructor = 0x9375341e; - - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - } - } - public static class TL_updateChatAdmins extends Update { public static int constructor = 0x6e947941; @@ -8759,6 +9171,15 @@ public class TLRPC { } } + public static class TL_updateSavedGifs extends Update { + public static int constructor = 0x9375341e; + + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + } + } + public static class TL_updateNewChannelMessage extends Update { public static int constructor = 0x62ba04d9; @@ -8781,6 +9202,7 @@ public class TLRPC { public static class TL_updateMessageID extends Update { public static int constructor = 0x4e90bfd6; + public int id; public void readParams(AbstractSerializedData stream, boolean exception) { id = stream.readInt32(exception); @@ -8876,6 +9298,27 @@ public class TLRPC { } } + public static class TL_updateInlineBotCallbackQuery extends Update { + public static int constructor = 0x2cbd95af; + + public TL_inputBotInlineMessageID msg_id; + + public void readParams(AbstractSerializedData stream, boolean exception) { + query_id = stream.readInt64(exception); + user_id = stream.readInt32(exception); + msg_id = TL_inputBotInlineMessageID.TLdeserialize(stream, stream.readInt32(exception), exception); + data = stream.readByteArray(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt64(query_id); + stream.writeInt32(user_id); + msg_id.serializeToStream(stream); + stream.writeByteArray(data); + } + } + public static class TL_updateEncryptedChatTyping extends Update { public static int constructor = 0x1710f156; @@ -8924,6 +9367,7 @@ public class TLRPC { public static class TL_updateChannelMessageViews extends Update { public static int constructor = 0x98a12b4b; + public int id; public void readParams(AbstractSerializedData stream, boolean exception) { channel_id = stream.readInt32(exception); @@ -9091,9 +9535,63 @@ public class TLRPC { } } + public static class TL_updateBotInlineSend extends Update { + public static int constructor = 0xe48f964; + + public String id; + public TL_inputBotInlineMessageID msg_id; + + public void readParams(AbstractSerializedData stream, boolean exception) { + flags = stream.readInt32(exception); + user_id = stream.readInt32(exception); + query = stream.readString(exception); + if ((flags & 1) != 0) { + geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception); + } + id = stream.readString(exception); + if ((flags & 2) != 0) { + msg_id = TL_inputBotInlineMessageID.TLdeserialize(stream, stream.readInt32(exception), exception); + } + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(flags); + stream.writeInt32(user_id); + stream.writeString(query); + if ((flags & 1) != 0) { + geo.serializeToStream(stream); + } + stream.writeString(id); + if ((flags & 2) != 0) { + msg_id.serializeToStream(stream); + } + } + } + + public static class TL_updateEditMessage extends Update { + public static int constructor = 0xe40370a3; + + public Message message; + + public void readParams(AbstractSerializedData stream, boolean exception) { + message = Message.TLdeserialize(stream, stream.readInt32(exception), exception); + pts = stream.readInt32(exception); + pts_count = stream.readInt32(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + message.serializeToStream(stream); + stream.writeInt32(pts); + stream.writeInt32(pts_count); + } + } + public static class TL_updateChannelPinnedMessage extends Update { public static int constructor = 0x98592475; + public int id; public void readParams(AbstractSerializedData stream, boolean exception) { channel_id = stream.readInt32(exception); @@ -10997,12 +11495,13 @@ public class TLRPC { } public static class TL_messages_botResults extends TLObject { - public static int constructor = 0x1170b0a3; + public static int constructor = 0x256709a6; public int flags; public boolean gallery; public long query_id; public String next_offset; + public TL_inlineBotSwitchPM switch_pm; public ArrayList results = new ArrayList<>(); public static TL_messages_botResults TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { @@ -11025,6 +11524,9 @@ public class TLRPC { if ((flags & 2) != 0) { next_offset = stream.readString(exception); } + if ((flags & 4) != 0) { + switch_pm = TL_inlineBotSwitchPM.TLdeserialize(stream, stream.readInt32(exception), exception); + } int magic = stream.readInt32(exception); if (magic != 0x1cb5c415) { if (exception) { @@ -11050,6 +11552,9 @@ public class TLRPC { if ((flags & 2) != 0) { stream.writeString(next_offset); } + if ((flags & 4) != 0) { + switch_pm.serializeToStream(stream); + } stream.writeInt32(0x1cb5c415); int count = results.size(); stream.writeInt32(count); @@ -11059,6 +11564,40 @@ public class TLRPC { } } + public static class TL_inputBotInlineMessageID extends TLObject { + public static int constructor = 0x890c3d89; + + public int dc_id; + public long id; + public long access_hash; + + public static TL_inputBotInlineMessageID TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { + if (TL_inputBotInlineMessageID.constructor != constructor) { + if (exception) { + throw new RuntimeException(String.format("can't parse magic %x in TL_inputBotInlineMessageID", constructor)); + } else { + return null; + } + } + TL_inputBotInlineMessageID result = new TL_inputBotInlineMessageID(); + result.readParams(stream, exception); + return result; + } + + public void readParams(AbstractSerializedData stream, boolean exception) { + dc_id = stream.readInt32(exception); + id = stream.readInt64(exception); + access_hash = stream.readInt64(exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeInt32(dc_id); + stream.writeInt64(id); + stream.writeInt64(access_hash); + } + } + public static class TL_messages_foundGifs extends TLObject { public static int constructor = 0x450a1c0a; @@ -14581,37 +15120,6 @@ public class TLRPC { } } - public static class TL_channels_messageEditData extends TLObject { - public static int constructor = 0x67e1255f; - - public int flags; - public boolean caption; - - public static TL_channels_messageEditData TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - if (TL_channels_messageEditData.constructor != constructor) { - if (exception) { - throw new RuntimeException(String.format("can't parse magic %x in TL_channels_messageEditData", constructor)); - } else { - return null; - } - } - TL_channels_messageEditData result = new TL_channels_messageEditData(); - result.readParams(stream, exception); - return result; - } - - public void readParams(AbstractSerializedData stream, boolean exception) { - flags = stream.readInt32(exception); - caption = (flags & 1) != 0; - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - flags = caption ? (flags | 1) : (flags &~ 1); - stream.writeInt32(flags); - } - } - public static class TL_inputEncryptedChat extends TLObject { public static int constructor = 0xf141b5e1; @@ -17886,9 +18394,12 @@ public class TLRPC { } public static class TL_messages_getInlineBotResults extends TLObject { - public static int constructor = 0x9324600d; + public static int constructor = 0x514e999d; + public int flags; public InputUser bot; + public InputPeer peer; + public InputGeoPoint geo_point; public String query; public String offset; @@ -17898,7 +18409,12 @@ public class TLRPC { public void serializeToStream(AbstractSerializedData stream) { stream.writeInt32(constructor); + stream.writeInt32(flags); bot.serializeToStream(stream); + peer.serializeToStream(stream); + if ((flags & 1) != 0) { + geo_point.serializeToStream(stream); + } stream.writeString(query); stream.writeString(offset); } @@ -17923,10 +18439,10 @@ public class TLRPC { public void serializeToStream(AbstractSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(flags); flags = broadcast ? (flags | 16) : (flags &~ 16); flags = silent ? (flags | 32) : (flags &~ 32); flags = background ? (flags | 64) : (flags &~ 64); + stream.writeInt32(flags); peer.serializeToStream(stream); if ((flags & 1) != 0) { stream.writeInt32(reply_to_msg_id); @@ -17937,6 +18453,139 @@ public class TLRPC { } } + public static class TL_messages_getMessageEditData extends TLObject { + public static int constructor = 0xfda68d36; + + public InputPeer peer; + public int id; + + public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { + return TL_messages_messageEditData.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt32(id); + } + } + + public static class TL_messages_editMessage extends TLObject { + public static int constructor = 0xce91e4ca; + + public int flags; + public boolean no_webpage; + public InputPeer peer; + public int id; + public String message; + public ReplyMarkup reply_markup; + public ArrayList entities = new ArrayList<>(); + + public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { + return Updates.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + flags = no_webpage ? (flags | 2) : (flags &~ 2); + stream.writeInt32(flags); + peer.serializeToStream(stream); + stream.writeInt32(id); + if ((flags & 2048) != 0) { + stream.writeString(message); + } + if ((flags & 4) != 0) { + reply_markup.serializeToStream(stream); + } + if ((flags & 8) != 0) { + stream.writeInt32(0x1cb5c415); + int count = entities.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + entities.get(a).serializeToStream(stream); + } + } + } + } + + public static class TL_messages_getBotCallbackAnswer extends TLObject { + public static int constructor = 0xa6e94f04; + + public InputPeer peer; + public int msg_id; + public byte[] data; + + public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { + return TL_messages_botCallbackAnswer.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt32(msg_id); + stream.writeByteArray(data); + } + } + + public static class TL_messages_setBotCallbackAnswer extends TLObject { + public static int constructor = 0x481c591a; + + public int flags; + public boolean alert; + public long query_id; + public String message; + + public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + flags = alert ? (flags | 2) : (flags &~ 2); + stream.writeInt32(flags); + stream.writeInt64(query_id); + if ((flags & 1) != 0) { + stream.writeString(message); + } + } + } + + public static class TL_messages_editInlineBotMessage extends TLObject { + public static int constructor = 0x130c2c85; + + public int flags; + public boolean no_webpage; + public TL_inputBotInlineMessageID id; + public String message; + public ReplyMarkup reply_markup; + public ArrayList entities = new ArrayList<>(); + + public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { + return Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + flags = no_webpage ? (flags | 2) : (flags &~ 2); + stream.writeInt32(flags); + id.serializeToStream(stream); + if ((flags & 2048) != 0) { + stream.writeString(message); + } + if ((flags & 4) != 0) { + reply_markup.serializeToStream(stream); + } + if ((flags & 8) != 0) { + stream.writeInt32(0x1cb5c415); + int count = entities.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + entities.get(a).serializeToStream(stream); + } + } + } + } + public static class TL_help_getAppChangelog extends TLObject { public static int constructor = 0x5bab7fb2; @@ -18527,55 +19176,6 @@ public class TLRPC { } } - public static class TL_channels_getMessageEditData extends TLObject { - public static int constructor = 0x27ea3a28; - - public InputChannel channel; - public int id; - - public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { - return TL_channels_messageEditData.TLdeserialize(stream, constructor, exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - channel.serializeToStream(stream); - stream.writeInt32(id); - } - } - - public static class TL_channels_editMessage extends TLObject { - public static int constructor = 0xdcda80ed; - - public int flags; - public boolean no_webpage; - public InputChannel channel; - public int id; - public String message; - public ArrayList entities = new ArrayList<>(); - - public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { - return Updates.TLdeserialize(stream, constructor, exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - flags = no_webpage ? (flags | 2) : (flags &~ 2); - stream.writeInt32(flags); - channel.serializeToStream(stream); - stream.writeInt32(id); - stream.writeString(message); - if ((flags & 8) != 0) { - stream.writeInt32(0x1cb5c415); - int count = entities.size(); - stream.writeInt32(count); - for (int a = 0; a < count; a++) { - entities.get(a).serializeToStream(stream); - } - } - } - } - public static class TL_channels_updatePinnedMessage extends TLObject { public static int constructor = 0xa72ded52; @@ -18590,8 +19190,8 @@ public class TLRPC { public void serializeToStream(AbstractSerializedData stream) { stream.writeInt32(constructor); - stream.writeInt32(flags); flags = silent ? (flags | 1) : (flags &~ 1); + stream.writeInt32(flags); channel.serializeToStream(stream); stream.writeInt32(id); } @@ -18989,6 +19589,8 @@ public class TLRPC { message = stream.readString(exception); if ((flags & 512) != 0) { media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + } else { + media = new TL_messageMediaEmpty(); } if ((flags & 64) != 0) { reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); @@ -19139,6 +19741,8 @@ public class TLRPC { message = stream.readString(exception); if ((flags & 512) != 0) { media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception); + } else { + media = new TL_messageMediaEmpty(); } if ((flags & 64) != 0) { reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index 1c76bc86d..692259feb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -12,21 +12,17 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.os.Build; -import android.text.TextUtils; -import android.util.TypedValue; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.R; import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; @@ -44,21 +40,23 @@ public class ActionBar extends FrameLayout { } private ImageView backButtonImageView; - private TextView titleTextView; - private TextView subTitleTextView; + private SimpleTextView titleTextView; + private SimpleTextView subtitleTextView; private View actionModeTop; private ActionBarMenu menu; private ActionBarMenu actionMode; private boolean occupyStatusBar = Build.VERSION.SDK_INT >= 21; private boolean actionModeVisible; private boolean addToContainer = true; + private boolean interceptTouches = true; + private int extraHeight; private boolean allowOverlayTitle; private CharSequence lastTitle; private boolean castShadows = true; protected boolean isSearchFieldVisible; - protected int itemsBackgroundResourceId; + protected int itemsBackgroundColor; private boolean isBackOverlayVisible; protected BaseFragment parentFragment; public ActionBarMenuOnItemClick actionBarMenuOnItemClick; @@ -73,7 +71,7 @@ public class ActionBar extends FrameLayout { } backButtonImageView = new ImageView(getContext()); backButtonImageView.setScaleType(ImageView.ScaleType.CENTER); - backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); + backButtonImageView.setBackgroundDrawable(Theme.createBarSelectorDrawable(itemsBackgroundColor)); backButtonImageView.setPadding(AndroidUtilities.dp(1), 0, 0, 0); addView(backButtonImageView, LayoutHelper.createFrame(54, 54, Gravity.LEFT | Gravity.TOP)); @@ -110,18 +108,14 @@ public class ActionBar extends FrameLayout { backButtonImageView.setImageResource(resource); } - private void createSubtitleTextView() { - if (subTitleTextView != null) { + private void createsubtitleTextView() { + if (subtitleTextView != null) { return; } - subTitleTextView = new TextView(getContext()); - subTitleTextView.setGravity(Gravity.LEFT); - subTitleTextView.setTextColor(0xffd7e8f7); - subTitleTextView.setSingleLine(true); - subTitleTextView.setLines(1); - subTitleTextView.setMaxLines(1); - subTitleTextView.setEllipsize(TextUtils.TruncateAt.END); - addView(subTitleTextView, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); + subtitleTextView = new SimpleTextView(getContext()); + subtitleTextView.setGravity(Gravity.LEFT); + subtitleTextView.setTextColor(Theme.ACTION_BAR_SUBTITLE_COLOR); + addView(subtitleTextView, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); } public void setAddToContainer(boolean value) { @@ -133,12 +127,12 @@ public class ActionBar extends FrameLayout { } public void setSubtitle(CharSequence value) { - if (value != null && subTitleTextView == null) { - createSubtitleTextView(); + if (value != null && subtitleTextView == null) { + createsubtitleTextView(); } - if (subTitleTextView != null) { - subTitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE); - subTitleTextView.setText(value); + if (subtitleTextView != null) { + subtitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE); + subtitleTextView.setText(value); } } @@ -146,12 +140,8 @@ public class ActionBar extends FrameLayout { if (titleTextView != null) { return; } - titleTextView = new TextView(getContext()); + titleTextView = new SimpleTextView(getContext()); titleTextView.setGravity(Gravity.LEFT); - titleTextView.setLines(1); - titleTextView.setMaxLines(1); - titleTextView.setSingleLine(true); - titleTextView.setEllipsize(TextUtils.TruncateAt.END); titleTextView.setTextColor(0xffffffff); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); addView(titleTextView, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); @@ -168,18 +158,14 @@ public class ActionBar extends FrameLayout { } } - public TextView getSubTitleTextView() { - return subTitleTextView; + public SimpleTextView getSubtitleTextView() { + return subtitleTextView; } - public TextView getTitleTextView() { + public SimpleTextView getTitleTextView() { return titleTextView; } - public Drawable getSubTitleIcon() { - return subTitleTextView.getCompoundDrawables()[0]; - } - public String getTitle() { if (titleTextView == null) { return null; @@ -258,8 +244,8 @@ public class ActionBar extends FrameLayout { if (titleTextView != null) { titleTextView.setVisibility(INVISIBLE); } - if (subTitleTextView != null) { - subTitleTextView.setVisibility(INVISIBLE); + if (subtitleTextView != null) { + subtitleTextView.setVisibility(INVISIBLE); } if (menu != null) { menu.setVisibility(INVISIBLE); @@ -275,8 +261,8 @@ public class ActionBar extends FrameLayout { if (titleTextView != null) { titleTextView.setVisibility(INVISIBLE); } - if (subTitleTextView != null) { - subTitleTextView.setVisibility(INVISIBLE); + if (subtitleTextView != null) { + subtitleTextView.setVisibility(INVISIBLE); } if (menu != null) { menu.setVisibility(INVISIBLE); @@ -287,7 +273,7 @@ public class ActionBar extends FrameLayout { if (drawable instanceof BackDrawable) { ((BackDrawable) drawable).setRotation(1, true); } - backButtonImageView.setBackgroundResource(R.drawable.bar_selector_mode); + backButtonImageView.setBackgroundDrawable(Theme.createBarSelectorDrawable(itemsBackgroundColor)); } } @@ -324,8 +310,8 @@ public class ActionBar extends FrameLayout { if (titleTextView != null) { titleTextView.setVisibility(VISIBLE); } - if (subTitleTextView != null) { - subTitleTextView.setVisibility(VISIBLE); + if (subtitleTextView != null) { + subtitleTextView.setVisibility(VISIBLE); } if (menu != null) { menu.setVisibility(VISIBLE); @@ -335,7 +321,7 @@ public class ActionBar extends FrameLayout { if (drawable instanceof BackDrawable) { ((BackDrawable) drawable).setRotation(0, true); } - backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); + backButtonImageView.setBackgroundDrawable(Theme.createBarSelectorDrawable(itemsBackgroundColor)); } } @@ -361,8 +347,8 @@ public class ActionBar extends FrameLayout { if (titleTextView != null) { titleTextView.setVisibility(visible ? INVISIBLE : VISIBLE); } - if (subTitleTextView != null) { - subTitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE); + if (subtitleTextView != null) { + subtitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE); } Drawable drawable = backButtonImageView.getDrawable(); if (drawable != null && drawable instanceof MenuDrawable) { @@ -370,6 +356,14 @@ public class ActionBar extends FrameLayout { } } + public void setInterceptTouches(boolean value) { + interceptTouches = value; + } + + public void setExtraHeight(int value) { + extraHeight = value; + } + public void closeSearchField() { if (!isSearchFieldVisible || menu == null) { return; @@ -391,7 +385,7 @@ public class ActionBar extends FrameLayout { int actionBarHeight = getCurrentActionBarHeight(); int actionBarHeightSpec = MeasureSpec.makeMeasureSpec(actionBarHeight, MeasureSpec.EXACTLY); - setMeasuredDimension(width, actionBarHeight + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0)); + setMeasuredDimension(width, actionBarHeight + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0) + extraHeight); int textLeft; if (backButtonImageView != null && backButtonImageView.getVisibility() != GONE) { @@ -411,24 +405,24 @@ public class ActionBar extends FrameLayout { menu.measure(menuWidth, actionBarHeightSpec); } - if (titleTextView != null && titleTextView.getVisibility() != GONE || subTitleTextView != null && subTitleTextView.getVisibility() != GONE) { + if (titleTextView != null && titleTextView.getVisibility() != GONE || subtitleTextView != null && subtitleTextView.getVisibility() != GONE) { int availableWidth = width - (menu != null ? menu.getMeasuredWidth() : 0) - AndroidUtilities.dp(16) - textLeft; if (titleTextView != null && titleTextView.getVisibility() != GONE) { - titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, !AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20); - titleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(actionBarHeight, MeasureSpec.AT_MOST)); + titleTextView.setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20); + titleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.AT_MOST)); } - if (subTitleTextView != null && subTitleTextView.getVisibility() != GONE) { - subTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, !AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 14 : 16); - subTitleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(actionBarHeight, MeasureSpec.AT_MOST)); + if (subtitleTextView != null && subtitleTextView.getVisibility() != GONE) { + subtitleTextView.setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 14 : 16); + subtitleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.AT_MOST)); } } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); - if (child.getVisibility() == GONE || child == titleTextView || child == subTitleTextView || child == menu || child == backButtonImageView) { + if (child.getVisibility() == GONE || child == titleTextView || child == subtitleTextView || child == menu || child == backButtonImageView) { continue; } measureChildWithMargins(child, widthMeasureSpec, 0, MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY), 0); @@ -452,25 +446,24 @@ public class ActionBar extends FrameLayout { menu.layout(menuLeft, additionalTop, menuLeft + menu.getMeasuredWidth(), additionalTop + menu.getMeasuredHeight()); } - int offset = AndroidUtilities.dp(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 2); if (titleTextView != null && titleTextView.getVisibility() != GONE) { int textTop; - if (subTitleTextView != null && subTitleTextView.getVisibility() != GONE) { - textTop = (getCurrentActionBarHeight() / 2 - titleTextView.getMeasuredHeight()) / 2 + offset; + if (subtitleTextView != null && subtitleTextView.getVisibility() != GONE) { + textTop = (getCurrentActionBarHeight() / 2 - titleTextView.getTextHeight()) / 2 + AndroidUtilities.dp(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 2 : 3); } else { - textTop = (getCurrentActionBarHeight() - titleTextView.getMeasuredHeight()) / 2 - AndroidUtilities.dp(1); + textTop = (getCurrentActionBarHeight() - titleTextView.getTextHeight()) / 2; } - titleTextView.layout(textLeft, additionalTop + textTop, textLeft + titleTextView.getMeasuredWidth(), additionalTop + textTop + titleTextView.getMeasuredHeight()); + titleTextView.layout(textLeft, additionalTop + textTop, textLeft + titleTextView.getMeasuredWidth(), additionalTop + textTop + titleTextView.getTextHeight()); } - if (subTitleTextView != null && subTitleTextView.getVisibility() != GONE) { - int textTop = getCurrentActionBarHeight() / 2 + (getCurrentActionBarHeight() / 2 - subTitleTextView.getMeasuredHeight()) / 2 - offset; - subTitleTextView.layout(textLeft, additionalTop + textTop, textLeft + subTitleTextView.getMeasuredWidth(), additionalTop + textTop + subTitleTextView.getMeasuredHeight()); + if (subtitleTextView != null && subtitleTextView.getVisibility() != GONE) { + int textTop = getCurrentActionBarHeight() / 2 + (getCurrentActionBarHeight() / 2 - subtitleTextView.getTextHeight()) / 2 - AndroidUtilities.dp(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 1); + subtitleTextView.layout(textLeft, additionalTop + textTop, textLeft + subtitleTextView.getMeasuredWidth(), additionalTop + textTop + subtitleTextView.getTextHeight()); } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); - if (child.getVisibility() == GONE || child == titleTextView || child == subTitleTextView || child == menu || child == backButtonImageView) { + if (child.getVisibility() == GONE || child == titleTextView || child == subtitleTextView || child == menu || child == backButtonImageView) { continue; } @@ -563,10 +556,10 @@ public class ActionBar extends FrameLayout { return occupyStatusBar; } - public void setItemsBackground(int resourceId) { - itemsBackgroundResourceId = resourceId; + public void setItemsBackgroundColor(int color) { + itemsBackgroundColor = color; if (backButtonImageView != null) { - backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); + backButtonImageView.setBackgroundDrawable(Theme.createBarSelectorDrawable(itemsBackgroundColor)); } } @@ -580,8 +573,7 @@ public class ActionBar extends FrameLayout { @Override public boolean onTouchEvent(MotionEvent event) { - super.onTouchEvent(event); - return true; + return super.onTouchEvent(event) || interceptTouches; } public static int getCurrentActionBarHeight() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java index 0bc3537ed..2eab94314 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -28,6 +28,7 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; @@ -248,7 +249,7 @@ public class ActionBarLayout extends FrameLayout { } final int restoreCount = canvas.save(); - if (!transitionAnimationInProgress && clipLeft != 0 && clipRight != 0) { + if (!transitionAnimationInProgress) { canvas.clipRect(clipLeft, 0, clipRight, getHeight()); } final boolean result = super.drawChild(canvas, child, drawingTime); @@ -427,7 +428,7 @@ public class ActionBarLayout extends FrameLayout { distToMove = containerView.getMeasuredWidth() - x; animatorSet.playTogether( ObjectAnimatorProxy.ofFloat(containerView, "translationX", containerView.getMeasuredWidth()), - ObjectAnimatorProxy.ofFloat(this, "innerTranslationX", (float)containerView.getMeasuredWidth()) + ObjectAnimatorProxy.ofFloat(this, "innerTranslationX", (float) containerView.getMeasuredWidth()) ); } else { distToMove = x; @@ -706,6 +707,7 @@ public class ActionBarLayout extends FrameLayout { ViewProxy.setTranslationX(containerView, 0); } }; + FileLog.e("tmessages", "onOpenAnimationsStart"); fragment.onTransitionAnimationStart(true, false); AnimatorSetProxy animation = fragment.onCustomTransitionAnimation(true, new Runnable() { @Override @@ -828,6 +830,7 @@ public class ActionBarLayout extends FrameLayout { layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); + FileLog.e("tmessages", "onCloseAnimationStart"); previousFragment.onTransitionAnimationStart(true, true); currentFragment.onTransitionAnimationStart(false, false); previousFragment.onResume(); @@ -918,6 +921,7 @@ public class ActionBarLayout extends FrameLayout { onAnimationEndCheck(false); } }); + FileLog.e("tmessages", "onCloseAnimationsStart"); currentAnimation.start(); } else { removeFragmentFromStackInternal(currentFragment); @@ -1043,11 +1047,13 @@ public class ActionBarLayout extends FrameLayout { if (post) { new Handler().post(new Runnable() { public void run() { + FileLog.e("tmessages", "onCloseAnimationEnd"); onCloseAnimationEndRunnable.run(); onCloseAnimationEndRunnable = null; } }); } else { + FileLog.e("tmessages", "onCloseAnimationEnd"); onCloseAnimationEndRunnable.run(); onCloseAnimationEndRunnable = null; } @@ -1061,11 +1067,13 @@ public class ActionBarLayout extends FrameLayout { if (post) { new Handler().post(new Runnable() { public void run() { + FileLog.e("tmessages", "onOpenAnimationEnd"); onOpenAnimationEndRunnable.run(); onOpenAnimationEndRunnable = null; } }); } else { + FileLog.e("tmessages", "onOpenAnimationEnd"); onOpenAnimationEndRunnable.run(); onOpenAnimationEndRunnable = null; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java index 374c1ee3a..bc9516e4d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java @@ -38,7 +38,7 @@ public class ActionBarMenu extends LinearLayout { addView(view); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; - view.setBackgroundResource(parentActionBar.itemsBackgroundResourceId); + view.setBackgroundDrawable(Theme.createBarSelectorDrawable(parentActionBar.itemsBackgroundColor)); view.setLayoutParams(layoutParams); view.setOnClickListener(new OnClickListener() { @Override @@ -50,23 +50,23 @@ public class ActionBarMenu extends LinearLayout { } public ActionBarMenuItem addItem(int id, Drawable drawable) { - return addItem(id, 0, parentActionBar.itemsBackgroundResourceId, drawable, AndroidUtilities.dp(48)); + return addItem(id, 0, parentActionBar.itemsBackgroundColor, drawable, AndroidUtilities.dp(48)); } public ActionBarMenuItem addItem(int id, int icon) { - return addItem(id, icon, parentActionBar.itemsBackgroundResourceId); + return addItem(id, icon, parentActionBar.itemsBackgroundColor); } - public ActionBarMenuItem addItem(int id, int icon, int backgroundResource) { - return addItem(id, icon, backgroundResource, null, AndroidUtilities.dp(48)); + public ActionBarMenuItem addItem(int id, int icon, int backgroundColor) { + return addItem(id, icon, backgroundColor, null, AndroidUtilities.dp(48)); } public ActionBarMenuItem addItemWithWidth(int id, int icon, int width) { - return addItem(id, icon, parentActionBar.itemsBackgroundResourceId, null, width); + return addItem(id, icon, parentActionBar.itemsBackgroundColor, null, width); } - public ActionBarMenuItem addItem(int id, int icon, int backgroundResource, Drawable drawable, int width) { - ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundResource); + public ActionBarMenuItem addItem(int id, int icon, int backgroundColor, Drawable drawable, int width) { + ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundColor); menuItem.setTag(id); if (drawable != null) { menuItem.iconView.setImageDrawable(drawable); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java index 40618db78..350d9a89e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java @@ -85,9 +85,11 @@ public class ActionBarMenuItem extends FrameLayoutFixed { protected boolean overrideMenuClick; private boolean processedPopupClick; - public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) { + public ActionBarMenuItem(Context context, ActionBarMenu menu, int backgroundColor) { super(context); - setBackgroundResource(background); + if (backgroundColor != 0) { + setBackgroundDrawable(Theme.createBarSelectorDrawable(backgroundColor)); + } parentMenu = menu; iconView = new ImageView(context); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java index 46631c952..126612e3d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java @@ -19,7 +19,6 @@ import android.view.ViewGroup; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.FileLog; -import org.telegram.messenger.R; import org.telegram.tgnet.ConnectionsManager; public class BaseFragment { @@ -116,14 +115,19 @@ public class BaseFragment { } } if (parentLayout != null && actionBar == null) { - actionBar = new ActionBar(parentLayout.getContext()); + actionBar = createActionBar(parentLayout.getContext()); actionBar.parentFragment = this; - actionBar.setBackgroundColor(0xff54759e); - actionBar.setItemsBackground(R.drawable.bar_selector); } } } + protected ActionBar createActionBar(Context context) { + ActionBar actionBar = new ActionBar(context); + actionBar.setBackgroundColor(Theme.ACTION_BAR_COLOR); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_SELECTOR_COLOR); + return actionBar; + } + public void finishFragment() { finishFragment(true); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java index b201c06f1..7f9b294e3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java @@ -56,11 +56,13 @@ public class BottomSheet extends Dialog { private LinearLayout containerView; private FrameLayout container; - private Object lastInsets; + private WindowInsets lastInsets; private boolean dismissed; private int tag; + private boolean disableBackground; + private DialogInterface.OnClickListener onClickListener; private CharSequence[] items; @@ -70,20 +72,21 @@ public class BottomSheet extends Dialog { private boolean fullWidth; private boolean isGrid; private ColorDrawable backgroundDrawable = new ColorDrawable(0xff000000); - private static Drawable shadowDrawable; private boolean focusable; private Paint ciclePaint = new Paint(Paint.ANTI_ALIAS_FLAG); - private static int backgroundPaddingTop; - private static int backgroundPaddingLeft; + private Drawable shadowDrawable; + protected static int backgroundPaddingTop; + protected static int backgroundPaddingLeft; private boolean useRevealAnimation; private float revealRadius; private int revealX; private int revealY; - private boolean applyTopPaddings = true; + private boolean applyTopPadding = true; + private boolean applyBottomPadding = true; private DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(); private AccelerateInterpolator accelerateInterpolator = new AccelerateInterpolator(); @@ -212,7 +215,17 @@ public class BottomSheet extends Dialog { } public BottomSheet(Context context, boolean needFocus) { - super(context); + super(context, R.style.TransparentDialog); + + if (Build.VERSION.SDK_INT >= 21 && !"N".equals(Build.VERSION.CODENAME)) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + } + + Rect padding = new Rect(); + shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow); + shadowDrawable.getPadding(padding); + backgroundPaddingLeft = padding.left; + backgroundPaddingTop = padding.top; container = new FrameLayout(getContext()) { @@ -227,12 +240,17 @@ public class BottomSheet extends Dialog { if (containerView != null) { int left = useRevealAnimation && Build.VERSION.SDK_INT <= 19 ? 0 : backgroundPaddingLeft; if (!fullWidth) { + int widthSpec; if (AndroidUtilities.isTablet()) { - int side = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f); - containerView.measure(MeasureSpec.makeMeasureSpec(side + left * 2, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); + widthSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f) + left * 2, MeasureSpec.EXACTLY); } else { - int maxWidth = Math.min(AndroidUtilities.dp(480), width); - containerView.measure(isPortrait ? MeasureSpec.makeMeasureSpec(width + left * 2, MeasureSpec.EXACTLY) : MeasureSpec.makeMeasureSpec((int) Math.max(width * 0.8f, maxWidth) + left * 2, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); + widthSpec = MeasureSpec.makeMeasureSpec(isPortrait ? width + left * 2 : (int) Math.max(width * 0.8f, Math.min(AndroidUtilities.dp(480), width)) + left * 2, MeasureSpec.EXACTLY); + } + if (lastInsets != null && Build.VERSION.SDK_INT >= 21 && focusable) { + containerView.getLayoutParams(); + containerView.measure(widthSpec, MeasureSpec.makeMeasureSpec(height - lastInsets.getSystemWindowInsetBottom(), MeasureSpec.AT_MOST)); + } else { + containerView.measure(widthSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); } } else { containerView.measure(MeasureSpec.makeMeasureSpec(width + left * 2, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); @@ -245,9 +263,7 @@ public class BottomSheet extends Dialog { continue; } if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { - WindowInsets wi = (WindowInsets) lastInsets; - wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); - child.dispatchApplyWindowInsets(wi); + child.dispatchApplyWindowInsets(lastInsets); } measureChildWithMargins(child, MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 0, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY), 0); } @@ -258,6 +274,13 @@ public class BottomSheet extends Dialog { if (containerView != null) { int l = ((right - left) - containerView.getMeasuredWidth()) / 2; int t = (bottom - top) - containerView.getMeasuredHeight(); + if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { + l += lastInsets.getSystemWindowInsetLeft() / 2; + l -= lastInsets.getSystemWindowInsetRight() / 2; + if (focusable) { + t -= lastInsets.getSystemWindowInsetBottom(); + } + } containerView.layout(l, t, l + containerView.getMeasuredWidth(), t + getMeasuredHeight()); } @@ -321,14 +344,14 @@ public class BottomSheet extends Dialog { }); container.setBackgroundDrawable(backgroundDrawable); focusable = needFocus; - if (Build.VERSION.SDK_INT >= 21 && !focusable) { + if (Build.VERSION.SDK_INT >= 21 && !"N".equals(Build.VERSION.CODENAME)) { container.setFitsSystemWindows(true); container.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @SuppressLint("NewApi") @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { lastInsets = insets; - container.requestLayout(); + v.requestLayout(); return insets.consumeSystemWindowInsets(); } }); @@ -341,18 +364,7 @@ public class BottomSheet extends Dialog { super.onCreate(savedInstanceState); Window window = getWindow(); - window.setBackgroundDrawableResource(R.drawable.transparent); - window.requestFeature(Window.FEATURE_NO_TITLE); window.setWindowAnimations(R.style.DialogNoAnimation); - - if (shadowDrawable == null) { - Rect padding = new Rect(); - shadowDrawable = getContext().getResources().getDrawable(R.drawable.sheet_shadow); - shadowDrawable.getPadding(padding); - backgroundPaddingLeft = padding.left; - backgroundPaddingTop = padding.top; - } - setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ciclePaint.setColor(0xffffffff); @@ -363,8 +375,6 @@ public class BottomSheet extends Dialog { protected void onDraw(Canvas canvas) { if (useRevealAnimation && Build.VERSION.SDK_INT <= 19) { canvas.drawCircle(revealX, revealY, revealRadius, ciclePaint); - //shadowDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); - //shadowDrawable.draw(canvas); } } @@ -373,6 +383,11 @@ public class BottomSheet extends Dialog { return super.drawChild(canvas, child, drawingTime); } }; + if (Build.VERSION.SDK_INT >= 21) { + containerView.setFitsSystemWindows(true); + } + containerView.setVisibility(View.INVISIBLE); + backgroundDrawable.setAlpha(0); containerView.setWillNotDraw(false); containerView.setOrientation(LinearLayout.VERTICAL); container.addView(containerView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM)); @@ -456,20 +471,18 @@ public class BottomSheet extends Dialog { } } - WindowManager.LayoutParams params = getWindow().getAttributes(); + WindowManager.LayoutParams params = window.getAttributes(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.gravity = Gravity.TOP | Gravity.LEFT; + params.dimAmount = 0; + params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; - params.dimAmount = 0; - params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; - } else { - params.dimAmount = 0.2f; } if (Build.VERSION.SDK_INT < 21) { params.height = ViewGroup.LayoutParams.MATCH_PARENT; } - getWindow().setAttributes(params); + window.setAttributes(params); } @Override @@ -479,14 +492,14 @@ public class BottomSheet extends Dialog { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); } dismissed = false; - if (Build.VERSION.SDK_INT >= 21 || !useRevealAnimation) { + if ((Build.VERSION.SDK_INT >= 21 || !useRevealAnimation) && !disableBackground) { containerView.setBackgroundDrawable(shadowDrawable); } else { containerView.setBackgroundDrawable(null); } - int left = useRevealAnimation && Build.VERSION.SDK_INT <= 19 ? 0 : backgroundPaddingLeft; - int top = useRevealAnimation && Build.VERSION.SDK_INT <= 19 ? 0 : backgroundPaddingTop; - containerView.setPadding(left, (applyTopPaddings ? AndroidUtilities.dp(8) : 0) + top, left, (applyTopPaddings ? AndroidUtilities.dp(isGrid ? 16 : 8) : 0)); + int left = useRevealAnimation && Build.VERSION.SDK_INT <= 19 || disableBackground ? 0 : backgroundPaddingLeft; + int top = useRevealAnimation && Build.VERSION.SDK_INT <= 19 || disableBackground ? 0 : backgroundPaddingTop; + containerView.setPadding(left, (applyTopPadding ? AndroidUtilities.dp(8) : 0) + top, left, (applyBottomPadding ? AndroidUtilities.dp(isGrid ? 16 : 8) : 0)); if (Build.VERSION.SDK_INT >= 21) { AndroidUtilities.runOnUIThread(new Runnable() { @Override @@ -499,6 +512,26 @@ public class BottomSheet extends Dialog { } } + public void setCustomView(View view) { + customView = view; + } + + public void setTitle(CharSequence value) { + title = value; + } + + public void setApplyTopPadding(boolean value) { + applyTopPadding = value; + } + + public void setApplyBottomPadding(boolean value) { + applyBottomPadding = value; + } + + public void setDisableBackground(boolean value) { + disableBackground = value; + } + protected void setRevealRadius(float radius) { revealRadius = radius; delegate.onRevealAnimationProgress(!dismissed, radius, revealX, revealY); @@ -513,12 +546,6 @@ public class BottomSheet extends Dialog { @SuppressLint("NewApi") private void startRevealAnimation(final boolean open) { - if (open) { - backgroundDrawable.setAlpha(0); - containerView.setVisibility(View.VISIBLE); - } else { - backgroundDrawable.setAlpha(51); - } ViewProxy.setTranslationY(containerView, 0); AnimatorSet animatorSet = new AnimatorSet(); @@ -621,6 +648,8 @@ public class BottomSheet extends Dialog { if (containerView.getMeasuredHeight() == 0) { containerView.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.y, View.MeasureSpec.AT_MOST)); } + backgroundDrawable.setAlpha(0); + containerView.setVisibility(View.VISIBLE); if (useRevealAnimation) { startRevealAnimation(true); } else { @@ -629,7 +658,7 @@ public class BottomSheet extends Dialog { AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy(); animatorSetProxy.playTogether( ObjectAnimatorProxy.ofFloat(containerView, "translationY", 0), - ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", focusable ? 0 : 51)); + ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", 51)); animatorSetProxy.setDuration(200); animatorSetProxy.setStartDelay(20); animatorSetProxy.setInterpolator(new DecelerateInterpolator()); @@ -712,6 +741,7 @@ public class BottomSheet extends Dialog { } dismissed = true; if (useRevealAnimation) { + backgroundDrawable.setAlpha(51); startRevealAnimation(false); } else { AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy(); @@ -806,8 +836,13 @@ public class BottomSheet extends Dialog { return this; } - public Builder setApplyTopPaddings(boolean value) { - bottomSheet.applyTopPaddings = value; + public Builder setApplyTopPadding(boolean value) { + bottomSheet.applyTopPadding = value; + return this; + } + + public Builder setApplyBottomPadding(boolean value) { + bottomSheet.applyBottomPadding = value; return this; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java index bb8e63493..f70a67e1a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java @@ -70,23 +70,23 @@ public class DrawerLayoutContainer extends FrameLayout { if (Build.VERSION.SDK_INT >= 21) { setFitsSystemWindows(true); - setOnApplyWindowInsetsListener(new InsetsListener()); + setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() { + @SuppressLint("NewApi") + @Override + public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { + final DrawerLayoutContainer drawerLayout = (DrawerLayoutContainer) v; + lastInsets = insets; + drawerLayout.setWillNotDraw(insets.getSystemWindowInsetTop() <= 0 && getBackground() == null); + drawerLayout.requestLayout(); + return insets.consumeSystemWindowInsets(); + } + }); setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } shadowLeft = getResources().getDrawable(R.drawable.menu_shadow); } - @SuppressLint("NewApi") - private class InsetsListener implements View.OnApplyWindowInsetsListener { - @Override - public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { - final DrawerLayoutContainer drawerLayout = (DrawerLayoutContainer) v; - drawerLayout.setChildInsets(insets, insets.getSystemWindowInsetTop() > 0); - return insets.consumeSystemWindowInsets(); - } - } - @SuppressLint("NewApi") private void dispatchChildInsets(View child, Object insets, int drawerGravity) { WindowInsets wi = (WindowInsets) insets; @@ -119,12 +119,6 @@ public class DrawerLayoutContainer extends FrameLayout { return 0; } - private void setChildInsets(Object insets, boolean draw) { - lastInsets = insets; - setWillNotDraw(!draw && getBackground() == null); - requestLayout(); - } - public void setDrawerLayout(ViewGroup layout) { drawerLayout = layout; addView(drawerLayout); @@ -371,6 +365,7 @@ public class DrawerLayoutContainer extends FrameLayout { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { inLayout = true; + FileLog.w("tmessages", "onLayout"); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); @@ -397,6 +392,10 @@ public class DrawerLayoutContainer extends FrameLayout { @Override public void requestLayout() { if (!inLayout) { + /*StackTraceElement[] elements = Thread.currentThread().getStackTrace(); + for (int a = 0; a < elements.length; a++) { + FileLog.d("tmessages", "on " + elements[a]); + }*/ super.requestLayout(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/SimpleTextView.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/SimpleTextView.java new file mode 100644 index 000000000..cdda2c80c --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/SimpleTextView.java @@ -0,0 +1,281 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.ui.ActionBar; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.text.Layout; +import android.text.SpannableStringBuilder; +import android.text.StaticLayout; +import android.text.TextPaint; +import android.text.TextUtils; +import android.view.Gravity; +import android.view.View; + +import org.telegram.messenger.AndroidUtilities; + +public class SimpleTextView extends View implements Drawable.Callback { + + private Layout layout; + private TextPaint textPaint; + private int gravity = Gravity.LEFT | Gravity.TOP; + private CharSequence text; + private SpannableStringBuilder spannableStringBuilder; + private Drawable leftDrawable; + private Drawable rightDrawable; + private int drawablePadding = AndroidUtilities.dp(4); + private int leftDrawableTopPadding; + private int rightDrawableTopPadding; + + private int offsetX; + private int textWidth; + private int textHeight; + private boolean wasLayout; + + public enum Alignment { + ALIGN_NORMAL, + ALIGN_OPPOSITE, + ALIGN_CENTER, + ALIGN_LEFT, + ALIGN_RIGHT + } + + public SimpleTextView(Context context) { + super(context); + textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + } + + public void setTextColor(int color) { + textPaint.setColor(color); + invalidate(); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + wasLayout = false; + } + + public void setTextSize(int size) { + int newSize = AndroidUtilities.dp(size); + if (newSize == textPaint.getTextSize()) { + return; + } + textPaint.setTextSize(newSize); + recreateLayoutMaybe(); + } + + public void setGravity(int value) { + gravity = value; + } + + public void setTypeface(Typeface typeface) { + textPaint.setTypeface(typeface); + } + + public int getSideDrawablesSize() { + int size = 0; + if (leftDrawable != null) { + size += leftDrawable.getIntrinsicWidth() + drawablePadding; + } + if (rightDrawable != null) { + size += rightDrawable.getIntrinsicWidth() + drawablePadding; + } + return size; + } + + public Paint getPaint() { + return textPaint; + } + + private void createLayout(int width) { + if (text != null) { + try { + if (leftDrawable != null) { + width -= leftDrawable.getIntrinsicWidth(); + width -= drawablePadding; + } + if (rightDrawable != null) { + width -= rightDrawable.getIntrinsicWidth(); + width -= drawablePadding; + } + width -= getPaddingLeft() + getPaddingRight(); + CharSequence string = TextUtils.ellipsize(text, textPaint, width, TextUtils.TruncateAt.END); + if (layout != null && TextUtils.equals(layout.getText(), string)) { + return; + } + layout = new StaticLayout(string, 0, string.length(), textPaint, width + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + + if (layout.getLineCount() > 0) { + textWidth = (int) Math.ceil(layout.getLineWidth(0)); + textHeight = layout.getLineBottom(0); + if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) { + offsetX = -(int) layout.getLineLeft(0); + } else if (layout.getLineLeft(0) == 0) { + offsetX = width - textWidth; + } else { + offsetX = 0; + } + } + } catch (Exception e) { + //ignore + } + } else { + layout = null; + textWidth = 0; + textHeight = 0; + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int width = MeasureSpec.getSize(widthMeasureSpec); + int height = MeasureSpec.getSize(heightMeasureSpec); + createLayout(width - getPaddingLeft() - getPaddingRight()); + + int finalHeight; + if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY) { + finalHeight = height; + } else { + finalHeight = textHeight; + } + setMeasuredDimension(width, finalHeight); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + if (changed) { + wasLayout = true; + } + } + + public int getTextWidth() { + return textWidth; + } + + public int getTextHeight() { + return textHeight; + } + + public void setLeftDrawableTopPadding(int value) { + leftDrawableTopPadding = value; + } + + public void setRightDrawableTopPadding(int value) { + rightDrawableTopPadding = value; + } + + public void setLeftDrawable(int resId) { + setLeftDrawable(resId == 0 ? null : getContext().getResources().getDrawable(resId)); + } + + public void setRightDrawable(int resId) { + setRightDrawable(resId == 0 ? null : getContext().getResources().getDrawable(resId)); + } + + public void setLeftDrawable(Drawable drawable) { + if (leftDrawable == drawable) { + return; + } + if (leftDrawable != null) { + leftDrawable.setCallback(null); + } + leftDrawable = drawable; + if (drawable != null) { + drawable.setCallback(this); + } + recreateLayoutMaybe(); + } + + public void setRightDrawable(Drawable drawable) { + if (rightDrawable == drawable) { + return; + } + if (rightDrawable != null) { + rightDrawable.setCallback(null); + } + rightDrawable = drawable; + if (drawable != null) { + drawable.setCallback(this); + } + recreateLayoutMaybe(); + } + + public void setText(CharSequence value) { + if (text == null && value == null || text != null && value != null && text.equals(value)) { + return; + } + text = value; + recreateLayoutMaybe(); + } + + public void setDrawablePadding(int value) { + if (drawablePadding == value) { + return; + } + drawablePadding = value; + recreateLayoutMaybe(); + } + + private void recreateLayoutMaybe() { + if (wasLayout) { + createLayout(getMeasuredWidth()); + invalidate(); + } else { + requestLayout(); + } + } + + public CharSequence getText() { + if (text == null) { + return ""; + } + return text; + } + + @Override + protected void onDraw(Canvas canvas) { + int textOffsetX = 0; + if (leftDrawable != null) { + int y = (textHeight - leftDrawable.getIntrinsicHeight()) / 2 + leftDrawableTopPadding; + leftDrawable.setBounds(0, y, leftDrawable.getIntrinsicWidth(), y + leftDrawable.getIntrinsicHeight()); + leftDrawable.draw(canvas); + if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) { + textOffsetX += drawablePadding + leftDrawable.getIntrinsicWidth(); + } + } + if (rightDrawable != null) { + int x = textOffsetX + textWidth + drawablePadding; + if (leftDrawable != null) { + x += drawablePadding + leftDrawable.getIntrinsicWidth(); + } + int y = (textHeight - rightDrawable.getIntrinsicHeight()) / 2 + rightDrawableTopPadding; + rightDrawable.setBounds(x, y, x + rightDrawable.getIntrinsicWidth(), y + rightDrawable.getIntrinsicHeight()); + rightDrawable.draw(canvas); + } + if (layout != null) { + if (offsetX + textOffsetX != 0) { + canvas.save(); + canvas.translate(offsetX + textOffsetX, 0); + } + layout.draw(canvas); + if (offsetX + textOffsetX != 0) { + canvas.restore(); + } + } + } + + @Override + public void invalidateDrawable(Drawable who) { + invalidate(); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java new file mode 100644 index 000000000..c529c9e16 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -0,0 +1,419 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.ui.ActionBar; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.graphics.Canvas; +import android.graphics.ColorFilter; +import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.RippleDrawable; +import android.graphics.drawable.StateListDrawable; +import android.os.Build; + +import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.R; + +public class Theme { + + public static final int ACTION_BAR_COLOR = 0xff527da3; + public static final int ACTION_BAR_PHOTO_VIEWER_COLOR = 0x7f000000; + public static final int ACTION_BAR_MEDIA_PICKER_COLOR = 0xff333333; + public static final int ACTION_BAR_CHANNEL_INTRO_COLOR = 0xffffffff; + public static final int ACTION_BAR_PLAYER_COLOR = 0xffffffff; + public static final int ACTION_BAR_TITLE_COLOR = 0xffffffff; + public static final int ACTION_BAR_SUBTITLE_COLOR = 0xffd5e8f7; + public static final int ACTION_BAR_PROFILE_COLOR = 0xff598fba; + public static final int ACTION_BAR_PROFILE_SUBTITLE_COLOR = 0xffd7eafa; + public static final int ACTION_BAR_MAIN_AVATAR_COLOR = 0xff5085b1; + public static final int ACTION_BAR_ACTION_MODE_TEXT_COLOR = 0xff737373; + public static final int ACTION_BAR_SELECTOR_COLOR = 0xff406d94; + + public static final int INPUT_FIELD_SELECTOR_COLOR = 0xffd6d6d6; + public static final int ACTION_BAR_PICKER_SELECTOR_COLOR = 0xff3d3d3d; + public static final int ACTION_BAR_WHITE_SELECTOR_COLOR = 0x40ffffff; + public static final int ACTION_BAR_AUDIO_SELECTOR_COLOR = 0x2f000000; + public static final int ACTION_BAR_CHANNEL_INTRO_SELECTOR_COLOR = 0x2f000000; + public static final int ACTION_BAR_MODE_SELECTOR_COLOR = 0xfff0f0f0; + public static final int ACTION_BAR_BLUE_SELECTOR_COLOR = 0xff4981ad; + public static final int ACTION_BAR_CYAN_SELECTOR_COLOR = 0xff39849d; + public static final int ACTION_BAR_GREEN_SELECTOR_COLOR = 0xff48953d; + public static final int ACTION_BAR_ORANGE_SELECTOR_COLOR = 0xffe67429; + public static final int ACTION_BAR_PINK_SELECTOR_COLOR = 0xffd44e7b; + public static final int ACTION_BAR_RED_SELECTOR_COLOR = 0xffbc4b41; + public static final int ACTION_BAR_VIOLET_SELECTOR_COLOR = 0xff735fbe; + public static final int ACTION_BAR_YELLOW_SELECTOR_COLOR = 0xffef9f09; + + + + public static final int CHAT_UNREAD_TEXT_COLOR = 0xff5695cc; + public static final int CHAT_ADD_CONTACT_TEXT_COLOR = 0xff4a82b5; + public static final int CHAT_REPORT_SPAM_TEXT_COLOR = 0xffcf5957; + public static final int CHAT_BOTTOM_OVERLAY_TEXT_COLOR = 0xff7f7f7f; + public static final int CHAT_BOTTOM_CHAT_OVERLAY_TEXT_COLOR = 0xff3a8ccf; + public static final int CHAT_GIF_HINT_TEXT_COLOR = 0xffffffff; + public static final int CHAT_EMPTY_VIEW_TEXT_COLOR = 0xffffffff; + + public static final int INAPP_PLAYER_PERFORMER_TEXT_COLOR = 0xff2f3438; + public static final int INAPP_PLAYER_TITLE_TEXT_COLOR = 0xff2f3438; + public static final int INAPP_PLAYER_BACKGROUND_COLOR = 0xffffffff; + + public static final int REPLY_PANEL_NAME_TEXT_COLOR = 0xff3a8ccf; + public static final int REPLY_PANEL_MESSAGE_TEXT_COLOR = 0xff222222; + + public static final int ALERT_PANEL_NAME_TEXT_COLOR = 0xff3a8ccf; + public static final int ALERT_PANEL_MESSAGE_TEXT_COLOR = 0xff999999; + + public static final int AUTODOWNLOAD_SHEET_SAVE_TEXT_COLOR = 0xff3a8ccf; + + public static final int SHARE_SHEET_COPY_TEXT_COLOR = 0xff3a8ccf; + public static final int SHARE_SHEET_SEND_TEXT_COLOR = 0xff3ec1f9; + public static final int SHARE_SHEET_SEND_DISABLED_TEXT_COLOR = 0xffb3b3b3; + public static final int SHARE_SHEET_EDIT_TEXT_COLOR = 0xff212121; + public static final int SHARE_SHEET_EDIT_PLACEHOLDER_TEXT_COLOR = 0xff979797; + public static final int SHARE_SHEET_BADGE_TEXT_COLOR = 0xffffffff; + + public static final int STICKERS_SHEET_TITLE_TEXT_COLOR = 0xff212121; + public static final int STICKERS_SHEET_SEND_TEXT_COLOR = 0xff3a8ccf; + public static final int STICKERS_SHEET_ADD_TEXT_COLOR = 0xff3a8ccf; + public static final int STICKERS_SHEET_CLOSE_TEXT_COLOR = 0xff3a8ccf; + public static final int STICKERS_SHEET_REMOVE_TEXT_COLOR = 0xffcd5a5a; + + public static final int PINNED_PANEL_NAME_TEXT_COLOR = 0xff3a8ccf; + public static final int PINNED_PANEL_MESSAGE_TEXT_COLOR = 0xff999999; + + public static final int SECRET_CHAT_INFO_TEXT_COLOR = 0xffffffff; + + public static final int MSG_WEB_PREVIEW_DURATION_TEXT_COLOR = 0xffffffff; + public static final int MSG_SECRET_TIME_TEXT_COLOR = 0xffe4e2e0; + public static final int MSG_STICKER_NAME_TEXT_COLOR = 0xffffffff; + public static final int MSG_BOT_BUTTON_TEXT_COLOR = 0xffffffff; + public static final int MSG_BOT_PROGRESS_COLOR = 0xffffffff; + public static final int MSG_IN_FORDWARDED_NAME_TEXT_COLOR = 0xff3886c7; + public static final int MSG_OUT_FORDWARDED_NAME_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_IN_VIA_BOT_NAME_TEXT_COLOR = 0xff3a8ccf; + public static final int MSG_OUT_VIA_BOT_NAME_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_STICKER_VIA_BOT_NAME_TEXT_COLOR = 0xffffffff; + public static final int MSG_IN_REPLY_LINE_COLOR = 0xff70b4e8; + public static final int MSG_OUT_REPLY_LINE_COLOR = 0xff88c97b; + public static final int MSG_STICKER_REPLY_LINE_COLOR = 0xffffffff; + public static final int MSG_IN_REPLY_NAME_TEXT_COLOR = 0xff3a8ccf; + public static final int MSG_OUT_REPLY_NAME_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_STICKER_REPLY_NAME_TEXT_COLOR = 0xffffffff; + public static final int MSG_IN_REPLY_MESSAGE_TEXT_COLOR = 0xff000000; + public static final int MSG_OUT_REPLY_MESSAGE_TEXT_COLOR = 0xff000000; + public static final int MSG_IN_REPLY_MEDIA_MESSAGE_TEXT_COLOR = 0xffa1aab3; + public static final int MSG_OUT_REPLY_MEDIA_MESSAGE_TEXT_COLOR = 0xff65b05b; + public static final int MSG_IN_REPLY_MEDIA_MESSAGE_SELETED_TEXT_COLOR = 0xff89b4c1; + public static final int MSG_OUT_REPLY_MEDIA_MESSAGE_SELETED_TEXT_COLOR = 0xff65b05b; + public static final int MSG_STICKER_REPLY_MESSAGE_TEXT_COLOR = 0xffffffff; + public static final int MSG_IN_WEB_PREVIEW_LINE_COLOR = 0xff70b4e8; + public static final int MSG_OUT_WEB_PREVIEW_LINE_COLOR = 0xff88c97b; + public static final int MSG_IN_SITE_NAME_TEXT_COLOR = 0xff3a8ccf; + public static final int MSG_OUT_SITE_NAME_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_IN_CONTACT_NAME_TEXT_COLOR = 0xff4e9ad4; + public static final int MSG_OUT_CONTACT_NAME_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_IN_CONTACT_PHONE_TEXT_COLOR = 0xff2f3438; + public static final int MSG_OUT_CONTACT_PHONE_TEXT_COLOR = 0xff354234; + public static final int MSG_MEDIA_PROGRESS_COLOR = 0xffffffff; + public static final int MSG_IN_AUDIO_PROGRESS_COLOR = 0xffffffff; + public static final int MSG_OUT_AUDIO_PROGRESS_COLOR = 0xffefffde; + public static final int MSG_IN_AUDIO_SELECTED_PROGRESS_COLOR = 0xffe2f8ff; + public static final int MSG_OUT_AUDIO_SELECTED_PROGRESS_COLOR = 0xffd4f5bc; + public static final int MSG_MEDIA_TIME_TEXT_COLOR = 0xffffffff; + public static final int MSG_IN_TIME_TEXT_COLOR = 0xffa1aab3; + public static final int MSG_OUT_TIME_TEXT_COLOR = 0xff70b15c; + public static final int MSG_IN_TIME_SELECTED_TEXT_COLOR = 0xff89b4c1; + public static final int MSG_OUT_TIME_SELECTED_TEXT_COLOR = 0xff70b15c; + public static final int MSG_IN_AUDIO_PERFORMER_TEXT_COLOR = 0xff2f3438; + public static final int MSG_OUT_AUDIO_PERFORMER_TEXT_COLOR = 0xff354234; + public static final int MSG_IN_AUDIO_TITLE_TEXT_COLOR = 0xff4e9ad4; + public static final int MSG_OUT_AUDIO_TITLE_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_IN_AUDIO_DURATION_TEXT_COLOR = 0xffa1aab3; + public static final int MSG_OUT_AUDIO_DURATION_TEXT_COLOR = 0xff65b05b; + public static final int MSG_IN_AUDIO_DURATION_SELECTED_TEXT_COLOR = 0xff89b4c1; + public static final int MSG_OUT_AUDIO_DURATION_SELECTED_TEXT_COLOR = 0xff65b05b; + public static final int MSG_IN_AUDIO_SEEKBAR_COLOR = 0xffe4eaf0; + public static final int MSG_OUT_AUDIO_SEEKBAR_COLOR = 0xffbbe3ac; + public static final int MSG_IN_AUDIO_SEEKBAR_SELECTED_COLOR = 0xffbcdee8; + public static final int MSG_OUT_AUDIO_SEEKBAR_SELECTED_COLOR = 0xffa9dd96; + public static final int MSG_IN_AUDIO_SEEKBAR_FILL_COLOR = 0xff72b5e8; + public static final int MSG_OUT_AUDIO_SEEKBAR_FILL_COLOR = 0xff78c272; + public static final int MSG_IN_VOICE_SEEKBAR_COLOR = 0xffdee5eb; + public static final int MSG_OUT_VOICE_SEEKBAR_COLOR = 0xffbbe3ac; + public static final int MSG_IN_VOICE_SEEKBAR_SELECTED_COLOR = 0xffbcdee8; + public static final int MSG_OUT_VOICE_SEEKBAR_SELECTED_COLOR = 0xffa9dd96; + public static final int MSG_IN_VOICE_SEEKBAR_FILL_COLOR = 0xff72b5e8; + public static final int MSG_OUT_VOICE_SEEKBAR_FILL_COLOR = 0xff78c272; + public static final int MSG_IN_FILE_PROGRESS_COLOR = 0xffebf0f5; + public static final int MSG_OUT_FILE_PROGRESS_COLOR = 0xffdaf5c3; + public static final int MSG_IN_FILE_PROGRESS_SELECTED_COLOR = 0xffcbeaf6; + public static final int MSG_OUT_FILE_PROGRESS_SELECTED_COLOR = 0xffc5eca7; + public static final int MSG_IN_FILE_NAME_TEXT_COLOR = 0xff4e9ad4; + public static final int MSG_OUT_FILE_NAME_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_IN_FILE_INFO_TEXT_COLOR = 0xffa1aab3; + public static final int MSG_OUT_FILE_INFO_TEXT_COLOR = 0xff65b05b; + public static final int MSG_IN_FILE_INFO_SELECTED_TEXT_COLOR = 0xff89b4c1; + public static final int MSG_OUT_FILE_INFO_SELECTED_TEXT_COLOR = 0xff65b05b; + public static final int MSG_IN_FILE_BACKGROUND_COLOR = 0xffebf0f5; + public static final int MSG_OUT_FILE_BACKGROUND_COLOR = 0xffdaf5c3; + public static final int MSG_IN_FILE_BACKGROUND_SELECTED_COLOR = 0xffcbeaf6; + public static final int MSG_OUT_FILE_BACKGROUND_SELECTED_COLOR = 0xffc5eca7; + public static final int MSG_IN_VENUE_NAME_TEXT_COLOR = 0xff4e9ad4; + public static final int MSG_OUT_VENUE_NAME_TEXT_COLOR = 0xff55ab4f; + public static final int MSG_IN_VENUE_INFO_TEXT_COLOR = 0xffa1aab3; + public static final int MSG_OUT_VENUE_INFO_TEXT_COLOR = 0xff65b05b; + public static final int MSG_IN_VENUE_INFO_SELECTED_TEXT_COLOR = 0xff89b4c1; + public static final int MSG_OUT_VENUE_INFO_SELECTED_TEXT_COLOR = 0xff65b05b; + public static final int MSG_MEDIA_INFO_TEXT_COLOR = 0xffffffff; + public static final int MSG_TEXT_COLOR = 0xff000000; + public static final int MSG_LINK_TEXT_COLOR = 0xff2678b6; + public static final int MSG_LINK_SELECT_BACKGROUND_COLOR = 0x3362a9e3; + + + public static Drawable backgroundDrawableIn; + public static Drawable backgroundDrawableInSelected; + public static Drawable backgroundDrawableOut; + public static Drawable backgroundDrawableOutSelected; + public static Drawable backgroundMediaDrawableIn; + public static Drawable backgroundMediaDrawableInSelected; + public static Drawable backgroundMediaDrawableOut; + public static Drawable backgroundMediaDrawableOutSelected; + public static Drawable checkDrawable; + public static Drawable halfCheckDrawable; + public static Drawable clockDrawable; + public static Drawable broadcastDrawable; + public static Drawable checkMediaDrawable; + public static Drawable halfCheckMediaDrawable; + public static Drawable clockMediaDrawable; + public static Drawable broadcastMediaDrawable; + public static Drawable errorDrawable; + public static Drawable systemDrawable; + public static Drawable backgroundBluePressed; + public static Drawable timeBackgroundDrawable; + public static Drawable timeStickerBackgroundDrawable; + public static Drawable botLink; + public static Drawable botInline; + public static Drawable[] clockChannelDrawable = new Drawable[2]; + + public static Drawable[] cornerOuter = new Drawable[4]; + public static Drawable[] cornerInner = new Drawable[4]; + + public static Drawable shareDrawable; + public static Drawable shareIconDrawable; + + public static Drawable[] viewsCountDrawable = new Drawable[2]; + public static Drawable viewsOutCountDrawable; + public static Drawable viewsMediaCountDrawable; + + public static Drawable geoInDrawable; + public static Drawable geoOutDrawable; + + public static Drawable inlineDocDrawable; + public static Drawable inlineAudioDrawable; + public static Drawable inlineLocationDrawable; + + public static Drawable[] contactDrawable = new Drawable[2]; + public static Drawable[][] fileStatesDrawable = new Drawable[10][2]; + public static Drawable[][] photoStatesDrawables = new Drawable[13][2]; + public static Drawable[] docMenuDrawable = new Drawable[4]; + + public static PorterDuffColorFilter colorFilter; + public static PorterDuffColorFilter colorPressedFilter; + private static int currentColor; + + private static Paint maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + + public static void loadRecources(Context context) { + if (backgroundDrawableIn == null) { + backgroundDrawableIn = context.getResources().getDrawable(R.drawable.msg_in); + backgroundDrawableInSelected = context.getResources().getDrawable(R.drawable.msg_in_selected); + backgroundDrawableOut = context.getResources().getDrawable(R.drawable.msg_out); + backgroundDrawableOutSelected = context.getResources().getDrawable(R.drawable.msg_out_selected); + backgroundMediaDrawableIn = context.getResources().getDrawable(R.drawable.msg_in_photo); + backgroundMediaDrawableInSelected = context.getResources().getDrawable(R.drawable.msg_in_photo_selected); + backgroundMediaDrawableOut = context.getResources().getDrawable(R.drawable.msg_out_photo); + backgroundMediaDrawableOutSelected = context.getResources().getDrawable(R.drawable.msg_out_photo_selected); + checkDrawable = context.getResources().getDrawable(R.drawable.msg_check); + halfCheckDrawable = context.getResources().getDrawable(R.drawable.msg_halfcheck); + clockDrawable = context.getResources().getDrawable(R.drawable.msg_clock); + checkMediaDrawable = context.getResources().getDrawable(R.drawable.msg_check_w); + halfCheckMediaDrawable = context.getResources().getDrawable(R.drawable.msg_halfcheck_w); + clockMediaDrawable = context.getResources().getDrawable(R.drawable.msg_clock_photo); + clockChannelDrawable[0] = context.getResources().getDrawable(R.drawable.msg_clock2); + clockChannelDrawable[1] = context.getResources().getDrawable(R.drawable.msg_clock2_s); + errorDrawable = context.getResources().getDrawable(R.drawable.msg_warning); + timeBackgroundDrawable = context.getResources().getDrawable(R.drawable.phototime2_b); + timeStickerBackgroundDrawable = context.getResources().getDrawable(R.drawable.phototime2); + broadcastDrawable = context.getResources().getDrawable(R.drawable.broadcast3); + broadcastMediaDrawable = context.getResources().getDrawable(R.drawable.broadcast4); + systemDrawable = context.getResources().getDrawable(R.drawable.system); + botLink = context.getResources().getDrawable(R.drawable.bot_link); + botInline = context.getResources().getDrawable(R.drawable.bot_lines); + + viewsCountDrawable[0] = context.getResources().getDrawable(R.drawable.post_views); + viewsCountDrawable[1] = context.getResources().getDrawable(R.drawable.post_views_s); + viewsOutCountDrawable = context.getResources().getDrawable(R.drawable.post_viewsg); + viewsMediaCountDrawable = context.getResources().getDrawable(R.drawable.post_views_w); + + fileStatesDrawable[0][0] = context.getResources().getDrawable(R.drawable.play_g); + fileStatesDrawable[0][1] = context.getResources().getDrawable(R.drawable.play_g_s); + fileStatesDrawable[1][0] = context.getResources().getDrawable(R.drawable.pause_g); + fileStatesDrawable[1][1] = context.getResources().getDrawable(R.drawable.pause_g_s); + fileStatesDrawable[2][0] = context.getResources().getDrawable(R.drawable.file_g_load); + fileStatesDrawable[2][1] = context.getResources().getDrawable(R.drawable.file_g_load_s); + fileStatesDrawable[3][0] = context.getResources().getDrawable(R.drawable.file_g); + fileStatesDrawable[3][1] = context.getResources().getDrawable(R.drawable.file_g_s); + fileStatesDrawable[4][0] = context.getResources().getDrawable(R.drawable.file_g_cancel); + fileStatesDrawable[4][1] = context.getResources().getDrawable(R.drawable.file_g_cancel_s); + fileStatesDrawable[5][0] = context.getResources().getDrawable(R.drawable.play_b); + fileStatesDrawable[5][1] = context.getResources().getDrawable(R.drawable.play_b_s); + fileStatesDrawable[6][0] = context.getResources().getDrawable(R.drawable.pause_b); + fileStatesDrawable[6][1] = context.getResources().getDrawable(R.drawable.pause_b_s); + fileStatesDrawable[7][0] = context.getResources().getDrawable(R.drawable.file_b_load); + fileStatesDrawable[7][1] = context.getResources().getDrawable(R.drawable.file_b_load_s); + fileStatesDrawable[8][0] = context.getResources().getDrawable(R.drawable.file_b); + fileStatesDrawable[8][1] = context.getResources().getDrawable(R.drawable.file_b_s); + fileStatesDrawable[9][0] = context.getResources().getDrawable(R.drawable.file_b_cancel); + fileStatesDrawable[9][1] = context.getResources().getDrawable(R.drawable.file_b_cancel_s); + + photoStatesDrawables[0][0] = context.getResources().getDrawable(R.drawable.photoload); + photoStatesDrawables[0][1] = context.getResources().getDrawable(R.drawable.photoload_pressed); + photoStatesDrawables[1][0] = context.getResources().getDrawable(R.drawable.photocancel); + photoStatesDrawables[1][1] = context.getResources().getDrawable(R.drawable.photocancel_pressed); + photoStatesDrawables[2][0] = context.getResources().getDrawable(R.drawable.photogif); + photoStatesDrawables[2][1] = context.getResources().getDrawable(R.drawable.photogif_pressed); + photoStatesDrawables[3][0] = context.getResources().getDrawable(R.drawable.playvideo); + photoStatesDrawables[3][1] = context.getResources().getDrawable(R.drawable.playvideo_pressed); + //photoStatesDrawables[4] = context.getResources().getDrawable(R.drawable.photopause); + photoStatesDrawables[4][0] = photoStatesDrawables[4][1] = context.getResources().getDrawable(R.drawable.burn); + photoStatesDrawables[5][0] = photoStatesDrawables[5][1] = context.getResources().getDrawable(R.drawable.circle); + photoStatesDrawables[6][0] = photoStatesDrawables[6][1] = context.getResources().getDrawable(R.drawable.photocheck); + + photoStatesDrawables[7][0] = context.getResources().getDrawable(R.drawable.photoload_g); + photoStatesDrawables[7][1] = context.getResources().getDrawable(R.drawable.photoload_g_s); + photoStatesDrawables[8][0] = context.getResources().getDrawable(R.drawable.photocancel_g); + photoStatesDrawables[8][1] = context.getResources().getDrawable(R.drawable.photocancel_g_s); + photoStatesDrawables[9][0] = context.getResources().getDrawable(R.drawable.doc_green); + photoStatesDrawables[9][1] = context.getResources().getDrawable(R.drawable.doc_green); + + photoStatesDrawables[10][0] = context.getResources().getDrawable(R.drawable.photoload_b); + photoStatesDrawables[10][1] = context.getResources().getDrawable(R.drawable.photoload_b_s); + photoStatesDrawables[11][0] = context.getResources().getDrawable(R.drawable.photocancel_b); + photoStatesDrawables[11][1] = context.getResources().getDrawable(R.drawable.photocancel_b_s); + photoStatesDrawables[12][0] = context.getResources().getDrawable(R.drawable.doc_blue); + photoStatesDrawables[12][1] = context.getResources().getDrawable(R.drawable.doc_blue_s); + + docMenuDrawable[0] = context.getResources().getDrawable(R.drawable.doc_actions_b); + docMenuDrawable[1] = context.getResources().getDrawable(R.drawable.doc_actions_g); + docMenuDrawable[2] = context.getResources().getDrawable(R.drawable.doc_actions_b_s); + docMenuDrawable[3] = context.getResources().getDrawable(R.drawable.video_actions); + + contactDrawable[0] = context.getResources().getDrawable(R.drawable.contact_blue); + contactDrawable[1] = context.getResources().getDrawable(R.drawable.contact_green); + + shareDrawable = context.getResources().getDrawable(R.drawable.share_round); + shareIconDrawable = context.getResources().getDrawable(R.drawable.share_arrow); + + geoInDrawable = context.getResources().getDrawable(R.drawable.location_b); + geoOutDrawable = context.getResources().getDrawable(R.drawable.location_g); + + context.getResources().getDrawable(R.drawable.attach_camera_states); + context.getResources().getDrawable(R.drawable.attach_gallery_states); + context.getResources().getDrawable(R.drawable.attach_video_states); + context.getResources().getDrawable(R.drawable.attach_audio_states); + context.getResources().getDrawable(R.drawable.attach_file_states); + context.getResources().getDrawable(R.drawable.attach_contact_states); + context.getResources().getDrawable(R.drawable.attach_location_states); + context.getResources().getDrawable(R.drawable.attach_hide_states); + + cornerOuter[0] = context.getResources().getDrawable(R.drawable.corner_out_tl); + cornerOuter[1] = context.getResources().getDrawable(R.drawable.corner_out_tr); + cornerOuter[2] = context.getResources().getDrawable(R.drawable.corner_out_br); + cornerOuter[3] = context.getResources().getDrawable(R.drawable.corner_out_bl); + + cornerInner[0] = context.getResources().getDrawable(R.drawable.corner_in_tr); + cornerInner[1] = context.getResources().getDrawable(R.drawable.corner_in_tl); + cornerInner[2] = context.getResources().getDrawable(R.drawable.corner_in_br); + cornerInner[3] = context.getResources().getDrawable(R.drawable.corner_in_bl); + + inlineDocDrawable = context.getResources().getDrawable(R.drawable.bot_file); + inlineAudioDrawable = context.getResources().getDrawable(R.drawable.bot_music); + inlineLocationDrawable = context.getResources().getDrawable(R.drawable.bot_location); + } + + int color = ApplicationLoader.getServiceMessageColor(); + if (currentColor != color) { + colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY); + colorPressedFilter = new PorterDuffColorFilter(ApplicationLoader.getServiceSelectedMessageColor(), PorterDuff.Mode.MULTIPLY); + currentColor = color; + for (int a = 0; a < 4; a++) { + cornerOuter[a].setColorFilter(colorFilter); + cornerInner[a].setColorFilter(colorFilter); + } + timeStickerBackgroundDrawable.setColorFilter(colorFilter); + } + } + + public static Drawable createBarSelectorDrawable(int color) { + return createBarSelectorDrawable(color, true); + } + + public static Drawable createBarSelectorDrawable(int color, boolean masked) { + Drawable drawable; + if (Build.VERSION.SDK_INT >= 21) { + Drawable maskDrawable = null; + if (masked) { + maskPaint.setColor(0xffffffff); + maskDrawable = new Drawable() { + @Override + public void draw(Canvas canvas) { + android.graphics.Rect bounds = getBounds(); + canvas.drawCircle(bounds.centerX(), bounds.centerY(), AndroidUtilities.dp(18), maskPaint); + } + + @Override + public void setAlpha(int alpha) { + + } + + @Override + public void setColorFilter(ColorFilter colorFilter) { + + } + + @Override + public int getOpacity() { + return 0; + } + }; + } + ColorStateList colorStateList = new ColorStateList( + new int[][]{new int[]{}}, + new int[]{color} + ); + return new RippleDrawable(colorStateList, null, maskDrawable); + } else { + StateListDrawable stateListDrawable = new StateListDrawable(); + stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(color)); + stateListDrawable.addState(new int[]{android.R.attr.state_focused}, new ColorDrawable(color)); + stateListDrawable.addState(new int[]{android.R.attr.state_selected}, new ColorDrawable(color)); + if (Build.VERSION.SDK_INT >= 11) { + stateListDrawable.addState(new int[]{android.R.attr.state_activated}, new ColorDrawable(color)); + } + stateListDrawable.addState(new int[]{}, new ColorDrawable(0x00000000)); + return stateListDrawable; + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ChatActivityAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ChatActivityAdapter.java index 183076a74..f01a9184e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ChatActivityAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ChatActivityAdapter.java @@ -202,7 +202,7 @@ public class ChatActivityAdapter { Intent intent = new Intent(Intent.ACTION_VIEW); if (message.type == 8 || message.type == 9) { MimeTypeMap myMime = MimeTypeMap.getSingleton(); - int idx = fileName.lastIndexOf("."); + int idx = fileName.lastIndexOf('.'); if (idx != -1) { String ext = fileName.substring(idx + 1); realMimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java index 7901531d1..11a1ccec8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -81,6 +81,13 @@ public class DialogsAdapter extends RecyclerView.Adapter { return arrayList.get(i); } + @Override + public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { + if (holder.itemView instanceof DialogCell) { + ((DialogCell) holder.itemView).checkCurrentDialogIndex(); + } + } + @Override public long getItemId(int i) { return i; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java index e3233f911..5f738ff28 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java @@ -331,7 +331,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { recentSearchObjects.add(0, recentSearchObject); recentSearchObject.did = did; recentSearchObject.object = object; - recentSearchObject.date = (int) System.currentTimeMillis() / 1000; + recentSearchObject.date = (int) (System.currentTimeMillis() / 1000); notifyDataSetChanged(); MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { @Override @@ -340,7 +340,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { SQLitePreparedStatement state = MessagesStorage.getInstance().getDatabase().executeFast("REPLACE INTO search_recent VALUES(?, ?)"); state.requery(); state.bindLong(1, did); - state.bindInteger(2, (int) System.currentTimeMillis() / 1000); + state.bindInteger(2, (int) (System.currentTimeMillis() / 1000)); state.step(); state.dispose(); } catch (Exception e) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java index bed8d26b3..dc0e10b6b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java @@ -8,17 +8,29 @@ package org.telegram.ui.Adapters; +import android.Manifest; +import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.location.Location; +import android.os.Build; import android.view.View; import android.view.ViewGroup; import org.telegram.SQLite.SQLiteCursor; import org.telegram.SQLite.SQLitePreparedStatement; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; +import org.telegram.messenger.R; +import org.telegram.messenger.SendMessagesHelper; import org.telegram.messenger.UserObject; import org.telegram.messenger.support.widget.LinearLayoutManager; import org.telegram.messenger.support.widget.RecyclerView; @@ -26,6 +38,8 @@ import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Cells.BotSwitchCell; import org.telegram.ui.Cells.ContextLinkCell; import org.telegram.ui.Cells.MentionCell; @@ -42,7 +56,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { void onContextClick(TLRPC.BotInlineResult result); } - private class Holder extends RecyclerView.ViewHolder { + public class Holder extends RecyclerView.ViewHolder { public Holder(View itemView) { super(itemView); @@ -50,6 +64,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { } private Context mContext; + private long dialog_id; private TLRPC.ChatFull info; private ArrayList botRecent; private ArrayList searchResultUsernames; @@ -58,6 +73,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { private ArrayList searchResultCommandsHelp; private ArrayList searchResultCommandsUsers; private ArrayList searchResultBotContext; + private TLRPC.TL_inlineBotSwitchPM searchResultBotContextSwitch; private HashMap searchResultBotContextById; private MentionsAdapterDelegate delegate; private HashMap botInfo; @@ -82,11 +98,62 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { private TLRPC.User foundContextBot; private boolean contextMedia; private Runnable contextQueryRunnable; + private Location lastKnownLocation; - public MentionsAdapter(Context context, boolean isDarkTheme, MentionsAdapterDelegate delegate) { + private BaseFragment parentFragment; + + private SendMessagesHelper.LocationProvider locationProvider = new SendMessagesHelper.LocationProvider(new SendMessagesHelper.LocationProvider.LocationProviderDelegate() { + @Override + public void onLocationAcquired(Location location) { + if (foundContextBot != null && foundContextBot.bot_inline_geo) { + lastKnownLocation = location; + searchForContextBotResults(foundContextBot, searchingContextQuery, ""); + } + } + + @Override + public void onUnableLocationAcquire() { + onLocationUnavailable(); + } + }) { + @Override + public void stop() { + super.stop(); + lastKnownLocation = null; + } + }; + + public MentionsAdapter(Context context, boolean isDarkTheme, long did, MentionsAdapterDelegate delegate) { mContext = context; this.delegate = delegate; this.isDarkTheme = isDarkTheme; + dialog_id = did; + } + + public void onDestroy() { + if (locationProvider != null) { + locationProvider.stop(); + } + if (contextQueryRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(contextQueryRunnable); + contextQueryRunnable = null; + } + if (contextUsernameReqid != 0) { + ConnectionsManager.getInstance().cancelRequest(contextUsernameReqid, true); + contextUsernameReqid = 0; + } + if (contextQueryReqid != 0) { + ConnectionsManager.getInstance().cancelRequest(contextQueryReqid, true); + contextQueryReqid = 0; + } + foundContextBot = null; + searchingContextUsername = null; + searchingContextQuery = null; + noUserName = false; + } + + public void setParentFragment(BaseFragment fragment) { + parentFragment = fragment; } public void setChatInfo(TLRPC.ChatFull chatParticipants) { @@ -115,7 +182,21 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { } cursor.dispose(); if (uids != null) { + final ArrayList uidsFinal = uids; final ArrayList users = MessagesStorage.getInstance().getUsers(uids); + Collections.sort(users, new Comparator() { + @Override + public int compare(TLRPC.User lhs, TLRPC.User rhs) { + int idx1 = uidsFinal.indexOf(lhs.id); + int idx2 = uidsFinal.indexOf(rhs.id); + if (idx1 > idx2) { + return 1; + } else if (idx1 < idx2) { + return -1; + } + return 0; + } + }); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { @@ -240,10 +321,18 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { } } + public TLRPC.TL_inlineBotSwitchPM getBotContextSwitch() { + return searchResultBotContextSwitch; + } + public int getContextBotId() { return foundContextBot != null ? foundContextBot.id : 0; } + public TLRPC.User getContextBotUser() { + return foundContextBot != null ? foundContextBot : null; + } + public String getContextBotName() { return foundContextBot != null ? foundContextBot.username : ""; } @@ -251,6 +340,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { private void searchForContextBot(final String username, final String query) { searchResultBotContext = null; searchResultBotContextById = null; + searchResultBotContextSwitch = null; notifyDataSetChanged(); if (foundContextBot != null) { delegate.needChangePanelVisibility(false); @@ -271,6 +361,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { foundContextBot = null; searchingContextUsername = null; searchingContextQuery = null; + locationProvider.stop(); noUserName = false; if (delegate != null) { delegate.onContextSearch(false); @@ -325,6 +416,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { } contextUsernameReqid = 0; foundContextBot = null; + locationProvider.stop(); if (error == null) { TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response; if (!res.users.isEmpty()) { @@ -333,6 +425,35 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { MessagesController.getInstance().putUser(user, false); MessagesStorage.getInstance().putUsersAndChats(res.users, null, true, true); foundContextBot = user; + if (foundContextBot.bot_inline_geo) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + boolean allowGeo = preferences.getBoolean("inlinegeo_" + foundContextBot.id, false); + if (!allowGeo && parentFragment != null && parentFragment.getParentActivity() != null) { + final TLRPC.User foundContextBotFinal = foundContextBot; + AlertDialog.Builder builder = new AlertDialog.Builder(parentFragment.getParentActivity()); + builder.setTitle(LocaleController.getString("ShareYouLocationTitle", R.string.ShareYouLocationTitle)); + builder.setMessage(LocaleController.getString("ShareYouLocationInline", R.string.ShareYouLocationInline)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (foundContextBotFinal != null) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + preferences.edit().putBoolean("inlinegeo_" + foundContextBotFinal.id, true).commit(); + checkLocationPermissionsOrStart(); + } + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + onLocationUnavailable(); + } + }); + parentFragment.showDialog(builder.create()); + } else { + checkLocationPermissionsOrStart(); + } + } } } } @@ -355,6 +476,28 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { AndroidUtilities.runOnUIThread(contextQueryRunnable, 400); } + private void onLocationUnavailable() { + if (foundContextBot != null && foundContextBot.bot_inline_geo) { + lastKnownLocation = new Location("network"); + lastKnownLocation.setLatitude(-1000); + lastKnownLocation.setLongitude(-1000); + searchForContextBotResults(foundContextBot, searchingContextQuery, ""); + } + } + + private void checkLocationPermissionsOrStart() { + if (parentFragment == null || parentFragment.getParentActivity() == null) { + return; + } + if (Build.VERSION.SDK_INT >= 23 && parentFragment.getParentActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + parentFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 2); + return; + } + if (foundContextBot != null && foundContextBot.bot_inline_geo) { + locationProvider.start(); + } + } + public int getOrientation() { return searchResultBotContext != null && !searchResultBotContext.isEmpty() && contextMedia ? LinearLayoutManager.HORIZONTAL : LinearLayoutManager.VERTICAL; } @@ -384,10 +527,26 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { searchingContextQuery = null; return; } + if (user.bot_inline_geo && lastKnownLocation == null) { + return; + } TLRPC.TL_messages_getInlineBotResults req = new TLRPC.TL_messages_getInlineBotResults(); req.bot = MessagesController.getInputUser(user); req.query = query; req.offset = offset; + if (user.bot_inline_geo && lastKnownLocation != null && lastKnownLocation.getLatitude() != -1000) { + req.flags |= 1; + req.geo_point = new TLRPC.TL_inputGeoPoint(); + req.geo_point.lat = lastKnownLocation.getLatitude(); + req.geo_point._long = lastKnownLocation.getLongitude(); + } + int lower_id = (int) dialog_id; + int high_id = (int) (dialog_id >> 32); + if (lower_id != 0) { + req.peer = MessagesController.getInputPeer(lower_id); + } else { + req.peer = new TLRPC.TL_inputPeerEmpty(); + } contextQueryReqid = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { @@ -406,6 +565,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { nextQueryOffset = res.next_offset; if (searchResultBotContextById == null) { searchResultBotContextById = new HashMap<>(); + searchResultBotContextSwitch = res.switch_pm; } for (int a = 0; a < res.results.size(); a++) { TLRPC.BotInlineResult result = res.results.get(a); @@ -433,11 +593,13 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { searchResultCommandsHelp = null; searchResultCommandsUsers = null; if (added) { - notifyItemRangeInserted(searchResultBotContext.size() - res.results.size(), res.results.size()); + boolean hasTop = getOrientation() == LinearLayoutManager.VERTICAL && searchResultBotContextSwitch != null; + notifyItemChanged(searchResultBotContext.size() - res.results.size() + (hasTop ? 1 : 0) - 1); + notifyItemRangeInserted(searchResultBotContext.size() - res.results.size() + (hasTop ? 1 : 0), res.results.size()); } else { notifyDataSetChanged(); } - delegate.needChangePanelVisibility(!searchResultBotContext.isEmpty()); + delegate.needChangePanelVisibility(!searchResultBotContext.isEmpty() || searchResultBotContextSwitch != null); } } }); @@ -666,7 +828,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { @Override public int getItemCount() { if (searchResultBotContext != null) { - return searchResultBotContext.size(); + return searchResultBotContext.size() + (getOrientation() == LinearLayoutManager.VERTICAL && searchResultBotContextSwitch != null ? 1 : 0); } else if (searchResultUsernames != null) { return searchResultUsernames.size(); } else if (searchResultHashtags != null) { @@ -680,6 +842,9 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { @Override public int getItemViewType(int position) { if (searchResultBotContext != null) { + if (position == 0 && getOrientation() == LinearLayoutManager.VERTICAL && searchResultBotContextSwitch != null) { + return 2; + } return 1; } else { return 0; @@ -688,6 +853,14 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { public Object getItem(int i) { if (searchResultBotContext != null) { + boolean hasTop = getOrientation() == LinearLayoutManager.VERTICAL && searchResultBotContextSwitch != null; + if (hasTop) { + if (i == 0) { + return searchResultBotContextSwitch; + } else { + i--; + } + } if (i < 0 || i >= searchResultBotContext.size()) { return null; } @@ -741,6 +914,8 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { delegate.onContextClick(cell.getResult()); } }); + } else if (viewType == 2) { + view = new BotSwitchCell(mContext); } else { view = new MentionCell(mContext); ((MentionCell) view).setIsDarkTheme(isDarkTheme); @@ -751,7 +926,17 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (searchResultBotContext != null) { - ((ContextLinkCell) holder.itemView).setLink(searchResultBotContext.get(position), contextMedia, position != searchResultBotContext.size() - 1); + boolean hasTop = getOrientation() == LinearLayoutManager.VERTICAL && searchResultBotContextSwitch != null; + if (holder.getItemViewType() == 2) { + if (hasTop) { + ((BotSwitchCell) holder.itemView).setText(searchResultBotContextSwitch.text); + } + } else { + if (hasTop) { + position--; + } + ((ContextLinkCell) holder.itemView).setLink(searchResultBotContext.get(position), contextMedia, position != searchResultBotContext.size() - 1, hasTop && position == 0); + } } else { if (searchResultUsernames != null) { ((MentionCell) holder.itemView).setUser(searchResultUsernames.get(position)); @@ -762,4 +947,16 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { } } } + + public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) { + if (requestCode == 2) { + if (foundContextBot != null && foundContextBot.bot_inline_geo) { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + locationProvider.start(); + } else { + onLocationUnavailable(); + } + } + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/PhotoAttachAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/PhotoAttachAdapter.java deleted file mode 100644 index 5eb63d8ad..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/PhotoAttachAdapter.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 3.x.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-2016. - */ - -package org.telegram.ui.Adapters; - -import android.content.Context; -import android.view.View; -import android.view.ViewGroup; - -import org.telegram.messenger.MediaController; -import org.telegram.messenger.support.widget.RecyclerView; -import org.telegram.ui.Cells.PhotoAttachPhotoCell; - -import java.util.HashMap; - -public class PhotoAttachAdapter extends RecyclerView.Adapter { - - private Context mContext; - private PhotoAttachAdapterDelegate delegate; - private HashMap selectedPhotos = new HashMap<>(); - - public interface PhotoAttachAdapterDelegate { - void selectedPhotosChanged(); - } - - private class Holder extends RecyclerView.ViewHolder { - - public Holder(View itemView) { - super(itemView); - } - } - - public PhotoAttachAdapter(Context context) { - mContext = context; - } - - public void clearSelectedPhotos() { - if (!selectedPhotos.isEmpty()) { - for (HashMap.Entry entry : selectedPhotos.entrySet()) { - MediaController.PhotoEntry photoEntry = entry.getValue(); - photoEntry.imagePath = null; - photoEntry.thumbPath = null; - photoEntry.caption = null; - } - selectedPhotos.clear(); - delegate.selectedPhotosChanged(); - notifyDataSetChanged(); - } - } - - public HashMap getSelectedPhotos() { - return selectedPhotos; - } - - public void setDelegate(PhotoAttachAdapterDelegate photoAttachAdapterDelegate) { - delegate = photoAttachAdapterDelegate; - } - - @Override - public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - PhotoAttachPhotoCell cell = (PhotoAttachPhotoCell) holder.itemView; - MediaController.PhotoEntry photoEntry = MediaController.allPhotosAlbumEntry.photos.get(position); - cell.setPhotoEntry(photoEntry, position == MediaController.allPhotosAlbumEntry.photos.size() - 1); - cell.setChecked(selectedPhotos.containsKey(photoEntry.imageId), false); - cell.getImageView().setTag(position); - cell.setTag(position); - } - - @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - PhotoAttachPhotoCell cell = new PhotoAttachPhotoCell(mContext); - cell.setDelegate(new PhotoAttachPhotoCell.PhotoAttachPhotoCellDelegate() { - @Override - public void onCheckClick(PhotoAttachPhotoCell v) { - MediaController.PhotoEntry photoEntry = v.getPhotoEntry(); - if (selectedPhotos.containsKey(photoEntry.imageId)) { - selectedPhotos.remove(photoEntry.imageId); - v.setChecked(false, true); - photoEntry.imagePath = null; - photoEntry.thumbPath = null; - v.setPhotoEntry(photoEntry, (Integer) v.getTag() == MediaController.allPhotosAlbumEntry.photos.size() - 1); - } else { - selectedPhotos.put(photoEntry.imageId, photoEntry); - v.setChecked(true, true); - } - delegate.selectedPhotosChanged(); - } - }); - return new Holder(cell); - } - - @Override - public int getItemCount() { - return (MediaController.allPhotosAlbumEntry != null ? MediaController.allPhotosAlbumEntry.photos.size() : 0); - } - - @Override - public int getItemViewType(int position) { - return 0; - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AudioPlayerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/AudioPlayerActivity.java index 416743649..7be4b309f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/AudioPlayerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/AudioPlayerActivity.java @@ -30,6 +30,7 @@ import org.telegram.messenger.R; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LineProgressView; @@ -179,9 +180,9 @@ public class AudioPlayerActivity extends BaseFragment implements NotificationCen }); fragmentView = frameLayout; - actionBar.setBackgroundColor(0xffffffff); + actionBar.setBackgroundColor(Theme.ACTION_BAR_PLAYER_COLOR); actionBar.setBackButtonImage(R.drawable.pl_back); - actionBar.setItemsBackground(R.drawable.bar_selector_audio); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR); if (!AndroidUtilities.isTablet()) { actionBar.showActionModeTop(); } @@ -436,7 +437,7 @@ public class AudioPlayerActivity extends BaseFragment implements NotificationCen actionBar.setTitle(messageObject.getMusicTitle()); actionBar.getTitleTextView().setTextColor(0xff212121); actionBar.setSubtitle(messageObject.getMusicAuthor()); - actionBar.getSubTitleTextView().setTextColor(0xff8a8a8a); + actionBar.getSubtitleTextView().setTextColor(0xff8a8a8a); } AudioInfo audioInfo = MediaController.getInstance().getAudioInfo(); if (audioInfo != null && audioInfo.getCover() != null) { @@ -451,10 +452,14 @@ public class AudioPlayerActivity extends BaseFragment implements NotificationCen if (durationTextView != null) { int duration = 0; - for (TLRPC.DocumentAttribute attribute : messageObject.messageOwner.media.document.attributes) { - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - duration = attribute.duration; - break; + TLRPC.Document document = messageObject.getDocument(); + if (document != null) { + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + duration = attribute.duration; + break; + } } } durationTextView.setText(duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--"); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java index 307d13c22..ccd898b41 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java @@ -472,7 +472,8 @@ public class CacheControlActivity extends BaseFragment { return; } BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); - builder.setApplyTopPaddings(false); + builder.setApplyTopPadding(false); + builder.setApplyBottomPadding(false); LinearLayout linearLayout = new LinearLayout(getParentActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < 6; a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/AboutLinkCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/AboutLinkCell.java index 9e75d81f2..160f91b83 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/AboutLinkCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/AboutLinkCell.java @@ -12,6 +12,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; +import android.os.Build; import android.text.Layout; import android.text.Spannable; import android.text.SpannableStringBuilder; @@ -29,8 +30,10 @@ import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessageObject; +import org.telegram.messenger.browser.Browser; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LinkPath; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.URLSpanNoUnderline; public class AboutLinkCell extends FrameLayout { @@ -60,10 +63,10 @@ public class AboutLinkCell extends FrameLayout { textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextSize(AndroidUtilities.dp(16)); textPaint.setColor(0xff000000); - textPaint.linkColor = 0xff316f9f; + textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR; urlPaint = new Paint(); - urlPaint.setColor(0x33316f9f); + urlPaint.setColor(Theme.MSG_LINK_SELECT_BACKGROUND_COLOR); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); @@ -107,6 +110,12 @@ public class AboutLinkCell extends FrameLayout { float x = event.getX(); float y = event.getY(); + if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) { + if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { + getBackground().setHotspot(x, y); + } + } + boolean result = false; if (textLayout != null) { if (event.getAction() == MotionEvent.ACTION_DOWN || pressedLink != null && event.getAction() == MotionEvent.ACTION_UP) { @@ -128,7 +137,7 @@ public class AboutLinkCell extends FrameLayout { result = true; try { int start = buffer.getSpanStart(pressedLink); - urlPath.setCurrentLayout(textLayout, start); + urlPath.setCurrentLayout(textLayout, start, 0); textLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), urlPath); } catch (Exception e) { FileLog.e("tmessages", e); @@ -154,7 +163,7 @@ public class AboutLinkCell extends FrameLayout { } } else { if (pressedLink instanceof URLSpan) { - AndroidUtilities.openUrl(getContext(), ((URLSpan) pressedLink).getURL()); + Browser.openUrl(getContext(), ((URLSpan) pressedLink).getURL()); } else { pressedLink.onClick(this); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java index ea8c3d3a6..71d87bdbe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java @@ -55,6 +55,10 @@ public class BaseCell extends View { setDrawableBounds(drawable, x, y, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); } + protected void setDrawableBounds(Drawable drawable, float x, float y) { + setDrawableBounds(drawable, (int) x, (int) y, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); + } + protected void setDrawableBounds(Drawable drawable, int x, int y, int w, int h) { if (drawable != null) { drawable.setBounds(x, y, x + w, y + h); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BotHelpCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BotHelpCell.java index 41568c1f6..e2f0292fc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BotHelpCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BotHelpCell.java @@ -28,8 +28,9 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; +import org.telegram.messenger.browser.Browser; import org.telegram.ui.Components.LinkPath; -import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.TypefaceSpan; import org.telegram.ui.Components.URLSpanNoUnderline; @@ -60,10 +61,10 @@ public class BotHelpCell extends View { textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextSize(AndroidUtilities.dp(16)); textPaint.setColor(0xff000000); - textPaint.linkColor = 0xff316f9f; + textPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR; urlPaint = new Paint(); - urlPaint.setColor(0x33316f9f); + urlPaint.setColor(Theme.MSG_LINK_SELECT_BACKGROUND_COLOR); } public void setDelegate(BotHelpCellDelegate botHelpCellDelegate) { @@ -140,7 +141,7 @@ public class BotHelpCell extends View { result = true; try { int start = buffer.getSpanStart(pressedLink); - urlPath.setCurrentLayout(textLayout, start); + urlPath.setCurrentLayout(textLayout, start, 0); textLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), urlPath); } catch (Exception e) { FileLog.e("tmessages", e); @@ -166,7 +167,7 @@ public class BotHelpCell extends View { } } else { if (pressedLink instanceof URLSpan) { - AndroidUtilities.openUrl(getContext(), ((URLSpan) pressedLink).getURL()); + Browser.openUrl(getContext(), ((URLSpan) pressedLink).getURL()); } else { pressedLink.onClick(this); } @@ -193,14 +194,16 @@ public class BotHelpCell extends View { protected void onDraw(Canvas canvas) { int x = (canvas.getWidth() - width) / 2; int y = AndroidUtilities.dp(4); - ResourceLoader.backgroundMediaDrawableIn.setBounds(x, y, width + x, height + y); - ResourceLoader.backgroundMediaDrawableIn.draw(canvas); + Theme.backgroundMediaDrawableIn.setBounds(x, y, width + x, height + y); + Theme.backgroundMediaDrawableIn.draw(canvas); canvas.save(); canvas.translate(textX = AndroidUtilities.dp(2 + 9) + x, textY = AndroidUtilities.dp(2 + 9) + y); if (pressedLink != null) { canvas.drawPath(urlPath, urlPaint); } - textLayout.draw(canvas); + if (textLayout != null) { + textLayout.draw(canvas); + } canvas.restore(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BotSwitchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BotSwitchCell.java new file mode 100644 index 000000000..dbe52d888 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BotSwitchCell.java @@ -0,0 +1,62 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.ui.Cells; + +import android.content.Context; +import android.os.Build; +import android.text.TextUtils; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.MotionEvent; +import android.widget.FrameLayout; +import android.widget.TextView; + +import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.LocaleController; +import org.telegram.messenger.R; +import org.telegram.ui.Components.LayoutHelper; + +public class BotSwitchCell extends FrameLayout { + + private TextView textView; + + public BotSwitchCell(Context context) { + super(context); + setBackgroundResource(R.drawable.list_selector); + + textView = new TextView(context); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); + textView.setTextColor(0xff4391cc); + textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + textView.setSingleLine(true); + textView.setEllipsize(TextUtils.TruncateAt.END); + textView.setMaxLines(1); + textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); + addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 14, 0, 14, 0)); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) { + if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { + getBackground().setHotspot(event.getX(), event.getY()); + } + } + return super.onTouchEvent(event); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(36), MeasureSpec.EXACTLY)); + } + + public void setText(String text) { + textView.setText(text); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java index bc73969a5..5e6f04df9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java @@ -12,7 +12,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; -import android.graphics.drawable.Drawable; +import android.graphics.RectF; import android.text.Layout; import android.text.Spannable; import android.text.StaticLayout; @@ -22,15 +22,15 @@ import android.view.MotionEvent; import android.view.SoundEffectConstants; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; -import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.UserConfig; -import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.PhotoViewer; import org.telegram.ui.Components.AvatarDrawable; @@ -43,6 +43,8 @@ public class ChatActionCell extends BaseCell { } private static TextPaint textPaint; + private static Paint backPaint; + private static RectF rect; private URLSpan pressedLink; @@ -69,11 +71,17 @@ public class ChatActionCell extends BaseCell { textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setColor(0xffffffff); textPaint.linkColor = 0xffffffff; + textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + + backPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + rect = new RectF(); } + backPaint.setColor(ApplicationLoader.getServiceMessageColor()); + imageReceiver = new ImageReceiver(this); imageReceiver.setRoundRadius(AndroidUtilities.dp(32)); avatarDrawable = new AvatarDrawable(); - textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize)); + textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize - 2)); } public void setDelegate(ChatActionCellDelegate delegate) { @@ -258,26 +266,148 @@ public class ChatActionCell extends BaseCell { setMeasuredDimension(width, textHeight + AndroidUtilities.dp(14 + (currentMessageObject.type == 11 ? 70 : 0))); } + private int findMaxWidthAroundLine(int line) { + int width = (int) Math.ceil(textLayout.getLineWidth(line)); + int count = textLayout.getLineCount(); + for (int a = line + 1; a < count; a++) { + int w = (int) Math.ceil(textLayout.getLineWidth(a)); + if (Math.abs(w - width) < AndroidUtilities.dp(12)) { + width = Math.max(w, width); + } else { + break; + } + } + for (int a = line - 1; a >= 0; a--) { + int w = (int) Math.ceil(textLayout.getLineWidth(a)); + if (Math.abs(w - width) < AndroidUtilities.dp(12)) { + width = Math.max(w, width); + } else { + break; + } + } + return width; + } + @Override protected void onDraw(Canvas canvas) { if (currentMessageObject == null) { return; } - Drawable backgroundDrawable; - if (ApplicationLoader.isCustomTheme()) { - backgroundDrawable = ResourceLoader.backgroundBlack; - } else { - backgroundDrawable = ResourceLoader.backgroundBlue; - } - backgroundDrawable.setBounds(textX - AndroidUtilities.dp(5), AndroidUtilities.dp(5), textX + textWidth + AndroidUtilities.dp(5), AndroidUtilities.dp(9) + textHeight); - backgroundDrawable.draw(canvas); - if (currentMessageObject.type == 11) { imageReceiver.draw(canvas); } if (textLayout != null) { + final int count = textLayout.getLineCount(); + final int corner = AndroidUtilities.dp(6); + int y = AndroidUtilities.dp(7); + int previousLineBottom = 0; + int dx; + int dy; + for (int a = 0; a < count; a++) { + int width = findMaxWidthAroundLine(a); + int x = (getMeasuredWidth() - width) / 2 - AndroidUtilities.dp(3); + width += AndroidUtilities.dp(6); + int lineBottom = textLayout.getLineBottom(a); + int height = lineBottom - previousLineBottom; + int additionalHeight = 0; + previousLineBottom = lineBottom; + + boolean drawBottomCorners = a == count - 1; + boolean drawTopCorners = a == 0; + + if (drawTopCorners) { + y -= AndroidUtilities.dp(3); + height += AndroidUtilities.dp(3); + } + if (drawBottomCorners) { + height += AndroidUtilities.dp(3); + } + canvas.drawRect(x, y, x + width, y + height, backPaint); + + if (!drawBottomCorners && a + 1 < count) { + int nextLineWidth = findMaxWidthAroundLine(a + 1) + AndroidUtilities.dp(6); + if (nextLineWidth + corner * 2 < width) { + int nextX = (getMeasuredWidth() - nextLineWidth) / 2; + drawBottomCorners = true; + additionalHeight = AndroidUtilities.dp(3); + + canvas.drawRect(x, y + height, nextX, y + height + AndroidUtilities.dp(3), backPaint); + canvas.drawRect(nextX + nextLineWidth, y + height, x + width, y + height + AndroidUtilities.dp(3), backPaint); + } else if (width + corner * 2 < nextLineWidth) { + additionalHeight = AndroidUtilities.dp(3); + + dy = y + height - AndroidUtilities.dp(9); + + dx = x - corner * 2; + Theme.cornerInner[2].setBounds(dx, dy, dx + corner, dy + corner); + Theme.cornerInner[2].draw(canvas); + + dx = x + width + corner; + Theme.cornerInner[3].setBounds(dx, dy, dx + corner, dy + corner); + Theme.cornerInner[3].draw(canvas); + } else { + additionalHeight = AndroidUtilities.dp(6); + } + } + if (!drawTopCorners && a > 0) { + int prevLineWidth = findMaxWidthAroundLine(a - 1) + AndroidUtilities.dp(6); + if (prevLineWidth + corner * 2 < width) { + int prevX = (getMeasuredWidth() - prevLineWidth) / 2; + drawTopCorners = true; + y -= AndroidUtilities.dp(3); + height += AndroidUtilities.dp(3); + + canvas.drawRect(x, y, prevX, y + AndroidUtilities.dp(3), backPaint); + canvas.drawRect(prevX + prevLineWidth, y, x + width, y + AndroidUtilities.dp(3), backPaint); + } else if (width + corner * 2 < prevLineWidth) { + y -= AndroidUtilities.dp(3); + height += AndroidUtilities.dp(3); + + dy = y + corner; + + dx = x - corner * 2; + Theme.cornerInner[0].setBounds(dx, dy, dx + corner, dy + corner); + Theme.cornerInner[0].draw(canvas); + + dx = x + width + corner; + Theme.cornerInner[1].setBounds(dx, dy, dx + corner, dy + corner); + Theme.cornerInner[1].draw(canvas); + } else { + y -= AndroidUtilities.dp(6); + height += AndroidUtilities.dp(6); + } + } + + canvas.drawRect(x - corner, y + corner, x, y + height + additionalHeight - corner, backPaint); + canvas.drawRect(x + width, y + corner, x + width + corner, y + height + additionalHeight - corner, backPaint); + + if (drawTopCorners) { + dx = x - corner; + Theme.cornerOuter[0].setBounds(dx, y, dx + corner, y + corner); + Theme.cornerOuter[0].draw(canvas); + + dx = x + width; + Theme.cornerOuter[1].setBounds(dx, y, dx + corner, y + corner); + Theme.cornerOuter[1].draw(canvas); + } + + if (drawBottomCorners) { + dy = y + height + additionalHeight - corner; + + dx = x + width; + Theme.cornerOuter[2].setBounds(dx, dy, dx + corner, dy + corner); + Theme.cornerOuter[2].draw(canvas); + + dx = x - corner; + Theme.cornerOuter[3].setBounds(dx, dy, dx + corner, dy + corner); + Theme.cornerOuter[3].draw(canvas); + } + + y += height; + } + canvas.save(); canvas.translate(textXLeft, textY); textLayout.draw(canvas); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java deleted file mode 100644 index 0e1040b9a..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java +++ /dev/null @@ -1,498 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 1.3.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-2016. - */ - -package org.telegram.ui.Cells; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.drawable.Drawable; -import android.text.Layout; -import android.text.StaticLayout; -import android.text.TextPaint; -import android.view.MotionEvent; -import android.view.SoundEffectConstants; - -import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ImageLoader; -import org.telegram.messenger.SendMessagesHelper; -import org.telegram.messenger.FileLoader; -import org.telegram.messenger.MediaController; -import org.telegram.messenger.MessageObject; -import org.telegram.tgnet.TLRPC; -import org.telegram.ui.Components.RadialProgress; -import org.telegram.ui.Components.ResourceLoader; -import org.telegram.ui.Components.SeekBar; -import org.telegram.ui.Components.SeekBarWaveform; - -import java.io.File; - -public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelegate { - - public interface ChatAudioCellDelegate { - boolean needPlayAudio(MessageObject messageObject); - } - - private static TextPaint timePaint; - private static Paint circlePaint; - - private boolean hasWaveform; - private SeekBar seekBar; - private SeekBarWaveform seekBarWaveform; - private int seekBarX; - private int seekBarY; - - private RadialProgress radialProgress; - private int buttonState = 0; - private int buttonX; - private int buttonY; - private boolean buttonPressed = false; - - private StaticLayout timeLayout; - private int timeX; - private int timeWidth2; - private String lastTimeString = null; - - private ChatAudioCellDelegate audioDelegate; - - public ChatAudioCell(Context context) { - super(context); - - seekBar = new SeekBar(context); - seekBar.setDelegate(this); - - seekBarWaveform = new SeekBarWaveform(context); - seekBarWaveform.setDelegate(this); - seekBarWaveform.setParentView(this); - - radialProgress = new RadialProgress(this); - drawForwardedName = true; - - if (timePaint == null) { - timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - timePaint.setTextSize(AndroidUtilities.dp(12)); - - circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - MediaController.getInstance().removeLoadingFileObserver(this); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - updateButtonState(false); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - float x = event.getX(); - float y = event.getY(); - boolean result = false; - if (delegate.canPerformActions()) { - if (hasWaveform) { - result = seekBarWaveform.onTouch(event.getAction(), event.getX() - seekBarX - AndroidUtilities.dp(13), event.getY() - seekBarY); - } else { - result = seekBar.onTouch(event.getAction(), event.getX() - seekBarX, event.getY() - seekBarY); - } - if (result) { - if (!hasWaveform && event.getAction() == MotionEvent.ACTION_DOWN) { - getParent().requestDisallowInterceptTouchEvent(true); - } else if (hasWaveform && !seekBarWaveform.isStartDraging() && event.getAction() == MotionEvent.ACTION_UP) { - didPressedButton(); - } - invalidate(); - } else { - int side = AndroidUtilities.dp(36); - boolean area; - if (buttonState == 0 || buttonState == 1) { - area = x >= buttonX - AndroidUtilities.dp(12) && x <= buttonX - AndroidUtilities.dp(12) + backgroundWidth && y >= namesOffset && y <= getMeasuredHeight(); - } else { - area = x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side; - } - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (area) { - buttonPressed = true; - invalidate(); - result = true; - radialProgress.swapBackground(getDrawableForCurrentState()); - } - } else if (buttonPressed) { - if (event.getAction() == MotionEvent.ACTION_UP) { - buttonPressed = false; - playSoundEffect(SoundEffectConstants.CLICK); - didPressedButton(); - invalidate(); - } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { - buttonPressed = false; - invalidate(); - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!area) { - buttonPressed = false; - invalidate(); - } - } - radialProgress.swapBackground(getDrawableForCurrentState()); - } - if (result && event.getAction() == MotionEvent.ACTION_DOWN) { - startCheckLongPress(); - } - if (event.getAction() != MotionEvent.ACTION_DOWN && event.getAction() != MotionEvent.ACTION_MOVE) { - cancelCheckLongPress(); - } - if (!result) { - result = super.onTouchEvent(event); - } - } - } - - return result; - } - - @Override - protected void onLongPress() { - super.onLongPress(); - if (buttonPressed) { - buttonPressed = false; - invalidate(); - } - } - - public void setAudioDelegate(ChatAudioCellDelegate delegate) { - audioDelegate = delegate; - } - - private void didPressedButton() { - if (buttonState == 0) { - if (audioDelegate.needPlayAudio(currentMessageObject)) { - buttonState = 1; - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - invalidate(); - } - } else if (buttonState == 1) { - boolean result = MediaController.getInstance().pauseAudio(currentMessageObject); - if (result) { - buttonState = 0; - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - invalidate(); - } - } else if (buttonState == 2) { - radialProgress.setProgress(0, false); - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); - buttonState = 3; - radialProgress.setBackground(getDrawableForCurrentState(), true, false); - invalidate(); - } else if (buttonState == 3) { - FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document); - buttonState = 2; - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - invalidate(); - } else if (buttonState == 4) { - if (currentMessageObject.isOut() && currentMessageObject.isSending()) { - if (delegate != null) { - delegate.didPressedCancelSendButton(this); - } - } - } - } - - public void updateProgress() { - if (currentMessageObject == null) { - return; - } - - if (hasWaveform) { - if (!seekBarWaveform.isDragging()) { - seekBarWaveform.setProgress(currentMessageObject.audioProgress); - } - } else { - if (!seekBar.isDragging()) { - seekBar.setProgress(currentMessageObject.audioProgress); - } - } - - int duration = 0; - if (!MediaController.getInstance().isPlayingAudio(currentMessageObject)) { - for (int a = 0; a < currentMessageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = currentMessageObject.messageOwner.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - duration = attribute.duration; - break; - } - } - } else { - duration = currentMessageObject.audioProgressSec; - } - String timeString = String.format("%02d:%02d", duration / 60, duration % 60); - if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { - lastTimeString = timeString; - timeWidth2 = (int)Math.ceil(timePaint.measureText(timeString)); - timeLayout = new StaticLayout(timeString, timePaint, timeWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - } - invalidate(); - } - - public void downloadAudioIfNeed() { - if (buttonState == 2) { - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); - buttonState = 3; - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - } - } - - public void updateButtonState(boolean animated) { - if (currentMessageObject == null) { - return; - } - if (currentMessageObject.isOut() && currentMessageObject.isSending()) { - MediaController.getInstance().addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, this); - buttonState = 4; - radialProgress.setBackground(getDrawableForCurrentState(), true, animated); - Float progress = ImageLoader.getInstance().getFileProgress(currentMessageObject.messageOwner.attachPath); - if (progress == null && SendMessagesHelper.getInstance().isSendingMessage(currentMessageObject.getId())) { - progress = 1.0f; - } - radialProgress.setProgress(progress != null ? progress : 0, false); - } else { - File cacheFile = null; - if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() > 0) { - cacheFile = new File(currentMessageObject.messageOwner.attachPath); - if(!cacheFile.exists()) { - cacheFile = null; - } - } - if (cacheFile == null) { - cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); - } - if (cacheFile.exists()) { - MediaController.getInstance().removeLoadingFileObserver(this); - boolean playing = MediaController.getInstance().isPlayingAudio(currentMessageObject); - if (!playing || playing && MediaController.getInstance().isAudioPaused()) { - buttonState = 0; - } else { - buttonState = 1; - } - radialProgress.setProgress(0, animated); - radialProgress.setBackground(getDrawableForCurrentState(), false, animated); - } else { - String fileName = currentMessageObject.getFileName(); - MediaController.getInstance().addLoadingFileObserver(fileName, this); - if (!FileLoader.getInstance().isLoadingFile(fileName)) { - buttonState = 2; - radialProgress.setProgress(0, animated); - radialProgress.setBackground(getDrawableForCurrentState(), false, animated); - } else { - buttonState = 3; - Float progress = ImageLoader.getInstance().getFileProgress(fileName); - if (progress != null) { - radialProgress.setProgress(progress, animated); - } else { - radialProgress.setProgress(0, animated); - } - radialProgress.setBackground(getDrawableForCurrentState(), true, animated); - } - } - } - updateProgress(); - } - - @Override - public void onFailedDownload(String fileName) { - updateButtonState(true); - } - - @Override - public void onSuccessDownload(String fileName) { - updateButtonState(true); - updateWaveform(); - } - - @Override - public void onProgressDownload(String fileName, float progress) { - radialProgress.setProgress(progress, true); - if (buttonState != 3) { - updateButtonState(false); - } - } - - @Override - public void onProgressUpload(String fileName, float progress, boolean isEncrypted) { - radialProgress.setProgress(progress, true); - } - - @Override - public void onSeekBarDrag(float progress) { - if (currentMessageObject == null) { - return; - } - currentMessageObject.audioProgress = progress; - MediaController.getInstance().seekToProgress(currentMessageObject, progress); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int width = MeasureSpec.getSize(widthMeasureSpec); - setMeasuredDimension(width, AndroidUtilities.dp(66) + namesOffset); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - - if (currentMessageObject.isOutOwner()) { - seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(55); - buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(13); - timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(66); - } else { - if (isChat && currentMessageObject.isFromUser()) { - seekBarX = AndroidUtilities.dp(116); - buttonX = AndroidUtilities.dp(74); - timeX = AndroidUtilities.dp(127); - } else { - seekBarX = AndroidUtilities.dp(64); - buttonX = AndroidUtilities.dp(22); - timeX = AndroidUtilities.dp(75); - } - } - seekBarWaveform.width = seekBar.width = backgroundWidth - AndroidUtilities.dp(70); - seekBarWaveform.height = seekBar.height = AndroidUtilities.dp(30); - seekBarWaveform.width -= AndroidUtilities.dp(20); - seekBarY = AndroidUtilities.dp(11) + namesOffset; - buttonY = AndroidUtilities.dp(13) + namesOffset; - radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(40), buttonY + AndroidUtilities.dp(40)); - - updateProgress(); - } - - @Override - public void setMessageObject(MessageObject messageObject) { - boolean dataChanged = currentMessageObject == messageObject && isUserDataChanged(); - if (currentMessageObject != messageObject || dataChanged) { - if (AndroidUtilities.isTablet()) { - backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(300)); - } else { - backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(300)); - } - - int duration = 0; - for (int a = 0; a < messageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = messageObject.messageOwner.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - duration = attribute.duration; - break; - } - } - - availableTimeWidth = backgroundWidth - AndroidUtilities.dp(75 + 14) - (int) Math.ceil(timePaint.measureText("00:00")); - measureTime(messageObject); - int minSize = AndroidUtilities.dp(40 + 14 + 20 + 90 + 10) + timeWidth; - backgroundWidth = Math.min(backgroundWidth, minSize + duration * AndroidUtilities.dp(10)); - - hasWaveform = false; - if (messageObject.isOutOwner()) { - seekBarWaveform.setColors(0xffc3e3ab, 0xff87bf78, 0xffa9d389); - } else { - seekBarWaveform.setColors(0xffdee5eb, 0xff4195e5, 0xffaed5e2); - } - seekBar.type = messageObject.isOutOwner() ? 0 : 1; - - super.setMessageObject(messageObject); - } - updateWaveform(); - updateButtonState(dataChanged); - } - - @Override - protected int getMaxNameWidth() { - return backgroundWidth - AndroidUtilities.dp(24); - } - - @Override - public void setCheckPressed(boolean value, boolean pressed) { - super.setCheckPressed(value, pressed); - if (radialProgress.swapBackground(getDrawableForCurrentState())) { - invalidate(); - } - seekBarWaveform.setSelected(isDrawSelectedBackground()); - } - - @Override - public void setHighlighted(boolean value) { - super.setHighlighted(value); - if (radialProgress.swapBackground(getDrawableForCurrentState())) { - invalidate(); - } - seekBarWaveform.setSelected(isDrawSelectedBackground()); - } - - @Override - public void setPressed(boolean pressed) { - super.setPressed(pressed); - if (radialProgress.swapBackground(getDrawableForCurrentState())) { - invalidate(); - } - seekBarWaveform.setSelected(isDrawSelectedBackground()); - } - - private Drawable getDrawableForCurrentState() { - return ResourceLoader.audioStatesDrawable[currentMessageObject.isOutOwner() ? buttonState : buttonState + 5][isDrawSelectedBackground() ? 2 : (buttonPressed ? 1 : 0)]; - } - - private void updateWaveform() { - File path = FileLoader.getPathToMessage(currentMessageObject.messageOwner); - for (int a = 0; a < currentMessageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = currentMessageObject.messageOwner.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - if (attribute.waveform == null || attribute.waveform.length == 0) { - MediaController.getInstance().generateWaveform(currentMessageObject); - } - hasWaveform = attribute.waveform != null; - seekBarWaveform.setWaveform(attribute.waveform); - seekBarWaveform.setMessageObject(currentMessageObject); - break; - } - } - } - - @Override - protected void onDraw(Canvas canvas) { - if (currentMessageObject == null) { - return; - } - - super.onDraw(canvas); - - canvas.save(); - if (hasWaveform) { - canvas.translate(seekBarX + AndroidUtilities.dp(13), seekBarY); - seekBarWaveform.draw(canvas); - } else { - canvas.translate(seekBarX, seekBarY); - seekBar.draw(canvas); - } - canvas.restore(); - - radialProgress.setProgressColor(currentMessageObject.isOutOwner() ? 0xff87bf78 : (isDrawSelectedBackground() ? 0xff83b2c2 : 0xffa2b5c7)); - timePaint.setColor(currentMessageObject.isOutOwner() ? 0xff70b15c : (isDrawSelectedBackground() ? 0xff89b4c1 : 0xffa1aab3)); - circlePaint.setColor(currentMessageObject.isOutOwner() ? 0xff87bf78 : 0xff4195e5); - radialProgress.draw(canvas); - - canvas.save(); - canvas.translate(timeX, AndroidUtilities.dp(42) + namesOffset); - timeLayout.draw(canvas); - canvas.restore(); - - if (currentMessageObject.messageOwner.to_id.channel_id == 0 && currentMessageObject.isContentUnread()) { - canvas.drawCircle(timeX + timeWidth2 + AndroidUtilities.dp(8), AndroidUtilities.dp(49.5f) + namesOffset, AndroidUtilities.dp(3), circlePaint); - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java index 9c32ab0d1..a3cf79580 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java @@ -10,9 +10,9 @@ package org.telegram.ui.Cells; import android.annotation.SuppressLint; import android.content.Context; -import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.text.Layout; import android.text.SpannableStringBuilder; @@ -30,7 +30,6 @@ import org.telegram.messenger.Emoji; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaController; import org.telegram.messenger.UserObject; -import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.tgnet.TLRPC; @@ -39,8 +38,7 @@ import org.telegram.messenger.R; import org.telegram.messenger.MessageObject; import org.telegram.messenger.ImageReceiver; import org.telegram.ui.Components.AvatarDrawable; -import org.telegram.ui.Components.ResourceLoader; -import org.telegram.ui.Components.StaticLayoutEx; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.TypefaceSpan; public class ChatBaseCell extends BaseCell implements MediaController.FileDownloadProgressListener { @@ -53,10 +51,12 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo void didLongPressed(ChatBaseCell cell); void didPressedReplyMessage(ChatBaseCell cell, int id); void didPressedUrl(MessageObject messageObject, ClickableSpan url, boolean longPress); - void needOpenWebView(String url, String title, String originalUrl, int w, int h); + void needOpenWebView(String url, String title, String description, String originalUrl, int w, int h); void didPressedImage(ChatBaseCell cell); void didPressedShare(ChatBaseCell cell); void didPressedOther(ChatBaseCell cell); + void didPressedBotButton(ChatBaseCell cell, TLRPC.KeyboardButton button); + boolean needPlayAudio(MessageObject messageObject); boolean canPerformActions(); } @@ -71,13 +71,15 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo private boolean wasLayout; protected boolean isAvatarVisible; protected boolean drawBackground = true; + protected int substractBackgroundHeight; protected boolean allowAssistant; + protected Drawable currentBackgroundDrawable; protected MessageObject currentMessageObject; private int viaWidth; private int viaNameWidth; protected int availableTimeWidth; - private static TextPaint timePaint; + protected static TextPaint timePaint; private static TextPaint namePaint; private static TextPaint forwardNamePaint; protected static TextPaint replyNamePaint; @@ -117,14 +119,16 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo protected int nameWidth; private float nameOffsetX; private float nameX; + private float nameY; protected boolean drawName; + protected boolean drawNameLayout; - private StaticLayout forwardedNameLayout; + private StaticLayout[] forwardedNameLayout = new StaticLayout[2]; protected int forwardedNameWidth; protected boolean drawForwardedName; private int forwardNameX; private int forwardNameY; - private float forwardNameOffsetX; + private float forwardNameOffsetX[] = new float[2]; private StaticLayout timeLayout; protected int timeWidth; @@ -162,7 +166,8 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo timePaint.setTextSize(AndroidUtilities.dp(12)); namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - namePaint.setTextSize(AndroidUtilities.dp(15)); + namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + namePaint.setTextSize(AndroidUtilities.dp(14)); forwardNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); forwardNamePaint.setTextSize(AndroidUtilities.dp(14)); @@ -173,7 +178,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo replyTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); replyTextPaint.setTextSize(AndroidUtilities.dp(14)); - replyTextPaint.linkColor = 0xff316f9f; + replyTextPaint.linkColor = Theme.MSG_LINK_TEXT_COLOR; replyLinePaint = new Paint(); } @@ -315,11 +320,11 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { currentViewsString = String.format("%s", LocaleController.formatShortNumber(Math.max(1, messageObject.messageOwner.views), null)); viewsTextWidth = (int) Math.ceil(timePaint.measureText(currentViewsString)); - timeWidth += viewsTextWidth + ResourceLoader.viewsCountDrawable[0].getIntrinsicWidth() + AndroidUtilities.dp(10); + timeWidth += viewsTextWidth + Theme.viewsCountDrawable[0].getIntrinsicWidth() + AndroidUtilities.dp(10); } if (hasSign) { if (availableTimeWidth == 0) { - availableTimeWidth = AndroidUtilities.dp(100); + availableTimeWidth = AndroidUtilities.dp(1000); } CharSequence name = ContactsController.formatName(signUser.first_name, signUser.last_name).replace('\n', ' '); int widthForSign = availableTimeWidth - timeWidth; @@ -342,7 +347,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo return true; } } else if (messageObject.messageOwner.from_id < 0 || messageObject.messageOwner.post) { - if (messageObject.messageOwner.to_id.channel_id != 0 && (messageObject.messageOwner.reply_to_msg_id == 0 || messageObject.type != 13)) { + if (messageObject.messageOwner.to_id.channel_id != 0 && (messageObject.messageOwner.via_bot_id == 0 && messageObject.messageOwner.reply_to_msg_id == 0 || messageObject.type != 13)) { return true; } } @@ -369,6 +374,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo currentUser = null; currentChat = null; currentViaBotUser = null; + drawNameLayout = false; if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { if (currentMessageObject.isContentUnread() && !currentMessageObject.isOut()) { @@ -417,25 +423,25 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo namesOffset = 0; String viaUsername = null; - String viaString = null; + CharSequence viaString = null; if (messageObject.messageOwner.via_bot_id != 0) { TLRPC.User botUser = MessagesController.getInstance().getUser(messageObject.messageOwner.via_bot_id); if (botUser != null && botUser.username != null && botUser.username.length() > 0) { viaUsername = "@" + botUser.username; - viaString = " via " + viaUsername; - viaWidth = (int) Math.ceil(forwardNamePaint.measureText(viaString)); + viaString = AndroidUtilities.replaceTags(String.format(" via %s", viaUsername)); + viaWidth = (int) Math.ceil(replyNamePaint.measureText(viaString, 0, viaString.length())); currentViaBotUser = botUser; } } else if (messageObject.messageOwner.via_bot_name != null && messageObject.messageOwner.via_bot_name.length() > 0) { viaUsername = "@" + messageObject.messageOwner.via_bot_name; - viaString = " via " + messageObject.messageOwner.via_bot_name; - viaWidth = (int) Math.ceil(forwardNamePaint.measureText(viaString)); + viaString = AndroidUtilities.replaceTags(String.format(" via %s", viaUsername)); + viaWidth = (int) Math.ceil(replyNamePaint.measureText(viaString, 0, viaString.length())); } boolean authorName = drawName && isChat && !currentMessageObject.isOutOwner(); - boolean viaBot = messageObject.messageOwner.fwd_from == null && viaUsername != null; + boolean viaBot = (messageObject.messageOwner.fwd_from == null || messageObject.type == 14) && viaUsername != null; if (authorName || viaBot) { - drawName = true; + drawNameLayout = true; nameWidth = getMaxNameWidth(); if (nameWidth < 0) { nameWidth = AndroidUtilities.dp(100); @@ -452,30 +458,38 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } else { currentNameString = ""; } - - CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - AndroidUtilities.dp(12) - (viaBot ? viaWidth : 0), TextUtils.TruncateAt.END); + CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace('\n', ' '), namePaint, nameWidth - (viaBot ? viaWidth : 0), TextUtils.TruncateAt.END); if (viaBot) { viaNameWidth = (int) Math.ceil(namePaint.measureText(nameStringFinal, 0, nameStringFinal.length())); if (viaNameWidth != 0) { viaNameWidth += AndroidUtilities.dp(4); } + int color; + if (currentMessageObject.type == 13) { + color = Theme.MSG_STICKER_VIA_BOT_NAME_TEXT_COLOR; + } else { + color = currentMessageObject.isOutOwner() ? Theme.MSG_OUT_VIA_BOT_NAME_TEXT_COLOR : Theme.MSG_IN_VIA_BOT_NAME_TEXT_COLOR; + } if (currentNameString.length() > 0) { SpannableStringBuilder stringBuilder = new SpannableStringBuilder(String.format("%s via %s", nameStringFinal, viaUsername)); - stringBuilder.setSpan(new TypefaceSpan(null, 0, currentMessageObject.isOutOwner() ? 0xff4a923c : 0xff006fc8), nameStringFinal.length() + 1, nameStringFinal.length() + 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, currentMessageObject.isOutOwner() ? 0xff4a923c : 0xff006fc8), nameStringFinal.length() + 5, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + stringBuilder.setSpan(new TypefaceSpan(Typeface.DEFAULT, 0, color), nameStringFinal.length() + 1, nameStringFinal.length() + 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, color), nameStringFinal.length() + 5, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); nameStringFinal = stringBuilder; } else { SpannableStringBuilder stringBuilder = new SpannableStringBuilder(String.format("via %s", viaUsername)); - stringBuilder.setSpan(new TypefaceSpan(null, 0, currentMessageObject.isOutOwner() ? 0xff4a923c : 0xff006fc8), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, currentMessageObject.isOutOwner() ? 0xff4a923c : 0xff006fc8), 4, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + stringBuilder.setSpan(new TypefaceSpan(Typeface.DEFAULT, 0, color), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, color), 4, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); nameStringFinal = stringBuilder; } + nameStringFinal = TextUtils.ellipsize(nameStringFinal, namePaint, nameWidth, TextUtils.TruncateAt.END); } try { nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (nameLayout != null && nameLayout.getLineCount() > 0) { - nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0)); - namesOffset += AndroidUtilities.dp(19); + nameWidth = (int) Math.ceil(nameLayout.getLineWidth(0)); + if (messageObject.type != 13) { + namesOffset += AndroidUtilities.dp(19); + } nameOffsetX = nameLayout.getLineLeft(0); } else { nameWidth = 0; @@ -483,14 +497,21 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } catch (Exception e) { FileLog.e("tmessages", e); } + if (currentNameString.length() == 0) { + currentNameString = null; + } } else { currentNameString = null; nameLayout = null; nameWidth = 0; } + currentForwardUser = null; + currentForwardNameString = null; + forwardedNameLayout[0] = null; + forwardedNameLayout[1] = null; + forwardedNameWidth = 0; if (drawForwardedName && messageObject.isForwarded()) { - currentForwardUser = null; currentForwardChannel = null; if (messageObject.messageOwner.fwd_from.channel_id != 0) { currentForwardChannel = MessagesController.getInstance().getChat(messageObject.messageOwner.fwd_from.channel_id); @@ -511,38 +532,33 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } forwardedNameWidth = getMaxNameWidth(); - - CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40) - viaWidth, TextUtils.TruncateAt.END); + int fromWidth = (int) Math.ceil(forwardNamePaint.measureText(LocaleController.getString("From", R.string.From) + " ")); + CharSequence name = TextUtils.ellipsize(currentForwardNameString.replace('\n', ' '), replyNamePaint, forwardedNameWidth - fromWidth - viaWidth, TextUtils.TruncateAt.END); + CharSequence lastLine; if (viaString != null) { - viaNameWidth = (int) Math.ceil(forwardNamePaint.measureText(LocaleController.getString("From", R.string.From) + " " + str)); - str = AndroidUtilities.replaceTags(String.format("%s\n%s %s via %s", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str, viaUsername)); + viaNameWidth = (int) Math.ceil(forwardNamePaint.measureText(LocaleController.getString("From", R.string.From) + " " + name)); + lastLine = AndroidUtilities.replaceTags(String.format("%s %s via %s", LocaleController.getString("From", R.string.From), name, viaUsername)); } else { - str = AndroidUtilities.replaceTags(String.format("%s\n%s %s", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str)); + lastLine = AndroidUtilities.replaceTags(String.format("%s %s", LocaleController.getString("From", R.string.From), name)); } - forwardedNameLayout = StaticLayoutEx.createStaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, forwardedNameWidth, 2); - if (forwardedNameLayout.getLineCount() > 1) { - forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1))); + lastLine = TextUtils.ellipsize(lastLine, forwardNamePaint, forwardedNameWidth, TextUtils.TruncateAt.END); + try { + forwardedNameLayout[1] = new StaticLayout(lastLine, forwardNamePaint, forwardedNameWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + lastLine = TextUtils.ellipsize(AndroidUtilities.replaceTags(LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage)), forwardNamePaint, forwardedNameWidth, TextUtils.TruncateAt.END); + forwardedNameLayout[0] = new StaticLayout(lastLine, forwardNamePaint, forwardedNameWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout[0].getLineWidth(0)), (int) Math.ceil(forwardedNameLayout[1].getLineWidth(0))); + forwardNameOffsetX[0] = forwardedNameLayout[0].getLineLeft(0); + forwardNameOffsetX[1] = forwardedNameLayout[1].getLineLeft(0); namesOffset += AndroidUtilities.dp(36); - forwardNameOffsetX = Math.min(forwardedNameLayout.getLineLeft(0), forwardedNameLayout.getLineLeft(1)); - } else { - forwardedNameWidth = 0; + } catch (Exception e) { + FileLog.e("tmessages", e); } - } else { - currentForwardNameString = null; - forwardedNameLayout = null; - forwardedNameWidth = 0; } - } else { - currentForwardNameString = null; - forwardedNameLayout = null; - forwardedNameWidth = 0; } if (messageObject.isReply()) { namesOffset += AndroidUtilities.dp(42); - if (messageObject.contentType == 2 || messageObject.contentType == 3) { - namesOffset += AndroidUtilities.dp(4); - } else if (messageObject.type != 0) { + if (messageObject.type != 0) { if (messageObject.type == 13) { namesOffset -= AndroidUtilities.dp(42); } else { @@ -550,33 +566,9 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } } - int maxWidth; - if (messageObject.type == 13) { - int width; - if (AndroidUtilities.isTablet()) { - if (AndroidUtilities.isSmallTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { - width = AndroidUtilities.displaySize.x; - } else { - int leftWidth = AndroidUtilities.displaySize.x / 100 * 35; - if (leftWidth < AndroidUtilities.dp(320)) { - leftWidth = AndroidUtilities.dp(320); - } - width = AndroidUtilities.displaySize.x - leftWidth; - } - } else { - width = AndroidUtilities.displaySize.x; - } - - if (messageObject.isOutOwner()) { - maxWidth = width - backgroundWidth - AndroidUtilities.dp(60); - } else { - maxWidth = width - backgroundWidth - AndroidUtilities.dp(56 + (isChat && messageObject.isFromUser() ? 61 : 0)); - } - } else { - maxWidth = getMaxNameWidth() - AndroidUtilities.dp(22); - } - if (!mediaBackground) { - maxWidth -= AndroidUtilities.dp(8); + int maxWidth = getMaxNameWidth(); + if (messageObject.type != 13) { + maxWidth -= AndroidUtilities.dp(10); } CharSequence stringFinalName = null; @@ -612,23 +604,23 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } if (name != null) { - stringFinalName = TextUtils.ellipsize(name.replace("\n", " "), replyNamePaint, maxWidth - AndroidUtilities.dp(8), TextUtils.TruncateAt.END); + stringFinalName = TextUtils.ellipsize(name.replace('\n', ' '), replyNamePaint, maxWidth, TextUtils.TruncateAt.END); } if (messageObject.replyMessageObject.messageText != null && messageObject.replyMessageObject.messageText.length() > 0) { String mess = messageObject.replyMessageObject.messageText.toString(); if (mess.length() > 150) { mess = mess.substring(0, 150); } - mess = mess.replace("\n", " "); + mess = mess.replace('\n', ' '); stringFinalText = Emoji.replaceEmoji(mess, replyTextPaint.getFontMetricsInt(), AndroidUtilities.dp(14), false); - stringFinalText = TextUtils.ellipsize(stringFinalText, replyTextPaint, maxWidth - AndroidUtilities.dp(8), TextUtils.TruncateAt.END); + stringFinalText = TextUtils.ellipsize(stringFinalText, replyTextPaint, maxWidth, TextUtils.TruncateAt.END); } } if (stringFinalName == null) { stringFinalName = LocaleController.getString("Loading", R.string.Loading); } try { - replyNameLayout = new StaticLayout(stringFinalName, replyNamePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + replyNameLayout = new StaticLayout(stringFinalName, replyNamePaint, maxWidth + AndroidUtilities.dp(6), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (replyNameLayout.getLineCount() > 0) { replyNameWidth = (int)Math.ceil(replyNameLayout.getLineWidth(0)) + AndroidUtilities.dp(12 + (needReplyImage ? 44 : 0)); replyNameOffset = replyNameLayout.getLineLeft(0); @@ -638,7 +630,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } try { if (stringFinalText != null) { - replyTextLayout = new StaticLayout(stringFinalText, replyTextPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + replyTextLayout = new StaticLayout(stringFinalText, replyTextPaint, maxWidth + AndroidUtilities.dp(6), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (replyTextLayout.getLineCount() > 0) { replyTextWidth = (int) Math.ceil(replyTextLayout.getLineWidth(0)) + AndroidUtilities.dp(12 + (needReplyImage ? 44 : 0)); replyTextOffset = replyTextLayout.getLineLeft(0); @@ -657,7 +649,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } protected int getMaxNameWidth() { - return backgroundWidth - AndroidUtilities.dp(8); + return backgroundWidth - AndroidUtilities.dp(mediaBackground ? 22 : 31); } @Override @@ -670,14 +662,14 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo if (isAvatarVisible && avatarImage.isInsideImage(x, y)) { avatarPressed = true; result = true; - } else if (drawForwardedName && forwardedNameLayout != null && x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + AndroidUtilities.dp(32)) { + } else if (drawForwardedName && forwardedNameLayout[0] != null && x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + AndroidUtilities.dp(32)) { if (viaWidth != 0 && x >= forwardNameX + viaNameWidth + AndroidUtilities.dp(4)) { forwardBotPressed = true; } else { forwardNamePressed = true; } result = true; - } else if (drawName && nameLayout != null && viaWidth != 0 && x >= nameX + viaNameWidth && x <= nameX + viaNameWidth + viaWidth && y >= AndroidUtilities.dp(6) && y <= AndroidUtilities.dp(30)) { + } else if (drawNameLayout && nameLayout != null && viaWidth != 0 && x >= nameX + viaNameWidth && x <= nameX + viaNameWidth + viaWidth && y >= nameY - AndroidUtilities.dp(4) && y <= nameY + AndroidUtilities.dp(20)) { forwardBotPressed = true; result = true; } else if (currentMessageObject.isReply() && x >= replyStartX && x <= replyStartX + Math.max(replyNameWidth, replyTextWidth) && y >= replyStartY && y <= replyStartY + AndroidUtilities.dp(35)) { @@ -742,12 +734,12 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { forwardBotPressed = false; } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (drawForwardedName && forwardedNameLayout != null) { + if (drawForwardedName && forwardedNameLayout[0] != null) { if (!(x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + AndroidUtilities.dp(32))) { forwardBotPressed = false; } } else { - if (!(x >= nameX + viaNameWidth && x <= nameX + viaNameWidth + viaWidth && y >= AndroidUtilities.dp(6) && y <= AndroidUtilities.dp(30))) { + if (!(x >= nameX + viaNameWidth && x <= nameX + viaNameWidth + viaWidth && y >= nameY - AndroidUtilities.dp(4) && y <= nameY + AndroidUtilities.dp(20))) { forwardBotPressed = false; } } @@ -796,20 +788,20 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo if (changed || !wasLayout) { layoutWidth = getMeasuredWidth(); - layoutHeight = getMeasuredHeight(); + layoutHeight = getMeasuredHeight() - substractBackgroundHeight; if (timeTextWidth < 0) { timeTextWidth = AndroidUtilities.dp(10); } - timeLayout = new StaticLayout(currentTimeString, timePaint, timeTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + timeLayout = new StaticLayout(currentTimeString, timePaint, timeTextWidth + AndroidUtilities.dp(6), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (!mediaBackground) { if (!currentMessageObject.isOutOwner()) { - timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(52) : 0); + timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(48) : 0); } else { timeX = layoutWidth - timeWidth - AndroidUtilities.dp(38.5f); } } else { if (!currentMessageObject.isOutOwner()) { - timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(52) : 0); + timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(48) : 0); } else { timeX = layoutWidth - timeWidth - AndroidUtilities.dp(42.0f); } @@ -822,14 +814,14 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } if (isAvatarVisible) { - avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(45), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); + avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(44), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); } wasLayout = true; } } - protected void onAfterBackgroundDraw(Canvas canvas) { + protected void drawContent(Canvas canvas) { } @@ -864,156 +856,170 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } if (mediaBackground) { - timePaint.setColor(0xffffffff); + timePaint.setColor(Theme.MSG_MEDIA_TIME_TEXT_COLOR); } else { if (currentMessageObject.isOutOwner()) { - timePaint.setColor(0xff70b15c); + timePaint.setColor(isDrawSelectedBackground() ? Theme.MSG_OUT_TIME_SELECTED_TEXT_COLOR : Theme.MSG_OUT_TIME_TEXT_COLOR); } else { - timePaint.setColor(isDrawSelectedBackground() ? 0xff89b4c1 : 0xffa1aab3); + timePaint.setColor(isDrawSelectedBackground() ? Theme.MSG_IN_TIME_SELECTED_TEXT_COLOR : Theme.MSG_IN_TIME_TEXT_COLOR); } } - Drawable currentBackgroundDrawable; if (currentMessageObject.isOutOwner()) { if (isDrawSelectedBackground()) { if (!mediaBackground) { - currentBackgroundDrawable = ResourceLoader.backgroundDrawableOutSelected; + currentBackgroundDrawable = Theme.backgroundDrawableOutSelected; } else { - currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableOutSelected; + currentBackgroundDrawable = Theme.backgroundMediaDrawableOutSelected; } } else { if (!mediaBackground) { - currentBackgroundDrawable = ResourceLoader.backgroundDrawableOut; + currentBackgroundDrawable = Theme.backgroundDrawableOut; } else { - currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableOut; + currentBackgroundDrawable = Theme.backgroundMediaDrawableOut; } } - setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!mediaBackground ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); + setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!mediaBackground ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth - (mediaBackground ? 0 : AndroidUtilities.dp(3)), layoutHeight - AndroidUtilities.dp(2)); } else { if (isDrawSelectedBackground()) { if (!mediaBackground) { - currentBackgroundDrawable = ResourceLoader.backgroundDrawableInSelected; + currentBackgroundDrawable = Theme.backgroundDrawableInSelected; } else { - currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableInSelected; + currentBackgroundDrawable = Theme.backgroundMediaDrawableInSelected; } } else { if (!mediaBackground) { - currentBackgroundDrawable = ResourceLoader.backgroundDrawableIn; + currentBackgroundDrawable = Theme.backgroundDrawableIn; } else { - currentBackgroundDrawable = ResourceLoader.backgroundMediaDrawableIn; + currentBackgroundDrawable = Theme.backgroundMediaDrawableIn; } } if (isChat && currentMessageObject.isFromUser()) { - setDrawableBounds(currentBackgroundDrawable, AndroidUtilities.dp(52 + (!mediaBackground ? 0 : 9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); + setDrawableBounds(currentBackgroundDrawable, AndroidUtilities.dp(48 + (!mediaBackground ? 3 : 9)), AndroidUtilities.dp(1), backgroundWidth - (mediaBackground ? 0 : AndroidUtilities.dp(3)), layoutHeight - AndroidUtilities.dp(2)); } else { - setDrawableBounds(currentBackgroundDrawable, (!mediaBackground ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); + setDrawableBounds(currentBackgroundDrawable, (!mediaBackground ? AndroidUtilities.dp(3) : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth - (mediaBackground ? 0 : AndroidUtilities.dp(3)), layoutHeight - AndroidUtilities.dp(2)); } } if (drawBackground && currentBackgroundDrawable != null) { currentBackgroundDrawable.draw(canvas); } - onAfterBackgroundDraw(canvas); + drawContent(canvas); if (drawShareButton) { - ResourceLoader.shareDrawable[ApplicationLoader.isCustomTheme() ? 1 : 0][sharePressed ? 1 : 0].setBounds(shareStartX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(8), shareStartY = layoutHeight - AndroidUtilities.dp(41), currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(40), layoutHeight - AndroidUtilities.dp(9)); - ResourceLoader.shareDrawable[ApplicationLoader.isCustomTheme() ? 1 : 0][sharePressed ? 1 : 0].draw(canvas); + Theme.shareDrawable.setColorFilter(sharePressed ? Theme.colorPressedFilter : Theme.colorFilter); + setDrawableBounds(Theme.shareDrawable, shareStartX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(8), shareStartY = layoutHeight - AndroidUtilities.dp(41)); + Theme.shareDrawable.draw(canvas); + setDrawableBounds(Theme.shareIconDrawable, shareStartX + AndroidUtilities.dp(9), shareStartY + AndroidUtilities.dp(9)); + Theme.shareIconDrawable.draw(canvas); } - if (drawName && nameLayout != null) { + if (drawNameLayout && nameLayout != null) { canvas.save(); - if (mediaBackground || currentMessageObject.isOutOwner()) { - canvas.translate(nameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10) - nameOffsetX, AndroidUtilities.dp(10)); + + if (currentMessageObject.type == 13) { + namePaint.setColor(Theme.MSG_STICKER_NAME_TEXT_COLOR); + int backWidth; + if (currentMessageObject.isOutOwner()) { + nameX = AndroidUtilities.dp(28); + } else { + nameX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(22); + } + nameY = layoutHeight - AndroidUtilities.dp(38); + Theme.systemDrawable.setColorFilter(Theme.colorFilter); + Theme.systemDrawable.setBounds((int) nameX - AndroidUtilities.dp(12), (int) nameY - AndroidUtilities.dp(5), (int) nameX + AndroidUtilities.dp(12) + nameWidth, (int) nameY + AndroidUtilities.dp(22)); + Theme.systemDrawable.draw(canvas); } else { - canvas.translate(nameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10)); - } - if (currentUser != null) { - namePaint.setColor(AvatarDrawable.getNameColorForId(currentUser.id)); - } else if (currentChat != null) { - namePaint.setColor(AvatarDrawable.getNameColorForId(currentChat.id)); - } else { - namePaint.setColor(AvatarDrawable.getNameColorForId(0)); + if (mediaBackground || currentMessageObject.isOutOwner()) { + nameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11) - nameOffsetX; + } else { + nameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(17) - nameOffsetX; + } + if (currentUser != null) { + namePaint.setColor(AvatarDrawable.getNameColorForId(currentUser.id)); + } else if (currentChat != null) { + namePaint.setColor(AvatarDrawable.getNameColorForId(currentChat.id)); + } else { + namePaint.setColor(AvatarDrawable.getNameColorForId(0)); + } + nameY = AndroidUtilities.dp(10); } + canvas.translate(nameX, nameY); nameLayout.draw(canvas); canvas.restore(); - - /*if (forwardedNameLayout == null && viaWidth != 0) { - canvas.drawRect(nameX + viaNameWidth, AndroidUtilities.dp(6), nameX + viaNameWidth + viaWidth, AndroidUtilities.dp(30), namePaint); - }*/ } - if (drawForwardedName && forwardedNameLayout != null) { - forwardNameY = AndroidUtilities.dp(10 + (drawName ? 19 : 0)); + if (drawForwardedName && forwardedNameLayout[0] != null && forwardedNameLayout[1] != null) { + forwardNameY = AndroidUtilities.dp(10 + (drawNameLayout ? 19 : 0)); if (currentMessageObject.isOutOwner()) { - forwardNamePaint.setColor(0xff4a923c); - forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10); + forwardNamePaint.setColor(Theme.MSG_OUT_FORDWARDED_NAME_TEXT_COLOR); + forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); } else { - forwardNamePaint.setColor(0xff006fc8); + forwardNamePaint.setColor(Theme.MSG_IN_FORDWARDED_NAME_TEXT_COLOR); if (mediaBackground) { - forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10); + forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); } else { - forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19); + forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(17); } } - canvas.save(); - canvas.translate(forwardNameX - forwardNameOffsetX, forwardNameY); - forwardedNameLayout.draw(canvas); - canvas.restore(); + for (int a = 0; a < 2; a++) { + canvas.save(); + canvas.translate(forwardNameX - forwardNameOffsetX[a], forwardNameY + AndroidUtilities.dp(16) * a); + forwardedNameLayout[a].draw(canvas); + canvas.restore(); + } } if (currentMessageObject.isReply()) { if (currentMessageObject.type == 13) { - replyLinePaint.setColor(0xffffffff); - replyNamePaint.setColor(0xffffffff); - replyTextPaint.setColor(0xffffffff); - int backWidth; + replyLinePaint.setColor(Theme.MSG_STICKER_REPLY_LINE_COLOR); + replyNamePaint.setColor(Theme.MSG_STICKER_REPLY_NAME_TEXT_COLOR); + replyTextPaint.setColor(Theme.MSG_STICKER_REPLY_MESSAGE_TEXT_COLOR); if (currentMessageObject.isOutOwner()) { - backWidth = currentBackgroundDrawable.getBounds().left - AndroidUtilities.dp(32); - replyStartX = currentBackgroundDrawable.getBounds().left - AndroidUtilities.dp(9) - backWidth; + replyStartX = AndroidUtilities.dp(23); } else { - backWidth = getWidth() - currentBackgroundDrawable.getBounds().right - AndroidUtilities.dp(32); - replyStartX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(23); - } - Drawable back; - if (ApplicationLoader.isCustomTheme()) { - back = ResourceLoader.backgroundBlack; - } else { - back = ResourceLoader.backgroundBlue; + replyStartX = currentBackgroundDrawable.getBounds().right + AndroidUtilities.dp(17); } replyStartY = layoutHeight - AndroidUtilities.dp(58); - back.setBounds(replyStartX - AndroidUtilities.dp(7), replyStartY - AndroidUtilities.dp(6), replyStartX - AndroidUtilities.dp(7) + backWidth, replyStartY + AndroidUtilities.dp(41)); - back.draw(canvas); + if (nameLayout != null) { + replyStartY -= AndroidUtilities.dp(25 + 6); + } + int backWidth = Math.max(replyNameWidth, replyTextWidth) + AndroidUtilities.dp(14 + (needReplyImage ? 44 : 0)); + Theme.systemDrawable.setColorFilter(Theme.colorFilter); + Theme.systemDrawable.setBounds(replyStartX - AndroidUtilities.dp(7), replyStartY - AndroidUtilities.dp(6), replyStartX - AndroidUtilities.dp(7) + backWidth, replyStartY + AndroidUtilities.dp(41)); + Theme.systemDrawable.draw(canvas); } else { if (currentMessageObject.isOutOwner()) { - replyLinePaint.setColor(0xff8dc97a); - replyNamePaint.setColor(0xff61a349); + replyLinePaint.setColor(Theme.MSG_OUT_REPLY_LINE_COLOR); + replyNamePaint.setColor(Theme.MSG_OUT_REPLY_NAME_TEXT_COLOR); if (currentMessageObject.replyMessageObject != null && currentMessageObject.replyMessageObject.type == 0) { - replyTextPaint.setColor(0xff000000); + replyTextPaint.setColor(Theme.MSG_OUT_REPLY_MESSAGE_TEXT_COLOR); } else { - replyTextPaint.setColor(0xff70b15c); + replyTextPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_OUT_REPLY_MEDIA_MESSAGE_SELETED_TEXT_COLOR : Theme.MSG_OUT_REPLY_MEDIA_MESSAGE_TEXT_COLOR); } - replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); + replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(12); } else { - replyLinePaint.setColor(0xff6c9fd2); - replyNamePaint.setColor(0xff377aae); + replyLinePaint.setColor(Theme.MSG_IN_REPLY_LINE_COLOR); + replyNamePaint.setColor(Theme.MSG_IN_REPLY_NAME_TEXT_COLOR); if (currentMessageObject.replyMessageObject != null && currentMessageObject.replyMessageObject.type == 0) { - replyTextPaint.setColor(0xff000000); + replyTextPaint.setColor(Theme.MSG_IN_REPLY_MESSAGE_TEXT_COLOR); } else { - replyTextPaint.setColor(0xff999999); + replyTextPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_IN_REPLY_MEDIA_MESSAGE_SELETED_TEXT_COLOR : Theme.MSG_IN_REPLY_MEDIA_MESSAGE_TEXT_COLOR); } if (mediaBackground) { - replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); + replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(12); } else { - replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(20); + replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(18); } } - replyStartY = AndroidUtilities.dp(12 + (drawForwardedName && forwardedNameLayout != null ? 36 : 0) + (drawName && nameLayout != null ? 20 : 0)); + replyStartY = AndroidUtilities.dp(12 + (drawForwardedName && forwardedNameLayout[0] != null ? 36 : 0) + (drawNameLayout && nameLayout != null ? 20 : 0)); } canvas.drawRect(replyStartX, replyStartY, replyStartX + AndroidUtilities.dp(2), replyStartY + AndroidUtilities.dp(35), replyLinePaint); if (needReplyImage) { replyImageReceiver.setImageCoords(replyStartX + AndroidUtilities.dp(10), replyStartY, AndroidUtilities.dp(35), AndroidUtilities.dp(35)); replyImageReceiver.draw(canvas); } + if (replyNameLayout != null) { canvas.save(); canvas.translate(replyStartX - replyNameOffset + AndroidUtilities.dp(10 + (needReplyImage ? 44 : 0)), replyStartY); @@ -1030,8 +1036,14 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo if (drawTime || !mediaBackground) { if (mediaBackground) { - setDrawableBounds(ResourceLoader.mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOutOwner() ? 20 : 0)), AndroidUtilities.dp(16.5f)); - ResourceLoader.mediaBackgroundDrawable.draw(canvas); + Drawable drawable; + if (currentMessageObject.type == 13) { + drawable = Theme.timeStickerBackgroundDrawable; + } else { + drawable = Theme.timeBackgroundDrawable; + } + setDrawableBounds(drawable, timeX - AndroidUtilities.dp(4), layoutHeight - AndroidUtilities.dp(27), timeWidth + AndroidUtilities.dp(8 + (currentMessageObject.isOutOwner() ? 20 : 0)), AndroidUtilities.dp(17)); + drawable.draw(canvas); int additionalX = 0; if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { @@ -1039,22 +1051,22 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo if (currentMessageObject.isSending()) { if (!currentMessageObject.isOutOwner()) { - setDrawableBounds(ResourceLoader.clockMediaDrawable, timeX + AndroidUtilities.dp(11), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.clockMediaDrawable.getIntrinsicHeight()); - ResourceLoader.clockMediaDrawable.draw(canvas); + setDrawableBounds(Theme.clockMediaDrawable, timeX + AndroidUtilities.dp(11), layoutHeight - AndroidUtilities.dp(13.0f) - Theme.clockMediaDrawable.getIntrinsicHeight()); + Theme.clockMediaDrawable.draw(canvas); } } else if (currentMessageObject.isSendError()) { if (!currentMessageObject.isOutOwner()) { - setDrawableBounds(ResourceLoader.errorDrawable, timeX + AndroidUtilities.dp(11), layoutHeight - AndroidUtilities.dp(12.5f) - ResourceLoader.errorDrawable.getIntrinsicHeight()); - ResourceLoader.errorDrawable.draw(canvas); + setDrawableBounds(Theme.errorDrawable, timeX + AndroidUtilities.dp(11), layoutHeight - AndroidUtilities.dp(12.5f) - Theme.errorDrawable.getIntrinsicHeight()); + Theme.errorDrawable.draw(canvas); } } else { - Drawable countDrawable = ResourceLoader.viewsMediaCountDrawable; - setDrawableBounds(countDrawable, timeX, layoutHeight - AndroidUtilities.dp(10) - timeLayout.getHeight()); + Drawable countDrawable = Theme.viewsMediaCountDrawable; + setDrawableBounds(countDrawable, timeX, layoutHeight - AndroidUtilities.dp(9.5f) - timeLayout.getHeight()); countDrawable.draw(canvas); if (viewsLayout != null) { canvas.save(); - canvas.translate(timeX + countDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(12.0f) - timeLayout.getHeight()); + canvas.translate(timeX + countDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(11.3f) - timeLayout.getHeight()); viewsLayout.draw(canvas); canvas.restore(); } @@ -1062,7 +1074,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } canvas.save(); - canvas.translate(timeX + additionalX, layoutHeight - AndroidUtilities.dp(12.0f) - timeLayout.getHeight()); + canvas.translate(timeX + additionalX, layoutHeight - AndroidUtilities.dp(11.3f) - timeLayout.getHeight()); timeLayout.draw(canvas); canvas.restore(); } else { @@ -1072,27 +1084,27 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo if (currentMessageObject.isSending()) { if (!currentMessageObject.isOutOwner()) { - Drawable clockDrawable = ResourceLoader.clockChannelDrawable[isDrawSelectedBackground() ? 1 : 0]; + Drawable clockDrawable = Theme.clockChannelDrawable[isDrawSelectedBackground() ? 1 : 0]; setDrawableBounds(clockDrawable, timeX + AndroidUtilities.dp(11), layoutHeight - AndroidUtilities.dp(8.5f) - clockDrawable.getIntrinsicHeight()); clockDrawable.draw(canvas); } } else if (currentMessageObject.isSendError()) { if (!currentMessageObject.isOutOwner()) { - setDrawableBounds(ResourceLoader.errorDrawable, timeX + AndroidUtilities.dp(11), layoutHeight - AndroidUtilities.dp(6.5f) - ResourceLoader.errorDrawable.getIntrinsicHeight()); - ResourceLoader.errorDrawable.draw(canvas); + setDrawableBounds(Theme.errorDrawable, timeX + AndroidUtilities.dp(11), layoutHeight - AndroidUtilities.dp(6.5f) - Theme.errorDrawable.getIntrinsicHeight()); + Theme.errorDrawable.draw(canvas); } } else { if (!currentMessageObject.isOutOwner()) { - setDrawableBounds(ResourceLoader.viewsCountDrawable[isDrawSelectedBackground() ? 1 : 0], timeX, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight()); - ResourceLoader.viewsCountDrawable[isDrawSelectedBackground() ? 1 : 0].draw(canvas); + setDrawableBounds(Theme.viewsCountDrawable[isDrawSelectedBackground() ? 1 : 0], timeX, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight()); + Theme.viewsCountDrawable[isDrawSelectedBackground() ? 1 : 0].draw(canvas); } else { - setDrawableBounds(ResourceLoader.viewsOutCountDrawable, timeX, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight()); - ResourceLoader.viewsOutCountDrawable.draw(canvas); + setDrawableBounds(Theme.viewsOutCountDrawable, timeX, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight()); + Theme.viewsOutCountDrawable.draw(canvas); } if (viewsLayout != null) { canvas.save(); - canvas.translate(timeX + ResourceLoader.viewsOutCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(6.5f) - timeLayout.getHeight()); + canvas.translate(timeX + Theme.viewsOutCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(6.5f) - timeLayout.getHeight()); viewsLayout.draw(canvas); canvas.restore(); } @@ -1103,6 +1115,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo canvas.translate(timeX + additionalX, layoutHeight - AndroidUtilities.dp(6.5f) - timeLayout.getHeight()); timeLayout.draw(canvas); canvas.restore(); + //canvas.drawRect(timeX, layoutHeight - AndroidUtilities.dp(6.5f) - timeLayout.getHeight(), timeX + availableTimeWidth, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight(), timePaint); } if (currentMessageObject.isOutOwner()) { @@ -1136,58 +1149,58 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo if (drawClock) { if (!mediaBackground) { - setDrawableBounds(ResourceLoader.clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - ResourceLoader.clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - ResourceLoader.clockDrawable.getIntrinsicHeight()); - ResourceLoader.clockDrawable.draw(canvas); + setDrawableBounds(Theme.clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - Theme.clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - Theme.clockDrawable.getIntrinsicHeight()); + Theme.clockDrawable.draw(canvas); } else { - setDrawableBounds(ResourceLoader.clockMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - ResourceLoader.clockMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.clockMediaDrawable.getIntrinsicHeight()); - ResourceLoader.clockMediaDrawable.draw(canvas); + setDrawableBounds(Theme.clockMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - Theme.clockMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - Theme.clockMediaDrawable.getIntrinsicHeight()); + Theme.clockMediaDrawable.draw(canvas); } } if (isBroadcast) { if (drawCheck1 || drawCheck2) { if (!mediaBackground) { - setDrawableBounds(ResourceLoader.broadcastDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - ResourceLoader.broadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.broadcastDrawable.getIntrinsicHeight()); - ResourceLoader.broadcastDrawable.draw(canvas); + setDrawableBounds(Theme.broadcastDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - Theme.broadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - Theme.broadcastDrawable.getIntrinsicHeight()); + Theme.broadcastDrawable.draw(canvas); } else { - setDrawableBounds(ResourceLoader.broadcastMediaDrawable, layoutWidth - AndroidUtilities.dp(24.0f) - ResourceLoader.broadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.broadcastMediaDrawable.getIntrinsicHeight()); - ResourceLoader.broadcastMediaDrawable.draw(canvas); + setDrawableBounds(Theme.broadcastMediaDrawable, layoutWidth - AndroidUtilities.dp(24.0f) - Theme.broadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - Theme.broadcastMediaDrawable.getIntrinsicHeight()); + Theme.broadcastMediaDrawable.draw(canvas); } } } else { if (drawCheck2) { if (!mediaBackground) { if (drawCheck1) { - setDrawableBounds(ResourceLoader.checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - ResourceLoader.checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.checkDrawable.getIntrinsicHeight()); + setDrawableBounds(Theme.checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - Theme.checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - Theme.checkDrawable.getIntrinsicHeight()); } else { - setDrawableBounds(ResourceLoader.checkDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - ResourceLoader.checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.checkDrawable.getIntrinsicHeight()); + setDrawableBounds(Theme.checkDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - Theme.checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - Theme.checkDrawable.getIntrinsicHeight()); } - ResourceLoader.checkDrawable.draw(canvas); + Theme.checkDrawable.draw(canvas); } else { if (drawCheck1) { - setDrawableBounds(ResourceLoader.checkMediaDrawable, layoutWidth - AndroidUtilities.dp(26.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicHeight()); + setDrawableBounds(Theme.checkMediaDrawable, layoutWidth - AndroidUtilities.dp(26.3f) - Theme.checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - Theme.checkMediaDrawable.getIntrinsicHeight()); } else { - setDrawableBounds(ResourceLoader.checkMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.checkMediaDrawable.getIntrinsicHeight()); + setDrawableBounds(Theme.checkMediaDrawable, layoutWidth - AndroidUtilities.dp(21.5f) - Theme.checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - Theme.checkMediaDrawable.getIntrinsicHeight()); } - ResourceLoader.checkMediaDrawable.draw(canvas); + Theme.checkMediaDrawable.draw(canvas); } } if (drawCheck1) { if (!mediaBackground) { - setDrawableBounds(ResourceLoader.halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - ResourceLoader.halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.halfCheckDrawable.getIntrinsicHeight()); - ResourceLoader.halfCheckDrawable.draw(canvas); + setDrawableBounds(Theme.halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - Theme.halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - Theme.halfCheckDrawable.getIntrinsicHeight()); + Theme.halfCheckDrawable.draw(canvas); } else { - setDrawableBounds(ResourceLoader.halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - ResourceLoader.halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - ResourceLoader.halfCheckMediaDrawable.getIntrinsicHeight()); - ResourceLoader.halfCheckMediaDrawable.draw(canvas); + setDrawableBounds(Theme.halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dp(21.5f) - Theme.halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - Theme.halfCheckMediaDrawable.getIntrinsicHeight()); + Theme.halfCheckMediaDrawable.draw(canvas); } } } if (drawError) { if (!mediaBackground) { - setDrawableBounds(ResourceLoader.errorDrawable, layoutWidth - AndroidUtilities.dp(18) - ResourceLoader.errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(6.5f) - ResourceLoader.errorDrawable.getIntrinsicHeight()); - ResourceLoader.errorDrawable.draw(canvas); + setDrawableBounds(Theme.errorDrawable, layoutWidth - AndroidUtilities.dp(18) - Theme.errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(7) - Theme.errorDrawable.getIntrinsicHeight()); + Theme.errorDrawable.draw(canvas); } else { - setDrawableBounds(ResourceLoader.errorDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - ResourceLoader.errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - ResourceLoader.errorDrawable.getIntrinsicHeight()); - ResourceLoader.errorDrawable.draw(canvas); + setDrawableBounds(Theme.errorDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - Theme.errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(11.5f) - Theme.errorDrawable.getIntrinsicHeight()); + Theme.errorDrawable.draw(canvas); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java deleted file mode 100644 index f204795d3..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 3.x.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-2016. - */ - -package org.telegram.ui.Cells; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.drawable.Drawable; -import android.text.Layout; -import android.text.StaticLayout; -import android.text.TextPaint; -import android.text.TextUtils; -import android.view.MotionEvent; -import android.view.SoundEffectConstants; - -import org.telegram.PhoneFormat.PhoneFormat; -import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ContactsController; -import org.telegram.messenger.ImageReceiver; -import org.telegram.messenger.LocaleController; -import org.telegram.messenger.MessageObject; -import org.telegram.messenger.MessagesController; -import org.telegram.messenger.R; -import org.telegram.tgnet.TLRPC; -import org.telegram.messenger.UserConfig; -import org.telegram.ui.Components.AvatarDrawable; - -public class ChatContactCell extends ChatBaseCell { - - public interface ChatContactCellDelegate { - void didClickAddButton(ChatContactCell cell, TLRPC.User user); - void didClickPhone(ChatContactCell cell); - } - - private static TextPaint namePaint; - private static TextPaint phonePaint; - private static Drawable addContactDrawableIn; - private static Drawable addContactDrawableOut; - - private ImageReceiver avatarImage; - private AvatarDrawable avatarDrawable; - - private StaticLayout nameLayout; - private StaticLayout phoneLayout; - - private TLRPC.User contactUser; - private TLRPC.FileLocation currentPhoto; - - private boolean avatarPressed = false; - private boolean buttonPressed = false; - private boolean drawAddButton = false; - private int namesWidth = 0; - - private ChatContactCellDelegate contactDelegate = null; - - public ChatContactCell(Context context) { - super(context); - if (namePaint == null) { - namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - namePaint.setTextSize(AndroidUtilities.dp(15)); - - phonePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - phonePaint.setTextSize(AndroidUtilities.dp(15)); - phonePaint.setColor(0xff212121); - - addContactDrawableIn = getResources().getDrawable(R.drawable.addcontact_blue); - addContactDrawableOut = getResources().getDrawable(R.drawable.addcontact_green); - } - avatarImage = new ImageReceiver(this); - avatarImage.setRoundRadius(AndroidUtilities.dp(21)); - avatarDrawable = new AvatarDrawable(); - } - - public void setContactDelegate(ChatContactCellDelegate delegate) { - this.contactDelegate = delegate; - } - - @Override - protected boolean isUserDataChanged() { - if (currentMessageObject == null) { - return false; - } - - int uid = currentMessageObject.messageOwner.media.user_id; - boolean newDrawAdd = contactUser != null && uid != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(uid) == null; - if (newDrawAdd != drawAddButton) { - return true; - } - - contactUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id); - - TLRPC.FileLocation newPhoto = null; - if (contactUser != null && contactUser.photo != null) { - newPhoto = contactUser.photo.photo_small; - } - - return currentPhoto == null && newPhoto != null || currentPhoto != null && newPhoto == null || currentPhoto != null && newPhoto != null && (currentPhoto.local_id != newPhoto.local_id || currentPhoto.volume_id != newPhoto.volume_id) || super.isUserDataChanged(); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - float x = event.getX(); - float y = event.getY(); - - boolean result = false; - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (x >= avatarImage.getImageX() && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(42) && y >= avatarImage.getImageY() && y <= avatarImage.getImageY() + avatarImage.getImageHeight()) { - avatarPressed = true; - result = true; - } else if (drawAddButton && x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) + namesOffset && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52) + namesOffset) { - buttonPressed = true; - result = true; - } - if (result) { - startCheckLongPress(); - } - } else { - if (event.getAction() != MotionEvent.ACTION_MOVE) { - cancelCheckLongPress(); - } - if (avatarPressed) { - if (event.getAction() == MotionEvent.ACTION_UP) { - avatarPressed = false; - playSoundEffect(SoundEffectConstants.CLICK); - if (contactUser != null) { - if (delegate != null) { - delegate.didPressedUserAvatar(this, contactUser); - } - } else { - if (contactDelegate != null) { - contactDelegate.didClickPhone(this); - } - } - } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { - avatarPressed = false; - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!(x >= avatarImage.getImageX() && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(42) && y >= avatarImage.getImageY() && y <= avatarImage.getImageY() + avatarImage.getImageHeight())) { - avatarPressed = false; - } - } - } else if (buttonPressed) { - if (event.getAction() == MotionEvent.ACTION_UP) { - buttonPressed = false; - playSoundEffect(SoundEffectConstants.CLICK); - if (contactUser != null && contactDelegate != null) { - contactDelegate.didClickAddButton(this, contactUser); - } - } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { - buttonPressed = false; - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!(x >= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(52) && y >= AndroidUtilities.dp(13) + namesOffset && x <= avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(92) && y <= AndroidUtilities.dp(52) + namesOffset)) { - buttonPressed = false; - } - } - } - } - if (!result) { - result = super.onTouchEvent(event); - } - - return result; - } - - @Override - public void setMessageObject(MessageObject messageObject) { - if (currentMessageObject != messageObject || isUserDataChanged()) { - - int uid = messageObject.messageOwner.media.user_id; - contactUser = MessagesController.getInstance().getUser(uid); - - drawAddButton = contactUser != null && uid != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(uid) == null; - - int maxWidth; - if (AndroidUtilities.isTablet()) { - maxWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); - } else { - maxWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); - } - maxWidth -= AndroidUtilities.dp(58 + (drawAddButton ? 42 : 0)); - - if (contactUser != null) { - if (contactUser.photo != null) { - currentPhoto = contactUser.photo.photo_small; - } else { - currentPhoto = null; - } - avatarDrawable.setInfo(contactUser); - } else { - currentPhoto = null; - avatarDrawable.setInfo(uid, null, null, false); - } - avatarImage.setImage(currentPhoto, "50_50", avatarDrawable, null, false); - - String phone = messageObject.messageOwner.media.phone_number; - if (phone != null && phone.length() != 0) { - if (!phone.startsWith("+")) { - phone = "+" + phone; - } - phone = PhoneFormat.getInstance().format(phone); - } else { - phone = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); - } - - String currentNameString = ContactsController.formatName(messageObject.messageOwner.media.first_name, messageObject.messageOwner.media.last_name); - if (currentNameString.length() == 0) { - currentNameString = phone; - } - int nameWidth = Math.min((int) Math.ceil(namePaint.measureText(currentNameString)), maxWidth); - if (maxWidth < 0) { - maxWidth = AndroidUtilities.dp(100); - } - - CharSequence stringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth, TextUtils.TruncateAt.END); - nameLayout = new StaticLayout(stringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - if (nameLayout.getLineCount() > 0) { - nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0)); - } else { - nameWidth = 0; - } - - - int phoneWidth = Math.min((int) Math.ceil(phonePaint.measureText(phone)), maxWidth); - stringFinal = TextUtils.ellipsize(phone.replace("\n", " "), phonePaint, phoneWidth, TextUtils.TruncateAt.END); - phoneLayout = new StaticLayout(stringFinal, phonePaint, phoneWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - if (phoneLayout.getLineCount() > 0) { - phoneWidth = (int)Math.ceil(phoneLayout.getLineWidth(0)); - } else { - phoneWidth = 0; - } - - namesWidth = Math.max(nameWidth, phoneWidth); - backgroundWidth = AndroidUtilities.dp(77 + (drawAddButton ? 42 : 0)) + namesWidth; - availableTimeWidth = backgroundWidth - AndroidUtilities.dp(29); - - super.setMessageObject(messageObject); - } - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(75) + namesOffset); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - - if (currentMessageObject == null) { - return; - } - - int x; - - if (currentMessageObject.isOutOwner()) { - x = layoutWidth - backgroundWidth + AndroidUtilities.dp(8); - } else { - if (isChat && currentMessageObject.isFromUser()) { - x = AndroidUtilities.dp(69); - } else { - x = AndroidUtilities.dp(16); - } - } - avatarImage.setImageCoords(x, AndroidUtilities.dp(9) + namesOffset, AndroidUtilities.dp(42), AndroidUtilities.dp(42)); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - if (currentMessageObject == null) { - return; - } - - avatarImage.draw(canvas); - - if (nameLayout != null) { - canvas.save(); - canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(10) + namesOffset); - namePaint.setColor(AvatarDrawable.getColorForId(currentMessageObject.messageOwner.media.user_id)); - nameLayout.draw(canvas); - canvas.restore(); - } - if (phoneLayout != null) { - canvas.save(); - canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(31) + namesOffset); - phoneLayout.draw(canvas); - canvas.restore(); - } - - if (drawAddButton) { - Drawable addContactDrawable; - if (currentMessageObject.isOutOwner()) { - addContactDrawable = addContactDrawableOut; - } else { - addContactDrawable = addContactDrawableIn; - } - setDrawableBounds(addContactDrawable, avatarImage.getImageX() + namesWidth + AndroidUtilities.dp(78), AndroidUtilities.dp(13) + namesOffset); - addContactDrawable.draw(canvas); - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatLoadingCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatLoadingCell.java index 021f74f06..a0f48780e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatLoadingCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatLoadingCell.java @@ -14,9 +14,9 @@ import android.widget.FrameLayout; import android.widget.ProgressBar; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.R; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.ActionBar.Theme; public class ChatLoadingCell extends FrameLayout { @@ -26,7 +26,8 @@ public class ChatLoadingCell extends FrameLayout { super(context); frameLayout = new FrameLayout(context); - frameLayout.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_loader2 : R.drawable.system_loader1); + frameLayout.setBackgroundResource(R.drawable.system_loader); + frameLayout.getBackground().setColorFilter(Theme.colorFilter); addView(frameLayout, LayoutHelper.createFrame(36, 36, Gravity.CENTER)); ProgressBar progressBar = new ProgressBar(context); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 978d7c064..f2cc715b0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -11,6 +11,7 @@ package org.telegram.ui.Cells; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; @@ -27,7 +28,10 @@ import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.ViewStructure; +import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ContactsController; +import org.telegram.messenger.Emoji; import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.LocaleController; @@ -35,54 +39,88 @@ import org.telegram.messenger.MediaController; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.MessageObject; +import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; import org.telegram.messenger.SendMessagesHelper; +import org.telegram.messenger.Utilities; +import org.telegram.messenger.browser.Browser; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.LinkPath; import org.telegram.ui.Components.RadialProgress; -import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.Components.SeekBar; +import org.telegram.ui.Components.SeekBarWaveform; import org.telegram.ui.Components.StaticLayoutEx; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.URLSpanBotCommand; import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.PhotoViewer; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; -public class ChatMessageCell extends ChatBaseCell { +public class ChatMessageCell extends ChatBaseCell implements SeekBar.SeekBarDelegate { + + private final static int DOCUMENT_ATTACH_TYPE_NONE = 0; + private final static int DOCUMENT_ATTACH_TYPE_DOCUMENT = 1; + private final static int DOCUMENT_ATTACH_TYPE_GIF = 2; + private final static int DOCUMENT_ATTACH_TYPE_AUDIO = 3; + private final static int DOCUMENT_ATTACH_TYPE_VIDEO = 4; + private final static int DOCUMENT_ATTACH_TYPE_MUSIC = 5; + private final static int DOCUMENT_ATTACH_TYPE_STICKER = 6; + + private class BotButton { + private int x; + private int y; + private int width; + private int height; + private StaticLayout caption; + private TLRPC.KeyboardButton button; + private int angle; + private float progressAlpha; + private long lastUpdateTime; + } private int textX; private int textY; private int totalHeight; + private int keyboardHeight; private int linkBlockNum; + private Rect scrollRect = new Rect(); + private int lastVisibleBlockNum; private int firstVisibleBlockNum; private int totalVisibleBlocksCount; + private boolean needNewVisiblePart; private RadialProgress radialProgress; private ImageReceiver photoImage; + private AvatarDrawable avatarDrawable; + + private boolean disallowLongPress; private boolean isSmallImage; private boolean drawImageButton; - private int isDocument; + private int documentAttachType; + private TLRPC.Document documentAttach; private boolean drawPhotoImage; private boolean hasLinkPreview; private int linkPreviewHeight; - private boolean isInstagram; + private int mediaOffsetY; private int descriptionY; private int durationWidth; private int descriptionX; private int titleX; private int authorX; - private StaticLayout sitecaptionLayout; + private StaticLayout siteCaptionLayout; private StaticLayout titleLayout; private StaticLayout descriptionLayout; private StaticLayout durationLayout; private StaticLayout authorLayout; - private static TextPaint durationPaint; private StaticLayout captionLayout; private int captionX; @@ -92,7 +130,6 @@ public class ChatMessageCell extends ChatBaseCell { private StaticLayout infoLayout; private int infoWidth; - private int infoOffset; private String currentUrl; @@ -103,71 +140,164 @@ public class ChatMessageCell extends ChatBaseCell { private int buttonState; private int buttonPressed; private int otherX; + private int otherY; private boolean imagePressed; private boolean otherPressed; private boolean photoNotSet; private RectF deleteProgressRect = new RectF(); + private RectF rect = new RectF(); private TLRPC.PhotoSize currentPhotoObject; private TLRPC.PhotoSize currentPhotoObjectThumb; private String currentPhotoFilter; private String currentPhotoFilterThumb; private boolean cancelLoading; - private static Drawable igvideoDrawable; private static TextPaint infoPaint; - private static TextPaint namePaint; + private static TextPaint docNamePaint; private static Paint docBackPaint; private static Paint deleteProgressPaint; + private static Paint botProgressPaint; private static TextPaint locationTitlePaint; private static TextPaint locationAddressPaint; private static Paint urlPaint; + private static TextPaint durationPaint; private ClickableSpan pressedLink; private int pressedLinkType; private boolean linkPreviewPressed; - private LinkPath urlPath = new LinkPath(); + private ArrayList urlPathCache = new ArrayList<>(); + private ArrayList urlPath = new ArrayList<>(); + //private LinkPath urlPath = new LinkPath(); + + private boolean useSeekBarWaweform; + private SeekBar seekBar; + private SeekBarWaveform seekBarWaveform; + private int seekBarX; + private int seekBarY; + + private StaticLayout timeLayout; + private String lastTimeString; + private int timeWidthAudio; + private int timeAudioX; + + private static TextPaint audioTimePaint; + private static TextPaint audioTitlePaint; + private static TextPaint audioPerformerPaint; + private static TextPaint botButtonPaint; + private static TextPaint contactNamePaint; + private static TextPaint contactPhonePaint; + + private StaticLayout songLayout; + private int songX; + + private StaticLayout performerLayout; + private int performerX; + + private ArrayList botButtons = new ArrayList<>(); + private HashMap botButtonsByData = new HashMap<>(); + private int widthForButtons; + private int pressedBotButton; public ChatMessageCell(Context context) { super(context); + avatarDrawable = new AvatarDrawable(); photoImage = new ImageReceiver(this); radialProgress = new RadialProgress(this); + seekBar = new SeekBar(context); + seekBar.setDelegate(this); + seekBarWaveform = new SeekBarWaveform(context); + seekBarWaveform.setDelegate(this); + seekBarWaveform.setParentView(this); if (infoPaint == null) { infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); infoPaint.setTextSize(AndroidUtilities.dp(12)); - namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - namePaint.setColor(0xff212121); - namePaint.setTextSize(AndroidUtilities.dp(16)); + docNamePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + docNamePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + docNamePaint.setTextSize(AndroidUtilities.dp(15)); - docBackPaint = new Paint(); + docBackPaint = new Paint(Paint.ANTI_ALIAS_FLAG); deleteProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - deleteProgressPaint.setColor(0xffe4e2e0); + deleteProgressPaint.setColor(Theme.MSG_SECRET_TIME_TEXT_COLOR); + + botProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + botProgressPaint.setColor(Theme.MSG_BOT_PROGRESS_COLOR); + botProgressPaint.setStrokeCap(Paint.Cap.ROUND); + botProgressPaint.setStyle(Paint.Style.STROKE); + botProgressPaint.setStrokeWidth(AndroidUtilities.dp(2)); locationTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - locationTitlePaint.setTextSize(AndroidUtilities.dp(14)); + locationTitlePaint.setTextSize(AndroidUtilities.dp(15)); locationTitlePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); locationAddressPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - locationAddressPaint.setTextSize(AndroidUtilities.dp(14)); - - igvideoDrawable = getResources().getDrawable(R.drawable.igvideo); + locationAddressPaint.setTextSize(AndroidUtilities.dp(13)); urlPaint = new Paint(); - urlPaint.setColor(0x33316f9f); + urlPaint.setColor(Theme.MSG_LINK_SELECT_BACKGROUND_COLOR); + + audioTimePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); + audioTimePaint.setTextSize(AndroidUtilities.dp(12)); + + audioTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + audioTitlePaint.setTextSize(AndroidUtilities.dp(16)); + audioTitlePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + + audioPerformerPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + audioPerformerPaint.setTextSize(AndroidUtilities.dp(15)); + + botButtonPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + botButtonPaint.setTextSize(AndroidUtilities.dp(15)); + botButtonPaint.setColor(Theme.MSG_BOT_BUTTON_TEXT_COLOR); + botButtonPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + + contactNamePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + contactNamePaint.setTextSize(AndroidUtilities.dp(15)); + contactNamePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + + contactPhonePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + contactPhonePaint.setTextSize(AndroidUtilities.dp(13)); + + durationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + durationPaint.setTextSize(AndroidUtilities.dp(12)); + durationPaint.setColor(Theme.MSG_WEB_PREVIEW_DURATION_TEXT_COLOR); } + + radialProgress = new RadialProgress(this); } private void resetPressedLink(int type) { if (pressedLink == null || pressedLinkType != type && type != -1) { return; } + resetUrlPaths(); pressedLink = null; pressedLinkType = -1; invalidate(); } + private void resetUrlPaths() { + if (urlPath.isEmpty()) { + return; + } + urlPathCache.addAll(urlPath); + urlPath.clear(); + } + + private LinkPath obtainNewUrlPath() { + LinkPath linkPath; + if (!urlPathCache.isEmpty()) { + linkPath = urlPathCache.get(0); + urlPathCache.remove(0); + } else { + linkPath = new LinkPath(); + } + urlPath.add(linkPath); + return linkPath; + } + private boolean checkTextBlockMotionEvent(MotionEvent event) { if (currentMessageObject.type != 0 || currentMessageObject.textLayoutBlocks == null || currentMessageObject.textLayoutBlocks.isEmpty() || !(currentMessageObject.messageText instanceof Spannable)) { return false; @@ -204,10 +334,47 @@ public class ChatMessageCell extends ChatBaseCell { pressedLink = link[0]; linkBlockNum = blockNum; pressedLinkType = 1; + resetUrlPaths(); try { + LinkPath path = obtainNewUrlPath(); int start = buffer.getSpanStart(pressedLink) - block.charactersOffset; - urlPath.setCurrentLayout(block.textLayout, start); - block.textLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink) - block.charactersOffset, urlPath); + int end = buffer.getSpanEnd(pressedLink); + int length = block.textLayout.getText().length(); + path.setCurrentLayout(block.textLayout, start, 0); + block.textLayout.getSelectionPath(start, end - block.charactersOffset, path); + if (end >= block.charactersOffset + length) { + for (int a = blockNum + 1; a < currentMessageObject.textLayoutBlocks.size(); a++) { + MessageObject.TextLayoutBlock nextBlock = currentMessageObject.textLayoutBlocks.get(a); + length = nextBlock.textLayout.getText().length(); + ClickableSpan[] nextLink = buffer.getSpans(nextBlock.charactersOffset, nextBlock.charactersOffset, ClickableSpan.class); + if (nextLink == null || nextLink.length == 0 || nextLink[0] != pressedLink) { + break; + } + path = obtainNewUrlPath(); + path.setCurrentLayout(nextBlock.textLayout, 0, nextBlock.height); + nextBlock.textLayout.getSelectionPath(0, end - nextBlock.charactersOffset, path); + if (end < block.charactersOffset + length - 1) { + break; + } + } + } + if (start < 0) { + for (int a = blockNum - 1; a >= 0; a--) { + MessageObject.TextLayoutBlock nextBlock = currentMessageObject.textLayoutBlocks.get(a); + length = nextBlock.textLayout.getText().length(); + ClickableSpan[] nextLink = buffer.getSpans(nextBlock.charactersOffset + length - 1, nextBlock.charactersOffset + length - 1, ClickableSpan.class); + if (nextLink == null || nextLink.length == 0 || nextLink[0] != pressedLink) { + break; + } + path = obtainNewUrlPath(); + start = buffer.getSpanStart(pressedLink) - nextBlock.charactersOffset; + path.setCurrentLayout(nextBlock.textLayout, start, -nextBlock.height); + nextBlock.textLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink) - nextBlock.charactersOffset, path); + if (start >= 0) { + break; + } + } + } } catch (Exception e) { FileLog.e("tmessages", e); } @@ -232,7 +399,7 @@ public class ChatMessageCell extends ChatBaseCell { return false; } - private boolean chechCaptionMotionEvent(MotionEvent event) { + private boolean checkCaptionMotionEvent(MotionEvent event) { if (!(currentMessageObject.caption instanceof Spannable) || captionLayout == null) { return false; } @@ -258,10 +425,12 @@ public class ChatMessageCell extends ChatBaseCell { if (!ignore) { pressedLink = link[0]; pressedLinkType = 3; + resetUrlPaths(); try { + LinkPath path = obtainNewUrlPath(); int start = buffer.getSpanStart(pressedLink); - urlPath.setCurrentLayout(captionLayout, start); - captionLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), urlPath); + path.setCurrentLayout(captionLayout, start, 0); + captionLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), path); } catch (Exception e) { FileLog.e("tmessages", e); } @@ -293,11 +462,11 @@ public class ChatMessageCell extends ChatBaseCell { if (x >= textX && x <= textX + backgroundWidth && y >= textY + currentMessageObject.textHeight && y <= textY + currentMessageObject.textHeight + linkPreviewHeight + AndroidUtilities.dp(8)) { if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (isDocument != 1 && drawPhotoImage && photoImage.isInsideImage(x, y)) { + if (documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT && drawPhotoImage && photoImage.isInsideImage(x, y)) { if (drawImageButton && buttonState != -1 && x >= buttonX && x <= buttonX + AndroidUtilities.dp(48) && y >= buttonY && y <= buttonY + AndroidUtilities.dp(48)) { buttonPressed = 1; return true; - } else if (isDocument == 2 && buttonState == -1 && MediaController.getInstance().canAutoplayGifs()) { + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && buttonState == -1 && MediaController.getInstance().canAutoplayGifs()) { linkPreviewPressed = false; return false; } else { @@ -323,10 +492,12 @@ public class ChatMessageCell extends ChatBaseCell { pressedLink = link[0]; linkBlockNum = -10; pressedLinkType = 2; + resetUrlPaths(); try { + LinkPath path = obtainNewUrlPath(); int start = buffer.getSpanStart(pressedLink); - urlPath.setCurrentLayout(descriptionLayout, start); - descriptionLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), urlPath); + path.setCurrentLayout(descriptionLayout, start, 0); + descriptionLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), path); } catch (Exception e) { FileLog.e("tmessages", e); } @@ -338,62 +509,93 @@ public class ChatMessageCell extends ChatBaseCell { FileLog.e("tmessages", e); } } - } else if (event.getAction() == MotionEvent.ACTION_UP && (pressedLinkType == 2 || buttonPressed != 0 || linkPreviewPressed)) { - if (buttonPressed != 0) { - if (event.getAction() == MotionEvent.ACTION_UP) { - buttonPressed = 0; - playSoundEffect(SoundEffectConstants.CLICK); - didPressedButton(false); - invalidate(); - } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { - buttonPressed = 0; - invalidate(); - } - } else if (pressedLink != null) { - if (pressedLink instanceof URLSpan) { - AndroidUtilities.openUrl(getContext(), ((URLSpan) pressedLink).getURL()); + } else if (event.getAction() == MotionEvent.ACTION_UP) { + if (pressedLinkType == 2 || buttonPressed != 0 || linkPreviewPressed) { + if (buttonPressed != 0) { + if (event.getAction() == MotionEvent.ACTION_UP) { + buttonPressed = 0; + playSoundEffect(SoundEffectConstants.CLICK); + didPressedButton(false); + invalidate(); + } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { + buttonPressed = 0; + invalidate(); + } + } else if (pressedLink != null) { + if (pressedLink instanceof URLSpan) { + Browser.openUrl(getContext(), ((URLSpan) pressedLink).getURL()); + } else { + pressedLink.onClick(this); + } + resetPressedLink(2); } else { - pressedLink.onClick(this); - } - } else { - if (drawImageButton) { - if (isDocument == 2) { - if (buttonState == -1) { - buttonState = 2; - currentMessageObject.audioProgress = 1; - photoImage.setAllowStartAnimation(false); - photoImage.stopAnimation(); - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - invalidate(); - playSoundEffect(SoundEffectConstants.CLICK); - } else if (buttonState == 2 || buttonState == 0) { - didPressedButton(false); + if (drawImageButton) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) { + if (buttonState == -1) { + buttonState = 2; + currentMessageObject.audioProgress = 1; + photoImage.setAllowStartAnimation(false); + photoImage.stopAnimation(); + radialProgress.setBackground(getDrawableForCurrentState(), false, false); + invalidate(); + playSoundEffect(SoundEffectConstants.CLICK); + } else if (buttonState == 2 || buttonState == 0) { + didPressedButton(false); + playSoundEffect(SoundEffectConstants.CLICK); + } + } else if (buttonState == -1) { + delegate.didPressedImage(this); playSoundEffect(SoundEffectConstants.CLICK); } - } else if (buttonState == -1) { - delegate.didPressedImage(this); - playSoundEffect(SoundEffectConstants.CLICK); - } - } else { - TLRPC.WebPage webPage = currentMessageObject.messageOwner.media.webpage; - if (Build.VERSION.SDK_INT >= 16 && webPage.embed_url != null && webPage.embed_url.length() != 0) { - delegate.needOpenWebView(webPage.embed_url, webPage.site_name, webPage.url, webPage.embed_width, webPage.embed_height); } else { - AndroidUtilities.openUrl(getContext(), webPage.url); + TLRPC.WebPage webPage = currentMessageObject.messageOwner.media.webpage; + if (webPage != null) { + if (Build.VERSION.SDK_INT >= 16 && webPage.embed_url != null && webPage.embed_url.length() != 0) { + delegate.needOpenWebView(webPage.embed_url, webPage.site_name, webPage.description, webPage.url, webPage.embed_width, webPage.embed_height); + } else { + Browser.openUrl(getContext(), webPage.url); + } + } } + resetPressedLink(2); + return true; } + } else { resetPressedLink(2); - return true; } - } else { - resetPressedLink(2); } } return false; } + + private boolean checkOtherButtonMotionEvent(MotionEvent event) { + if (documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT && currentMessageObject.type != 12 && documentAttachType != DOCUMENT_ATTACH_TYPE_MUSIC && documentAttachType != DOCUMENT_ATTACH_TYPE_VIDEO) { + return false; + } + + int x = (int) event.getX(); + int y = (int) event.getY(); + + boolean result = false; + if (event.getAction() == MotionEvent.ACTION_DOWN) { + if (x >= otherX - AndroidUtilities.dp(20) && x <= otherX + AndroidUtilities.dp(20) && y >= otherY - AndroidUtilities.dp(4) && y <= otherY + AndroidUtilities.dp(30)) { + otherPressed = true; + result = true; + } + } else { + if (event.getAction() == MotionEvent.ACTION_UP) { + if (otherPressed) { + otherPressed = false; + playSoundEffect(SoundEffectConstants.CLICK); + delegate.didPressedOther(this); + } + } + } + return result; + } private boolean checkPhotoImageMotionEvent(MotionEvent event) { - if (!drawPhotoImage) { + if (!drawPhotoImage && documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT) { return false; } @@ -407,19 +609,23 @@ public class ChatMessageCell extends ChatBaseCell { invalidate(); result = true; } else { - if (isDocument == 1) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(50) && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) { imagePressed = true; result = true; - } else if (x >= otherX - AndroidUtilities.dp(20) && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) { - otherPressed = true; - result = true; } - } else if (currentMessageObject.type != 13) { + } else if (currentMessageObject.type != 13 || currentMessageObject.getInputStickerSet() != null) { if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) { imagePressed = true; result = true; } + if (currentMessageObject.type == 12) { + TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id); + if (user == null) { + imagePressed = false; + result = false; + } + } } } if (imagePressed && currentMessageObject.isSecretPhoto()) { @@ -443,12 +649,107 @@ public class ChatMessageCell extends ChatBaseCell { if (buttonState == -1 || buttonState == 2 || buttonState == 3) { playSoundEffect(SoundEffectConstants.CLICK); didClickedImage(); + } else if (buttonState == 0 && documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { + playSoundEffect(SoundEffectConstants.CLICK); + didPressedButton(false); } invalidate(); - } else if (otherPressed) { - otherPressed = false; + } + } + } + return result; + } + + private boolean checkAudioMotionEvent(MotionEvent event) { + if (documentAttachType != DOCUMENT_ATTACH_TYPE_AUDIO && documentAttachType != DOCUMENT_ATTACH_TYPE_MUSIC) { + return false; + } + + int x = (int) event.getX(); + int y = (int) event.getY(); + boolean result; + if (useSeekBarWaweform) { + result = seekBarWaveform.onTouch(event.getAction(), event.getX() - seekBarX - AndroidUtilities.dp(13), event.getY() - seekBarY); + } else { + result = seekBar.onTouch(event.getAction(), event.getX() - seekBarX, event.getY() - seekBarY); + } + if (result) { + if (!useSeekBarWaweform && event.getAction() == MotionEvent.ACTION_DOWN) { + getParent().requestDisallowInterceptTouchEvent(true); + } else if (useSeekBarWaweform && !seekBarWaveform.isStartDraging() && event.getAction() == MotionEvent.ACTION_UP) { + didPressedButton(true); + } + disallowLongPress = true; + invalidate(); + } else { + int side = AndroidUtilities.dp(36); + boolean area; + if (buttonState == 0 || buttonState == 1 || buttonState == 2) { + area = x >= buttonX - AndroidUtilities.dp(12) && x <= buttonX - AndroidUtilities.dp(12) + backgroundWidth && y >= namesOffset + mediaOffsetY && y <= layoutHeight; + } else { + area = x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side; + } + if (event.getAction() == MotionEvent.ACTION_DOWN) { + if (area) { + buttonPressed = 1; + invalidate(); + result = true; + radialProgress.swapBackground(getDrawableForCurrentState()); + } + } else if (buttonPressed != 0) { + if (event.getAction() == MotionEvent.ACTION_UP) { + buttonPressed = 0; playSoundEffect(SoundEffectConstants.CLICK); - delegate.didPressedOther(this); + didPressedButton(true); + invalidate(); + } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { + buttonPressed = 0; + invalidate(); + } else if (event.getAction() == MotionEvent.ACTION_MOVE) { + if (!area) { + buttonPressed = 0; + invalidate(); + } + } + radialProgress.swapBackground(getDrawableForCurrentState()); + } + } + return result; + } + + private boolean checkBotButtonMotionEvent(MotionEvent event) { + if (botButtons.isEmpty()) { + return false; + } + + int x = (int) event.getX(); + int y = (int) event.getY(); + + boolean result = false; + if (event.getAction() == MotionEvent.ACTION_DOWN) { + int addX; + if (currentMessageObject.isOutOwner()) { + addX = getMeasuredWidth() - widthForButtons - AndroidUtilities.dp(10); + } else { + addX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(mediaBackground ? 1 : 7); + } + for (int a = 0; a < botButtons.size(); a++) { + BotButton button = botButtons.get(a); + int y2 = button.y + layoutHeight - AndroidUtilities.dp(2); + if (x >= button.x + addX && x <= button.x + addX + button.width && y >= y2 && y <= y2 + button.height) { + pressedBotButton = a; + invalidate(); + result = true; + break; + } + } + } else { + if (event.getAction() == MotionEvent.ACTION_UP) { + if (pressedBotButton != -1) { + playSoundEffect(SoundEffectConstants.CLICK); + delegate.didPressedBotButton(this, botButtons.get(pressedBotButton).button); + pressedBotButton = -1; + invalidate(); } } } @@ -461,34 +762,114 @@ public class ChatMessageCell extends ChatBaseCell { return super.onTouchEvent(event); } + disallowLongPress = false; + boolean result = checkTextBlockMotionEvent(event); + if (!result) { + result = checkOtherButtonMotionEvent(event); + } if (!result) { result = checkLinkPreviewMotionEvent(event); } if (!result) { - result = chechCaptionMotionEvent(event); + result = checkCaptionMotionEvent(event); + } + if (!result) { + result = checkAudioMotionEvent(event); } if (!result) { result = checkPhotoImageMotionEvent(event); } + if (!result) { + result = checkBotButtonMotionEvent(event); + } if (event.getAction() == MotionEvent.ACTION_CANCEL) { buttonPressed = 0; + pressedBotButton = -1; linkPreviewPressed = false; otherPressed = false; imagePressed = false; result = false; resetPressedLink(-1); } - if (result && event.getAction() == MotionEvent.ACTION_DOWN) { + if (!disallowLongPress && result && event.getAction() == MotionEvent.ACTION_DOWN) { startCheckLongPress(); } if (event.getAction() != MotionEvent.ACTION_DOWN && event.getAction() != MotionEvent.ACTION_MOVE) { cancelCheckLongPress(); } + return result || super.onTouchEvent(event); } + public void updateAudioProgress() { + if (currentMessageObject == null || documentAttach == null) { + return; + } + + if (useSeekBarWaweform) { + if (!seekBarWaveform.isDragging()) { + seekBarWaveform.setProgress(currentMessageObject.audioProgress); + } + } else { + if (!seekBar.isDragging()) { + seekBar.setProgress(currentMessageObject.audioProgress); + } + } + + int duration = 0; + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO) { + if (!MediaController.getInstance().isPlayingAudio(currentMessageObject)) { + for (int a = 0; a < documentAttach.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + duration = attribute.duration; + break; + } + } + } else { + duration = currentMessageObject.audioProgressSec; + } + String timeString = String.format("%02d:%02d", duration / 60, duration % 60); + if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { + lastTimeString = timeString; + timeWidthAudio = (int) Math.ceil(audioTimePaint.measureText(timeString)); + timeLayout = new StaticLayout(timeString, audioTimePaint, timeWidthAudio, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + } + } else { + int currentProgress = 0; + for (int a = 0; a < documentAttach.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + duration = attribute.duration; + break; + } + } + if (MediaController.getInstance().isPlayingAudio(currentMessageObject)) { + currentProgress = currentMessageObject.audioProgressSec; + } + String timeString = String.format("%d:%02d / %d:%02d", currentProgress / 60, currentProgress % 60, duration / 60, duration % 60); + if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { + lastTimeString = timeString; + int timeWidth = (int) Math.ceil(audioTimePaint.measureText(timeString)); + timeLayout = new StaticLayout(timeString, audioTimePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + } + } + invalidate(); + } + + public void downloadAudioIfNeed() { + if (documentAttachType != DOCUMENT_ATTACH_TYPE_AUDIO || documentAttach.size >= 1024 * 1024 * 5) { + return; + } + if (buttonState == 2) { + FileLoader.getInstance().loadFile(documentAttach, true, false); + buttonState = 4; + radialProgress.setBackground(getDrawableForCurrentState(), false, false); + } + } + public void setVisiblePart(int position, int height) { if (currentMessageObject == null || currentMessageObject.textLayoutBlocks == null) { return; @@ -562,12 +943,15 @@ public class ChatMessageCell extends ChatBaseCell { } private void didClickedImage() { - if (currentMessageObject.type == 1) { + if (currentMessageObject.type == 1 || currentMessageObject.type == 13) { if (buttonState == -1) { delegate.didPressedImage(this); } else if (buttonState == 0) { didPressedButton(false); } + } else if (currentMessageObject.type == 12) { + TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id); + delegate.didPressedUserAvatar(this, user); } else if (currentMessageObject.type == 8) { if (buttonState == -1) { buttonState = 2; @@ -579,23 +963,23 @@ public class ChatMessageCell extends ChatBaseCell { } else if (buttonState == 2 || buttonState == 0) { didPressedButton(false); } - } else if (currentMessageObject.type == 3) { + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) { if (buttonState == 0 || buttonState == 3) { didPressedButton(false); } } else if (currentMessageObject.type == 4) { delegate.didPressedImage(this); - } else if (isDocument == 1) { + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { if (buttonState == -1) { delegate.didPressedImage(this); } - } else if (isDocument == 2) { + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) { if (buttonState == -1) { TLRPC.WebPage webPage = currentMessageObject.messageOwner.media.webpage; if (Build.VERSION.SDK_INT >= 16 && webPage.embed_url != null && webPage.embed_url.length() != 0) { - delegate.needOpenWebView(webPage.embed_url, webPage.site_name, webPage.url, webPage.embed_width, webPage.embed_height); + delegate.needOpenWebView(webPage.embed_url, webPage.site_name, webPage.description, webPage.url, webPage.embed_width, webPage.embed_height); } else { - AndroidUtilities.openUrl(getContext(), webPage.url); + Browser.openUrl(getContext(), webPage.url); } } } @@ -609,7 +993,6 @@ public class ChatMessageCell extends ChatBaseCell { if (str == null) { return; } - infoOffset = 0; infoWidth = (int) Math.ceil(infoPaint.measureText(str)); CharSequence str2 = TextUtils.ellipsize(str, infoPaint, infoWidth, TextUtils.TruncateAt.END); infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); @@ -617,7 +1000,7 @@ public class ChatMessageCell extends ChatBaseCell { } private boolean isPhotoDataChanged(MessageObject object) { - if (object.type == 0) { + if (object.type == 0 || object.type == 14) { return false; } if (object.type == 4) { @@ -626,7 +1009,7 @@ public class ChatMessageCell extends ChatBaseCell { } double lat = object.messageOwner.media.geo.lat; double lon = object.messageOwner.media.geo._long; - String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); + String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:mid|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); if (!url.equals(currentUrl)) { return true; } @@ -634,7 +1017,7 @@ public class ChatMessageCell extends ChatBaseCell { return true; } else if (currentMessageObject != null && photoNotSet) { File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); - if (cacheFile.exists()) { + if (cacheFile.exists()) { //TODO return true; } } @@ -643,11 +1026,7 @@ public class ChatMessageCell extends ChatBaseCell { @Override protected boolean isUserDataChanged() { - if (!hasLinkPreview && currentMessageObject.messageOwner.media != null && currentMessageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage) { - return true; - } - //suppress warning - return super.isUserDataChanged(); + return currentMessageObject != null && (!hasLinkPreview && currentMessageObject.messageOwner.media != null && currentMessageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage || super.isUserDataChanged()); } @Override @@ -665,7 +1044,11 @@ public class ChatMessageCell extends ChatBaseCell { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - if (photoImage.onAttachedToWindow()) { + if (drawPhotoImage) { + if (photoImage.onAttachedToWindow()) { + updateButtonState(false); + } + } else { updateButtonState(false); } } @@ -683,6 +1066,11 @@ public class ChatMessageCell extends ChatBaseCell { return; } resetPressedLink(-1); + if (buttonPressed != 0 || pressedBotButton != -1) { + buttonPressed = 0; + pressedBotButton = -1; + invalidate(); + } super.onLongPress(); } @@ -692,6 +1080,11 @@ public class ChatMessageCell extends ChatBaseCell { if (radialProgress.swapBackground(getDrawableForCurrentState())) { invalidate(); } + if (useSeekBarWaweform) { + seekBarWaveform.setSelected(isDrawSelectedBackground()); + } else { + seekBar.setSelected(isDrawSelectedBackground()); + } } @Override @@ -700,6 +1093,11 @@ public class ChatMessageCell extends ChatBaseCell { if (radialProgress.swapBackground(getDrawableForCurrentState())) { invalidate(); } + if (useSeekBarWaweform) { + seekBarWaveform.setSelected(isDrawSelectedBackground()); + } else { + seekBar.setSelected(isDrawSelectedBackground()); + } } @Override @@ -708,96 +1106,213 @@ public class ChatMessageCell extends ChatBaseCell { if (radialProgress.swapBackground(getDrawableForCurrentState())) { invalidate(); } + if (useSeekBarWaweform) { + seekBarWaveform.setSelected(isDrawSelectedBackground()); + } else { + seekBar.setSelected(isDrawSelectedBackground()); + } + } + + @Override + public void onSeekBarDrag(float progress) { + if (currentMessageObject == null) { + return; + } + currentMessageObject.audioProgress = progress; + MediaController.getInstance().seekToProgress(currentMessageObject, progress); + } + + private void updateWaveform() { + if (currentMessageObject == null || documentAttachType != DOCUMENT_ATTACH_TYPE_AUDIO) { + return; + } + for (int a = 0; a < documentAttach.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + if (attribute.waveform == null || attribute.waveform.length == 0) { + MediaController.getInstance().generateWaveform(currentMessageObject); + } + useSeekBarWaweform = attribute.waveform != null; + seekBarWaveform.setWaveform(attribute.waveform); + break; + } + } } private int createDocumentLayout(int maxWidth, MessageObject messageObject) { - TLRPC.Document document = null; - if (messageObject.type == 9) { - document = messageObject.messageOwner.media.document; - } else if (messageObject.type == 0) { - document = messageObject.messageOwner.media.webpage.document; + if (messageObject.type == 0) { + documentAttach = messageObject.messageOwner.media.webpage.document; + } else { + documentAttach = messageObject.messageOwner.media.document; } - if (document == null) { + if (documentAttach == null) { return 0; } - isDocument = 1; - String name = FileLoader.getDocumentFileName(document); - if (name == null || name.length() == 0) { - name = LocaleController.getString("AttachDocument", R.string.AttachDocument); - } - captionLayout = StaticLayoutEx.createStaticLayout(name, namePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.MIDDLE, maxWidth, 3); - nameOffsetX = Integer.MIN_VALUE; - int captionWidth; - if (captionLayout != null && captionLayout.getLineCount() > 0) { - int maxLineWidth = 0; - for (int a = 0; a < captionLayout.getLineCount(); a++) { - maxLineWidth = Math.max(maxLineWidth, (int) Math.ceil(captionLayout.getLineWidth(a))); - nameOffsetX = Math.max(nameOffsetX, (int) Math.ceil(-captionLayout.getLineLeft(a))); + if (MessageObject.isVoiceDocument(documentAttach)) { + documentAttachType = DOCUMENT_ATTACH_TYPE_AUDIO; + int duration = 0; + for (int a = 0; a < documentAttach.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + duration = attribute.duration; + break; + } } - captionWidth = Math.min(maxWidth, maxLineWidth); - } else { - captionWidth = maxWidth; - nameOffsetX = 0; - } - - String str = AndroidUtilities.formatFileSize(document.size) + " " + FileLoader.getDocumentExtension(document); - infoWidth = Math.min(maxWidth, (int) Math.ceil(infoPaint.measureText(str))); - CharSequence str2 = TextUtils.ellipsize(str, infoPaint, infoWidth, TextUtils.TruncateAt.END); - try { - if (infoWidth < 0) { - infoWidth = AndroidUtilities.dp(10); + availableTimeWidth = maxWidth - AndroidUtilities.dp(76 + 18) - (int) Math.ceil(audioTimePaint.measureText("00:00")); + measureTime(messageObject); + int minSize = AndroidUtilities.dp(40 + 14 + 20 + 90 + 10) + timeWidth; + if (!hasLinkPreview) { + backgroundWidth = Math.min(maxWidth, minSize + duration * AndroidUtilities.dp(10)); } - infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); - photoImage.setNeedsQualityThumb(true); - photoImage.setShouldGenerateQualityThumb(true); - photoImage.setParentMessageObject(messageObject); - if (currentPhotoObject != null) { - currentPhotoFilter = "86_86_b"; - photoImage.setImage(null, null, null, null, currentPhotoObject.location, currentPhotoFilter, 0, null, true); + if (messageObject.isOutOwner()) { + seekBarWaveform.setColors(Theme.MSG_OUT_VOICE_SEEKBAR_COLOR, Theme.MSG_OUT_VOICE_SEEKBAR_FILL_COLOR, Theme.MSG_OUT_VOICE_SEEKBAR_SELECTED_COLOR); + seekBar.setColors(Theme.MSG_OUT_AUDIO_SEEKBAR_COLOR, Theme.MSG_OUT_AUDIO_SEEKBAR_FILL_COLOR, Theme.MSG_OUT_AUDIO_SEEKBAR_SELECTED_COLOR); + } else { + seekBarWaveform.setColors(Theme.MSG_IN_VOICE_SEEKBAR_COLOR, Theme.MSG_IN_VOICE_SEEKBAR_FILL_COLOR, Theme.MSG_IN_VOICE_SEEKBAR_SELECTED_COLOR); + seekBar.setColors(Theme.MSG_IN_AUDIO_SEEKBAR_COLOR, Theme.MSG_IN_AUDIO_SEEKBAR_FILL_COLOR, Theme.MSG_IN_AUDIO_SEEKBAR_SELECTED_COLOR); + } + seekBarWaveform.setMessageObject(messageObject); + return 0; + } else if (MessageObject.isMusicDocument(documentAttach)) { + documentAttachType = DOCUMENT_ATTACH_TYPE_MUSIC; + if (messageObject.isOutOwner()) { + seekBar.setColors(Theme.MSG_OUT_AUDIO_SEEKBAR_COLOR, Theme.MSG_OUT_AUDIO_SEEKBAR_FILL_COLOR, Theme.MSG_OUT_AUDIO_SEEKBAR_SELECTED_COLOR); + } else { + seekBar.setColors(Theme.MSG_IN_AUDIO_SEEKBAR_COLOR, Theme.MSG_IN_AUDIO_SEEKBAR_FILL_COLOR, Theme.MSG_IN_AUDIO_SEEKBAR_SELECTED_COLOR); + } + + maxWidth = maxWidth - AndroidUtilities.dp(86); + + CharSequence stringFinal = TextUtils.ellipsize(messageObject.getMusicTitle().replace('\n', ' '), audioTitlePaint, maxWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); + songLayout = new StaticLayout(stringFinal, audioTitlePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + if (songLayout.getLineCount() > 0) { + songX = -(int) Math.ceil(songLayout.getLineLeft(0)); + } + + stringFinal = TextUtils.ellipsize(messageObject.getMusicAuthor().replace('\n', ' '), audioPerformerPaint, maxWidth, TextUtils.TruncateAt.END); + performerLayout = new StaticLayout(stringFinal, audioPerformerPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + if (performerLayout.getLineCount() > 0) { + performerX = -(int) Math.ceil(performerLayout.getLineLeft(0)); + } + + int duration = 0; + for (int a = 0; a < documentAttach.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + duration = attribute.duration; + break; + } + } + int durationWidth = (int) Math.ceil(audioTimePaint.measureText(String.format("%d:%02d / %d:%02d", duration / 60, duration % 60, duration / 60, duration % 60))); + availableTimeWidth = backgroundWidth - AndroidUtilities.dp(76 + 18) - durationWidth; + return durationWidth; + } else if (MessageObject.isVideoDocument(documentAttach)) { + documentAttachType = DOCUMENT_ATTACH_TYPE_VIDEO; + int duration = 0; + for (int a = 0; a < documentAttach.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeVideo) { + duration = attribute.duration; + break; + } + } + int minutes = duration / 60; + int seconds = duration - minutes * 60; + String str = String.format("%d:%02d, %s", minutes, seconds, AndroidUtilities.formatFileSize(documentAttach.size)); + infoWidth = (int) Math.ceil(infoPaint.measureText(str)); + infoLayout = new StaticLayout(str, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + + return 0; } else { - photoImage.setImageBitmap((BitmapDrawable) null); + drawPhotoImage = documentAttach.mime_type != null && documentAttach.mime_type.toLowerCase().startsWith("image/") || documentAttach.thumb instanceof TLRPC.TL_photoSize && !(documentAttach.thumb.location instanceof TLRPC.TL_fileLocationUnavailable); + if (!drawPhotoImage) { + maxWidth += AndroidUtilities.dp(30); + } + documentAttachType = DOCUMENT_ATTACH_TYPE_DOCUMENT; + String name = FileLoader.getDocumentFileName(documentAttach); + if (name == null || name.length() == 0) { + name = LocaleController.getString("AttachDocument", R.string.AttachDocument); + } + captionLayout = StaticLayoutEx.createStaticLayout(name, docNamePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.MIDDLE, maxWidth, drawPhotoImage ? 2 : 1); + nameOffsetX = Integer.MIN_VALUE; + int captionWidth; + if (captionLayout != null && captionLayout.getLineCount() > 0) { + int maxLineWidth = 0; + for (int a = 0; a < captionLayout.getLineCount(); a++) { + maxLineWidth = Math.max(maxLineWidth, (int) Math.ceil(captionLayout.getLineWidth(a))); + nameOffsetX = Math.max(nameOffsetX, (int) Math.ceil(-captionLayout.getLineLeft(a))); + } + captionWidth = Math.min(maxWidth, maxLineWidth); + } else { + captionWidth = maxWidth; + nameOffsetX = 0; + } + + String str = AndroidUtilities.formatFileSize(documentAttach.size) + " " + FileLoader.getDocumentExtension(documentAttach); + infoWidth = Math.min(maxWidth, (int) Math.ceil(infoPaint.measureText(str))); + CharSequence str2 = TextUtils.ellipsize(str, infoPaint, infoWidth, TextUtils.TruncateAt.END); + try { + if (infoWidth < 0) { + infoWidth = AndroidUtilities.dp(10); + } + infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + if (drawPhotoImage) { + currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); + photoImage.setNeedsQualityThumb(true); + photoImage.setShouldGenerateQualityThumb(true); + photoImage.setParentMessageObject(messageObject); + if (currentPhotoObject != null) { + currentPhotoFilter = "86_86_b"; + photoImage.setImage(null, null, null, null, currentPhotoObject.location, currentPhotoFilter, 0, null, true); + } else { + photoImage.setImageBitmap((BitmapDrawable) null); + } + } + return captionWidth; } - return captionWidth; } private void calcBackgroundWidth(int maxWidth, int timeMore, int maxChildWidth) { if (hasLinkPreview || maxWidth - currentMessageObject.lastLineWidth < timeMore) { totalHeight += AndroidUtilities.dp(14); - backgroundWidth = Math.max(maxChildWidth, currentMessageObject.lastLineWidth) + AndroidUtilities.dp(29); - backgroundWidth = Math.max(backgroundWidth, timeWidth + AndroidUtilities.dp(29)); + backgroundWidth = Math.max(maxChildWidth, currentMessageObject.lastLineWidth) + AndroidUtilities.dp(31); + backgroundWidth = Math.max(backgroundWidth, timeWidth + AndroidUtilities.dp(31)); } else { int diff = maxChildWidth - currentMessageObject.lastLineWidth; if (diff >= 0 && diff <= timeMore) { - backgroundWidth = maxChildWidth + timeMore - diff + AndroidUtilities.dp(29); + backgroundWidth = maxChildWidth + timeMore - diff + AndroidUtilities.dp(31); } else { - backgroundWidth = Math.max(maxChildWidth, currentMessageObject.lastLineWidth + timeMore) + AndroidUtilities.dp(29); + backgroundWidth = Math.max(maxChildWidth, currentMessageObject.lastLineWidth + timeMore) + AndroidUtilities.dp(31); } } } @Override public void setMessageObject(MessageObject messageObject) { - boolean messageChanged = currentMessageObject != messageObject; + boolean messageIdChanged = currentMessageObject == null || currentMessageObject.getId() != messageObject.getId(); + boolean messageChanged = currentMessageObject != messageObject || messageObject.forceUpdate; boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet); if (messageChanged || dataChanged || isPhotoDataChanged(messageObject)) { resetPressedLink(-1); + messageObject.forceUpdate = false; drawPhotoImage = false; hasLinkPreview = false; linkPreviewPressed = false; buttonPressed = 0; + pressedBotButton = -1; linkPreviewHeight = 0; - infoOffset = 0; - isInstagram = false; + mediaOffsetY = 0; durationLayout = null; - isDocument = 0; + documentAttachType = DOCUMENT_ATTACH_TYPE_NONE; + documentAttach = null; descriptionLayout = null; titleLayout = null; - sitecaptionLayout = null; + siteCaptionLayout = null; authorLayout = null; captionLayout = null; drawImageButton = false; @@ -811,15 +1326,23 @@ public class ChatMessageCell extends ChatBaseCell { photoNotSet = false; drawBackground = true; drawName = false; + useSeekBarWaweform = false; + drawForwardedName = false; + mediaBackground = false; + availableTimeWidth = 0; + photoImage.setNeedsQualityThumb(false); + photoImage.setShouldGenerateQualityThumb(false); + photoImage.setParentMessageObject(null); + photoImage.setRoundRadius(AndroidUtilities.dp(3)); if (messageChanged) { firstVisibleBlockNum = 0; lastVisibleBlockNum = 0; + needNewVisiblePart = true; } if (messageObject.type == 0) { drawForwardedName = true; - mediaBackground = false; int maxWidth; if (AndroidUtilities.isTablet()) { @@ -839,9 +1362,26 @@ public class ChatMessageCell extends ChatBaseCell { drawName = messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isOutOwner(); } } + measureTime(messageObject); + int timeMore = timeWidth + AndroidUtilities.dp(6); + if (messageObject.isOutOwner()) { + timeMore += AndroidUtilities.dp(20.5f); + } + hasLinkPreview = messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage; backgroundWidth = maxWidth; - availableTimeWidth = backgroundWidth - AndroidUtilities.dp(29); + if (hasLinkPreview || maxWidth - messageObject.lastLineWidth < timeMore) { + backgroundWidth = Math.max(backgroundWidth, messageObject.lastLineWidth) + AndroidUtilities.dp(31); + backgroundWidth = Math.max(backgroundWidth, timeWidth + AndroidUtilities.dp(31)); + } else { + int diff = backgroundWidth - messageObject.lastLineWidth; + if (diff >= 0 && diff <= timeMore) { + backgroundWidth = backgroundWidth + timeMore - diff + AndroidUtilities.dp(31); + } else { + backgroundWidth = Math.max(backgroundWidth, messageObject.lastLineWidth + timeMore) + AndroidUtilities.dp(31); + } + } + availableTimeWidth = backgroundWidth - AndroidUtilities.dp(31); super.setMessageObject(messageObject); @@ -854,12 +1394,7 @@ public class ChatMessageCell extends ChatBaseCell { maxChildWidth = Math.max(maxChildWidth, replyTextWidth); int maxWebWidth = 0; - int timeMore = timeWidth + AndroidUtilities.dp(6); - if (messageObject.isOutOwner()) { - timeMore += AndroidUtilities.dp(20.5f); - } - - if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage) { + if (hasLinkPreview) { int linkPreviewMaxWidth; if (AndroidUtilities.isTablet()) { if (messageObject.isFromUser() && (currentMessageObject.messageOwner.to_id.channel_id != 0 || currentMessageObject.messageOwner.to_id.chat_id != 0) && !currentMessageObject.isOut()) { @@ -889,8 +1424,6 @@ public class ChatMessageCell extends ChatBaseCell { int additionalHeight = 0; linkPreviewMaxWidth -= additinalWidth; - hasLinkPreview = true; - if (currentMessageObject.photoThumbs == null && webPage.photo != null) { currentMessageObject.generateThumbs(true); } @@ -900,12 +1433,12 @@ public class ChatMessageCell extends ChatBaseCell { if (webPage.site_name != null) { try { int width = (int) Math.ceil(replyNamePaint.measureText(webPage.site_name)); - sitecaptionLayout = new StaticLayout(webPage.site_name, replyNamePaint, Math.min(width, linkPreviewMaxWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - int height = sitecaptionLayout.getLineBottom(sitecaptionLayout.getLineCount() - 1); + siteCaptionLayout = new StaticLayout(webPage.site_name, replyNamePaint, Math.min(width, linkPreviewMaxWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + int height = siteCaptionLayout.getLineBottom(siteCaptionLayout.getLineCount() - 1); linkPreviewHeight += height; totalHeight += height; additionalHeight += height; - width = sitecaptionLayout.getWidth(); + width = siteCaptionLayout.getWidth(); maxChildWidth = Math.max(maxChildWidth, width + additinalWidth); maxWebWidth = Math.max(maxWebWidth, width + additinalWidth); } catch (Exception e) { @@ -926,7 +1459,7 @@ public class ChatMessageCell extends ChatBaseCell { titleLayout = StaticLayoutEx.createStaticLayout(webPage.title, replyNamePaint, linkPreviewMaxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, AndroidUtilities.dp(1), false, TextUtils.TruncateAt.END, linkPreviewMaxWidth, 4); } else { restLines = restLinesCount; - titleLayout = generateStaticLayout(webPage.title, replyNamePaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 2), restLinesCount, 4); + titleLayout = generateStaticLayout(webPage.title, replyNamePaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 4), restLinesCount, 4); restLinesCount -= titleLayout.getLineCount(); } int height = titleLayout.getLineBottom(titleLayout.getLineCount() - 1); @@ -949,7 +1482,7 @@ public class ChatMessageCell extends ChatBaseCell { width = (int) Math.ceil(titleLayout.getLineWidth(a)); } if (a < restLines || lineLeft != 0 && isSmallImage) { - width += AndroidUtilities.dp(48 + 2); + width += AndroidUtilities.dp(48 + 4); } maxChildWidth = Math.max(maxChildWidth, width + additinalWidth); maxWebWidth = Math.max(maxWebWidth, width + additinalWidth); @@ -970,7 +1503,7 @@ public class ChatMessageCell extends ChatBaseCell { if (restLinesCount == 3 && (!isSmallImage || webPage.description == null)) { authorLayout = new StaticLayout(webPage.author, replyNamePaint, linkPreviewMaxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } else { - authorLayout = generateStaticLayout(webPage.author, replyNamePaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 2), restLinesCount, 1); + authorLayout = generateStaticLayout(webPage.author, replyNamePaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 4), restLinesCount, 1); restLinesCount -= authorLayout.getLineCount(); } int height = authorLayout.getLineBottom(authorLayout.getLineCount() - 1); @@ -1005,7 +1538,7 @@ public class ChatMessageCell extends ChatBaseCell { descriptionLayout = StaticLayoutEx.createStaticLayout(messageObject.linkDescription, replyTextPaint, linkPreviewMaxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, AndroidUtilities.dp(1), false, TextUtils.TruncateAt.END, linkPreviewMaxWidth, 6); } else { restLines = restLinesCount; - descriptionLayout = generateStaticLayout(messageObject.linkDescription, replyTextPaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 2), restLinesCount, 6); + descriptionLayout = generateStaticLayout(messageObject.linkDescription, replyTextPaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 4), restLinesCount, 6); } int height = descriptionLayout.getLineBottom(descriptionLayout.getLineCount() - 1); linkPreviewHeight += height; @@ -1037,7 +1570,7 @@ public class ChatMessageCell extends ChatBaseCell { width = hasRTL ? descriptionLayout.getWidth() : (int) Math.ceil(descriptionLayout.getLineWidth(a)); } if (a < restLines || restLines != 0 && lineLeft != 0 && isSmallImage) { - width += AndroidUtilities.dp(48 + 2); + width += AndroidUtilities.dp(48 + 4); } if (maxWebWidth < width + additinalWidth) { if (titleIsRTL) { @@ -1071,15 +1604,16 @@ public class ChatMessageCell extends ChatBaseCell { int maxPhotoWidth = smallImage ? AndroidUtilities.dp(48) : linkPreviewMaxWidth; if (webPage.document != null) { - if (MessageObject.isGifDocument(webPage.document)){ + TLRPC.Document document = webPage.document; + if (MessageObject.isGifDocument(document)){ if (!MediaController.getInstance().canAutoplayGifs()) { messageObject.audioProgress = 1; } photoImage.setAllowStartAnimation(messageObject.audioProgress != 1); - currentPhotoObject = webPage.document.thumb; + currentPhotoObject = document.thumb; if (currentPhotoObject != null && (currentPhotoObject.w == 0 || currentPhotoObject.h == 0)) { - for (int a = 0; a < webPage.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = webPage.document.attributes.get(a); + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeImageSize || attribute instanceof TLRPC.TL_documentAttributeVideo) { currentPhotoObject.w = attribute.w; currentPhotoObject.h = attribute.h; @@ -1087,23 +1621,85 @@ public class ChatMessageCell extends ChatBaseCell { } } if (currentPhotoObject.w == 0 || currentPhotoObject.h == 0) { - currentPhotoObject.w = currentPhotoObject.h = AndroidUtilities.dp(100); + currentPhotoObject.w = currentPhotoObject.h = AndroidUtilities.dp(150); } } - isDocument = 2; + documentAttachType = DOCUMENT_ATTACH_TYPE_GIF; + } else if (MessageObject.isVideoDocument(document)) { + currentPhotoObject = document.thumb; + if (currentPhotoObject != null && (currentPhotoObject.w == 0 || currentPhotoObject.h == 0)) { + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeVideo) { + currentPhotoObject.w = attribute.w; + currentPhotoObject.h = attribute.h; + break; + } + } + if (currentPhotoObject.w == 0 || currentPhotoObject.h == 0) { + currentPhotoObject.w = currentPhotoObject.h = AndroidUtilities.dp(150); + } + } + createDocumentLayout(0, messageObject); + } else if (MessageObject.isStickerDocument(document)) { + currentPhotoObject = document.thumb; + if (currentPhotoObject != null && (currentPhotoObject.w == 0 || currentPhotoObject.h == 0)) { + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeImageSize) { + currentPhotoObject.w = attribute.w; + currentPhotoObject.h = attribute.h; + break; + } + } + if (currentPhotoObject.w == 0 || currentPhotoObject.h == 0) { + currentPhotoObject.w = currentPhotoObject.h = AndroidUtilities.dp(150); + } + } + documentAttach = document; + documentAttachType = DOCUMENT_ATTACH_TYPE_STICKER; } else { - TLRPC.Document document = messageObject.messageOwner.media.webpage.document; - if (!MessageObject.isStickerDocument(document) && !MessageObject.isVoiceDocument(document)) { - calcBackgroundWidth(maxWidth, timeMore, maxChildWidth); + calcBackgroundWidth(maxWidth, timeMore, maxChildWidth); + if (!MessageObject.isStickerDocument(document)) { if (backgroundWidth < maxWidth + AndroidUtilities.dp(20)) { backgroundWidth = maxWidth + AndroidUtilities.dp(20); } - createDocumentLayout(backgroundWidth - AndroidUtilities.dp(86 + 24 + 58), messageObject); - drawPhotoImage = true; - drawImageButton = true; - photoImage.setImageCoords(0, totalHeight + namesOffset, AndroidUtilities.dp(86), AndroidUtilities.dp(86)); - totalHeight += AndroidUtilities.dp(86); - linkPreviewHeight += AndroidUtilities.dp(86); + if (MessageObject.isVoiceDocument(document)) { + createDocumentLayout(backgroundWidth - AndroidUtilities.dp(10), messageObject); + mediaOffsetY = currentMessageObject.textHeight + AndroidUtilities.dp(8) + linkPreviewHeight; + totalHeight += AndroidUtilities.dp(30 + 14); + linkPreviewHeight += AndroidUtilities.dp(44); + calcBackgroundWidth(maxWidth, timeMore, maxChildWidth); + } else if (MessageObject.isMusicDocument(document)) { + int durationWidth = createDocumentLayout(backgroundWidth - AndroidUtilities.dp(10), messageObject); + mediaOffsetY = currentMessageObject.textHeight + AndroidUtilities.dp(8) + linkPreviewHeight; + totalHeight += AndroidUtilities.dp(42 + 14); + linkPreviewHeight += AndroidUtilities.dp(56); + + maxWidth = maxWidth - AndroidUtilities.dp(86); + maxChildWidth = Math.max(maxChildWidth, durationWidth + additinalWidth + AndroidUtilities.dp(86 + 8)); + if (songLayout != null && songLayout.getLineCount() > 0) { + maxChildWidth = (int) Math.max(maxChildWidth, songLayout.getLineWidth(0) + additinalWidth + AndroidUtilities.dp(86)); + } + if (performerLayout != null && performerLayout.getLineCount() > 0) { + maxChildWidth = (int) Math.max(maxChildWidth, performerLayout.getLineWidth(0) + additinalWidth + AndroidUtilities.dp(86)); + } + + calcBackgroundWidth(maxWidth, timeMore, maxChildWidth); + } else { + createDocumentLayout(backgroundWidth - AndroidUtilities.dp(86 + 24 + 58), messageObject); + drawImageButton = true; + if (drawPhotoImage) { + totalHeight += AndroidUtilities.dp(86 + 14); + linkPreviewHeight += AndroidUtilities.dp(86); + photoImage.setImageCoords(0, totalHeight + namesOffset, AndroidUtilities.dp(86), AndroidUtilities.dp(86)); + } else { + mediaOffsetY = currentMessageObject.textHeight + AndroidUtilities.dp(8) + linkPreviewHeight; + photoImage.setImageCoords(0, totalHeight + namesOffset - AndroidUtilities.dp(14), AndroidUtilities.dp(56), AndroidUtilities.dp(56)); + totalHeight += AndroidUtilities.dp(50 + 14); + linkPreviewHeight += AndroidUtilities.dp(50); + } + } } } } else if (webPage.photo != null) { @@ -1114,14 +1710,22 @@ public class ChatMessageCell extends ChatBaseCell { } } - if (isDocument != 1) { + if (documentAttachType != DOCUMENT_ATTACH_TYPE_MUSIC && documentAttachType != DOCUMENT_ATTACH_TYPE_AUDIO && documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT) { if (currentPhotoObject != null) { - drawImageButton = webPage.type != null && (webPage.type.equals("photo") || webPage.type.equals("document") || webPage.type.equals("gif")); + drawImageButton = webPage.type != null && (webPage.type.equals("photo") || webPage.type.equals("document") && documentAttachType != DOCUMENT_ATTACH_TYPE_STICKER || webPage.type.equals("gif") || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO); if (linkPreviewHeight != 0) { linkPreviewHeight += AndroidUtilities.dp(2); totalHeight += AndroidUtilities.dp(2); } + if (documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) { + if (AndroidUtilities.isTablet()) { + maxPhotoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.5f); + } else { + maxPhotoWidth = (int) (AndroidUtilities.displaySize.x * 0.5f); + } + } + maxChildWidth = Math.max(maxChildWidth, maxPhotoWidth + additinalWidth); currentPhotoObject.size = -1; if (currentPhotoObjectThumb != null) { @@ -1135,10 +1739,10 @@ public class ChatMessageCell extends ChatBaseCell { } else { width = currentPhotoObject.w; height = currentPhotoObject.h; - float scale = width / (float) maxPhotoWidth; + float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2)); width /= scale; height /= scale; - if (webPage.site_name == null || webPage.site_name != null && !webPage.site_name.toLowerCase().equals("instagram") && isDocument == 0) { + if (webPage.site_name == null || webPage.site_name != null && !webPage.site_name.toLowerCase().equals("instagram") && documentAttachType == 0) { if (height > AndroidUtilities.displaySize.y / 3) { height = AndroidUtilities.displaySize.y / 3; } @@ -1160,12 +1764,12 @@ public class ChatMessageCell extends ChatBaseCell { currentPhotoFilter = String.format(Locale.US, "%d_%d", width, height); currentPhotoFilterThumb = String.format(Locale.US, "%d_%d_b", width, height); - if (isDocument == 2) { - boolean photoExist = true; - File cacheFile = FileLoader.getPathToAttach(webPage.document); - if (!cacheFile.exists()) { - photoExist = false; - } + if (documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) { + photoImage.setImage(documentAttach, null, currentPhotoFilter, null, currentPhotoObject != null ? currentPhotoObject.location : null, "b1", documentAttach.size, "webp", true); + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) { + photoImage.setImage(null, null, currentPhotoObject.location, currentPhotoFilter, 0, null, false); + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) { + boolean photoExist = messageObject.mediaExists; String fileName = FileLoader.getAttachFileName(webPage.document); if (photoExist || MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_GIF) || FileLoader.getInstance().isLoadingFile(fileName)) { photoNotSet = false; @@ -1175,11 +1779,7 @@ public class ChatMessageCell extends ChatBaseCell { photoImage.setImage(null, null, currentPhotoObject.location, currentPhotoFilter, 0, null, false); } } else { - boolean photoExist = true; - File cacheFile = FileLoader.getPathToAttach(currentPhotoObject, true); - if (!cacheFile.exists()) { - photoExist = false; - } + boolean photoExist = messageObject.mediaExists; String fileName = FileLoader.getAttachFileName(currentPhotoObject); if (photoExist || MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO) || FileLoader.getInstance().isLoadingFile(fileName)) { photoNotSet = false; @@ -1195,18 +1795,7 @@ public class ChatMessageCell extends ChatBaseCell { } drawPhotoImage = true; - if (webPage.site_name != null) { - if (webPage.site_name.toLowerCase().equals("instagram") && webPage.type != null && webPage.type.equals("video")) { - isInstagram = true; - } - } - if (webPage.type != null && webPage.type.equals("video") && webPage.duration != 0) { - if (durationPaint == null) { - durationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - durationPaint.setTextSize(AndroidUtilities.dp(12)); - durationPaint.setColor(0xffffffff); - } int minutes = webPage.duration / 60; int seconds = webPage.duration - minutes * 60; String str = String.format("%d:%02d", minutes, seconds); @@ -1224,10 +1813,90 @@ public class ChatMessageCell extends ChatBaseCell { photoImage.setImageBitmap((Drawable) null); calcBackgroundWidth(maxWidth, timeMore, maxChildWidth); } + } else if (messageObject.type == 12) { + drawName = false; + drawForwardedName = true; + drawPhotoImage = true; + photoImage.setRoundRadius(AndroidUtilities.dp(22)); + if (AndroidUtilities.isTablet()) { + backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } else { + backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } + availableTimeWidth = backgroundWidth - AndroidUtilities.dp(31); + + int uid = messageObject.messageOwner.media.user_id; + TLRPC.User user = MessagesController.getInstance().getUser(uid); + + int maxWidth = getMaxNameWidth() - AndroidUtilities.dp(110); + if (maxWidth < 0) { + maxWidth = AndroidUtilities.dp(10); + } + + TLRPC.FileLocation currentPhoto = null; + if (user != null) { + if (user.photo != null) { + currentPhoto = user.photo.photo_small; + } + avatarDrawable.setInfo(user); + } + photoImage.setImage(currentPhoto, "50_50", user != null ? avatarDrawable : Theme.contactDrawable[messageObject.isOutOwner() ? 1 : 0], null, false); + + String phone = messageObject.messageOwner.media.phone_number; + if (phone != null && phone.length() != 0) { + if (!phone.startsWith("+")) { + phone = "+" + phone; + } + phone = PhoneFormat.getInstance().format(phone); + } else { + phone = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); + } + + CharSequence currentNameString = ContactsController.formatName(messageObject.messageOwner.media.first_name, messageObject.messageOwner.media.last_name).replace('\n', ' '); + if (currentNameString.length() == 0) { + currentNameString = phone; + } + titleLayout = new StaticLayout(TextUtils.ellipsize(currentNameString, contactNamePaint, maxWidth, TextUtils.TruncateAt.END), contactNamePaint, maxWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + captionLayout = new StaticLayout(TextUtils.ellipsize(phone.replace('\n', ' '), contactPhonePaint, maxWidth, TextUtils.TruncateAt.END), contactPhonePaint, maxWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + + super.setMessageObject(messageObject); + + if (drawForwardedName && messageObject.isForwarded()) { + namesOffset += AndroidUtilities.dp(5); + } else if (drawNameLayout && messageObject.messageOwner.reply_to_msg_id == 0) { + namesOffset += AndroidUtilities.dp(7); + } + + totalHeight = AndroidUtilities.dp(70) + namesOffset; + } else if (messageObject.type == 2) { + drawForwardedName = true; + if (AndroidUtilities.isTablet()) { + backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } else { + backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } + createDocumentLayout(backgroundWidth, messageObject); + + super.setMessageObject(messageObject); + + totalHeight = AndroidUtilities.dp(70) + namesOffset; + } else if (messageObject.type == 14) { + if (AndroidUtilities.isTablet()) { + backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } else { + backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } + + createDocumentLayout(backgroundWidth, messageObject); + + super.setMessageObject(messageObject); + + totalHeight = AndroidUtilities.dp(82) + namesOffset; } else { drawForwardedName = messageObject.messageOwner.fwd_from != null && messageObject.type != 13; mediaBackground = messageObject.type != 9; drawImageButton = true; + drawPhotoImage = true; int photoWidth = 0; int photoHeight = 0; @@ -1241,62 +1910,61 @@ public class ChatMessageCell extends ChatBaseCell { photoImage.setForcePreview(messageObject.isSecretPhoto()); if (messageObject.type == 9) { - int maxWidth; if (AndroidUtilities.isTablet()) { - maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(122 + 86 + 24); + backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); } else { - maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122 + 86 + 24); + backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); } if (checkNeedDrawShareButton(messageObject)) { - maxWidth -= AndroidUtilities.dp(20); + backgroundWidth -= AndroidUtilities.dp(20); } - int captionWidth = createDocumentLayout(maxWidth, messageObject); - photoWidth = AndroidUtilities.dp(86); - photoHeight = AndroidUtilities.dp(86); - availableTimeWidth = Math.max(captionWidth, infoWidth) + AndroidUtilities.dp(37); - backgroundWidth = photoWidth + availableTimeWidth + AndroidUtilities.dp(31); + int maxWidth = backgroundWidth - AndroidUtilities.dp(86 + 52); + + createDocumentLayout(maxWidth, messageObject); + if (drawPhotoImage) { + photoWidth = AndroidUtilities.dp(86); + photoHeight = AndroidUtilities.dp(86); + } else { + photoWidth = AndroidUtilities.dp(56); + photoHeight = AndroidUtilities.dp(56); + } + availableTimeWidth = maxWidth; } else if (messageObject.type == 4) { //geo double lat = messageObject.messageOwner.media.geo.lat; double lon = messageObject.messageOwner.media.geo._long; if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) { - int maxWidth = (AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() : Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) - AndroidUtilities.dp((isChat && !messageObject.isOutOwner() ? 102 : 40) + 86 + 24); - captionLayout = StaticLayoutEx.createStaticLayout(messageObject.messageOwner.media.title, locationTitlePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth - AndroidUtilities.dp(4), 3); + if (AndroidUtilities.isTablet()) { + backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } else { + backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(270)); + } + if (checkNeedDrawShareButton(messageObject)) { + backgroundWidth -= AndroidUtilities.dp(20); + } + int maxWidth = backgroundWidth - AndroidUtilities.dp(86 + 37); + + captionLayout = StaticLayoutEx.createStaticLayout(messageObject.messageOwner.media.title, locationTitlePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth, 2); int lineCount = captionLayout.getLineCount(); if (messageObject.messageOwner.media.address != null && messageObject.messageOwner.media.address.length() > 0) { - infoLayout = StaticLayoutEx.createStaticLayout(messageObject.messageOwner.media.address, locationAddressPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth - AndroidUtilities.dp(4), Math.min(3, 4 - lineCount)); + infoLayout = StaticLayoutEx.createStaticLayout(messageObject.messageOwner.media.address, locationAddressPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth, Math.min(3, 3 - lineCount)); } else { infoLayout = null; } mediaBackground = false; - availableTimeWidth = maxWidth - AndroidUtilities.dp(7); - measureTime(messageObject); + availableTimeWidth = maxWidth; photoWidth = AndroidUtilities.dp(86); photoHeight = AndroidUtilities.dp(86); - maxWidth = timeWidth + AndroidUtilities.dp(messageObject.isOutOwner() ? 29 : 9); - for (int a = 0; a < lineCount; a++) { - maxWidth = (int) Math.max(maxWidth, captionLayout.getLineWidth(a) + AndroidUtilities.dp(16)); - } - if (infoLayout != null) { - for (int a = 0; a < infoLayout.getLineCount(); a++) { - maxWidth = (int) Math.max(maxWidth, infoLayout.getLineWidth(a) + AndroidUtilities.dp(16)); - } - } - backgroundWidth = photoWidth + AndroidUtilities.dp(21) + maxWidth; - currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=72x72&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); + currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=72x72&maptype=roadmap&scale=%d&markers=color:red|size:mid|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); } else { availableTimeWidth = AndroidUtilities.dp(200 - 14); photoWidth = AndroidUtilities.dp(200); photoHeight = AndroidUtilities.dp(100); backgroundWidth = photoWidth + AndroidUtilities.dp(12); - currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=200x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); + currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=200x100&maptype=roadmap&scale=%d&markers=color:red|size:mid|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); } - - photoImage.setNeedsQualityThumb(false); - photoImage.setShouldGenerateQualityThumb(false); - photoImage.setParentMessageObject(null); - photoImage.setImage(currentUrl, null, messageObject.isOutOwner() ? ResourceLoader.geoOutDrawable : ResourceLoader.geoInDrawable, null, 0); + photoImage.setImage(currentUrl, null, messageObject.isOutOwner() ? Theme.geoOutDrawable : Theme.geoInDrawable, null, 0); } else if (messageObject.type == 13) { //webp drawBackground = false; for (int a = 0; a < messageObject.messageOwner.media.document.attributes.size(); a++) { @@ -1321,27 +1989,21 @@ public class ChatMessageCell extends ChatBaseCell { if (photoHeight > maxHeight) { photoWidth *= maxHeight / photoHeight; photoHeight = (int) maxHeight; - } - if (photoWidth > maxWidth) { + } else { photoHeight *= maxWidth / photoWidth; photoWidth = (int) maxWidth; } + documentAttachType = DOCUMENT_ATTACH_TYPE_STICKER; availableTimeWidth = photoWidth - AndroidUtilities.dp(14); backgroundWidth = photoWidth + AndroidUtilities.dp(12); currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); - photoImage.setNeedsQualityThumb(false); - photoImage.setShouldGenerateQualityThumb(false); - photoImage.setParentMessageObject(null); - if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() > 0) { - File f = new File(messageObject.messageOwner.attachPath); - if (f.exists()) { - photoImage.setImage(null, messageObject.messageOwner.attachPath, - String.format(Locale.US, "%d_%d", photoWidth, photoHeight), - null, - currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, - "b1", - messageObject.messageOwner.media.document.size, "webp", true); - } + if (messageObject.attachPathExists) { + photoImage.setImage(null, messageObject.messageOwner.attachPath, + String.format(Locale.US, "%d_%d", photoWidth, photoHeight), + null, + currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, + "b1", + messageObject.messageOwner.media.document.size, "webp", true); } else if (messageObject.messageOwner.media.document.id != 0) { photoImage.setImage(messageObject.messageOwner.media.document, null, String.format(Locale.US, "%d_%d", photoWidth, photoHeight), @@ -1372,26 +2034,9 @@ public class ChatMessageCell extends ChatBaseCell { if (messageObject.type == 1) { //photo updateSecretTimeText(messageObject); - photoImage.setNeedsQualityThumb(false); - photoImage.setShouldGenerateQualityThumb(false); - photoImage.setParentMessageObject(null); currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80); } else if (messageObject.type == 3) { //video - int duration = 0; - for (int a = 0; a < messageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = messageObject.messageOwner.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeVideo) { - duration = attribute.duration; - break; - } - } - int minutes = duration / 60; - int seconds = duration - minutes * 60; - String str = String.format("%d:%02d, %s", minutes, seconds, AndroidUtilities.formatFileSize(messageObject.messageOwner.media.document.size)); - infoOffset = ResourceLoader.videoIconDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4); - infoWidth = (int) Math.ceil(infoPaint.measureText(str)); - infoLayout = new StaticLayout(str, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - + createDocumentLayout(0, messageObject); photoImage.setNeedsQualityThumb(true); photoImage.setShouldGenerateQualityThumb(true); photoImage.setParentMessageObject(messageObject); @@ -1423,14 +2068,10 @@ public class ChatMessageCell extends ChatBaseCell { w = (int) (currentPhotoObject.w / scale); h = (int) (currentPhotoObject.h / scale); if (w == 0) { - if (messageObject.type == 3) { - w = infoWidth + infoOffset + AndroidUtilities.dp(16); - } else { - w = AndroidUtilities.dp(100); - } + w = AndroidUtilities.dp(150); } if (h == 0) { - h = AndroidUtilities.dp(100); + h = AndroidUtilities.dp(150); } if (h > photoHeight) { float scale2 = h; @@ -1472,7 +2113,12 @@ public class ChatMessageCell extends ChatBaseCell { if (w == 0 || h == 0) { - w = h = AndroidUtilities.dp(100); + w = h = AndroidUtilities.dp(150); + } + if (messageObject.type == 3) { + if (w < infoWidth + AndroidUtilities.dp(16 + 24)) { + w = infoWidth + AndroidUtilities.dp(16 + 24); + } } availableTimeWidth = maxPhotoWidth - AndroidUtilities.dp(14); @@ -1531,15 +2177,13 @@ public class ChatMessageCell extends ChatBaseCell { if (messageObject.type == 1) { if (currentPhotoObject != null) { - String fileName = FileLoader.getAttachFileName(currentPhotoObject); boolean photoExist = true; - File cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner); - if (!cacheFile.exists()) { - photoExist = false; - } else { + String fileName = FileLoader.getAttachFileName(currentPhotoObject); + if (messageObject.mediaExists) { MediaController.getInstance().removeLoadingFileObserver(this); + } else { + photoExist = false; } - if (photoExist || MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO) || FileLoader.getInstance().isLoadingFile(fileName)) { if (allowedToSetPhoto || ImageLoader.getInstance().getImageFromMemory(currentPhotoObject.location, null, currentPhotoFilter) != null) { allowedToSetPhoto = true; @@ -1562,26 +2206,16 @@ public class ChatMessageCell extends ChatBaseCell { } } else if (messageObject.type == 8) { String fileName = FileLoader.getAttachFileName(messageObject.messageOwner.media.document); - File cacheFile = null; - boolean localFile = false; - if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() != 0) { - cacheFile = new File(messageObject.messageOwner.attachPath); - if (!cacheFile.exists()) { - cacheFile = null; - } else { - MediaController.getInstance().removeLoadingFileObserver(this); - localFile = true; - } + int localFile = 0; + if (messageObject.attachPathExists) { + MediaController.getInstance().removeLoadingFileObserver(this); + localFile = 1; + } else if (messageObject.mediaExists) { + localFile = 2; } - if (cacheFile == null) { - cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner); - if (!cacheFile.exists()) { - cacheFile = null; - } - } - if (!messageObject.isSending() && (cacheFile != null || MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_GIF) && MessageObject.isNewGifDocument(messageObject.messageOwner.media.document) || FileLoader.getInstance().isLoadingFile(fileName))) { - if (localFile) { - photoImage.setImage(null, messageObject.isSendError() ? null : cacheFile.getAbsolutePath(), null, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, 0, null, false); + if (!messageObject.isSending() && (localFile != 0 || MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_GIF) && MessageObject.isNewGifDocument(messageObject.messageOwner.media.document) || FileLoader.getInstance().isLoadingFile(fileName))) { + if (localFile == 1) { + photoImage.setImage(null, messageObject.isSendError() ? null : messageObject.messageOwner.attachPath, null, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, 0, null, false); } else { photoImage.setImage(messageObject.messageOwner.media.document, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, messageObject.messageOwner.media.document.size, null, false); } @@ -1597,23 +2231,81 @@ public class ChatMessageCell extends ChatBaseCell { if (drawForwardedName) { namesOffset += AndroidUtilities.dp(5); - } else if (drawName && messageObject.messageOwner.reply_to_msg_id == 0) { + } else if (drawNameLayout && messageObject.messageOwner.reply_to_msg_id == 0) { namesOffset += AndroidUtilities.dp(7); } invalidate(); - drawPhotoImage = true; photoImage.setImageCoords(0, AndroidUtilities.dp(7) + namesOffset, photoWidth, photoHeight); totalHeight = photoHeight + AndroidUtilities.dp(14) + namesOffset + additionHeight; } + + botButtons.clear(); + if (messageIdChanged) { + botButtonsByData.clear(); + } + if (messageObject.messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup) { + int rows = messageObject.messageOwner.reply_markup.rows.size(); + substractBackgroundHeight = keyboardHeight = AndroidUtilities.dp(44 + 4) * rows + AndroidUtilities.dp(1); + + widthForButtons = backgroundWidth; + boolean fullWidth = false; + if (messageObject.wantedBotKeyboardWidth > widthForButtons) { + int maxButtonWidth = -AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 62 : 10); + if (AndroidUtilities.isTablet()) { + maxButtonWidth += AndroidUtilities.getMinTabletSide(); + } else { + maxButtonWidth += Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y); + } + widthForButtons = Math.max(backgroundWidth, Math.min(messageObject.wantedBotKeyboardWidth, maxButtonWidth)); + fullWidth = true; + } + + int maxButtonsWidth = 0; + for (int a = 0; a < rows; a++) { + TLRPC.TL_keyboardButtonRow row = messageObject.messageOwner.reply_markup.rows.get(a); + int buttonsCount = row.buttons.size(); + int buttonWidth = (widthForButtons - (AndroidUtilities.dp(5) * (buttonsCount - 1)) - AndroidUtilities.dp(!fullWidth && mediaBackground ? 0 : 9) - AndroidUtilities.dp(2)) / buttonsCount; + for (int b = 0; b < row.buttons.size(); b++) { + BotButton botButton = new BotButton(); + botButton.button = row.buttons.get(b); + String key = Utilities.bytesToHex(botButton.button.data); + BotButton oldButton = botButtonsByData.get(key); + if (oldButton != null) { + botButton.progressAlpha = oldButton.progressAlpha; + botButton.angle = oldButton.angle; + botButton.lastUpdateTime = oldButton.lastUpdateTime; + } else { + botButton.lastUpdateTime = System.currentTimeMillis(); + } + botButtonsByData.put(key, botButton); + botButton.x = b * (buttonWidth + AndroidUtilities.dp(5)); + botButton.y = a * AndroidUtilities.dp(44 + 4) + AndroidUtilities.dp(5); + botButton.width = buttonWidth; + botButton.height = AndroidUtilities.dp(44); + CharSequence caption = Emoji.replaceEmoji(botButton.button.text, botButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(15), false); + caption = TextUtils.ellipsize(caption, botButtonPaint, buttonWidth - AndroidUtilities.dp(10), TextUtils.TruncateAt.END); + botButton.caption = new StaticLayout(caption, botButtonPaint, buttonWidth - AndroidUtilities.dp(10), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false); + botButtons.add(botButton); + if (b == row.buttons.size() - 1) { + maxButtonsWidth = Math.max(maxButtonsWidth, botButton.x + botButton.width); + } + } + } + widthForButtons = maxButtonsWidth; + } else { + substractBackgroundHeight = 0; + keyboardHeight = 0; + } } + updateWaveform(); updateButtonState(dataChanged); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), totalHeight); + setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), totalHeight + keyboardHeight); } @Override @@ -1621,13 +2313,92 @@ public class ChatMessageCell extends ChatBaseCell { super.onLayout(changed, left, top, right, bottom); if (currentMessageObject.type == 0) { + textY = AndroidUtilities.dp(10) + namesOffset; + } + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO) { if (currentMessageObject.isOutOwner()) { - textX = layoutWidth - backgroundWidth + AndroidUtilities.dp(10); - textY = AndroidUtilities.dp(10) + namesOffset; + seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(57); + buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(14); + timeAudioX = layoutWidth - backgroundWidth + AndroidUtilities.dp(67); } else { - textX = AndroidUtilities.dp(19) + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(52) : 0); - textY = AndroidUtilities.dp(10) + namesOffset; + if (isChat && currentMessageObject.isFromUser()) { + seekBarX = AndroidUtilities.dp(114); + buttonX = AndroidUtilities.dp(71); + timeAudioX = AndroidUtilities.dp(124); + } else { + seekBarX = AndroidUtilities.dp(66); + buttonX = AndroidUtilities.dp(23); + timeAudioX = AndroidUtilities.dp(76); + } } + if (hasLinkPreview) { + seekBarX += AndroidUtilities.dp(10); + buttonX += AndroidUtilities.dp(10); + timeAudioX += AndroidUtilities.dp(10); + } + seekBarWaveform.setSize(backgroundWidth - AndroidUtilities.dp(92 + (hasLinkPreview ? 10 : 0)), AndroidUtilities.dp(30)); + seekBar.setSize(backgroundWidth - AndroidUtilities.dp(72 + (hasLinkPreview ? 10 : 0)), AndroidUtilities.dp(30)); + seekBarY = AndroidUtilities.dp(13) + namesOffset + mediaOffsetY; + buttonY = AndroidUtilities.dp(13) + namesOffset + mediaOffsetY; + radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(44), buttonY + AndroidUtilities.dp(44)); + + updateAudioProgress(); + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (currentMessageObject.isOutOwner()) { + seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(56); + buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(14); + timeAudioX = layoutWidth - backgroundWidth + AndroidUtilities.dp(67); + } else { + if (isChat && currentMessageObject.isFromUser()) { + seekBarX = AndroidUtilities.dp(113); + buttonX = AndroidUtilities.dp(71); + timeAudioX = AndroidUtilities.dp(124); + } else { + seekBarX = AndroidUtilities.dp(65); + buttonX = AndroidUtilities.dp(23); + timeAudioX = AndroidUtilities.dp(76); + } + } + if (hasLinkPreview) { + seekBarX += AndroidUtilities.dp(10); + buttonX += AndroidUtilities.dp(10); + timeAudioX += AndroidUtilities.dp(10); + } + seekBar.setSize(backgroundWidth - AndroidUtilities.dp(65 + (hasLinkPreview ? 10 : 0)), AndroidUtilities.dp(30)); + seekBarY = AndroidUtilities.dp(29) + namesOffset + mediaOffsetY; + buttonY = AndroidUtilities.dp(13) + namesOffset + mediaOffsetY; + radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(44), buttonY + AndroidUtilities.dp(44)); + + updateAudioProgress(); + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT && !drawPhotoImage) { + if (currentMessageObject.isOutOwner()) { + buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(14); + } else { + if (isChat && currentMessageObject.isFromUser()) { + buttonX = AndroidUtilities.dp(71); + } else { + buttonX = AndroidUtilities.dp(23); + } + } + if (hasLinkPreview) { + buttonX += AndroidUtilities.dp(10); + } + buttonY = AndroidUtilities.dp(13) + namesOffset + mediaOffsetY; + radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(44), buttonY + AndroidUtilities.dp(44)); + photoImage.setImageCoords(buttonX - AndroidUtilities.dp(10), buttonY - AndroidUtilities.dp(10), photoImage.getImageWidth(), photoImage.getImageHeight()); + } else if (currentMessageObject.type == 12) { + int x; + + if (currentMessageObject.isOutOwner()) { + x = layoutWidth - backgroundWidth + AndroidUtilities.dp(14); + } else { + if (isChat && currentMessageObject.isFromUser()) { + x = AndroidUtilities.dp(72); + } else { + x = AndroidUtilities.dp(23); + } + } + photoImage.setImageCoords(x, AndroidUtilities.dp(13) + namesOffset, AndroidUtilities.dp(44), AndroidUtilities.dp(44)); } else { int x; if (currentMessageObject.isOutOwner()) { @@ -1638,7 +2409,7 @@ public class ChatMessageCell extends ChatBaseCell { } } else { if (isChat && currentMessageObject.isFromUser()) { - x = AndroidUtilities.dp(67); + x = AndroidUtilities.dp(63); } else { x = AndroidUtilities.dp(15); } @@ -1652,22 +2423,29 @@ public class ChatMessageCell extends ChatBaseCell { } @Override - protected void onAfterBackgroundDraw(Canvas canvas) { + protected void drawContent(Canvas canvas) { + + if (needNewVisiblePart && currentMessageObject.type == 0) { + getLocalVisibleRect(scrollRect); + setVisiblePart(scrollRect.top, scrollRect.bottom - scrollRect.top); + needNewVisiblePart = false; + } photoImage.setPressed(isDrawSelectedBackground()); photoImage.setVisible(!PhotoViewer.getInstance().isShowingImage(currentMessageObject), false); radialProgress.setHideCurrentDrawable(false); + radialProgress.setProgressColor(Theme.MSG_MEDIA_PROGRESS_COLOR); boolean imageDrawn = false; if (currentMessageObject.type == 0 && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty()) { if (currentMessageObject.isOutOwner()) { - textX = layoutWidth - backgroundWidth + AndroidUtilities.dp(10); - textY = AndroidUtilities.dp(10) + namesOffset; + textX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); } else { - textX = AndroidUtilities.dp(19) + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(52) : 0); - textY = AndroidUtilities.dp(10) + namesOffset; + textX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(17); } + textY = AndroidUtilities.dp(10) + namesOffset; + if (firstVisibleBlockNum >= 0) { for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) { if (a >= currentMessageObject.textLayoutBlocks.size()) { @@ -1677,7 +2455,9 @@ public class ChatMessageCell extends ChatBaseCell { canvas.save(); canvas.translate(textX - (int) Math.ceil(block.textXOffset), textY + block.textYOffset); if (pressedLink != null && a == linkBlockNum) { - canvas.drawPath(urlPath, urlPaint); + for (int b = 0; b < urlPath.size(); b++) { + canvas.drawPath(urlPath.get(b), urlPaint); + } } try { block.textLayout.draw(canvas); @@ -1690,29 +2470,31 @@ public class ChatMessageCell extends ChatBaseCell { if (hasLinkPreview) { int startY = textY + currentMessageObject.textHeight + AndroidUtilities.dp(8); + int linkX = textX + AndroidUtilities.dp(1); int linkPreviewY = startY; int smallImageStartY = 0; - replyLinePaint.setColor(currentMessageObject.isOutOwner() ? 0xff8dc97a : 0xff6c9fd2); + replyLinePaint.setColor(currentMessageObject.isOutOwner() ? Theme.MSG_OUT_WEB_PREVIEW_LINE_COLOR : Theme.MSG_IN_WEB_PREVIEW_LINE_COLOR); - canvas.drawRect(textX, linkPreviewY - AndroidUtilities.dp(3), textX + AndroidUtilities.dp(2), linkPreviewY + linkPreviewHeight + AndroidUtilities.dp(3), replyLinePaint); + canvas.drawRect(linkX, linkPreviewY - AndroidUtilities.dp(3), linkX + AndroidUtilities.dp(2), linkPreviewY + linkPreviewHeight + AndroidUtilities.dp(3), replyLinePaint); - if (sitecaptionLayout != null) { - replyNamePaint.setColor(currentMessageObject.isOutOwner() ? 0xff70b15c : 0xff4b91cf); + if (siteCaptionLayout != null) { + replyNamePaint.setColor(currentMessageObject.isOutOwner() ? Theme.MSG_OUT_SITE_NAME_TEXT_COLOR : Theme.MSG_IN_SITE_NAME_TEXT_COLOR); canvas.save(); - canvas.translate(textX + AndroidUtilities.dp(10), linkPreviewY - AndroidUtilities.dp(3)); - sitecaptionLayout.draw(canvas); + canvas.translate(linkX + AndroidUtilities.dp(10), linkPreviewY - AndroidUtilities.dp(3)); + siteCaptionLayout.draw(canvas); canvas.restore(); - linkPreviewY += sitecaptionLayout.getLineBottom(sitecaptionLayout.getLineCount() - 1); + linkPreviewY += siteCaptionLayout.getLineBottom(siteCaptionLayout.getLineCount() - 1); } + replyNamePaint.setColor(Theme.MSG_TEXT_COLOR); + replyTextPaint.setColor(Theme.MSG_TEXT_COLOR); if (titleLayout != null) { if (linkPreviewY != startY) { linkPreviewY += AndroidUtilities.dp(2); } - replyNamePaint.setColor(0xff000000); smallImageStartY = linkPreviewY - AndroidUtilities.dp(1); canvas.save(); - canvas.translate(textX + AndroidUtilities.dp(10) + titleX, linkPreviewY - AndroidUtilities.dp(3)); + canvas.translate(linkX + AndroidUtilities.dp(10) + titleX, linkPreviewY - AndroidUtilities.dp(3)); titleLayout.draw(canvas); canvas.restore(); linkPreviewY += titleLayout.getLineBottom(titleLayout.getLineCount() - 1); @@ -1725,9 +2507,8 @@ public class ChatMessageCell extends ChatBaseCell { if (smallImageStartY == 0) { smallImageStartY = linkPreviewY - AndroidUtilities.dp(1); } - replyNamePaint.setColor(0xff000000); canvas.save(); - canvas.translate(textX + AndroidUtilities.dp(10) + authorX, linkPreviewY - AndroidUtilities.dp(3)); + canvas.translate(linkX + AndroidUtilities.dp(10) + authorX, linkPreviewY - AndroidUtilities.dp(3)); authorLayout.draw(canvas); canvas.restore(); linkPreviewY += authorLayout.getLineBottom(authorLayout.getLineCount() - 1); @@ -1740,12 +2521,13 @@ public class ChatMessageCell extends ChatBaseCell { if (smallImageStartY == 0) { smallImageStartY = linkPreviewY - AndroidUtilities.dp(1); } - replyTextPaint.setColor(0xff000000); descriptionY = linkPreviewY - AndroidUtilities.dp(3); canvas.save(); - canvas.translate(textX + AndroidUtilities.dp(10) + descriptionX, descriptionY); + canvas.translate(linkX + AndroidUtilities.dp(10) + descriptionX, descriptionY); if (pressedLink != null && linkBlockNum == -10) { - canvas.drawPath(urlPath, urlPaint); + for (int b = 0; b < urlPath.size(); b++) { + canvas.drawPath(urlPath.get(b), urlPaint); + } } descriptionLayout.draw(canvas); canvas.restore(); @@ -1758,9 +2540,9 @@ public class ChatMessageCell extends ChatBaseCell { } if (isSmallImage) { - photoImage.setImageCoords(textX + backgroundWidth - AndroidUtilities.dp(77), smallImageStartY, photoImage.getImageWidth(), photoImage.getImageHeight()); + photoImage.setImageCoords(linkX + backgroundWidth - AndroidUtilities.dp(81), smallImageStartY, photoImage.getImageWidth(), photoImage.getImageHeight()); } else { - photoImage.setImageCoords(textX + AndroidUtilities.dp(10), linkPreviewY, photoImage.getImageWidth(), photoImage.getImageHeight()); + photoImage.setImageCoords(linkX + AndroidUtilities.dp(10), linkPreviewY, photoImage.getImageWidth(), photoImage.getImageHeight()); if (drawImageButton) { int size = AndroidUtilities.dp(48); buttonX = (int) (photoImage.getImageX() + (photoImage.getImageWidth() - size) / 2.0f); @@ -1770,18 +2552,11 @@ public class ChatMessageCell extends ChatBaseCell { } imageDrawn = photoImage.draw(canvas); - if (isInstagram && igvideoDrawable != null) { - int x = photoImage.getImageX() + photoImage.getImageWidth() - igvideoDrawable.getIntrinsicWidth() - AndroidUtilities.dp(4); - int y = photoImage.getImageY() + AndroidUtilities.dp(4); - igvideoDrawable.setBounds(x, y, x + igvideoDrawable.getIntrinsicWidth(), y + igvideoDrawable.getIntrinsicHeight()); - igvideoDrawable.draw(canvas); - } - if (durationLayout != null) { int x = photoImage.getImageX() + photoImage.getImageWidth() - AndroidUtilities.dp(8) - durationWidth; int y = photoImage.getImageY() + photoImage.getImageHeight() - AndroidUtilities.dp(19); - ResourceLoader.mediaBackgroundDrawable.setBounds(x - AndroidUtilities.dp(4), y - AndroidUtilities.dp(1.5f), x + durationWidth + AndroidUtilities.dp(4), y + AndroidUtilities.dp(14.5f)); - ResourceLoader.mediaBackgroundDrawable.draw(canvas); + Theme.timeBackgroundDrawable.setBounds(x - AndroidUtilities.dp(4), y - AndroidUtilities.dp(1.5f), x + durationWidth + AndroidUtilities.dp(4), y + AndroidUtilities.dp(14.5f)); + Theme.timeBackgroundDrawable.draw(canvas); canvas.save(); canvas.translate(x, y); @@ -1791,24 +2566,23 @@ public class ChatMessageCell extends ChatBaseCell { } } drawTime = true; - } else { + } else if (drawPhotoImage) { imageDrawn = photoImage.draw(canvas); drawTime = photoImage.getVisible(); - radialProgress.setProgressColor(0xffffffff); } if (buttonState == -1 && currentMessageObject.isSecretPhoto()) { - int drawable = 5; + int drawable = 4; if (currentMessageObject.messageOwner.destroyTime != 0) { if (currentMessageObject.isOutOwner()) { - drawable = 7; - } else { drawable = 6; + } else { + drawable = 5; } } - setDrawableBounds(ResourceLoader.buttonStatesDrawables[drawable], buttonX, buttonY); - ResourceLoader.buttonStatesDrawables[drawable].setAlpha((int) (255 * (1.0f - radialProgress.getAlpha()))); - ResourceLoader.buttonStatesDrawables[drawable].draw(canvas); + setDrawableBounds(Theme.photoStatesDrawables[drawable][buttonPressed], buttonX, buttonY); + Theme.photoStatesDrawables[drawable][buttonPressed].setAlpha((int) (255 * (1.0f - radialProgress.getAlpha()))); + Theme.photoStatesDrawables[drawable][buttonPressed].draw(canvas); if (!currentMessageObject.isOutOwner() && currentMessageObject.messageOwner.destroyTime != 0) { long msTime = System.currentTimeMillis() + ConnectionsManager.getInstance().getTimeDifference() * 1000; float progress = Math.max(0, (long) currentMessageObject.messageOwner.destroyTime * 1000 - msTime) / (currentMessageObject.messageOwner.ttl * 1000.0f); @@ -1821,12 +2595,91 @@ public class ChatMessageCell extends ChatBaseCell { } } - if (currentMessageObject.type == 1 || currentMessageObject.type == 3) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (currentMessageObject.isOutOwner()) { + audioTitlePaint.setColor(Theme.MSG_OUT_AUDIO_TITLE_TEXT_COLOR); + audioPerformerPaint.setColor(Theme.MSG_OUT_AUDIO_PERFORMER_TEXT_COLOR); + audioTimePaint.setColor(Theme.MSG_OUT_AUDIO_DURATION_TEXT_COLOR); + radialProgress.setProgressColor(isDrawSelectedBackground() || buttonPressed != 0 ? Theme.MSG_OUT_AUDIO_SELECTED_PROGRESS_COLOR : Theme.MSG_OUT_AUDIO_PROGRESS_COLOR); + } else { + audioTitlePaint.setColor(Theme.MSG_IN_AUDIO_TITLE_TEXT_COLOR); + audioPerformerPaint.setColor(Theme.MSG_IN_AUDIO_PERFORMER_TEXT_COLOR); + audioTimePaint.setColor(Theme.MSG_IN_AUDIO_DURATION_TEXT_COLOR); + radialProgress.setProgressColor(isDrawSelectedBackground() || buttonPressed != 0 ? Theme.MSG_IN_AUDIO_SELECTED_PROGRESS_COLOR : Theme.MSG_IN_AUDIO_PROGRESS_COLOR); + } + radialProgress.draw(canvas); + + canvas.save(); + canvas.translate(timeAudioX + songX, AndroidUtilities.dp(13) + namesOffset + mediaOffsetY); + songLayout.draw(canvas); + canvas.restore(); + + canvas.save(); + if (MediaController.getInstance().isPlayingAudio(currentMessageObject)) { + canvas.translate(seekBarX, seekBarY); + seekBar.draw(canvas); + } else { + canvas.translate(timeAudioX + performerX, AndroidUtilities.dp(35) + namesOffset + mediaOffsetY); + performerLayout.draw(canvas); + } + canvas.restore(); + + canvas.save(); + canvas.translate(timeAudioX, AndroidUtilities.dp(57) + namesOffset + mediaOffsetY); + timeLayout.draw(canvas); + canvas.restore(); + + Drawable menuDrawable; + if (currentMessageObject.isOutOwner()) { + menuDrawable = Theme.docMenuDrawable[1]; + } else { + menuDrawable = Theme.docMenuDrawable[isDrawSelectedBackground() ? 2 : 0]; + } + setDrawableBounds(menuDrawable, otherX = buttonX + backgroundWidth - AndroidUtilities.dp(currentMessageObject.type == 0 ? 58 : 48), otherY = buttonY - AndroidUtilities.dp(5)); + menuDrawable.draw(canvas); + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO) { + if (currentMessageObject.isOutOwner()) { + audioTimePaint.setColor(isDrawSelectedBackground() ? Theme.MSG_OUT_AUDIO_DURATION_SELECTED_TEXT_COLOR : Theme.MSG_OUT_AUDIO_DURATION_TEXT_COLOR); + radialProgress.setProgressColor(isDrawSelectedBackground() || buttonPressed != 0 ? Theme.MSG_OUT_AUDIO_SELECTED_PROGRESS_COLOR : Theme.MSG_OUT_AUDIO_PROGRESS_COLOR); + } else { + audioTimePaint.setColor(isDrawSelectedBackground() ? Theme.MSG_IN_AUDIO_DURATION_SELECTED_TEXT_COLOR : Theme.MSG_IN_AUDIO_DURATION_TEXT_COLOR); + radialProgress.setProgressColor(isDrawSelectedBackground() || buttonPressed != 0 ? Theme.MSG_IN_AUDIO_SELECTED_PROGRESS_COLOR : Theme.MSG_IN_AUDIO_PROGRESS_COLOR); + } + radialProgress.draw(canvas); + + canvas.save(); + if (useSeekBarWaweform) { + canvas.translate(seekBarX + AndroidUtilities.dp(13), seekBarY); + seekBarWaveform.draw(canvas); + } else { + canvas.translate(seekBarX, seekBarY); + seekBar.draw(canvas); + } + canvas.restore(); + + canvas.save(); + canvas.translate(timeAudioX, AndroidUtilities.dp(44) + namesOffset + mediaOffsetY); + timeLayout.draw(canvas); + canvas.restore(); + + if (currentMessageObject.type != 0 && currentMessageObject.messageOwner.to_id.channel_id == 0 && currentMessageObject.isContentUnread()) { + docBackPaint.setColor(currentMessageObject.isOutOwner() ? Theme.MSG_OUT_VOICE_SEEKBAR_FILL_COLOR : Theme.MSG_IN_VOICE_SEEKBAR_FILL_COLOR); + canvas.drawCircle(timeAudioX + timeWidthAudio + AndroidUtilities.dp(6), AndroidUtilities.dp(51) + namesOffset + mediaOffsetY, AndroidUtilities.dp(3), docBackPaint); + } + } + if (currentMessageObject.type == 1 || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) { + setDrawableBounds(Theme.docMenuDrawable[3], otherX = photoImage.getImageX() + photoImage.getImageWidth() - AndroidUtilities.dp(14), otherY = photoImage.getImageY() + AndroidUtilities.dp(8.1f)); + Theme.docMenuDrawable[3].draw(canvas); + } + if (captionLayout != null) { canvas.save(); canvas.translate(captionX = photoImage.getImageX() + AndroidUtilities.dp(5), captionY = photoImage.getImageY() + photoImage.getImageHeight() + AndroidUtilities.dp(6)); if (pressedLink != null) { - canvas.drawPath(urlPath, urlPaint); + for (int b = 0; b < urlPath.size(); b++) { + canvas.drawPath(urlPath.get(b), urlPaint); + } } try { captionLayout.draw(canvas); @@ -1836,32 +2689,33 @@ public class ChatMessageCell extends ChatBaseCell { canvas.restore(); } if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto())) { - infoPaint.setColor(0xffffffff); - setDrawableBounds(ResourceLoader.mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(16.5f)); - ResourceLoader.mediaBackgroundDrawable.draw(canvas); - - if (currentMessageObject.type == 3) { - setDrawableBounds(ResourceLoader.videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(7.5f)); - ResourceLoader.videoIconDrawable.draw(canvas); - } + infoPaint.setColor(Theme.MSG_MEDIA_INFO_TEXT_COLOR); + setDrawableBounds(Theme.timeBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8), AndroidUtilities.dp(16.5f)); + Theme.timeBackgroundDrawable.draw(canvas); canvas.save(); - canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8) + infoOffset, photoImage.getImageY() + AndroidUtilities.dp(5.5f)); + canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(5.5f)); infoLayout.draw(canvas); canvas.restore(); } } else if (currentMessageObject.type == 4) { if (captionLayout != null) { - locationAddressPaint.setColor(currentMessageObject.isOutOwner() ? 0xff70b15c : (isDrawSelectedBackground() ? 0xff89b4c1 : 0xff999999)); + if (currentMessageObject.isOutOwner()) { + locationTitlePaint.setColor(Theme.MSG_OUT_VENUE_NAME_TEXT_COLOR); + locationAddressPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_OUT_VENUE_INFO_SELECTED_TEXT_COLOR : Theme.MSG_OUT_VENUE_INFO_TEXT_COLOR); + } else { + locationTitlePaint.setColor(Theme.MSG_IN_VENUE_NAME_TEXT_COLOR); + locationAddressPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_IN_VENUE_INFO_SELECTED_TEXT_COLOR : Theme.MSG_IN_VENUE_INFO_TEXT_COLOR); + } canvas.save(); - canvas.translate(nameOffsetX + photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(3)); + canvas.translate(nameOffsetX + photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); captionLayout.draw(canvas); canvas.restore(); if (infoLayout != null) { canvas.save(); - canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(captionLayout.getLineCount() * 16 + 5)); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + captionLayout.getLineBottom(captionLayout.getLineCount() - 1) + AndroidUtilities.dp(13)); infoLayout.draw(canvas); canvas.restore(); } @@ -1871,7 +2725,9 @@ public class ChatMessageCell extends ChatBaseCell { canvas.save(); canvas.translate(captionX = photoImage.getImageX() + AndroidUtilities.dp(5), captionY = photoImage.getImageY() + photoImage.getImageHeight() + AndroidUtilities.dp(6)); if (pressedLink != null) { - canvas.drawPath(urlPath, urlPaint); + for (int b = 0; b < urlPath.size(); b++) { + canvas.drawPath(urlPath.get(b), urlPaint); + } } try { captionLayout.draw(canvas); @@ -1880,76 +2736,103 @@ public class ChatMessageCell extends ChatBaseCell { } canvas.restore(); } - } else if (captionLayout != null) { - canvas.save(); - canvas.translate(nameOffsetX + photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); - captionLayout.draw(canvas); - canvas.restore(); - - try { - if (infoLayout != null) { - canvas.save(); - canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + captionLayout.getLineBottom(captionLayout.getLineCount() - 1) + AndroidUtilities.dp(10)); - infoLayout.draw(canvas); - canvas.restore(); - } - } catch (Exception e) { - FileLog.e("tmessages", e); + } else if (currentMessageObject.type == 12) { + contactNamePaint.setColor(currentMessageObject.isOutOwner() ? Theme.MSG_OUT_CONTACT_NAME_TEXT_COLOR : Theme.MSG_IN_CONTACT_NAME_TEXT_COLOR); + contactPhonePaint.setColor(currentMessageObject.isOutOwner() ? Theme.MSG_OUT_CONTACT_PHONE_TEXT_COLOR : Theme.MSG_IN_CONTACT_PHONE_TEXT_COLOR); + if (titleLayout != null) { + canvas.save(); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(16) + namesOffset); + titleLayout.draw(canvas); + canvas.restore(); } - } - if (isDocument == 1) { + if (captionLayout != null) { + canvas.save(); + canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(39) + namesOffset); + captionLayout.draw(canvas); + canvas.restore(); + } + Drawable menuDrawable; if (currentMessageObject.isOutOwner()) { - infoPaint.setColor(0xff70b15c); - docBackPaint.setColor(isDrawSelectedBackground() ? 0xffc5eca7 : 0xffdaf5c3); - menuDrawable = ResourceLoader.docMenuDrawable[1]; + menuDrawable = Theme.docMenuDrawable[1]; } else { - infoPaint.setColor(isDrawSelectedBackground() ? 0xff89b4c1 : 0xffa1aab3); - docBackPaint.setColor(isDrawSelectedBackground() ? 0xffcbeaf6 : 0xffebf0f5); - menuDrawable = ResourceLoader.docMenuDrawable[isDrawSelectedBackground() ? 2 : 0]; + menuDrawable = Theme.docMenuDrawable[isDrawSelectedBackground() ? 2 : 0]; + } + setDrawableBounds(menuDrawable, otherX = photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(48), otherY = photoImage.getImageY() - AndroidUtilities.dp(5)); + menuDrawable.draw(canvas); + } + if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { + Drawable menuDrawable; + if (currentMessageObject.isOutOwner()) { + docNamePaint.setColor(Theme.MSG_OUT_FILE_NAME_TEXT_COLOR); + infoPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_OUT_FILE_INFO_SELECTED_TEXT_COLOR : Theme.MSG_OUT_FILE_INFO_TEXT_COLOR); + docBackPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_OUT_FILE_BACKGROUND_SELECTED_COLOR : Theme.MSG_OUT_FILE_BACKGROUND_COLOR); + menuDrawable = Theme.docMenuDrawable[1]; + } else { + docNamePaint.setColor(Theme.MSG_IN_FILE_NAME_TEXT_COLOR); + infoPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_IN_FILE_INFO_SELECTED_TEXT_COLOR : Theme.MSG_IN_FILE_INFO_TEXT_COLOR); + docBackPaint.setColor(isDrawSelectedBackground() ? Theme.MSG_IN_FILE_BACKGROUND_SELECTED_COLOR : Theme.MSG_IN_FILE_BACKGROUND_COLOR); + menuDrawable = Theme.docMenuDrawable[isDrawSelectedBackground() ? 2 : 0]; } - if (currentMessageObject.type == 0) { - setDrawableBounds(menuDrawable, otherX = photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(58), photoImage.getImageY() + AndroidUtilities.dp(4)); + int x; + int titleY; + int subtitleY; + if (drawPhotoImage) { + if (currentMessageObject.type == 0) { + setDrawableBounds(menuDrawable, otherX = photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(56), otherY = photoImage.getImageY() + AndroidUtilities.dp(1)); + } else { + setDrawableBounds(menuDrawable, otherX = photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(40), otherY = photoImage.getImageY() + AndroidUtilities.dp(1)); + } + + x = photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10); + titleY = photoImage.getImageY() + AndroidUtilities.dp(8); + subtitleY = photoImage.getImageY() + captionLayout.getLineBottom(captionLayout.getLineCount() - 1) + AndroidUtilities.dp(13); + if (buttonState >= 0 && buttonState < 4) { + if (!imageDrawn) { + int image = buttonState; + if (buttonState == 0) { + image = currentMessageObject.isOutOwner() ? 7 : 10; + } else if (buttonState == 1) { + image = currentMessageObject.isOutOwner() ? 8 : 11; + } + radialProgress.swapBackground(Theme.photoStatesDrawables[image][isDrawSelectedBackground() || buttonPressed != 0 ? 1 : 0]); + } else { + radialProgress.swapBackground(Theme.photoStatesDrawables[buttonState][buttonPressed]); + } + } + + if (!imageDrawn) { + rect.set(photoImage.getImageX(), photoImage.getImageY(), photoImage.getImageX() + photoImage.getImageWidth(), photoImage.getImageY() + photoImage.getImageHeight()); + canvas.drawRoundRect(rect, AndroidUtilities.dp(3), AndroidUtilities.dp(3), docBackPaint); + if (currentMessageObject.isOutOwner()) { + radialProgress.setProgressColor(isDrawSelectedBackground() ? Theme.MSG_OUT_FILE_PROGRESS_SELECTED_COLOR : Theme.MSG_OUT_FILE_PROGRESS_COLOR); + } else { + radialProgress.setProgressColor(isDrawSelectedBackground() ? Theme.MSG_IN_FILE_PROGRESS_SELECTED_COLOR : Theme.MSG_IN_FILE_PROGRESS_COLOR); + } + } else { + if (buttonState == -1) { + radialProgress.setHideCurrentDrawable(true); + } + radialProgress.setProgressColor(Theme.MSG_MEDIA_PROGRESS_COLOR); + } } else { - setDrawableBounds(menuDrawable, otherX = photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(44), photoImage.getImageY() + AndroidUtilities.dp(4)); + setDrawableBounds(menuDrawable, otherX = buttonX + backgroundWidth - AndroidUtilities.dp(currentMessageObject.type == 0 ? 58 : 48), otherY = buttonY - AndroidUtilities.dp(5)); + x = buttonX + AndroidUtilities.dp(53); + titleY = buttonY + AndroidUtilities.dp(4); + subtitleY = buttonY + AndroidUtilities.dp(27); + if (currentMessageObject.isOutOwner()) { + radialProgress.setProgressColor(isDrawSelectedBackground() || buttonPressed != 0 ? Theme.MSG_OUT_AUDIO_SELECTED_PROGRESS_COLOR : Theme.MSG_OUT_AUDIO_PROGRESS_COLOR); + } else { + radialProgress.setProgressColor(isDrawSelectedBackground() || buttonPressed != 0 ? Theme.MSG_IN_AUDIO_SELECTED_PROGRESS_COLOR : Theme.MSG_IN_AUDIO_PROGRESS_COLOR); + } } menuDrawable.draw(canvas); - if (buttonState >= 0 && buttonState < 4) { - if (!imageDrawn) { - if (buttonState == 1 && !currentMessageObject.isSending()) { - radialProgress.swapBackground(ResourceLoader.buttonStatesDrawablesDoc[2][currentMessageObject.isOutOwner() ? 1 : (isDrawSelectedBackground() ? 2 : 0)]); - } else { - radialProgress.swapBackground(ResourceLoader.buttonStatesDrawablesDoc[buttonState][currentMessageObject.isOutOwner() ? 1 : (isDrawSelectedBackground() ? 2 : 0)]); - } - } else { - if (buttonState == 1 && !currentMessageObject.isSending()) { - radialProgress.swapBackground(ResourceLoader.buttonStatesDrawables[4]); - } else { - radialProgress.swapBackground(ResourceLoader.buttonStatesDrawables[buttonState]); - } - } - } - - if (!imageDrawn) { - canvas.drawRect(photoImage.getImageX(), photoImage.getImageY(), photoImage.getImageX() + photoImage.getImageWidth(), photoImage.getImageY() + photoImage.getImageHeight(), docBackPaint); - if (currentMessageObject.isOutOwner()) { - radialProgress.setProgressColor(0xff81bd72); - } else { - radialProgress.setProgressColor(isDrawSelectedBackground() ? 0xff83b2c2 : 0xffadbdcc); - } - } else { - if (buttonState == -1) { - radialProgress.setHideCurrentDrawable(true); - } - radialProgress.setProgressColor(0xffffffff); - } - try { if (captionLayout != null) { canvas.save(); - canvas.translate(nameOffsetX + photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); + canvas.translate(x + nameOffsetX, titleY); captionLayout.draw(canvas); canvas.restore(); } @@ -1960,7 +2843,7 @@ public class ChatMessageCell extends ChatBaseCell { try { if (infoLayout != null) { canvas.save(); - canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + captionLayout.getLineBottom(captionLayout.getLineCount() - 1) + AndroidUtilities.dp(10)); + canvas.translate(x, subtitleY); infoLayout.draw(canvas); canvas.restore(); } @@ -1971,84 +2854,216 @@ public class ChatMessageCell extends ChatBaseCell { if (drawImageButton) { radialProgress.draw(canvas); } + + if (!botButtons.isEmpty()) { + int addX; + if (currentMessageObject.isOutOwner()) { + addX = getMeasuredWidth() - widthForButtons - AndroidUtilities.dp(10); + } else { + addX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(mediaBackground ? 1 : 7); + } + for (int a = 0; a < botButtons.size(); a++) { + BotButton button = botButtons.get(a); + int y = button.y + layoutHeight - AndroidUtilities.dp(2); + Theme.systemDrawable.setColorFilter(a == pressedBotButton ? Theme.colorPressedFilter : Theme.colorFilter); + Theme.systemDrawable.setBounds(button.x + addX, y, button.x + addX + button.width, y + button.height); + Theme.systemDrawable.draw(canvas); + canvas.save(); + canvas.translate(button.x + addX + AndroidUtilities.dp(5), y + (AndroidUtilities.dp(44) - button.caption.getLineBottom(button.caption.getLineCount() - 1)) / 2); + button.caption.draw(canvas); + canvas.restore(); + if (button.button instanceof TLRPC.TL_keyboardButtonUrl) { + int x = button.x + button.width - AndroidUtilities.dp(3) - Theme.botLink.getIntrinsicWidth() + addX; + setDrawableBounds(Theme.botLink, x, y + AndroidUtilities.dp(3)); + Theme.botLink.draw(canvas); + } else if (button.button instanceof TLRPC.TL_keyboardButtonSwitchInline) { + int x = button.x + button.width - AndroidUtilities.dp(3) - Theme.botInline.getIntrinsicWidth() + addX; + setDrawableBounds(Theme.botInline, x, y + AndroidUtilities.dp(3)); + Theme.botInline.draw(canvas); + } else if (button.button instanceof TLRPC.TL_keyboardButtonCallback || button.button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation) { + boolean drawProgress = button.button instanceof TLRPC.TL_keyboardButtonCallback && SendMessagesHelper.getInstance().isSendingCallback(currentMessageObject, button.button) || + button.button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation && SendMessagesHelper.getInstance().isSendingCurrentLocation(currentMessageObject, button.button); + if (drawProgress || !drawProgress && button.progressAlpha != 0) { + botProgressPaint.setAlpha(Math.min(255, (int) (button.progressAlpha * 255))); + int x = button.x + button.width - AndroidUtilities.dp(9 + 3) + addX; + rect.set(x, y + AndroidUtilities.dp(4), x + AndroidUtilities.dp(8), y + AndroidUtilities.dp(8 + 4)); + canvas.drawArc(rect, button.angle, 220, false, botProgressPaint); + invalidate((int) rect.left - AndroidUtilities.dp(2), (int) rect.top - AndroidUtilities.dp(2), (int) rect.right + AndroidUtilities.dp(2), (int) rect.bottom + AndroidUtilities.dp(2)); + long newTime = System.currentTimeMillis(); + if (Math.abs(button.lastUpdateTime - System.currentTimeMillis()) < 1000) { + long delta = (newTime - button.lastUpdateTime); + float dt = 360 * delta / 2000.0f; + button.angle += dt; + button.angle -= 360 * (button.angle / 360); + if (drawProgress) { + if (button.progressAlpha < 1.0f) { + button.progressAlpha += delta / 200.0f; + if (button.progressAlpha > 1.0f) { + button.progressAlpha = 1.0f; + } + } + } else { + if (button.progressAlpha > 0.0f) { + button.progressAlpha -= delta / 200.0f; + if (button.progressAlpha < 0.0f) { + button.progressAlpha = 0.0f; + } + } + } + } + button.lastUpdateTime = newTime; + } + } + } + } } private Drawable getDrawableForCurrentState() { - if (buttonState >= 0 && buttonState < 4) { - if (isDocument == 1) { - if (buttonState == 1 && !currentMessageObject.isSending()) { - return ResourceLoader.buttonStatesDrawablesDoc[2][currentMessageObject.isOutOwner() ? 1 : (isDrawSelectedBackground() ? 2 : 0)]; - } else { - return ResourceLoader.buttonStatesDrawablesDoc[buttonState][currentMessageObject.isOutOwner() ? 1 : (isDrawSelectedBackground() ? 2 : 0)]; + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (buttonState == -1) { + return null; + } + radialProgress.setAlphaForPrevious(false); + return Theme.fileStatesDrawable[currentMessageObject.isOutOwner() ? buttonState : buttonState + 5][isDrawSelectedBackground() || buttonPressed != 0 ? 1 : 0]; + } else { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT && !drawPhotoImage) { + radialProgress.setAlphaForPrevious(false); + if (buttonState == -1) { + return Theme.fileStatesDrawable[currentMessageObject.isOutOwner() ? 3 : 8][isDrawSelectedBackground() ? 1 : 0]; + } else if (buttonState == 0) { + return Theme.fileStatesDrawable[currentMessageObject.isOutOwner() ? 2 : 7][isDrawSelectedBackground() ? 1 : 0]; + } else if (buttonState == 1) { + return Theme.fileStatesDrawable[currentMessageObject.isOutOwner() ? 4 : 9][isDrawSelectedBackground() ? 1 : 0]; } } else { - if (buttonState == 1 && (currentMessageObject.type == 0 || !currentMessageObject.isSending())) { - return ResourceLoader.buttonStatesDrawables[4]; - } else { - return ResourceLoader.buttonStatesDrawables[buttonState]; + radialProgress.setAlphaForPrevious(true); + if (buttonState >= 0 && buttonState < 4) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { + int image = buttonState; + if (buttonState == 0) { + image = currentMessageObject.isOutOwner() ? 7 : 10; + } else if (buttonState == 1) { + image = currentMessageObject.isOutOwner() ? 8 : 11; + } + return Theme.photoStatesDrawables[image][isDrawSelectedBackground() || buttonPressed != 0 ? 1 : 0]; + } else { + return Theme.photoStatesDrawables[buttonState][buttonPressed]; + } + } else if (buttonState == -1 && documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { + return Theme.photoStatesDrawables[currentMessageObject.isOutOwner() ? 9 : 12][isDrawSelectedBackground() ? 1 : 0]; } } - } else if (buttonState == -1 && isDocument == 1) { - return ResourceLoader.placeholderDocDrawable[currentMessageObject.isOutOwner() ? 1 : (isDrawSelectedBackground() ? 2 : 0)]; } return null; } @Override protected int getMaxNameWidth() { - if (currentMessageObject.type == 0) { - return super.getMaxNameWidth(); + if (documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) { + int maxWidth; + if (AndroidUtilities.isTablet()) { + if (isChat && !currentMessageObject.isOutOwner() && currentMessageObject.isFromUser()) { + maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(42); + } else { + maxWidth = AndroidUtilities.getMinTabletSide(); + } + } else { + if (isChat && !currentMessageObject.isOutOwner() && currentMessageObject.isFromUser()) { + maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(42); + } else { + maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y); + } + } + return maxWidth - backgroundWidth - AndroidUtilities.dp(57); } - return backgroundWidth - AndroidUtilities.dp(mediaBackground ? 14 : 26); + return super.getMaxNameWidth(); } public void updateButtonState(boolean animated) { String fileName = null; - File cacheFile = null; + boolean fileExists = false; if (currentMessageObject.type == 1) { if (currentPhotoObject == null) { return; } fileName = FileLoader.getAttachFileName(currentPhotoObject); - cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); - } else if (currentMessageObject.type == 8 || currentMessageObject.type == 3 || currentMessageObject.type == 9) { - if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() != 0) { - File f = new File(currentMessageObject.messageOwner.attachPath); - if (f.exists()) { - fileName = currentMessageObject.messageOwner.attachPath; - cacheFile = f; - } + fileExists = currentMessageObject.mediaExists; + } else if (currentMessageObject.type == 8 || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || currentMessageObject.type == 9 || documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (currentMessageObject.attachPathExists) { + fileName = currentMessageObject.messageOwner.attachPath; + fileExists = true; + } else if (!currentMessageObject.isSendError() || documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + fileName = currentMessageObject.getFileName(); + fileExists = currentMessageObject.mediaExists; } - if (fileName == null) { - if (!currentMessageObject.isSendError()) { - fileName = currentMessageObject.getFileName(); - cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); - } - } - } else if (isDocument != 0) { - fileName = FileLoader.getAttachFileName(currentMessageObject.messageOwner.media.webpage.document); - cacheFile = FileLoader.getPathToAttach(currentMessageObject.messageOwner.media.webpage.document); - } else { + } else if (documentAttachType != DOCUMENT_ATTACH_TYPE_NONE) { + fileName = FileLoader.getAttachFileName(documentAttach); + fileExists = currentMessageObject.mediaExists; + } else if (currentPhotoObject != null) { fileName = FileLoader.getAttachFileName(currentPhotoObject); - cacheFile = FileLoader.getPathToAttach(currentPhotoObject, true); + fileExists = currentMessageObject.mediaExists; } if (fileName == null || fileName.length() == 0) { radialProgress.setBackground(null, false, false); return; } + boolean fromBot = currentMessageObject.messageOwner.params != null && currentMessageObject.messageOwner.params.containsKey("query_id"); - if (currentMessageObject.type == 0 && isDocument != 1) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (currentMessageObject.isOut() && currentMessageObject.isSending() || currentMessageObject.isSendError() && fromBot) { + MediaController.getInstance().addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, currentMessageObject, this); + buttonState = 4; + radialProgress.setBackground(getDrawableForCurrentState(), !fromBot, animated); + if (!fromBot) { + Float progress = ImageLoader.getInstance().getFileProgress(currentMessageObject.messageOwner.attachPath); + if (progress == null && SendMessagesHelper.getInstance().isSendingMessage(currentMessageObject.getId())) { + progress = 1.0f; + } + radialProgress.setProgress(progress != null ? progress : 0, false); + } else { + radialProgress.setProgress(0, false); + } + } else { + if (fileExists) { + MediaController.getInstance().removeLoadingFileObserver(this); + boolean playing = MediaController.getInstance().isPlayingAudio(currentMessageObject); + if (!playing || playing && MediaController.getInstance().isAudioPaused()) { + buttonState = 0; + } else { + buttonState = 1; + } + radialProgress.setBackground(getDrawableForCurrentState(), false, animated); + } else { + MediaController.getInstance().addLoadingFileObserver(fileName, currentMessageObject, this); + if (!FileLoader.getInstance().isLoadingFile(fileName)) { + buttonState = 2; + radialProgress.setProgress(0, animated); + radialProgress.setBackground(getDrawableForCurrentState(), false, animated); + } else { + buttonState = 4; + Float progress = ImageLoader.getInstance().getFileProgress(fileName); + if (progress != null) { + radialProgress.setProgress(progress, animated); + } else { + radialProgress.setProgress(0, animated); + } + radialProgress.setBackground(getDrawableForCurrentState(), true, animated); + } + } + } + updateAudioProgress(); + } else if (currentMessageObject.type == 0 && documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT && documentAttachType != DOCUMENT_ATTACH_TYPE_VIDEO) { if (currentPhotoObject == null || !drawImageButton) { return; } - if (!cacheFile.exists()) { - MediaController.getInstance().addLoadingFileObserver(fileName, this); + if (!fileExists) { + MediaController.getInstance().addLoadingFileObserver(fileName, currentMessageObject, this); float setProgress = 0; boolean progressVisible = false; if (!FileLoader.getInstance().isLoadingFile(fileName)) { if (!cancelLoading && - (isDocument == 0 && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO) || - isDocument == 2 && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_GIF))) { + (documentAttachType == 0 && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO) || + documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_GIF))) { progressVisible = true; buttonState = 1; } else { @@ -2065,7 +3080,7 @@ public class ChatMessageCell extends ChatBaseCell { invalidate(); } else { MediaController.getInstance().removeLoadingFileObserver(this); - if (isDocument == 2 && !photoImage.isAllowStartAnimation()) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && !photoImage.isAllowStartAnimation()) { buttonState = 2; } else { buttonState = -1; @@ -2076,7 +3091,7 @@ public class ChatMessageCell extends ChatBaseCell { } else { if (currentMessageObject.isOut() && currentMessageObject.isSending()) { if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() > 0) { - MediaController.getInstance().addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, this); + MediaController.getInstance().addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, currentMessageObject, this); boolean needProgress = currentMessageObject.messageOwner.attachPath == null || !currentMessageObject.messageOwner.attachPath.startsWith("http"); HashMap params = currentMessageObject.messageOwner.params; if (currentMessageObject.messageOwner.message != null && params != null && (params.containsKey("url") || params.containsKey("bot"))) { @@ -2101,11 +3116,8 @@ public class ChatMessageCell extends ChatBaseCell { if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() != 0) { MediaController.getInstance().removeLoadingFileObserver(this); } - if (cacheFile.exists() && cacheFile.length() == 0) { - cacheFile.delete(); - } - if (!cacheFile.exists()) { - MediaController.getInstance().addLoadingFileObserver(fileName, this); + if (!fileExists) { + MediaController.getInstance().addLoadingFileObserver(fileName, currentMessageObject, this); float setProgress = 0; boolean progressVisible = false; if (!FileLoader.getInstance().isLoadingFile(fileName)) { @@ -2123,14 +3135,14 @@ public class ChatMessageCell extends ChatBaseCell { Float progress = ImageLoader.getInstance().getFileProgress(fileName); setProgress = progress != null ? progress : 0; } - radialProgress.setProgress(setProgress, false); radialProgress.setBackground(getDrawableForCurrentState(), progressVisible, animated); + radialProgress.setProgress(setProgress, false); invalidate(); } else { MediaController.getInstance().removeLoadingFileObserver(this); if (currentMessageObject.type == 8 && !photoImage.isAllowStartAnimation()) { buttonState = 2; - } else if (currentMessageObject.type == 3) { + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) { buttonState = 3; } else { buttonState = -1; @@ -2161,86 +3173,129 @@ public class ChatMessageCell extends ChatBaseCell { private void didPressedButton(boolean animated) { if (buttonState == 0) { - cancelLoading = false; - radialProgress.setProgress(0, false); - if (currentMessageObject.type == 1) { - photoImage.setImage(currentPhotoObject.location, currentPhotoFilter, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilter, currentPhotoObject.size, null, false); - } else if (currentMessageObject.type == 8) { - currentMessageObject.audioProgress = 2; - photoImage.setImage(currentMessageObject.messageOwner.media.document, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, currentMessageObject.messageOwner.media.document.size, null, false); - } else if (currentMessageObject.type == 9) { - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, false, false); - } else if (currentMessageObject.type == 3) { - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); - } else if (currentMessageObject.type == 0 && isDocument != 0) { - if (isDocument == 2) { - photoImage.setImage(currentMessageObject.messageOwner.media.webpage.document, null, currentPhotoObject.location, currentPhotoFilter, currentMessageObject.messageOwner.media.webpage.document.size, null, false); + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (delegate.needPlayAudio(currentMessageObject)) { + buttonState = 1; + radialProgress.setBackground(getDrawableForCurrentState(), false, false); + invalidate(); + } + } else { + cancelLoading = false; + radialProgress.setProgress(0, false); + if (currentMessageObject.type == 1) { + photoImage.setImage(currentPhotoObject.location, currentPhotoFilter, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilter, currentPhotoObject.size, null, false); + } else if (currentMessageObject.type == 8) { currentMessageObject.audioProgress = 2; - } else if (isDocument == 1) { - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.webpage.document, false, false); + photoImage.setImage(currentMessageObject.messageOwner.media.document, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, currentMessageObject.messageOwner.media.document.size, null, false); + } else if (currentMessageObject.type == 9) { + FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, false, false); + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) { + FileLoader.getInstance().loadFile(documentAttach, true, false); + } else if (currentMessageObject.type == 0 && documentAttachType != DOCUMENT_ATTACH_TYPE_NONE) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) { + photoImage.setImage(currentMessageObject.messageOwner.media.webpage.document, null, currentPhotoObject.location, currentPhotoFilter, currentMessageObject.messageOwner.media.webpage.document.size, null, false); + currentMessageObject.audioProgress = 2; + } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { + FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.webpage.document, false, false); + } + } else { + photoImage.setImage(currentPhotoObject.location, currentPhotoFilter, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilterThumb, 0, null, false); } - } else { - photoImage.setImage(currentPhotoObject.location, currentPhotoFilter, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilterThumb, 0, null, false); - } - buttonState = 1; - radialProgress.setBackground(getDrawableForCurrentState(), true, animated); - invalidate(); - } else if (buttonState == 1) { - if (currentMessageObject.isOut() && currentMessageObject.isSending()) { - delegate.didPressedCancelSendButton(this); - } else { - cancelLoading = true; - if (currentMessageObject.type == 0 && isDocument == 1) { - FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.webpage.document); - } else if (currentMessageObject.type == 0 || currentMessageObject.type == 1 || currentMessageObject.type == 8) { - photoImage.cancelLoadImage(); - } else if (currentMessageObject.type == 9 || currentMessageObject.type == 3) { - FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document); - } - buttonState = 0; - radialProgress.setBackground(getDrawableForCurrentState(), false, animated); + buttonState = 1; + radialProgress.setBackground(getDrawableForCurrentState(), true, animated); invalidate(); } + } else if (buttonState == 1) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + boolean result = MediaController.getInstance().pauseAudio(currentMessageObject); + if (result) { + buttonState = 0; + radialProgress.setBackground(getDrawableForCurrentState(), false, false); + invalidate(); + } + } else { + if (currentMessageObject.isOut() && currentMessageObject.isSending()) { + delegate.didPressedCancelSendButton(this); + } else { + cancelLoading = true; + if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) { + FileLoader.getInstance().cancelLoadFile(documentAttach); + } else if (currentMessageObject.type == 0 || currentMessageObject.type == 1 || currentMessageObject.type == 8) { + photoImage.cancelLoadImage(); + } else if (currentMessageObject.type == 9) { + FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document); + } + buttonState = 0; + radialProgress.setBackground(getDrawableForCurrentState(), false, animated); + invalidate(); + } + } } else if (buttonState == 2) { - photoImage.setAllowStartAnimation(true); - photoImage.startAnimation(); - currentMessageObject.audioProgress = 0; - buttonState = -1; - radialProgress.setBackground(getDrawableForCurrentState(), false, animated); + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + radialProgress.setProgress(0, false); + FileLoader.getInstance().loadFile(documentAttach, true, false); + buttonState = 4; + radialProgress.setBackground(getDrawableForCurrentState(), true, false); + invalidate(); + } else { + photoImage.setAllowStartAnimation(true); + photoImage.startAnimation(); + currentMessageObject.audioProgress = 0; + buttonState = -1; + radialProgress.setBackground(getDrawableForCurrentState(), false, animated); + } } else if (buttonState == 3) { delegate.didPressedImage(this); + } else if (buttonState == 4) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (currentMessageObject.isOut() && currentMessageObject.isSending() || currentMessageObject.isSendError()) { + if (delegate != null) { + delegate.didPressedCancelSendButton(this); + } + } else { + FileLoader.getInstance().cancelLoadFile(documentAttach); + buttonState = 2; + radialProgress.setBackground(getDrawableForCurrentState(), false, false); + invalidate(); + } + } } } @Override public void onFailedDownload(String fileName) { - updateButtonState(false); + updateButtonState(documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC); } @Override public void onSuccessDownload(String fileName) { - radialProgress.setProgress(1, true); - if (currentMessageObject.type == 0) { - if (isDocument == 2 && currentMessageObject.audioProgress != 1) { - buttonState = 2; - didPressedButton(true); - } else if (!photoNotSet) { - updateButtonState(true); - } else { - setMessageObject(currentMessageObject); - } + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + updateButtonState(true); + updateWaveform(); } else { - if (!photoNotSet || currentMessageObject.type == 8 && currentMessageObject.audioProgress != 1) { - if (currentMessageObject.type == 8 && currentMessageObject.audioProgress != 1) { - photoNotSet = false; + radialProgress.setProgress(1, true); + if (currentMessageObject.type == 0) { + if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && currentMessageObject.audioProgress != 1) { buttonState = 2; didPressedButton(true); - } else { + } else if (!photoNotSet) { updateButtonState(true); + } else { + setMessageObject(currentMessageObject); + } + } else { + if (!photoNotSet || currentMessageObject.type == 8 && currentMessageObject.audioProgress != 1) { + if (currentMessageObject.type == 8 && currentMessageObject.audioProgress != 1) { + photoNotSet = false; + buttonState = 2; + didPressedButton(true); + } else { + updateButtonState(true); + } + } + if (photoNotSet) { + setMessageObject(currentMessageObject); } - } - if (photoNotSet) { - setMessageObject(currentMessageObject); } } } @@ -2248,8 +3303,14 @@ public class ChatMessageCell extends ChatBaseCell { @Override public void onProgressDownload(String fileName, float progress) { radialProgress.setProgress(progress, true); - if (buttonState != 1) { - updateButtonState(false); + if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { + if (buttonState != 4) { + updateButtonState(false); + } + } else { + if (buttonState != 1) { + updateButtonState(false); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMusicCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMusicCell.java deleted file mode 100644 index 0404682d3..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMusicCell.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 3.x.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-2016. - */ - -package org.telegram.ui.Cells; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.drawable.Drawable; -import android.text.Layout; -import android.text.StaticLayout; -import android.text.TextPaint; -import android.text.TextUtils; -import android.view.MotionEvent; -import android.view.SoundEffectConstants; - -import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ImageLoader; -import org.telegram.messenger.MediaController; -import org.telegram.messenger.MessageObject; -import org.telegram.messenger.SendMessagesHelper; -import org.telegram.messenger.FileLoader; -import org.telegram.tgnet.TLRPC; -import org.telegram.ui.Components.RadialProgress; -import org.telegram.ui.Components.ResourceLoader; -import org.telegram.ui.Components.SeekBar; - -import java.io.File; - -public class ChatMusicCell extends ChatBaseCell implements SeekBar.SeekBarDelegate { - - public interface ChatMusicCellDelegate { - boolean needPlayMusic(MessageObject messageObject); - } - - private static TextPaint timePaint; - private static TextPaint titlePaint; - private static TextPaint authorPaint; - - private SeekBar seekBar; - private int seekBarX; - private int seekBarY; - - private RadialProgress radialProgress; - private int buttonState = 0; - private int buttonX; - private int buttonY; - private boolean buttonPressed = false; - - private StaticLayout timeLayout; - private int timeX; - private String lastTimeString = null; - - private StaticLayout titleLayout; - private int titleX; - - private StaticLayout authorLayout; - private int authorX; - - private ChatMusicCellDelegate musicDelegate; - - public ChatMusicCell(Context context) { - super(context); - - seekBar = new SeekBar(context); - seekBar.setDelegate(this); - radialProgress = new RadialProgress(this); - drawForwardedName = false; - - if (timePaint == null) { - timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - timePaint.setTextSize(AndroidUtilities.dp(13)); - - titlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - titlePaint.setTextSize(AndroidUtilities.dp(16)); - titlePaint.setColor(0xff212121); - titlePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - - authorPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - authorPaint.setTextSize(AndroidUtilities.dp(15)); - authorPaint.setColor(0xff212121); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - MediaController.getInstance().removeLoadingFileObserver(this); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - updateButtonState(false); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - float x = event.getX(); - float y = event.getY(); - boolean result = seekBar.onTouch(event.getAction(), event.getX() - seekBarX, event.getY() - seekBarY); - if (result) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - getParent().requestDisallowInterceptTouchEvent(true); - } - invalidate(); - } else { - int side = AndroidUtilities.dp(36); - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side) { - buttonPressed = true; - invalidate(); - result = true; - radialProgress.swapBackground(getDrawableForCurrentState()); - } - } else if (buttonPressed) { - if (event.getAction() == MotionEvent.ACTION_UP) { - buttonPressed = false; - playSoundEffect(SoundEffectConstants.CLICK); - didPressedButton(); - invalidate(); - } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { - buttonPressed = false; - invalidate(); - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!(x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side)) { - buttonPressed = false; - invalidate(); - } - } - radialProgress.swapBackground(getDrawableForCurrentState()); - } - if (!result) { - result = super.onTouchEvent(event); - } - } - - return result; - } - - private void didPressedButton() { - if (buttonState == 0) { - if (musicDelegate != null) { - if (musicDelegate.needPlayMusic(currentMessageObject)) { - buttonState = 1; - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - invalidate(); - } - } - } else if (buttonState == 1) { - boolean result = MediaController.getInstance().pauseAudio(currentMessageObject); - if (result) { - buttonState = 0; - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - invalidate(); - } - } else if (buttonState == 2) { - radialProgress.setProgress(0, false); - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); - buttonState = 3; - radialProgress.setBackground(getDrawableForCurrentState(), true, false); - invalidate(); - } else if (buttonState == 3) { - FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document); - buttonState = 2; - radialProgress.setBackground(getDrawableForCurrentState(), false, false); - invalidate(); - } else if (buttonState == 4) { - if (currentMessageObject.isOut() && currentMessageObject.isSending()) { - if (delegate != null) { - delegate.didPressedCancelSendButton(this); - } - } - } - } - - public void setMusicDelegate(ChatMusicCellDelegate delegate) { - musicDelegate = delegate; - } - - public void updateProgress() { - if (currentMessageObject == null) { - return; - } - - if (!seekBar.isDragging()) { - seekBar.setProgress(currentMessageObject.audioProgress); - } - - int duration = 0; - int currentProgress = 0; - for (int a = 0; a < currentMessageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = currentMessageObject.messageOwner.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - duration = attribute.duration; - break; - } - } - if (MediaController.getInstance().isPlayingAudio(currentMessageObject)) { - currentProgress = currentMessageObject.audioProgressSec; - } - String timeString = String.format("%d:%02d / %d:%02d", currentProgress / 60, currentProgress % 60, duration / 60, duration % 60); - if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) { - lastTimeString = timeString; - int timeWidth = (int) Math.ceil(timePaint.measureText(timeString)); - timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - } - invalidate(); - } - - public void downloadAudioIfNeed() { - //if (buttonState == 2) { - //FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); - // buttonState = 3; - // invalidate(); - //} - } - - public void updateButtonState(boolean animated) { - if (currentMessageObject == null) { - return; - } - if (currentMessageObject.isOut() && currentMessageObject.isSending()) { - MediaController.getInstance().addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, this); - buttonState = 4; - radialProgress.setBackground(getDrawableForCurrentState(), true, animated); - Float progress = ImageLoader.getInstance().getFileProgress(currentMessageObject.messageOwner.attachPath); - if (progress == null && SendMessagesHelper.getInstance().isSendingMessage(currentMessageObject.getId())) { - progress = 1.0f; - } - radialProgress.setProgress(progress != null ? progress : 0, false); - } else { - File cacheFile = null; - if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() > 0) { - cacheFile = new File(currentMessageObject.messageOwner.attachPath); - if (!cacheFile.exists()) { - cacheFile = null; - } - } - if (cacheFile == null) { - cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); - } - if (cacheFile.exists()) { - MediaController.getInstance().removeLoadingFileObserver(this); - boolean playing = MediaController.getInstance().isPlayingAudio(currentMessageObject); - if (!playing || playing && MediaController.getInstance().isAudioPaused()) { - buttonState = 0; - } else { - buttonState = 1; - } - radialProgress.setProgress(0, animated); - radialProgress.setBackground(getDrawableForCurrentState(), false, animated); - } else { - String fileName = currentMessageObject.getFileName(); - MediaController.getInstance().addLoadingFileObserver(fileName, this); - if (!FileLoader.getInstance().isLoadingFile(fileName)) { - buttonState = 2; - radialProgress.setProgress(0, animated); - radialProgress.setBackground(getDrawableForCurrentState(), false, animated); - } else { - buttonState = 3; - Float progress = ImageLoader.getInstance().getFileProgress(fileName); - if (progress != null) { - radialProgress.setProgress(progress, animated); - } else { - radialProgress.setProgress(0, animated); - } - radialProgress.setBackground(getDrawableForCurrentState(), true, animated); - } - } - } - updateProgress(); - } - - @Override - public void onFailedDownload(String fileName) { - updateButtonState(true); - } - - @Override - public void onSuccessDownload(String fileName) { - updateButtonState(true); - } - - @Override - public void onProgressDownload(String fileName, float progress) { - radialProgress.setProgress(progress, true); - if (buttonState != 3) { - updateButtonState(false); - } - } - - @Override - public void onProgressUpload(String fileName, float progress, boolean isEncrypted) { - radialProgress.setProgress(progress, true); - } - - @Override - public void onSeekBarDrag(float progress) { - if (currentMessageObject == null) { - return; - } - currentMessageObject.audioProgress = progress; - MediaController.getInstance().seekToProgress(currentMessageObject, progress); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int width = MeasureSpec.getSize(widthMeasureSpec); - setMeasuredDimension(width, AndroidUtilities.dp(78) + namesOffset); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - - if (currentMessageObject.isOutOwner()) { - seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(52); - buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(13); - timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(63); - } else { - if (isChat && currentMessageObject.isFromUser()) { - seekBarX = AndroidUtilities.dp(113); - buttonX = AndroidUtilities.dp(74); - timeX = AndroidUtilities.dp(124); - } else { - seekBarX = AndroidUtilities.dp(61); - buttonX = AndroidUtilities.dp(22); - timeX = AndroidUtilities.dp(72); - } - } - - seekBar.width = backgroundWidth - AndroidUtilities.dp(67); - seekBar.height = AndroidUtilities.dp(30); - seekBarY = AndroidUtilities.dp(26) + namesOffset; - buttonY = AndroidUtilities.dp(13) + namesOffset; - radialProgress.setProgressRect(buttonX, buttonY, buttonX + AndroidUtilities.dp(40), buttonY + AndroidUtilities.dp(40)); - - updateProgress(); - } - - @Override - public void setMessageObject(MessageObject messageObject) { - boolean dataChanged = currentMessageObject == messageObject && isUserDataChanged(); - if (currentMessageObject != messageObject || dataChanged) { - if (AndroidUtilities.isTablet()) { - backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(300)); - } else { - backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), AndroidUtilities.dp(300)); - } - - if (messageObject.isOutOwner()) { - seekBar.type = 0; - radialProgress.setProgressColor(0xff87bf78); - } else { - seekBar.type = 1; - radialProgress.setProgressColor(0xffa2b5c7); - } - - int maxWidth = backgroundWidth - AndroidUtilities.dp(86); - - CharSequence stringFinal = TextUtils.ellipsize(messageObject.getMusicTitle().replace("\n", " "), titlePaint, maxWidth, TextUtils.TruncateAt.END); - titleLayout = new StaticLayout(stringFinal, titlePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - if (titleLayout.getLineCount() > 0) { - titleX = -(int) Math.ceil(titleLayout.getLineLeft(0)); - } - - stringFinal = TextUtils.ellipsize(messageObject.getMusicAuthor().replace("\n", " "), authorPaint, maxWidth, TextUtils.TruncateAt.END); - authorLayout = new StaticLayout(stringFinal, authorPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - if (authorLayout.getLineCount() > 0) { - authorX = -(int) Math.ceil(authorLayout.getLineLeft(0)); - } - - int duration = 0; - for (int a = 0; a < messageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = messageObject.messageOwner.media.document.attributes.get(a); - if (attribute instanceof TLRPC.TL_documentAttributeAudio) { - duration = attribute.duration; - break; - } - } - availableTimeWidth = backgroundWidth - AndroidUtilities.dp(72 + 14) - (int) Math.ceil(timePaint.measureText(String.format("%d:%02d / %d:%02d", duration / 60, duration % 60, duration / 60, duration % 60))); - - super.setMessageObject(messageObject); - } - updateButtonState(dataChanged); - } - - @Override - public void setCheckPressed(boolean value, boolean pressed) { - super.setCheckPressed(value, pressed); - if (radialProgress.swapBackground(getDrawableForCurrentState())) { - invalidate(); - } - } - - @Override - public void setHighlighted(boolean value) { - super.setHighlighted(value); - if (radialProgress.swapBackground(getDrawableForCurrentState())) { - invalidate(); - } - } - - @Override - public void setPressed(boolean pressed) { - super.setPressed(pressed); - if (radialProgress.swapBackground(getDrawableForCurrentState())) { - invalidate(); - } - } - - private Drawable getDrawableForCurrentState() { - return ResourceLoader.audioStatesDrawable[currentMessageObject.isOutOwner() ? buttonState : buttonState + 5][isDrawSelectedBackground() ? 2 : (buttonPressed ? 1 : 0)]; - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - if (currentMessageObject == null) { - return; - } - - if (currentMessageObject.isOutOwner()) { - timePaint.setColor(0xff70b15c); - } else { - timePaint.setColor(isDrawSelectedBackground() ? 0xff89b4c1 : 0xffa1aab3); - } - radialProgress.draw(canvas); - - canvas.save(); - canvas.translate(timeX + titleX, AndroidUtilities.dp(12) + namesOffset); - titleLayout.draw(canvas); - canvas.restore(); - - canvas.save(); - if (MediaController.getInstance().isPlayingAudio(currentMessageObject)) { - canvas.translate(seekBarX, seekBarY); - seekBar.draw(canvas); - } else { - canvas.translate(timeX + authorX, AndroidUtilities.dp(32) + namesOffset); - authorLayout.draw(canvas); - } - canvas.restore(); - - canvas.save(); - canvas.translate(timeX, AndroidUtilities.dp(52) + namesOffset); - timeLayout.draw(canvas); - canvas.restore(); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatUnreadCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatUnreadCell.java index ef043f5b3..b69baddc4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatUnreadCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatUnreadCell.java @@ -18,6 +18,7 @@ import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.R; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.ActionBar.Theme; public class ChatUnreadCell extends FrameLayout { @@ -38,7 +39,8 @@ public class ChatUnreadCell extends FrameLayout { textView = new TextView(context); textView.setPadding(0, 0, 0, AndroidUtilities.dp(1)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - textView.setTextColor(0xff4a7297); + textView.setTextColor(Theme.CHAT_UNREAD_TEXT_COLOR); + textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java index b9ec45600..5c789c3dd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java @@ -21,8 +21,10 @@ import android.text.TextUtils; import android.view.MotionEvent; import android.view.SoundEffectConstants; import android.view.View; +import android.view.animation.AccelerateInterpolator; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.ImageLoader; @@ -30,11 +32,12 @@ import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaController; import org.telegram.messenger.MessageObject; +import org.telegram.messenger.R; import org.telegram.messenger.Utilities; import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.LetterDrawable; import org.telegram.ui.Components.RadialProgress; -import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.ActionBar.Theme; import java.io.File; import java.util.ArrayList; @@ -42,6 +45,16 @@ import java.util.Locale; public class ContextLinkCell extends View implements MediaController.FileDownloadProgressListener { + private final static int DOCUMENT_ATTACH_TYPE_NONE = 0; + private final static int DOCUMENT_ATTACH_TYPE_DOCUMENT = 1; + private final static int DOCUMENT_ATTACH_TYPE_GIF = 2; + private final static int DOCUMENT_ATTACH_TYPE_AUDIO = 3; + private final static int DOCUMENT_ATTACH_TYPE_VIDEO = 4; + private final static int DOCUMENT_ATTACH_TYPE_MUSIC = 5; + private final static int DOCUMENT_ATTACH_TYPE_STICKER = 6; + private final static int DOCUMENT_ATTACH_TYPE_PHOTO = 7; + private final static int DOCUMENT_ATTACH_TYPE_GEO = 8; + public interface ContextLinkCellDelegate { void didPressedImage(ContextLinkCell cell); } @@ -52,6 +65,7 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa private boolean needDivider; private boolean buttonPressed; + private boolean needShadow; private int linkY; private StaticLayout linkLayout; @@ -62,18 +76,26 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa private int descriptionY = AndroidUtilities.dp(27); private StaticLayout descriptionLayout; - private TLRPC.BotInlineResult result; - private TLRPC.Document gif; + private TLRPC.BotInlineResult inlineResult; + private TLRPC.Document documentAttach; + private int documentAttachType; private boolean mediaWebpage; private static TextPaint titleTextPaint; private static TextPaint descriptionTextPaint; private static Paint paint; + private static Drawable shadowDrawable; private int TAG; private int buttonState; private RadialProgress radialProgress; + private long lastUpdateTime; + private boolean scaled; + private float scale; + private long time = 0; + private static AccelerateInterpolator interpolator = new AccelerateInterpolator(0.5f); + private ContextLinkCellDelegate delegate; public ContextLinkCell(Context context) { @@ -93,7 +115,6 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa paint.setStrokeWidth(1); } - setWillNotDraw(false); linkImageView = new ImageReceiver(this); letterDrawable = new LetterDrawable(); radialProgress = new RadialProgress(this); @@ -107,47 +128,43 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa descriptionLayout = null; titleLayout = null; linkLayout = null; - TLRPC.PhotoSize currentPhotoObject = null; - TLRPC.PhotoSize currentPhotoObjectThumb = null; - ArrayList photoThumbs = null; - String url = null; linkY = AndroidUtilities.dp(27); - if (result == null && gif == null) { + if (inlineResult == null && documentAttach == null) { setMeasuredDimension(AndroidUtilities.dp(100), AndroidUtilities.dp(100)); return; } - int maxWidth = MeasureSpec.getSize(widthMeasureSpec) - AndroidUtilities.dp(AndroidUtilities.leftBaseline) - AndroidUtilities.dp(8); + int viewWidth = MeasureSpec.getSize(widthMeasureSpec); + int maxWidth = viewWidth - AndroidUtilities.dp(AndroidUtilities.leftBaseline) - AndroidUtilities.dp(8); - TLRPC.Document document = null; - if (result != null && result.document != null) { - document = result.document; - } else if (gif != null) { - document = gif; - } - if (document != null) { + TLRPC.PhotoSize currentPhotoObject = null; + TLRPC.PhotoSize currentPhotoObjectThumb = null; + ArrayList photoThumbs = null; + String url = null; + + if (documentAttach != null) { photoThumbs = new ArrayList<>(); - photoThumbs.add(document.thumb); - } else if (result != null && result.photo != null) { - photoThumbs = new ArrayList<>(result.photo.sizes); + photoThumbs.add(documentAttach.thumb); + } else if (inlineResult != null && inlineResult.photo != null) { + photoThumbs = new ArrayList<>(inlineResult.photo.sizes); } - if (!mediaWebpage && result != null) { - if (result.title != null) { + if (!mediaWebpage && inlineResult != null) { + if (inlineResult.title != null) { try { - int width = (int) Math.ceil(titleTextPaint.measureText(result.title)); - CharSequence titleFinal = TextUtils.ellipsize(result.title.replace("\n", " "), titleTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.END); - titleLayout = new StaticLayout(titleFinal, titleTextPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + int width = (int) Math.ceil(titleTextPaint.measureText(inlineResult.title)); + CharSequence titleFinal = TextUtils.ellipsize(Emoji.replaceEmoji(inlineResult.title.replace('\n', ' '), titleTextPaint.getFontMetricsInt(), AndroidUtilities.dp(15), false), titleTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.END); + titleLayout = new StaticLayout(titleFinal, titleTextPaint, maxWidth + AndroidUtilities.dp(4), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } catch (Exception e) { FileLog.e("tmessages", e); } - letterDrawable.setTitle(result.title); + letterDrawable.setTitle(inlineResult.title); } - if (result.description != null) { + if (inlineResult.description != null) { try { - descriptionLayout = ChatMessageCell.generateStaticLayout(result.description, descriptionTextPaint, maxWidth, maxWidth, 0, 3); + descriptionLayout = ChatMessageCell.generateStaticLayout(Emoji.replaceEmoji(inlineResult.description, descriptionTextPaint.getFontMetricsInt(), AndroidUtilities.dp(13), false), descriptionTextPaint, maxWidth, maxWidth, 0, 3); if (descriptionLayout.getLineCount() > 0) { linkY = descriptionY + descriptionLayout.getLineBottom(descriptionLayout.getLineCount() - 1) + AndroidUtilities.dp(1); } @@ -156,10 +173,10 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } } - if (result.url != null) { + if (inlineResult.url != null) { try { - int width = (int) Math.ceil(descriptionTextPaint.measureText(result.url)); - CharSequence linkFinal = TextUtils.ellipsize(result.url.replace("\n", " "), descriptionTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.MIDDLE); + int width = (int) Math.ceil(descriptionTextPaint.measureText(inlineResult.url)); + CharSequence linkFinal = TextUtils.ellipsize(inlineResult.url.replace('\n', ' '), descriptionTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.MIDDLE); linkLayout = new StaticLayout(linkFinal, descriptionTextPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } catch (Exception e) { FileLog.e("tmessages", e); @@ -167,32 +184,52 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } } - boolean isGifDocument = false; - if (document != null && MessageObject.isGifDocument(document)) { - currentPhotoObject = document.thumb; - isGifDocument = true; - } else if (result != null && result.photo != null) { + documentAttachType = DOCUMENT_ATTACH_TYPE_NONE; + String ext = null; + if (documentAttach != null) { + if (MessageObject.isGifDocument(documentAttach)) { + documentAttachType = DOCUMENT_ATTACH_TYPE_GIF; + currentPhotoObject = documentAttach.thumb; + } else if (MessageObject.isStickerDocument(documentAttach)) { + documentAttachType = DOCUMENT_ATTACH_TYPE_STICKER; + currentPhotoObject = documentAttach.thumb; + ext = "webp"; + } else { + currentPhotoObject = documentAttach.thumb; + } + } else if (inlineResult != null && inlineResult.photo != null) { + documentAttachType = DOCUMENT_ATTACH_TYPE_PHOTO; currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, AndroidUtilities.getPhotoSize(), true); currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, 80); if (currentPhotoObjectThumb == currentPhotoObject) { currentPhotoObjectThumb = null; } } - if (result != null) { - if (result.content_url != null) { - if (result.type != null) { - if (result.type.startsWith("gif")) { - if (!isGifDocument) { - url = result.content_url; - isGifDocument = true; + if (inlineResult != null) { + if (inlineResult.content_url != null) { + if (inlineResult.type != null) { + if (inlineResult.type.startsWith("gif")) { + if (documentAttachType != DOCUMENT_ATTACH_TYPE_GIF) { + url = inlineResult.content_url; + documentAttachType = DOCUMENT_ATTACH_TYPE_GIF; + } + } else if (inlineResult.type.equals("photo")) { + url = inlineResult.thumb_url; + if (url == null) { + url = inlineResult.content_url; } - } else if (result.type.equals("photo")) { - url = result.content_url; } } } - if (url == null && result.thumb_url != null) { - url = result.thumb_url; + if (url == null && inlineResult.thumb_url != null) { + url = inlineResult.thumb_url; + } + } + if (url == null && currentPhotoObject == null && currentPhotoObjectThumb == null) { + if (inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue || inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo) { + double lat = inlineResult.send_message.geo.lat; + double lon = inlineResult.send_message.geo._long; + url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=15&size=72x72&maptype=roadmap&scale=%d&markers=color:red|size:small|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); } } @@ -200,9 +237,9 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa int w = 0; int h = 0; - if (document != null) { - for (int b = 0; b < document.attributes.size(); b++) { - TLRPC.DocumentAttribute attribute = document.attributes.get(b); + if (documentAttach != null) { + for (int b = 0; b < documentAttach.attributes.size(); b++) { + TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeImageSize || attribute instanceof TLRPC.TL_documentAttributeVideo) { w = attribute.w; h = attribute.h; @@ -212,24 +249,26 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } if (w == 0 || h == 0) { if (currentPhotoObject != null) { - currentPhotoObject.size = -1; if (currentPhotoObjectThumb != null) { currentPhotoObjectThumb.size = -1; } w = currentPhotoObject.w; h = currentPhotoObject.h; - } else if (result != null) { - w = result.w; - h = result.h; + } else if (inlineResult != null) { + w = inlineResult.w; + h = inlineResult.h; } } - if (document != null || currentPhotoObject != null || url != null) { + if (w == 0 || h == 0) { + w = h = AndroidUtilities.dp(80); + } + if (documentAttach != null || currentPhotoObject != null || url != null) { String currentPhotoFilter; String currentPhotoFilterThumb = "52_52_b"; if (mediaWebpage) { width = (int) (w / (h / (float) AndroidUtilities.dp(80))); - if (Build.VERSION.SDK_INT >= 11 && isGifDocument) { + if (Build.VERSION.SDK_INT >= 11 && documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) { currentPhotoFilterThumb = currentPhotoFilter = String.format(Locale.US, "%d_%d_b", (int) (width / AndroidUtilities.density), 80); } else { currentPhotoFilter = String.format(Locale.US, "%d_%d", (int) (width / AndroidUtilities.density), 80); @@ -239,25 +278,26 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa currentPhotoFilter = "52_52"; } - if (isGifDocument) { - if (document != null && Build.VERSION.SDK_INT >= 11) { - linkImageView.setImage(document, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, document.size, null, false); + if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) { + if (documentAttach != null && Build.VERSION.SDK_INT >= 11) { + linkImageView.setImage(documentAttach, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, documentAttach.size, ext, false); } else { - linkImageView.setImage(null, url, null, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, -1, null, true); + linkImageView.setImage(null, url, null, null, currentPhotoObject != null ? currentPhotoObject.location : null, currentPhotoFilter, -1, ext, true); } } else { if (currentPhotoObject != null) { - linkImageView.setImage(currentPhotoObject.location, currentPhotoFilter, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilterThumb, 0, null, false); + linkImageView.setImage(currentPhotoObject.location, currentPhotoFilter, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilterThumb, 0, ext, false); } else { - linkImageView.setImage(null, url, currentPhotoFilter, null, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilterThumb, -1, null, true); + linkImageView.setImage(null, url, currentPhotoFilter, null, currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, currentPhotoFilterThumb, -1, ext, true); } } drawLinkImageView = true; } if (mediaWebpage) { - if (gif != null) { - width = MeasureSpec.getSize(widthMeasureSpec); + setBackgroundDrawable(null); + if (inlineResult == null) { + width = viewWidth; int height = MeasureSpec.getSize(heightMeasureSpec); setMeasuredDimension(width, height); if (needDivider) { @@ -275,6 +315,7 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa linkImageView.setImageCoords(AndroidUtilities.dp(5), AndroidUtilities.dp(5), width, AndroidUtilities.dp(80)); } } else { + setBackgroundResource(R.drawable.list_selector); int height = 0; if (titleLayout != null && titleLayout.getLineCount() != 0) { height += titleLayout.getLineBottom(titleLayout.getLineCount() - 1); @@ -290,14 +331,23 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa int maxPhotoWidth = AndroidUtilities.dp(52); int x = LocaleController.isRTL ? MeasureSpec.getSize(widthMeasureSpec) - AndroidUtilities.dp(8) - maxPhotoWidth : AndroidUtilities.dp(8); - letterDrawable.setBounds(x, AndroidUtilities.dp(8), x + maxPhotoWidth, AndroidUtilities.dp(62)); + letterDrawable.setBounds(x, AndroidUtilities.dp(8), x + maxPhotoWidth, AndroidUtilities.dp(60)); linkImageView.setImageCoords(x, AndroidUtilities.dp(8), maxPhotoWidth, maxPhotoWidth); } } - public void setLink(TLRPC.BotInlineResult contextResult, boolean media, boolean divider) { + public void setLink(TLRPC.BotInlineResult contextResult, boolean media, boolean divider, boolean shadow) { needDivider = divider; - result = contextResult; + needShadow = shadow; + if (needShadow && shadowDrawable == null) { + shadowDrawable = getContext().getResources().getDrawable(R.drawable.header_shadow); + } + inlineResult = contextResult; + if (inlineResult != null && inlineResult.document != null) { + documentAttach = inlineResult.document; + } else { + documentAttach = null; + } mediaWebpage = media; requestLayout(); updateButtonState(false); @@ -305,13 +355,32 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa public void setGif(TLRPC.Document document, boolean divider) { needDivider = divider; - result = null; - gif = document; + needShadow = false; + inlineResult = null; + documentAttach = document; mediaWebpage = true; requestLayout(); updateButtonState(false); } + public boolean isSticker() { + return documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER; + } + + public boolean showingBitmap() { + return linkImageView.getBitmap() != null; + } + + public TLRPC.Document getDocument() { + return documentAttach; + } + + public void setScaled(boolean value) { + scaled = value; + lastUpdateTime = System.currentTimeMillis(); + invalidate(); + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); @@ -333,7 +402,13 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa @Override public boolean onTouchEvent(MotionEvent event) { - if (mediaWebpage || delegate == null || result == null) { + if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) { + if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { + getBackground().setHotspot(event.getX(), event.getY()); + } + } + + if (mediaWebpage || delegate == null || inlineResult == null) { return super.onTouchEvent(event); } int x = (int) event.getX(); @@ -341,22 +416,24 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa boolean result = false; int side = AndroidUtilities.dp(48); - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (letterDrawable.getBounds().contains(x, y)) { - buttonPressed = true; - result = true; - } - } else { - if (buttonPressed) { - if (event.getAction() == MotionEvent.ACTION_UP) { - buttonPressed = false; - playSoundEffect(SoundEffectConstants.CLICK); - delegate.didPressedImage(this); - } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { - buttonPressed = false; - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (!letterDrawable.getBounds().contains(x, y)) { + if (inlineResult != null && inlineResult.content_url != null && inlineResult.content_url.length() > 0) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + if (letterDrawable.getBounds().contains(x, y)) { + buttonPressed = true; + result = true; + } + } else { + if (buttonPressed) { + if (event.getAction() == MotionEvent.ACTION_UP) { buttonPressed = false; + playSoundEffect(SoundEffectConstants.CLICK); + delegate.didPressedImage(this); + } else if (event.getAction() == MotionEvent.ACTION_CANCEL) { + buttonPressed = false; + } else if (event.getAction() == MotionEvent.ACTION_MOVE) { + if (!letterDrawable.getBounds().contains(x, y)) { + buttonPressed = false; + } } } } @@ -386,7 +463,7 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } if (linkLayout != null) { - descriptionTextPaint.setColor(0xff316f9f); + descriptionTextPaint.setColor(Theme.MSG_LINK_TEXT_COLOR); canvas.save(); canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), linkY); linkLayout.draw(canvas); @@ -394,12 +471,68 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } if (!mediaWebpage) { - letterDrawable.draw(canvas); + if (inlineResult != null && inlineResult.type.equals("file")) { + int w = Theme.inlineDocDrawable.getIntrinsicWidth(); + int h = Theme.inlineDocDrawable.getIntrinsicHeight(); + int x = linkImageView.getImageX() + (AndroidUtilities.dp(52) - w) / 2; + int y = linkImageView.getImageY() + (AndroidUtilities.dp(52) - h) / 2; + canvas.drawRect(linkImageView.getImageX(), linkImageView.getImageY(), linkImageView.getImageX() + AndroidUtilities.dp(52), linkImageView.getImageY() + AndroidUtilities.dp(52), LetterDrawable.paint); + Theme.inlineDocDrawable.setBounds(x, y, x + w, y + h); + Theme.inlineDocDrawable.draw(canvas); + } else if (inlineResult != null && (inlineResult.type.equals("audio") || inlineResult.type.equals("voice"))) { + int w = Theme.inlineAudioDrawable.getIntrinsicWidth(); + int h = Theme.inlineAudioDrawable.getIntrinsicHeight(); + int x = linkImageView.getImageX() + (AndroidUtilities.dp(52) - w) / 2; + int y = linkImageView.getImageY() + (AndroidUtilities.dp(52) - h) / 2; + canvas.drawRect(linkImageView.getImageX(), linkImageView.getImageY(), linkImageView.getImageX() + AndroidUtilities.dp(52), linkImageView.getImageY() + AndroidUtilities.dp(52), LetterDrawable.paint); + Theme.inlineAudioDrawable.setBounds(x, y, x + w, y + h); + Theme.inlineAudioDrawable.draw(canvas); + } else if (inlineResult != null && (inlineResult.type.equals("venue") || inlineResult.type.equals("geo"))) { + int w = Theme.inlineLocationDrawable.getIntrinsicWidth(); + int h = Theme.inlineLocationDrawable.getIntrinsicHeight(); + int x = linkImageView.getImageX() + (AndroidUtilities.dp(52) - w) / 2; + int y = linkImageView.getImageY() + (AndroidUtilities.dp(52) - h) / 2; + canvas.drawRect(linkImageView.getImageX(), linkImageView.getImageY(), linkImageView.getImageX() + AndroidUtilities.dp(52), linkImageView.getImageY() + AndroidUtilities.dp(52), LetterDrawable.paint); + Theme.inlineLocationDrawable.setBounds(x, y, x + w, y + h); + Theme.inlineLocationDrawable.draw(canvas); + } else { + letterDrawable.draw(canvas); + } + } else { + if (inlineResult != null && (inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo || inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue)) { + int w = Theme.inlineLocationDrawable.getIntrinsicWidth(); + int h = Theme.inlineLocationDrawable.getIntrinsicHeight(); + int x = linkImageView.getImageX() + (linkImageView.getImageWidth() - w) / 2; + int y = linkImageView.getImageY() + (linkImageView.getImageHeight() - h) / 2; + canvas.drawRect(linkImageView.getImageX(), linkImageView.getImageY(), linkImageView.getImageX() + linkImageView.getImageWidth(), linkImageView.getImageY() + linkImageView.getImageHeight(), LetterDrawable.paint); + Theme.inlineLocationDrawable.setBounds(x, y, x + w, y + h); + Theme.inlineLocationDrawable.draw(canvas); + } } if (drawLinkImageView) { + canvas.save(); + if (scaled && scale != 0.8f || !scaled && scale != 1.0f) { + long newTime = System.currentTimeMillis(); + long dt = (newTime - lastUpdateTime); + lastUpdateTime = newTime; + if (scaled && scale != 0.8f) { + scale -= dt / 400.0f; + if (scale < 0.8f) { + scale = 0.8f; + } + } else { + scale += dt / 400.0f; + if (scale > 1.0f) { + scale = 1.0f; + } + } + invalidate(); + } + canvas.scale(scale, scale, getMeasuredWidth() / 2, getMeasuredHeight() / 2); linkImageView.draw(canvas); + canvas.restore(); } - if (mediaWebpage) { + if (mediaWebpage && (documentAttachType == DOCUMENT_ATTACH_TYPE_PHOTO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF)) { radialProgress.draw(canvas); } @@ -410,10 +543,14 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, paint); } } + if (needShadow && shadowDrawable != null) { + shadowDrawable.setBounds(0, 0, getMeasuredWidth(), AndroidUtilities.dp(3)); + shadowDrawable.draw(canvas); + } } private Drawable getDrawableForCurrentState() { - return buttonState == 1 ? ResourceLoader.buttonStatesDrawables[6] : null; + return buttonState == 1 ? Theme.photoStatesDrawables[5][0] : null; } public void updateButtonState(boolean animated) { @@ -422,27 +559,24 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } String fileName = null; File cacheFile = null; - if (result != null) { - if (result.photo instanceof TLRPC.TL_photo) { - TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(result.photo.sizes, AndroidUtilities.getPhotoSize(), true); - if (currentPhotoObject != null) { - currentPhotoObject.size = -1; - } + if (inlineResult != null) { + if (inlineResult.document instanceof TLRPC.TL_document) { + fileName = FileLoader.getAttachFileName(inlineResult.document); + cacheFile = FileLoader.getPathToAttach(inlineResult.document); + } else if (inlineResult.photo instanceof TLRPC.TL_photo) { + TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(inlineResult.photo.sizes, AndroidUtilities.getPhotoSize(), true); fileName = FileLoader.getAttachFileName(currentPhotoObject); cacheFile = FileLoader.getPathToAttach(currentPhotoObject); - } else if (result.document instanceof TLRPC.TL_document) { - fileName = FileLoader.getAttachFileName(result.document); - cacheFile = FileLoader.getPathToAttach(result.document); - } else if (result.content_url != null) { - fileName = Utilities.MD5(result.content_url) + "." + ImageLoader.getHttpUrlExtension(result.content_url, "jpg"); + } else if (inlineResult.content_url != null) { + fileName = Utilities.MD5(inlineResult.content_url) + "." + ImageLoader.getHttpUrlExtension(inlineResult.content_url, "jpg"); cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName); - } else if (result.thumb_url != null) { - fileName = Utilities.MD5(result.thumb_url) + "." + ImageLoader.getHttpUrlExtension(result.thumb_url, "jpg"); + } else if (inlineResult.thumb_url != null) { + fileName = Utilities.MD5(inlineResult.thumb_url) + "." + ImageLoader.getHttpUrlExtension(inlineResult.thumb_url, "jpg"); cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName); } - } else if (gif != null) { - fileName = FileLoader.getAttachFileName(gif); - cacheFile = FileLoader.getPathToAttach(gif); + } else if (documentAttach != null) { + fileName = FileLoader.getAttachFileName(documentAttach); + cacheFile = FileLoader.getPathToAttach(documentAttach); } if (fileName == null) { radialProgress.setBackground(null, false, false); @@ -473,7 +607,7 @@ public class ContextLinkCell extends View implements MediaController.FileDownloa } public TLRPC.BotInlineResult getResult() { - return result; + return inlineResult; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 53bb5a867..d7a67358f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -395,7 +395,7 @@ public class DialogCell extends BaseCell { if (mess.length() > 150) { mess = mess.substring(0, 150); } - mess = mess.replace("\n", " "); + mess = mess.replace('\n', ' '); messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name.replace("\n", ""), mess), AndroidUtilities.FLAG_TAG_COLOR), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20), false); } else { if (message.messageOwner.media != null && !message.isMediaEmpty()) { @@ -407,7 +407,7 @@ public class DialogCell extends BaseCell { if (mess.length() > 150) { mess = mess.substring(0, 150); } - mess = mess.replace("\n", " "); + mess = mess.replace('\n', ' '); messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name.replace("\n", ""), mess), AndroidUtilities.FLAG_TAG_COLOR), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20), false); } } @@ -559,7 +559,7 @@ public class DialogCell extends BaseCell { } nameWidth = Math.max(AndroidUtilities.dp(12), nameWidth); - CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace("\n", " "), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); + CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace('\n', ' '), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); try { nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } catch (Exception e) { @@ -609,7 +609,7 @@ public class DialogCell extends BaseCell { if (mess.length() > 150) { mess = mess.substring(0, 150); } - mess = mess.replace("\n", " "); + mess = mess.replace('\n', ' '); messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(17), false); } messageWidth = Math.max(AndroidUtilities.dp(12), messageWidth); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java index 4504abbcc..d2219fc22 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java @@ -12,6 +12,8 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; @@ -34,6 +36,7 @@ import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.ActionBar.Theme; public class DrawerProfileCell extends FrameLayout { @@ -44,10 +47,11 @@ public class DrawerProfileCell extends FrameLayout { private Rect srcRect = new Rect(); private Rect destRect = new Rect(); private Paint paint = new Paint(); + private int currentColor; public DrawerProfileCell(Context context) { super(context); - setBackgroundColor(0xff4c84b5); + setBackgroundColor(Theme.ACTION_BAR_PROFILE_COLOR); shadowView = new ImageView(context); shadowView.setVisibility(INVISIBLE); @@ -96,6 +100,12 @@ public class DrawerProfileCell extends FrameLayout { @Override protected void onDraw(Canvas canvas) { Drawable backgroundDrawable = ApplicationLoader.getCachedWallpaper(); + int color = ApplicationLoader.getServiceMessageColor(); + if (currentColor != color) { + currentColor = color; + shadowView.getDrawable().setColorFilter(new PorterDuffColorFilter(color | 0xff000000, PorterDuff.Mode.MULTIPLY)); + } + if (ApplicationLoader.isCustomTheme() && backgroundDrawable != null) { phoneTextView.setTextColor(0xffffffff); shadowView.setVisibility(VISIBLE); @@ -133,7 +143,7 @@ public class DrawerProfileCell extends FrameLayout { nameTextView.setText(UserObject.getUserName(user)); phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone)); AvatarDrawable avatarDrawable = new AvatarDrawable(user); - avatarDrawable.setColor(0xff5c98cd); + avatarDrawable.setColor(Theme.ACTION_BAR_MAIN_AVATAR_COLOR); avatarImageView.setImage(photo, "50_50", avatarDrawable); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/MentionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/MentionCell.java index 2a9aba56a..94ffcd3c4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/MentionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/MentionCell.java @@ -9,9 +9,11 @@ package org.telegram.ui.Cells; import android.content.Context; +import android.os.Build; import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; +import android.view.MotionEvent; import android.widget.LinearLayout; import android.widget.TextView; @@ -66,6 +68,16 @@ public class MentionCell extends LinearLayout { super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(36), MeasureSpec.EXACTLY)); } + @Override + public boolean onTouchEvent(MotionEvent event) { + if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) { + if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { + getBackground().setHotspot(event.getX(), event.getY()); + } + } + return super.onTouchEvent(event); + } + public void setUser(TLRPC.User user) { if (user == null) { nameTextView.setText(""); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java index e39fb48a2..c4d28b1d4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java @@ -52,7 +52,7 @@ public class PhotoPickerPhotoCell extends FrameLayout { super.onMeasure(MeasureSpec.makeMeasureSpec(itemWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(itemWidth, MeasureSpec.EXACTLY)); } - public void setChecked(final boolean checked, boolean animated) { + public void setChecked(final boolean checked, final boolean animated) { checkBox.setChecked(checked, animated); if (animator != null) { animator.cancel(); @@ -69,13 +69,20 @@ public class PhotoPickerPhotoCell extends FrameLayout { animator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animator.equals(animation)) { + if (animator != null && animator.equals(animation)) { animator = null; if (!checked) { setBackgroundColor(0); } } } + + @Override + public void onAnimationCancel(Object animation) { + if (animator != null && animator.equals(animation)) { + animator = null; + } + } }); animator.start(); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java index dbba717d1..b09451644 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java @@ -32,6 +32,7 @@ import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.ui.Components.AvatarDrawable; +import org.telegram.ui.ActionBar.Theme; public class ProfileSearchCell extends BaseCell { @@ -104,7 +105,7 @@ public class ProfileSearchCell extends BaseCell { onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); onlinePaint.setTextSize(AndroidUtilities.dp(16)); - onlinePaint.setColor(0xff316f9f); + onlinePaint.setColor(Theme.MSG_LINK_TEXT_COLOR); offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); offlinePaint.setTextSize(AndroidUtilities.dp(16)); @@ -263,7 +264,7 @@ public class ProfileSearchCell extends BaseCell { } else if (user != null) { nameString2 = UserObject.getUserName(user); } - nameString = nameString2.replace("\n", " "); + nameString = nameString2.replace('\n', ' '); } if (nameString.length() == 0) { if (user != null && user.phone != null && user.phone.length() != 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SendLocationCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SendLocationCell.java index e78a8c390..e7d11b6ff 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SendLocationCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SendLocationCell.java @@ -17,7 +17,7 @@ import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; import org.telegram.ui.Components.LayoutHelper; -import org.telegram.ui.Components.SimpleTextView; +import org.telegram.ui.ActionBar.SimpleTextView; public class SendLocationCell extends FrameLayout { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java index 5e45e5262..d9793952e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShareDialogCell.java @@ -9,9 +9,11 @@ package org.telegram.ui.Cells; import android.content.Context; +import android.os.Build; import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; +import android.view.MotionEvent; import android.widget.FrameLayout; import android.widget.TextView; @@ -34,6 +36,7 @@ public class ShareDialogCell extends FrameLayout { public ShareDialogCell(Context context) { super(context); + setBackgroundResource(R.drawable.list_selector); imageView = new BackupImageView(context); imageView.setRoundRadius(AndroidUtilities.dp(27)); @@ -61,6 +64,16 @@ public class ShareDialogCell extends FrameLayout { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(100), MeasureSpec.EXACTLY)); } + @Override + public boolean onTouchEvent(MotionEvent event) { + if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) { + if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { + getBackground().setHotspot(event.getX(), event.getY()); + } + } + return super.onTouchEvent(event); + } + public void setDialog(TLRPC.Dialog dialog, boolean checked, CharSequence name) { int lower_id = (int) dialog.id; TLRPC.FileLocation photo = null; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java index 5f6238ec1..63475c9b3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java @@ -146,7 +146,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F } if (color == -1) { int idx; - String ext = (idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1); + String ext = (idx = name.lastIndexOf('.')) == -1 ? "" : name.substring(idx + 1); if (ext.length() != 0) { color = ext.charAt(0) % icons.length; } else { @@ -198,34 +198,49 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F checkBox.setChecked(checked, animated); } - public void setDocument(MessageObject document, boolean divider) { + public void setDocument(MessageObject messageObject, boolean divider) { needDivider = divider; - message = document; + message = messageObject; loaded = false; loading = false; - if (document != null && document.messageOwner.media != null && document.messageOwner.media.document != null) { + if (messageObject != null && messageObject.getDocument() != null) { int idx; - String name = FileLoader.getDocumentFileName(document.messageOwner.media.document); - if (name.length() == 0) { - if (document.isMusic()) { - name = document.getMusicAuthor() + " - " + document.getMusicTitle(); + String name = null; + if (messageObject.isMusic()) { + TLRPC.Document document; + if (messageObject.type == 0) { + document = messageObject.messageOwner.media.webpage.document; + } else { + document = messageObject.messageOwner.media.document; + } + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + if (attribute.performer != null && attribute.performer.length() != 0 || attribute.title != null && attribute.title.length() != 0) { + name = messageObject.getMusicAuthor() + " - " + messageObject.getMusicTitle(); + } + } } } + String fileName = FileLoader.getDocumentFileName(messageObject.getDocument()); + if (name == null) { + name = fileName; + } + nameTextView.setText(name); placeholderImabeView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE); - placeholderImabeView.setImageResource(getThumbForNameOrMime(name, document.messageOwner.media.document.mime_type)); - nameTextView.setText(name); - extTextView.setText((idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1).toLowerCase()); - if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty || document.messageOwner.media.document.thumb == null) { + placeholderImabeView.setImageResource(getThumbForNameOrMime(fileName, messageObject.getDocument().mime_type)); + extTextView.setText((idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toLowerCase()); + if (messageObject.getDocument().thumb instanceof TLRPC.TL_photoSizeEmpty || messageObject.getDocument().thumb == null) { thumbImageView.setVisibility(INVISIBLE); thumbImageView.setImageBitmap(null); } else { thumbImageView.setVisibility(VISIBLE); - thumbImageView.setImage(document.messageOwner.media.document.thumb.location, "40_40", (Drawable) null); + thumbImageView.setImage(messageObject.getDocument().thumb.location, "40_40", (Drawable) null); } - long date = (long) document.messageOwner.date * 1000; - dateTextView.setText(String.format("%s, %s", AndroidUtilities.formatFileSize(document.messageOwner.media.document.size), LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))))); + long date = (long) messageObject.messageOwner.date * 1000; + dateTextView.setText(String.format("%s, %s", AndroidUtilities.formatFileSize(messageObject.getDocument().size), LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))))); } else { nameTextView.setText(""); extTextView.setText(""); @@ -248,7 +263,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F if (message.messageOwner.attachPath == null || message.messageOwner.attachPath.length() == 0 || !(new File(message.messageOwner.attachPath).exists())) { cacheFile = FileLoader.getPathToMessage(message.messageOwner); if (!cacheFile.exists()) { - fileName = FileLoader.getAttachFileName(message.messageOwner.media.document); + fileName = FileLoader.getAttachFileName(message.getDocument()); } } loaded = false; @@ -286,7 +301,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F } } - public MessageObject getDocument() { + public MessageObject getMessage() { return message; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java index 48d272883..4693f4890 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java @@ -10,13 +10,11 @@ package org.telegram.ui.Cells; import android.annotation.SuppressLint; import android.content.Context; -import android.content.Intent; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; -import android.provider.Browser; import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; @@ -33,11 +31,13 @@ import org.telegram.messenger.MessageObject; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; +import org.telegram.messenger.browser.Browser; import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.CheckBox; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LetterDrawable; import org.telegram.ui.Components.LinkPath; +import org.telegram.ui.ActionBar.Theme; import java.io.File; import java.util.ArrayList; @@ -100,7 +100,7 @@ public class SharedLinkCell extends FrameLayout { paint.setStrokeWidth(1); urlPaint = new Paint(); - urlPaint.setColor(0x33316f9f); + urlPaint.setColor(Theme.MSG_LINK_SELECT_BACKGROUND_COLOR); } setWillNotDraw(false); @@ -216,7 +216,7 @@ public class SharedLinkCell extends FrameLayout { if (title != null) { try { int width = (int) Math.ceil(titleTextPaint.measureText(title)); - CharSequence titleFinal = TextUtils.ellipsize(title.replace("\n", " "), titleTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.END); + CharSequence titleFinal = TextUtils.ellipsize(title.replace('\n', ' '), titleTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.END); titleLayout = new StaticLayout(titleFinal, titleTextPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } catch (Exception e) { FileLog.e("tmessages", e); @@ -252,7 +252,7 @@ public class SharedLinkCell extends FrameLayout { try { String link = links.get(a); int width = (int) Math.ceil(descriptionTextPaint.measureText(link)); - CharSequence linkFinal = TextUtils.ellipsize(link.replace("\n", " "), descriptionTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.MIDDLE); + CharSequence linkFinal = TextUtils.ellipsize(link.replace('\n', ' '), descriptionTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.MIDDLE); StaticLayout layout = new StaticLayout(linkFinal, descriptionTextPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); linkY = description2Y; if (descriptionLayout2 != null && descriptionLayout2.getLineCount() != 0) { @@ -378,7 +378,7 @@ public class SharedLinkCell extends FrameLayout { pressedLink = a; linkPreviewPressed = true; try { - urlPath.setCurrentLayout(layout, 0); + urlPath.setCurrentLayout(layout, 0, 0); layout.getSelectionPath(0, layout.getText().length(), urlPath); } catch (Exception e) { FileLog.e("tmessages", e); @@ -390,7 +390,7 @@ public class SharedLinkCell extends FrameLayout { if (webPage != null && Build.VERSION.SDK_INT >= 16 && webPage.embed_url != null && webPage.embed_url.length() != 0) { delegate.needOpenWebView(webPage); } else { - AndroidUtilities.openUrl(getContext(), links.get(pressedLink)); + Browser.openUrl(getContext(), links.get(pressedLink)); } } catch (Exception e) { FileLog.e("tmessages", e); @@ -461,7 +461,7 @@ public class SharedLinkCell extends FrameLayout { } if (!linkLayout.isEmpty()) { - descriptionTextPaint.setColor(0xff316f9f); + descriptionTextPaint.setColor(Theme.MSG_LINK_TEXT_COLOR); int offset = 0; for (int a = 0; a < linkLayout.size(); a++) { StaticLayout layout = linkLayout.get(a); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java index c703e0353..333a86877 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java @@ -123,13 +123,20 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { animator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animator.equals(animation)) { + if (animator != null && animator.equals(animation)) { animator = null; if (!checked) { setBackgroundColor(0); } } } + + @Override + public void onAnimationCancel(Object animation) { + if (animator != null && animator.equals(animation)) { + animator = null; + } + } }); animator.start(); } else { @@ -229,8 +236,8 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { if (messageObject.isVideo()) { photoVideoView.videoInfoContainer.setVisibility(VISIBLE); int duration = 0; - for (int b = 0; b < messageObject.messageOwner.media.document.attributes.size(); b++) { - TLRPC.DocumentAttribute attribute = messageObject.messageOwner.media.document.attributes.get(b); + for (int b = 0; b < messageObject.getDocument().attributes.size(); b++) { + TLRPC.DocumentAttribute attribute = messageObject.getDocument().attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeVideo) { duration = attribute.duration; break; @@ -239,8 +246,8 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { int minutes = duration / 60; int seconds = duration - minutes * 60; photoVideoView.videoTextView.setText(String.format("%d:%02d", minutes, seconds)); - if (messageObject.messageOwner.media.document.thumb != null) { - TLRPC.FileLocation location = messageObject.messageOwner.media.document.thumb.location; + if (messageObject.getDocument().thumb != null) { + TLRPC.FileLocation location = messageObject.getDocument().thumb.location; photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, location, "b", null, 0); } else { photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java index f04f7e70b..d8dc1d564 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java @@ -26,6 +26,7 @@ import org.telegram.messenger.AnimationCompat.ViewProxy; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.LayoutHelper; @@ -76,21 +77,10 @@ public class StickerSetCell extends FrameLayout { optionsButton = new ImageView(context); optionsButton.setFocusable(false); - optionsButton.setBackgroundResource(R.drawable.bar_selector_grey); + optionsButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR)); optionsButton.setImageResource(R.drawable.doc_actions_b); optionsButton.setScaleType(ImageView.ScaleType.CENTER); addView(optionsButton, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP)); - - /*ActionBarMenuItem menuItem = new ActionBarMenuItem(context, null, R.drawable.bar_selector_grey); - menuItem.setIcon(R.drawable.doc_actions_b); - addView(menuItem, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 40 : 0, 0, LocaleController.isRTL ? 0 : 40, 0)); - menuItem.addSubItem(1, "test", 0); - menuItem.addSubItem(2, "test", 0); - menuItem.addSubItem(3, "test", 0); - menuItem.addSubItem(4, "test", 0); - menuItem.addSubItem(5, "test", 0); - menuItem.addSubItem(6, "test", 0); - menuItem.addSubItem(7, "test", 0);*/ } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java index 0cc41f21f..cb9751307 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java @@ -10,58 +10,78 @@ package org.telegram.ui.Cells; import android.content.Context; import android.graphics.drawable.Drawable; -import android.text.TextUtils; -import android.util.TypedValue; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; -import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.ActionBar.SimpleTextView; public class TextCell extends FrameLayout { - private TextView textView; - private TextView valueTextView; + private SimpleTextView textView; + private SimpleTextView valueTextView; private ImageView imageView; private ImageView valueImageView; public TextCell(Context context) { super(context); - textView = new TextView(context); + textView = new SimpleTextView(context); textView.setTextColor(0xff212121); - textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); - textView.setLines(1); - textView.setMaxLines(1); - textView.setSingleLine(true); - textView.setEllipsize(TextUtils.TruncateAt.END); - textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); - addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 16 : 71, 0, LocaleController.isRTL ? 71 : 16, 0)); + textView.setTextSize(16); + textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); + addView(textView); - valueTextView = new TextView(context); + valueTextView = new SimpleTextView(context); valueTextView.setTextColor(0xff2f8cc9); - valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); - valueTextView.setLines(1); - valueTextView.setMaxLines(1); - valueTextView.setSingleLine(true); - valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); - addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 24 : 0, 0, LocaleController.isRTL ? 0 : 24, 0)); + valueTextView.setTextSize(16); + valueTextView.setGravity(LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); + addView(valueTextView); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); - addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 16, 5, LocaleController.isRTL ? 16 : 0, 0)); + addView(imageView); valueImageView = new ImageView(context); valueImageView.setScaleType(ImageView.ScaleType.CENTER); - addView(valueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 24 : 0, 0, LocaleController.isRTL ? 0 : 24, 0)); + addView(valueImageView); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY)); + int width = MeasureSpec.getSize(widthMeasureSpec); + int height = AndroidUtilities.dp(48); + + valueTextView.measure(MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(24), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.EXACTLY)); + textView.measure(MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(71 + 24), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.EXACTLY)); + imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); + valueImageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); + + setMeasuredDimension(width, AndroidUtilities.dp(48)); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + int height = bottom - top; + int width = right - left; + + int viewTop = (height - valueTextView.getTextHeight()) / 2; + int viewLeft = LocaleController.isRTL ? AndroidUtilities.dp(24) : 0; + valueTextView.layout(viewLeft, viewTop, viewLeft + valueTextView.getMeasuredWidth(), viewTop + valueTextView.getMeasuredHeight()); + + viewTop = (height - textView.getTextHeight()) / 2; + viewLeft = !LocaleController.isRTL ? AndroidUtilities.dp(71) : AndroidUtilities.dp(24); + textView.layout(viewLeft, viewTop, viewLeft + textView.getMeasuredWidth(), viewTop + textView.getMeasuredHeight()); + + viewTop = AndroidUtilities.dp(5); + viewLeft = !LocaleController.isRTL ? AndroidUtilities.dp(16) : width - imageView.getMeasuredWidth() - AndroidUtilities.dp(16); + imageView.layout(viewLeft, viewTop, viewLeft + imageView.getMeasuredWidth(), viewTop + imageView.getMeasuredHeight()); + + viewTop = (height - valueImageView.getMeasuredHeight()) / 2; + viewLeft = LocaleController.isRTL ? AndroidUtilities.dp(24) : width - valueImageView.getMeasuredWidth() - AndroidUtilities.dp(24); + valueImageView.layout(viewLeft, viewTop, viewLeft + valueImageView.getMeasuredWidth(), viewTop + valueImageView.getMeasuredHeight()); } public void setTextColor(int color) { @@ -70,6 +90,7 @@ public class TextCell extends FrameLayout { public void setText(String text) { textView.setText(text); + valueTextView.setText(null); imageView.setVisibility(INVISIBLE); valueTextView.setVisibility(INVISIBLE); valueImageView.setVisibility(INVISIBLE); @@ -77,6 +98,7 @@ public class TextCell extends FrameLayout { public void setTextAndIcon(String text, int resId) { textView.setText(text); + valueTextView.setText(null); imageView.setImageResource(resId); imageView.setVisibility(VISIBLE); valueTextView.setVisibility(INVISIBLE); @@ -94,6 +116,7 @@ public class TextCell extends FrameLayout { public void setTextAndValueDrawable(String text, Drawable drawable) { textView.setText(text); + valueTextView.setText(null); valueImageView.setVisibility(VISIBLE); valueImageView.setImageDrawable(drawable); valueTextView.setVisibility(INVISIBLE); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java index 46c40454a..71af0bb96 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java @@ -12,6 +12,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.os.Build; +import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; import android.widget.TextView; @@ -29,6 +30,7 @@ public class TextCheckCell extends FrameLayoutFixed { private Switch checkBox; private static Paint paint; private boolean needDivider; + private boolean isMultiline; public TextCheckCell(Context context) { super(context); @@ -46,7 +48,8 @@ public class TextCheckCell extends FrameLayoutFixed { textView.setMaxLines(1); textView.setSingleLine(true); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); - addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0)); + textView.setEllipsize(TextUtils.TruncateAt.END); + addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : 17, 0, LocaleController.isRTL ? 17 : 64, 0)); valueTextView = new TextView(context); valueTextView.setTextColor(0xff8a8a8a); @@ -56,7 +59,8 @@ public class TextCheckCell extends FrameLayoutFixed { valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setPadding(0, 0, 0, 0); - addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 35, 17, 0)); + valueTextView.setEllipsize(TextUtils.TruncateAt.END); + addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : 17, 35, LocaleController.isRTL ? 17 : 64, 0)); checkBox = new Switch(context); checkBox.setDuplicateParentStateEnabled(false); @@ -68,7 +72,11 @@ public class TextCheckCell extends FrameLayoutFixed { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 64 : 48) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY)); + if (isMultiline) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); + } else { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 64 : 48) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY)); + } } public void setTextAndCheck(String text, boolean checked, boolean divider) { @@ -77,6 +85,7 @@ public class TextCheckCell extends FrameLayoutFixed { checkBox.resetLayout(); checkBox.requestLayout(); } + isMultiline = false; checkBox.setChecked(checked); needDivider = divider; valueTextView.setVisibility(GONE); @@ -87,7 +96,7 @@ public class TextCheckCell extends FrameLayoutFixed { setWillNotDraw(!divider); } - public void setTextAndValueAndCheck(String text, String value, boolean checked, boolean divider) { + public void setTextAndValueAndCheck(String text, String value, boolean checked, boolean multiline, boolean divider) { textView.setText(text); valueTextView.setText(value); if (Build.VERSION.SDK_INT < 11) { @@ -97,6 +106,20 @@ public class TextCheckCell extends FrameLayoutFixed { checkBox.setChecked(checked); needDivider = divider; valueTextView.setVisibility(VISIBLE); + isMultiline = multiline; + if (multiline) { + valueTextView.setLines(0); + valueTextView.setMaxLines(0); + valueTextView.setSingleLine(false); + valueTextView.setEllipsize(null); + valueTextView.setPadding(0, 0, 0, AndroidUtilities.dp(11)); + } else { + valueTextView.setLines(1); + valueTextView.setMaxLines(1); + valueTextView.setSingleLine(true); + valueTextView.setEllipsize(TextUtils.TruncateAt.END); + valueTextView.setPadding(0, 0, 0, 0); + } LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.topMargin = AndroidUtilities.dp(10); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java index baf0f8279..b008bb767 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java @@ -18,6 +18,7 @@ import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.ActionBar.Theme; public class TextInfoPrivacyCell extends FrameLayout { @@ -28,7 +29,7 @@ public class TextInfoPrivacyCell extends FrameLayout { textView = new TextView(context); textView.setTextColor(0xff808080); - textView.setLinkTextColor(0xff316f9f); + textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(17)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java index ecc6b8ae7..257eb9c58 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java @@ -27,7 +27,7 @@ import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.CheckBox; import org.telegram.ui.Components.CheckBoxSquare; import org.telegram.ui.Components.LayoutHelper; -import org.telegram.ui.Components.SimpleTextView; +import org.telegram.ui.ActionBar.SimpleTextView; public class UserCell extends FrameLayout { @@ -89,17 +89,21 @@ public class UserCell extends FrameLayout { if (admin) { adminImage = new ImageView(context); - adminImage.setImageResource(R.drawable.admin_star); addView(adminImage, LayoutHelper.createFrame(16, 16, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 24 : 0, 13.5f, LocaleController.isRTL ? 0 : 24, 0)); } } - public void setIsAdmin(boolean value) { + public void setIsAdmin(int value) { if (adminImage == null) { return; } - adminImage.setVisibility(value ? VISIBLE : GONE); - nameTextView.setPadding(LocaleController.isRTL && value ? AndroidUtilities.dp(16) : 0, 0, !LocaleController.isRTL && value ? AndroidUtilities.dp(16) : 0, 0); + adminImage.setVisibility(value != 0 ? VISIBLE : GONE); + nameTextView.setPadding(LocaleController.isRTL && value != 0 ? AndroidUtilities.dp(16) : 0, 0, !LocaleController.isRTL && value != 0 ? AndroidUtilities.dp(16) : 0, 0); + if (value == 1) { + adminImage.setImageResource(R.drawable.admin_star); + } else if (value == 2) { + adminImage.setImageResource(R.drawable.admin_star2); + } } public void setData(TLObject user, CharSequence name, CharSequence status, int resId) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/WallpaperCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/WallpaperCell.java index d42160a75..a37de6fe2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/WallpaperCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/WallpaperCell.java @@ -16,7 +16,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.FileLoader; import org.telegram.messenger.R; import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.BackupImageView; @@ -64,7 +63,18 @@ public class WallpaperCell extends FrameLayout { imageView.setImageBitmap(null); imageView.setBackgroundColor(0xff000000 | wallpaper.bg_color); } else { - TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallpaper.sizes, AndroidUtilities.dp(100)); + int side = AndroidUtilities.dp(100); + TLRPC.PhotoSize size = null; + for (int a = 0; a < wallpaper.sizes.size(); a++) { + TLRPC.PhotoSize obj = wallpaper.sizes.get(a); + if (obj == null) { + continue; + } + int currentSide = obj.w >= obj.h ? obj.w : obj.h; + if (size == null || side > 100 && size.location != null && size.location.dc_id == Integer.MIN_VALUE || obj instanceof TLRPC.TL_photoCachedSize || currentSide <= side) { + size = obj; + } + } if (size != null && size.location != null) { imageView.setImage(size.location, "100_100", (Drawable) null); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java index 037b50730..4add7d3e1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java @@ -1147,7 +1147,7 @@ public class ChangePhoneActivity extends BaseFragment { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 1, 0)); } createTimer(); - } else if (currentType == 2 && nextType == 4) { + } else if (currentType == 2 && (nextType == 4 || nextType == 3)) { timeText.setVisibility(VISIBLE); timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 2, 0)); problemText.setVisibility(time < 1000 ? VISIBLE : GONE); @@ -1220,7 +1220,7 @@ public class ChangePhoneActivity extends BaseFragment { if (time >= 1000) { int minutes = time / 1000 / 60; int seconds = time / 1000 - minutes * 60; - if (nextType == 4) { + if (nextType == 4 || nextType == 3) { timeText.setText(LocaleController.formatString("CallText", R.string.CallText, minutes, seconds)); } else if (nextType == 2) { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, minutes, seconds)); @@ -1239,25 +1239,33 @@ public class ChangePhoneActivity extends BaseFragment { waitingForEvent = false; destroyCodeTimer(); resendCode(); - } else { - timeText.setText(LocaleController.getString("Calling", R.string.Calling)); - createCodeTimer(); - TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode(); - req.phone_number = requestPhone; - req.phone_code_hash = phoneHash; - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(TLObject response, final TLRPC.TL_error error) { - if (error != null && error.text != null) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - lastError = error.text; - } - }); + } else if (currentType == 2) { + if (nextType == 4) { + timeText.setText(LocaleController.getString("Calling", R.string.Calling)); + createCodeTimer(); + TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode(); + req.phone_number = requestPhone; + req.phone_code_hash = phoneHash; + ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(TLObject response, final TLRPC.TL_error error) { + if (error != null && error.text != null) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + lastError = error.text; + } + }); + } } - } - }, ConnectionsManager.RequestFlagFailOnServerErrors); + }, ConnectionsManager.RequestFlagFailOnServerErrors); + } else if (nextType == 3) { + AndroidUtilities.setWaitingForSms(false); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); + waitingForEvent = false; + destroyCodeTimer(); + resendCode(); + } } } } @@ -1320,7 +1328,7 @@ public class ChangePhoneActivity extends BaseFragment { finishFragment(); } else { lastError = error.text; - if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && nextType == 4) { + if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3)) { createTimer(); } if (currentType == 2) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelIntroActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelIntroActivity.java index 1c1b286c0..1ad5b77b8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelIntroActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelIntroActivity.java @@ -23,6 +23,7 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; public class ChannelIntroActivity extends BaseFragment { @@ -33,10 +34,9 @@ public class ChannelIntroActivity extends BaseFragment { @Override public View createView(Context context) { - - actionBar.setBackgroundColor(0xffffffff); + actionBar.setBackgroundColor(Theme.ACTION_BAR_CHANNEL_INTRO_COLOR); actionBar.setBackButtonImage(R.drawable.pl_back); - actionBar.setItemsBackground(R.drawable.bar_selector_audio); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_CHANNEL_INTRO_SELECTOR_COLOR); actionBar.setCastShadows(false); if (!AndroidUtilities.isTablet()) { actionBar.showActionModeTop(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelUsersActivity.java index fe51b1ce5..78c2ff5df 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelUsersActivity.java @@ -209,9 +209,9 @@ public class ChannelUsersActivity extends BaseFragment implements NotificationCe args.putBoolean("returnAsResult", true); args.putBoolean("needForwardCount", false); args.putBoolean("allowUsernameSearch", true); - if (isMegagroup) { + /*if (isMegagroup) { args.putBoolean("allowBots", false); - } + }*/ args.putString("selectAlertString", LocaleController.getString("ChannelAddUserAdminAlert", R.string.ChannelAddUserAdminAlert)); ContactsActivity fragment = new ContactsActivity(args); fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 899037f59..eeeb857e4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -21,6 +21,7 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.Cursor; import android.graphics.Bitmap; +import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.media.ExifInterface; @@ -65,6 +66,7 @@ import org.telegram.messenger.SendMessagesHelper; import org.telegram.messenger.UserObject; import org.telegram.messenger.Utilities; import org.telegram.messenger.VideoEditedInfo; +import org.telegram.messenger.browser.Browser; import org.telegram.messenger.query.BotQuery; import org.telegram.messenger.query.MessagesSearchQuery; import org.telegram.messenger.query.MessagesQuery; @@ -88,45 +90,40 @@ import org.telegram.messenger.UserConfig; import org.telegram.ui.ActionBar.ActionBarLayout; import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BottomSheet; +import org.telegram.ui.ActionBar.SimpleTextView; import org.telegram.ui.Adapters.MentionsAdapter; import org.telegram.ui.Adapters.StickersAdapter; import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.AnimationCompat.ViewProxy; +import org.telegram.ui.Cells.BotSwitchCell; import org.telegram.ui.Cells.ChatActionCell; -import org.telegram.ui.Cells.ChatAudioCell; import org.telegram.ui.Cells.ChatBaseCell; -import org.telegram.ui.Cells.ChatContactCell; import org.telegram.ui.Cells.ChatLoadingCell; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.Cells.ChatMessageCell; -import org.telegram.ui.Cells.ChatMusicCell; import org.telegram.ui.Cells.ChatUnreadCell; import org.telegram.ui.Cells.CheckBoxCell; import org.telegram.ui.Components.AlertsCreator; -import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Cells.BotHelpCell; import org.telegram.ui.Components.ChatActivityEnterView; import org.telegram.messenger.ImageReceiver; import org.telegram.ui.Components.ChatAttachView; +import org.telegram.ui.Components.ChatAvatarContainer; import org.telegram.ui.Components.PlayerView; import org.telegram.ui.Components.FrameLayoutFixed; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.NumberTextView; -import org.telegram.ui.Components.RadioButton; -import org.telegram.ui.Components.RecordStatusDrawable; import org.telegram.ui.Components.RecyclerListView; -import org.telegram.ui.Components.ResourceLoader; -import org.telegram.ui.Components.SendingFileExDrawable; -import org.telegram.ui.Components.ShareFrameLayout; +import org.telegram.ui.Components.ShareAlert; import org.telegram.ui.Components.SizeNotifierFrameLayout; -import org.telegram.ui.Components.TimerDrawable; -import org.telegram.ui.Components.TypingDotsDrawable; +import org.telegram.ui.Components.StickersAlert; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.URLSpanBotCommand; import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.Components.URLSpanReplacement; @@ -141,7 +138,7 @@ import java.util.concurrent.Semaphore; import java.util.regex.Matcher; @SuppressWarnings("unchecked") -public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.MessagesActivityDelegate, +public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate, PhotoViewer.PhotoViewerProvider { protected TLRPC.Chat currentChat; @@ -155,9 +152,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private FrameLayout progressView; private FrameLayout bottomOverlay; protected ChatActivityEnterView chatActivityEnterView; - private ImageView timeItem; private View timeItem2; - private TimerDrawable timerDrawable; private ActionBarMenuItem menuItem; private ActionBarMenuItem attachItem; private ActionBarMenuItem headerItem; @@ -168,24 +163,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private RecyclerListView chatListView; private LinearLayoutManager chatLayoutManager; private ChatActivityAdapter chatAdapter; - private BackupImageView avatarImageView; private TextView bottomOverlayChatText; private FrameLayout bottomOverlayChat; - private TypingDotsDrawable typingDotsDrawable; - private RecordStatusDrawable recordStatusDrawable; - private SendingFileExDrawable sendingFileDrawable; private FrameLayout emptyViewContainer; private ArrayList actionModeViews = new ArrayList<>(); - private TextView nameTextView; - private TextView onlineTextView; - private RadioButton radioButton; - private FrameLayout avatarContainer; + private ChatAvatarContainer avatarContainer; private TextView bottomOverlayText; private TextView secretViewStatusTextView; private NumberTextView selectedMessagesCountTextView; private TextView actionModeTextView; private RecyclerListView stickersListView; private RecyclerListView.OnItemClickListener stickersOnItemClickListener; + private RecyclerListView.OnItemClickListener mentionsOnItemClickListener; private StickersAdapter stickersAdapter; private FrameLayout stickersPanel; private TextView muteItem; @@ -195,6 +184,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private TextView replyObjectTextView; private ImageView replyIconImageView; private MentionsAdapter mentionsAdapter; + private BotSwitchCell botSwitchCell; + private View botSwitchShadow; + private FrameLayout mentionContainer; private RecyclerListView mentionListView; private LinearLayoutManager mentionLayoutManager; private AnimatorSetProxy mentionListAnimation; @@ -210,8 +202,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private View emojiButtonRed; private FrameLayout pinnedMessageView; private AnimatorSetProxy pinnedMessageViewAnimator; - private TextView pinnedMessageNameTextView; - private TextView pinnedMessageTextView; + private SimpleTextView pinnedMessageNameTextView; + private SimpleTextView pinnedMessageTextView; + private FrameLayout alertView; + private Runnable hideAlertViewRunnable; + private TextView alertNameTextView; + private TextView alertTextView; + private AnimatorSetProxy alertViewAnimator; + + private boolean mentionListViewIgnoreLayout; + private int mentionListViewScrollOffsetY; + private int mentionListViewLastViewTop; + private int mentionListViewLastViewPosition; + private boolean mentionListViewIsScrolling; private MessageObject pinnedMessageObject; private int loadingPinnedMessage; @@ -247,6 +250,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private Runnable waitingForCharaterEnterRunnable; private boolean openAnimationEnded; + private boolean attachAttachViewFirstShow = true; private int readWithDate; private int readWithMid; @@ -295,19 +299,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private Rect scrollRect = new Rect(); protected TLRPC.ChatFull info = null; - private int onlineCount = -1; private HashMap botInfo = new HashMap<>(); private String botUser; + private long inlineReturn; private MessageObject botButtons; private MessageObject botReplyButtons; private int botsCount; private boolean hasBotsCommands; - - private CharSequence lastPrintString; - private String lastStatus; - private int lastStatusDrawable; - private long chatEnterTime = 0; private long chatLeaveTime = 0; @@ -380,6 +379,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not final int chatId = arguments.getInt("chat_id", 0); final int userId = arguments.getInt("user_id", 0); final int encId = arguments.getInt("enc_id", 0); + inlineReturn = arguments.getLong("inline_return", 0); + String inlineQuery = arguments.getString("inline_query"); startLoadFromMessageId = arguments.getInt("message_id", 0); int migrated_to = arguments.getInt("migrated_to", 0); scrollToTopOnResume = arguments.getBoolean("scrollToTopOnResume", false); @@ -445,6 +446,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } dialog_id = userId; botUser = arguments.getString("botUser"); + if (inlineQuery != null) { + MessagesController.getInstance().sendBotStart(currentUser, inlineQuery); + } } else if (encId != 0) { currentEncryptedChat = MessagesController.getInstance().getEncryptedChat(encId); if (currentEncryptedChat == null) { @@ -595,13 +599,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, false); } - typingDotsDrawable = new TypingDotsDrawable(); - typingDotsDrawable.setIsChat(currentChat != null); - recordStatusDrawable = new RecordStatusDrawable(); - recordStatusDrawable.setIsChat(currentChat != null); - sendingFileDrawable = new SendingFileExDrawable(); - sendingFileDrawable.setIsChat(currentChat != null); - if (currentEncryptedChat != null && AndroidUtilities.getMyLayerVersion(currentEncryptedChat.layer) != SecretChatHelper.CURRENT_SECRET_CHAT_LAYER) { SecretChatHelper.getInstance().sendNotifyLayerMessage(currentEncryptedChat, null); } @@ -615,6 +612,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (chatActivityEnterView != null) { chatActivityEnterView.onDestroy(); } + if (mentionsAdapter != null) { + mentionsAdapter.onDestroy(); + } MessagesController.getInstance().setLastCreatedDialogId(dialog_id, false); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); @@ -701,13 +701,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } cantDeleteMessagesCount = 0; - lastPrintString = null; - lastStatus = null; hasOwnBackground = true; chatAttachView = null; chatAttachViewSheet = null; - ResourceLoader.loadRecources(context); + Theme.loadRecources(context); actionBar.setBackButtonDrawable(new BackDrawable(false)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @@ -843,19 +841,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not args.putBoolean("addContact", true); presentFragment(new ContactAddActivity(args)); } else { - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfo", R.string.AreYouSureShareMyContactInfo)); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - SendMessagesHelper.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); - moveScrollToLastMessage(); - showReplyPanel(false, null, null, null, false, true); - } - }); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); - showDialog(builder.create()); + shareMyContact(replyingMessageObject); } } else if (id == mute) { toggleMute(false); @@ -883,93 +869,28 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return; } - if (chatAttachView == null) { - BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); - chatAttachView = new ChatAttachView(getParentActivity()); - chatAttachView.setDelegate(new ChatAttachView.ChatAttachViewDelegate() { - @Override - public void didPressedButton(int button) { - if (button == 7) { - chatAttachViewSheet.dismiss(); - HashMap selectedPhotos = chatAttachView.getSelectedPhotos(); - if (!selectedPhotos.isEmpty()) { - ArrayList photos = new ArrayList<>(); - ArrayList captions = new ArrayList<>(); - for (HashMap.Entry entry : selectedPhotos.entrySet()) { - MediaController.PhotoEntry photoEntry = entry.getValue(); - if (photoEntry.imagePath != null) { - photos.add(photoEntry.imagePath); - captions.add(photoEntry.caption != null ? photoEntry.caption.toString() : null); - } else if (photoEntry.path != null) { - photos.add(photoEntry.path); - captions.add(photoEntry.caption != null ? photoEntry.caption.toString() : null); - } - photoEntry.imagePath = null; - photoEntry.thumbPath = null; - photoEntry.caption = null; - } - SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject, captions, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); - showReplyPanel(false, null, null, null, false, true); - } - return; - } else { - if (chatAttachViewSheet != null) { - chatAttachViewSheet.dismissWithButtonClick(button); - } - } - processSelectedAttach(button); - } - }); - builder.setDelegate(new BottomSheet.BottomSheetDelegate() { - - @Override - public void onRevealAnimationStart(boolean open) { - if (chatAttachView != null) { - chatAttachView.onRevealAnimationStart(open); - } - } - - @Override - public void onRevealAnimationProgress(boolean open, float radius, int x, int y) { - if (chatAttachView != null) { - chatAttachView.onRevealAnimationProgress(open, radius, x, y); - } - } - - @Override - public void onRevealAnimationEnd(boolean open) { - if (chatAttachView != null) { - chatAttachView.onRevealAnimationEnd(open); - } - } - - @Override - public void onOpenAnimationEnd() { - if (chatAttachView != null) { - chatAttachView.onRevealAnimationEnd(true); - } - } - - @Override - public View getRevealView() { - return menuItem; - } - }); - builder.setApplyTopPaddings(false); - builder.setUseRevealAnimation(); - builder.setCustomView(chatAttachView); - chatAttachViewSheet = builder.create(); - } + createChatAttachView(); + chatAttachView.loadGalleryPhotos(); if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) { chatActivityEnterView.closeKeyboard(); } chatAttachView.init(ChatActivity.this); - showDialog(chatAttachViewSheet); + if (attachAttachViewFirstShow) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + showDialog(chatAttachViewSheet); + } + }); + attachAttachViewFirstShow = false; + } else { + showDialog(chatAttachViewSheet); + } } else if (id == bot_help) { - SendMessagesHelper.getInstance().sendMessage("/help", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage("/help", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null, null); } else if (id == bot_settings) { - SendMessagesHelper.getInstance().sendMessage("/settings", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage("/settings", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null, null); } else if (id == search) { openSearchWithText(null); } else if (id == search_up) { @@ -987,34 +908,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); - avatarContainer = new FrameLayoutFixed(context); - avatarContainer.setBackgroundResource(R.drawable.bar_selector); - avatarContainer.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0); + avatarContainer = new ChatAvatarContainer(context, this, ChatObject.isChannel(currentChat) && !currentChat.megagroup && !(currentChat instanceof TLRPC.TL_channelForbidden), currentEncryptedChat != null); + avatarContainer.setRadioChecked(channelMessagesImportant == 1, false); actionBar.addView(avatarContainer, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 56, 0, 40, 0)); - avatarContainer.setOnClickListener(new View.OnClickListener() { + avatarContainer.setDelegate(new ChatAvatarContainer.ChatAvatarContainerDelegate() { @Override - public void onClick(View v) { - if (radioButton == null || radioButton.getVisibility() != View.VISIBLE) { - if (currentUser != null) { - Bundle args = new Bundle(); - args.putInt("user_id", currentUser.id); - if (currentEncryptedChat != null) { - args.putLong("dialog_id", dialog_id); - } - ProfileActivity fragment = new ProfileActivity(args); - fragment.setPlayProfileAnimation(true); - presentFragment(fragment); - } else if (currentChat != null) { - Bundle args = new Bundle(); - args.putInt("chat_id", currentChat.id); - ProfileActivity fragment = new ProfileActivity(args); - fragment.setChatInfo(info); - fragment.setPlayProfileAnimation(true); - presentFragment(fragment); - } - } else { - switchImportantMode(null); - } + public void didPressedRadioButton() { + switchImportantMode(null); } }); @@ -1030,58 +930,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - avatarImageView = new BackupImageView(context); - avatarImageView.setRoundRadius(AndroidUtilities.dp(21)); - avatarContainer.addView(avatarImageView, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 0, 3, 0, 0)); - - if (currentEncryptedChat != null) { - timeItem = new ImageView(context); - timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5)); - timeItem.setScaleType(ImageView.ScaleType.CENTER); - timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context)); - avatarContainer.addView(timeItem, LayoutHelper.createFrame(34, 34, Gravity.TOP | Gravity.LEFT, 16, 18, 0, 0)); - timeItem.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (getParentActivity() == null) { - return; - } - showDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat).create()); - } - }); - } - - nameTextView = new TextView(context); - nameTextView.setTextColor(0xffffffff); - nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); - nameTextView.setLines(1); - nameTextView.setMaxLines(1); - nameTextView.setSingleLine(true); - nameTextView.setEllipsize(TextUtils.TruncateAt.END); - nameTextView.setGravity(Gravity.LEFT); - nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); - nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - avatarContainer.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 54, 0, 0, 22)); - - onlineTextView = new TextView(context); - onlineTextView.setTextColor(0xffd7e8f7); - onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - onlineTextView.setLines(1); - onlineTextView.setMaxLines(1); - onlineTextView.setSingleLine(true); - onlineTextView.setEllipsize(TextUtils.TruncateAt.END); - onlineTextView.setGravity(Gravity.LEFT); - - if (ChatObject.isChannel(currentChat) && !currentChat.megagroup && !(currentChat instanceof TLRPC.TL_channelForbidden)) { - radioButton = new RadioButton(context); - radioButton.setChecked(channelMessagesImportant == 1, false); - radioButton.setVisibility(View.GONE); - avatarContainer.addView(radioButton, LayoutHelper.createFrame(24, 24, Gravity.LEFT | Gravity.BOTTOM, 50, 0, 0, 0)); - avatarContainer.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 54, 0, 0, 4)); - } else { - avatarContainer.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 54, 0, 0, 4)); - } - ActionBarMenu menu = actionBar.createMenu(); if (currentEncryptedChat == null && !isBroadcast) { @@ -1177,7 +1025,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } updateTitle(); - updateSubtitle(); + avatarContainer.updateOnlineCount(); + avatarContainer.updateSubtitle(); updateTitleIcons(); attachItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_other).setOverrideMenuClick(true).setAllowCloseAnimation(false); @@ -1192,7 +1041,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not selectedMessagesCountTextView = new NumberTextView(actionMode.getContext()); selectedMessagesCountTextView.setTextSize(18); selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - selectedMessagesCountTextView.setTextColor(0xff737373); + selectedMessagesCountTextView.setTextColor(Theme.ACTION_BAR_ACTION_MODE_TEXT_COLOR); actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 65, 0, 0, 0)); selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() { @Override @@ -1204,7 +1053,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not actionModeTextView = new TextView(actionMode.getContext()); actionModeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); actionModeTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - actionModeTextView.setTextColor(0xff737373); + actionModeTextView.setTextColor(Theme.ACTION_BAR_ACTION_MODE_TEXT_COLOR); actionModeTextView.setVisibility(View.GONE); actionModeTextView.setGravity(Gravity.CENTER_VERTICAL); actionModeTextView.setText(LocaleController.getString("Edit", R.string.Edit)); @@ -1218,17 +1067,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentEncryptedChat == null) { if (!isBroadcast) { - actionModeViews.add(actionMode.addItem(reply, R.drawable.ic_ab_reply, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(reply, R.drawable.ic_ab_reply, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); } - actionModeViews.add(actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - actionModeViews.add(actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - actionModeViews.add(actionMode.addItem(edit_done, R.drawable.check_blue, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(edit_done, R.drawable.check_blue, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); actionMode.getItem(edit_done).setVisibility(View.GONE); } else { - actionModeViews.add(actionMode.addItem(reply, R.drawable.ic_ab_reply, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - actionModeViews.add(actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(reply, R.drawable.ic_ab_reply, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(copy, R.drawable.ic_ab_fwd_copy, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); } actionMode.getItem(copy).setVisibility(selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE); actionMode.getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE); @@ -1273,6 +1122,51 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not child.measure(contentWidthSpec, contentHeightSpec); } else if (chatActivityEnterView.isPopupView(child)) { child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY)); + } else if (child == mentionContainer) { + int orientation = mentionsAdapter.getOrientation(); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mentionContainer.getLayoutParams(); + int height; + mentionListViewIgnoreLayout = true; + if (mentionsAdapter.isBotContext()) { + if (orientation == LinearLayoutManager.HORIZONTAL) { + height = AndroidUtilities.dp(90); + if (botSwitchCell.getVisibility() == VISIBLE) { + height += AndroidUtilities.dp(36); + mentionListView.setPadding(0, AndroidUtilities.dp(2 + 36), AndroidUtilities.dp(5), 0); + } else { + mentionListView.setPadding(0, AndroidUtilities.dp(2), AndroidUtilities.dp(5), 0); + } + } else { + int size = mentionsAdapter.getItemCount(); + int maxHeight = 0; + if (mentionsAdapter.getBotContextSwitch() != null) { + maxHeight += 36; + size -= 1; + } + maxHeight += size * 68; + + height = heightSize - chatActivityEnterView.getMeasuredHeight() + (maxHeight != 0 ? AndroidUtilities.dp(2) : 0); + mentionListView.setPadding(0, Math.max(0, height - AndroidUtilities.dp(Math.min(maxHeight, 68 * 1.8f))), 0, 0); + } + layoutParams.height = height; + layoutParams.topMargin = 0; + } else { + if (orientation == LinearLayoutManager.HORIZONTAL) { + mentionListView.setPadding(0, AndroidUtilities.dp(2), AndroidUtilities.dp(5), 0); + height = 90; + } else { + mentionListView.setPadding(0, AndroidUtilities.dp(2), 0, 0); + if (mentionsAdapter.isBotContext()) { + height = 36 * 3 + 18; + } else { + height = 36 * Math.min(3, mentionsAdapter.getItemCount()) + (mentionsAdapter.getItemCount() > 3 ? 18 : 0); + } + } + layoutParams.height = AndroidUtilities.dp(height + (height != 0 ? 2 : 0)); + layoutParams.topMargin = -AndroidUtilities.dp(height); + } + mentionListViewIgnoreLayout = false; + child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY)); } else { measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0); } @@ -1336,7 +1230,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not childTop = lp.topMargin; } - if (child == mentionListView) { + if (child == mentionContainer) { childTop -= chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(2); } else if (child == pagedownButton) { childTop -= chatActivityEnterView.getMeasuredHeight(); @@ -1350,6 +1244,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not child.layout(childLeft, childTop, childLeft + width, childTop + height); } + updateMessagesVisisblePart(); notifyHeightChanged(); } }; @@ -1375,22 +1270,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { emptyView.setText(LocaleController.getString("NoMessages", R.string.NoMessages)); } - emptyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + emptyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); emptyView.setGravity(Gravity.CENTER); - emptyView.setTextColor(0xffffffff); - emptyView.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_black : R.drawable.system_blue); - emptyView.setPadding(AndroidUtilities.dp(7), AndroidUtilities.dp(1), AndroidUtilities.dp(7), AndroidUtilities.dp(1)); + emptyView.setTextColor(Theme.CHAT_EMPTY_VIEW_TEXT_COLOR); + emptyView.setBackgroundResource(R.drawable.system); + emptyView.getBackground().setColorFilter(Theme.colorFilter); + emptyView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + emptyView.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(2), AndroidUtilities.dp(10), AndroidUtilities.dp(3)); emptyViewContainer.addView(emptyView, new FrameLayout.LayoutParams(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); } else { LinearLayout secretChatPlaceholder = new LinearLayout(context); - secretChatPlaceholder.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_black : R.drawable.system_blue); + secretChatPlaceholder.setBackgroundResource(R.drawable.system); + secretChatPlaceholder.getBackground().setColorFilter(Theme.colorFilter); secretChatPlaceholder.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12)); secretChatPlaceholder.setOrientation(LinearLayout.VERTICAL); emptyViewContainer.addView(secretChatPlaceholder, new FrameLayout.LayoutParams(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); secretViewStatusTextView = new TextView(context); secretViewStatusTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); - secretViewStatusTextView.setTextColor(0xffffffff); + secretViewStatusTextView.setTextColor(Theme.SECRET_CHAT_INFO_TEXT_COLOR); secretViewStatusTextView.setGravity(Gravity.CENTER_HORIZONTAL); secretViewStatusTextView.setMaxWidth(AndroidUtilities.dp(210)); if (currentEncryptedChat.admin_id == UserConfig.getClientUserId()) { @@ -1403,7 +1301,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not TextView textView = new TextView(context); textView.setText(LocaleController.getString("EncryptedDescriptionTitle", R.string.EncryptedDescriptionTitle)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); - textView.setTextColor(0xffffffff); + textView.setTextColor(Theme.SECRET_CHAT_INFO_TEXT_COLOR); textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setMaxWidth(AndroidUtilities.dp(260)); secretChatPlaceholder.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 0, 8, 0, 0)); @@ -1418,7 +1316,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); - textView.setTextColor(0xffffffff); + textView.setTextColor(Theme.SECRET_CHAT_INFO_TEXT_COLOR); textView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); textView.setMaxWidth(AndroidUtilities.dp(260)); @@ -1450,6 +1348,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (chatActivityEnterView != null) { chatActivityEnterView.onDestroy(); } + if (mentionsAdapter != null) { + mentionsAdapter.onDestroy(); + } chatListView = new RecyclerListView(context) { @Override @@ -1501,7 +1402,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - checkScrollForLoad(); + checkScrollForLoad(true); int firstVisibleItem = chatLayoutManager.findFirstVisibleItemPosition(); int visibleItemCount = firstVisibleItem == RecyclerView.NO_POSITION ? 0 : Math.abs(chatLayoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1; if (visibleItemCount > 0) { @@ -1629,7 +1530,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not contentView.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); View view = new View(context); - view.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_loader2 : R.drawable.system_loader1); + view.setBackgroundResource(R.drawable.system_loader); + view.getBackground().setColorFilter(Theme.colorFilter); progressView.addView(view, LayoutHelper.createFrame(36, 36, Gravity.CENTER)); ProgressBar progressBar = new ProgressBar(context); @@ -1661,22 +1563,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not lineView.setBackgroundColor(0xff6c9fd2); pinnedMessageView.addView(lineView, LayoutHelper.createFrame(2, 32, Gravity.LEFT | Gravity.TOP, 8, 8, 0, 0)); - pinnedMessageNameTextView = new TextView(context); - pinnedMessageNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - pinnedMessageNameTextView.setTextColor(0xff377aae); + pinnedMessageNameTextView = new SimpleTextView(context); + pinnedMessageNameTextView.setTextSize(14); + pinnedMessageNameTextView.setTextColor(Theme.PINNED_PANEL_NAME_TEXT_COLOR); pinnedMessageNameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - pinnedMessageNameTextView.setSingleLine(true); - pinnedMessageNameTextView.setEllipsize(TextUtils.TruncateAt.END); - pinnedMessageNameTextView.setMaxLines(1); - pinnedMessageView.addView(pinnedMessageNameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 18, 5, 52, 0)); + pinnedMessageView.addView(pinnedMessageNameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(18), Gravity.TOP | Gravity.LEFT, 18, 7.3f, 52, 0)); - pinnedMessageTextView = new TextView(context); - pinnedMessageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - pinnedMessageTextView.setTextColor(0xff999999); - pinnedMessageTextView.setSingleLine(true); - pinnedMessageTextView.setEllipsize(TextUtils.TruncateAt.END); - pinnedMessageTextView.setMaxLines(1); - pinnedMessageView.addView(pinnedMessageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 18, 23, 52, 0)); + pinnedMessageTextView = new SimpleTextView(context); + pinnedMessageTextView.setTextSize(14); + pinnedMessageTextView.setTextColor(Theme.PINNED_PANEL_MESSAGE_TEXT_COLOR); + pinnedMessageView.addView(pinnedMessageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(18), Gravity.TOP | Gravity.LEFT, 18, 25.3f, 52, 0)); ImageView closePinned = new ImageView(context); closePinned.setImageResource(R.drawable.miniplayer_close); @@ -1718,7 +1614,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not contentView.addView(reportSpamView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.TOP | Gravity.LEFT)); addToContactsButton = new TextView(context); - addToContactsButton.setTextColor(0xff4a82b5); + addToContactsButton.setTextColor(Theme.CHAT_ADD_CONTACT_TEXT_COLOR); addToContactsButton.setVisibility(View.GONE); addToContactsButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); addToContactsButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); @@ -1742,7 +1638,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not reportSpamView.addView(reportSpamContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 0, AndroidUtilities.dp(1))); reportSpamButton = new TextView(context); - reportSpamButton.setTextColor(0xffcf5957); + reportSpamButton.setTextColor(Theme.CHAT_REPORT_SPAM_TEXT_COLOR); reportSpamButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); reportSpamButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); reportSpamButton.setSingleLine(true); @@ -1784,8 +1680,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { MessagesController.getInstance().deleteUserFromChat((int) -dialog_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null); } - finishFragment(); + } else { + MessagesController.getInstance().deleteDialog(dialog_id, 0); } + finishFragment(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); @@ -1805,52 +1703,164 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); + alertView = new FrameLayoutFixed(context); + alertView.setTag(1); + ViewProxy.setTranslationY(alertView, -AndroidUtilities.dp(50)); + alertView.clearAnimation(); + alertView.setVisibility(View.GONE); + alertView.setBackgroundResource(R.drawable.blockpanel); + contentView.addView(alertView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.TOP | Gravity.LEFT)); + + alertNameTextView = new TextView(context); + alertNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + alertNameTextView.setTextColor(Theme.ALERT_PANEL_NAME_TEXT_COLOR); + alertNameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + alertNameTextView.setSingleLine(true); + alertNameTextView.setEllipsize(TextUtils.TruncateAt.END); + alertNameTextView.setMaxLines(1); + alertView.addView(alertNameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 8, 5, 8, 0)); + + alertTextView = new TextView(context); + alertTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + alertTextView.setTextColor(Theme.ALERT_PANEL_MESSAGE_TEXT_COLOR); + alertTextView.setSingleLine(true); + alertTextView.setEllipsize(TextUtils.TruncateAt.END); + alertTextView.setMaxLines(1); + alertView.addView(alertTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 8, 23, 8, 0)); + if (!isBroadcast) { - mentionListView = new RecyclerListView(context); + mentionContainer = new FrameLayoutFixed(context) { + + private Drawable background; + + @Override + public void onDraw(Canvas canvas) { + if (mentionsAdapter.isBotContext() && mentionsAdapter.getOrientation() == LinearLayoutManager.VERTICAL) { + background.setBounds(0, mentionListViewScrollOffsetY - AndroidUtilities.dp(2), getMeasuredWidth(), getMeasuredHeight()); + } else { + background.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); + } + background.draw(canvas); + } + + @Override + public void setBackgroundResource(int resid) { + background = getContext().getResources().getDrawable(resid); + } + + @Override + public void requestLayout() { + if (mentionListViewIgnoreLayout) { + return; + } + super.requestLayout(); + } + }; + mentionContainer.setBackgroundResource(R.drawable.compose_panel); + mentionContainer.setVisibility(View.GONE); + mentionContainer.setWillNotDraw(false); + contentView.addView(mentionContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 110, Gravity.LEFT | Gravity.BOTTOM)); + + mentionListView = new RecyclerListView(context) { + + private int lastWidth; + private int lastHeight; + + @Override + public boolean onInterceptTouchEvent(MotionEvent event) { + if (!mentionListViewIsScrolling && mentionListViewScrollOffsetY != 0 && event.getY() < mentionListViewScrollOffsetY && mentionsAdapter.isBotContext() && mentionsAdapter.getOrientation() == LinearLayoutManager.VERTICAL) { + return false; + } + boolean result = StickerPreviewViewer.getInstance().onInterceptTouchEvent(event, mentionListView, 0); + return super.onInterceptTouchEvent(event) || result; + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (!mentionListViewIsScrolling && mentionListViewScrollOffsetY != 0 && event.getY() < mentionListViewScrollOffsetY && mentionsAdapter.isBotContext() && mentionsAdapter.getOrientation() == LinearLayoutManager.VERTICAL) { + return false; + } + //supress warning + return super.onTouchEvent(event); + } + + @Override + public void requestLayout() { + if (mentionListViewIgnoreLayout) { + return; + } + super.requestLayout(); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + int width = r - l; + int height = b - t; + + int newPosition = -1; + int newTop = 0; + if (mentionListView != null && mentionListViewLastViewPosition >= 0 && width == lastWidth && height - lastHeight != 0) { + newPosition = mentionListViewLastViewPosition; + newTop = mentionListViewLastViewTop + height - lastHeight - getPaddingTop(); + } + + super.onLayout(changed, l, t, r, b); + + if (newPosition != -1) { + mentionListViewIgnoreLayout = true; + mentionLayoutManager.scrollToPositionWithOffset(newPosition, newTop); + super.onLayout(false, l, t, r, b); + mentionListViewIgnoreLayout = false; + } + + lastHeight = height; + lastWidth = width; + mentionListViewUpdateLayout(); + } + }; + mentionListView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return StickerPreviewViewer.getInstance().onTouch(event, mentionListView, 0, mentionsOnItemClickListener); + } + }); mentionLayoutManager = new LinearLayoutManager(context) { @Override public boolean supportsPredictiveItemAnimations() { return false; } }; + mentionListView.setItemAnimator(null); + mentionListView.setLayoutAnimation(null); mentionLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mentionListView.setLayoutManager(mentionLayoutManager); + mentionListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); + mentionContainer.addView(mentionListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); - mentionListView.setBackgroundResource(R.drawable.compose_panel); - mentionListView.setVisibility(View.GONE); - mentionListView.setPadding(0, AndroidUtilities.dp(2), 0, 0); - mentionListView.setClipToPadding(true); - mentionListView.setDisallowInterceptTouchEvents(true); - if (Build.VERSION.SDK_INT > 8) { - mentionListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); - } - contentView.addView(mentionListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 110, Gravity.LEFT | Gravity.BOTTOM)); - - mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(context, false, new MentionsAdapter.MentionsAdapterDelegate() { + mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(context, false, dialog_id, new MentionsAdapter.MentionsAdapterDelegate() { @Override public void needChangePanelVisibility(boolean show) { if (show) { int orientation = mentionsAdapter.getOrientation(); - - FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) mentionListView.getLayoutParams(); - int height; if (orientation == LinearLayoutManager.HORIZONTAL) { - mentionListView.setPadding(0, AndroidUtilities.dp(2), AndroidUtilities.dp(5), 0); mentionListView.setClipToPadding(false); - height = 90; + mentionListView.setDisallowInterceptTouchEvents(true); } else { - mentionListView.setPadding(0, AndroidUtilities.dp(2), 0, 0); - mentionListView.setClipToPadding(true); - if (mentionsAdapter.isBotContext()) { - height = 36 * 3 + 18; - } else { - height = 36 * Math.min(3, mentionsAdapter.getItemCount()) + (mentionsAdapter.getItemCount() > 3 ? 18 : 0); - } + mentionListView.setClipToPadding(!mentionsAdapter.isBotContext()); + mentionListView.setDisallowInterceptTouchEvents(false); + } + if (mentionsAdapter.isBotContext() && orientation == LinearLayoutManager.HORIZONTAL && mentionsAdapter.getBotContextSwitch() != null) { + botSwitchShadow.setVisibility(View.VISIBLE); + botSwitchCell.setVisibility(View.VISIBLE); + botSwitchCell.setText(mentionsAdapter.getBotContextSwitch().text); + } else { + botSwitchShadow.setVisibility(View.GONE); + botSwitchCell.setVisibility(View.GONE); + } + if (!mentionsAdapter.isBotContext() || orientation == LinearLayoutManager.HORIZONTAL) { + mentionListViewScrollOffsetY = 0; + mentionListViewLastViewPosition = -1; } - layoutParams3.height = AndroidUtilities.dp(2 + height); - layoutParams3.topMargin = -AndroidUtilities.dp(height); - mentionListView.setLayoutParams(layoutParams3); - mentionLayoutManager.setOrientation(orientation); if (mentionListAnimation != null) { @@ -1858,8 +1868,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not mentionListAnimation = null; } - if (mentionListView.getVisibility() == View.VISIBLE) { - ViewProxy.setAlpha(mentionListView, 1.0f); + if (mentionContainer.getVisibility() == View.VISIBLE) { + ViewProxy.setAlpha(mentionContainer, 1.0f); return; } else { mentionLayoutManager.scrollToPositionWithOffset(0, 10000); @@ -1876,17 +1886,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not preferences.edit().putBoolean("secretbot", true).commit(); } } - mentionListView.setVisibility(View.VISIBLE); - mentionListView.setTag(null); + mentionContainer.setVisibility(View.VISIBLE); + mentionContainer.setTag(null); mentionListAnimation = new AnimatorSetProxy(); mentionListAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(mentionListView, "alpha", 0.0f, 1.0f) + ObjectAnimatorProxy.ofFloat(mentionContainer, "alpha", 0.0f, 1.0f) ); mentionListAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { - mentionListView.clearAnimation(); + mentionContainer.clearAnimation(); + mentionListAnimation = null; + } + } + + @Override + public void onAnimationCancel(Object animation) { + if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { mentionListAnimation = null; } } @@ -1894,9 +1911,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not mentionListAnimation.setDuration(200); mentionListAnimation.start(); } else { - ViewProxy.setAlpha(mentionListView, 1.0f); - mentionListView.clearAnimation(); - mentionListView.setVisibility(View.INVISIBLE); + ViewProxy.setAlpha(mentionContainer, 1.0f); + mentionContainer.clearAnimation(); + mentionContainer.setVisibility(View.INVISIBLE); } } else { if (mentionListAnimation != null) { @@ -1904,21 +1921,28 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not mentionListAnimation = null; } - if (mentionListView.getVisibility() == View.GONE) { + if (mentionContainer.getVisibility() == View.GONE) { return; } if (allowStickersPanel) { mentionListAnimation = new AnimatorSetProxy(); mentionListAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(mentionListView, "alpha", 0.0f) + ObjectAnimatorProxy.ofFloat(mentionContainer, "alpha", 0.0f) ); mentionListAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { - mentionListView.clearAnimation(); - mentionListView.setVisibility(View.GONE); - mentionListView.setTag(null); + mentionContainer.clearAnimation(); + mentionContainer.setVisibility(View.GONE); + mentionContainer.setTag(null); + mentionListAnimation = null; + } + } + + @Override + public void onAnimationCancel(Object animation) { + if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { mentionListAnimation = null; } } @@ -1926,9 +1950,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not mentionListAnimation.setDuration(200); mentionListAnimation.start(); } else { - mentionListView.setTag(null); - mentionListView.clearAnimation(); - mentionListView.setVisibility(View.GONE); + mentionContainer.setTag(null); + mentionContainer.clearAnimation(); + mentionContainer.setVisibility(View.GONE); } } } @@ -1948,22 +1972,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (result.type.equals("video") || result.type.equals("web_player_video")) { BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); - builder.setCustomView(new WebFrameLayout(getParentActivity(), builder.create(), result.title != null ? result.title : "", result.content_url, result.content_url, result.w, result.h)); + builder.setCustomView(new WebFrameLayout(getParentActivity(), builder.create(), result.title != null ? result.title : "", result.description, result.content_url, result.content_url, result.w, result.h)); builder.setUseFullWidth(true); showDialog(builder.create()); } else { - AndroidUtilities.openUrl(getParentActivity(), result.content_url); + Browser.openUrl(getParentActivity(), result.content_url); } } })); if (!ChatObject.isChannel(currentChat) || currentChat != null && currentChat.megagroup) { mentionsAdapter.setBotInfo(botInfo); } + mentionsAdapter.setParentFragment(this); mentionsAdapter.setChatInfo(info); mentionsAdapter.setNeedUsernames(currentChat != null); mentionsAdapter.setNeedBotContext(currentEncryptedChat == null || AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 46); mentionsAdapter.setBotsCount(currentChat != null ? botsCount : 1); - mentionListView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { + mentionListView.setOnItemClickListener(mentionsOnItemClickListener = new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Object object = mentionsAdapter.getItem(position); @@ -1976,7 +2001,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else if (object instanceof String) { if (mentionsAdapter.isBotCommands()) { - SendMessagesHelper.getInstance().sendMessage((String) object, dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage((String) object, dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null, null); chatActivityEnterView.setFieldText(""); } else { chatActivityEnterView.replaceWithText(start, len, object + " "); @@ -1996,6 +2021,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not SendMessagesHelper.prepareSendingBotContextResult(result, params, dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); chatActivityEnterView.setFieldText(""); showReplyPanel(false, null, null, null, false, true); + } else if (object instanceof TLRPC.TL_inlineBotSwitchPM) { + processInlineBotContextPM((TLRPC.TL_inlineBotSwitchPM) object); } } }); @@ -2035,6 +2062,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); mentionListView.setOnScrollListener(new RecyclerView.OnScrollListener() { + + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + mentionListViewIsScrolling = newState == RecyclerView.SCROLL_STATE_DRAGGING; + } + @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int lastVisibleItem = mentionLayoutManager.findLastVisibleItemPosition(); @@ -2042,8 +2075,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (visibleItemCount > 0 && lastVisibleItem > mentionsAdapter.getItemCount() - 5) { mentionsAdapter.searchForContextBotForNextOffset(); } + + mentionListViewUpdateLayout(); } }); + + botSwitchCell = new BotSwitchCell(context); + botSwitchCell.setVisibility(View.GONE); + botSwitchCell.setBackgroundResource(R.drawable.list_selector); + mentionContainer.addView(botSwitchCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.LEFT | Gravity.TOP, 0, 2, 0, 0)); + botSwitchCell.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + processInlineBotContextPM(mentionsAdapter.getBotContextSwitch()); + } + }); + + botSwitchShadow = new View(context); + botSwitchShadow.setBackgroundResource(R.drawable.header_shadow); + botSwitchShadow.setVisibility(View.GONE); + mentionContainer.addView(botSwitchShadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.LEFT | Gravity.TOP, 0, 38, 0, 0)); } pagedownButton = new ImageView(context); @@ -2160,9 +2211,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not stickersPanel.clearAnimation(); stickersPanel.setVisibility(View.INVISIBLE); } - if (mentionListView != null && mentionListView.getVisibility() == View.VISIBLE) { - mentionListView.clearAnimation(); - mentionListView.setVisibility(View.INVISIBLE); + if (mentionContainer != null && mentionContainer.getVisibility() == View.VISIBLE) { + mentionContainer.clearAnimation(); + mentionContainer.setVisibility(View.INVISIBLE); } } else { allowStickersPanel = true; @@ -2170,15 +2221,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not stickersPanel.clearAnimation(); stickersPanel.setVisibility(View.VISIBLE); } - if (mentionListView != null && mentionListView.getVisibility() == View.INVISIBLE && (!mentionsAdapter.isBotContext() || (allowContextBotPanel || allowContextBotPanelSecond))) { - mentionListView.clearAnimation(); - mentionListView.setVisibility(View.VISIBLE); - mentionListView.setTag(null); + if (mentionContainer != null && mentionContainer.getVisibility() == View.INVISIBLE && (!mentionsAdapter.isBotContext() || (allowContextBotPanel || allowContextBotPanelSecond))) { + mentionContainer.clearAnimation(); + mentionContainer.setVisibility(View.VISIBLE); + mentionContainer.setTag(null); } } + allowContextBotPanel = !chatActivityEnterView.isPopupShowing(); checkContextBotPanel(); - updateMessagesVisisblePart(); } @Override @@ -2219,7 +2270,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not replyNameTextView = new TextView(context); replyNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - replyNameTextView.setTextColor(0xff377aae); + replyNameTextView.setTextColor(Theme.REPLY_PANEL_NAME_TEXT_COLOR); replyNameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); replyNameTextView.setSingleLine(true); replyNameTextView.setEllipsize(TextUtils.TruncateAt.END); @@ -2228,7 +2279,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not replyObjectTextView = new TextView(context); replyObjectTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - replyObjectTextView.setTextColor(0xff999999); + replyObjectTextView.setTextColor(Theme.REPLY_PANEL_MESSAGE_TEXT_COLOR); replyObjectTextView.setSingleLine(true); replyObjectTextView.setEllipsize(TextUtils.TruncateAt.END); replyObjectTextView.setMaxLines(1); @@ -2270,22 +2321,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not stickersPanel.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 53, 0, 0, 0)); bottomOverlay = new FrameLayout(context); - bottomOverlay.setBackgroundColor(0xffffffff); bottomOverlay.setVisibility(View.INVISIBLE); bottomOverlay.setFocusable(true); bottomOverlay.setFocusableInTouchMode(true); bottomOverlay.setClickable(true); - contentView.addView(bottomOverlay, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM)); + bottomOverlay.setBackgroundResource(R.drawable.compose_panel); + bottomOverlay.setPadding(0, AndroidUtilities.dp(3), 0, 0); + contentView.addView(bottomOverlay, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM)); bottomOverlayText = new TextView(context); bottomOverlayText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); - bottomOverlayText.setTextColor(0xff7f7f7f); + bottomOverlayText.setTextColor(Theme.CHAT_BOTTOM_OVERLAY_TEXT_COLOR); bottomOverlay.addView(bottomOverlayText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); bottomOverlayChat = new FrameLayout(context); - bottomOverlayChat.setBackgroundColor(0xfffbfcfd); + bottomOverlayChat.setBackgroundResource(R.drawable.compose_panel); + bottomOverlayChat.setPadding(0, AndroidUtilities.dp(3), 0, 0); bottomOverlayChat.setVisibility(View.INVISIBLE); - contentView.addView(bottomOverlayChat, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM)); + contentView.addView(bottomOverlayChat, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM)); bottomOverlayChat.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -2301,7 +2354,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (botUserLast != null && botUserLast.length() != 0) { MessagesController.getInstance().sendBotStart(currentUser, botUserLast); } else { - SendMessagesHelper.getInstance().sendMessage("/start", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage("/start", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null, null); } } else { builder = new AlertDialog.Builder(getParentActivity()); @@ -2317,7 +2370,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (botUser.length() != 0) { MessagesController.getInstance().sendBotStart(currentUser, botUser); } else { - SendMessagesHelper.getInstance().sendMessage("/start", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage("/start", dialog_id, null, null, false, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null, null); } botUser = null; updateBottomOverlay(); @@ -2349,8 +2402,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); bottomOverlayChatText = new TextView(context); - bottomOverlayChatText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); - bottomOverlayChatText.setTextColor(0xff3e6fa1); + bottomOverlayChatText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); + bottomOverlayChatText.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + bottomOverlayChatText.setTextColor(Theme.CHAT_BOTTOM_CHAT_OVERLAY_TEXT_COLOR); bottomOverlayChat.addView(bottomOverlayChatText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); chatAdapter.updateRows(); @@ -2375,20 +2429,160 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updatePinnedMessageView(true); try { - if (currentEncryptedChat != null && Build.VERSION.SDK_INT >= 14) { + if (currentEncryptedChat != null && Build.VERSION.SDK_INT >= 23) { getParentActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); } } catch (Throwable e) { FileLog.e("tmessages", e); } + fixLayoutInternal(); return fragmentView; } + private void mentionListViewUpdateLayout() { + if (mentionListView.getChildCount() <= 0 || !mentionsAdapter.isBotContext() || mentionsAdapter.getOrientation() != LinearLayoutManager.VERTICAL) { + mentionListViewScrollOffsetY = 0; + mentionListViewLastViewPosition = -1; + return; + } + View child = mentionListView.getChildAt(mentionListView.getChildCount() - 1); + MentionsAdapter.Holder holder = (MentionsAdapter.Holder) mentionListView.findContainingViewHolder(child); + if (holder != null) { + mentionListViewLastViewPosition = holder.getAdapterPosition(); + mentionListViewLastViewTop = child.getTop(); + } else { + mentionListViewLastViewPosition = -1; + } + + child = mentionListView.getChildAt(0); + holder = (MentionsAdapter.Holder) mentionListView.findContainingViewHolder(child); + int newOffset = child.getTop() > 0 && holder != null && holder.getAdapterPosition() == 0 ? child.getTop() : 0; + if (mentionListViewScrollOffsetY != newOffset) { + mentionListView.setTopGlowOffset(mentionListViewScrollOffsetY = newOffset); + mentionListView.invalidate(); + mentionContainer.invalidate(); + } + } + + public void processInlineBotContextPM(TLRPC.TL_inlineBotSwitchPM object) { + if (object == null) { + return; + } + TLRPC.User user = mentionsAdapter.getContextBotUser(); + if (user == null) { + return; + } + chatActivityEnterView.setFieldText(""); + if (dialog_id == user.id) { + inlineReturn = dialog_id; + MessagesController.getInstance().sendBotStart(currentUser, object.start_param); + } else { + Bundle args = new Bundle(); + args.putInt("user_id", user.id); + args.putString("inline_query", object.start_param); + args.putLong("inline_return", dialog_id); + if (!MessagesController.checkCanOpenChat(args, ChatActivity.this)) { + return; + } + presentFragment(new ChatActivity(args)); + } + } + + private void createChatAttachView() { + if (chatAttachView == null) { + BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); + chatAttachView = new ChatAttachView(getParentActivity()); + chatAttachView.setDelegate(new ChatAttachView.ChatAttachViewDelegate() { + @Override + public void didPressedButton(int button) { + if (button == 7) { + chatAttachViewSheet.dismiss(); + HashMap selectedPhotos = chatAttachView.getSelectedPhotos(); + if (!selectedPhotos.isEmpty()) { + ArrayList photos = new ArrayList<>(); + ArrayList captions = new ArrayList<>(); + for (HashMap.Entry entry : selectedPhotos.entrySet()) { + MediaController.PhotoEntry photoEntry = entry.getValue(); + if (photoEntry.imagePath != null) { + photos.add(photoEntry.imagePath); + captions.add(photoEntry.caption != null ? photoEntry.caption.toString() : null); + } else if (photoEntry.path != null) { + photos.add(photoEntry.path); + captions.add(photoEntry.caption != null ? photoEntry.caption.toString() : null); + } + photoEntry.imagePath = null; + photoEntry.thumbPath = null; + photoEntry.caption = null; + } + SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject, captions, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); + showReplyPanel(false, null, null, null, false, true); + } + return; + } else { + if (chatAttachViewSheet != null) { + chatAttachViewSheet.dismissWithButtonClick(button); + } + } + processSelectedAttach(button); + } + }); + builder.setDelegate(new BottomSheet.BottomSheetDelegate() { + + @Override + public void onRevealAnimationStart(boolean open) { + if (chatAttachView != null) { + chatAttachView.onRevealAnimationStart(open); + } + } + + @Override + public void onRevealAnimationProgress(boolean open, float radius, int x, int y) { + if (chatAttachView != null) { + chatAttachView.onRevealAnimationProgress(open, radius, x, y); + } + } + + @Override + public void onRevealAnimationEnd(boolean open) { + if (chatAttachView != null) { + chatAttachView.onRevealAnimationEnd(open); + } + } + + @Override + public void onOpenAnimationEnd() { + if (chatAttachView != null) { + chatAttachView.onRevealAnimationEnd(true); + } + } + + @Override + public View getRevealView() { + return menuItem; + } + }); + builder.setApplyTopPadding(false); + builder.setApplyBottomPadding(false); + builder.setUseRevealAnimation(); + builder.setCustomView(chatAttachView); + chatAttachViewSheet = builder.create(); + } + } + public long getDialogId() { return dialog_id; } + public void setBotUser(String value) { + if (inlineReturn != 0) { + MessagesController.getInstance().sendBotStart(currentUser, value); + } else { + botUser = value; + updateBottomOverlay(); + } + } + public boolean playFirstUnreadVoiceMessage() { for (int a = messages.size() - 1; a >= 0; a--) { MessageObject messageObject = messages.get(a); @@ -2451,6 +2645,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not runningAnimation = null; } } + + @Override + public void onAnimationCancel(Object animation) { + if (runningAnimation != null && runningAnimation.equals(animation)) { + runningAnimation = null; + } + } }); runningAnimation.start(); } else if (!show) { @@ -2471,6 +2672,30 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); } + public void shareMyContact(final MessageObject messageObject) { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("ShareYouPhoneNumberTitle", R.string.ShareYouPhoneNumberTitle)); + if (currentUser != null) { + if (currentUser.bot) { + builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfoBot", R.string.AreYouSureShareMyContactInfoBot)); + } else { + builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureShareMyContactInfoUser", R.string.AreYouSureShareMyContactInfoUser, PhoneFormat.getInstance().format("+" + UserConfig.getCurrentUser().phone), ContactsController.formatName(currentUser.first_name, currentUser.last_name)))); + } + } else { + builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfo", R.string.AreYouSureShareMyContactInfo)); + } + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + SendMessagesHelper.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id, messageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); + moveScrollToLastMessage(); + showReplyPanel(false, null, null, null, false, true); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showDialog(builder.create()); + } + private void showGifHint() { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); if (preferences.getBoolean("gifhint", false)) { @@ -2499,7 +2724,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not gifHintTextView = new TextView(getParentActivity()); gifHintTextView.setBackgroundResource(R.drawable.tooltip); - gifHintTextView.setTextColor(0xffffffff); + gifHintTextView.setTextColor(Theme.CHAT_GIF_HINT_TEXT_COLOR); gifHintTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); gifHintTextView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0); gifHintTextView.setText(LocaleController.getString("TapHereGifs", R.string.TapHereGifs)); @@ -2546,23 +2771,29 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private void checkContextBotPanel() { if (allowStickersPanel && mentionsAdapter != null && mentionsAdapter.isBotContext()) { if (!allowContextBotPanel && !allowContextBotPanelSecond) { - if (mentionListView.getVisibility() == View.VISIBLE && mentionListView.getTag() == null) { + if (mentionContainer.getVisibility() == View.VISIBLE && mentionContainer.getTag() == null) { if (mentionListAnimation != null) { mentionListAnimation.cancel(); - mentionListAnimation = null; } - mentionListView.setTag(1); + mentionContainer.setTag(1); mentionListAnimation = new AnimatorSetProxy(); mentionListAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(mentionListView, "alpha", 0.0f) + ObjectAnimatorProxy.ofFloat(mentionContainer, "alpha", 0.0f) ); mentionListAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { - mentionListView.clearAnimation(); - mentionListView.setVisibility(View.INVISIBLE); + mentionContainer.clearAnimation(); + mentionContainer.setVisibility(View.INVISIBLE); + mentionListAnimation = null; + } + } + + @Override + public void onAnimationCancel(Object animation) { + if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { mentionListAnimation = null; } } @@ -2571,22 +2802,28 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not mentionListAnimation.start(); } } else { - if (mentionListView.getVisibility() == View.INVISIBLE || mentionListView.getTag() != null) { + if (mentionContainer.getVisibility() == View.INVISIBLE || mentionContainer.getTag() != null) { if (mentionListAnimation != null) { mentionListAnimation.cancel(); - mentionListAnimation = null; } - mentionListView.setTag(null); - mentionListView.setVisibility(View.VISIBLE); + mentionContainer.setTag(null); + mentionContainer.setVisibility(View.VISIBLE); mentionListAnimation = new AnimatorSetProxy(); mentionListAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(mentionListView, "alpha", 0.0f, 1.0f) + ObjectAnimatorProxy.ofFloat(mentionContainer, "alpha", 0.0f, 1.0f) ); mentionListAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { - mentionListView.clearAnimation(); + mentionContainer.clearAnimation(); + mentionListAnimation = null; + } + } + + @Override + public void onAnimationCancel(Object animation) { + if (mentionListAnimation != null && mentionListAnimation.equals(animation)) { mentionListAnimation = null; } } @@ -2598,7 +2835,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - private void checkScrollForLoad() { + private void checkScrollForLoad(boolean scroll) { if (chatLayoutManager == null || paused) { return; } @@ -2606,7 +2843,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int visibleItemCount = firstVisibleItem == RecyclerView.NO_POSITION ? 0 : Math.abs(chatLayoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1; if (visibleItemCount > 0) { int totalItemCount = chatAdapter.getItemCount(); - if (firstVisibleItem <= 25 && !loading) { + int checkLoadCount; + if (scroll) { + if (lastLoadIndex < 3) { + checkLoadCount = 5; + } else { + checkLoadCount = 25; + } + } else { + checkLoadCount = 5; + } + if (firstVisibleItem <= checkLoadCount && !loading) { if (!endReached[0]) { loading = true; waitingForLoad.add(lastLoadIndex); @@ -2737,14 +2984,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not FileLog.e("tmessages", e); } } else if (which == attach_location) { - if (!isGoogleMapsInstalled()) { + if (!AndroidUtilities.isGoogleMapsInstalled(ChatActivity.this)) { return; } LocationActivity fragment = new LocationActivity(); fragment.setDelegate(new LocationActivity.LocationActivityDelegate() { @Override public void didSelectLocation(TLRPC.MessageMedia location) { - SendMessagesHelper.getInstance().sendMessage(location, dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); + SendMessagesHelper.getInstance().sendMessage(location, dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); moveScrollToLastMessage(); showReplyPanel(false, null, null, null, false, true); if (paused) { @@ -3035,7 +3282,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (mess.length() > 150) { mess = mess.substring(0, 150); } - mess = mess.replace("\n", " "); + mess = mess.replace('\n', ' '); replyObjectTextView.setText(Emoji.replaceEmoji(mess, replyObjectTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); } } else if (messageObjects != null) { @@ -3121,7 +3368,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (mess.length() > 150) { mess = mess.substring(0, 150); } - mess = mess.replace("\n", " "); + mess = mess.replace('\n', ' '); replyObjectTextView.setText(Emoji.replaceEmoji(mess, replyObjectTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); } else { replyObjectTextView.setText(LocaleController.formatPluralString("ForwardedMessage", messageObjects.size())); @@ -3153,7 +3400,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not replyObjectTextView.setText(LocaleController.getString("AttachGif", R.string.AttachGif)); } else { String name; - if ((name = FileLoader.getDocumentFileName(messageObjects.get(0).messageOwner.media.document)).length() != 0) { + if ((name = FileLoader.getDocumentFileName(messageObjects.get(0).getDocument())).length() != 0) { replyObjectTextView.setText(name); } messageObject = messageObjects.get(0); @@ -3191,7 +3438,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) replyNameTextView.getLayoutParams(); FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) replyObjectTextView.getLayoutParams(); TLRPC.PhotoSize photoSize = messageObject != null ? FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80) : null; - if (photoSize == null || messageObject.type == 13 || messageObject != null && messageObject.isSecretMedia()) { + if (photoSize == null || photoSize instanceof TLRPC.TL_photoSizeEmpty || photoSize.location instanceof TLRPC.TL_fileLocationUnavailable || messageObject.type == 13 || messageObject != null && messageObject.isSecretMedia()) { replyImageView.setImageBitmap(null); replyImageLocation = null; replyImageView.setVisibility(View.INVISIBLE); @@ -3502,52 +3749,44 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not checkActionBarMenu(); } + @Override + public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) { + if (chatActivityEnterView != null) { + chatActivityEnterView.onRequestPermissionsResultFragment(requestCode, permissions, grantResults); + } + if (mentionsAdapter != null) { + mentionsAdapter.onRequestPermissionsResultFragment(requestCode, permissions, grantResults); + } + } + private void checkActionBarMenu() { if (currentEncryptedChat != null && !(currentEncryptedChat instanceof TLRPC.TL_encryptedChat) || currentChat != null && ChatObject.isNotInChat(currentChat) || currentUser != null && UserObject.isDeleted(currentUser)) { - if (menuItem != null) { menuItem.setVisibility(View.GONE); } - if (timeItem != null) { - timeItem.setVisibility(View.GONE); - } if (timeItem2 != null) { timeItem2.setVisibility(View.GONE); } + if (avatarContainer != null) { + avatarContainer.hideTimeItem(); + } } else { if (menuItem != null) { menuItem.setVisibility(View.VISIBLE); } - if (timeItem != null) { - timeItem.setVisibility(View.VISIBLE); - } if (timeItem2 != null) { timeItem2.setVisibility(View.VISIBLE); } - } - - if (timerDrawable != null && currentEncryptedChat != null) { - timerDrawable.setTime(currentEncryptedChat.ttl); - } - - checkAndUpdateAvatar(); - } - - private int updateOnlineCount() { - onlineCount = 0; - int currentTime = ConnectionsManager.getInstance().getCurrentTime(); - if (info instanceof TLRPC.TL_chatFull || info instanceof TLRPC.TL_channelFull && info.participants_count <= 200 && info.participants != null) { - for (int a = 0; a < info.participants.participants.size(); a++) { - TLRPC.ChatParticipant participant = info.participants.participants.get(a); - TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id); - if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getClientUserId()) && user.status.expires > 10000) { - onlineCount++; - } + if (avatarContainer != null) { + avatarContainer.showTimeItem(); } } - return onlineCount; + if (avatarContainer != null && currentEncryptedChat != null) { + avatarContainer.setTime(currentEncryptedChat.ttl); + } + checkAndUpdateAvatar(); } private int getMessageType(MessageObject messageObject) { @@ -3575,52 +3814,52 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } return 1; } else { - if (!messageObject.isMediaEmpty()) { - if (messageObject.isVoice()) { - return 2; - } else if (messageObject.isSticker()) { - TLRPC.InputStickerSet inputStickerSet = messageObject.getInputStickerSet(); - if (inputStickerSet instanceof TLRPC.TL_inputStickerSetID) { - if (!StickersQuery.isStickerPackInstalled(inputStickerSet.id)) { - return 7; - } - } else if (inputStickerSet instanceof TLRPC.TL_inputStickerSetShortName) { - if (!StickersQuery.isStickerPackInstalled(inputStickerSet.short_name)) { - return 7; - } + if (messageObject.isVoice()) { + return 2; + } else if (messageObject.isSticker()) { + TLRPC.InputStickerSet inputStickerSet = messageObject.getInputStickerSet(); + if (inputStickerSet instanceof TLRPC.TL_inputStickerSetID) { + if (!StickersQuery.isStickerPackInstalled(inputStickerSet.id)) { + return 7; } - } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { - boolean canSave = false; - if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() != 0) { - File f = new File(messageObject.messageOwner.attachPath); - if (f.exists()) { - canSave = true; - } - } - if (!canSave) { - File f = FileLoader.getPathToMessage(messageObject.messageOwner); - if (f.exists()) { - canSave = true; - } - } - if (canSave) { - if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { - String mime = messageObject.messageOwner.media.document.mime_type; - if (mime != null) { - if (mime.endsWith("/xml")) { - return 5; - } else if (mime.endsWith("/png") || mime.endsWith("/jpg") || mime.endsWith("/jpeg")) { - return 6; - } - } - } - return 4; + } else if (inputStickerSet instanceof TLRPC.TL_inputStickerSetShortName) { + if (!StickersQuery.isStickerPackInstalled(inputStickerSet.short_name)) { + return 7; } } - return 2; - } else { + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto || messageObject.getDocument() != null || messageObject.isMusic() || messageObject.isVideo()) { + boolean canSave = false; + if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() != 0) { + File f = new File(messageObject.messageOwner.attachPath); + if (f.exists()) { + canSave = true; + } + } + if (!canSave) { + File f = FileLoader.getPathToMessage(messageObject.messageOwner); + if (f.exists()) { + canSave = true; + } + } + if (canSave) { + if (messageObject.getDocument() != null) { + String mime = messageObject.getDocument().mime_type; + if (mime != null) { + if (mime.endsWith("/xml")) { + return 5; + } else if (mime.endsWith("/png") || mime.endsWith("/jpg") || mime.endsWith("/jpeg")) { + return 6; + } + } + } + return 4; + } + } else if (messageObject.type == 12) { + return 8; + } else if (messageObject.isMediaEmpty()) { return 3; } + return 2; } } } else { @@ -3642,46 +3881,46 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return 1; } } else { - if (!messageObject.isMediaEmpty()) { - if (messageObject.isVoice()) { - return 2; - } else if (messageObject.isSticker()) { - TLRPC.InputStickerSet inputStickerSet = messageObject.getInputStickerSet(); - if (inputStickerSet instanceof TLRPC.TL_inputStickerSetShortName) { - if (!StickersQuery.isStickerPackInstalled(inputStickerSet.short_name)) { - return 7; - } - } - } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { - boolean canSave = false; - if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() != 0) { - File f = new File(messageObject.messageOwner.attachPath); - if (f.exists()) { - canSave = true; - } - } - if (!canSave) { - File f = FileLoader.getPathToMessage(messageObject.messageOwner); - if (f.exists()) { - canSave = true; - } - } - if (canSave) { - if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { - String mime = messageObject.messageOwner.media.document.mime_type; - if (mime != null && mime.endsWith("text/xml")) { - return 5; - } - } - if (messageObject.messageOwner.ttl <= 0) { - return 4; - } + if (messageObject.isVoice()) { + return 2; + } else if (messageObject.isSticker()) { + TLRPC.InputStickerSet inputStickerSet = messageObject.getInputStickerSet(); + if (inputStickerSet instanceof TLRPC.TL_inputStickerSetShortName) { + if (!StickersQuery.isStickerPackInstalled(inputStickerSet.short_name)) { + return 7; } } - return 2; - } else { + } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto || messageObject.getDocument() != null || messageObject.isMusic() || messageObject.isVideo()) { + boolean canSave = false; + if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() != 0) { + File f = new File(messageObject.messageOwner.attachPath); + if (f.exists()) { + canSave = true; + } + } + if (!canSave) { + File f = FileLoader.getPathToMessage(messageObject.messageOwner); + if (f.exists()) { + canSave = true; + } + } + if (canSave) { + if (messageObject.getDocument() != null) { + String mime = messageObject.getDocument().mime_type; + if (mime != null && mime.endsWith("text/xml")) { + return 5; + } + } + if (messageObject.messageOwner.ttl <= 0) { + return 4; + } + } + } else if (messageObject.type == 12) { + return 8; + } else if (messageObject.isMediaEmpty()) { return 3; } + return 2; } } } @@ -3724,7 +3963,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (replyItem.getVisibility() != newVisibility) { if (replyButtonAnimation != null) { replyButtonAnimation.cancel(); - replyButtonAnimation = null; } if (copyVisible != newCopyVisible) { if (newVisibility == View.VISIBLE) { @@ -3755,13 +3993,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not replyButtonAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (replyButtonAnimation.equals(animation)) { + if (replyButtonAnimation != null && replyButtonAnimation.equals(animation)) { replyItem.clearAnimation(); if (newVisibility == View.GONE) { replyItem.setVisibility(View.GONE); } } } + + @Override + public void onAnimationCancel(Object animation) { + if (replyButtonAnimation != null && replyButtonAnimation.equals(animation)) { + replyButtonAnimation = null; + } + } }); replyButtonAnimation.start(); } @@ -3799,20 +4044,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void updateTitle() { - if (nameTextView == null) { + if (avatarContainer == null) { return; } if (currentChat != null) { - nameTextView.setText(currentChat.title); + avatarContainer.setTitle(currentChat.title); } else if (currentUser != null) { if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) { if (currentUser.phone != null && currentUser.phone.length() != 0) { - nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone)); + avatarContainer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone)); } else { - nameTextView.setText(UserObject.getUserName(currentUser)); + avatarContainer.setTitle(UserObject.getUserName(currentUser)); } } else { - nameTextView.setText(UserObject.getUserName(currentUser)); + avatarContainer.setTitle(UserObject.getUserName(currentUser)); } } } @@ -3852,13 +4097,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void updateTitleIcons() { - if (nameTextView == null) { + if (avatarContainer == null) { return; } - int leftIcon = currentEncryptedChat != null ? R.drawable.ic_lock_header : 0; int rightIcon = MessagesController.getInstance().isDialogMuted(dialog_id) ? R.drawable.mute_fixed : 0; - nameTextView.setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, rightIcon, 0); - + avatarContainer.setTitleIcons(currentEncryptedChat != null ? R.drawable.ic_lock_header : 0, rightIcon); if (rightIcon != 0) { muteItem.setText(LocaleController.getString("UnmuteNotifications", R.string.UnmuteNotifications)); } else { @@ -3866,189 +4109,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - private void updateSubtitle() { - if (onlineTextView == null) { - return; - } - CharSequence printString = MessagesController.getInstance().printingStrings.get(dialog_id); - if (printString != null) { - printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""}); - } - if (printString == null || printString.length() == 0 || ChatObject.isChannel(currentChat) && !currentChat.megagroup) { - setTypingAnimation(false); - if (currentChat != null) { - if (ChatObject.isChannel(currentChat)) { - if (!currentChat.broadcast && !currentChat.megagroup && !(currentChat instanceof TLRPC.TL_channelForbidden)) { - onlineTextView.setText(LocaleController.getString("ShowDiscussion", R.string.ShowDiscussion)); - if (radioButton != null && radioButton.getVisibility() != View.VISIBLE) { - radioButton.setVisibility(View.VISIBLE); - onlineTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 74, 0, 0, 4)); - } - } else { - if (info != null && info.participants_count != 0) { - if (currentChat.megagroup && info.participants_count <= 200) { - if (onlineCount > 1 && info.participants_count != 0) { - onlineTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", info.participants_count), LocaleController.formatPluralString("Online", onlineCount))); - } else { - onlineTextView.setText(LocaleController.formatPluralString("Members", info.participants_count)); - } - } else { - int result[] = new int[1]; - String shortNumber = LocaleController.formatShortNumber(info.participants_count, result); - String text = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber); - onlineTextView.setText(text); - } - } else { - if (currentChat.megagroup) { - onlineTextView.setText(LocaleController.getString("Loading", R.string.Loading).toLowerCase()); - } else { - if ((currentChat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) { - onlineTextView.setText(LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase()); - } else { - onlineTextView.setText(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase()); - } - } - } - if (radioButton != null && radioButton.getVisibility() != View.GONE) { - radioButton.setVisibility(View.GONE); - onlineTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 54, 0, 0, 4)); - } - } - } else { - if (ChatObject.isKickedFromChat(currentChat)) { - onlineTextView.setText(LocaleController.getString("YouWereKicked", R.string.YouWereKicked)); - } else if (ChatObject.isLeftFromChat(currentChat)) { - onlineTextView.setText(LocaleController.getString("YouLeft", R.string.YouLeft)); - } else { - int count = currentChat.participants_count; - if (info != null) { - count = info.participants.participants.size(); - } - if (onlineCount > 1 && count != 0) { - onlineTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))); - } else { - onlineTextView.setText(LocaleController.formatPluralString("Members", count)); - } - } - } - } else if (currentUser != null) { - TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id); - if (user != null) { - currentUser = user; - } - String newStatus; - if (currentUser.id == 333000 || currentUser.id == 777000) { - newStatus = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications); - } else if (currentUser.bot) { - newStatus = LocaleController.getString("Bot", R.string.Bot); - } else { - newStatus = LocaleController.formatUserStatus(currentUser); - } - if (lastStatus == null || lastPrintString != null || !lastStatus.equals(newStatus)) { - lastStatus = newStatus; - onlineTextView.setText(newStatus); - } - } - lastPrintString = null; - } else { - lastPrintString = printString; - onlineTextView.setText(printString); - setTypingAnimation(true); - } - } - - private void setTypingAnimation(boolean start) { - if (actionBar == null) { - return; - } - if (start) { - try { - Integer type = MessagesController.getInstance().printingStringsTypes.get(dialog_id); - if (type == 0) { - if (lastStatusDrawable == 1) { - return; - } - lastStatusDrawable = 1; - if (onlineTextView != null) { - onlineTextView.setCompoundDrawablesWithIntrinsicBounds(typingDotsDrawable, null, null, null); - onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); - - typingDotsDrawable.start(); - recordStatusDrawable.stop(); - sendingFileDrawable.stop(); - } - } else if (type == 1) { - if (lastStatusDrawable == 2) { - return; - } - lastStatusDrawable = 2; - if (onlineTextView != null) { - onlineTextView.setCompoundDrawablesWithIntrinsicBounds(recordStatusDrawable, null, null, null); - onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); - - recordStatusDrawable.start(); - typingDotsDrawable.stop(); - sendingFileDrawable.stop(); - } - } else if (type == 2) { - if (lastStatusDrawable == 3) { - return; - } - lastStatusDrawable = 3; - if (onlineTextView != null) { - onlineTextView.setCompoundDrawablesWithIntrinsicBounds(sendingFileDrawable, null, null, null); - onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); - - sendingFileDrawable.start(); - typingDotsDrawable.stop(); - recordStatusDrawable.stop(); - } - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } else { - if (lastStatusDrawable == 0) { - return; - } - lastStatusDrawable = 0; - if (onlineTextView != null) { - onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); - onlineTextView.setCompoundDrawablePadding(0); - - typingDotsDrawable.stop(); - recordStatusDrawable.stop(); - sendingFileDrawable.stop(); - } - } - } - private void checkAndUpdateAvatar() { - TLRPC.FileLocation newPhoto = null; - AvatarDrawable avatarDrawable = null; if (currentUser != null) { TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id); if (user == null) { return; } currentUser = user; - if (currentUser.photo != null) { - newPhoto = currentUser.photo.photo_small; - } - avatarDrawable = new AvatarDrawable(currentUser); } else if (currentChat != null) { TLRPC.Chat chat = MessagesController.getInstance().getChat(currentChat.id); if (chat == null) { return; } currentChat = chat; - if (currentChat.photo != null) { - newPhoto = currentChat.photo.photo_small; - } - avatarDrawable = new AvatarDrawable(currentChat); } - if (avatarImageView != null) { - avatarImageView.setImage(newPhoto, "50_50", avatarDrawable); + if (avatarContainer != null) { + avatarContainer.checkAndUpdateAvatar(); } } @@ -4254,7 +4330,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not user.first_name = name; user.last_name = ""; user.phone = number; - SendMessagesHelper.getInstance().sendMessage(user, dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); + SendMessagesHelper.getInstance().sendMessage(user, dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin(), null, null); } if (sent) { showReplyPanel(false, null, null, null, false, true); @@ -4309,6 +4385,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (id == NotificationCenter.messagesDidLoaded) { int guid = (Integer) args[11]; if (guid == classGuid) { + if (!openAnimationEnded) { + NotificationCenter.getInstance().setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.chatInfoDidLoaded, NotificationCenter.dialogsNeedReload, + NotificationCenter.closeChats, NotificationCenter.botKeyboardDidLoaded/*, NotificationCenter.botInfoDidLoaded*/}); + } int queryLoadIndex = (Integer) args[12]; int index = waitingForLoad.indexOf(queryLoadIndex); if (index == -1) { @@ -4402,8 +4482,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentEncryptedChat == null) { MessagesQuery.loadReplyMessagesForMessages(messArr, dialog_id); } + int approximateHeightSum = 0; for (int a = 0; a < messArr.size(); a++) { MessageObject obj = messArr.get(a); + approximateHeightSum += obj.getApproximateHeight(); if (currentUser != null && currentUser.bot && obj.isOut()) { obj.setIsRead(); } @@ -4449,7 +4531,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not dateMsg.id = 0; MessageObject dateObj = new MessageObject(dateMsg, null, false); dateObj.type = 10; - dateObj.contentType = 4; + dateObj.contentType = 1; if (load_type == 1) { messages.add(0, dateObj); } else { @@ -4474,7 +4556,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not dateMsg.from_id = group.max_id; MessageObject dateObj = new MessageObject(dateMsg, null, false); dateObj.type = 10; - dateObj.contentType = 4; + dateObj.contentType = 1; dayArray.add(dateObj); if (load_type == 1) { messages.add(0, dateObj); @@ -4490,22 +4572,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not messages.add(messages.size() - 1, obj); } + if (obj.getId() == last_message_id) { + forwardEndReached[loadIndex] = true; + } + if (load_type == 2 && obj.getId() == first_unread_id) { - TLRPC.Message dateMsg = new TLRPC.Message(); - dateMsg.message = ""; - dateMsg.id = 0; - MessageObject dateObj = new MessageObject(dateMsg, null, false); - dateObj.contentType = dateObj.type = 6; - //boolean dateAdded = true; - //if (a != messArr.size() - 1) { - // MessageObject next = messArr.get(a + 1); - // dateAdded = !next.dateKey.equals(obj.dateKey); - //} - messages.add(messages.size() - 1, dateObj); - unreadMessageObject = dateObj; - scrollToMessage = unreadMessageObject; - scrollToMessagePosition = -10000; - newRowsCount++; + if (approximateHeightSum > AndroidUtilities.displaySize.y / 2 || !forwardEndReached[0]) { + TLRPC.Message dateMsg = new TLRPC.Message(); + dateMsg.message = ""; + dateMsg.id = 0; + MessageObject dateObj = new MessageObject(dateMsg, null, false); + dateObj.type = 6; + dateObj.contentType = 2; + messages.add(messages.size() - 1, dateObj); + unreadMessageObject = dateObj; + scrollToMessage = unreadMessageObject; + scrollToMessagePosition = -10000; + newRowsCount++; + } } else if (load_type == 3 && obj.getId() == startLoadFromMessageId) { if (needSelectFromMessageId) { highlightMessageId = obj.getId(); @@ -4518,10 +4602,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not scrollToMessagePosition = -9000; } } - - if (obj.getId() == last_message_id) { - forwardEndReached[loadIndex] = true; - } } if (forwardEndReached[loadIndex] && loadIndex != 1) { @@ -4679,7 +4759,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not progressView.setVisibility(View.INVISIBLE); } } - checkScrollForLoad(); + checkScrollForLoad(false); } } else if (id == NotificationCenter.emojiDidLoaded) { if (chatListView != null) { @@ -4688,6 +4768,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (replyObjectTextView != null) { replyObjectTextView.invalidate(); } + if (alertTextView != null) { + alertTextView.invalidate(); + } + if (pinnedMessageTextView != null) { + pinnedMessageTextView.invalidate(); + } + if (mentionListView != null) { + mentionListView.invalidateViews(); + } } else if (id == NotificationCenter.updateInterfaces) { int updateMask = (Integer) args[0]; if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) { @@ -4695,24 +4784,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } boolean updateSubtitle = false; if ((updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0 || (updateMask & MessagesController.UPDATE_MASK_STATUS) != 0) { - if (currentChat != null) { - int lastCount = onlineCount; - if (lastCount != updateOnlineCount()) { - updateSubtitle = true; - } - } else { - updateSubtitle = true; + if (currentChat != null && avatarContainer != null) { + avatarContainer.updateOnlineCount(); } + updateSubtitle = true; } if ((updateMask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_NAME) != 0) { checkAndUpdateAvatar(); updateVisibleRows(); } if ((updateMask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) { - CharSequence printString = MessagesController.getInstance().printingStrings.get(dialog_id); - if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) { - updateSubtitle = true; - } + updateSubtitle = true; } if ((updateMask & MessagesController.UPDATE_MASK_CHANNEL) != 0 && ChatObject.isChannel(currentChat)) { TLRPC.Chat chat = MessagesController.getInstance().getChat(currentChat.id); @@ -4726,8 +4808,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatActivityEnterView.setDialogId(dialog_id); } } - if (updateSubtitle) { - updateSubtitle(); + if (avatarContainer != null && updateSubtitle) { + avatarContainer.updateSubtitle(); } if ((updateMask & MessagesController.UPDATE_MASK_USER_PHONE) != 0) { updateContactStatus(); @@ -4739,7 +4821,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not boolean updateChat = false; boolean hasFromMe = false; ArrayList arr = (ArrayList) args[1]; - if (currentEncryptedChat != null && arr.size() == 1) { MessageObject obj = arr.get(0); @@ -4754,21 +4835,39 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } - if (currentChat != null) { + if (currentChat != null || inlineReturn != 0) { for (int a = 0; a < arr.size(); a++) { MessageObject messageObject = arr.get(a); - if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser && messageObject.messageOwner.action.user_id == UserConfig.getClientUserId() || - messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser && messageObject.messageOwner.action.users.contains(UserConfig.getClientUserId())) { - TLRPC.Chat newChat = MessagesController.getInstance().getChat(currentChat.id); - if (newChat != null) { - currentChat = newChat; - updateBottomOverlay(); - updateSubtitle(); + if (currentChat != null) { + if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser && messageObject.messageOwner.action.user_id == UserConfig.getClientUserId() || + messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser && messageObject.messageOwner.action.users.contains(UserConfig.getClientUserId())) { + TLRPC.Chat newChat = MessagesController.getInstance().getChat(currentChat.id); + if (newChat != null) { + currentChat = newChat; + checkActionBarMenu(); + updateBottomOverlay(); + if (avatarContainer != null) { + avatarContainer.updateSubtitle(); + } + } + } else if (messageObject.messageOwner.reply_to_msg_id != 0 && messageObject.replyMessageObject == null) { + messageObject.replyMessageObject = messagesDict[0].get(messageObject.messageOwner.reply_to_msg_id); + if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { + messageObject.generatePinMessageText(null, null); + } } - } else if (messageObject.messageOwner.reply_to_msg_id != 0 && messageObject.replyMessageObject == null) { - messageObject.replyMessageObject = messagesDict[0].get(messageObject.messageOwner.reply_to_msg_id); - if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { - messageObject.generatePinMessageText(null, null); + } else if (inlineReturn != 0) { + if (messageObject.messageOwner.reply_markup != null) { + for (int b = 0; b < messageObject.messageOwner.reply_markup.rows.size(); b++) { + TLRPC.TL_keyboardButtonRow row = messageObject.messageOwner.reply_markup.rows.get(b); + for (int c = 0; c < row.buttons.size(); c++) { + TLRPC.KeyboardButton button = row.buttons.get(c); + if (button instanceof TLRPC.TL_keyboardButtonSwitchInline) { + processSwitchButton((TLRPC.TL_keyboardButtonSwitchInline) button); + break; + } + } + } } } } @@ -4788,10 +4887,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentUser != null && currentUser.bot && obj.isOut()) { obj.setIsRead(); } - if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && - obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerDrawable != null) { - TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction; - timerDrawable.setTime(action.ttl_seconds); + if (avatarContainer != null && currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) { + avatarContainer.setTime(((TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction).ttl_seconds); } if (obj.messageOwner.action instanceof TLRPC.TL_messageActionChatMigrateTo) { final Bundle bundle = new Bundle(); @@ -4868,10 +4965,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentUser != null && currentUser.bot && obj.isOut()) { obj.setIsRead(); } - if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && - obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerDrawable != null) { - TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction; - timerDrawable.setTime(action.ttl_seconds); + if (avatarContainer != null && currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) { + avatarContainer.setTime(((TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction).ttl_seconds); } if (messagesDict[0].containsKey(obj.getId())) { continue; @@ -4941,7 +5036,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not dateMsg.id = 0; MessageObject dateObj = new MessageObject(dateMsg, null, false); dateObj.type = 10; - dateObj.contentType = 4; + dateObj.contentType = 1; messages.add(0, dateObj); addedCount++; } @@ -4960,7 +5055,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not dateMsg.message = ""; dateMsg.id = 0; MessageObject dateObj = new MessageObject(dateMsg, null, false); - dateObj.contentType = dateObj.type = 6; + dateObj.type = 6; + dateObj.contentType = 2; messages.add(0, dateObj); unreadMessageObject = dateObj; scrollToMessage = unreadMessageObject; @@ -5214,18 +5310,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not TLRPC.Message newMsgObj = (TLRPC.Message) args[2]; boolean mediaUpdated = false; try { - mediaUpdated = newMsgObj.media != null && obj.messageOwner.media != null && !newMsgObj.media.getClass().equals(obj.messageOwner.media.getClass()); + mediaUpdated = obj.messageOwner.params != null && obj.messageOwner.params.containsKey("query_id") || newMsgObj.media != null && obj.messageOwner.media != null && !newMsgObj.media.getClass().equals(obj.messageOwner.media.getClass()); } catch (Exception e) { //TODO FileLog.e("tmessages", e); } if (newMsgObj != null) { - obj.messageOwner.media = newMsgObj.media; + obj.messageOwner = newMsgObj; obj.generateThumbs(true); + obj.setType(); } messagesDict[0].remove(msgId); messagesDict[0].put(newMsgId, obj); obj.messageOwner.id = newMsgId; obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; + obj.forceUpdate = mediaUpdated; ArrayList messArr = new ArrayList<>(); messArr.add(obj); if (currentEncryptedChat == null) { @@ -5284,8 +5382,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { updatePinnedMessageView(true); } - updateOnlineCount(); - updateSubtitle(); + if (avatarContainer != null) { + avatarContainer.updateOnlineCount(); + avatarContainer.updateSubtitle(); + } if (isBroadcast) { SendMessagesHelper.getInstance().setCurrentChatInfo(info); } @@ -5369,7 +5469,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else if (id == NotificationCenter.contactsDidLoaded) { updateContactStatus(); - updateSubtitle(); + if (avatarContainer != null) { + avatarContainer.updateSubtitle(); + } } else if (id == NotificationCenter.encryptedChatUpdated) { TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) args[0]; if (currentEncryptedChat != null && chat.id == currentEncryptedChat.id) { @@ -5405,14 +5507,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int count = chatListView.getChildCount(); for (int a = 0; a < count; a++) { View view = chatListView.getChildAt(a); - if (view instanceof ChatAudioCell) { - ChatAudioCell cell = (ChatAudioCell) view; - if (cell.getMessageObject() != null) { - cell.updateButtonState(false); - } - } else if (view instanceof ChatMusicCell) { - ChatMusicCell cell = (ChatMusicCell) view; - if (cell.getMessageObject() != null) { + if (view instanceof ChatMessageCell) { + ChatMessageCell cell = (ChatMessageCell) view; + MessageObject messageObject = cell.getMessageObject(); + if (messageObject != null && (messageObject.isVoice() || messageObject.isMusic())) { cell.updateButtonState(false); } } @@ -5424,27 +5522,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int count = chatListView.getChildCount(); for (int a = 0; a < count; a++) { View view = chatListView.getChildAt(a); - if (view instanceof ChatAudioCell) { - ChatAudioCell cell = (ChatAudioCell) view; + if (view instanceof ChatMessageCell) { + ChatMessageCell cell = (ChatMessageCell) view; if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) { MessageObject playing = cell.getMessageObject(); MessageObject player = MediaController.getInstance().getPlayingMessageObject(); if (player != null) { playing.audioProgress = player.audioProgress; playing.audioProgressSec = player.audioProgressSec; - cell.updateProgress(); - } - break; - } - } else if (view instanceof ChatMusicCell) { - ChatMusicCell cell = (ChatMusicCell) view; - if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) { - MessageObject playing = cell.getMessageObject(); - MessageObject player = MediaController.getInstance().getPlayingMessageObject(); - if (player != null) { - playing.audioProgress = player.audioProgress; - playing.audioProgressSec = player.audioProgressSec; - cell.updateProgress(); + cell.updateAudioProgress(); } break; } @@ -5558,14 +5644,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int count = chatListView.getChildCount(); for (int a = 0; a < count; a++) { View view = chatListView.getChildAt(a); - if (view instanceof ChatAudioCell) { - ChatAudioCell cell = (ChatAudioCell) view; - if (cell.getMessageObject() != null) { - cell.updateButtonState(false); - } - } else if (view instanceof ChatMusicCell) { - ChatMusicCell cell = (ChatMusicCell) view; - if (cell.getMessageObject() != null) { + if (view instanceof ChatMessageCell) { + ChatMessageCell cell = (ChatMessageCell) view; + MessageObject messageObject1 = cell.getMessageObject(); + if (messageObject1 != null && (messageObject1.isVoice() || messageObject1.isMusic())) { cell.updateButtonState(false); } } @@ -5655,7 +5737,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (updated) { updateVisibleRows(); - if (chatLayoutManager.findLastVisibleItemPosition() >= messages.size() - 1) { + if (chatLayoutManager != null && chatLayoutManager.findLastVisibleItemPosition() >= messages.size() - 1) { moveScrollToLastMessage(); } } @@ -5773,6 +5855,48 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } + public boolean processSwitchButton(TLRPC.TL_keyboardButtonSwitchInline button) { + if (inlineReturn == 0) { + return false; + } + String query = "@" + currentUser.username + " " + button.query; + if (inlineReturn == dialog_id) { + inlineReturn = 0; + chatActivityEnterView.setFieldText(query); + } else { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putString("dialog_" + inlineReturn, query); + editor.commit(); + if (parentLayout.fragmentsStack.size() > 1) { + BaseFragment prevFragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2); + if (prevFragment instanceof ChatActivity && ((ChatActivity) prevFragment).dialog_id == inlineReturn) { + finishFragment(); + } else { + Bundle bundle = new Bundle(); + int lower_part = (int) inlineReturn; + int high_part = (int) (inlineReturn >> 32); + if (lower_part != 0) { + if (lower_part > 0) { + bundle.putInt("user_id", lower_part); + } else if (lower_part < 0) { + bundle.putInt("chat_id", -lower_part); + } + } else { + bundle.putInt("enc_id", high_part); + } + /*ActionBarLayout parentLayout = ChatActivity.this.parentLayout; + if (lastFragment != null) { + NotificationCenter.getInstance().removeObserver(lastFragment, NotificationCenter.closeChats); + } + NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);*/ + presentFragment(new ChatActivity(bundle), true); + } + } + } + return true; + } + private void updateSearchButtons(int mask) { if (searchUpItem != null) { searchUpItem.setEnabled((mask & 1) != 0); @@ -5784,16 +5908,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void onTransitionAnimationStart(boolean isOpen, boolean backward) { + NotificationCenter.getInstance().setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.chatInfoDidLoaded, NotificationCenter.dialogsNeedReload, + NotificationCenter.closeChats, NotificationCenter.messagesDidLoaded, NotificationCenter.botKeyboardDidLoaded/*, NotificationCenter.botInfoDidLoaded*/}); + NotificationCenter.getInstance().setAnimationInProgress(true); if (isOpen) { - NotificationCenter.getInstance().setAnimationInProgress(true); openAnimationEnded = false; } } @Override public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + NotificationCenter.getInstance().setAnimationInProgress(false); if (isOpen) { - NotificationCenter.getInstance().setAnimationInProgress(false); openAnimationEnded = true; int count = chatListView.getChildCount(); for (int a = 0; a < count; a++) { @@ -5806,6 +5932,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentUser != null) { MessagesController.getInstance().loadFullUser(currentUser, classGuid, false); } + if (Build.VERSION.SDK_INT >= 21) { + createChatAttachView(); + } } } @@ -5887,6 +6016,94 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not checkRaiseSensors(); } + public void showAlert(TLRPC.User user, String message) { + if (alertView == null || user == null || message == null) { + return; + } + + if (alertView.getTag() != null) { + alertView.setTag(null); + if (alertViewAnimator != null) { + alertViewAnimator.cancel(); + alertViewAnimator = null; + } + if (Build.VERSION.SDK_INT >= 11) { + alertView.setVisibility(View.VISIBLE); + alertViewAnimator = new AnimatorSetProxy(); + alertViewAnimator.playTogether(ObjectAnimatorProxy.ofFloat(alertView, "translationY", 0)); + alertViewAnimator.setDuration(200); + alertViewAnimator.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { + alertView.clearAnimation(); + alertViewAnimator = null; + } + } + + @Override + public void onAnimationCancel(Object animation) { + if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { + alertViewAnimator = null; + } + } + }); + alertViewAnimator.start(); + } else { + ViewProxy.setTranslationY(alertView, 0); + alertView.clearAnimation(); + alertView.setVisibility(View.VISIBLE); + } + } + alertNameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); + alertTextView.setText(Emoji.replaceEmoji(message.replace('\n', ' '), alertTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); + if (hideAlertViewRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(hideAlertViewRunnable); + } + AndroidUtilities.runOnUIThread(hideAlertViewRunnable = new Runnable() { + @Override + public void run() { + if (hideAlertViewRunnable != this) { + return; + } + if (alertView.getTag() == null) { + alertView.setTag(1); + if (alertViewAnimator != null) { + alertViewAnimator.cancel(); + alertViewAnimator = null; + } + if (Build.VERSION.SDK_INT >= 11) { + alertViewAnimator = new AnimatorSetProxy(); + alertViewAnimator.playTogether(ObjectAnimatorProxy.ofFloat(alertView, "translationY", -AndroidUtilities.dp(50))); + alertViewAnimator.setDuration(200); + alertViewAnimator.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { + alertView.clearAnimation(); + alertView.setVisibility(View.GONE); + alertViewAnimator = null; + } + } + + @Override + public void onAnimationCancel(Object animation) { + if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { + alertViewAnimator = null; + } + } + }); + alertViewAnimator.start(); + } else { + ViewProxy.setTranslationY(alertView, -AndroidUtilities.dp(50)); + alertView.clearAnimation(); + alertView.setVisibility(View.GONE); + } + } + } + }, 3000); + } + private void hidePinnedMessageView(boolean animated) { if (pinnedMessageView.getTag() == null) { pinnedMessageView.setTag(1); @@ -5981,7 +6198,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (mess.length() > 150) { mess = mess.substring(0, 150); } - mess = mess.replace("\n", " "); + mess = mess.replace('\n', ' '); pinnedMessageTextView.setText(Emoji.replaceEmoji(mess, pinnedMessageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); } } else { @@ -6034,6 +6251,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not reportSpamViewAnimator = null; } } + + @Override + public void onAnimationCancel(Object animation) { + if (reportSpamViewAnimator != null && reportSpamViewAnimator.equals(animation)) { + reportSpamViewAnimator = null; + } + } }); reportSpamViewAnimator.start(); } else { @@ -6059,6 +6283,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not reportSpamViewAnimator = null; } } + + @Override + public void onAnimationCancel(Object animation) { + if (reportSpamViewAnimator != null && reportSpamViewAnimator.equals(animation)) { + reportSpamViewAnimator = null; + } + } }); reportSpamViewAnimator.start(); } else { @@ -6191,7 +6422,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not readWhenResume = false; MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).getId(), readWithMid, readWithDate, true, false); } - checkScrollForLoad(); + checkScrollForLoad(false); if (wasPaused) { wasPaused = false; if (chatAdapter != null) { @@ -6199,7 +6430,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - fixLayout(true); + fixLayout(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); if (chatActivityEnterView.getFieldText() == null) { String lastMessageText = preferences.getString("dialog_" + dialog_id, null); @@ -6339,7 +6570,34 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MediaController.getInstance().setLastEncryptedChatParams(chatEnterTime, chatLeaveTime, currentEncryptedChat, visibleMessages); } - private void fixLayout(final boolean resume) { + private boolean fixLayoutInternal() { + if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + selectedMessagesCountTextView.setTextSize(18); + actionModeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); + } else { + selectedMessagesCountTextView.setTextSize(20); + actionModeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); + } + + if (AndroidUtilities.isTablet()) { + if (AndroidUtilities.isSmallTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { + actionBar.setBackButtonDrawable(new BackDrawable(false)); + if (playerView != null && playerView.getParent() == null) { + ((ViewGroup) fragmentView).addView(playerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); + } + } else { + actionBar.setBackButtonDrawable(new BackDrawable(parentLayout == null || parentLayout.fragmentsStack.isEmpty() || parentLayout.fragmentsStack.get(0) == ChatActivity.this || parentLayout.fragmentsStack.size() == 1)); + if (playerView != null && playerView.getParent() != null) { + fragmentView.setPadding(0, 0, 0, 0); + ((ViewGroup) fragmentView).removeView(playerView); + } + } + return false; + } + return true; + } + + private void fixLayout() { if (avatarContainer != null) { avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override @@ -6347,39 +6605,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (avatarContainer != null) { avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this); } - if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - selectedMessagesCountTextView.setTextSize(18); - actionModeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); - } else { - selectedMessagesCountTextView.setTextSize(20); - actionModeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); - } - - int padding = (ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2; - if (avatarContainer.getPaddingTop() != padding) { - avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding); - } - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams(); - if (layoutParams.topMargin != (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) { - layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); - avatarContainer.setLayoutParams(layoutParams); - } - if (AndroidUtilities.isTablet()) { - if (AndroidUtilities.isSmallTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { - actionBar.setBackButtonDrawable(new BackDrawable(false)); - if (playerView != null && playerView.getParent() == null) { - ((ViewGroup) fragmentView).addView(playerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); - } - } else { - actionBar.setBackButtonDrawable(new BackDrawable(true)); - if (playerView != null && playerView.getParent() != null) { - fragmentView.setPadding(0, 0, 0, 0); - ((ViewGroup) fragmentView).removeView(playerView); - } - } - return false; - } - return true; + return fixLayoutInternal(); } }); } @@ -6387,7 +6613,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void onConfigurationChanged(android.content.res.Configuration newConfig) { - fixLayout(false); + fixLayout(); } private void switchImportantMode(MessageObject searchBeforeMessage) { @@ -6446,8 +6672,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - radioButton.setChecked(!radioButton.isChecked(), true); - channelMessagesImportant = radioButton.isChecked() ? 1 : 2; + avatarContainer.setRadioChecked(!avatarContainer.isRadioChecked(), true); + channelMessagesImportant = avatarContainer.isRadioChecked() ? 1 : 2; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); preferences.edit().putInt("important_" + dialog_id, channelMessagesImportant).commit(); waitingForImportantLoad = true; @@ -6610,7 +6836,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return; } final int type = getMessageType(message); - if (channelMessagesImportant == 2 && message.getId() == 0 && message.contentType == 4 && message.type == 10 && message.messageOwner.from_id != 0) { + if (channelMessagesImportant == 2 && message.getId() == 0 && message.contentType == 1 && message.type == 10 && message.messageOwner.from_id != 0) { switchImportantMode(message); return; } @@ -6708,12 +6934,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not options.add(4); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); - } else if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { - if (MessageObject.isNewGifDocument(selectedObject.messageOwner.media.document)) { + } else if (selectedObject.isMusic()) { + items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic)); + options.add(10); + items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); + options.add(6); + } else if (selectedObject.getDocument() != null) { + if (MessageObject.isNewGifDocument(selectedObject.getDocument())) { items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs)); options.add(11); } - items.add(selectedObject.isMusic() ? LocaleController.getString("SaveToMusic", R.string.SaveToMusic) : LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); + items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); @@ -6729,13 +6960,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else if (type == 6) { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(7); - items.add(selectedObject.isMusic() ? LocaleController.getString("SaveToMusic", R.string.SaveToMusic) : LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); + items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers)); options.add(9); + } else if (type == 8) { + TLRPC.User user = MessagesController.getInstance().getUser(selectedObject.messageOwner.media.user_id); + if (user != null && user.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(user.id) == null) { + items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle)); + options.add(15); + } + if (selectedObject.messageOwner.media.phone_number != null || selectedObject.messageOwner.media.phone_number.length() != 0) { + items.add(LocaleController.getString("Copy", R.string.Copy)); + options.add(16); + items.add(LocaleController.getString("Call", R.string.Call)); + options.add(17); + } } items.add(LocaleController.getString("Forward", R.string.Forward)); options.add(2); @@ -6769,8 +7012,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not options.add(4); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); - } else if (!selectedObject.isVideo() && selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) { - items.add(selectedObject.isMusic() ? LocaleController.getString("SaveToMusic", R.string.SaveToMusic) : LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); + } else if (selectedObject.isMusic()) { + items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic)); + options.add(10); + items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); + options.add(6); + } else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) { + items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); @@ -6849,283 +7097,342 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (selectedObject == null) { return; } - if (option == 0) { - if (SendMessagesHelper.getInstance().retrySendMessage(selectedObject, false)) { - moveScrollToLastMessage(); - } - } else if (option == 1) { - if (getParentActivity() == null) { - selectedObject = null; - return; - } - createDeleteMessagesAlert(selectedObject); - } else if (option == 2) { - forwaringMessage = selectedObject; - Bundle args = new Bundle(); - args.putBoolean("onlySelect", true); - args.putInt("dialogsType", 1); - DialogsActivity fragment = new DialogsActivity(args); - fragment.setDelegate(this); - presentFragment(fragment); - } else if (option == 3) { - try { - CharSequence str; - if (selectedObject.type == 0 && selectedObject.messageOwner.message != null) { - str = selectedObject.messageOwner.message; - } else if (selectedObject.messageOwner.media != null && selectedObject.messageOwner.media.caption != null) { - str = selectedObject.messageOwner.media.caption; - } else { - str = selectedObject.messageText; + switch (option) { + case 0: { + if (SendMessagesHelper.getInstance().retrySendMessage(selectedObject, false)) { + moveScrollToLastMessage(); } - if (Build.VERSION.SDK_INT < 11) { - android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - clipboard.setText(str); - } else { - android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", str); - clipboard.setPrimaryClip(clip); + break; + } + case 1: { + if (getParentActivity() == null) { + selectedObject = null; + return; } - } catch (Exception e) { - FileLog.e("tmessages", e); + createDeleteMessagesAlert(selectedObject); + break; } - } else if (option == 4) { - String path = selectedObject.messageOwner.attachPath; - if (path != null && path.length() > 0) { - File temp = new File(path); - if (!temp.exists()) { - path = null; + case 2: { + forwaringMessage = selectedObject; + Bundle args = new Bundle(); + args.putBoolean("onlySelect", true); + args.putInt("dialogsType", 1); + DialogsActivity fragment = new DialogsActivity(args); + fragment.setDelegate(this); + presentFragment(fragment); + break; + } + case 3: { + try { + CharSequence str; + if (selectedObject.type == 0 && selectedObject.messageOwner.message != null) { + str = selectedObject.messageOwner.message; + } else if (selectedObject.messageOwner.media != null && selectedObject.messageOwner.media.caption != null) { + str = selectedObject.messageOwner.media.caption; + } else { + str = selectedObject.messageText; + } + if (Build.VERSION.SDK_INT < 11) { + android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + clipboard.setText(str); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", str); + clipboard.setPrimaryClip(clip); + } + } catch (Exception e) { + FileLog.e("tmessages", e); } + break; } - if (path == null || path.length() == 0) { - path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); + case 4: { + String path = selectedObject.messageOwner.attachPath; + if (path != null && path.length() > 0) { + File temp = new File(path); + if (!temp.exists()) { + path = null; + } + } + if (path == null || path.length() == 0) { + path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); + } + if (selectedObject.type == 3 || selectedObject.type == 1) { + if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4); + selectedObject = null; + return; + } + MediaController.saveFile(path, getParentActivity(), selectedObject.type == 3 ? 1 : 0, null, null); + } + break; } - if (selectedObject.type == 3 || selectedObject.type == 1) { + case 5: { + File locFile = null; + if (selectedObject.messageOwner.attachPath != null && selectedObject.messageOwner.attachPath.length() != 0) { + File f = new File(selectedObject.messageOwner.attachPath); + if (f.exists()) { + locFile = f; + } + } + if (locFile == null) { + File f = FileLoader.getPathToMessage(selectedObject.messageOwner); + if (f.exists()) { + locFile = f; + } + } + if (locFile != null) { + if (LocaleController.getInstance().applyLanguageFile(locFile)) { + presentFragment(new LanguageSelectActivity()); + } else { + if (getParentActivity() == null) { + selectedObject = null; + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setMessage(LocaleController.getString("IncorrectLocalization", R.string.IncorrectLocalization)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + showDialog(builder.create()); + } + } + break; + } + case 6: { + String path = selectedObject.messageOwner.attachPath; + if (path != null && path.length() > 0) { + File temp = new File(path); + if (!temp.exists()) { + path = null; + } + } + if (path == null || path.length() == 0) { + path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); + } + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType(selectedObject.getDocument().mime_type); + intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path))); + getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500); + break; + } + case 7: { + String path = selectedObject.messageOwner.attachPath; + if (path != null && path.length() > 0) { + File temp = new File(path); + if (!temp.exists()) { + path = null; + } + } + if (path == null || path.length() == 0) { + path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); + } if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4); selectedObject = null; return; } - MediaController.saveFile(path, getParentActivity(), selectedObject.type == 3 ? 1 : 0, null); + MediaController.saveFile(path, getParentActivity(), 0, null, null); + break; } - } else if (option == 5) { - File locFile = null; - if (selectedObject.messageOwner.attachPath != null && selectedObject.messageOwner.attachPath.length() != 0) { - File f = new File(selectedObject.messageOwner.attachPath); - if (f.exists()) { - locFile = f; + case 8: { + showReplyPanel(true, selectedObject, null, null, false, true); + break; + } + case 9: { + showDialog(new StickersAlert(getParentActivity(), selectedObject.getInputStickerSet(), null, bottomOverlayChat.getVisibility() != View.VISIBLE ? chatActivityEnterView : null)); + break; + } + case 10: { + if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4); + selectedObject = null; + return; } - } - if (locFile == null) { - File f = FileLoader.getPathToMessage(selectedObject.messageOwner); - if (f.exists()) { - locFile = f; + String fileName = FileLoader.getDocumentFileName(selectedObject.getDocument()); + if (fileName == null || fileName.length() == 0) { + fileName = selectedObject.getFileName(); } - } - if (locFile != null) { - if (LocaleController.getInstance().applyLanguageFile(locFile)) { - presentFragment(new LanguageSelectActivity()); - } else { - if (getParentActivity() == null) { - selectedObject = null; - return; + String path = selectedObject.messageOwner.attachPath; + if (path != null && path.length() > 0) { + File temp = new File(path); + if (!temp.exists()) { + path = null; } - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setMessage(LocaleController.getString("IncorrectLocalization", R.string.IncorrectLocalization)); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); - showDialog(builder.create()); } - } - } else if (option == 6) { - String path = selectedObject.messageOwner.attachPath; - if (path != null && path.length() > 0) { - File temp = new File(path); - if (!temp.exists()) { - path = null; + if (path == null || path.length() == 0) { + path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); } + MediaController.saveFile(path, getParentActivity(), selectedObject.isMusic() ? 3 : 2, fileName, selectedObject.getDocument() != null ? selectedObject.getDocument().mime_type : ""); + break; } - if (path == null || path.length() == 0) { - path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); + case 11: { + MediaController.SearchImage searchImage = MessagesController.getInstance().saveGif(selectedObject.getDocument()); + showGifHint(); + chatActivityEnterView.addRecentGif(searchImage); + break; } - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType(selectedObject.messageOwner.media.document.mime_type); - intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path))); - getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500); - } else if (option == 7) { - String path = selectedObject.messageOwner.attachPath; - if (path != null && path.length() > 0) { - File temp = new File(path); - if (!temp.exists()) { - path = null; + case 12: { + if (getParentActivity() == null) { + selectedObject = null; + return; } - } - if (path == null || path.length() == 0) { - path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); - } - if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4); - selectedObject = null; - return; - } - MediaController.saveFile(path, getParentActivity(), 0, null); - } else if (option == 8) { - showReplyPanel(true, selectedObject, null, null, false, true); - } else if (option == 9) { - StickersQuery.loadStickers(this, selectedObject.getInputStickerSet()); - } else if (option == 10) { - if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4); - selectedObject = null; - return; - } - String fileName = FileLoader.getDocumentFileName(selectedObject.messageOwner.media.document); - if (fileName == null || fileName.length() == 0) { - fileName = selectedObject.getFileName(); - } - String path = selectedObject.messageOwner.attachPath; - if (path != null && path.length() > 0) { - File temp = new File(path); - if (!temp.exists()) { - path = null; - } - } - if (path == null || path.length() == 0) { - path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); - } - MediaController.saveFile(path, getParentActivity(), selectedObject.isMusic() ? 3 : 2, fileName); - } else if (option == 11) { - MediaController.SearchImage searchImage; - if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) { - searchImage = MessagesController.getInstance().saveGif(selectedObject.messageOwner.media.webpage.document); - } else { - searchImage = MessagesController.getInstance().saveGif(selectedObject.messageOwner.media.document); - } - showGifHint(); - chatActivityEnterView.addRecentGif(searchImage); - } else if (option == 12) { - if (getParentActivity() == null) { - selectedObject = null; - return; - } - final MessageObject editingMessageObject = selectedObject; - final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); - progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); - progressDialog.setCanceledOnTouchOutside(false); - progressDialog.setCancelable(false); + final MessageObject editingMessageObject = selectedObject; + final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); + progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); + progressDialog.setCanceledOnTouchOutside(false); + progressDialog.setCancelable(false); - TLRPC.TL_channels_getMessageEditData req = new TLRPC.TL_channels_getMessageEditData(); - req.channel = MessagesController.getInputChannel(currentChat); - req.id = selectedObject.getId(); - final int reqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(final TLObject response, TLRPC.TL_error error) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - try { - if (!getParentActivity().isFinishing()) { - progressDialog.dismiss(); + TLRPC.TL_messages_getMessageEditData req = new TLRPC.TL_messages_getMessageEditData(); + req.peer = MessagesController.getInputPeer((int) dialog_id); + req.id = selectedObject.getId(); + final int reqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(final TLObject response, TLRPC.TL_error error) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + try { + if (!getParentActivity().isFinishing()) { + progressDialog.dismiss(); + } + } catch (Exception e) { + FileLog.e("tmessages", e); } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - if (response != null) { - TLRPC.TL_channels_messageEditData res = (TLRPC.TL_channels_messageEditData) response; - if (mentionsAdapter != null) { - mentionsAdapter.setNeedBotContext(false); - chatListView.setOnItemLongClickListener(null); - chatListView.setOnItemClickListener(null); - chatListView.setClickable(false); - chatListView.setLongClickable(false); - chatActivityEnterView.setEditinigMessageObject(editingMessageObject, res.caption); - actionModeTextView.setVisibility(View.VISIBLE); - selectedMessagesCountTextView.setVisibility(View.GONE); + if (response != null) { + TLRPC.TL_messages_messageEditData res = (TLRPC.TL_messages_messageEditData) response; + if (mentionsAdapter != null) { + mentionsAdapter.setNeedBotContext(false); + chatListView.setOnItemLongClickListener(null); + chatListView.setOnItemClickListener(null); + chatListView.setClickable(false); + chatListView.setLongClickable(false); + chatActivityEnterView.setEditinigMessageObject(editingMessageObject, res.caption); + actionModeTextView.setVisibility(View.VISIBLE); + selectedMessagesCountTextView.setVisibility(View.GONE); - chatActivityEnterView.setAllowStickersAndGifs(false, false); - final ActionBarMenu actionMode = actionBar.createActionMode(); - actionMode.getItem(reply).setVisibility(View.GONE); - actionMode.getItem(copy).setVisibility(View.GONE); - actionMode.getItem(forward).setVisibility(View.GONE); - actionMode.getItem(delete).setVisibility(View.GONE); - actionMode.getItem(edit_done).setVisibility(View.VISIBLE); - actionBar.showActionMode(); - updatePinnedMessageView(true); + chatActivityEnterView.setAllowStickersAndGifs(false, false); + final ActionBarMenu actionMode = actionBar.createActionMode(); + actionMode.getItem(reply).setVisibility(View.GONE); + actionMode.getItem(copy).setVisibility(View.GONE); + actionMode.getItem(forward).setVisibility(View.GONE); + actionMode.getItem(delete).setVisibility(View.GONE); + actionMode.getItem(edit_done).setVisibility(View.VISIBLE); + actionBar.showActionMode(); + updatePinnedMessageView(true); + } + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setMessage(LocaleController.getString("EditMessageError", R.string.EditMessageError)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + showDialog(builder.create()); } - } else { - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setMessage(LocaleController.getString("EditMessageError", R.string.EditMessageError)); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); - showDialog(builder.create()); } + }); + } + }); + progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + ConnectionsManager.getInstance().cancelRequest(reqId, true); + try { + dialog.dismiss(); + } catch (Exception e) { + FileLog.e("tmessages", e); } - }); - } - }); - progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - ConnectionsManager.getInstance().cancelRequest(reqId, true); - try { - dialog.dismiss(); - } catch (Exception e) { - FileLog.e("tmessages", e); } + }); + try { + progressDialog.show(); + } catch (Exception e) { + //don't promt } - }); - try { - progressDialog.show(); - } catch (Exception e) { - //don't promt + break; } - } else if (option == 13) { - final int mid = selectedObject.getId(); - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage(LocaleController.getString("PinMessageAlert", R.string.PinMessageAlert)); + case 13: { + final int mid = selectedObject.getId(); + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setMessage(LocaleController.getString("PinMessageAlert", R.string.PinMessageAlert)); - final boolean[] checks = new boolean[]{true}; - FrameLayout frameLayout = new FrameLayout(getParentActivity()); - if (Build.VERSION.SDK_INT >= 21) { - frameLayout.setPadding(0, AndroidUtilities.dp(8), 0, 0); + final boolean[] checks = new boolean[]{true}; + FrameLayout frameLayout = new FrameLayout(getParentActivity()); + if (Build.VERSION.SDK_INT >= 21) { + frameLayout.setPadding(0, AndroidUtilities.dp(8), 0, 0); + } + CheckBoxCell cell = new CheckBoxCell(getParentActivity()); + cell.setBackgroundResource(R.drawable.list_selector); + if (Build.VERSION.SDK_INT < 11) { + cell.setTextColor(0xffffffff); + } + cell.setText(LocaleController.getString("PinNotify", R.string.PinNotify), "", true, false); + cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(8) : 0, 0, LocaleController.isRTL ? 0 : AndroidUtilities.dp(8), 0); + frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 8, 0, 8, 0)); + cell.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CheckBoxCell cell = (CheckBoxCell) v; + checks[0] = !checks[0]; + cell.setChecked(checks[0], true); + } + }); + builder.setView(frameLayout); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + MessagesController.getInstance().pinChannelMessage(currentChat, mid, checks[0]); + } + }); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showDialog(builder.create()); + break; } - CheckBoxCell cell = new CheckBoxCell(getParentActivity()); - cell.setBackgroundResource(R.drawable.list_selector); - if (Build.VERSION.SDK_INT < 11) { - cell.setTextColor(0xffffffff); + case 14: { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setMessage(LocaleController.getString("UnpinMessageAlert", R.string.UnpinMessageAlert)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + MessagesController.getInstance().pinChannelMessage(currentChat, 0, false); + } + }); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showDialog(builder.create()); + break; } - cell.setText(LocaleController.getString("PinNotify", R.string.PinNotify), "", true, false); - cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(8) : 0, 0, LocaleController.isRTL ? 0 : AndroidUtilities.dp(8), 0); - frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 8, 0, 8, 0)); - cell.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - CheckBoxCell cell = (CheckBoxCell) v; - checks[0] = !checks[0]; - cell.setChecked(checks[0], true); + case 15: { + Bundle args = new Bundle(); + args.putInt("user_id", selectedObject.messageOwner.media.user_id); + args.putString("phone", selectedObject.messageOwner.media.phone_number); + args.putBoolean("addContact", true); + presentFragment(new ContactAddActivity(args)); + break; + } + case 16: { + try { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { + android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + clipboard.setText(selectedObject.messageOwner.media.phone_number); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", selectedObject.messageOwner.media.phone_number); + clipboard.setPrimaryClip(clip); + } + } catch (Exception e) { + FileLog.e("tmessages", e); } - }); - builder.setView(frameLayout); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - MessagesController.getInstance().pinChannelMessage(currentChat, mid, checks[0]); + break; + } + case 17: { + try { + Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + selectedObject.messageOwner.media.phone_number)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + getParentActivity().startActivityForResult(intent, 500); + } catch (Exception e) { + FileLog.e("tmessages", e); } - }); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); - showDialog(builder.create()); - } else if (option == 14) { - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage(LocaleController.getString("UnpinMessageAlert", R.string.UnpinMessageAlert)); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - MessagesController.getInstance().pinChannelMessage(currentChat, 0, false); - } - }); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); - showDialog(builder.create()); + break; + } } selectedObject = null; } @@ -7215,34 +7522,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return true; } - public boolean isGoogleMapsInstalled() { - try { - ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0); - return true; - } catch (PackageManager.NameNotFoundException e) { - if (getParentActivity() == null) { - return false; - } - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage("Install Google Maps?"); - builder.setCancelable(true); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - try { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps")); - getParentActivity().startActivityForResult(intent, 500); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - }); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); - showDialog(builder.create()); - return false; - } - } - private void updateVisibleRows() { if (chatListView == null) { return; @@ -7304,7 +7583,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (message.type == 3) { builder.setMessage(LocaleController.getString("NoPlayerInstalled", R.string.NoPlayerInstalled)); } else { - builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, message.messageOwner.media.document.mime_type)); + builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, message.getDocument().mime_type)); } showDialog(builder.create()); } @@ -7337,6 +7616,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return currentEncryptedChat != null; } + public TLRPC.User getCurrentUser() { + return currentUser; + } + + public TLRPC.Chat getCurrentChat() { + return currentChat; + } + + public TLRPC.EncryptedChat getCurrentEncryptedChat() { + return currentEncryptedChat; + } + + public TLRPC.ChatFull getCurrentChatInfo() { + return info; + } + @Override public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (messageObject == null) { @@ -7419,6 +7714,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return 0; } + public void showOpenUrlAlert(final String url) { + if (Browser.isInternalUrl(url)) { + Browser.openUrl(getParentActivity(), url, inlineReturn == 0); + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, url)); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + Browser.openUrl(getParentActivity(), url, inlineReturn == 0); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showDialog(builder.create()); + } + } + public class ChatActivityAdapter extends RecyclerView.Adapter { private Context mContext; @@ -7491,49 +7804,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { view = new ChatMessageCell(mContext); } - } else if (viewType == 2) { - view = new ChatAudioCell(mContext); - ((ChatAudioCell) view).setAudioDelegate(new ChatAudioCell.ChatAudioCellDelegate() { - @Override - public boolean needPlayAudio(MessageObject messageObject) { - boolean result = MediaController.getInstance().playAudio(messageObject); - MediaController.getInstance().setVoiceMessagesPlaylist(result ? createVoiceMessagesPlaylist(messageObject, false) : null, false); - return result; - } - }); - } else if (viewType == 3) { - view = new ChatContactCell(mContext); - } else if (viewType == 4) { - view = new ChatActionCell(mContext); - } else if (viewType == 5) { - view = new ChatLoadingCell(mContext); - } else if (viewType == 6) { - view = new ChatUnreadCell(mContext); - } else if (viewType == 7) { - view = new BotHelpCell(mContext); - ((BotHelpCell) view).setDelegate(new BotHelpCell.BotHelpCellDelegate() { - @Override - public void didPressUrl(String url) { - if (url.startsWith("@")) { - MessagesController.openByUserName(url.substring(1), ChatActivity.this, 0); - } else if (url.startsWith("#")) { - DialogsActivity fragment = new DialogsActivity(null); - fragment.setSearchString(url); - presentFragment(fragment); - } else if (url.startsWith("/")) { - chatActivityEnterView.setCommand(null, url, false, false); - } - } - }); - } else if (viewType == 8) { - view = new ChatMusicCell(mContext); - } - - if (view instanceof ChatBaseCell) { - if (currentEncryptedChat == null) { - ((ChatBaseCell) view).setAllowAssistant(true); - } - ((ChatBaseCell) view).setDelegate(new ChatBaseCell.ChatBaseCellDelegate() { + ChatMessageCell chatMessageCell = (ChatMessageCell) view; + chatMessageCell.setDelegate(new ChatBaseCell.ChatBaseCellDelegate() { @Override public void didPressedShare(ChatBaseCell cell) { if (getParentActivity() == null) { @@ -7542,10 +7814,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (chatActivityEnterView != null) { chatActivityEnterView.closeKeyboard(); } - BottomSheet.Builder builder = new BottomSheet.Builder(mContext, true); - builder.setCustomView(new ShareFrameLayout(mContext, builder.create(), cell.getMessageObject(), ChatObject.isChannel(currentChat) && !currentChat.megagroup && currentChat.username != null && currentChat.username.length() > 0)).setApplyTopPaddings(false); - builder.setUseFullWidth(false); - showDialog(builder.create()); + showDialog(new ShareAlert(mContext, cell.getMessageObject(), ChatObject.isChannel(currentChat) && !currentChat.megagroup && currentChat.username != null && currentChat.username.length() > 0)); + } + + @Override + public boolean needPlayAudio(MessageObject messageObject) { + if (messageObject.isVoice()) { + boolean result = MediaController.getInstance().playAudio(messageObject); + MediaController.getInstance().setVoiceMessagesPlaylist(result ? createVoiceMessagesPlaylist(messageObject, false) : null, false); + return result; + } else if (messageObject.isMusic()) { + return MediaController.getInstance().setPlaylist(messages, messageObject); + } + return false; } @Override @@ -7586,6 +7867,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } + @Override + public void didPressedBotButton(ChatBaseCell cell, TLRPC.KeyboardButton button) { + if (getParentActivity() == null || bottomOverlayChat.getVisibility() == View.VISIBLE && !(button instanceof TLRPC.TL_keyboardButtonCallback) && !(button instanceof TLRPC.TL_keyboardButtonUrl)) { + return; + } + chatActivityEnterView.didPressedBotButton(button, cell.getMessageObject(), cell.getMessageObject()); + } + @Override public void didPressedCancelSendButton(ChatBaseCell cell) { MessageObject message = cell.getMessageObject(); @@ -7635,7 +7924,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void onClick(DialogInterface dialog, final int which) { if (which == 0) { - AndroidUtilities.openUrl(getParentActivity(), urlFinal); + Browser.openUrl(getParentActivity(), urlFinal, inlineReturn == 0); } else if (which == 1) { try { if (Build.VERSION.SDK_INT < 11) { @@ -7656,23 +7945,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not showDialog(builder.create()); } else { if (url instanceof URLSpanReplacement) { - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, ((URLSpanReplacement) url).getURL())); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - try { - AndroidUtilities.openUrl(getParentActivity(), urlFinal); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - }); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); - showDialog(builder.create()); + showOpenUrlAlert(((URLSpanReplacement) url).getURL()); } else if (url instanceof URLSpan) { - AndroidUtilities.openUrl(getParentActivity(), urlFinal); + Browser.openUrl(getParentActivity(), urlFinal, inlineReturn == 0); } else { url.onClick(fragmentView); } @@ -7681,9 +7956,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } @Override - public void needOpenWebView(String url, String title, String originalUrl, int w, int h) { + public void needOpenWebView(String url, String title, String description, String originalUrl, int w, int h) { BottomSheet.Builder builder = new BottomSheet.Builder(mContext); - builder.setCustomView(new WebFrameLayout(mContext, builder.create(), title, originalUrl, url, w, h)); + builder.setCustomView(new WebFrameLayout(mContext, builder.create(), title, description, originalUrl, url, w, h)); builder.setUseFullWidth(true); showDialog(builder.create()); } @@ -7693,7 +7968,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessageObject messageObject = cell.getMessageObject(); if (messageObject.replyMessageObject != null && !messageObject.replyMessageObject.isImportant() && channelMessagesImportant == 2) { channelMessagesImportant = 1; - radioButton.setChecked(channelMessagesImportant == 1, false); + avatarContainer.setRadioChecked(true, false); } scrollToMessageId(id, messageObject.getId(), true, messageObject.getDialogId() == mergeDialogId ? 1 : 0); } @@ -7718,7 +7993,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else if (message.isSending()) { return; } - if (message.type == 1 || message.type == 0 && !message.isWebpageDocument()) { + if (message.type == 13) { + showDialog(new StickersAlert(getParentActivity(), message.getInputStickerSet(), null, bottomOverlayChat.getVisibility() != View.VISIBLE ? chatActivityEnterView : null)); + } else if (message.type == 1 || message.type == 0 && !message.isWebpageDocument()) { PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(message, message.type != 0 ? dialog_id : 0, message.type != 0 ? mergeDialogId : 0, ChatActivity.this); } else if (message.type == 3) { @@ -7738,7 +8015,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not alertUserOpenError(message); } } else if (message.type == 4) { - if (!isGoogleMapsInstalled()) { + if (!AndroidUtilities.isGoogleMapsInstalled(ChatActivity.this)) { return; } LocationActivity fragment = new LocationActivity(); @@ -7758,15 +8035,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not try { Intent intent = new Intent(Intent.ACTION_VIEW); MimeTypeMap myMime = MimeTypeMap.getSingleton(); - int idx = fileName.lastIndexOf("."); + int idx = fileName.lastIndexOf('.'); if (idx != -1) { String ext = fileName.substring(idx + 1); realMimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); if (realMimeType == null) { - if (message.type == 9) { - realMimeType = message.messageOwner.media.document.mime_type; - } else if (message.type == 0) { - realMimeType = message.messageOwner.media.webpage.document.mime_type; + if (message.type == 9 || message.type == 0) { + realMimeType = message.getDocument().mime_type; } if (realMimeType == null || realMimeType.length() == 0) { realMimeType = null; @@ -7797,75 +8072,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } }); - if (view instanceof ChatMessageCell) { - ((ChatMessageCell) view).setAllowedToSetPhoto(openAnimationEnded); - } else if (view instanceof ChatContactCell) { - ((ChatContactCell) view).setContactDelegate(new ChatContactCell.ChatContactCellDelegate() { - @Override - public void didClickAddButton(ChatContactCell cell, TLRPC.User user) { - if (actionBar.isActionModeShowed()) { - processRowSelect(cell); - return; - } - MessageObject messageObject = cell.getMessageObject(); - Bundle args = new Bundle(); - args.putInt("user_id", messageObject.messageOwner.media.user_id); - args.putString("phone", messageObject.messageOwner.media.phone_number); - args.putBoolean("addContact", true); - presentFragment(new ContactAddActivity(args)); - } - - @Override - public void didClickPhone(ChatContactCell cell) { - if (actionBar.isActionModeShowed()) { - processRowSelect(cell); - return; - } - final MessageObject messageObject = cell.getMessageObject(); - if (getParentActivity() == null || messageObject.messageOwner.media.phone_number == null || messageObject.messageOwner.media.phone_number.length() == 0) { - return; - } - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 1) { - try { - Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + messageObject.messageOwner.media.phone_number)); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - getParentActivity().startActivityForResult(intent, 500); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } else if (i == 0) { - try { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - clipboard.setText(messageObject.messageOwner.media.phone_number); - } else { - android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", messageObject.messageOwner.media.phone_number); - clipboard.setPrimaryClip(clip); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - } - } - ); - showDialog(builder.create()); - } - }); - } else if (view instanceof ChatMusicCell) { - ((ChatMusicCell) view).setMusicDelegate(new ChatMusicCell.ChatMusicCellDelegate() { - @Override - public boolean needPlayMusic(MessageObject messageObject) { - return MediaController.getInstance().setPlaylist(messages, messageObject); - } - }); + chatMessageCell.setAllowedToSetPhoto(openAnimationEnded); + if (currentEncryptedChat == null) { + chatMessageCell.setAllowAssistant(true); } - } else if (view instanceof ChatActionCell) { + } else if (viewType == 1) { + view = new ChatActionCell(mContext); ((ChatActionCell) view).setDelegate(new ChatActionCell.ChatActionCellDelegate() { @Override public void didClickedImage(ChatActionCell cell) { @@ -7899,6 +8111,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } }); + } else if (viewType == 2) { + view = new ChatUnreadCell(mContext); + } else if (viewType == 3) { + view = new BotHelpCell(mContext); + ((BotHelpCell) view).setDelegate(new BotHelpCell.BotHelpCellDelegate() { + @Override + public void didPressUrl(String url) { + if (url.startsWith("@")) { + MessagesController.openByUserName(url.substring(1), ChatActivity.this, 0); + } else if (url.startsWith("#")) { + DialogsActivity fragment = new DialogsActivity(null); + fragment.setSearchString(url); + presentFragment(fragment); + } else if (url.startsWith("/")) { + chatActivityEnterView.setCommand(null, url, false, false); + } + } + }); + } else if (viewType == 4) { + view = new ChatLoadingCell(mContext); } view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT)); return new Holder(view); @@ -7930,15 +8162,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not view.setBackgroundColor(0); } - if (view instanceof ChatBaseCell) { - ChatBaseCell baseCell = (ChatBaseCell) view; - baseCell.isChat = currentChat != null; - baseCell.setMessageObject(message); - baseCell.setCheckPressed(!disableSelection, disableSelection && selected); - if (view instanceof ChatAudioCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) { - ((ChatAudioCell) view).downloadAudioIfNeed(); + if (view instanceof ChatMessageCell) { + ChatMessageCell messageCell = (ChatMessageCell) view; + messageCell.isChat = currentChat != null; + messageCell.setMessageObject(message); + messageCell.setCheckPressed(!disableSelection, disableSelection && selected); + if (view instanceof ChatMessageCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) { + ((ChatMessageCell) view).downloadAudioIfNeed(); } - baseCell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && message.getId() == highlightMessageId); + messageCell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && message.getId() == highlightMessageId); } else if (view instanceof ChatActionCell) { ChatActionCell actionCell = (ChatActionCell) view; actionCell.setMessageObject(message); @@ -7951,22 +8183,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public int getItemViewType(int position) { - if (position == loadingUpRow || position == loadingDownRow) { - return 5; - } else if (position == botInfoRow) { - return 7; - } else if (position >= messagesStartRow && position < messagesEndRow) { + if (position >= messagesStartRow && position < messagesEndRow) { return messages.get(messages.size() - (position - messagesStartRow) - 1).contentType; + } else if (position == botInfoRow) { + return 3; } - return 5; + return 4; } @Override public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { - if (holder.itemView instanceof ChatBaseCell) { - ChatBaseCell baseCell = (ChatBaseCell) holder.itemView; - baseCell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && baseCell.getMessageObject().getId() == highlightMessageId); - } if (holder.itemView instanceof ChatMessageCell) { final ChatMessageCell messageCell = (ChatMessageCell) holder.itemView; messageCell.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @@ -7978,6 +8204,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return true; } }); + messageCell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && messageCell.getMessageObject().getId() == highlightMessageId); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java index ed2c6c4cf..c9c17d729 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java @@ -16,7 +16,6 @@ import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; -import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; @@ -161,7 +160,7 @@ public class AlertsCreator { builder.setNegativeButton(LocaleController.getString("MoreInfo", R.string.MoreInfo), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - AndroidUtilities.openUrl(fragment.getParentActivity(), LocaleController.getString("NobodyLikesSpamUrl", R.string.NobodyLikesSpamUrl)); + MessagesController.openByUserName("spambot", fragment, 1); } }); break; @@ -212,6 +211,12 @@ public class AlertsCreator { case "USERS_TOO_FEW": builder.setMessage(LocaleController.getString("CreateGroupError", R.string.CreateGroupError)); break; + case "USER_RESTRICTED": + builder.setMessage(LocaleController.getString("UserRestricted", R.string.UserRestricted)); + break; + default: + builder.setMessage(error); + break; } builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); fragment.showDialog(builder.create(), true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java index 098a000a9..649694d7e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java @@ -9,9 +9,14 @@ package org.telegram.ui.Components; import android.graphics.Bitmap; +import android.graphics.BitmapShader; import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Rect; +import android.graphics.RectF; +import android.graphics.Shader; import android.graphics.drawable.Animatable; import android.graphics.drawable.BitmapDrawable; import android.os.Handler; @@ -43,8 +48,17 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable { private boolean decoderCreated; private File path; - private float scaleX = 1f; - private float scaleY = 1f; + private BitmapShader renderingShader; + private BitmapShader nextRenderingShader; + private BitmapShader backgroundShader; + + private int roundRadius; + private RectF roundRect = new RectF(); + private RectF bitmapRect = new RectF(); + private Matrix shaderMatrix = new Matrix(); + + private float scaleX = 1.0f; + private float scaleY = 1.0f; private boolean applyTransformation; private final android.graphics.Rect dstRect = new android.graphics.Rect(); private static final Handler uiHandler = new Handler(Looper.getMainLooper()); @@ -74,11 +88,13 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable { if (nativePtr == 0) { if (backgroundBitmap != null) { backgroundBitmap.recycle(); + backgroundBitmap = null; } return; } loadFrameTask = null; nextRenderingBitmap = backgroundBitmap; + nextRenderingShader = backgroundShader; if (metaData[2] < lastTimeStamp) { lastTimeStamp = 0; } @@ -107,11 +123,11 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable { } catch (Throwable e) { FileLog.e("tmessages", e); } + if (backgroundShader == null && backgroundBitmap != null && roundRadius != 0) { + backgroundShader = new BitmapShader(backgroundBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + } } if (backgroundBitmap != null) { - /*if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 21) { - Utilities.unpinBitmap(backgroundBitmap); - }*/ getVideoFrame(nativePtr, backgroundBitmap, metaData); } } catch (Throwable e) { @@ -197,12 +213,12 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable { } isRunning = true; if (renderingBitmap == null) { - scheduleNextGetFrame(renderingBitmap); + scheduleNextGetFrame(); } runOnUiThread(mStartTask); } - private void scheduleNextGetFrame(Bitmap bitmap) { + private void scheduleNextGetFrame() { if (loadFrameTask != null || nativePtr == 0 && decoderCreated || destroyWhenDone) { return; } @@ -242,12 +258,14 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable { } if (isRunning) { if (renderingBitmap == null && nextRenderingBitmap == null) { - scheduleNextGetFrame(renderingBitmap); + scheduleNextGetFrame(); } else if (Math.abs(System.currentTimeMillis() - lastFrameTime) >= invalidateAfter) { if (nextRenderingBitmap != null) { - scheduleNextGetFrame(renderingBitmap); + scheduleNextGetFrame(); renderingBitmap = nextRenderingBitmap; + renderingShader = nextRenderingShader; nextRenderingBitmap = null; + nextRenderingShader = null; lastFrameTime = System.currentTimeMillis(); } } @@ -260,9 +278,33 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable { scaleY = (float) dstRect.height() / renderingBitmap.getHeight(); applyTransformation = false; } - canvas.translate(dstRect.left, dstRect.top); - canvas.scale(scaleX, scaleY); - canvas.drawBitmap(renderingBitmap, 0, 0, getPaint()); + if (roundRadius != 0) { + int bitmapW = renderingBitmap.getWidth(); + int bitmapH = renderingBitmap.getHeight(); + float scale = Math.max(scaleX, scaleY); + + if (renderingShader == null) { + renderingShader = new BitmapShader(backgroundBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + } + getPaint().setShader(renderingShader); + roundRect.set(dstRect); + shaderMatrix.reset(); + if (Math.abs(scaleX - scaleY) > 0.00001f) { + int w = (int) Math.floor(dstRect.width() / scale); + int h = (int) Math.floor(dstRect.height() / scale); + bitmapRect.set((bitmapW - w) / 2, (bitmapH - h) / 2, w, h); + shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.START); + } else { + bitmapRect.set(0, 0, renderingBitmap.getWidth(), renderingBitmap.getHeight()); + shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL); + } + renderingShader.setLocalMatrix(shaderMatrix); + canvas.drawRoundRect(roundRect, roundRadius, roundRadius, getPaint()); + } else { + canvas.translate(dstRect.left, dstRect.top); + canvas.scale(scaleX, scaleY); + canvas.drawBitmap(renderingBitmap, 0, 0, getPaint()); + } if (isRunning) { uiHandler.postDelayed(mInvalidateTask, invalidateAfter); } @@ -288,6 +330,11 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable { return null; } + public void setRoundRadius(int value) { + roundRadius = value; + getPaint().setFlags(Paint.ANTI_ALIAS_FLAG); + } + public boolean hasBitmap() { return nativePtr != 0 && (renderingBitmap != null || nextRenderingBitmap != null); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java index 22694ce13..cd1f12515 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java @@ -24,6 +24,7 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.R; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.ApplicationLoader; +import org.telegram.ui.ActionBar.Theme; public class AvatarDrawable extends Drawable { @@ -31,12 +32,12 @@ public class AvatarDrawable extends Drawable { private static TextPaint namePaint; private static TextPaint namePaintSmall; private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xff8e85ee, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a}; - private static int[] arrColorsProfiles = {0xffd86f65, 0xfff69d61, 0xff8c79d2, 0xff67b35d, 0xff56a2bb, 0xff5c98cd, 0xff8c79d2, 0xfff37fa6}; - private static int[] arrColorsProfilesBack = {0xffca6056, 0xfff18944, 0xff7d6ac4, 0xff56a14c, 0xff4492ac, 0xff4c84b6, 0xff7d6ac4, 0xff4c84b6}; - private static int[] arrColorsProfilesText = {0xfff9cbc5, 0xfffdddc8, 0xffcdc4ed, 0xffc0edba, 0xffb8e2f0, 0xffb3d7f7, 0xffcdc4ed, 0xffb3d7f7}; + private static int[] arrColorsProfiles = {0xffd86f65, 0xfff69d61, 0xff8c79d2, 0xff67b35d, 0xff56a2bb, Theme.ACTION_BAR_MAIN_AVATAR_COLOR, 0xff8c79d2, 0xfff37fa6}; + private static int[] arrColorsProfilesBack = {0xffca6056, 0xfff18944, 0xff7d6ac4, 0xff56a14c, 0xff4492ac, Theme.ACTION_BAR_PROFILE_COLOR, 0xff7d6ac4, 0xff4c84b6}; + private static int[] arrColorsProfilesText = {0xfff9cbc5, 0xfffdddc8, 0xffcdc4ed, 0xffc0edba, 0xffb8e2f0, Theme.ACTION_BAR_PROFILE_SUBTITLE_COLOR, 0xffcdc4ed, 0xffb3d7f7}; private static int[] arrColorsNames = {0xffca5650, 0xffd87b29, 0xff4e92cc, 0xff50b232, 0xff42b1a8, 0xff4e92cc, 0xff4e92cc, 0xff4e92cc}; - private static int[] arrColorsButtons = {R.drawable.bar_selector_red, R.drawable.bar_selector_orange, R.drawable.bar_selector_violet, - R.drawable.bar_selector_green, R.drawable.bar_selector_cyan, R.drawable.bar_selector_blue, R.drawable.bar_selector_violet, R.drawable.bar_selector_blue}; + private static int[] arrColorsButtons = {Theme.ACTION_BAR_RED_SELECTOR_COLOR, Theme.ACTION_BAR_ORANGE_SELECTOR_COLOR, Theme.ACTION_BAR_VIOLET_SELECTOR_COLOR, + Theme.ACTION_BAR_GREEN_SELECTOR_COLOR, Theme.ACTION_BAR_CYAN_SELECTOR_COLOR, Theme.ACTION_BAR_BLUE_SELECTOR_COLOR, Theme.ACTION_BAR_VIOLET_SELECTOR_COLOR, Theme.ACTION_BAR_BLUE_SELECTOR_COLOR}; private static Drawable broadcastDrawable; private static Drawable photoDrawable; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotKeyboardView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotKeyboardView.java index b8a091bee..7c1bfa0d3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotKeyboardView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotKeyboardView.java @@ -34,7 +34,7 @@ public class BotKeyboardView extends LinearLayout { private ArrayList buttonViews = new ArrayList<>(); public interface BotKeyboardViewDelegate { - void didPressedButton(CharSequence text); + void didPressedButton(TLRPC.KeyboardButton button); } public BotKeyboardView(Context context) { @@ -99,8 +99,9 @@ public class BotKeyboardView extends LinearLayout { float weight = 1.0f / row.buttons.size(); for (int b = 0; b < row.buttons.size(); b++) { - TLRPC.TL_keyboardButton button = row.buttons.get(b); + TLRPC.KeyboardButton button = row.buttons.get(b); TextView textView = new TextView(getContext()); + textView.setTag(button); textView.setTextColor(0xff36474f); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setGravity(Gravity.CENTER); @@ -111,7 +112,7 @@ public class BotKeyboardView extends LinearLayout { textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - delegate.didPressedButton(((TextView) v).getText()); + delegate.didPressedButton((TLRPC.KeyboardButton) v.getTag()); } }); buttonViews.add(textView); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 299508c7c..92884aa38 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -21,7 +21,9 @@ import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.os.Build; +import android.os.Bundle; import android.os.PowerManager; +import android.os.SystemClock; import android.text.Editable; import android.text.InputFilter; import android.text.Layout; @@ -64,18 +66,22 @@ import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.ui.ActionBar.ActionBar; -import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.AnimationCompat.ViewProxy; import org.telegram.messenger.ApplicationLoader; +import org.telegram.ui.ActionBar.Theme; +import org.telegram.ui.ChatActivity; +import org.telegram.ui.DialogsActivity; import org.telegram.ui.StickersActivity; import java.io.File; +import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.Locale; -public class ChatActivityEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate { +public class ChatActivityEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate, StickersAlert.StickersAlertDelegate { public interface ChatActivityEnterViewDelegate { void onMessageSend(String message); @@ -134,8 +140,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - seekBarWaveform.width = right - left; - seekBarWaveform.height = bottom - top; + seekBarWaveform.setSize(right - left, bottom - top); } @Override @@ -152,9 +157,28 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private int userNameLength; private int xOffset; private int yOffset; + private Object editor; + private Field editorField; + private Drawable[] mCursorDrawable; + private Field mCursorDrawableField; + private int triesCount = 0; public EditTextCaption(Context context) { super(context); + + try { + Field field = TextView.class.getDeclaredField("mEditor"); + field.setAccessible(true); + editor = field.get(this); + Class editorClass = Class.forName("android.widget.Editor"); + editorField = editorClass.getDeclaredField("mShowCursor"); + editorField.setAccessible(true); + mCursorDrawableField = editorClass.getDeclaredField("mCursorDrawable"); + mCursorDrawableField.setAccessible(true); + mCursorDrawable = (Drawable[]) mCursorDrawableField.get(editor); + } catch (Throwable e) { + FileLog.e("tmessages", e); + } } public void setCaption(String value) { @@ -217,6 +241,21 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } catch (Exception e) { FileLog.e("tmessages", e); } + + try { + if (editorField != null && mCursorDrawable != null && mCursorDrawable[0] != null) { + long mShowCursor = editorField.getLong(editor); + boolean showCursor = (SystemClock.uptimeMillis() - mShowCursor) % (2 * 500) < 500; + if (showCursor) { + canvas.save(); + canvas.translate(0, getPaddingTop()); + mCursorDrawable[0].draw(canvas); + canvas.restore(); + } + } + } catch (Throwable e) { + //ignore + } } @Override @@ -231,6 +270,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private EditTextCaption messageEditText; private ImageView sendButton; + private ImageView cancelBotButton; private ImageView emojiButton; private EmojiView emojiView; private TextView recordTimeText; @@ -254,6 +294,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private ImageView notifyButton; private RecordCircle recordCircle; private ContextProgressView contextProgressView; + private CloseProgressDrawable2 progressDrawable; private MessageObject editingMessageObject; private boolean editingCaption; @@ -299,7 +340,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private boolean lastSizeChangeValue2; private Activity parentActivity; - private BaseFragment parentFragment; + private ChatActivity parentFragment; private long dialog_id; private boolean ignoreTextChange; private int innerTextChange; @@ -319,6 +360,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private boolean allowShowTopView; private AnimatorSetProxy currentTopViewAnimation; + private MessageObject pendingMessageObject; + private TLRPC.KeyboardButton pendingLocationButton; + private boolean waitingForKeyboardOpen; private Runnable openKeyboardRunnable = new Runnable() { @Override @@ -450,7 +494,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } } - public ChatActivityEnterView(Activity context, SizeNotifierFrameLayout parent, BaseFragment fragment, boolean isChat) { + public ChatActivityEnterView(Activity context, SizeNotifierFrameLayout parent, ChatActivity fragment, boolean isChat) { super(context); setBackgroundResource(R.drawable.compose_panel); setFocusable(true); @@ -486,12 +530,10 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); emojiButton.setPadding(0, AndroidUtilities.dp(1), 0, 0); if (Build.VERSION.SDK_INT >= 21) { - emojiButton.setBackgroundResource(R.drawable.circle_selector); - frameLayout.addView(emojiButton, LayoutHelper.createFrame(44, 44, Gravity.BOTTOM | Gravity.LEFT, 4, 0, 0, 2)); - } else { - frameLayout.addView(emojiButton, LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.LEFT, 3, 0, 0, 0)); + emojiButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR)); } - emojiButton.setOnClickListener(new View.OnClickListener() { + frameLayout.addView(emojiButton, LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.LEFT, 3, 0, 0, 0)); + emojiButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (!isPopupShowing() || currentPopupContentType != 0) { @@ -513,11 +555,10 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat messageEditText.setGravity(Gravity.BOTTOM); messageEditText.setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(12)); messageEditText.setBackgroundDrawable(null); - AndroidUtilities.clearCursorDrawable(messageEditText); messageEditText.setTextColor(0xff000000); messageEditText.setHintTextColor(0xffb2b2b2); frameLayout.addView(messageEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 52, 0, isChat ? 50 : 2, 0)); - messageEditText.setOnKeyListener(new View.OnKeyListener() { + messageEditText.setOnKeyListener(new OnKeyListener() { boolean ctrlPressed = false; @@ -624,6 +665,13 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } } }); + try { + Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes"); + mCursorDrawableRes.setAccessible(true); + mCursorDrawableRes.set(messageEditText, R.drawable.field_carret); + } catch (Exception e) { + //nothing to do + } if (isChat) { contextProgressView = new ContextProgressView(context); @@ -641,11 +689,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat botButton.setScaleType(ImageView.ScaleType.CENTER); botButton.setVisibility(GONE); if (Build.VERSION.SDK_INT >= 21) { - botButton.setBackgroundResource(R.drawable.circle_selector); - attachButton.addView(botButton, LayoutHelper.createLinear(44, 44, Gravity.CENTER_VERTICAL, 2, 0, 2, 0)); - } else { - attachButton.addView(botButton, LayoutHelper.createLinear(48, 48)); + botButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR)); } + attachButton.addView(botButton, LayoutHelper.createLinear(48, 48)); botButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -673,11 +719,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat asAdminButton.setScaleType(ImageView.ScaleType.CENTER); asAdminButton.setVisibility(adminModeAvailable ? VISIBLE : GONE); if (Build.VERSION.SDK_INT >= 21) { - asAdminButton.setBackgroundResource(R.drawable.circle_selector); - attachButton.addView(asAdminButton, LayoutHelper.createLinear(44, 44, Gravity.CENTER_VERTICAL, 2, 0, 2, 0)); - } else { - attachButton.addView(asAdminButton, LayoutHelper.createLinear(48, 48)); + asAdminButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR)); } + attachButton.addView(asAdminButton, LayoutHelper.createLinear(48, 48)); asAdminButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -694,11 +738,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat notifyButton.setScaleType(ImageView.ScaleType.CENTER); notifyButton.setVisibility(canWriteToChannel ? VISIBLE : GONE); if (Build.VERSION.SDK_INT >= 21) { - notifyButton.setBackgroundResource(R.drawable.circle_selector); - attachButton.addView(notifyButton, LayoutHelper.createLinear(44, 44, Gravity.CENTER_VERTICAL, 2, 0, 2, 0)); - } else { - attachButton.addView(notifyButton, LayoutHelper.createLinear(48, 48)); + notifyButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR)); } + attachButton.addView(notifyButton, LayoutHelper.createLinear(48, 48)); notifyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -820,7 +862,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat audioSendButton.setSoundEffectsEnabled(false); audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0); sendButtonContainer.addView(audioSendButton, LayoutHelper.createFrame(48, 48)); - audioSendButton.setOnTouchListener(new View.OnTouchListener() { + audioSendButton.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { @@ -906,8 +948,32 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat recordCircle.setVisibility(GONE); sizeNotifierLayout.addView(recordCircle, LayoutHelper.createFrame(124, 124, Gravity.BOTTOM | Gravity.RIGHT, 0, 0, -36, -38)); + cancelBotButton = new ImageView(context); + cancelBotButton.setVisibility(INVISIBLE); + cancelBotButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); + //cancelBotButton.setImageResource(R.drawable.delete_reply); + cancelBotButton.setImageDrawable(progressDrawable = new CloseProgressDrawable2()); + cancelBotButton.setSoundEffectsEnabled(false); + ViewProxy.setScaleX(cancelBotButton, 0.1f); + ViewProxy.setScaleY(cancelBotButton, 0.1f); + ViewProxy.setAlpha(cancelBotButton, 0.0f); + cancelBotButton.clearAnimation(); + sendButtonContainer.addView(cancelBotButton, LayoutHelper.createFrame(48, 48)); + cancelBotButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + String text = messageEditText.getText().toString(); + int idx = text.indexOf(' '); + if (idx == -1 || idx == text.length() - 1) { + setFieldText(""); + } else { + setFieldText(text.substring(0, idx + 1)); + } + } + }); + sendButton = new ImageView(context); - sendButton.setVisibility(View.INVISIBLE); + sendButton.setVisibility(INVISIBLE); sendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); sendButton.setImageResource(R.drawable.ic_send); sendButton.setSoundEffectsEnabled(false); @@ -916,7 +982,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat ViewProxy.setAlpha(sendButton, 0.0f); sendButton.clearAnimation(); sendButtonContainer.addView(sendButton, LayoutHelper.createFrame(48, 48)); - sendButton.setOnClickListener(new View.OnClickListener() { + sendButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { sendMessage(); @@ -931,7 +997,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } public void showContextProgress(boolean show) { - if (contextProgressView == null) { + /*if (contextProgressView == null) { return; } contextProgressView.setVisibility(show ? VISIBLE : INVISIBLE); @@ -939,12 +1005,21 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat messageEditText.setPadding(0, AndroidUtilities.dp(11), show ? AndroidUtilities.dp(38) : 0, AndroidUtilities.dp(12)); } catch (Exception e) { FileLog.e("tmessages", e); + }*/ + if (progressDrawable == null) { + return; + } + if (show) { + progressDrawable.startAnimation(); + } else { + progressDrawable.stopAnimation(); } } public void setCaption(String caption) { if (messageEditText != null) { messageEditText.setCaption(caption); + checkSendButton(true); } } @@ -1025,6 +1100,13 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat currentTopViewAnimation = null; } } + + @Override + public void onAnimationCancel(Object animation) { + if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { + currentTopViewAnimation = null; + } + } }); currentTopViewAnimation.setDuration(200); currentTopViewAnimation.start(); @@ -1068,6 +1150,13 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat currentTopViewAnimation = null; } } + + @Override + public void onAnimationCancel(Object animation) { + if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { + currentTopViewAnimation = null; + } + } }); currentTopViewAnimation.setDuration(200); currentTopViewAnimation.start(); @@ -1095,7 +1184,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat if (allowShowTopView) { allowShowTopView = false; if (needShowTopView) { - topView.setVisibility(View.GONE); + topView.setVisibility(GONE); setTopViewAnimation(0.0f); } } @@ -1103,7 +1192,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat if (!allowShowTopView) { allowShowTopView = true; if (needShowTopView) { - topView.setVisibility(View.VISIBLE); + topView.setVisibility(VISIBLE); setTopViewAnimation(1.0f); } } @@ -1245,7 +1334,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat @Override public void onAnimationEnd(Object animation) { recordedAudioPanel.clearAnimation(); - recordedAudioPanel.setVisibility(View.GONE); + recordedAudioPanel.setVisibility(GONE); } }); @@ -1275,7 +1364,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat if (playing != null && playing == audioToSendMessageObject) { MediaController.getInstance().cleanupPlayer(true, true); } - SendMessagesHelper.getInstance().sendMessage(audioToSend, null, audioToSendPath, dialog_id, replyingMessageObject, isAsAdmin, null); + SendMessagesHelper.getInstance().sendMessage(audioToSend, null, audioToSendPath, dialog_id, replyingMessageObject, isAsAdmin, null, null); if (delegate != null) { delegate.onMessageSend(null); } @@ -1310,7 +1399,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat int count = (int) Math.ceil(text.length() / 4096.0f); for (int a = 0; a < count; a++) { String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length())); - SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, replyingMessageObject, messageWebPage, messageWebPageSearch, asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, replyingMessageObject, messageWebPage, messageWebPageSearch, asAdmin(), null, null, null); } return true; } @@ -1337,9 +1426,11 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } String message = getTrimmedString(messageEditText.getText().toString()); if (message.length() > 0 || forceShowSendButton || audioToSend != null) { - if (audioSendButton.getVisibility() == View.VISIBLE) { + boolean showBotButton = messageEditText.caption != null && sendButton.getVisibility() == VISIBLE; + boolean showSendButton = messageEditText.caption == null && cancelBotButton.getVisibility() == VISIBLE; + if (audioSendButton.getVisibility() == VISIBLE || showBotButton || showSendButton) { if (animated) { - if (runningAnimationType == 1) { + if (runningAnimationType == 1 && messageEditText.caption == null || runningAnimationType == 3 && messageEditText.caption != null) { return; } if (runningAnimation != null) { @@ -1361,60 +1452,116 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat runningAnimation2.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (runningAnimation2.equals(animation)) { - attachButton.setVisibility(View.GONE); + if (runningAnimation2 != null && runningAnimation2.equals(animation)) { + attachButton.setVisibility(GONE); attachButton.clearAnimation(); } } + + @Override + public void onAnimationCancel(Object animation) { + if (runningAnimation2 != null && runningAnimation2.equals(animation)) { + runningAnimation2 = null; + } + } }); runningAnimation2.start(); - updateFieldRight(0); - if (delegate != null) { delegate.onAttachButtonHidden(); } } - sendButton.setVisibility(View.VISIBLE); runningAnimation = new AnimatorSetProxy(); - runningAnimationType = 1; - runningAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 0.1f), - ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 0.1f), - ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 0.0f), - ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 1.0f), - ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 1.0f), - ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 1.0f) - ); + ArrayList animators = new ArrayList<>(); + if (audioSendButton.getVisibility() == VISIBLE) { + animators.add(ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 0.0f)); + } + if (showBotButton) { + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 0.0f)); + } else if (showSendButton) { + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "scaleX", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "scaleY", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "alpha", 0.0f)); + } + if (messageEditText.caption != null) { + runningAnimationType = 3; + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "scaleX", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "scaleY", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "alpha", 1.0f)); + cancelBotButton.setVisibility(VISIBLE); + } else { + runningAnimationType = 1; + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 1.0f)); + sendButton.setVisibility(VISIBLE); + } + runningAnimation.playTogether(animators); runningAnimation.setDuration(150); runningAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { if (runningAnimation != null && runningAnimation.equals(animation)) { - sendButton.setVisibility(View.VISIBLE); - audioSendButton.setVisibility(View.GONE); + if (messageEditText.caption != null) { + cancelBotButton.setVisibility(VISIBLE); + sendButton.setVisibility(GONE); + sendButton.clearAnimation(); + } else { + sendButton.setVisibility(VISIBLE); + cancelBotButton.setVisibility(GONE); + cancelBotButton.clearAnimation(); + } + audioSendButton.setVisibility(GONE); audioSendButton.clearAnimation(); runningAnimation = null; runningAnimationType = 0; } } + + @Override + public void onAnimationCancel(Object animation) { + if (runningAnimation != null && runningAnimation.equals(animation)) { + runningAnimation = null; + } + } }); runningAnimation.start(); } else { ViewProxy.setScaleX(audioSendButton, 0.1f); ViewProxy.setScaleY(audioSendButton, 0.1f); ViewProxy.setAlpha(audioSendButton, 0.0f); - ViewProxy.setScaleX(sendButton, 1.0f); - ViewProxy.setScaleY(sendButton, 1.0f); - ViewProxy.setAlpha(sendButton, 1.0f); - sendButton.setVisibility(View.VISIBLE); - audioSendButton.setVisibility(View.GONE); + if (messageEditText.caption != null) { + ViewProxy.setScaleX(sendButton, 0.1f); + ViewProxy.setScaleY(sendButton, 0.1f); + ViewProxy.setAlpha(sendButton, 0.0f); + ViewProxy.setScaleX(cancelBotButton, 1.0f); + ViewProxy.setScaleY(cancelBotButton, 1.0f); + ViewProxy.setAlpha(cancelBotButton, 1.0f); + cancelBotButton.setVisibility(VISIBLE); + sendButton.setVisibility(GONE); + sendButton.clearAnimation(); + } else { + ViewProxy.setScaleX(cancelBotButton, 0.1f); + ViewProxy.setScaleY(cancelBotButton, 0.1f); + ViewProxy.setAlpha(cancelBotButton, 0.0f); + ViewProxy.setScaleX(sendButton, 1.0f); + ViewProxy.setScaleY(sendButton, 1.0f); + ViewProxy.setAlpha(sendButton, 1.0f); + sendButton.setVisibility(VISIBLE); + cancelBotButton.setVisibility(GONE); + cancelBotButton.clearAnimation(); + } + audioSendButton.setVisibility(GONE); audioSendButton.clearAnimation(); if (attachButton != null) { - attachButton.setVisibility(View.GONE); + attachButton.setVisibility(GONE); attachButton.clearAnimation(); if (delegate != null) { delegate.onAttachButtonHidden(); @@ -1423,7 +1570,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } } } - } else if (sendButton.getVisibility() == View.VISIBLE) { + } else if (sendButton.getVisibility() == VISIBLE || cancelBotButton.getVisibility() == VISIBLE) { if (animated) { if (runningAnimationType == 2) { return; @@ -1439,7 +1586,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } if (attachButton != null) { - attachButton.setVisibility(View.VISIBLE); + attachButton.setVisibility(VISIBLE); runningAnimation2 = new AnimatorSetProxy(); runningAnimation2.playTogether( ObjectAnimatorProxy.ofFloat(attachButton, "alpha", 1.0f), @@ -1447,52 +1594,70 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat ); runningAnimation2.setDuration(100); runningAnimation2.start(); - updateFieldRight(1); - delegate.onAttachButtonShow(); } - audioSendButton.setVisibility(View.VISIBLE); + audioSendButton.setVisibility(VISIBLE); runningAnimation = new AnimatorSetProxy(); runningAnimationType = 2; - runningAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 0.1f), - ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 0.1f), - ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 0.0f), - ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 1.0f), - ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 1.0f), - ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 1.0f) - ); + ArrayList animators = new ArrayList<>(); + animators.add(ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleX", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(audioSendButton, "scaleY", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 1.0f)); + if (cancelBotButton.getVisibility() == VISIBLE) { + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "scaleX", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "scaleY", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(cancelBotButton, "alpha", 0.0f)); + } else { + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "scaleX", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "scaleY", 0.1f)); + animators.add(ObjectAnimatorProxy.ofFloat(sendButton, "alpha", 0.0f)); + } + runningAnimation.playTogether(animators); runningAnimation.setDuration(150); runningAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { if (runningAnimation != null && runningAnimation.equals(animation)) { - sendButton.setVisibility(View.GONE); + sendButton.setVisibility(GONE); sendButton.clearAnimation(); - audioSendButton.setVisibility(View.VISIBLE); + cancelBotButton.setVisibility(GONE); + cancelBotButton.clearAnimation(); + audioSendButton.setVisibility(VISIBLE); runningAnimation = null; runningAnimationType = 0; } } + + @Override + public void onAnimationCancel(Object animation) { + if (runningAnimation != null && runningAnimation.equals(animation)) { + runningAnimation = null; + } + } }); runningAnimation.start(); } else { ViewProxy.setScaleX(sendButton, 0.1f); ViewProxy.setScaleY(sendButton, 0.1f); ViewProxy.setAlpha(sendButton, 0.0f); + ViewProxy.setScaleX(cancelBotButton, 0.1f); + ViewProxy.setScaleY(cancelBotButton, 0.1f); + ViewProxy.setAlpha(cancelBotButton, 0.0f); ViewProxy.setScaleX(audioSendButton, 1.0f); ViewProxy.setScaleY(audioSendButton, 1.0f); ViewProxy.setAlpha(audioSendButton, 1.0f); - sendButton.setVisibility(View.GONE); + cancelBotButton.setVisibility(GONE); + cancelBotButton.clearAnimation(); + sendButton.setVisibility(GONE); sendButton.clearAnimation(); - audioSendButton.setVisibility(View.VISIBLE); + audioSendButton.setVisibility(VISIBLE); if (attachButton != null) { delegate.onAttachButtonShow(); - attachButton.setVisibility(View.VISIBLE); + attachButton.setVisibility(VISIBLE); updateFieldRight(1); } } @@ -1604,8 +1769,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat params.leftMargin = AndroidUtilities.dp(30); slideText.setLayoutParams(params); ViewProxy.setAlpha(slideText, 1); - recordPanel.setVisibility(View.GONE); - recordCircle.setVisibility(View.GONE); + recordPanel.setVisibility(GONE); + recordCircle.setVisibility(GONE); runningAnimationAudio = null; } } @@ -1644,9 +1809,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } else { TLRPC.User user = messageObject != null && (int) dialog_id < 0 ? MessagesController.getInstance().getUser(messageObject.messageOwner.from_id) : null; if ((botCount != 1 || username) && user != null && user.bot && !command.contains("@")) { - SendMessagesHelper.getInstance().sendMessage(String.format(Locale.US, "%s@%s", command, user.username), dialog_id, null, null, false, asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage(String.format(Locale.US, "%s@%s", command, user.username), dialog_id, null, null, false, asAdmin(), null, null, null); } else { - SendMessagesHelper.getInstance().sendMessage(command, dialog_id, null, null, false, asAdmin(), null, null); + SendMessagesHelper.getInstance().sendMessage(command, dialog_id, null, null, false, asAdmin(), null, null, null); } } } @@ -1680,10 +1845,12 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat layoutParams.rightMargin = AndroidUtilities.dp(4); messageEditText.setLayoutParams(layoutParams); sendButton.clearAnimation(); + cancelBotButton.clearAnimation(); audioSendButton.clearAnimation(); attachButton.clearAnimation(); sendButtonContainer.clearAnimation(); sendButton.setVisibility(GONE); + cancelBotButton.setVisibility(GONE); audioSendButton.setVisibility(GONE); attachButton.setVisibility(GONE); sendButtonContainer.setVisibility(GONE); @@ -1698,11 +1865,16 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat ViewProxy.setScaleX(sendButton, 0.1f); ViewProxy.setScaleY(sendButton, 0.1f); ViewProxy.setAlpha(sendButton, 0.0f); + ViewProxy.setScaleX(cancelBotButton, 0.1f); + ViewProxy.setScaleY(cancelBotButton, 0.1f); + ViewProxy.setAlpha(cancelBotButton, 0.0f); ViewProxy.setScaleX(audioSendButton, 1.0f); ViewProxy.setScaleY(audioSendButton, 1.0f); ViewProxy.setAlpha(audioSendButton, 1.0f); - sendButton.setVisibility(View.GONE); + sendButton.setVisibility(GONE); sendButton.clearAnimation(); + cancelBotButton.setVisibility(GONE); + cancelBotButton.clearAnimation(); messageEditText.setText(""); delegate.onAttachButtonShow(); updateFieldRight(1); @@ -1794,11 +1966,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat viewGroup.removeView(view); } if (Build.VERSION.SDK_INT >= 21) { - view.setBackgroundResource(R.drawable.circle_selector); - attachButton.addView(view, LayoutHelper.createLinear(44, 44, Gravity.CENTER_VERTICAL, 2, 0, 2, 0)); - } else { - attachButton.addView(view, LayoutHelper.createLinear(48, 48)); + view.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR)); } + attachButton.addView(view, LayoutHelper.createLinear(48, 48)); } private void updateBotButton() { @@ -1851,9 +2021,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat botKeyboardView.setVisibility(GONE); botKeyboardView.setDelegate(new BotKeyboardView.BotKeyboardViewDelegate() { @Override - public void didPressedButton(CharSequence text) { + public void didPressedButton(TLRPC.KeyboardButton button) { MessageObject object = replyingMessageObject != null ? replyingMessageObject : ((int) dialog_id < 0 ? botButtonsMessageObject : null); - SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, object, null, false, asAdmin(), null, null); + didPressedBotButton(button, object, replyingMessageObject != null ? replyingMessageObject : botButtonsMessageObject); if (replyingMessageObject != null) { openKeyboardInternal(); setButtons(botMessageObject, false); @@ -1897,6 +2067,92 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat updateBotButton(); } + public void didPressedBotButton(final TLRPC.KeyboardButton button, final MessageObject replyMessageObject, final MessageObject messageObject) { + if (button == null || messageObject == null) { + return; + } + if (button instanceof TLRPC.TL_keyboardButton) { + SendMessagesHelper.getInstance().sendMessage(button.text, dialog_id, replyMessageObject, null, false, asAdmin(), null, null, null); + } else if (button instanceof TLRPC.TL_keyboardButtonUrl) { + parentFragment.showOpenUrlAlert(button.url); + } else if (button instanceof TLRPC.TL_keyboardButtonRequestPhone) { + parentFragment.shareMyContact(messageObject); + } else if (button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation) { + AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); + builder.setTitle(LocaleController.getString("ShareYouLocationTitle", R.string.ShareYouLocationTitle)); + builder.setMessage(LocaleController.getString("ShareYouLocationInfo", R.string.ShareYouLocationInfo)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (Build.VERSION.SDK_INT >= 23 && parentActivity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + parentActivity.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 2); + pendingMessageObject = messageObject; + pendingLocationButton = button; + return; + } + SendMessagesHelper.getInstance().sendCurrentLocation(messageObject, button); + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + parentFragment.showDialog(builder.create()); + } else if (button instanceof TLRPC.TL_keyboardButtonCallback) { + SendMessagesHelper.getInstance().sendCallback(messageObject, button, parentFragment); + } else if (button instanceof TLRPC.TL_keyboardButtonSwitchInline) { + if (parentFragment.processSwitchButton((TLRPC.TL_keyboardButtonSwitchInline) button)) { + return; + } + Bundle args = new Bundle(); + args.putBoolean("onlySelect", true); + args.putInt("dialogsType", 1); + DialogsActivity fragment = new DialogsActivity(args); + fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() { + @Override + public void didSelectDialog(DialogsActivity fragment, long did, boolean param) { + int uid = messageObject.messageOwner.from_id; + if (messageObject.messageOwner.via_bot_id != 0) { + uid = messageObject.messageOwner.via_bot_id; + } + TLRPC.User user = MessagesController.getInstance().getUser(uid); + if (user == null) { + fragment.finishFragment(); + return; + } + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putString("dialog_" + did, "@" + user.username + " " + button.query); + editor.commit(); + if (did != dialog_id) { + int lower_part = (int) did; + if (lower_part != 0) { + Bundle args = new Bundle(); + if (lower_part > 0) { + args.putInt("user_id", lower_part); + } else if (lower_part < 0) { + args.putInt("chat_id", -lower_part); + } + if (!MessagesController.checkCanOpenChat(args, fragment)) { + return; + } + ChatActivity chatActivity = new ChatActivity(args); + if (parentFragment.presentFragment(chatActivity, true)) { + if (!AndroidUtilities.isTablet()) { + parentFragment.removeSelfFromStack(); + } + } else { + fragment.finishFragment(); + } + } else { + fragment.finishFragment(); + } + } else { + fragment.finishFragment(); + } + } + }); + parentFragment.presentFragment(fragment); + } + } + public boolean isPopupView(View view) { return view == botKeyboardView || view == emojiView; } @@ -1939,10 +2195,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } public void onStickerSelected(TLRPC.Document sticker) { - SendMessagesHelper.getInstance().sendSticker(sticker, dialog_id, replyingMessageObject, asAdmin()); - if (delegate != null) { - delegate.onMessageSend(null); - } + ChatActivityEnterView.this.onStickerSelected(sticker); } @Override @@ -2004,6 +2257,14 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat sizeNotifierLayout.addView(emojiView); } + @Override + public void onStickerSelected(TLRPC.Document sticker) { + SendMessagesHelper.getInstance().sendSticker(sticker, dialog_id, replyingMessageObject, asAdmin()); + if (delegate != null) { + delegate.onMessageSend(null); + } + } + private void showPopup(int show, int contentType) { if (show == 1) { if (contentType == 0 && emojiView == null) { @@ -2338,4 +2599,16 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } } } + + public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) { + if (requestCode == 2) { + if (pendingLocationButton != null) { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + SendMessagesHelper.getInstance().sendCurrentLocation(pendingMessageObject, pendingLocationButton); + } + pendingLocationButton = null; + pendingMessageObject = null; + } + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachView.java index 97a47121f..86c3d2aa5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachView.java @@ -37,8 +37,8 @@ import org.telegram.messenger.MessageObject; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.support.widget.LinearLayoutManager; import org.telegram.messenger.R; +import org.telegram.messenger.support.widget.RecyclerView; import org.telegram.tgnet.TLRPC; -import org.telegram.ui.Adapters.PhotoAttachAdapter; import org.telegram.ui.Cells.PhotoAttachPhotoCell; import org.telegram.ui.ChatActivity; import org.telegram.ui.PhotoViewer; @@ -60,12 +60,13 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No private RecyclerListView attachPhotoRecyclerView; private View lineView; private EmptyTextProgressView progressView; + private ArrayList viewsCache = new ArrayList<>(8); private float[] distCache = new float[20]; private DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(); - private boolean loading; + private boolean loading = true; private ChatAttachViewDelegate delegate; @@ -106,12 +107,6 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No super(context); NotificationCenter.getInstance().addObserver(this, NotificationCenter.albumsDidLoaded); - if (MediaController.allPhotosAlbumEntry == null) { - if (Build.VERSION.SDK_INT >= 21) { - MediaController.loadGalleryPhotosAlbums(0); - } - loading = true; - } views[8] = attachPhotoRecyclerView = new RecyclerListView(context); attachPhotoRecyclerView.setVerticalScrollBarEnabled(true); @@ -132,12 +127,6 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No }; attachPhotoLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); attachPhotoRecyclerView.setLayoutManager(attachPhotoLayoutManager); - photoAttachAdapter.setDelegate(new PhotoAttachAdapter.PhotoAttachAdapterDelegate() { - @Override - public void selectedPhotosChanged() { - updatePhotosButton(); - } - }); attachPhotoRecyclerView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @SuppressWarnings("unchecked") @Override @@ -215,6 +204,10 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No } }); + for (int a = 0; a < 8; a++) { + viewsCache.add(photoAttachAdapter.createHolder()); + } + if (loading) { progressView.showProgress(); } else { @@ -288,6 +281,14 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No } } + public void loadGalleryPhotos() { + if (MediaController.allPhotosAlbumEntry == null) { + if (Build.VERSION.SDK_INT >= 21) { + MediaController.loadGalleryPhotosAlbums(0); + } + } + } + @SuppressLint("NewApi") public void onRevealAnimationStart(boolean open) { if (!open) { @@ -523,4 +524,98 @@ public class ChatAttachView extends FrameLayout implements NotificationCenter.No public int getSelectedCount() { return photoAttachAdapter.getSelectedPhotos().size(); } + + @Override + public boolean hasOverlappingRendering() { + return false; + } + + public class PhotoAttachAdapter extends RecyclerView.Adapter { + + private Context mContext; + private HashMap selectedPhotos = new HashMap<>(); + + private class Holder extends RecyclerView.ViewHolder { + + public Holder(View itemView) { + super(itemView); + } + } + + public PhotoAttachAdapter(Context context) { + mContext = context; + } + + public void clearSelectedPhotos() { + if (!selectedPhotos.isEmpty()) { + for (HashMap.Entry entry : selectedPhotos.entrySet()) { + MediaController.PhotoEntry photoEntry = entry.getValue(); + photoEntry.imagePath = null; + photoEntry.thumbPath = null; + photoEntry.caption = null; + } + selectedPhotos.clear(); + updatePhotosButton(); + notifyDataSetChanged(); + } + } + + public Holder createHolder() { + PhotoAttachPhotoCell cell = new PhotoAttachPhotoCell(mContext); + cell.setDelegate(new PhotoAttachPhotoCell.PhotoAttachPhotoCellDelegate() { + @Override + public void onCheckClick(PhotoAttachPhotoCell v) { + MediaController.PhotoEntry photoEntry = v.getPhotoEntry(); + if (selectedPhotos.containsKey(photoEntry.imageId)) { + selectedPhotos.remove(photoEntry.imageId); + v.setChecked(false, true); + photoEntry.imagePath = null; + photoEntry.thumbPath = null; + v.setPhotoEntry(photoEntry, (Integer) v.getTag() == MediaController.allPhotosAlbumEntry.photos.size() - 1); + } else { + selectedPhotos.put(photoEntry.imageId, photoEntry); + v.setChecked(true, true); + } + updatePhotosButton(); + } + }); + return new Holder(cell); + } + + public HashMap getSelectedPhotos() { + return selectedPhotos; + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + PhotoAttachPhotoCell cell = (PhotoAttachPhotoCell) holder.itemView; + MediaController.PhotoEntry photoEntry = MediaController.allPhotosAlbumEntry.photos.get(position); + cell.setPhotoEntry(photoEntry, position == MediaController.allPhotosAlbumEntry.photos.size() - 1); + cell.setChecked(selectedPhotos.containsKey(photoEntry.imageId), false); + cell.getImageView().setTag(position); + cell.setTag(position); + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + Holder holder; + if (!viewsCache.isEmpty()) { + holder = viewsCache.get(0); + viewsCache.remove(0); + } else { + holder = createHolder(); + } + return holder; + } + + @Override + public int getItemCount() { + return (MediaController.allPhotosAlbumEntry != null ? MediaController.allPhotosAlbumEntry.photos.size() : 0); + } + + @Override + public int getItemViewType(int position) { + return 0; + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java new file mode 100644 index 000000000..c851dbf9c --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java @@ -0,0 +1,366 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.ui.Components; + +import android.content.Context; +import android.os.Build; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.Gravity; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ChatObject; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; +import org.telegram.messenger.MessagesController; +import org.telegram.messenger.R; +import org.telegram.messenger.UserConfig; +import org.telegram.tgnet.ConnectionsManager; +import org.telegram.tgnet.TLRPC; +import org.telegram.ui.ActionBar.ActionBar; +import org.telegram.ui.ActionBar.SimpleTextView; +import org.telegram.ui.ActionBar.Theme; +import org.telegram.ui.ChatActivity; +import org.telegram.ui.ProfileActivity; + +public class ChatAvatarContainer extends FrameLayout { + + private BackupImageView avatarImageView; + private SimpleTextView titleTextView; + private SimpleTextView subtitleTextView; + private RadioButton radioButton; + private ImageView timeItem; + private TimerDrawable timerDrawable; + private ChatActivity parentFragment; + private TypingDotsDrawable typingDotsDrawable; + private RecordStatusDrawable recordStatusDrawable; + private SendingFileExDrawable sendingFileDrawable; + private AvatarDrawable avatarDrawable = new AvatarDrawable(); + private ChatAvatarContainerDelegate delegate; + + private int onlineCount = -1; + + public interface ChatAvatarContainerDelegate { + void didPressedRadioButton(); + } + + public ChatAvatarContainer(Context context, ChatActivity chatActivity, boolean needRadio, boolean needTime) { + super(context); + parentFragment = chatActivity; + + avatarImageView = new BackupImageView(context); + avatarImageView.setRoundRadius(AndroidUtilities.dp(21)); + addView(avatarImageView); + + titleTextView = new SimpleTextView(context); + titleTextView.setTextColor(Theme.ACTION_BAR_TITLE_COLOR); + titleTextView.setTextSize(18); + titleTextView.setGravity(Gravity.LEFT); + titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + titleTextView.setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f)); + titleTextView.setRightDrawableTopPadding(-AndroidUtilities.dp(1.3f)); + addView(titleTextView); + + subtitleTextView = new SimpleTextView(context); + subtitleTextView.setTextColor(Theme.ACTION_BAR_SUBTITLE_COLOR); + subtitleTextView.setTextSize(14); + subtitleTextView.setGravity(Gravity.LEFT); + addView(subtitleTextView); + + if (needTime) { + timeItem = new ImageView(context); + timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5)); + timeItem.setScaleType(ImageView.ScaleType.CENTER); + timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context)); + addView(timeItem); + timeItem.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + parentFragment.showDialog(AndroidUtilities.buildTTLAlert(getContext(), parentFragment.getCurrentEncryptedChat()).create()); + } + }); + } + + if (needRadio) { + radioButton = new RadioButton(context); + radioButton.setVisibility(View.GONE); + addView(radioButton); + } + + setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (radioButton == null || radioButton.getVisibility() != View.VISIBLE) { + TLRPC.User user = parentFragment.getCurrentUser(); + TLRPC.Chat chat = parentFragment.getCurrentChat(); + if (user != null) { + Bundle args = new Bundle(); + args.putInt("user_id", user.id); + if (timeItem != null) { + args.putLong("dialog_id", parentFragment.getDialogId()); + } + ProfileActivity fragment = new ProfileActivity(args); + fragment.setPlayProfileAnimation(true); + parentFragment.presentFragment(fragment); + } else if (chat != null) { + Bundle args = new Bundle(); + args.putInt("chat_id", chat.id); + ProfileActivity fragment = new ProfileActivity(args); + fragment.setChatInfo(parentFragment.getCurrentChatInfo()); + fragment.setPlayProfileAnimation(true); + parentFragment.presentFragment(fragment); + } + } else { + delegate.didPressedRadioButton(); + } + } + }); + + TLRPC.Chat chat = parentFragment.getCurrentChat(); + typingDotsDrawable = new TypingDotsDrawable(); + typingDotsDrawable.setIsChat(chat != null); + recordStatusDrawable = new RecordStatusDrawable(); + recordStatusDrawable.setIsChat(chat != null); + sendingFileDrawable = new SendingFileExDrawable(); + sendingFileDrawable.setIsChat(chat != null); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int width = MeasureSpec.getSize(widthMeasureSpec); + int availableWidth = width - AndroidUtilities.dp(54 + 16); + avatarImageView.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY)); + titleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.AT_MOST)); + if (radioButton != null && radioButton.getVisibility() == VISIBLE) { + radioButton.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.EXACTLY)); + availableWidth -= AndroidUtilities.dp(20); + } + subtitleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.AT_MOST)); + if (timeItem != null) { + timeItem.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(34), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(34), MeasureSpec.EXACTLY)); + } + setMeasuredDimension(width, MeasureSpec.getSize(heightMeasureSpec)); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + int actionBarHeight = ActionBar.getCurrentActionBarHeight(); + int viewTop = (actionBarHeight - AndroidUtilities.dp(42)) / 2 + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); + avatarImageView.layout(AndroidUtilities.dp(8), viewTop, AndroidUtilities.dp(42 + 8), viewTop + AndroidUtilities.dp(42)); + titleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(1.3f), AndroidUtilities.dp(8 + 54) + titleTextView.getMeasuredWidth(), viewTop + titleTextView.getTextHeight() + AndroidUtilities.dp(1.3f)); + if (timeItem != null) { + timeItem.layout(AndroidUtilities.dp(8 + 16), viewTop + AndroidUtilities.dp(15), AndroidUtilities.dp(8 + 16 + 34), viewTop + AndroidUtilities.dp(15 + 34)); + } + if (radioButton != null && radioButton.getVisibility() == VISIBLE) { + subtitleTextView.layout(AndroidUtilities.dp(8 + 54 + 20), viewTop + AndroidUtilities.dp(24), AndroidUtilities.dp(8 + 54 + 20) + subtitleTextView.getMeasuredWidth(), viewTop + subtitleTextView.getTextHeight() + AndroidUtilities.dp(24)); + viewTop = viewTop + subtitleTextView.getTextHeight() / 2 + AndroidUtilities.dp(12); + radioButton.layout(AndroidUtilities.dp(8 + 50), viewTop, AndroidUtilities.dp(8 + 50 + 24), viewTop + AndroidUtilities.dp(24)); + } else { + subtitleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(24), AndroidUtilities.dp(8 + 54) + subtitleTextView.getMeasuredWidth(), viewTop + subtitleTextView.getTextHeight() + AndroidUtilities.dp(24)); + } + } + + public void setRadioChecked(boolean value, boolean animated) { + if (radioButton == null) { + return; + } + radioButton.setChecked(value, animated); + } + + public boolean isRadioChecked() { + return radioButton.isChecked(); + } + + public void showTimeItem() { + if (timeItem == null) { + return; + } + timeItem.setVisibility(VISIBLE); + } + + public void hideTimeItem() { + if (timeItem == null) { + return; + } + timeItem.setVisibility(GONE); + } + + public void setTime(int value) { + if (timerDrawable == null) { + return; + } + timerDrawable.setTime(value); + } + + public void setTitleIcons(int leftIcon, int rightIcon) { + titleTextView.setLeftDrawable(leftIcon); + titleTextView.setRightDrawable(rightIcon); + } + + public void setTitle(CharSequence value) { + titleTextView.setText(value); + } + + public void setDelegate(ChatAvatarContainerDelegate chatAvatarContainerDelegate) { + delegate = chatAvatarContainerDelegate; + } + + private void setTypingAnimation(boolean start) { + if (start) { + try { + Integer type = MessagesController.getInstance().printingStringsTypes.get(parentFragment.getDialogId()); + if (type == 0) { + subtitleTextView.setLeftDrawable(typingDotsDrawable); + typingDotsDrawable.start(); + recordStatusDrawable.stop(); + sendingFileDrawable.stop(); + } else if (type == 1) { + subtitleTextView.setLeftDrawable(recordStatusDrawable); + recordStatusDrawable.start(); + typingDotsDrawable.stop(); + sendingFileDrawable.stop(); + } else if (type == 2) { + subtitleTextView.setLeftDrawable(sendingFileDrawable); + sendingFileDrawable.start(); + typingDotsDrawable.stop(); + recordStatusDrawable.stop(); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } else { + subtitleTextView.setLeftDrawable(null); + typingDotsDrawable.stop(); + recordStatusDrawable.stop(); + sendingFileDrawable.stop(); + } + } + + public void updateSubtitle() { + TLRPC.User user = parentFragment.getCurrentUser(); + TLRPC.Chat chat = parentFragment.getCurrentChat(); + CharSequence printString = MessagesController.getInstance().printingStrings.get(parentFragment.getDialogId()); + if (printString != null) { + printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""}); + } + if (printString == null || printString.length() == 0 || ChatObject.isChannel(chat) && !chat.megagroup) { + setTypingAnimation(false); + if (chat != null) { + TLRPC.ChatFull info = parentFragment.getCurrentChatInfo(); + if (ChatObject.isChannel(chat)) { + if (!chat.broadcast && !chat.megagroup && !(chat instanceof TLRPC.TL_channelForbidden)) { + subtitleTextView.setText(LocaleController.getString("ShowDiscussion", R.string.ShowDiscussion)); + if (radioButton != null && radioButton.getVisibility() != VISIBLE) { + radioButton.setVisibility(View.VISIBLE); + } + } else { + if (info != null && info.participants_count != 0) { + if (chat.megagroup && info.participants_count <= 200) { + if (onlineCount > 1 && info.participants_count != 0) { + subtitleTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", info.participants_count), LocaleController.formatPluralString("Online", onlineCount))); + } else { + subtitleTextView.setText(LocaleController.formatPluralString("Members", info.participants_count)); + } + } else { + int result[] = new int[1]; + String shortNumber = LocaleController.formatShortNumber(info.participants_count, result); + String text = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber); + subtitleTextView.setText(text); + } + } else { + if (chat.megagroup) { + subtitleTextView.setText(LocaleController.getString("Loading", R.string.Loading).toLowerCase()); + } else { + if ((chat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) { + subtitleTextView.setText(LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase()); + } else { + subtitleTextView.setText(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase()); + } + } + } + if (radioButton != null && radioButton.getVisibility() != GONE) { + radioButton.setVisibility(View.GONE); + } + } + } else { + if (ChatObject.isKickedFromChat(chat)) { + subtitleTextView.setText(LocaleController.getString("YouWereKicked", R.string.YouWereKicked)); + } else if (ChatObject.isLeftFromChat(chat)) { + subtitleTextView.setText(LocaleController.getString("YouLeft", R.string.YouLeft)); + } else { + int count = chat.participants_count; + if (info != null) { + count = info.participants.participants.size(); + } + if (onlineCount > 1 && count != 0) { + subtitleTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))); + } else { + subtitleTextView.setText(LocaleController.formatPluralString("Members", count)); + } + } + } + } else if (user != null) { + user = MessagesController.getInstance().getUser(user.id); + String newStatus; + if (user.id == 333000 || user.id == 777000) { + newStatus = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications); + } else if (user.bot) { + newStatus = LocaleController.getString("Bot", R.string.Bot); + } else { + newStatus = LocaleController.formatUserStatus(user); + } + subtitleTextView.setText(newStatus); + } + } else { + subtitleTextView.setText(printString); + setTypingAnimation(true); + } + } + + public void checkAndUpdateAvatar() { + TLRPC.FileLocation newPhoto = null; + TLRPC.User user = parentFragment.getCurrentUser(); + TLRPC.Chat chat = parentFragment.getCurrentChat(); + if (user != null) { + if (user.photo != null) { + newPhoto = user.photo.photo_small; + } + avatarDrawable.setInfo(user); + } else if (chat != null) { + if (chat.photo != null) { + newPhoto = chat.photo.photo_small; + } + avatarDrawable.setInfo(chat); + } + if (avatarImageView != null) { + avatarImageView.setImage(newPhoto, "50_50", avatarDrawable); + } + } + + public void updateOnlineCount() { + onlineCount = 0; + TLRPC.ChatFull info = parentFragment.getCurrentChatInfo(); + if (info == null) { + return; + } + int currentTime = ConnectionsManager.getInstance().getCurrentTime(); + if (info instanceof TLRPC.TL_chatFull || info instanceof TLRPC.TL_channelFull && info.participants_count <= 200 && info.participants != null) { + for (int a = 0; a < info.participants.participants.size(); a++) { + TLRPC.ChatParticipant participant = info.participants.participants.get(a); + TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id); + if (user != null && user.status != null && (user.status.expires > currentTime || user.id == UserConfig.getClientUserId()) && user.status.expires > 10000) { + onlineCount++; + } + } + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java index 615777efe..64790946f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java @@ -51,6 +51,9 @@ public class ClippingImageView extends View { matrix = new Matrix(); drawRect = new RectF(); bitmapRect = new RectF(); + roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + roundRect = new RectF(); + shaderMatrix = new Matrix(); } public void setAnimationValues(float[][] values) { @@ -109,10 +112,32 @@ public class ClippingImageView extends View { canvas.save(); if (needRadius) { - roundRect.set(0, 0, getWidth(), getHeight()); shaderMatrix.reset(); - shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL); + roundRect.set(0, 0, getWidth(), getHeight()); + + int bitmapW; + int bitmapH; + if (orientation % 360 == 90 || orientation % 360 == 270) { + bitmapW = bmp.getHeight(); + bitmapH = bmp.getWidth(); + } else { + bitmapW = bmp.getWidth(); + bitmapH = bmp.getHeight(); + } + float scaleW = getWidth() != 0 ? bitmapW / getWidth() : 1.0f; + float scaleH = getHeight() != 0 ? bitmapH / getHeight() : 1.0f; + float scale = Math.min(scaleW, scaleH); + if (Math.abs(scaleW - scaleH) > 0.00001f) { + int w = (int) Math.floor(getWidth() * scale); + int h = (int) Math.floor(getHeight() * scale); + bitmapRect.set((bitmapW - w) / 2, (bitmapH - h) / 2, w, h); + shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.START); + } else { + bitmapRect.set(0, 0, bmp.getWidth(), bmp.getHeight()); + shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL); + } bitmapShader.setLocalMatrix(shaderMatrix); + canvas.clipRect(clipLeft / scaleY, clipTop / scaleY, getWidth() - clipRight / scaleY, getHeight() - clipBottom / scaleY); canvas.drawRoundRect(roundRect, radius, radius, roundPaint); } else { if (orientation == 90 || orientation == 270) { @@ -182,10 +207,7 @@ public class ClippingImageView extends View { if (bitmap != null) { bitmapRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight()); if (needRadius) { - roundRect = new RectF(); - shaderMatrix = new Matrix(); bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); - roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); roundPaint.setShader(bitmapShader); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/CloseProgressDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/CloseProgressDrawable.java new file mode 100644 index 000000000..7ddd35863 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/CloseProgressDrawable.java @@ -0,0 +1,91 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.ui.Components; + +import android.graphics.Canvas; +import android.graphics.ColorFilter; +import android.graphics.Paint; +import android.graphics.PixelFormat; +import android.graphics.drawable.Drawable; +import android.view.animation.DecelerateInterpolator; + +import org.telegram.messenger.AndroidUtilities; + +public class CloseProgressDrawable extends Drawable { + + private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + private long lastFrameTime; + private int currentAnimationTime; + private DecelerateInterpolator interpolator = new DecelerateInterpolator(); + private int currentSegment; + + public CloseProgressDrawable() { + super(); + paint.setColor(0xff757575); + paint.setStrokeWidth(AndroidUtilities.dp(2)); + paint.setStrokeCap(Paint.Cap.ROUND); + } + + @Override + public void draw(Canvas canvas) { + long newTime = System.currentTimeMillis(); + if (lastFrameTime != 0) { + long dt = (newTime - lastFrameTime); + currentAnimationTime += dt; + if (currentAnimationTime > 200) { + currentAnimationTime = 0; + currentSegment++; + if (currentSegment == 4) { + currentSegment -= 4; + } + } + } + + canvas.save(); + canvas.translate(getIntrinsicWidth() / 2, getIntrinsicHeight() / 2); + canvas.rotate(45); + paint.setAlpha(255 - (currentSegment % 4) * 40); + canvas.drawLine(-AndroidUtilities.dp(8), 0, 0, 0, paint); + paint.setAlpha(255 - ((currentSegment + 1) % 4) * 40); + canvas.drawLine(0, -AndroidUtilities.dp(8), 0, 0, paint); + paint.setAlpha(255 - ((currentSegment + 2) % 4) * 40); + canvas.drawLine(0, 0, AndroidUtilities.dp(8), 0, paint); + paint.setAlpha(255 - ((currentSegment + 3) % 4) * 40); + canvas.drawLine(0, 0, 0, AndroidUtilities.dp(8), paint); + canvas.restore(); + + lastFrameTime = newTime; + invalidateSelf(); + } + + @Override + public void setAlpha(int alpha) { + + } + + @Override + public void setColorFilter(ColorFilter cf) { + + } + + @Override + public int getOpacity() { + return PixelFormat.TRANSPARENT; + } + + @Override + public int getIntrinsicWidth() { + return AndroidUtilities.dp(24); + } + + @Override + public int getIntrinsicHeight() { + return AndroidUtilities.dp(24); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/CloseProgressDrawable2.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/CloseProgressDrawable2.java new file mode 100644 index 000000000..7d93f1253 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/CloseProgressDrawable2.java @@ -0,0 +1,143 @@ +/* + * This is the source code of Telegram for Android v. 3.x.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-2016. + */ + +package org.telegram.ui.Components; + +import android.graphics.Canvas; +import android.graphics.ColorFilter; +import android.graphics.Paint; +import android.graphics.PixelFormat; +import android.graphics.RectF; +import android.graphics.drawable.Drawable; +import android.view.animation.DecelerateInterpolator; + +import org.telegram.messenger.AndroidUtilities; + +public class CloseProgressDrawable2 extends Drawable { + + private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + private long lastFrameTime; + private DecelerateInterpolator interpolator = new DecelerateInterpolator(); + private RectF rect = new RectF(); + private float angle; + private boolean animating; + + public CloseProgressDrawable2() { + super(); + paint.setColor(0xffadadad); + paint.setStrokeWidth(AndroidUtilities.dp(2)); + paint.setStrokeCap(Paint.Cap.ROUND); + paint.setStyle(Paint.Style.STROKE); + } + + public void startAnimation() { + animating = true; + lastFrameTime = System.currentTimeMillis(); + invalidateSelf(); + } + + public void stopAnimation() { + animating = false; + } + + @Override + public void draw(Canvas canvas) { + long newTime = System.currentTimeMillis(); + boolean invalidate = false; + if (lastFrameTime != 0) { + long dt = (newTime - lastFrameTime); + if (animating || angle != 0) { + angle += 360 * dt / 500.0f; + if (!animating && angle >= 720) { + angle = 0; + } else { + angle -= (int) (angle / 720) * 720; + } + invalidateSelf(); + } + } + + canvas.save(); + canvas.translate(getIntrinsicWidth() / 2, getIntrinsicHeight() / 2); + canvas.rotate(-45); + float progress1 = 1.0f; + float progress2 = 1.0f; + float progress3 = 1.0f; + float progress4 = 0.0f; + if (angle >= 0 && angle < 90) { + progress1 = (1.0f - angle / 90.0f); + } else if (angle >= 90 && angle < 180) { + progress1 = 0.0f; + progress2 = 1.0f - (angle - 90) / 90.0f; + } else if (angle >= 180 && angle < 270) { + progress1 = progress2 = 0; + progress3 = 1.0f - (angle - 180) / 90.0f; + } else if (angle >= 270 && angle < 360) { + progress1 = progress2 = progress3 = 0; + progress4 = (angle - 270) / 90.0f; + } else if (angle >= 360 && angle < 450) { + progress1 = progress2 = progress3 = 0; + progress4 = 1.0f - (angle - 360) / 90.0f; + } else if (angle >= 450 && angle < 540) { + progress2 = progress3 = 0; + progress1 = (angle - 450) / 90.0f; + } else if (angle >= 540 && angle < 630) { + progress3 = 0; + progress2 = (angle - 540) / 90.0f; + } else if (angle >= 630 && angle < 720) { + progress3 = (angle - 630) / 90.0f; + } + + if (progress1 != 0) { + canvas.drawLine(0, 0, 0, AndroidUtilities.dp(8) * progress1, paint); + } + if (progress2 != 0) { + canvas.drawLine(-AndroidUtilities.dp(8) * progress2, 0, 0, 0, paint); + } + if (progress3 != 0) { + canvas.drawLine(0, -AndroidUtilities.dp(8) * progress3, 0, 0, paint); + } + if (progress4 != 1) { + canvas.drawLine(AndroidUtilities.dp(8) * progress4, 0, AndroidUtilities.dp(8), 0, paint); + } + + canvas.restore(); + + int cx = getBounds().centerX(); + int cy = getBounds().centerY(); + rect.set(cx - AndroidUtilities.dp(8), cy - AndroidUtilities.dp(8), cx + AndroidUtilities.dp(8), cy + AndroidUtilities.dp(8)); + canvas.drawArc(rect, (angle < 360 ? 0 : angle - 360) - 45, (angle < 360 ? angle : 720 - angle), false, paint); + + lastFrameTime = newTime; + } + + @Override + public void setAlpha(int alpha) { + + } + + @Override + public void setColorFilter(ColorFilter cf) { + + } + + @Override + public int getOpacity() { + return PixelFormat.TRANSPARENT; + } + + @Override + public int getIntrinsicWidth() { + return AndroidUtilities.dp(24); + } + + @Override + public int getIntrinsicHeight() { + return AndroidUtilities.dp(24); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterDrawable.java index e8567c3e7..91bd7ead0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterDrawable.java @@ -23,7 +23,7 @@ import org.telegram.messenger.FileLog; public class LetterDrawable extends Drawable { - private static Paint paint = new Paint(); + public static Paint paint = new Paint(); private static TextPaint namePaint; private StaticLayout textLayout; @@ -36,7 +36,7 @@ public class LetterDrawable extends Drawable { super(); if (namePaint == null) { - paint.setColor(0xffdfdfdf); + paint.setColor(0xfff0f0f0); namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); namePaint.setColor(0xffffffff); namePaint.setTextSize(AndroidUtilities.dp(28)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkPath.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkPath.java index 4f146c6dc..f7203005e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkPath.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkPath.java @@ -16,15 +16,19 @@ public class LinkPath extends Path { private StaticLayout currentLayout; private int currentLine; private float lastTop = -1; + private float heightOffset; - public void setCurrentLayout(StaticLayout layout, int start) { + public void setCurrentLayout(StaticLayout layout, int start, float yOffset) { currentLayout = layout; currentLine = layout.getLineForOffset(start); lastTop = -1; + heightOffset = yOffset; } @Override public void addRect(float left, float top, float right, float bottom, Direction dir) { + top += heightOffset; + bottom += heightOffset; if (lastTop == -1) { lastTop = top; } else if (lastTop != top) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java index c7825462e..c5a162982 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java @@ -40,6 +40,7 @@ import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.AnimationCompat.ViewProxy; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Cells.PhotoEditToolCell; import java.nio.ByteBuffer; @@ -2068,7 +2069,7 @@ public class PhotoFilterView extends FrameLayout { cancelTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); cancelTextView.setTextColor(0xffffffff); cancelTextView.setGravity(Gravity.CENTER); - cancelTextView.setBackgroundResource(R.drawable.bar_selector_picker); + cancelTextView.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false)); cancelTextView.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0); cancelTextView.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase()); cancelTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); @@ -2078,7 +2079,7 @@ public class PhotoFilterView extends FrameLayout { doneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); doneTextView.setTextColor(0xff51bdf3); doneTextView.setGravity(Gravity.CENTER); - doneTextView.setBackgroundResource(R.drawable.bar_selector_picker); + doneTextView.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false)); doneTextView.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0); doneTextView.setText(LocaleController.getString("Done", R.string.Done).toUpperCase()); doneTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); @@ -2169,7 +2170,7 @@ public class PhotoFilterView extends FrameLayout { ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.edit_cancel); - imageView.setBackgroundResource(R.drawable.bar_selector_picker); + imageView.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false)); imageView.setPadding(AndroidUtilities.dp(22), 0, AndroidUtilities.dp(22), 0); frameLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); imageView.setOnClickListener(new OnClickListener() { @@ -2217,7 +2218,7 @@ public class PhotoFilterView extends FrameLayout { imageView = new ImageView(context); imageView.setImageResource(R.drawable.edit_doneblue); - imageView.setBackgroundResource(R.drawable.bar_selector_picker); + imageView.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false)); imageView.setPadding(AndroidUtilities.dp(22), AndroidUtilities.dp(1), AndroidUtilities.dp(22), 0); frameLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT)); imageView.setOnClickListener(new OnClickListener() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java index ffbf63466..3da5c1ac1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java @@ -9,13 +9,17 @@ package org.telegram.ui.Components; import android.content.Context; +import android.os.Build; import android.text.Editable; import android.text.InputFilter; import android.text.TextWatcher; import android.text.style.ImageSpan; import android.util.TypedValue; +import android.view.ActionMode; import android.view.Gravity; import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.EditText; @@ -34,6 +38,9 @@ import org.telegram.tgnet.TLRPC; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayoutPhoto.SizeNotifierFrameLayoutPhotoDelegate { public interface PhotoViewerCaptionEnterViewDelegate { @@ -47,6 +54,8 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not private EmojiView emojiView; private SizeNotifierFrameLayoutPhoto sizeNotifierLayout; + private ActionMode currentActionMode; + private AnimatorSetProxy runningAnimation; private AnimatorSetProxy runningAnimation2; private ObjectAnimatorProxy runningAnimationAudio; @@ -65,11 +74,14 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not private PhotoViewerCaptionEnterViewDelegate delegate; - public PhotoViewerCaptionEnterView(Context context, SizeNotifierFrameLayoutPhoto parent) { + private View windowView; + + public PhotoViewerCaptionEnterView(Context context, SizeNotifierFrameLayoutPhoto parent, final View window) { super(context); setBackgroundColor(0x7f000000); setFocusable(true); setFocusableInTouchMode(true); + windowView = window; sizeNotifierLayout = parent; @@ -97,6 +109,63 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not }); messageEditText = new EditText(context); + if (Build.VERSION.SDK_INT >= 23) { + messageEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + currentActionMode = mode; + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + if (Build.VERSION.SDK_INT >= 23) { + fixActionMode(mode); + } + return true; + } + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return false; + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + if (currentActionMode == mode) { + currentActionMode = null; + } + } + }); + + messageEditText.setCustomInsertionActionModeCallback(new ActionMode.Callback() { + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + currentActionMode = mode; + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + if (Build.VERSION.SDK_INT >= 23) { + fixActionMode(mode); + } + return true; + } + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return false; + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + if (currentActionMode == mode) { + currentActionMode = null; + } + } + }); + } messageEditText.setHint(LocaleController.getString("AddCaption", R.string.AddCaption)); messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); messageEditText.setInputType(messageEditText.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES); @@ -116,11 +185,15 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not messageEditText.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View view, int i, KeyEvent keyEvent) { - if (i == KeyEvent.KEYCODE_BACK && !keyboardVisible && isPopupShowing()) { - if (keyEvent.getAction() == 1) { - showPopup(0); + if (i == KeyEvent.KEYCODE_BACK) { + if (hideActionMode()) { + return true; + } else if (!keyboardVisible && isPopupShowing()) { + if (keyEvent.getAction() == 1) { + showPopup(0); + } + return true; } - return true; } return false; } @@ -187,6 +260,47 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not }); } + public boolean hideActionMode() { + if (Build.VERSION.SDK_INT >= 23 && currentActionMode != null) { + currentActionMode.finish(); + currentActionMode = null; + return true; + } + return false; + } + + @SuppressWarnings("unchecked") + private void fixActionMode(ActionMode mode) { + try { + Class classActionMode = Class.forName("com.android.internal.view.FloatingActionMode"); + Field fieldToolbar = classActionMode.getDeclaredField("mFloatingToolbar"); + fieldToolbar.setAccessible(true); + Object toolbar = fieldToolbar.get(mode); + + Class classToolbar = Class.forName("com.android.internal.widget.FloatingToolbar"); + Field fieldToolbarPopup = classToolbar.getDeclaredField("mPopup"); + Field fieldToolbarWidth = classToolbar.getDeclaredField("mWidthChanged"); + fieldToolbarPopup.setAccessible(true); + fieldToolbarWidth.setAccessible(true); + Object popup = fieldToolbarPopup.get(toolbar); + + Class classToolbarPopup = Class.forName("com.android.internal.widget.FloatingToolbar$FloatingToolbarPopup"); + Field fieldToolbarPopupParent = classToolbarPopup.getDeclaredField("mParent"); + fieldToolbarPopupParent.setAccessible(true); + + View currentView = (View) fieldToolbarPopupParent.get(popup); + if (currentView != windowView) { + fieldToolbarPopupParent.set(popup, windowView); + + Method method = classActionMode.getDeclaredMethod("updateViewLocationInWindow"); + method.setAccessible(true); + method.invoke(mode); + } + } catch (Throwable e) { + FileLog.e("tmessages", e); + } + } + private void onWindowSizeChanged() { int size = sizeNotifierLayout.getHeight(); if (!keyboardVisible) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java index de73728f3..8aaf358f1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PickerBottomLayout.java @@ -19,6 +19,7 @@ import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; +import org.telegram.ui.ActionBar.Theme; public class PickerBottomLayout extends FrameLayout { @@ -43,7 +44,7 @@ public class PickerBottomLayout extends FrameLayout { cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); cancelButton.setTextColor(isDarkTheme ? 0xffffffff : 0xff19a7e8); cancelButton.setGravity(Gravity.CENTER); - cancelButton.setBackgroundResource(isDarkTheme ? R.drawable.bar_selector_picker : R.drawable.bar_selector_audio); + cancelButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false)); cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0); cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase()); cancelButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); @@ -51,7 +52,7 @@ public class PickerBottomLayout extends FrameLayout { doneButton = new LinearLayout(context); doneButton.setOrientation(LinearLayout.HORIZONTAL); - doneButton.setBackgroundResource(isDarkTheme ? R.drawable.bar_selector_picker : R.drawable.bar_selector_audio); + doneButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false)); doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0); addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PlayerView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PlayerView.java index d85fae84a..18cbeaf85 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PlayerView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PlayerView.java @@ -32,6 +32,7 @@ import org.telegram.messenger.MessageObject; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.AudioPlayerActivity; public class PlayerView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate { @@ -54,7 +55,7 @@ public class PlayerView extends FrameLayout implements NotificationCenter.Notifi setTag(1); FrameLayout frameLayout = new FrameLayout(context); - frameLayout.setBackgroundColor(0xffffffff); + frameLayout.setBackgroundColor(Theme.INAPP_PLAYER_BACKGROUND_COLOR); addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 0)); View shadow = new View(context); @@ -76,7 +77,7 @@ public class PlayerView extends FrameLayout implements NotificationCenter.Notifi }); titleTextView = new TextView(context); - titleTextView.setTextColor(0xff212121); + titleTextView.setTextColor(Theme.INAPP_PLAYER_TITLE_TEXT_COLOR); titleTextView.setMaxLines(1); titleTextView.setLines(1); titleTextView.setSingleLine(true); @@ -163,9 +164,11 @@ public class PlayerView extends FrameLayout implements NotificationCenter.Notifi lastMessageObject = null; if (visible) { visible = false; - if (create && topPadding != 0) { + if (create) { clearAnimation(); - setVisibility(GONE); + if (getVisibility() != GONE) { + setVisibility(GONE); + } setTopPadding(0); } else { if (animatorSet != null) { @@ -233,7 +236,7 @@ public class PlayerView extends FrameLayout implements NotificationCenter.Notifi stringBuilder = new SpannableStringBuilder(String.format("%s - %s", messageObject.getMusicAuthor(), messageObject.getMusicTitle())); titleTextView.setEllipsize(TextUtils.TruncateAt.END); } - TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.INAPP_PLAYER_PERFORMER_TEXT_COLOR); stringBuilder.setSpan(span, 0, messageObject.getMusicAuthor().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); titleTextView.setText(stringBuilder); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java index c68e8709b..a6a40c039 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java @@ -25,6 +25,7 @@ import org.telegram.messenger.FileLoader; import org.telegram.messenger.R; import org.telegram.messenger.MessageObject; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Cells.BaseCell; import java.io.File; @@ -60,23 +61,23 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, super(context); if (backgroundMediaDrawableIn == null) { backgroundMediaDrawableIn = getResources().getDrawable(R.drawable.msg_in_photo); - statesDrawable[0][0] = getResources().getDrawable(R.drawable.play_w2); - statesDrawable[0][1] = getResources().getDrawable(R.drawable.play_w2_pressed); - statesDrawable[1][0] = getResources().getDrawable(R.drawable.pause_w2); - statesDrawable[1][1] = getResources().getDrawable(R.drawable.pause_w2_pressed); - statesDrawable[2][0] = getResources().getDrawable(R.drawable.download_g); - statesDrawable[2][1] = getResources().getDrawable(R.drawable.download_g_pressed); - statesDrawable[3][0] = getResources().getDrawable(R.drawable.pause_g); - statesDrawable[3][1] = getResources().getDrawable(R.drawable.pause_g_pressed); + statesDrawable[0][0] = getResources().getDrawable(R.drawable.play_g); + statesDrawable[0][1] = getResources().getDrawable(R.drawable.play_g_s); + statesDrawable[1][0] = getResources().getDrawable(R.drawable.pause_g); + statesDrawable[1][1] = getResources().getDrawable(R.drawable.pause_g_s); + statesDrawable[2][0] = getResources().getDrawable(R.drawable.file_g_load); + statesDrawable[2][1] = getResources().getDrawable(R.drawable.file_g_load_s); + statesDrawable[3][0] = getResources().getDrawable(R.drawable.file_g_cancel); + statesDrawable[3][1] = getResources().getDrawable(R.drawable.file_g_cancel_s); - statesDrawable[4][0] = getResources().getDrawable(R.drawable.play_w); - statesDrawable[4][1] = getResources().getDrawable(R.drawable.play_w_pressed); - statesDrawable[5][0] = getResources().getDrawable(R.drawable.pause_w); - statesDrawable[5][1] = getResources().getDrawable(R.drawable.pause_w_pressed); - statesDrawable[6][0] = getResources().getDrawable(R.drawable.download_b); - statesDrawable[6][1] = getResources().getDrawable(R.drawable.download_b_pressed); - statesDrawable[7][0] = getResources().getDrawable(R.drawable.pause_b); - statesDrawable[7][1] = getResources().getDrawable(R.drawable.pause_b_pressed); + statesDrawable[4][0] = getResources().getDrawable(R.drawable.play_b); + statesDrawable[4][1] = getResources().getDrawable(R.drawable.play_b_s); + statesDrawable[5][0] = getResources().getDrawable(R.drawable.pause_b); + statesDrawable[5][1] = getResources().getDrawable(R.drawable.pause_b_s); + statesDrawable[6][0] = getResources().getDrawable(R.drawable.file_b_load); + statesDrawable[6][1] = getResources().getDrawable(R.drawable.file_b_load_s); + statesDrawable[7][0] = getResources().getDrawable(R.drawable.file_b_cancel); + statesDrawable[7][1] = getResources().getDrawable(R.drawable.file_b_cancel_s); timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); timePaint.setTextSize(AndroidUtilities.dp(16)); @@ -91,7 +92,7 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, public void setMessageObject(MessageObject messageObject) { if (currentMessageObject != messageObject) { - seekBar.type = 1; + seekBar.setColors(Theme.MSG_IN_AUDIO_SEEKBAR_COLOR, Theme.MSG_IN_AUDIO_SEEKBAR_FILL_COLOR, Theme.MSG_IN_AUDIO_SEEKBAR_SELECTED_COLOR); progressView.setProgressColors(0xffd9e2eb, 0xff86c5f8); currentMessageObject = messageObject; @@ -123,8 +124,7 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, buttonX = AndroidUtilities.dp(10); timeX = getMeasuredWidth() - timeWidth - AndroidUtilities.dp(16); - seekBar.width = getMeasuredWidth() - AndroidUtilities.dp(70) - timeWidth; - seekBar.height = AndroidUtilities.dp(30); + seekBar.setSize(getMeasuredWidth() - AndroidUtilities.dp(70) - timeWidth, AndroidUtilities.dp(30)); progressView.width = getMeasuredWidth() - AndroidUtilities.dp(94) - timeWidth; progressView.height = AndroidUtilities.dp(30); seekBarY = AndroidUtilities.dp(13); @@ -248,11 +248,11 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, invalidate(); } } else if (buttonState == 2) { - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); + FileLoader.getInstance().loadFile(currentMessageObject.getDocument(), true, false); buttonState = 3; invalidate(); } else if (buttonState == 3) { - FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document); + FileLoader.getInstance().cancelLoadFile(currentMessageObject.getDocument()); buttonState = 2; invalidate(); } @@ -269,8 +269,8 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, int duration = 0; if (!MediaController.getInstance().isPlayingAudio(currentMessageObject)) { - for (int a = 0; a < currentMessageObject.messageOwner.media.document.attributes.size(); a++) { - TLRPC.DocumentAttribute attribute = currentMessageObject.messageOwner.media.document.attributes.get(a); + for (int a = 0; a < currentMessageObject.getDocument().attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = currentMessageObject.getDocument().attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeAudio) { duration = attribute.duration; break; @@ -289,7 +289,7 @@ public class PopupAudioView extends BaseCell implements SeekBar.SeekBarDelegate, public void downloadAudioIfNeed() { if (buttonState == 2) { - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); + FileLoader.getInstance().loadFile(currentMessageObject.getDocument(), true, false); buttonState = 3; invalidate(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RadialProgress.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RadialProgress.java index 4f68cd136..a21a27f36 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RadialProgress.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RadialProgress.java @@ -27,7 +27,7 @@ public class RadialProgress { private float animatedProgressValue = 0; private RectF progressRect = new RectF(); private RectF cicleRect = new RectF(); - private View parent = null; + private View parent; private float animatedAlphaValue = 1.0f; private boolean currentWithRound; @@ -37,8 +37,9 @@ public class RadialProgress { private boolean hideCurrentDrawable; private int progressColor = 0xffffffff; - private static DecelerateInterpolator decelerateInterpolator = null; - private static Paint progressPaint = null; + private static DecelerateInterpolator decelerateInterpolator; + private static Paint progressPaint; + private boolean alphaForPrevious = true; public RadialProgress(View parentView) { if (decelerateInterpolator == null) { @@ -46,7 +47,7 @@ public class RadialProgress { progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); progressPaint.setStyle(Paint.Style.STROKE); progressPaint.setStrokeCap(Paint.Cap.ROUND); - progressPaint.setStrokeWidth(AndroidUtilities.dp(2)); + progressPaint.setStrokeWidth(AndroidUtilities.dp(3)); } parent = parentView; } @@ -55,6 +56,10 @@ public class RadialProgress { progressRect.set(left, top, right, bottom); } + public void setAlphaForPrevious(boolean value) { + alphaForPrevious = value; + } + private void updateAnimation(boolean progress) { long newTime = System.currentTimeMillis(); long dt = newTime - lastUpdateTime; @@ -105,10 +110,17 @@ public class RadialProgress { } public void setProgress(float value, boolean animated) { + if (value != 1 && animatedAlphaValue != 0 && previousDrawable != null) { + animatedAlphaValue = 0.0f; + previousDrawable = null; + } if (!animated) { animatedProgressValue = value; animationProgressStart = value; } else { + if (animatedProgressValue > value) { + animatedProgressValue = value; + } animationProgressStart = animatedProgressValue; } currentProgress = value; @@ -125,10 +137,10 @@ public class RadialProgress { public void setBackground(Drawable drawable, boolean withRound, boolean animated) { lastUpdateTime = System.currentTimeMillis(); if (animated && currentDrawable != drawable) { - setProgress(1, animated); previousDrawable = currentDrawable; previousWithRound = currentWithRound; animatedAlphaValue = 1.0f; + setProgress(1, animated); } else { previousDrawable = null; previousWithRound = false; @@ -156,7 +168,11 @@ public class RadialProgress { public void draw(Canvas canvas) { if (previousDrawable != null) { - previousDrawable.setAlpha((int)(255 * animatedAlphaValue)); + if (alphaForPrevious) { + previousDrawable.setAlpha((int) (255 * animatedAlphaValue)); + } else { + previousDrawable.setAlpha(255); + } previousDrawable.setBounds((int)progressRect.left, (int)progressRect.top, (int)progressRect.right, (int)progressRect.bottom); previousDrawable.draw(canvas); } @@ -172,7 +188,7 @@ public class RadialProgress { } if (currentWithRound || previousWithRound) { - int diff = AndroidUtilities.dp(1); + int diff = AndroidUtilities.dp(4); progressPaint.setColor(progressColor); if (previousWithRound) { progressPaint.setAlpha((int)(255 * animatedAlphaValue)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RadioButton.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RadioButton.java index 1dd5e1a50..93bd1efff 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RadioButton.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RadioButton.java @@ -21,6 +21,7 @@ import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.FileLog; import org.telegram.messenger.ImageLoader; +import org.telegram.ui.ActionBar.Theme; public class RadioButton extends View { @@ -30,8 +31,8 @@ public class RadioButton extends View { private static Paint eraser; private static Paint checkedPaint; - private int checkedColor = 0xffd7e8f7; - private int color = 0xffd7e8f7; + private int checkedColor = Theme.ACTION_BAR_SUBTITLE_COLOR; + private int color = Theme.ACTION_BAR_SUBTITLE_COLOR; private float progress; private ObjectAnimatorProxy checkAnimator; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecordStatusDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecordStatusDrawable.java index 8f93244c5..6bcf6de14 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecordStatusDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecordStatusDrawable.java @@ -15,6 +15,7 @@ import android.graphics.RectF; import android.graphics.drawable.Drawable; import org.telegram.messenger.AndroidUtilities; +import org.telegram.ui.ActionBar.Theme; public class RecordStatusDrawable extends Drawable { @@ -27,7 +28,7 @@ public class RecordStatusDrawable extends Drawable { public RecordStatusDrawable() { super(); - paint.setColor(0xffd7e8f7); + paint.setColor(Theme.ACTION_BAR_SUBTITLE_COLOR); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(AndroidUtilities.dp(2)); paint.setStrokeCap(Paint.Cap.ROUND); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ResourceLoader.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ResourceLoader.java deleted file mode 100644 index 5d705c37d..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ResourceLoader.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 3.x.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-2016. - */ - -package org.telegram.ui.Components; - -import android.content.Context; -import android.graphics.drawable.Drawable; - -import org.telegram.messenger.R; - -public class ResourceLoader { - - public static Drawable backgroundDrawableIn; - public static Drawable backgroundDrawableInSelected; - public static Drawable backgroundDrawableOut; - public static Drawable backgroundDrawableOutSelected; - public static Drawable backgroundMediaDrawableIn; - public static Drawable backgroundMediaDrawableInSelected; - public static Drawable backgroundMediaDrawableOut; - public static Drawable backgroundMediaDrawableOutSelected; - public static Drawable checkDrawable; - public static Drawable halfCheckDrawable; - public static Drawable clockDrawable; - public static Drawable broadcastDrawable; - public static Drawable checkMediaDrawable; - public static Drawable halfCheckMediaDrawable; - public static Drawable clockMediaDrawable; - public static Drawable broadcastMediaDrawable; - public static Drawable errorDrawable; - public static Drawable backgroundBlack; - public static Drawable backgroundBlue; - public static Drawable mediaBackgroundDrawable; - public static Drawable[] clockChannelDrawable = new Drawable[2]; - - public static Drawable[][] shareDrawable = new Drawable[2][2]; - - public static Drawable[] viewsCountDrawable = new Drawable[2]; - public static Drawable viewsOutCountDrawable; - public static Drawable viewsMediaCountDrawable; - - public static Drawable geoInDrawable; - public static Drawable geoOutDrawable; - - public static Drawable[][] audioStatesDrawable = new Drawable[10][3]; - - public static Drawable[] placeholderDocDrawable = new Drawable[3]; - public static Drawable videoIconDrawable; - public static Drawable[] docMenuDrawable = new Drawable[3]; - public static Drawable[] buttonStatesDrawables = new Drawable[8]; - public static Drawable[][] buttonStatesDrawablesDoc = new Drawable[3][3]; - - public static void loadRecources(Context context) { - if (backgroundDrawableIn == null) { - backgroundDrawableIn = context.getResources().getDrawable(R.drawable.msg_in); - backgroundDrawableInSelected = context.getResources().getDrawable(R.drawable.msg_in_selected); - backgroundDrawableOut = context.getResources().getDrawable(R.drawable.msg_out); - backgroundDrawableOutSelected = context.getResources().getDrawable(R.drawable.msg_out_selected); - backgroundMediaDrawableIn = context.getResources().getDrawable(R.drawable.msg_in_photo); - backgroundMediaDrawableInSelected = context.getResources().getDrawable(R.drawable.msg_in_photo_selected); - backgroundMediaDrawableOut = context.getResources().getDrawable(R.drawable.msg_out_photo); - backgroundMediaDrawableOutSelected = context.getResources().getDrawable(R.drawable.msg_out_photo_selected); - checkDrawable = context.getResources().getDrawable(R.drawable.msg_check); - halfCheckDrawable = context.getResources().getDrawable(R.drawable.msg_halfcheck); - clockDrawable = context.getResources().getDrawable(R.drawable.msg_clock); - checkMediaDrawable = context.getResources().getDrawable(R.drawable.msg_check_w); - halfCheckMediaDrawable = context.getResources().getDrawable(R.drawable.msg_halfcheck_w); - clockMediaDrawable = context.getResources().getDrawable(R.drawable.msg_clock_photo); - clockChannelDrawable[0] = context.getResources().getDrawable(R.drawable.msg_clock2); - clockChannelDrawable[1] = context.getResources().getDrawable(R.drawable.msg_clock2_s); - errorDrawable = context.getResources().getDrawable(R.drawable.msg_warning); - mediaBackgroundDrawable = context.getResources().getDrawable(R.drawable.phototime); - broadcastDrawable = context.getResources().getDrawable(R.drawable.broadcast3); - broadcastMediaDrawable = context.getResources().getDrawable(R.drawable.broadcast4); - backgroundBlack = context.getResources().getDrawable(R.drawable.system_black); - backgroundBlue = context.getResources().getDrawable(R.drawable.system_blue); - - viewsCountDrawable[0] = context.getResources().getDrawable(R.drawable.post_views); - viewsCountDrawable[1] = context.getResources().getDrawable(R.drawable.post_views_s); - viewsOutCountDrawable = context.getResources().getDrawable(R.drawable.post_viewsg); - viewsMediaCountDrawable = context.getResources().getDrawable(R.drawable.post_views_w); - - audioStatesDrawable[0][2] = audioStatesDrawable[0][0] = context.getResources().getDrawable(R.drawable.play_w2); - audioStatesDrawable[0][1] = context.getResources().getDrawable(R.drawable.play_w2_pressed); - - audioStatesDrawable[1][2] = audioStatesDrawable[1][0] = context.getResources().getDrawable(R.drawable.pause_w2); - audioStatesDrawable[1][1] = context.getResources().getDrawable(R.drawable.pause_w2_pressed); - - audioStatesDrawable[2][0] = context.getResources().getDrawable(R.drawable.download_g); - audioStatesDrawable[2][1] = context.getResources().getDrawable(R.drawable.download_g_pressed); - audioStatesDrawable[2][2] = context.getResources().getDrawable(R.drawable.download_g_s); - - audioStatesDrawable[3][0] = context.getResources().getDrawable(R.drawable.pause_g); - audioStatesDrawable[3][1] = context.getResources().getDrawable(R.drawable.pause_g_pressed); - audioStatesDrawable[3][2] = context.getResources().getDrawable(R.drawable.pause_g_s); - - audioStatesDrawable[4][0] = context.getResources().getDrawable(R.drawable.cancel_g); - audioStatesDrawable[4][1] = context.getResources().getDrawable(R.drawable.cancel_g_pressed); - audioStatesDrawable[4][2] = context.getResources().getDrawable(R.drawable.cancel_g_s); - - audioStatesDrawable[5][2] = audioStatesDrawable[5][0] = context.getResources().getDrawable(R.drawable.play_w); - audioStatesDrawable[5][1] = context.getResources().getDrawable(R.drawable.play_w_pressed); - - audioStatesDrawable[6][2] = audioStatesDrawable[6][0] = context.getResources().getDrawable(R.drawable.pause_w); - audioStatesDrawable[6][1] = context.getResources().getDrawable(R.drawable.pause_w_pressed); - - audioStatesDrawable[7][0] = context.getResources().getDrawable(R.drawable.download_b); - audioStatesDrawable[7][1] = context.getResources().getDrawable(R.drawable.download_b_pressed); - audioStatesDrawable[7][2] = context.getResources().getDrawable(R.drawable.download_b_s); - - audioStatesDrawable[8][0] = context.getResources().getDrawable(R.drawable.pause_b); - audioStatesDrawable[8][1] = context.getResources().getDrawable(R.drawable.pause_b_pressed); - audioStatesDrawable[8][2] = context.getResources().getDrawable(R.drawable.pause_b_s); - - audioStatesDrawable[9][0] = context.getResources().getDrawable(R.drawable.cancel_b); - audioStatesDrawable[9][1] = context.getResources().getDrawable(R.drawable.cancel_b_pressed); - audioStatesDrawable[9][2] = context.getResources().getDrawable(R.drawable.cancel_b_s); - - placeholderDocDrawable[0] = context.getResources().getDrawable(R.drawable.doc_blue); - placeholderDocDrawable[1] = context.getResources().getDrawable(R.drawable.doc_green); - placeholderDocDrawable[2] = context.getResources().getDrawable(R.drawable.doc_blue_s); - buttonStatesDrawables[0] = context.getResources().getDrawable(R.drawable.photoload); - buttonStatesDrawables[1] = context.getResources().getDrawable(R.drawable.photocancel); - buttonStatesDrawables[2] = context.getResources().getDrawable(R.drawable.photogif); - buttonStatesDrawables[3] = context.getResources().getDrawable(R.drawable.playvideo); - buttonStatesDrawables[4] = context.getResources().getDrawable(R.drawable.photopause); - buttonStatesDrawables[5] = context.getResources().getDrawable(R.drawable.burn); - buttonStatesDrawables[6] = context.getResources().getDrawable(R.drawable.circle); - buttonStatesDrawables[7] = context.getResources().getDrawable(R.drawable.photocheck); - buttonStatesDrawablesDoc[0][0] = context.getResources().getDrawable(R.drawable.docload_b); - buttonStatesDrawablesDoc[0][1] = context.getResources().getDrawable(R.drawable.docload_g); - buttonStatesDrawablesDoc[0][2] = context.getResources().getDrawable(R.drawable.docload_b_s); - buttonStatesDrawablesDoc[1][0] = context.getResources().getDrawable(R.drawable.doccancel_b); - buttonStatesDrawablesDoc[1][1] = context.getResources().getDrawable(R.drawable.doccancel_g); - buttonStatesDrawablesDoc[1][2] = context.getResources().getDrawable(R.drawable.doccancel_b_s); - buttonStatesDrawablesDoc[2][0] = context.getResources().getDrawable(R.drawable.docpause_b); - buttonStatesDrawablesDoc[2][1] = context.getResources().getDrawable(R.drawable.docpause_g); - buttonStatesDrawablesDoc[2][2] = context.getResources().getDrawable(R.drawable.docpause_b_s); - videoIconDrawable = context.getResources().getDrawable(R.drawable.ic_video); - docMenuDrawable[0] = context.getResources().getDrawable(R.drawable.doc_actions_b); - docMenuDrawable[1] = context.getResources().getDrawable(R.drawable.doc_actions_g); - docMenuDrawable[2] = context.getResources().getDrawable(R.drawable.doc_actions_b_s); - - shareDrawable[0][0] = context.getResources().getDrawable(R.drawable.shareblue); - shareDrawable[0][1] = context.getResources().getDrawable(R.drawable.shareblue_pressed); - shareDrawable[1][0] = context.getResources().getDrawable(R.drawable.shareblack); - shareDrawable[1][1] = context.getResources().getDrawable(R.drawable.shareblack_pressed); - - geoInDrawable = context.getResources().getDrawable(R.drawable.location_b); - geoOutDrawable = context.getResources().getDrawable(R.drawable.location_g); - - context.getResources().getDrawable(R.drawable.attach_camera_states); - context.getResources().getDrawable(R.drawable.attach_gallery_states); - context.getResources().getDrawable(R.drawable.attach_video_states); - context.getResources().getDrawable(R.drawable.attach_audio_states); - context.getResources().getDrawable(R.drawable.attach_file_states); - context.getResources().getDrawable(R.drawable.attach_contact_states); - context.getResources().getDrawable(R.drawable.attach_location_states); - context.getResources().getDrawable(R.drawable.attach_hide_states); - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBar.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBar.java index fddeafa74..87a77c457 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBar.java @@ -21,36 +21,25 @@ public class SeekBar { void onSeekBarDrag(float progress); } - private static Paint innerPaint1; - private static Paint outerPaint1; - private static Paint innerPaint2; - private static Paint outerPaint2; + private static Paint innerPaint; + private static Paint outerPaint; private static int thumbWidth; - private static int thumbHeight; - public int type; - public int thumbX = 0; - public int thumbDX = 0; + private int thumbX = 0; + private int thumbDX = 0; private boolean pressed = false; - public int width; - public int height; + private int width; + private int height; private SeekBarDelegate delegate; + private int innerColor; + private int outerColor; + private int selectedColor; + private boolean selected; public SeekBar(Context context) { - if (innerPaint1 == null) { - innerPaint1 = new Paint(Paint.ANTI_ALIAS_FLAG); - innerPaint1.setColor(0xffc3e3ab); - - outerPaint1 = new Paint(Paint.ANTI_ALIAS_FLAG); - outerPaint1.setColor(0xff87bf78); - - innerPaint2 = new Paint(Paint.ANTI_ALIAS_FLAG); - innerPaint2.setColor(0xffe4eaf0); - - outerPaint2 = new Paint(Paint.ANTI_ALIAS_FLAG); - outerPaint2.setColor(0xff4195e5); - + if (innerPaint == null) { + innerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + outerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); thumbWidth = AndroidUtilities.dp(24); - thumbHeight = AndroidUtilities.dp(24); } } @@ -88,6 +77,12 @@ public class SeekBar { return false; } + public void setColors(int inner, int outer, int selected) { + innerColor = inner; + outerColor = outer; + selectedColor = selected; + } + public void setProgress(float progress) { thumbX = (int)Math.ceil((width - thumbWidth) * progress); if (thumbX < 0) { @@ -101,19 +96,21 @@ public class SeekBar { return pressed; } + public void setSelected(boolean value) { + selected = value; + } + + public void setSize(int w, int h) { + width = w; + height = h; + } + public void draw(Canvas canvas) { - Paint inner = null; - Paint outer = null; - if (type == 0) { - inner = innerPaint1; - outer = outerPaint1; - } else if (type == 1) { - inner = innerPaint2; - outer = outerPaint2; - } - int y = (height - thumbHeight) / 2; - canvas.drawRect(thumbWidth / 2, height / 2 - AndroidUtilities.dp(1), width - thumbWidth / 2, height / 2 + AndroidUtilities.dp(1), inner); - canvas.drawRect(thumbWidth / 2, height / 2 - AndroidUtilities.dp(1), thumbWidth / 2 + thumbX, height / 2 + AndroidUtilities.dp(1), outer); - canvas.drawCircle(thumbX + thumbWidth / 2, y + thumbHeight / 2, AndroidUtilities.dp(pressed ? 8 : 6), outer); + innerPaint.setColor(selected ? selectedColor : innerColor); + outerPaint.setColor(outerColor); + + canvas.drawRect(thumbWidth / 2, height / 2 - AndroidUtilities.dp(1), width - thumbWidth / 2, height / 2 + AndroidUtilities.dp(1), innerPaint); + canvas.drawRect(thumbWidth / 2, height / 2 - AndroidUtilities.dp(1), thumbWidth / 2 + thumbX, height / 2 + AndroidUtilities.dp(1), outerPaint); + canvas.drawCircle(thumbX + thumbWidth / 2, height / 2, AndroidUtilities.dp(pressed ? 8 : 6), outerPaint); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarWaveform.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarWaveform.java index 385893d12..776fbe48c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarWaveform.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBarWaveform.java @@ -21,13 +21,13 @@ public class SeekBarWaveform { private static Paint paintInner; private static Paint paintOuter; - public int thumbX = 0; - public int thumbDX = 0; + private int thumbX = 0; + private int thumbDX = 0; private float startX; private boolean startDraging = false; private boolean pressed = false; - public int width; - public int height; + private int width; + private int height; private SeekBar.SeekBarDelegate delegate; private byte[] waveformBytes; private MessageObject messageObject; @@ -128,6 +128,11 @@ public class SeekBarWaveform { return pressed; } + public void setSize(int w, int h) { + width = w; + height = h; + } + public void draw(Canvas canvas) { if (waveformBytes == null || width == 0) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileDrawable.java index 3e68de538..60c13ea66 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileDrawable.java @@ -16,6 +16,7 @@ import android.graphics.drawable.Drawable; import android.view.animation.DecelerateInterpolator; import org.telegram.messenger.AndroidUtilities; +import org.telegram.ui.ActionBar.Theme; public class SendingFileDrawable extends Drawable { @@ -33,7 +34,7 @@ public class SendingFileDrawable extends Drawable { public SendingFileDrawable() { super(); - paint.setColor(0xffd7e8f7); + paint.setColor(Theme.ACTION_BAR_SUBTITLE_COLOR); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(AndroidUtilities.dp(2)); paint.setStrokeCap(Paint.Cap.ROUND); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileEx2Drawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileEx2Drawable.java index 25f0ae6b0..5770e9d04 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileEx2Drawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileEx2Drawable.java @@ -14,6 +14,7 @@ import android.graphics.Paint; import android.graphics.drawable.Drawable; import org.telegram.messenger.AndroidUtilities; +import org.telegram.ui.ActionBar.Theme; public class SendingFileEx2Drawable extends Drawable { @@ -25,7 +26,7 @@ public class SendingFileEx2Drawable extends Drawable { public SendingFileEx2Drawable() { super(); - paint.setColor(0xffd7e8f7); + paint.setColor(Theme.ACTION_BAR_SUBTITLE_COLOR); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(AndroidUtilities.dp(3)); paint.setStrokeCap(Paint.Cap.ROUND); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileExDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileExDrawable.java index 48d5d917e..9953d0bfc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileExDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileExDrawable.java @@ -14,6 +14,7 @@ import android.graphics.Paint; import android.graphics.drawable.Drawable; import org.telegram.messenger.AndroidUtilities; +import org.telegram.ui.ActionBar.Theme; public class SendingFileExDrawable extends Drawable { @@ -25,7 +26,7 @@ public class SendingFileExDrawable extends Drawable { public SendingFileExDrawable() { super(); - paint.setColor(0xffd7e8f7); + paint.setColor(Theme.ACTION_BAR_SUBTITLE_COLOR); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(AndroidUtilities.dp(2)); paint.setStrokeCap(Paint.Cap.ROUND); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareFrameLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java similarity index 73% rename from TMessagesProj/src/main/java/org/telegram/ui/Components/ShareFrameLayout.java rename to TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java index cad5ced81..440205d3a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareFrameLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java @@ -8,7 +8,10 @@ package org.telegram.ui.Components; +import android.annotation.SuppressLint; import android.content.Context; +import android.graphics.*; +import android.graphics.drawable.Drawable; import android.os.Build; import android.text.Editable; import android.text.InputType; @@ -20,10 +23,8 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; -import android.widget.AdapterView; import android.widget.EditText; import android.widget.FrameLayout; -import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -40,13 +41,15 @@ import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.R; import org.telegram.messenger.SendMessagesHelper; +import org.telegram.messenger.support.widget.GridLayoutManager; +import org.telegram.messenger.support.widget.RecyclerView; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.NativeByteBuffer; import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.BottomSheet; -import org.telegram.ui.Adapters.BaseFragmentAdapter; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Cells.ShareDialogCell; import java.util.ArrayList; @@ -57,18 +60,22 @@ import java.util.Locale; import java.util.Timer; import java.util.TimerTask; -public class ShareFrameLayout extends FrameLayout { +public class ShareAlert extends BottomSheet { - private BottomSheet parentBottomSheet; + private FrameLayout frameLayout; + private FrameLayout container; private TextView doneButtonBadgeTextView; private TextView doneButtonTextView; private LinearLayout doneButton; private EditText nameTextView; - private GridView gridView; + private View shadow; + private RecyclerListView gridView; + private GridLayoutManager layoutManager; private ShareDialogsAdapter listAdapter; private ShareSearchAdapter searchAdapter; private MessageObject sendingMessageObject; private EmptyTextProgressView searchEmptyView; + private Drawable shadowDrawable; private HashMap selectedDialogs = new HashMap<>(); private TLRPC.TL_exportedMessageLink exportedMessageLink; @@ -77,10 +84,19 @@ public class ShareFrameLayout extends FrameLayout { private boolean isPublicChannel; - public ShareFrameLayout(final Context context, BottomSheet bottomSheet, final MessageObject messageObject, boolean publicChannel) { - super(context); + private int scrollOffsetY; + private int topBeforeSwitch; + + public ShareAlert(final Context context, final MessageObject messageObject, boolean publicChannel) { + super(context, true); + setApplyTopPadding(false); + setApplyBottomPadding(false); + if (Build.VERSION.SDK_INT >= 11) { + setDisableBackground(true); + } + + shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow); - parentBottomSheet = bottomSheet; sendingMessageObject = messageObject; searchAdapter = new ShareSearchAdapter(context); isPublicChannel = publicChannel; @@ -110,26 +126,91 @@ public class ShareFrameLayout extends FrameLayout { }); } - FrameLayout frameLayout = new FrameLayout(context); + container = new FrameLayout(context) { + + private boolean ignoreLayout = false; + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return scrollOffsetY != 0 && ev.getY() < scrollOffsetY || super.onInterceptTouchEvent(ev); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int height = MeasureSpec.getSize(heightMeasureSpec); + if (Build.VERSION.SDK_INT >= 21) { + height -= AndroidUtilities.statusBarHeight; + } + int size = Math.max(searchAdapter.getItemCount(), listAdapter.getItemCount()); + int contentSize = AndroidUtilities.dp(48) + Math.max(3, (int) Math.ceil(size / 4.0f)) * AndroidUtilities.dp(100) + backgroundPaddingTop; + if (Build.VERSION.SDK_INT < 11) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(contentSize, AndroidUtilities.displaySize.y / 5 * 3), MeasureSpec.EXACTLY)); + } else { + int padding = contentSize < height ? 0 : height - (height / 5 * 3) + AndroidUtilities.dp(8); + if (gridView.getPaddingTop() != padding) { + ignoreLayout = true; + gridView.setPadding(0, padding, 0, AndroidUtilities.dp(8)); + ignoreLayout = false; + } + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(contentSize, height), MeasureSpec.EXACTLY)); + } + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + if (Build.VERSION.SDK_INT >= 11) { + updateLayout(); + } + } + + @Override + public void requestLayout() { + if (ignoreLayout) { + return; + } + super.requestLayout(); + } + + @Override + protected void onDraw(Canvas canvas) { + if (Build.VERSION.SDK_INT >= 11) { + shadowDrawable.setBounds(0, scrollOffsetY - backgroundPaddingTop, getMeasuredWidth(), getMeasuredHeight()); + shadowDrawable.draw(canvas); + } + } + }; + if (Build.VERSION.SDK_INT >= 11) { + container.setWillNotDraw(false); + } + container.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0); + setCustomView(container); + + frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(0xffffffff); - addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP)); + frameLayout.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return true; + } + }); doneButton = new LinearLayout(context); doneButton.setOrientation(LinearLayout.HORIZONTAL); - doneButton.setBackgroundResource(R.drawable.bar_selector_audio); + doneButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false)); doneButton.setPadding(AndroidUtilities.dp(21), 0, AndroidUtilities.dp(21), 0); frameLayout.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT)); - doneButton.setOnClickListener(new OnClickListener() { + doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selectedDialogs.isEmpty() && isPublicChannel) { if (loadingLink) { copyLinkOnEnd = true; - Toast.makeText(ShareFrameLayout.this.getContext(), LocaleController.getString("Loading", R.string.Loading), Toast.LENGTH_SHORT).show(); + Toast.makeText(ShareAlert.this.getContext(), LocaleController.getString("Loading", R.string.Loading), Toast.LENGTH_SHORT).show(); } else { - copyLink(ShareFrameLayout.this.getContext()); + copyLink(ShareAlert.this.getContext()); } - parentBottomSheet.dismiss(); + dismiss(); } else { ArrayList arrayList = new ArrayList<>(); arrayList.add(sendingMessageObject); @@ -145,7 +226,7 @@ public class ShareFrameLayout extends FrameLayout { } SendMessagesHelper.getInstance().sendMessage(arrayList, entry.getKey(), asAdmin); } - parentBottomSheet.dismiss(); + dismiss(); } } }); @@ -153,7 +234,7 @@ public class ShareFrameLayout extends FrameLayout { doneButtonBadgeTextView = new TextView(context); doneButtonBadgeTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); - doneButtonBadgeTextView.setTextColor(0xffffffff); + doneButtonBadgeTextView.setTextColor(Theme.SHARE_SHEET_BADGE_TEXT_COLOR); doneButtonBadgeTextView.setGravity(Gravity.CENTER); doneButtonBadgeTextView.setBackgroundResource(R.drawable.bluecounter); doneButtonBadgeTextView.setMinWidth(AndroidUtilities.dp(23)); @@ -162,7 +243,6 @@ public class ShareFrameLayout extends FrameLayout { doneButtonTextView = new TextView(context); doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - doneButtonTextView.setTextColor(0xff19a7e8); doneButtonTextView.setGravity(Gravity.CENTER); doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8)); doneButtonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); @@ -181,11 +261,11 @@ public class ShareFrameLayout extends FrameLayout { nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); nameTextView.setBackgroundDrawable(null); - nameTextView.setHintTextColor(0xff979797); + nameTextView.setHintTextColor(Theme.SHARE_SHEET_EDIT_PLACEHOLDER_TEXT_COLOR); nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); nameTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); AndroidUtilities.clearCursorDrawable(nameTextView); - nameTextView.setTextColor(0xff212121); + nameTextView.setTextColor(Theme.SHARE_SHEET_EDIT_TEXT_COLOR); frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 48, 2, 96, 0)); nameTextView.addTextChangedListener(new TextWatcher() { @Override @@ -203,6 +283,7 @@ public class ShareFrameLayout extends FrameLayout { String text = nameTextView.getText().toString(); if (text.length() != 0) { if (gridView.getAdapter() != searchAdapter) { + topBeforeSwitch = getCurrentTop(); gridView.setAdapter(searchAdapter); searchAdapter.notifyDataSetChanged(); } @@ -211,9 +292,13 @@ public class ShareFrameLayout extends FrameLayout { } } else { if (gridView.getAdapter() != listAdapter) { + int top = getCurrentTop(); searchEmptyView.setText(LocaleController.getString("NoChats", R.string.NoChats)); gridView.setAdapter(listAdapter); listAdapter.notifyDataSetChanged(); + if (top > 0) { + layoutManager.scrollToPositionWithOffset(0, -top); + } } } if (searchAdapter != null) { @@ -222,39 +307,37 @@ public class ShareFrameLayout extends FrameLayout { } }); - View lineView = new View(context); - lineView.setBackgroundResource(R.drawable.header_shadow); - addView(lineView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); - - setOnTouchListener(new OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - return true; - } - }); - - gridView = new GridView(context); - gridView.setDrawSelectorOnTop(true); - gridView.setPadding(0, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8)); + gridView = new RecyclerListView(context); + gridView.setPadding(0, 0, 0, AndroidUtilities.dp(8)); gridView.setClipToPadding(false); - gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); + gridView.setLayoutManager(layoutManager = new GridLayoutManager(getContext(), 4)); gridView.setHorizontalScrollBarEnabled(false); gridView.setVerticalScrollBarEnabled(false); - gridView.setNumColumns(4); - gridView.setVerticalSpacing(AndroidUtilities.dp(4)); - gridView.setHorizontalSpacing(AndroidUtilities.dp(4)); - gridView.setSelector(R.drawable.list_selector); - addView(gridView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); - gridView.setAdapter(listAdapter = new ShareDialogsAdapter(context)); - AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); - gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + gridView.addItemDecoration(new RecyclerView.ItemDecoration() { @Override - public void onItemClick(AdapterView adapterView, View view, int i, long l) { + public void getItemOffsets(android.graphics.Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + Holder holder = (Holder) parent.getChildViewHolder(view); + if (holder != null) { + int pos = holder.getAdapterPosition(); + outRect.left = pos % 4 == 0 ? 0 : AndroidUtilities.dp(4); + outRect.right = pos % 4 == 3 ? 0 : AndroidUtilities.dp(4); + } else { + outRect.left = AndroidUtilities.dp(4); + outRect.right = AndroidUtilities.dp(4); + } + } + }); + container.addView(gridView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); + gridView.setAdapter(listAdapter = new ShareDialogsAdapter(context)); + gridView.setGlowColor(0xfff5f6f7); + gridView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { + @Override + public void onItemClick(View view, int position) { TLRPC.Dialog dialog; if (gridView.getAdapter() == listAdapter) { - dialog = listAdapter.getItem(i); + dialog = listAdapter.getItem(position); } else { - dialog = searchAdapter.getItem(i); + dialog = searchAdapter.getItem(position); } ShareDialogCell cell = (ShareDialogCell) view; if (selectedDialogs.containsKey(dialog.id)) { @@ -267,18 +350,62 @@ public class ShareFrameLayout extends FrameLayout { updateSelectedCount(); } }); + if (Build.VERSION.SDK_INT >= 11) { + gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { + @SuppressLint("NewApi") + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + updateLayout(); + } + }); + } searchEmptyView = new EmptyTextProgressView(context); searchEmptyView.setShowAtCenter(true); searchEmptyView.showTextView(); searchEmptyView.setText(LocaleController.getString("NoChats", R.string.NoChats)); gridView.setEmptyView(searchEmptyView); - addView(searchEmptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); + container.addView(searchEmptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); + + container.addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP)); + + shadow = new View(context); + shadow.setBackgroundResource(R.drawable.header_shadow); + container.addView(shadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); updateSelectedCount(); } - public void copyLink(Context context) { + private int getCurrentTop() { + if (gridView.getChildCount() != 0) { + View child = gridView.getChildAt(0); + Holder holder = (Holder) gridView.findContainingViewHolder(child); + if (holder != null) { + return gridView.getPaddingTop() - (holder.getAdapterPosition() == 0 && child.getTop() >= 0 ? child.getTop() : 0); + } + } + return -1000; + } + + @SuppressLint("NewApi") + private void updateLayout() { + if (gridView.getChildCount() <= 0) { + return; + } + View child = gridView.getChildAt(0); + Holder holder = (Holder) gridView.findContainingViewHolder(child); + int top = child.getTop() - AndroidUtilities.dp(8); + int newOffset = top > 0 && holder != null && holder.getAdapterPosition() == 0 ? top : 0; + if (scrollOffsetY != newOffset) { + gridView.setTopGlowOffset(scrollOffsetY = newOffset); + frameLayout.setTranslationY(scrollOffsetY); + shadow.setTranslationY(scrollOffsetY); + searchEmptyView.setTranslationY(scrollOffsetY); + container.invalidate(); + } + } + + private void copyLink(Context context) { if (exportedMessageLink == null) { return; } @@ -301,11 +428,11 @@ public class ShareFrameLayout extends FrameLayout { if (selectedDialogs.isEmpty()) { doneButtonBadgeTextView.setVisibility(View.GONE); if (!isPublicChannel) { - doneButtonTextView.setTextColor(0xffb3b3b3); + doneButtonTextView.setTextColor(Theme.SHARE_SHEET_SEND_DISABLED_TEXT_COLOR); doneButton.setEnabled(false); doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase()); } else { - doneButtonTextView.setTextColor(0xff517fad); + doneButtonTextView.setTextColor(Theme.SHARE_SHEET_COPY_TEXT_COLOR); doneButton.setEnabled(true); doneButtonTextView.setText(LocaleController.getString("CopyLink", R.string.CopyLink).toUpperCase()); } @@ -313,25 +440,27 @@ public class ShareFrameLayout extends FrameLayout { doneButtonTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); doneButtonBadgeTextView.setVisibility(View.VISIBLE); doneButtonBadgeTextView.setText(String.format("%d", selectedDialogs.size())); - doneButtonTextView.setTextColor(0xff3ec1f9); + doneButtonTextView.setTextColor(Theme.SHARE_SHEET_SEND_TEXT_COLOR); doneButton.setEnabled(true); doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase()); } } - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(310), MeasureSpec.EXACTLY)); + private class Holder extends RecyclerView.ViewHolder { + + public Holder(View itemView) { + super(itemView); + } } - private class ShareDialogsAdapter extends BaseFragmentAdapter { + private class ShareDialogsAdapter extends RecyclerView.Adapter { - private Context mContext; + private Context context; private int currentCount; private ArrayList dialogs = new ArrayList<>(); public ShareDialogsAdapter(Context context) { - mContext = context; + this.context = context; for (int a = 0; a < MessagesController.getInstance().dialogsServerOnly.size(); a++) { TLRPC.Dialog dialog = MessagesController.getInstance().dialogsServerOnly.get(a); int lower_id = (int) dialog.id; @@ -350,7 +479,7 @@ public class ShareFrameLayout extends FrameLayout { } @Override - public int getCount() { + public int getItemCount() { return dialogs.size(); } @@ -367,35 +496,28 @@ public class ShareFrameLayout extends FrameLayout { } @Override - public View getView(int i, View view, ViewGroup viewGroup) { - if (view == null) { - view = new ShareDialogCell(mContext); - } - ShareDialogCell cell = (ShareDialogCell) view; - TLRPC.Dialog dialog = getItem(i); + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = new ShareDialogCell(context); + view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(100))); + return new Holder(view); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + ShareDialogCell cell = (ShareDialogCell) holder.itemView; + TLRPC.Dialog dialog = getItem(position); cell.setDialog(dialog, selectedDialogs.containsKey(dialog.id), null); - return view; } @Override public int getItemViewType(int i) { return 0; } - - @Override - public int getViewTypeCount() { - return 1; - } - - @Override - public boolean isEmpty() { - return getCount() == 0; - } } - public class ShareSearchAdapter extends BaseFragmentAdapter { + public class ShareSearchAdapter extends RecyclerView.Adapter { - private Context mContext; + private Context context; private Timer searchTimer; private ArrayList searchResult = new ArrayList<>(); private String lastSearchText; @@ -411,7 +533,7 @@ public class ShareFrameLayout extends FrameLayout { } public ShareSearchAdapter(Context context) { - mContext = context; + this.context = context; } private void searchDialogsInternal(final String query, final int searchId) { @@ -629,8 +751,17 @@ public class ShareFrameLayout extends FrameLayout { MessagesController.getInstance().putChat(chat, true); } } + boolean becomeEmpty = !searchResult.isEmpty() && result.isEmpty(); + boolean isEmpty = searchResult.isEmpty() && result.isEmpty(); + if (becomeEmpty) { + topBeforeSwitch = getCurrentTop(); + } searchResult = result; notifyDataSetChanged(); + if (!isEmpty && !becomeEmpty && topBeforeSwitch > 0) { + layoutManager.scrollToPositionWithOffset(0, -topBeforeSwitch); + topBeforeSwitch = -1000; + } } }); } @@ -650,6 +781,7 @@ public class ShareFrameLayout extends FrameLayout { } if (query == null || query.length() == 0) { searchResult.clear(); + topBeforeSwitch = getCurrentTop(); notifyDataSetChanged(); } else { final int searchId = ++lastSearchId; @@ -671,7 +803,7 @@ public class ShareFrameLayout extends FrameLayout { } @Override - public int getCount() { + public int getItemCount() { return searchResult.size(); } @@ -685,24 +817,22 @@ public class ShareFrameLayout extends FrameLayout { } @Override - public View getView(int i, View view, ViewGroup viewGroup) { - if (view == null) { - view = new ShareDialogCell(mContext); - } - ShareDialogCell cell = (ShareDialogCell) view; - DialogSearchResult result = searchResult.get(i); + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = new ShareDialogCell(context); + view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(100))); + return new Holder(view); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + ShareDialogCell cell = (ShareDialogCell) holder.itemView; + DialogSearchResult result = searchResult.get(position); cell.setDialog(result.dialog, selectedDialogs.containsKey(result.dialog.id), result.name); - return view; } @Override public int getItemViewType(int i) { return 0; } - - @Override - public boolean isEmpty() { - return getCount() == 0; - } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleTextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleTextView.java deleted file mode 100644 index 4b135739f..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleTextView.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 3.x.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-2016. - */ - -package org.telegram.ui.Components; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.Typeface; -import android.text.Layout; -import android.text.SpannableStringBuilder; -import android.text.StaticLayout; -import android.text.TextPaint; -import android.text.TextUtils; -import android.view.Gravity; -import android.view.View; - -import org.telegram.messenger.AndroidUtilities; - -public class SimpleTextView extends View { - - private Layout layout; - private TextPaint textPaint; - private int gravity; - private CharSequence text; - private SpannableStringBuilder spannableStringBuilder; - - private int offsetX; - private boolean wasLayout = false; - - public SimpleTextView(Context context) { - super(context); - textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - } - - public void setTextColor(int color) { - textPaint.setColor(color); - } - - public void setTextSize(int size) { - textPaint.setTextSize(AndroidUtilities.dp(size)); - } - - public void setGravity(int value) { - gravity = value; - } - - public void setTypeface(Typeface typeface) { - textPaint.setTypeface(typeface); - } - - private void createLayout(int width) { - if (text != null) { - try { - CharSequence string = TextUtils.ellipsize(text, textPaint, width, TextUtils.TruncateAt.END); - layout = new StaticLayout(string, 0, string.length(), textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - - /*if (metrics == null) { - metrics = BoringLayout.isBoring(text, textPaint); - } - if (layout == null) { - layout = BoringLayout.make(text, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, metrics, false, TextUtils.TruncateAt.END, width); - } else { - layout = ((BoringLayout) layout).replaceOrMake(text, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, metrics, false, TextUtils.TruncateAt.END, width); - }*/ - - /*if (spannableStringBuilder == null) { - spannableStringBuilder = new SpannableStringBuilder(text); - layout = new DynamicLayout(text, text, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, width); - } else { - spannableStringBuilder.replace(0, text.length(), text); - }*/ - - if (layout.getLineCount() > 0) { - if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) { - offsetX = -(int) layout.getLineLeft(0); - } else if (layout.getLineLeft(0) == 0) { - offsetX = (int) (width - layout.getLineWidth(0)); - } else { - offsetX = 0; - } - offsetX += getPaddingLeft(); - } - } catch (Exception e) { - //ignore - } - } - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - if (changed) { - createLayout(right - left - getPaddingLeft() - getPaddingRight()); - invalidate(); - wasLayout = true; - } - } - - public void setText(CharSequence value) { - text = value; - if (wasLayout) { - createLayout(getMeasuredWidth() - getPaddingLeft() - getPaddingRight()); - invalidate(); - } else { - requestLayout(); - } - } - - @Override - protected void onDraw(Canvas canvas) { - if (layout != null) { - if (offsetX != 0) { - canvas.save(); - canvas.translate(offsetX, 0); - } - layout.draw(canvas); - if (offsetX != 0) { - canvas.restore(); - } - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java index d81c556fd..8cb1adadb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java @@ -20,7 +20,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.R; +import org.telegram.ui.ActionBar.Theme; public class SlidingTabView extends LinearLayout { @@ -58,7 +58,7 @@ public class SlidingTabView extends LinearLayout { tab.setTextColor(0xffffffff); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); tab.setTypeface(Typeface.DEFAULT_BOLD); - tab.setBackgroundResource(R.drawable.bar_selector_picker); + tab.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false)); tab.setOnClickListener(new OnClickListener() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java index 97916e024..eae765ee7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java @@ -8,80 +8,545 @@ package org.telegram.ui.Components; -import android.app.AlertDialog; +import android.annotation.SuppressLint; import android.content.Context; -import android.content.DialogInterface; -import android.database.DataSetObserver; +import android.graphics.*; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.text.TextUtils; +import android.util.TypedValue; +import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.widget.BaseAdapter; import android.widget.FrameLayout; -import android.widget.GridView; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; +import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; +import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.messenger.AnimationCompat.ViewProxy; +import org.telegram.messenger.Emoji; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; +import org.telegram.messenger.R; +import org.telegram.messenger.query.StickersQuery; +import org.telegram.messenger.support.widget.GridLayoutManager; +import org.telegram.messenger.support.widget.RecyclerView; +import org.telegram.tgnet.ConnectionsManager; +import org.telegram.tgnet.RequestDelegate; +import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.ActionBar.BottomSheet; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Cells.StickerEmojiCell; import org.telegram.ui.StickerPreviewViewer; -import java.util.ArrayList; +public class StickersAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate { -public class StickersAlert extends AlertDialog implements NotificationCenter.NotificationCenterDelegate { + public interface StickersAlertDelegate { + void onStickerSelected(TLRPC.Document sticker); + } - private ArrayList stickers; - private GridView gridView; + private FrameLayout container; + private RecyclerListView gridView; + private GridLayoutManager layoutManager; + private GridAdapter adapter; + private TextView titleTextView; + private PickerBottomLayout pickerBottomLayout; + private FrameLayout stickerPreviewLayout; + private TextView previewSendButton; + private View previewSendButtonShadow; + private BackupImageView stickerImageView; + private TextView stickerEmojiTextView; + private RecyclerListView.OnItemClickListener stickersOnItemClickListener; + private Drawable shadowDrawable; + private AnimatorSetProxy shadowAnimation[] = new AnimatorSetProxy[2]; + private View shadow[] = new View[2]; + private FrameLayout emptyView; - public StickersAlert(Context context, TLRPC.TL_messages_stickerSet set) { - super(context); - stickers = set.documents; + private TLRPC.TL_messages_stickerSet stickerSet; + private TLRPC.Document selectedSticker; + private TLRPC.InputStickerSet inputStickerSet; + + private StickersAlertDelegate delegate; + + private int scrollOffsetY; + private int reqId; + private boolean ignoreLayout = false; + + public StickersAlert(Context context, TLRPC.InputStickerSet set, TLRPC.TL_messages_stickerSet loadedSet, StickersAlertDelegate stickersAlertDelegate) { + super(context, false); + setApplyTopPadding(false); + setApplyBottomPadding(false); + if (Build.VERSION.SDK_INT >= 11) { + setDisableBackground(true); + } + + delegate = stickersAlertDelegate; + inputStickerSet = set; + stickerSet = loadedSet; + shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow); + + container = new FrameLayout(context) { + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return scrollOffsetY != 0 && ev.getY() < scrollOffsetY || super.onInterceptTouchEvent(ev); + } - FrameLayout container = new FrameLayout(context) { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec((int) Math.min(Math.ceil(stickers.size() / 4.0f) * AndroidUtilities.dp(82), AndroidUtilities.displaySize.y / 5 * 3), MeasureSpec.EXACTLY)); + int height = MeasureSpec.getSize(heightMeasureSpec); + if (Build.VERSION.SDK_INT >= 21) { + height -= AndroidUtilities.statusBarHeight; + } + int contentSize = AndroidUtilities.dp(48 + 48) + Math.max(3, (stickerSet != null ? (int) Math.ceil(stickerSet.documents.size() / 5.0f) : 0)) * AndroidUtilities.dp(82) + backgroundPaddingTop; + if (Build.VERSION.SDK_INT < 11) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(contentSize, AndroidUtilities.displaySize.y / 5 * 3), MeasureSpec.EXACTLY)); + } else { + int padding = contentSize < (height / 5 * 3.2) ? 0 : (height / 5 * 2); + if (padding != 0 && contentSize < height) { + padding -= (height - contentSize); + } + if (padding == 0) { + padding = backgroundPaddingTop; + } + if (gridView.getPaddingTop() != padding) { + ignoreLayout = true; + gridView.setPadding(AndroidUtilities.dp(10), padding, AndroidUtilities.dp(10), 0); + emptyView.setPadding(0, padding, 0, 0); + ignoreLayout = false; + } + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(contentSize, height), MeasureSpec.EXACTLY)); + } + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + if (Build.VERSION.SDK_INT >= 11) { + updateLayout(); + } + } + + @Override + public void requestLayout() { + if (ignoreLayout) { + return; + } + super.requestLayout(); + } + + @Override + protected void onDraw(Canvas canvas) { + if (Build.VERSION.SDK_INT >= 11) { + shadowDrawable.setBounds(0, scrollOffsetY - backgroundPaddingTop, getMeasuredWidth(), getMeasuredHeight()); + shadowDrawable.draw(canvas); + } } }; - setView(container, AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0); + if (Build.VERSION.SDK_INT >= 11) { + container.setWillNotDraw(false); + } + container.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0); + setCustomView(container); - gridView = new GridView(context) { + titleTextView = new TextView(context); + + titleTextView = new TextView(getContext()); + titleTextView.setLines(1); + titleTextView.setSingleLine(true); + titleTextView.setTextColor(Theme.STICKERS_SHEET_TITLE_TEXT_COLOR); + titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); + titleTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE); + titleTextView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + titleTextView.setGravity(Gravity.CENTER_VERTICAL); + titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + container.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); + titleTextView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return true; + } + }); + + shadow[0] = new View(context); + shadow[0].setBackgroundResource(R.drawable.header_shadow); + ViewProxy.setAlpha(shadow[0], 0.0f); + shadow[0].clearAnimation(); + shadow[0].setVisibility(View.INVISIBLE); + shadow[0].setTag(1); + container.addView(shadow[0], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); + + gridView = new RecyclerListView(context) { @Override public boolean onInterceptTouchEvent(MotionEvent event) { boolean result = StickerPreviewViewer.getInstance().onInterceptTouchEvent(event, gridView, 0); return super.onInterceptTouchEvent(event) || result; } + + @Override + public void requestLayout() { + if (ignoreLayout) { + return; + } + super.requestLayout(); + } }; - gridView.setNumColumns(4); - gridView.setAdapter(new GridAdapter(context)); + gridView.setLayoutManager(layoutManager = new GridLayoutManager(getContext(), 5)); + gridView.setAdapter(adapter = new GridAdapter(context)); gridView.setVerticalScrollBarEnabled(false); + gridView.addItemDecoration(new RecyclerView.ItemDecoration() { + @Override + public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + outRect.left = 0; + outRect.right = 0; + outRect.bottom = 0; + outRect.top = 0; + } + }); + gridView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0); + gridView.setClipToPadding(false); + gridView.setEnabled(true); + gridView.setGlowColor(0xfff5f6f7); gridView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { - return StickerPreviewViewer.getInstance().onTouch(event, gridView, 0, null); + return StickerPreviewViewer.getInstance().onTouch(event, gridView, 0, stickersOnItemClickListener); } }); - container.addView(gridView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); - - setTitle(set.set.title); - - NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); - - setOnShowListener(new OnShowListener() { + if (Build.VERSION.SDK_INT >= 11) { + gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { + @SuppressLint("NewApi") + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + updateLayout(); + } + }); + } + stickersOnItemClickListener = new RecyclerListView.OnItemClickListener() { @Override - public void onShow(DialogInterface arg0) { - if (getButton(AlertDialog.BUTTON_NEUTRAL) != null) { - getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(0xffcd5a5a); + public void onItemClick(View view, int position) { + if (stickerSet == null || position < 0 || position >= stickerSet.documents.size()) { + return; } - if (getButton(AlertDialog.BUTTON_POSITIVE) != null) { - getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(0xff37a919); + selectedSticker = stickerSet.documents.get(position); + + boolean set = false; + for (int a = 0; a < selectedSticker.attributes.size(); a++) { + TLRPC.DocumentAttribute attribute = selectedSticker.attributes.get(a); + if (attribute instanceof TLRPC.TL_documentAttributeSticker) { + if (attribute.alt != null && attribute.alt.length() > 0) { + stickerEmojiTextView.setText(Emoji.replaceEmoji(attribute.alt, stickerEmojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(30), false)); + set = true; + } + break; + } } + if (!set) { + stickerEmojiTextView.setText(Emoji.replaceEmoji(StickersQuery.getEmojiForSticker(selectedSticker.id), stickerEmojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(30), false)); + } + + stickerImageView.getImageReceiver().setImage(selectedSticker, null, selectedSticker.thumb.location, null, "webp", true); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) stickerPreviewLayout.getLayoutParams(); + layoutParams.topMargin = scrollOffsetY; + stickerPreviewLayout.setLayoutParams(layoutParams); + stickerPreviewLayout.setVisibility(View.VISIBLE); + AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + animatorSet.playTogether(ObjectAnimatorProxy.ofFloat(stickerPreviewLayout, "alpha", 0.0f, 1.0f)); + animatorSet.setDuration(200); + animatorSet.start(); + } + }; + gridView.setOnItemClickListener(stickersOnItemClickListener); + container.addView(gridView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 48)); + + emptyView = new FrameLayout(context) { + @Override + public void requestLayout() { + if (ignoreLayout) { + return; + } + super.requestLayout(); + } + }; + container.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48)); + gridView.setEmptyView(emptyView); + emptyView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return true; } }); + + ProgressBar progressView = new ProgressBar(context); + emptyView.addView(progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); + + shadow[1] = new View(context); + shadow[1].setBackgroundResource(R.drawable.header_shadow_reverse); + container.addView(shadow[1], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48)); + + pickerBottomLayout = new PickerBottomLayout(context, false); + container.addView(pickerBottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM)); + pickerBottomLayout.cancelButton.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + pickerBottomLayout.cancelButton.setTextColor(Theme.STICKERS_SHEET_CLOSE_TEXT_COLOR); + pickerBottomLayout.cancelButton.setText(LocaleController.getString("Close", R.string.Close).toUpperCase()); + pickerBottomLayout.cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dismiss(); + } + }); + pickerBottomLayout.doneButton.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + pickerBottomLayout.doneButtonBadgeTextView.setBackgroundResource(R.drawable.stickercounter); + + stickerPreviewLayout = new FrameLayout(context); + stickerPreviewLayout.setBackgroundColor(0xdfffffff); + stickerPreviewLayout.setVisibility(View.GONE); + stickerPreviewLayout.setSoundEffectsEnabled(false); + container.addView(stickerPreviewLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); + stickerPreviewLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + hidePreview(); + } + }); + + ImageView closeButton = new ImageView(context); + closeButton.setImageResource(R.drawable.delete_reply); + closeButton.setScaleType(ImageView.ScaleType.CENTER); + if (Build.VERSION.SDK_INT >= 21) { + closeButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR)); + } + stickerPreviewLayout.addView(closeButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP)); + closeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + hidePreview(); + } + }); + + stickerImageView = new BackupImageView(context); + stickerImageView.setAspectFit(true); + int size = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) / 2 / AndroidUtilities.density); + stickerPreviewLayout.addView(stickerImageView, LayoutHelper.createFrame(size, size, Gravity.CENTER)); + + stickerEmojiTextView = new TextView(context); + stickerEmojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30); + stickerEmojiTextView.setGravity(Gravity.BOTTOM | Gravity.RIGHT); + stickerPreviewLayout.addView(stickerEmojiTextView, LayoutHelper.createFrame(size, size, Gravity.CENTER)); + + previewSendButton = new TextView(context); + previewSendButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + previewSendButton.setTextColor(Theme.STICKERS_SHEET_SEND_TEXT_COLOR); + previewSendButton.setGravity(Gravity.CENTER); + previewSendButton.setBackgroundColor(0xffffffff); + previewSendButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0); + previewSendButton.setText(LocaleController.getString("Close", R.string.Close).toUpperCase()); + previewSendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + previewSendButton.setVisibility(View.GONE); + stickerPreviewLayout.addView(previewSendButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT)); + previewSendButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + delegate.onStickerSelected(selectedSticker); + dismiss(); + } + }); + + previewSendButtonShadow = new View(context); + previewSendButtonShadow.setBackgroundResource(R.drawable.header_shadow_reverse); + previewSendButtonShadow.setVisibility(View.GONE); + stickerPreviewLayout.addView(previewSendButtonShadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48)); + + if (delegate != null) { + previewSendButton.setText(LocaleController.getString("SendSticker", R.string.SendSticker).toUpperCase()); + stickerImageView.setLayoutParams(LayoutHelper.createFrame(size, size, Gravity.CENTER, 0, 0, 0, 30)); + stickerEmojiTextView.setLayoutParams(LayoutHelper.createFrame(size, size, Gravity.CENTER, 0, 0, 0, 30)); + previewSendButton.setVisibility(View.VISIBLE); + previewSendButtonShadow.setVisibility(View.VISIBLE); + } + + if (stickerSet == null && inputStickerSet.short_name != null) { + stickerSet = StickersQuery.getStickerSetByName(inputStickerSet.short_name); + } + if (stickerSet == null) { + stickerSet = StickersQuery.getStickerSetById(inputStickerSet.id); + } + if (stickerSet == null) { + TLRPC.TL_messages_getStickerSet req = new TLRPC.TL_messages_getStickerSet(); + req.stickerset = inputStickerSet; + ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(final TLObject response, final TLRPC.TL_error error) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + reqId = 0; + if (error == null) { + stickerSet = (TLRPC.TL_messages_stickerSet) response; + updateFields(); + adapter.notifyDataSetChanged(); + } else { + Toast.makeText(getContext(), LocaleController.getString("AddStickersNotFound", R.string.AddStickersNotFound), Toast.LENGTH_SHORT).show(); + dismiss(); + } + } + }); + } + }); + } + NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); + updateFields(); + } + + private void updateFields() { + if (titleTextView == null) { + return; + } + if (stickerSet != null) { + titleTextView.setText(stickerSet.set.title); + + if (stickerSet.set == null || !StickersQuery.isStickerPackInstalled(stickerSet.set.id)) { + setRightButton(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + TLRPC.TL_messages_installStickerSet req = new TLRPC.TL_messages_installStickerSet(); + req.stickerset = inputStickerSet; + ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(TLObject response, final TLRPC.TL_error error) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + try { + if (error == null) { + Toast.makeText(getContext(), LocaleController.getString("AddStickersInstalled", R.string.AddStickersInstalled), Toast.LENGTH_SHORT).show(); + } else { + if (error.text.equals("STICKERSETS_TOO_MUCH")) { + Toast.makeText(getContext(), LocaleController.getString("TooMuchStickersets", R.string.TooMuchStickersets), Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(getContext(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred), Toast.LENGTH_SHORT).show(); + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + StickersQuery.loadStickers(false, true); + } + }); + } + }); + } + }, LocaleController.getString("AddStickers", R.string.AddStickers), Theme.STICKERS_SHEET_ADD_TEXT_COLOR, true); + } else { + if (stickerSet.set.official) { + setRightButton(null, null, Theme.STICKERS_SHEET_REMOVE_TEXT_COLOR, false); + } else { + setRightButton(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + StickersQuery.removeStickersSet(getContext(), stickerSet.set, 0); + } + }, LocaleController.getString("StickersRemove", R.string.StickersRemove), Theme.STICKERS_SHEET_REMOVE_TEXT_COLOR, false); + } + } + adapter.notifyDataSetChanged(); + } else { + setRightButton(null, null, Theme.STICKERS_SHEET_REMOVE_TEXT_COLOR, false); + } + } + + @SuppressLint("NewApi") + private void updateLayout() { + if (gridView.getChildCount() <= 0) { + gridView.setTopGlowOffset(scrollOffsetY = gridView.getPaddingTop()); + titleTextView.setTranslationY(scrollOffsetY); + shadow[0].setTranslationY(scrollOffsetY); + container.invalidate(); + return; + } + View child = gridView.getChildAt(0); + GridAdapter.Holder holder = (GridAdapter.Holder) gridView.findContainingViewHolder(child); + int top = child.getTop(); + int newOffset = 0; + if (top >= 0 && holder != null && holder.getAdapterPosition() == 0) { + newOffset = top; + runShadowAnimation(0, false); + } else { + runShadowAnimation(0, true); + } + if (scrollOffsetY != newOffset) { + gridView.setTopGlowOffset(scrollOffsetY = newOffset); + titleTextView.setTranslationY(scrollOffsetY); + shadow[0].setTranslationY(scrollOffsetY); + container.invalidate(); + } + } + + private void hidePreview() { + AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + animatorSet.playTogether(ObjectAnimatorProxy.ofFloat(stickerPreviewLayout, "alpha", 0.0f)); + animatorSet.setDuration(200); + animatorSet.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + stickerPreviewLayout.setVisibility(View.GONE); + } + }); + animatorSet.start(); + } + + private void runShadowAnimation(final int num, final boolean show) { + if (show && shadow[num].getTag() != null || !show && shadow[num].getTag() == null) { + shadow[num].setTag(show ? null : 1); + if (show) { + shadow[num].setVisibility(View.VISIBLE); + } + if (shadowAnimation[num] != null) { + shadowAnimation[num].cancel(); + } + shadowAnimation[num] = new AnimatorSetProxy(); + shadowAnimation[num].playTogether(ObjectAnimatorProxy.ofFloat(shadow[num], "alpha", show ? 1.0f : 0.0f)); + shadowAnimation[num].setDuration(150); + shadowAnimation[num].addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (shadowAnimation[num] != null && shadowAnimation[num].equals(animation)) { + shadow[num].clearAnimation(); + if (!show) { + shadow[num].setVisibility(View.INVISIBLE); + } + shadowAnimation[num] = null; + } + } + + @Override + public void onAnimationCancel(Object animation) { + if (shadowAnimation[num] != null && shadowAnimation[num].equals(animation)) { + shadowAnimation[num] = null; + } + } + }); + shadowAnimation[num].start(); + } } @Override public void dismiss() { super.dismiss(); + if (reqId != 0) { + ConnectionsManager.getInstance().cancelRequest(reqId, true); + reqId = 0; + } NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); } @@ -98,7 +563,24 @@ public class StickersAlert extends AlertDialog implements NotificationCenter.Not } } - private class GridAdapter extends BaseAdapter { + private void setRightButton(View.OnClickListener onClickListener, String title, int color, boolean showCircle) { + if (title == null) { + pickerBottomLayout.doneButton.setVisibility(View.GONE); + } else { + pickerBottomLayout.doneButton.setVisibility(View.VISIBLE); + if (showCircle) { + pickerBottomLayout.doneButtonBadgeTextView.setVisibility(View.VISIBLE); + pickerBottomLayout.doneButtonBadgeTextView.setText(String.format("%d", stickerSet.documents.size())); + } else { + pickerBottomLayout.doneButtonBadgeTextView.setVisibility(View.GONE); + } + pickerBottomLayout.doneButtonTextView.setTextColor(color); + pickerBottomLayout.doneButtonTextView.setText(title.toUpperCase()); + pickerBottomLayout.doneButton.setOnClickListener(onClickListener); + } + } + + private class GridAdapter extends RecyclerView.Adapter { Context context; @@ -106,45 +588,28 @@ public class StickersAlert extends AlertDialog implements NotificationCenter.Not this.context = context; } - public int getCount() { - return stickers.size(); - } - - public Object getItem(int i) { - return stickers.get(i); - } - - public long getItemId(int i) { - return stickers.get(i).id; - } - @Override - public boolean areAllItemsEnabled() { - return false; + public int getItemCount() { + return stickerSet != null ? stickerSet.documents.size() : 0; } - @Override - public boolean isEnabled(int position) { - return false; - } + private class Holder extends RecyclerView.ViewHolder { - public View getView(int i, View view, ViewGroup viewGroup) { - if (view == null) { - view = new StickerEmojiCell(context) { - public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(82), MeasureSpec.EXACTLY)); - } - }; + public Holder(View itemView) { + super(itemView); } - ((StickerEmojiCell) view).setSticker(stickers.get(i), true); - return view; } @Override - public void unregisterDataSetObserver(DataSetObserver observer) { - if (observer != null) { - super.unregisterDataSetObserver(observer); - } + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = new StickerEmojiCell(context); + view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(82))); + return new Holder(view); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + ((StickerEmojiCell) holder.itemView).setSticker(stickerSet.documents.get(position), true); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java index 41d4bd9a8..34a95d0c7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java @@ -15,6 +15,7 @@ import android.graphics.drawable.Drawable; import android.view.animation.DecelerateInterpolator; import org.telegram.messenger.AndroidUtilities; +import org.telegram.ui.ActionBar.Theme; public class TypingDotsDrawable extends Drawable { @@ -29,7 +30,7 @@ public class TypingDotsDrawable extends Drawable { public TypingDotsDrawable() { super(); - paint.setColor(0xffd7e8f7); + paint.setColor(Theme.ACTION_BAR_SUBTITLE_COLOR); } public void setIsChat(boolean value) { @@ -90,9 +91,9 @@ public class TypingDotsDrawable extends Drawable { public void draw(Canvas canvas) { int y; if (isChat) { - y = AndroidUtilities.dp(6); + y = AndroidUtilities.dp(8.3f) + getBounds().top; } else { - y = AndroidUtilities.dp(7); + y = AndroidUtilities.dp(9) + getBounds().top; } canvas.drawCircle(AndroidUtilities.dp(3), y, scales[0] * AndroidUtilities.density, paint); canvas.drawCircle(AndroidUtilities.dp(9), y, scales[1] * AndroidUtilities.density, paint); @@ -124,6 +125,6 @@ public class TypingDotsDrawable extends Drawable { @Override public int getIntrinsicHeight() { - return AndroidUtilities.dp(10); + return AndroidUtilities.dp(18); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanBotCommand.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanBotCommand.java index 61b7433e4..adb870543 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanBotCommand.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanBotCommand.java @@ -10,6 +10,8 @@ package org.telegram.ui.Components; import android.text.TextPaint; +import org.telegram.ui.ActionBar.Theme; + public class URLSpanBotCommand extends URLSpanNoUnderline { public static boolean enabled = true; @@ -21,7 +23,7 @@ public class URLSpanBotCommand extends URLSpanNoUnderline { @Override public void updateDrawState(TextPaint ds) { super.updateDrawState(ds); - ds.setColor(enabled ? 0xff316f9f : 0xff000000); + ds.setColor(enabled ? Theme.MSG_LINK_TEXT_COLOR : Theme.MSG_TEXT_COLOR); ds.setUnderlineText(false); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/WebFrameLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/WebFrameLayout.java index a9250c135..43a315199 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/WebFrameLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/WebFrameLayout.java @@ -16,6 +16,7 @@ import android.util.TypedValue; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.webkit.CookieManager; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -28,11 +29,13 @@ import android.widget.TextView; import android.widget.Toast; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.LocaleController; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; +import org.telegram.messenger.browser.Browser; import org.telegram.ui.ActionBar.BottomSheet; +import org.telegram.ui.ActionBar.Theme; import java.util.HashMap; @@ -48,11 +51,13 @@ public class WebFrameLayout extends FrameLayout { private int width; private int height; private String openUrl; + private boolean hasDescription; @SuppressLint("SetJavaScriptEnabled") - public WebFrameLayout(Context context, BottomSheet parentDialog, String title, String originalUrl, final String url, int w, int h) { + public WebFrameLayout(Context context, final BottomSheet parentDialog, String title, String descripton, String originalUrl, final String url, int w, int h) { super(context); + hasDescription = descripton != null && descripton.length() > 0; openUrl = originalUrl; width = w; height = h; @@ -67,69 +72,18 @@ public class WebFrameLayout extends FrameLayout { if (Build.VERSION.SDK_INT >= 21) { fullscreenVideoContainer.setFitsSystemWindows(true); } + parentDialog.setApplyTopPadding(false); + parentDialog.setApplyBottomPadding(false); dialog.getContainer().addView(fullscreenVideoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); fullscreenVideoContainer.setVisibility(INVISIBLE); - LinearLayout linearLayout = new LinearLayout(context); + /*LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.HORIZONTAL); addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 32, Gravity.LEFT | Gravity.TOP)); - TextView textView = new TextView(context); - textView.setTextColor(0xff666666); - textView.setText(title); - textView.setSingleLine(true); - textView.setEllipsize(TextUtils.TruncateAt.END); - textView.setGravity(Gravity.CENTER_VERTICAL); - textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); - linearLayout.addView(textView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 16, 0, 0, 0)); - textView = new TextView(context); - textView.setTextColor(0xff999999); - textView.setText(LocaleController.getString("OpenInBrowser", R.string.OpenInBrowser)); - textView.setGravity(Gravity.CENTER_VERTICAL); - textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); - linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 16, 0, 0, 0)); - textView.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - AndroidUtilities.openUrl(getContext(), openUrl); - if (dialog != null) { - dialog.dismiss(); - } - } - }); - textView = new TextView(context); - textView.setTextColor(0xff999999); - textView.setText(LocaleController.getString("CopyUrl", R.string.CopyUrl)); - textView.setGravity(Gravity.CENTER_VERTICAL); - textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); - linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 16, 0, 16, 0)); - textView.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - try { - if (Build.VERSION.SDK_INT < 11) { - android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - clipboard.setText(openUrl); - } else { - android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", openUrl); - clipboard.setPrimaryClip(clip); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - Toast.makeText(getContext(), LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT).show(); - if (dialog != null) { - dialog.dismiss(); - } - } - }); - - View lineView = new View(context); - lineView.setBackgroundResource(R.drawable.header_shadow); - addView(lineView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.TOP | Gravity.LEFT, 0, 40, 0, 0)); + */ webView = new WebView(context); webView.getSettings().setJavaScriptEnabled(true); @@ -203,10 +157,117 @@ public class WebFrameLayout extends FrameLayout { } }); - addView(webView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 8, 49, 8, 0)); + addView(webView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48 + 36 + (hasDescription ? 22 : 0))); progressBar = new ProgressBar(context); - addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 8, 24, 8, 0)); + addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, (48 + 36 + (hasDescription ? 22 : 0)) / 2)); + + //TODO 16m + //TODO 14 + + TextView textView; + + if (hasDescription) { + textView = new TextView(context); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + textView.setTextColor(0xff222222); + textView.setText(descripton); + textView.setSingleLine(true); + textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + textView.setEllipsize(TextUtils.TruncateAt.END); + textView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 48 + 9 + 20)); + } + + textView = new TextView(context); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + textView.setTextColor(0xff8a8a8a); + textView.setText(title); + textView.setSingleLine(true); + textView.setEllipsize(TextUtils.TruncateAt.END); + textView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 48 + 9)); + + View lineView = new View(context); + lineView.setBackgroundColor(0xffdbdbdb); + addView(lineView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1, Gravity.LEFT | Gravity.BOTTOM)); + ((LayoutParams) lineView.getLayoutParams()).bottomMargin = AndroidUtilities.dp(48); + + FrameLayout frameLayout = new FrameLayout(context); + frameLayout.setBackgroundColor(0xffffffff); + addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM)); + + textView = new TextView(context); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + textView.setTextColor(0xff19a7e8); + textView.setGravity(Gravity.CENTER); + textView.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false)); + textView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + textView.setText(LocaleController.getString("Close", R.string.Close).toUpperCase()); + textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); + textView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (dialog != null) { + dialog.dismiss(); + } + } + }); + + LinearLayout linearLayout = new LinearLayout(context); + linearLayout.setOrientation(LinearLayout.HORIZONTAL); + frameLayout.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT)); + + textView = new TextView(context); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + textView.setTextColor(0xff19a7e8); + textView.setGravity(Gravity.CENTER); + textView.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false)); + textView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + textView.setText(LocaleController.getString("Copy", R.string.Copy).toUpperCase()); + textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + linearLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); + textView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + try { + if (Build.VERSION.SDK_INT < 11) { + android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + clipboard.setText(openUrl); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", openUrl); + clipboard.setPrimaryClip(clip); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + Toast.makeText(getContext(), LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT).show(); + if (dialog != null) { + dialog.dismiss(); + } + } + }); + + textView = new TextView(context); + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + textView.setTextColor(0xff19a7e8); + textView.setGravity(Gravity.CENTER); + textView.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false)); + textView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); + textView.setText(LocaleController.getString("OpenInBrowser", R.string.OpenInBrowser).toUpperCase()); + textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + linearLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); + textView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + Browser.openUrl(getContext(), openUrl); + if (dialog != null) { + dialog.dismiss(); + } + } + }); setOnTouchListener(new OnTouchListener() { @Override @@ -248,6 +309,6 @@ public class WebFrameLayout extends FrameLayout { int parentWidth = MeasureSpec.getSize(widthMeasureSpec); float scale = width / parentWidth; int h = (int) Math.min(height / scale, AndroidUtilities.displaySize.y / 2); - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(h + AndroidUtilities.dp(49), MeasureSpec.EXACTLY)); + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(h + AndroidUtilities.dp(48 + 36 + (hasDescription ? 22 : 0)) + 1, MeasureSpec.EXACTLY)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java index 2719ce944..c4a0da7b5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java @@ -98,6 +98,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent user.last_name = lastNameField.getText().toString(); ContactsController.getInstance().addContact(user); finishFragment(); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + preferences.edit().putInt("spam3_" + user_id, 1).commit(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index a6b256bfe..c5771d909 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -72,7 +72,7 @@ import org.telegram.ui.Components.PlayerView; import org.telegram.ui.Components.EmptyTextProgressView; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RecyclerListView; -import org.telegram.ui.Components.ResourceLoader; +import org.telegram.ui.ActionBar.Theme; import java.util.ArrayList; @@ -111,9 +111,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. private String searchString; private long openedDialogId; - private MessagesActivityDelegate delegate; + private DialogsActivityDelegate delegate; - public interface MessagesActivityDelegate { + public interface DialogsActivityDelegate { void didSelectDialog(DialogsActivity fragment, long dialog_id, boolean param); } @@ -186,7 +186,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. searching = false; searchWas = false; - ResourceLoader.loadRecources(context); + Theme.loadRecources(context); ActionBarMenu menu = actionBar.createMenu(); if (!onlySelect && searchString == null) { @@ -625,7 +625,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. textView = new TextView(context); String help = LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp); if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) { - help = help.replace("\n", " "); + help = help.replace('\n', ' '); } textView.setText(help); textView.setTextColor(0xff959595); @@ -1011,7 +1011,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } } - public void setDelegate(MessagesActivityDelegate delegate) { + public void setDelegate(DialogsActivityDelegate delegate) { this.delegate = delegate; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index db9e4887c..1e93dd0a3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -33,6 +33,7 @@ import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; import org.telegram.ui.ActionBar.BackDrawable; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; @@ -186,7 +187,7 @@ public class DocumentSelectActivity extends BaseFragment { }); actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 65, 0, 0, 0)); - actionModeViews.add(actionMode.addItem(done, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(done, R.drawable.ic_ab_done_gray, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); fragmentView = getParentActivity().getLayoutInflater().inflate(R.layout.document_select_layout, null, false); listAdapter = new ListAdapter(context); @@ -453,8 +454,9 @@ public class DocumentSelectActivity extends BaseFragment { }*/ } }); - for (File file : files) { - if (file.getName().startsWith(".")) { + for (int a = 0; a < files.length; a++) { + File file = files[a]; + if (file.getName().indexOf('.') == 0) { continue; } ListItem item = new ListItem(); @@ -514,7 +516,7 @@ public class DocumentSelectActivity extends BaseFragment { String defaultPathState = Environment.getExternalStorageState(); if (defaultPathState.equals(Environment.MEDIA_MOUNTED) || defaultPathState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { ListItem ext = new ListItem(); - if (Build.VERSION.SDK_INT < 9 || Environment.isExternalStorageRemovable()) { + if (Environment.isExternalStorageRemovable()) { ext.title = LocaleController.getString("SdCard", R.string.SdCard); ext.icon = R.drawable.ic_external_storage; } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java index 80409c3fd..401a1b005 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java @@ -39,6 +39,7 @@ import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Components.IdenticonDrawable; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.URLSpanReplacement; public class IdenticonActivity extends BaseFragment { @@ -114,7 +115,7 @@ public class IdenticonActivity extends BaseFragment { textView.setClickable(true); textView.setMovementMethod(new LinkMovementMethodMy()); //textView.setAutoLinkMask(Linkify.WEB_URLS); - textView.setLinkTextColor(0xff316f9f); + textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); textView.setGravity(Gravity.CENTER); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java index 006bc6b22..05755ec14 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java @@ -32,6 +32,7 @@ import org.telegram.messenger.BuildVars; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; import org.telegram.tgnet.ConnectionsManager; +import org.telegram.ui.ActionBar.Theme; public class IntroActivity extends Activity { @@ -50,6 +51,7 @@ public class IntroActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_TMessages); super.onCreate(savedInstanceState); + Theme.loadRecources(this); requestWindowFeature(Window.FEATURE_NO_TITLE); if (AndroidUtilities.isTablet()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index e42fabcfe..d636ea4bd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -47,18 +47,19 @@ import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.ChatObject; import org.telegram.messenger.ContactsController; import org.telegram.messenger.ImageLoader; +import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.NativeCrashManager; import org.telegram.messenger.SendMessagesHelper; import org.telegram.messenger.UserObject; import org.telegram.messenger.Utilities; -import org.telegram.messenger.query.StickersQuery; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; +import org.telegram.messenger.browser.Browser; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; @@ -70,15 +71,18 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.DrawerLayoutContainer; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PasscodeView; +import org.telegram.ui.Components.StickersAlert; +import org.telegram.ui.ActionBar.Theme; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; -public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.MessagesActivityDelegate { +public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate { private boolean finished; private String videoPath; @@ -144,6 +148,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa getWindow().setBackgroundDrawableResource(R.drawable.transparent); super.onCreate(savedInstanceState); + Theme.loadRecources(this); if (UserConfig.passcodeHash.length() != 0 && UserConfig.appLocked) { UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime(); @@ -329,7 +334,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa presentFragment(new SettingsActivity()); drawerLayoutContainer.closeDrawer(false); } else if (position == 9) { - AndroidUtilities.openUrl(LaunchActivity.this, LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)); + Browser.openUrl(LaunchActivity.this, LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)); drawerLayoutContainer.closeDrawer(false); } } @@ -357,6 +362,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().addObserver(this, NotificationCenter.needShowAlert); + NotificationCenter.getInstance().addObserver(this, NotificationCenter.wasUnableToFindCurrentLocation); if (Build.VERSION.SDK_INT < 14) { NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged); } @@ -607,22 +613,24 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa error = true; } } else { - if ((type == null || type != null && (type.equals("text/plain") || type.equals("message/rfc822"))) && (intent.getStringExtra(Intent.EXTRA_TEXT) != null || intent.getCharSequenceExtra(Intent.EXTRA_TEXT) != null)) { - String text = intent.getStringExtra(Intent.EXTRA_TEXT); - if (text == null) { - text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT).toString(); - } - String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); - - if (text != null && text.length() != 0) { - if ((text.startsWith("http://") || text.startsWith("https://")) && subject != null && subject.length() != 0) { - text = subject + "\n" + text; - } - sendingText = text; - } else if (subject != null && subject.length() > 0) { - sendingText = subject; + String text = intent.getStringExtra(Intent.EXTRA_TEXT); + if (text == null) { + CharSequence textSequence = intent.getCharSequenceExtra(Intent.EXTRA_TEXT); + if (textSequence != null) { + text = textSequence.toString(); } } + String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); + + if (text != null && text.length() != 0) { + if ((text.startsWith("http://") || text.startsWith("https://")) && subject != null && subject.length() != 0) { + text = subject + "\n" + text; + } + sendingText = text; + } else if (subject != null && subject.length() > 0) { + sendingText = subject; + } + Parcelable parcelable = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (parcelable != null) { String path; @@ -631,11 +639,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } Uri uri = (Uri) parcelable; if (uri != null) { - if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { - String pathString = Utilities.readlink(uri.getPath()); - if (pathString != null && pathString.contains("/data/data/" + getPackageName() + "/files")) { - error = true; - } + if (isInternalUri(uri)) { + error = true; } } if (!error) { @@ -694,12 +699,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } Uri uri = (Uri) parcelable; if (uri != null) { - if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { - String pathString = Utilities.readlink(uri.getPath()); - if (pathString != null && pathString.contains("/data/data/" + getPackageName() + "/files")) { - uris.remove(a); - a--; - } + if (isInternalUri(uri)) { + uris.remove(a); + a--; } } } @@ -1030,6 +1032,21 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa return false; } + private boolean isInternalUri(Uri uri) { + String pathString = uri.getPath(); + if (pathString == null) { + return false; + } + while (true) { + String newPath = Utilities.readlink(pathString); + if (newPath == null || newPath.equals(pathString)) { + break; + } + pathString = newPath; + } + return pathString != null && pathString.toLowerCase().contains("/data/data/" + getPackageName() + "/files"); + } + private void runLinkRequest(final String username, final String group, final String sticker, final String botUser, final String botChat, final String message, final boolean hasUrl, final Integer messageId, final int state) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); @@ -1073,7 +1090,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa args.putInt("dialogsType", 2); args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupTitle", R.string.AddToTheGroupTitle, UserObject.getUserName(user), "%1$s")); DialogsActivity fragment = new DialogsActivity(args); - fragment.setDelegate(new DialogsActivity.MessagesActivityDelegate() { + fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() { @Override public void didSelectDialog(DialogsActivity fragment, long did, boolean param) { Bundle args = new Bundle(); @@ -1088,22 +1105,32 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa }); presentFragment(fragment); } else { + long dialog_id; + boolean isBot = false; Bundle args = new Bundle(); if (!res.chats.isEmpty()) { args.putInt("chat_id", res.chats.get(0).id); + dialog_id = -res.chats.get(0).id; } else { args.putInt("user_id", res.users.get(0).id); + dialog_id = res.users.get(0).id; } if (botUser != null && res.users.size() > 0 && res.users.get(0).bot) { args.putString("botUser", botUser); + isBot = true; } if (messageId != null) { args.putInt("message_id", messageId); } - if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) { - ChatActivity fragment = new ChatActivity(args); - NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); - actionBarLayout.presentFragment(fragment, false, true, true); + BaseFragment lastFragment = !mainFragmentsStack.isEmpty() ? mainFragmentsStack.get(mainFragmentsStack.size() - 1) : null; + if (lastFragment == null || MessagesController.checkCanOpenChat(args, lastFragment)) { + if (isBot && lastFragment != null && lastFragment instanceof ChatActivity && ((ChatActivity) lastFragment).getDialogId() == dialog_id) { + ((ChatActivity) lastFragment).setBotUser(botUser); + } else { + ChatActivity fragment = new ChatActivity(args); + NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); + actionBarLayout.presentFragment(fragment, false, true, true); + } } } } else { @@ -1241,14 +1268,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa if (!mainFragmentsStack.isEmpty()) { TLRPC.TL_inputStickerSetShortName stickerset = new TLRPC.TL_inputStickerSetShortName(); stickerset.short_name = sticker; - StickersQuery.loadStickers(mainFragmentsStack.get(0), stickerset); + mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(new StickersAlert(LaunchActivity.this, stickerset, null, null)); } return; } else if (message != null) { Bundle args = new Bundle(); args.putBoolean("onlySelect", true); DialogsActivity fragment = new DialogsActivity(args); - fragment.setDelegate(new DialogsActivity.MessagesActivityDelegate() { + fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() { @Override public void didSelectDialog(DialogsActivity fragment, long did, boolean param) { Bundle args = new Bundle(); @@ -1391,7 +1418,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } if (contactsToSend != null && !contactsToSend.isEmpty()) { for (TLRPC.User user : contactsToSend) { - SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null, true); + SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null, true, null, null); } } } @@ -1419,6 +1446,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.needShowAlert); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.wasUnableToFindCurrentLocation); if (Build.VERSION.SDK_INT < 14) { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.screenStateChanged); } @@ -1434,7 +1462,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa public void needLayout() { if (AndroidUtilities.isTablet()) { - RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams(); + RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) layersActionBarLayout.getLayoutParams(); relativeLayoutParams.leftMargin = (AndroidUtilities.displaySize.x - relativeLayoutParams.width) / 2; int y = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); relativeLayoutParams.topMargin = y + (AndroidUtilities.displaySize.y - relativeLayoutParams.height - y) / 2; @@ -1463,11 +1491,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa relativeLayoutParams.leftMargin = leftWidth; rightActionBarLayout.setLayoutParams(relativeLayoutParams); - if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() == 2) { - BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1); - chatFragment.onPause(); - actionBarLayout.fragmentsStack.remove(1); - rightActionBarLayout.fragmentsStack.add(chatFragment); + if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() >= 2) { + for (int a = 1; a < actionBarLayout.fragmentsStack.size(); a++) { + BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(a); + chatFragment.onPause(); + actionBarLayout.fragmentsStack.remove(a); + rightActionBarLayout.fragmentsStack.add(chatFragment); + a--; + } if (passcodeView.getVisibility() != View.VISIBLE) { actionBarLayout.showLastFragment(); rightActionBarLayout.showLastFragment(); @@ -1489,12 +1520,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa rightActionBarLayout.setVisibility(View.GONE); backgroundTablet.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE); - if (rightActionBarLayout.fragmentsStack.size() == 1) { - BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(0); - chatFragment.onPause(); - rightActionBarLayout.fragmentsStack.remove(0); - actionBarLayout.fragmentsStack.add(chatFragment); - //actionBarLayout.addFragmentToStack(chatFragment); + if (!rightActionBarLayout.fragmentsStack.isEmpty()) { + for (int a = 0; a < rightActionBarLayout.fragmentsStack.size(); a++) { + BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(a); + chatFragment.onPause(); + rightActionBarLayout.fragmentsStack.remove(a); + actionBarLayout.fragmentsStack.add(chatFragment); + a--; + } if (passcodeView.getVisibility() != View.VISIBLE) { actionBarLayout.showLastFragment(); } @@ -1628,6 +1661,18 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa AndroidUtilities.unregisterUpdates(); } + @Override + protected void onStart() { + super.onStart(); + Browser.bindCustomTabsService(this); + } + + @Override + protected void onStop() { + super.onStop(); + Browser.unbindCustomTabsService(this); + } + @Override protected void onDestroy() { PhotoViewer.getInstance().destroyPhotoViewer(); @@ -1743,7 +1788,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa builder.setNegativeButton(LocaleController.getString("MoreInfo", R.string.MoreInfo), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - AndroidUtilities.openUrl(LaunchActivity.this, LocaleController.getString("NobodyLikesSpamUrl", R.string.NobodyLikesSpamUrl)); + if (!mainFragmentsStack.isEmpty()) { + MessagesController.openByUserName("spambot", mainFragmentsStack.get(mainFragmentsStack.size() - 1), 1); + } } }); } @@ -1757,6 +1804,38 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa if (!mainFragmentsStack.isEmpty()) { mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(builder.create()); } + } else if (id == NotificationCenter.wasUnableToFindCurrentLocation) { + final HashMap waitingForLocation = (HashMap) args[0]; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + builder.setNegativeButton(LocaleController.getString("ShareYouLocationUnableManually", R.string.ShareYouLocationUnableManually), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (mainFragmentsStack.isEmpty()) { + return; + } + BaseFragment lastFragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1); + if (!AndroidUtilities.isGoogleMapsInstalled(lastFragment)) { + return; + } + LocationActivity fragment = new LocationActivity(); + fragment.setDelegate(new LocationActivity.LocationActivityDelegate() { + @Override + public void didSelectLocation(TLRPC.MessageMedia location) { + for (HashMap.Entry entry : waitingForLocation.entrySet()) { + MessageObject messageObject = entry.getValue(); + SendMessagesHelper.getInstance().sendMessage(location, messageObject.getDialogId(), messageObject, false, null, null); + } + } + }); + presentFragment(fragment); + } + }); + builder.setMessage(LocaleController.getString("ShareYouLocationUnable", R.string.ShareYouLocationUnable)); + if (!mainFragmentsStack.isEmpty()) { + mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(builder.create()); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java index 5c8e98130..78bc7cb0d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java @@ -363,6 +363,15 @@ public class LocationActivity extends BaseFragment implements NotificationCenter routeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (Build.VERSION.SDK_INT >= 23) { + Activity activity = getParentActivity(); + if (activity != null) { + if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + showPermissionAlert(true); + return; + } + } + } if (myLocation != null) { try { Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", myLocation.getLatitude(), myLocation.getLongitude(), messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long))); @@ -382,7 +391,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter Activity activity = getParentActivity(); if (activity != null) { if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - showPermissionAlert(); + showPermissionAlert(true); return; } } @@ -539,7 +548,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter Activity activity = getParentActivity(); if (activity != null) { if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - showPermissionAlert(); + showPermissionAlert(false); return; } } @@ -646,13 +655,17 @@ public class LocationActivity extends BaseFragment implements NotificationCenter return fragmentView; } - private void showPermissionAlert() { + private void showPermissionAlert(boolean byButton) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); - builder.setMessage(LocaleController.getString("PermissionNoLocation", R.string.PermissionNoLocation)); + if (byButton) { + builder.setMessage(LocaleController.getString("PermissionNoLocationPosition", R.string.PermissionNoLocationPosition)); + } else { + builder.setMessage(LocaleController.getString("PermissionNoLocation", R.string.PermissionNoLocation)); + } builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() { @TargetApi(Build.VERSION_CODES.GINGERBREAD) @Override @@ -935,6 +948,13 @@ public class LocationActivity extends BaseFragment implements NotificationCenter FileLog.e("tmessages", e); } } + if (googleMap != null) { + try { + googleMap.setMyLocationEnabled(true); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } updateUserData(); fixLayoutInternal(true); if (checkPermission && Build.VERSION.SDK_INT >= 23) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index bb6491688..7dc0183ad 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -290,7 +290,7 @@ public class LoginActivity extends BaseFragment { @Override protected void onDialogDismiss(Dialog dialog) { - if (Build.VERSION.SDK_INT >= 23 && dialog == permissionsDialog && !permissionsItems.isEmpty()) { + if (Build.VERSION.SDK_INT >= 23 && dialog == permissionsDialog && !permissionsItems.isEmpty() && getParentActivity() != null) { getParentActivity().requestPermissions(permissionsItems.toArray(new String[permissionsItems.size()]), 6); } } @@ -906,7 +906,7 @@ public class LoginActivity extends BaseFragment { req.api_hash = BuildVars.APP_HASH; req.api_id = BuildVars.APP_ID; req.phone_number = phone; - req.lang_code = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); + req.lang_code = LocaleController.getLocaleStringIso639(); if (req.lang_code.length() == 0) { req.lang_code = "en"; } @@ -1339,7 +1339,7 @@ public class LoginActivity extends BaseFragment { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 1, 0)); } createTimer(); - } else if (currentType == 2 && nextType == 4) { + } else if (currentType == 2 && (nextType == 4 || nextType == 3)) { timeText.setVisibility(VISIBLE); timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 2, 0)); problemText.setVisibility(time < 1000 ? VISIBLE : GONE); @@ -1412,7 +1412,7 @@ public class LoginActivity extends BaseFragment { if (time >= 1000) { int minutes = time / 1000 / 60; int seconds = time / 1000 - minutes * 60; - if (nextType == 4) { + if (nextType == 4 || nextType == 3) { timeText.setText(LocaleController.formatString("CallText", R.string.CallText, minutes, seconds)); } else if (nextType == 2) { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, minutes, seconds)); @@ -1431,25 +1431,33 @@ public class LoginActivity extends BaseFragment { waitingForEvent = false; destroyCodeTimer(); resendCode(); - } else { - timeText.setText(LocaleController.getString("Calling", R.string.Calling)); - createCodeTimer(); - TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode(); - req.phone_number = requestPhone; - req.phone_code_hash = phoneHash; - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(TLObject response, final TLRPC.TL_error error) { - if (error != null && error.text != null) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - lastError = error.text; - } - }); + } else if (currentType == 2) { + if (nextType == 4) { + timeText.setText(LocaleController.getString("Calling", R.string.Calling)); + createCodeTimer(); + TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode(); + req.phone_number = requestPhone; + req.phone_code_hash = phoneHash; + ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(TLObject response, final TLRPC.TL_error error) { + if (error != null && error.text != null) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + lastError = error.text; + } + }); + } } - } - }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); + }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); + } else if (nextType == 3) { + AndroidUtilities.setWaitingForSms(false); + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); + waitingForEvent = false; + destroyCodeTimer(); + resendCode(); + } } } } @@ -1559,7 +1567,7 @@ public class LoginActivity extends BaseFragment { destroyCodeTimer(); } else { needHideProgress(); - if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && nextType == 4) { + if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3)) { createTimer(); } if (currentType == 2) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ManageSpaceActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ManageSpaceActivity.java index a2e77c3d8..65430d061 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ManageSpaceActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ManageSpaceActivity.java @@ -33,6 +33,7 @@ import org.telegram.ui.ActionBar.ActionBarLayout; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.DrawerLayoutContainer; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.ActionBar.Theme; import java.util.ArrayList; @@ -56,6 +57,7 @@ public class ManageSpaceActivity extends Activity implements ActionBarLayout.Act getWindow().setBackgroundDrawableResource(R.drawable.transparent); super.onCreate(savedInstanceState); + Theme.loadRecources(this); int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index 76553ab3f..716dea31e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -42,6 +42,7 @@ import org.telegram.messenger.ChatObject; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaController; import org.telegram.messenger.MessagesController; +import org.telegram.messenger.browser.Browser; import org.telegram.messenger.query.SharedMediaQuery; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLoader; @@ -60,6 +61,7 @@ import org.telegram.ui.ActionBar.ActionBarPopupWindow; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BottomSheet; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.BaseSectionsAdapter; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; @@ -336,7 +338,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No args.putBoolean("onlySelect", true); args.putInt("dialogsType", 1); DialogsActivity fragment = new DialogsActivity(args); - fragment.setDelegate(new DialogsActivity.MessagesActivityDelegate() { + fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() { @Override public void didSelectDialog(DialogsActivity fragment, long did, boolean param) { int lower_part = (int) did; @@ -442,7 +444,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No searchItem.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); searchItem.setVisibility(View.GONE); - dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector); + dropDownContainer = new ActionBarMenuItem(context, menu, 0); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(shared_media_item, LocaleController.getString("SharedMediaTitle", R.string.SharedMediaTitle), 0); dropDownContainer.addSubItem(files_item, LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle), 0); @@ -491,9 +493,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 65, 0, 0, 0)); if ((int) dialog_id != 0) { - actionModeViews.add(actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); } - actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, Theme.ACTION_BAR_MODE_SELECTOR_COLOR, null, AndroidUtilities.dp(54))); photoVideoAdapter = new SharedPhotoVideoAdapter(context); documentsAdapter = new SharedDocumentsAdapter(context, 1); @@ -516,7 +518,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public void onItemClick(AdapterView adapterView, View view, final int i, long l) { if ((selectedMode == 1 || selectedMode == 4) && view instanceof SharedDocumentCell) { - MediaActivity.this.onItemClick(i, view, ((SharedDocumentCell) view).getDocument(), 0); + MediaActivity.this.onItemClick(i, view, ((SharedDocumentCell) view).getMessage(), 0); } else if (selectedMode == 3 && view instanceof SharedLinkCell) { MediaActivity.this.onItemClick(i, view, ((SharedLinkCell) view).getMessage(), 0); } @@ -564,7 +566,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No public boolean onItemLongClick(AdapterView parent, View view, int i, long id) { if ((selectedMode == 1 || selectedMode == 4) && view instanceof SharedDocumentCell) { SharedDocumentCell cell = (SharedDocumentCell) view; - MessageObject message = cell.getDocument(); + MessageObject message = cell.getMessage(); return MediaActivity.this.onItemLongClick(message, view, 0); } else if (selectedMode == 3 && view instanceof SharedLinkCell) { SharedLinkCell cell = (SharedLinkCell) view; @@ -1064,7 +1066,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } } File f = null; - String fileName = message.messageOwner.media != null ? FileLoader.getAttachFileName(message.messageOwner.media.document) : ""; + String fileName = message.messageOwner.media != null ? FileLoader.getAttachFileName(message.getDocument()) : ""; if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) { f = new File(message.messageOwner.attachPath); } @@ -1076,12 +1078,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No try { Intent intent = new Intent(Intent.ACTION_VIEW); MimeTypeMap myMime = MimeTypeMap.getSingleton(); - int idx = fileName.lastIndexOf("."); + int idx = fileName.lastIndexOf('.'); if (idx != -1) { String ext = fileName.substring(idx + 1); realMimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); if (realMimeType == null) { - realMimeType = message.messageOwner.media.document.mime_type; + realMimeType = message.getDocument().mime_type; if (realMimeType == null || realMimeType.length() == 0) { realMimeType = null; } @@ -1111,15 +1113,15 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); - builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, message.messageOwner.media.document.mime_type)); + builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, message.getDocument().mime_type)); showDialog(builder.create()); } } } else if (!cell.isLoading()) { - FileLoader.getInstance().loadFile(cell.getDocument().messageOwner.media.document, false, false); + FileLoader.getInstance().loadFile(cell.getMessage().getDocument(), false, false); cell.updateFileExistIcon(); } else { - FileLoader.getInstance().cancelLoadFile(cell.getDocument().messageOwner.media.document); + FileLoader.getInstance().cancelLoadFile(cell.getMessage().getDocument()); cell.updateFileExistIcon(); } } @@ -1139,7 +1141,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No link = ((SharedLinkCell) view).getLink(0); } if (link != null) { - AndroidUtilities.openUrl(getParentActivity(), link); + Browser.openUrl(getParentActivity(), link); } } catch (Exception e) { FileLog.e("tmessages", e); @@ -1150,7 +1152,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No private void openWebView(TLRPC.WebPage webPage) { BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); - builder.setCustomView(new WebFrameLayout(getParentActivity(), builder.create(), webPage.title, webPage.url, webPage.embed_url, webPage.embed_width, webPage.embed_height)); + builder.setCustomView(new WebFrameLayout(getParentActivity(), builder.create(), webPage.site_name, webPage.description, webPage.url, webPage.embed_url, webPage.embed_width, webPage.embed_height)); builder.setUseFullWidth(true); showDialog(builder.create()); } @@ -1632,14 +1634,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public void run() { if (!sharedMediaData[currentType].messages.isEmpty()) { - if (currentType == 1) { + if (currentType == 1 || currentType == 4) { MessageObject messageObject = sharedMediaData[currentType].messages.get(sharedMediaData[currentType].messages.size() - 1); queryServerSearch(query, messageObject.getId(), messageObject.getDialogId()); - } else if (currentType == 3 || currentType == 4) { + } else if (currentType == 3) { queryServerSearch(query, 0, dialog_id); } } - if (currentType == 1) { + if (currentType == 1 || currentType == 4) { final ArrayList copy = new ArrayList<>(); copy.addAll(sharedMediaData[currentType].messages); Utilities.searchQueue.postRunnable(new Runnable() { @@ -1664,7 +1666,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No for (int a = 0; a < copy.size(); a++) { MessageObject messageObject = copy.get(a); - for (String q : search) { + for (int b = 0; b < search.length; b++) { + String q = search[b]; String name = messageObject.getDocumentName(); if (name == null || name.length() == 0) { continue; @@ -1674,6 +1677,31 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No resultArray.add(messageObject); break; } + if (currentType == 4) { + TLRPC.Document document; + if (messageObject.type == 0) { + document = messageObject.messageOwner.media.webpage.document; + } else { + document = messageObject.messageOwner.media.document; + } + boolean ok = false; + for (int c = 0; c < document.attributes.size(); c++) { + TLRPC.DocumentAttribute attribute = document.attributes.get(c); + if (attribute instanceof TLRPC.TL_documentAttributeAudio) { + if (attribute.performer != null) { + ok = attribute.performer.toLowerCase().contains(q); + } + if (!ok && attribute.title != null) { + ok = attribute.title.toLowerCase().contains(q); + } + break; + } + } + if (ok) { + resultArray.add(messageObject); + break; + } + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java index 0ad05c2d7..513a21ae7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java @@ -57,7 +57,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif private boolean reseting = false; private int notificationsServiceRow; - private int messageSectionRow2; + private int notificationsServiceConnectionRow; private int messageSectionRow; private int messageAlertRow; private int messagePreviewRow; @@ -85,6 +85,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif private int eventsSectionRow2; private int eventsSectionRow; private int contactJoinedRow; + private int pinnedMessageRow; private int otherSectionRow2; private int otherSectionRow; private int badgeNumberRow; @@ -97,8 +98,6 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif @Override public boolean onFragmentCreate() { - notificationsServiceRow = rowCount++; - messageSectionRow2 = rowCount++; messageSectionRow = rowCount++; messageAlertRow = rowCount++; messagePreviewRow = rowCount++; @@ -138,8 +137,11 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif eventsSectionRow2 = rowCount++; eventsSectionRow = rowCount++; contactJoinedRow = rowCount++; + pinnedMessageRow = rowCount++; otherSectionRow2 = rowCount++; otherSectionRow = rowCount++; + notificationsServiceRow = rowCount++; + notificationsServiceConnectionRow = rowCount++; badgeNumberRow = rowCount++; androidAutoAlertRow = -1; repeatRow = rowCount++; @@ -319,6 +321,12 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif MessagesController.getInstance().enableJoined = !enabled; editor.putBoolean("EnableContactJoined", !enabled); editor.commit(); + } else if (i == pinnedMessageRow) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + enabled = preferences.getBoolean("PinnedMessages", true); + editor.putBoolean("PinnedMessages", !enabled); + editor.commit(); } else if (i == androidAutoAlertRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); @@ -332,14 +340,30 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif editor.putBoolean("badgeNumber", !enabled); editor.commit(); NotificationsController.getInstance().setBadgeEnabled(!enabled); + } else if (i == notificationsServiceConnectionRow) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + enabled = preferences.getBoolean("pushConnection", true); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("pushConnection", !enabled); + editor.commit(); + if (!enabled) { + ConnectionsManager.getInstance().setPushConnectionEnabled(true); + } else { + ConnectionsManager.getInstance().setPushConnectionEnabled(false); + } } else if (i == notificationsServiceRow) { final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); enabled = preferences.getBoolean("pushService", true); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("pushService", !enabled); + editor.commit(); if (!enabled) { - final SharedPreferences.Editor editor = preferences.edit(); - editor.putBoolean("pushService", !enabled); - editor.commit(); ApplicationLoader.startPushService(); + } else { + ApplicationLoader.stopPushService(); + } + /*if (!enabled) { + } else { if (getParentActivity() == null) { return; @@ -350,7 +374,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - ApplicationLoader.stopPushService(); + final SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("pushService", false); editor.commit(); @@ -364,7 +388,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif } }); showDialog(builder.create()); - } + }*/ } else if (i == messageLedRow || i == groupLedRow) { if (getParentActivity() == null) { return; @@ -641,7 +665,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif public boolean isEnabled(int i) { return !(i == messageSectionRow || i == groupSectionRow || i == inappSectionRow || i == eventsSectionRow || i == otherSectionRow || i == resetSectionRow || - i == messageSectionRow2 || i == eventsSectionRow2 || i == groupSectionRow2 || + i == eventsSectionRow2 || i == groupSectionRow2 || i == inappSectionRow2 || i == otherSectionRow2 || i == resetSectionRow2); } @@ -709,11 +733,15 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif } else if (i == inappPriorityRow) { checkCell.setTextAndCheck(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), preferences.getBoolean("EnableInAppPriority", false), false); } else if (i == contactJoinedRow) { - checkCell.setTextAndCheck(LocaleController.getString("ContactJoined", R.string.ContactJoined), preferences.getBoolean("EnableContactJoined", true), false); + checkCell.setTextAndCheck(LocaleController.getString("ContactJoined", R.string.ContactJoined), preferences.getBoolean("EnableContactJoined", true), true); + } else if (i == pinnedMessageRow) { + checkCell.setTextAndCheck(LocaleController.getString("PinnedMessages", R.string.PinnedMessages), preferences.getBoolean("PinnedMessages", true), false); } else if (i == androidAutoAlertRow) { checkCell.setTextAndCheck("Android Auto", preferences.getBoolean("EnableAutoNotifications", false), true); } else if (i == notificationsServiceRow) { - checkCell.setTextAndCheck(LocaleController.getString("NotificationsService", R.string.NotificationsService), preferences.getBoolean("pushService", true), false); + checkCell.setTextAndValueAndCheck(LocaleController.getString("NotificationsService", R.string.NotificationsService), LocaleController.getString("NotificationsServiceInfo", R.string.NotificationsServiceInfo), preferences.getBoolean("pushService", true), true, true); + } else if (i == notificationsServiceConnectionRow) { + checkCell.setTextAndValueAndCheck(LocaleController.getString("NotificationsServiceConnection", R.string.NotificationsServiceConnection), LocaleController.getString("NotificationsServiceConnectionInfo", R.string.NotificationsServiceConnectionInfo), preferences.getBoolean("pushConnection", true), true, true); } else if (i == badgeNumberRow) { checkCell.setTextAndCheck(LocaleController.getString("BadgeNumber", R.string.BadgeNumber), preferences.getBoolean("badgeNumber", true), true); } else if (i == inchatSoundRow) { @@ -837,13 +865,13 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif return 0; } else if (i == messageAlertRow || i == messagePreviewRow || i == groupAlertRow || i == groupPreviewRow || i == inappSoundRow || i == inappVibrateRow || - i == inappPreviewRow || i == contactJoinedRow || + i == inappPreviewRow || i == contactJoinedRow || i == pinnedMessageRow || i == notificationsServiceRow || i == badgeNumberRow || i == inappPriorityRow || - i == inchatSoundRow || i == androidAutoAlertRow) { + i == inchatSoundRow || i == androidAutoAlertRow || i == notificationsServiceConnectionRow) { return 1; } else if (i == messageLedRow || i == groupLedRow) { return 3; - } else if (i == messageSectionRow2 || i == eventsSectionRow2 || i == groupSectionRow2 || + } else if (i == eventsSectionRow2 || i == groupSectionRow2 || i == inappSectionRow2 || i == otherSectionRow2 || i == resetSectionRow2) { return 4; } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java index e3848972d..64f5deb6c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java @@ -53,6 +53,7 @@ import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.TextCheckCell; import org.telegram.ui.Cells.TextInfoPrivacyCell; @@ -255,7 +256,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter } if (type == 1) { - dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector); + dropDownContainer = new ActionBarMenuItem(context, menu, 0); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0); dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0); @@ -362,7 +363,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter @Override public String format(int value) { if (value == 0) { - return LocaleController.getString("Disabled", R.string.Disabled); + return LocaleController.getString("AutoLockDisabled", R.string.AutoLockDisabled); } else if (value == 1) { return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1)); } else if (value == 2) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java index 909fb7c94..c4b50be27 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java @@ -37,6 +37,7 @@ import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.PhotoPickerAlbumsCell; import org.telegram.ui.Cells.PhotoPickerSearchCell; @@ -111,8 +112,8 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati @SuppressWarnings("unchecked") @Override public View createView(Context context) { - actionBar.setBackgroundColor(0xff333333); - actionBar.setItemsBackground(R.drawable.bar_selector_picker); + actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR); actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override @@ -160,7 +161,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati if (!singlePhoto) { selectedMode = 0; - dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector_picker); + dropDownContainer = new ActionBarMenuItem(context, menu, 0); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(item_photos, LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0); dropDownContainer.addSubItem(item_video, LocaleController.getString("PickerVideo", R.string.PickerVideo), 0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java index 95c30acc1..b3d8d6590 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java @@ -28,6 +28,7 @@ import org.telegram.messenger.R; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.LayoutHelper; import java.io.File; @@ -417,8 +418,8 @@ public class PhotoCropActivity extends BaseFragment { @Override public View createView(Context context) { - actionBar.setBackgroundColor(0xff333333); - actionBar.setItemsBackground(R.drawable.bar_selector_picker); + actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR); actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("CropImage", R.string.CropImage)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java index c7cb26b90..c7d9915b8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -60,6 +60,7 @@ import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.BaseFragment; @@ -161,8 +162,8 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @SuppressWarnings("unchecked") @Override public View createView(Context context) { - actionBar.setBackgroundColor(0xff333333); - actionBar.setItemsBackground(R.drawable.bar_selector_picker); + actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR); actionBar.setBackButtonImage(R.drawable.ic_ab_back); if (selectedAlbum != null) { actionBar.setTitle(selectedAlbum.bucketName); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 9d4b170ab..9071f57d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -31,6 +31,8 @@ import android.os.Bundle; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.util.TypedValue; +import android.view.ActionMode; +import android.view.ContextThemeWrapper; import android.view.GestureDetector; import android.view.Gravity; import android.view.KeyEvent; @@ -67,6 +69,7 @@ import org.telegram.tgnet.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.messenger.MessageObject; import org.telegram.messenger.Utilities; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Adapters.MentionsAdapter; import org.telegram.messenger.AnimationCompat.AnimatorListenerAdapterProxy; import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; @@ -101,6 +104,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private boolean isVisible; private Activity parentActivity; + private Context actvityContext; private ActionBar actionBar; private boolean isActionBarVisible = true; @@ -294,7 +298,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); progressPaint.setStyle(Paint.Style.STROKE); progressPaint.setStrokeCap(Paint.Cap.ROUND); - progressPaint.setStrokeWidth(AndroidUtilities.dp(2)); + progressPaint.setStrokeWidth(AndroidUtilities.dp(3)); progressPaint.setColor(0xffffffff); } parent = parentView; @@ -389,7 +393,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } if (backgroundState == 0 || backgroundState == 1 || previousBackgroundState == 0 || previousBackgroundState == 1) { - int diff = AndroidUtilities.dp(1); + int diff = AndroidUtilities.dp(4); if (previousBackgroundState != -2) { progressPaint.setAlpha((int) (255 * animatedAlphaValue * alpha)); } else { @@ -886,6 +890,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return; } parentActivity = activity; + actvityContext = new ContextThemeWrapper(parentActivity, R.style.Theme_TMessages); if (progressDrawables == null) { progressDrawables = new Drawable[4]; @@ -911,11 +916,26 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } return super.dispatchKeyEventPreIme(event); } + + @Override + public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, int type) { + if (Build.VERSION.SDK_INT >= 23) { + View view = parentActivity.findViewById(android.R.id.content); + if (view instanceof ViewGroup) { + try { + return ((ViewGroup) view).startActionModeForChild(originalView, callback, type); + } catch (Throwable e) { + FileLog.e("tmessages", e); + } + } + } + return super.startActionModeForChild(originalView, callback, type); + } }; windowView.setBackgroundDrawable(backgroundDrawable); windowView.setFocusable(false); if (Build.VERSION.SDK_INT >= 23) { - windowView.setFitsSystemWindows(true); //TODO ? + windowView.setFitsSystemWindows(true); } animatingImageView = new ClippingImageView(activity); @@ -935,9 +955,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; actionBar = new ActionBar(activity); - actionBar.setBackgroundColor(0x7F000000); + actionBar.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR); actionBar.setOccupyStatusBar(false); - actionBar.setItemsBackground(R.drawable.bar_selector_white); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR); actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); containerView.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); @@ -965,7 +985,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } if (f != null && f.exists()) { - MediaController.saveFile(f.toString(), parentActivity, currentMessageObject != null && currentMessageObject.isVideo() ? 1 : 0, null); + MediaController.saveFile(f.toString(), parentActivity, currentMessageObject != null && currentMessageObject.isVideo() ? 1 : 0, null, null); } else { AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); @@ -1159,11 +1179,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat cropItem = menu.addItemWithWidth(gallery_menu_crop, R.drawable.photo_crop, AndroidUtilities.dp(56)); tuneItem = menu.addItemWithWidth(gallery_menu_tune, R.drawable.photo_tools, AndroidUtilities.dp(56)); - bottomLayout = new FrameLayout(parentActivity); + bottomLayout = new FrameLayout(actvityContext); bottomLayout.setBackgroundColor(0x7f000000); containerView.addView(bottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT)); - captionTextViewOld = new TextView(parentActivity); + captionTextViewOld = new TextView(actvityContext); captionTextViewOld.setMaxLines(10); captionTextViewOld.setBackgroundColor(0x7f000000); captionTextViewOld.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(8), AndroidUtilities.dp(16), AndroidUtilities.dp(8)); @@ -1174,7 +1194,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat captionTextViewOld.setVisibility(View.INVISIBLE); containerView.addView(captionTextViewOld, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48)); - captionTextView = captionTextViewNew = new TextView(parentActivity); + captionTextView = captionTextViewNew = new TextView(actvityContext); captionTextViewNew.setMaxLines(10); captionTextViewNew.setBackgroundColor(0x7f000000); captionTextViewNew.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(8), AndroidUtilities.dp(16), AndroidUtilities.dp(8)); @@ -1195,7 +1215,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat shareButton = new ImageView(containerView.getContext()); shareButton.setImageResource(R.drawable.share); shareButton.setScaleType(ImageView.ScaleType.CENTER); - shareButton.setBackgroundResource(R.drawable.bar_selector_white); + shareButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR)); bottomLayout.addView(shareButton, LayoutHelper.createFrame(50, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT)); shareButton.setOnClickListener(new View.OnClickListener() { @Override @@ -1261,7 +1281,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat dateTextView.setGravity(Gravity.LEFT); bottomLayout.addView(dateTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 16, 25, 50, 0)); - pickerView = new PickerBottomLayout(parentActivity); + pickerView = new PickerBottomLayout(actvityContext); pickerView.setBackgroundColor(0x7f000000); containerView.addView(pickerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT)); pickerView.cancelButton.setOnClickListener(new View.OnClickListener() { @@ -1282,7 +1302,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } }); - editorDoneLayout = new PickerBottomLayout(parentActivity); + editorDoneLayout = new PickerBottomLayout(actvityContext); editorDoneLayout.setBackgroundColor(0x7f000000); editorDoneLayout.updateSelectedCount(0, false); editorDoneLayout.setVisibility(View.GONE); @@ -1310,10 +1330,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } }); - ImageView rotateButton = new ImageView(parentActivity); + ImageView rotateButton = new ImageView(actvityContext); rotateButton.setScaleType(ImageView.ScaleType.CENTER); rotateButton.setImageResource(R.drawable.tool_rotate); - rotateButton.setBackgroundResource(R.drawable.bar_selector_white); + rotateButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR)); editorDoneLayout.addView(rotateButton, LayoutHelper.createFrame(48, 48, Gravity.CENTER)); rotateButton.setOnClickListener(new View.OnClickListener() { @Override @@ -1358,7 +1378,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } }); - captionEditText = new PhotoViewerCaptionEnterView(parentActivity, containerView); + captionEditText = new PhotoViewerCaptionEnterView(actvityContext, containerView, windowView); captionEditText.setDelegate(new PhotoViewerCaptionEnterView.PhotoViewerCaptionEnterViewDelegate() { @Override public void onCaptionEnter() { @@ -1392,8 +1412,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat }); containerView.addView(captionEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, -400)); - mentionListView = new RecyclerListView(parentActivity); - mentionLayoutManager = new LinearLayoutManager(parentActivity) { + mentionListView = new RecyclerListView(actvityContext); + mentionLayoutManager = new LinearLayoutManager(actvityContext) { @Override public boolean supportsPredictiveItemAnimations() { return false; @@ -1404,12 +1424,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat mentionListView.setBackgroundColor(0x7f000000); mentionListView.setVisibility(View.GONE); mentionListView.setClipToPadding(true); - if (Build.VERSION.SDK_INT > 8) { - mentionListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); - } + mentionListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); containerView.addView(mentionListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 110, Gravity.LEFT | Gravity.BOTTOM)); - mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(parentActivity, true, new MentionsAdapter.MentionsAdapterDelegate() { + mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(actvityContext, true, 0, new MentionsAdapter.MentionsAdapterDelegate() { @Override public void needChangePanelVisibility(boolean show) { if (show) { @@ -1788,7 +1806,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat imageMoveAnimation.start(); } else if (mode == 1) { if (photoCropView == null) { - photoCropView = new PhotoCropView(parentActivity); + photoCropView = new PhotoCropView(actvityContext); photoCropView.setVisibility(View.GONE); containerView.addView(photoCropView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48)); photoCropView.setDelegate(new PhotoCropView.PhotoCropViewDelegate() { @@ -2173,12 +2191,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else { size[0] = -1; } - } else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaDocument && message.messageOwner.media.document != null && message.messageOwner.media.document.thumb != null) { - size[0] = message.messageOwner.media.document.thumb.size; + } else if (message.getDocument() != null && message.getDocument().thumb != null) { + size[0] = message.getDocument().thumb.size; if (size[0] == 0) { size[0] = -1; } - return message.messageOwner.media.document.thumb.location; + return message.getDocument().thumb.location; } } return null; @@ -2366,7 +2384,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat closePhoto(false, false); return; } - currentMessageObject = imagesArr.get(currentIndex); + MessageObject newMessageObject = imagesArr.get(currentIndex); + sameImage = currentMessageObject != null && currentMessageObject.getId() == newMessageObject.getId(); + currentMessageObject = newMessageObject; isVideo = currentMessageObject.isVideo(); if (currentMessageObject.canDeleteMessage(null)) { menuItem.showSubItem(gallery_menu_delete); @@ -2391,7 +2411,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat long date = (long) currentMessageObject.messageOwner.date * 1000; String dateString = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))); if (currentFileNames[0] != null && isVideo) { - dateTextView.setText(String.format("%s (%s)", dateString, AndroidUtilities.formatFileSize(currentMessageObject.messageOwner.media.document.size))); + dateTextView.setText(String.format("%s (%s)", dateString, AndroidUtilities.formatFileSize(currentMessageObject.getDocument().size))); } else { dateTextView.setText(dateString); } @@ -2986,6 +3006,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { + NotificationCenter.getInstance().setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded, NotificationCenter.mediaDidLoaded}); NotificationCenter.getInstance().setAnimationInProgress(true); animatorSet.start(); } @@ -3047,6 +3068,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (parentActivity == null || !isVisible || checkAnimation() || placeProvider == null) { return; } + if (captionEditText.hideActionMode() && !fromEditMode) { + return; + } captionEditText.onDestroy(); parentChatActivity = null; @@ -3914,9 +3938,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } if (loadFile) { if (!FileLoader.getInstance().isLoadingFile(currentFileNames[0])) { - FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.document, true, false); + FileLoader.getInstance().loadFile(currentMessageObject.getDocument(), true, false); } else { - FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.document); + FileLoader.getInstance().cancelLoadFile(currentMessageObject.getDocument()); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java index e63a43f7e..41e6345d3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java @@ -63,6 +63,7 @@ import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PopupAudioView; import org.telegram.ui.Components.RecordStatusDrawable; import org.telegram.ui.Components.SizeNotifierFrameLayout; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.TypingDotsDrawable; import java.io.File; @@ -160,6 +161,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Theme.loadRecources(this); int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { @@ -347,8 +349,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC actionBar = new ActionBar(this); actionBar.setOccupyStatusBar(false); actionBar.setBackButtonImage(R.drawable.ic_ab_back); - actionBar.setBackgroundColor(0xff54759e); - actionBar.setItemsBackground(R.drawable.bar_selector); + actionBar.setBackgroundColor(Theme.ACTION_BAR_COLOR); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_SELECTOR_COLOR); popupContainer.addView(actionBar); ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; @@ -359,7 +361,6 @@ public class PopupNotificationActivity extends Activity implements NotificationC countText = (TextView) view.findViewById(R.id.count_text); avatarContainer = new FrameLayoutFixed(this); - avatarContainer.setBackgroundResource(R.drawable.bar_selector); avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); actionBar.addView(avatarContainer); FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams(); @@ -398,7 +399,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC nameTextView.setLayoutParams(layoutParams2); onlineTextView = new TextView(this); - onlineTextView.setTextColor(0xffd7e8f7); + onlineTextView.setTextColor(Theme.ACTION_BAR_SUBTITLE_COLOR); onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); onlineTextView.setLines(1); onlineTextView.setMaxLines(1); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 16ebe2f88..4ffd7be05 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -20,14 +20,13 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Bitmap; +import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Outline; -import android.graphics.drawable.Drawable; +import android.graphics.Paint; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.text.TextUtils; -import android.util.TypedValue; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; @@ -38,7 +37,6 @@ import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.PhoneFormat.PhoneFormat; @@ -70,6 +68,7 @@ import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.messenger.AnimationCompat.ViewProxy; +import org.telegram.ui.ActionBar.SimpleTextView; import org.telegram.ui.Cells.AboutLinkCell; import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.EmptyCell; @@ -90,6 +89,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Components.IdenticonDrawable; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RecyclerListView; +import org.telegram.ui.ActionBar.Theme; import java.util.ArrayList; import java.util.Collections; @@ -97,20 +97,19 @@ import java.util.Comparator; import java.util.HashMap; import java.util.concurrent.Semaphore; -public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider { +public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate, PhotoViewer.PhotoViewerProvider { private RecyclerListView listView; private LinearLayoutManager layoutManager; private ListAdapter listAdapter; private BackupImageView avatarImage; - private TextView nameTextView[] = new TextView[2]; - private TextView onlineTextView[] = new TextView[2]; + private SimpleTextView nameTextView[] = new SimpleTextView[2]; + private SimpleTextView onlineTextView[] = new SimpleTextView[2]; private ImageView writeButton; private AnimatorSetProxy writeButtonAnimation; - private View extraHeightView; - private View shadowView; private AvatarDrawable avatarDrawable; private ActionBarMenuItem animatingItem; + private TopView topView; private int user_id; private int chat_id; private long dialog_id; @@ -154,7 +153,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. private final static int edit_channel = 12; private final static int convert_to_supergroup = 13; - private int overscrollRow; private int emptyRow; private int emptyRowChat; private int emptyRowChat2; @@ -182,6 +180,38 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. private int addMemberRow; private int rowCount = 0; + private class TopView extends View { + + private int currentColor; + private Paint paint = new Paint(); + + public TopView(Context context) { + super(context); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), ActionBar.getCurrentActionBarHeight() + (!AndroidUtilities.isTablet() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.dp(91)); + } + + @Override + public void setBackgroundColor(int color) { + if (color != currentColor) { + paint.setColor(color); + invalidate(); + } + } + + @Override + protected void onDraw(Canvas canvas) { + int height = getMeasuredHeight() - AndroidUtilities.dp(91); + canvas.drawRect(0, 0, getMeasuredWidth(), height + extraHeight, paint); + if (parentLayout != null) { + parentLayout.drawHeaderShadow(canvas, height + extraHeight); + } + } + } + public ProfileActivity(Bundle args) { super(args); } @@ -309,17 +339,25 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } @Override - public View createView(Context context) { - actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id)); - actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id)); + protected ActionBar createActionBar(Context context) { + ActionBar actionBar = new ActionBar(context) { + @Override + public boolean onTouchEvent(MotionEvent event) { + return super.onTouchEvent(event); //TODO + } + }; + actionBar.setItemsBackgroundColor(AvatarDrawable.getButtonColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id)); actionBar.setBackButtonDrawable(new BackDrawable(false)); actionBar.setCastShadows(false); actionBar.setAddToContainer(false); + actionBar.setOccupyStatusBar(!AndroidUtilities.isTablet()); + return actionBar; + } + + @Override + public View createView(Context context) { hasOwnBackground = true; extraHeight = 88; - if (AndroidUtilities.isTablet()) { - actionBar.setOccupyStatusBar(false); - } actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(final int id) { @@ -358,7 +396,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. MessagesController.getInstance().blockUser(user_id); } else { MessagesController.getInstance().unblockUser(user_id); - SendMessagesHelper.getInstance().sendMessage("/start", user_id, null, null, false, false, null, null); + SendMessagesHelper.getInstance().sendMessage("/start", user_id, null, null, false, false, null, null, null); finishFragment(); } } @@ -421,7 +459,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. args.putInt("dialogsType", 2); args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupTitle", R.string.AddToTheGroupTitle, UserObject.getUserName(user), "%1$s")); DialogsActivity fragment = new DialogsActivity(args); - fragment.setDelegate(new DialogsActivity.MessagesActivityDelegate() { + fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() { @Override public void didSelectDialog(DialogsActivity fragment, long did, boolean param) { Bundle args = new Bundle(); @@ -482,6 +520,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. public boolean hasOverlappingRendering() { return false; } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + checkListViewScroll(); + } }; FrameLayout frameLayout = (FrameLayout) fragmentView; @@ -491,10 +535,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return false; } }; + listView.setPadding(0, AndroidUtilities.dp(88), 0, 0); listView.setBackgroundColor(0xffffffff); listView.setVerticalScrollBarEnabled(false); listView.setItemAnimator(null); listView.setLayoutAnimation(null); + listView.setClipToPadding(false); layoutManager = new LinearLayoutManager(context) { @Override public boolean supportsPredictiveItemAnimations() { @@ -550,67 +596,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); - } else if (position == usernameRow) { - final TLRPC.User user = MessagesController.getInstance().getUser(user_id); - if (user == null || user.username == null) { - return; - } - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - try { - if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { - android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - clipboard.setText("@" + user.username); - } else { - android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", "@" + user.username); - clipboard.setPrimaryClip(clip); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - } - }); - showDialog(builder.create()); - } else if (position == phoneRow) { - final TLRPC.User user = MessagesController.getInstance().getUser(user_id); - if (user == null || user.phone == null || user.phone.length() == 0 || getParentActivity() == null) { - return; - } - - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setItems(new CharSequence[]{LocaleController.getString("Call", R.string.Call), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - try { - Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + user.phone)); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - getParentActivity().startActivityForResult(intent, 500); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } else if (i == 1) { - try { - if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { - android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - clipboard.setText("+" + user.phone); - } else { - android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", "+" + user.phone); - clipboard.setPrimaryClip(clip); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - } - }); - showDialog(builder.create()); } else if (position > emptyRowChat2 && position < membersEndRow) { int user_id; if (!sortedUsers.isEmpty()) { @@ -652,26 +637,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. args.putInt("type", 2); } presentFragment(new ChannelUsersActivity(args)); - } else if (position == channelInfoRow) { - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - try { - if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { - android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - clipboard.setText(info.about); - } else { - android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", info.about); - clipboard.setPrimaryClip(clip); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - }); - showDialog(builder.create()); } else if (position == convertRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("ConvertGroupAlert", R.string.ConvertGroupAlert)); @@ -684,134 +649,126 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); + } else { + processOnClickOrPress(position); } } }); - if (chat_id != 0) { - listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() { - @Override - public boolean onItemClick(View view, int position) { - if (position > emptyRowChat2 && position < membersEndRow) { - if (getParentActivity() == null) { - return false; - } - boolean allowKick = false; - boolean allowSetAdmin = false; - - final TLRPC.ChatParticipant user; - if (!sortedUsers.isEmpty()) { - user = info.participants.participants.get(sortedUsers.get(position - emptyRowChat2 - 1)); - } else { - user = info.participants.participants.get(position - emptyRowChat2 - 1); - } - selectedUser = user.user_id; - - if (ChatObject.isChannel(currentChat)) { - TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) user).channelParticipant; - if (user.user_id != UserConfig.getClientUserId()) { - if (currentChat.creator) { - allowKick = true; - } else if (channelParticipant instanceof TLRPC.TL_channelParticipant) { - if (currentChat.editor || channelParticipant.inviter_id == UserConfig.getClientUserId()) { - allowKick = true; - } - } - } - TLRPC.User u = MessagesController.getInstance().getUser(user.user_id); - allowSetAdmin = channelParticipant instanceof TLRPC.TL_channelParticipant && !u.bot; - } else { - if (user.user_id != UserConfig.getClientUserId()) { - if (currentChat.creator) { - allowKick = true; - } else if (user instanceof TLRPC.TL_chatParticipant) { - if (currentChat.admin && currentChat.admins_enabled || user.inviter_id == UserConfig.getClientUserId()) { - allowKick = true; - } - } - } - } - if (!allowKick) { - return false; - } - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - if (currentChat.megagroup && currentChat.creator && allowSetAdmin) { - CharSequence[] items = new CharSequence[]{LocaleController.getString("SetAsAdmin", R.string.SetAsAdmin), LocaleController.getString("KickFromGroup", R.string.KickFromGroup)}; - builder.setItems(items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - TLRPC.TL_chatChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) user); - - channelParticipant.channelParticipant = new TLRPC.TL_channelParticipantEditor(); - channelParticipant.channelParticipant.inviter_id = UserConfig.getClientUserId(); - channelParticipant.channelParticipant.user_id = user.user_id; - channelParticipant.channelParticipant.date = user.date; - - TLRPC.TL_channels_editAdmin req = new TLRPC.TL_channels_editAdmin(); - req.channel = MessagesController.getInputChannel(chat_id); - req.user_id = MessagesController.getInputUser(selectedUser); - req.role = new TLRPC.TL_channelRoleEditor(); - ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { - @Override - public void run(TLObject response, final TLRPC.TL_error error) { - if (error == null) { - MessagesController.getInstance().processUpdates((TLRPC.Updates) response, false); - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - MessagesController.getInstance().loadFullChat(chat_id, 0, true); - } - }, 1000); - } else { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - AlertsCreator.showAddUserAlert(error.text, ProfileActivity.this, false); - } - }); - } - } - }); - } else if (i == 1) { - kickUser(selectedUser); - } - } - }); - } else { - CharSequence[] items = new CharSequence[]{chat_id > 0 ? LocaleController.getString("KickFromGroup", R.string.KickFromGroup) : LocaleController.getString("KickFromBroadcast", R.string.KickFromBroadcast)}; - builder.setItems(items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - kickUser(selectedUser); - } - } - }); - } - showDialog(builder.create()); - return true; + listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() { + @Override + public boolean onItemClick(View view, int position) { + if (position > emptyRowChat2 && position < membersEndRow) { + if (getParentActivity() == null) { + return false; } - return false; + boolean allowKick = false; + boolean allowSetAdmin = false; + + final TLRPC.ChatParticipant user; + if (!sortedUsers.isEmpty()) { + user = info.participants.participants.get(sortedUsers.get(position - emptyRowChat2 - 1)); + } else { + user = info.participants.participants.get(position - emptyRowChat2 - 1); + } + selectedUser = user.user_id; + + if (ChatObject.isChannel(currentChat)) { + TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) user).channelParticipant; + if (user.user_id != UserConfig.getClientUserId()) { + if (currentChat.creator) { + allowKick = true; + } else if (channelParticipant instanceof TLRPC.TL_channelParticipant) { + if (currentChat.editor || channelParticipant.inviter_id == UserConfig.getClientUserId()) { + allowKick = true; + } + } + } + TLRPC.User u = MessagesController.getInstance().getUser(user.user_id); + allowSetAdmin = channelParticipant instanceof TLRPC.TL_channelParticipant && !u.bot; + } else { + if (user.user_id != UserConfig.getClientUserId()) { + if (currentChat.creator) { + allowKick = true; + } else if (user instanceof TLRPC.TL_chatParticipant) { + if (currentChat.admin && currentChat.admins_enabled || user.inviter_id == UserConfig.getClientUserId()) { + allowKick = true; + } + } + } + } + if (!allowKick) { + return false; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + if (currentChat.megagroup && currentChat.creator && allowSetAdmin) { + CharSequence[] items = new CharSequence[]{LocaleController.getString("SetAsAdmin", R.string.SetAsAdmin), LocaleController.getString("KickFromGroup", R.string.KickFromGroup)}; + builder.setItems(items, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (i == 0) { + TLRPC.TL_chatChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) user); + + channelParticipant.channelParticipant = new TLRPC.TL_channelParticipantEditor(); + channelParticipant.channelParticipant.inviter_id = UserConfig.getClientUserId(); + channelParticipant.channelParticipant.user_id = user.user_id; + channelParticipant.channelParticipant.date = user.date; + + TLRPC.TL_channels_editAdmin req = new TLRPC.TL_channels_editAdmin(); + req.channel = MessagesController.getInputChannel(chat_id); + req.user_id = MessagesController.getInputUser(selectedUser); + req.role = new TLRPC.TL_channelRoleEditor(); + ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { + @Override + public void run(TLObject response, final TLRPC.TL_error error) { + if (error == null) { + MessagesController.getInstance().processUpdates((TLRPC.Updates) response, false); + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + MessagesController.getInstance().loadFullChat(chat_id, 0, true); + } + }, 1000); + } else { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + AlertsCreator.showAddUserAlert(error.text, ProfileActivity.this, false); + } + }); + } + } + }); + } else if (i == 1) { + kickUser(selectedUser); + } + } + }); + } else { + CharSequence[] items = new CharSequence[]{chat_id > 0 ? LocaleController.getString("KickFromGroup", R.string.KickFromGroup) : LocaleController.getString("KickFromBroadcast", R.string.KickFromBroadcast)}; + builder.setItems(items, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (i == 0) { + kickUser(selectedUser); + } + } + }); + } + showDialog(builder.create()); + return true; + } else { + return processOnClickOrPress(position); } - }); - } + } + }); + + topView = new TopView(context); + topView.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id)); + frameLayout.addView(topView); frameLayout.addView(actionBar); - extraHeightView = new View(context); - ViewProxy.setPivotY(extraHeightView, 0); - extraHeightView.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id)); - frameLayout.addView(extraHeightView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 88)); - - shadowView = new View(context); - try { - shadowView.setBackgroundResource(R.drawable.header_shadow); - } catch (Throwable e) { - FileLog.e("tmessages", e); - } - frameLayout.addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3)); - avatarImage = new BackupImageView(context); avatarImage.setRoundRadius(AndroidUtilities.dp(21)); ViewProxy.setPivotX(avatarImage, 0); @@ -840,27 +797,20 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (!playProfileAnimation && a == 0) { continue; } - nameTextView[a] = new TextView(context); + nameTextView[a] = new SimpleTextView(context); nameTextView[a].setTextColor(0xffffffff); - nameTextView[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); - nameTextView[a].setLines(1); - nameTextView[a].setMaxLines(1); - nameTextView[a].setSingleLine(true); - nameTextView[a].setEllipsize(TextUtils.TruncateAt.END); + nameTextView[a].setTextSize(18); nameTextView[a].setGravity(Gravity.LEFT); nameTextView[a].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - nameTextView[a].setCompoundDrawablePadding(AndroidUtilities.dp(4)); + nameTextView[a].setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f)); + nameTextView[a].setRightDrawableTopPadding(-AndroidUtilities.dp(1.3f)); ViewProxy.setPivotX(nameTextView[a], 0); ViewProxy.setPivotY(nameTextView[a], 0); frameLayout.addView(nameTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, a == 0 ? 48 : 0, 0)); - onlineTextView[a] = new TextView(context); + onlineTextView[a] = new SimpleTextView(context); onlineTextView[a].setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id)); - onlineTextView[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - onlineTextView[a].setLines(1); - onlineTextView[a].setMaxLines(1); - onlineTextView[a].setSingleLine(true); - onlineTextView[a].setEllipsize(TextUtils.TruncateAt.END); + onlineTextView[a].setTextSize(14); onlineTextView[a].setGravity(Gravity.LEFT); frameLayout.addView(onlineTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, a == 0 ? 48 : 8, 0)); } @@ -968,11 +918,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. needLayout(); listView.setOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - } - @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { checkListViewScroll(); @@ -985,6 +930,104 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return fragmentView; } + private boolean processOnClickOrPress(final int position) { + if (position == usernameRow) { + final TLRPC.User user = MessagesController.getInstance().getUser(user_id); + if (user == null || user.username == null) { + return false; + } + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (i == 0) { + try { + if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { + android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + clipboard.setText("@" + user.username); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", "@" + user.username); + clipboard.setPrimaryClip(clip); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } + }); + showDialog(builder.create()); + return true; + } else if (position == phoneRow) { + final TLRPC.User user = MessagesController.getInstance().getUser(user_id); + if (user == null || user.phone == null || user.phone.length() == 0 || getParentActivity() == null) { + return false; + } + + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setItems(new CharSequence[]{LocaleController.getString("Call", R.string.Call), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (i == 0) { + try { + Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + user.phone)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + getParentActivity().startActivityForResult(intent, 500); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } else if (i == 1) { + try { + if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { + android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + clipboard.setText("+" + user.phone); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", "+" + user.phone); + clipboard.setPrimaryClip(clip); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } + }); + showDialog(builder.create()); + return true; + } else if (position == channelInfoRow || position == userInfoRow) { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + try { + String about; + if (position == channelInfoRow) { + about = info.about; + } else { + about = MessagesController.getInstance().getUserAbout(botInfo.user_id); + } + if (about == null) { + return; + } + if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { + android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + clipboard.setText(about); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", about); + clipboard.setPrimaryClip(clip); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + showDialog(builder.create()); + return true; + } + return false; + } + private void leaveChatPressed() { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); if (ChatObject.isChannel(chat_id) && !currentChat.megagroup) { @@ -1115,19 +1158,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } private void checkListViewScroll() { - if (listView.getChildCount() == 0 || openAnimationInProgress) { + if (listView.getChildCount() <= 0 || openAnimationInProgress) { return; } - int height = 0; + View child = listView.getChildAt(0); - if (child != null) { - if (layoutManager.findFirstVisibleItemPosition() == 0) { - height = AndroidUtilities.dp(88) + (child.getTop() < 0 ? child.getTop() : 0); - } - if (extraHeight != height) { - extraHeight = height; - needLayout(); - } + ListAdapter.Holder holder = (ListAdapter.Holder) listView.findContainingViewHolder(child); + int top = child.getTop(); + int newOffset = 0; + if (top >= 0 && holder != null && holder.getAdapterPosition() == 0) { + newOffset = top; + } + if (extraHeight != newOffset) { + extraHeight = newOffset; + topView.invalidate(); + needLayout(); } } @@ -1139,14 +1184,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (layoutParams.topMargin != newTop) { layoutParams.topMargin = newTop; listView.setLayoutParams(layoutParams); - ViewProxy.setTranslationY(extraHeightView, newTop); } } if (avatarImage != null) { float diff = extraHeight / (float) AndroidUtilities.dp(88); - ViewProxy.setScaleY(extraHeightView, diff); - ViewProxy.setTranslationY(shadowView, newTop + extraHeight); listView.setTopGlowOffset(extraHeight); if (writeButton != null) { @@ -1228,9 +1270,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. continue; } ViewProxy.setTranslationX(nameTextView[a], -21 * AndroidUtilities.density * diff); - ViewProxy.setTranslationY(nameTextView[a], (float) Math.floor(avatarY) - (float) Math.ceil(AndroidUtilities.density) + (float) Math.floor(7 * AndroidUtilities.density * diff)); + ViewProxy.setTranslationY(nameTextView[a], (float) Math.floor(avatarY) + AndroidUtilities.dp(1.3f) + AndroidUtilities.dp(7) * diff); ViewProxy.setTranslationX(onlineTextView[a], -21 * AndroidUtilities.density * diff); - ViewProxy.setTranslationY(onlineTextView[a], (float) Math.floor(avatarY) + AndroidUtilities.dp(22) + (float) Math.floor(11 * AndroidUtilities.density) * diff); + ViewProxy.setTranslationY(onlineTextView[a], (float) Math.floor(avatarY) + AndroidUtilities.dp(24) + (float) Math.floor(11 * AndroidUtilities.density) * diff); ViewProxy.setScaleX(nameTextView[a], 1.0f + 0.12f * diff); ViewProxy.setScaleY(nameTextView[a], 1.0f + 0.12f * diff); if (a == 1 && !openAnimationInProgress) { @@ -1241,13 +1283,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. width = AndroidUtilities.displaySize.x; } width = (int) (width - AndroidUtilities.dp(118 + 8 + 40 * (1.0f - diff)) - ViewProxy.getTranslationX(nameTextView[a])); - float width2 = nameTextView[a].getPaint().measureText(nameTextView[a].getText().toString()) * ViewProxy.getScaleX(nameTextView[a]); - Drawable[] drawables = nameTextView[a].getCompoundDrawables(); - for (int b = 0; b < drawables.length; b++) { - if (drawables[b] != null) { - width2 += drawables[b].getIntrinsicWidth() + AndroidUtilities.dp(4); - } - } + float width2 = nameTextView[a].getPaint().measureText(nameTextView[a].getText().toString()) * ViewProxy.getScaleX(nameTextView[a]) + nameTextView[a].getSideDrawablesSize(); layoutParams = (FrameLayout.LayoutParams) nameTextView[a].getLayoutParams(); if (width < width2) { layoutParams.width = (int) Math.ceil(width / ViewProxy.getScaleX(nameTextView[a])); @@ -1447,7 +1483,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. updateRowsIds(); if (listAdapter != null) { listAdapter.notifyDataSetChanged(); - checkListViewScroll(); } } } else if (id == NotificationCenter.didReceivedNewMessages) { @@ -1490,6 +1525,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (!backward && playProfileAnimation) { openAnimationInProgress = true; } + NotificationCenter.getInstance().setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded}); NotificationCenter.getInstance().setAnimationInProgress(true); } @@ -1508,22 +1544,32 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. public void setAnimationProgress(float progress) { animationProgress = progress; ViewProxy.setAlpha(listView, progress); - ViewProxy.setTranslationX(listView, AndroidUtilities.dp(48) * (1.0f - progress)); + + //ViewProxy.setTranslationY(listView, -AndroidUtilities.dp(48) + AndroidUtilities.dp(48) * progress); int color = AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id); - int rD = (int) ((Color.red(color) - 0x54) * progress); - int gD = (int) ((Color.green(color) - 0x75) * progress); - int bD = (int) ((Color.blue(color) - 0x9e) * progress); - actionBar.setBackgroundColor(Color.rgb(0x54 + rD, 0x75 + gD, 0x9e + bD)); - extraHeightView.setBackgroundColor(Color.rgb(0x54 + rD, 0x75 + gD, 0x9e + bD)); + + int r = Color.red(Theme.ACTION_BAR_COLOR); + int g = Color.green(Theme.ACTION_BAR_COLOR); + int b = Color.blue(Theme.ACTION_BAR_COLOR); + + int rD = (int) ((Color.red(color) - r) * progress); + int gD = (int) ((Color.green(color) - g) * progress); + int bD = (int) ((Color.blue(color) - b) * progress); + topView.setBackgroundColor(Color.rgb(r + rD, g + gD, b + bD)); color = AvatarDrawable.getProfileTextColorForId(user_id != 0 || ChatObject.isChannel(chat_id) && !currentChat.megagroup ? 5 : chat_id); - rD = (int) ((Color.red(color) - 0xd7) * progress); - gD = (int) ((Color.green(color) - 0xe8) * progress); - bD = (int) ((Color.blue(color) - 0xf7) * progress); + + r = Color.red(Theme.ACTION_BAR_SUBTITLE_COLOR); + g = Color.green(Theme.ACTION_BAR_SUBTITLE_COLOR); + b = Color.blue(Theme.ACTION_BAR_SUBTITLE_COLOR); + + rD = (int) ((Color.red(color) - r) * progress); + gD = (int) ((Color.green(color) - g) * progress); + bD = (int) ((Color.blue(color) - b) * progress); for (int a = 0; a < 2; a++) { if (onlineTextView[a] == null) { continue; } - onlineTextView[a].setTextColor(Color.rgb(0xd7 + rD, 0xe8 + gD, 0xf7 + bD)); + onlineTextView[a].setTextColor(Color.rgb(r + rD, g + gD, b + bD)); } extraHeight = (int) (initialAnimationExtraHeight * progress); color = AvatarDrawable.getProfileColorForId(user_id != 0 ? user_id : chat_id); @@ -1543,7 +1589,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. protected AnimatorSetProxy onCustomTransitionAnimation(final boolean isOpen, final Runnable callback) { if (playProfileAnimation) { final AnimatorSetProxy animatorSet = new AnimatorSetProxy(); - animatorSet.setDuration(150); + animatorSet.setDuration(180); if (Build.VERSION.SDK_INT > 15) { listView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } @@ -1559,14 +1605,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. onlineTextView[1].setLayoutParams(layoutParams); int width = (int) Math.ceil(AndroidUtilities.displaySize.x - AndroidUtilities.dp(118 + 8) + 21 * AndroidUtilities.density); - float width2 = nameTextView[1].getPaint().measureText(nameTextView[1].getText().toString()) * 1.12f; - Drawable[] drawables = nameTextView[1].getCompoundDrawables(); - for (int b = 0; b < drawables.length; b++) { - if (drawables[b] != null) { - width2 += drawables[b].getIntrinsicWidth() + AndroidUtilities.dp(4); - } - } - + float width2 = nameTextView[1].getPaint().measureText(nameTextView[1].getText().toString()) * 1.12f + nameTextView[1].getSideDrawablesSize(); layoutParams = (FrameLayout.LayoutParams) nameTextView[1].getLayoutParams(); if (width < width2) { layoutParams.width = (int) Math.ceil(width / 1.12f); @@ -1878,7 +1917,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. blockedUsersRow = -1; rowCount = 0; - overscrollRow = rowCount++; if (user_id != 0) { TLRPC.User user = MessagesController.getInstance().getUser(user_id); emptyRow = rowCount++; @@ -2011,15 +2049,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (nameTextView[a] == null) { continue; } - if (a == 0) { - if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) { - if (user.phone != null && user.phone.length() != 0) { - nameTextView[a].setText(PhoneFormat.getInstance().format("+" + user.phone)); - } else { - nameTextView[a].setText(UserObject.getUserName(user)); - } - } else { - nameTextView[a].setText(UserObject.getUserName(user)); + if (a == 0 && user.phone != null && user.phone.length() != 0 && user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null && + (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) { + String phoneString = PhoneFormat.getInstance().format("+" + user.phone); + if (!nameTextView[a].getText().equals(phoneString)) { + nameTextView[a].setText(phoneString); } } else { if (!nameTextView[a].getText().equals(newString)) { @@ -2030,19 +2064,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. onlineTextView[a].setText(newString2); } int leftIcon = currentEncryptedChat != null ? R.drawable.ic_lock_header : 0; - if (a != 0) { - if (user.verified) { - if (nameTextView[a].getCompoundDrawables()[2] == null || nameTextView[a].getCompoundDrawables()[0] == null && leftIcon != 0) { - nameTextView[a].setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, R.drawable.check_profile_fixed, 0); - } - } else { - if (nameTextView[a].getCompoundDrawables()[2] != null || nameTextView[a].getCompoundDrawables()[0] == null && leftIcon != 0) { - nameTextView[a].setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, 0, 0); - } - } - } else { - nameTextView[a].setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, MessagesController.getInstance().isDialogMuted(dialog_id != 0 ? dialog_id : (long) user_id) ? R.drawable.mute_fixed : 0, 0); + int rightIcon = 0; + if (a == 0) { + rightIcon = MessagesController.getInstance().isDialogMuted(dialog_id != 0 ? dialog_id : (long) user_id) ? R.drawable.mute_fixed : 0; + } else if (user.verified) { + rightIcon = R.drawable.check_profile_fixed; } + nameTextView[a].setLeftDrawable(leftIcon); + nameTextView[a].setRightDrawable(rightIcon); } avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); @@ -2098,18 +2127,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (chat.title != null && !nameTextView[a].getText().equals(chat.title)) { nameTextView[a].setText(chat.title); } + nameTextView[a].setLeftDrawable(null); if (a != 0) { if (chat.verified) { - if (nameTextView[a].getCompoundDrawables()[2] == null) { - nameTextView[a].setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.check_profile_fixed, 0); - } + nameTextView[a].setRightDrawable(R.drawable.check_profile_fixed); } else { - if (nameTextView[a].getCompoundDrawables()[2] != null) { - nameTextView[a].setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - } + nameTextView[a].setRightDrawable(null); } } else { - nameTextView[a].setCompoundDrawablesWithIntrinsicBounds(0, 0, MessagesController.getInstance().isDialogMuted((long) -chat_id) ? R.drawable.mute_fixed : 0, 0); + nameTextView[a].setRightDrawable(MessagesController.getInstance().isDialogMuted((long) -chat_id) ? R.drawable.mute_fixed : 0); } if (currentChat.megagroup && info != null && info.participants_count <= 200 && onlineCount > 0) { if (!onlineTextView[a].getText().equals(newString)) { @@ -2250,7 +2276,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. presentFragment(new ChatActivity(args), true); removeSelfFromStack(); TLRPC.User user = MessagesController.getInstance().getUser(user_id); - SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null, true); + SendMessagesHelper.getInstance().sendMessage(user, dialog_id, null, true, null, null); } } @@ -2363,9 +2389,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. boolean checkBackground = true; switch (holder.getItemViewType()) { case 0: - if (i == overscrollRow) { - ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(88)); - } else if (i == emptyRowChat || i == emptyRowChat2) { + if (i == emptyRowChat || i == emptyRowChat2) { ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(8)); } else { ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(36)); @@ -2475,9 +2499,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (part != null) { if (part instanceof TLRPC.TL_chatChannelParticipant) { TLRPC.ChannelParticipant channelParticipant = ((TLRPC.TL_chatChannelParticipant) part).channelParticipant; - userCell.setIsAdmin(channelParticipant instanceof TLRPC.TL_channelParticipantCreator || channelParticipant instanceof TLRPC.TL_channelParticipantEditor || channelParticipant instanceof TLRPC.TL_channelParticipantModerator); + if (channelParticipant instanceof TLRPC.TL_channelParticipantCreator) { + userCell.setIsAdmin(1); + } else if (channelParticipant instanceof TLRPC.TL_channelParticipantEditor || channelParticipant instanceof TLRPC.TL_channelParticipantModerator) { + userCell.setIsAdmin(2); + } else { + userCell.setIsAdmin(0); + } } else { - userCell.setIsAdmin(part instanceof TLRPC.TL_chatParticipantAdmin || part instanceof TLRPC.TL_chatParticipantCreator); + if (part instanceof TLRPC.TL_chatParticipantCreator) { + userCell.setIsAdmin(1); + } else if (currentChat.admins_enabled && part instanceof TLRPC.TL_chatParticipantAdmin) { + userCell.setIsAdmin(2); + } else { + userCell.setIsAdmin(0); + } } userCell.setData(MessagesController.getInstance().getUser(part.user_id), null, null, i == emptyRowChat2 + 1 ? R.drawable.menu_newgroup : 0); } @@ -2501,9 +2537,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (checkBackground) { boolean enabled = false; if (user_id != 0) { - enabled = i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == startSecretChatRow || i == usernameRow; + enabled = i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || + i == sharedMediaRow || i == startSecretChatRow || i == usernameRow || i == userInfoRow; } else if (chat_id != 0) { - enabled = i == convertRow || i == settingsNotificationsRow || i == sharedMediaRow || i > emptyRowChat2 && i < membersEndRow || i == addMemberRow || i == channelNameRow || i == leaveChannelRow || i == membersRow || i == managementRow || i == blockedUsersRow || i == channelInfoRow; + enabled = i == convertRow || i == settingsNotificationsRow || i == sharedMediaRow || i > emptyRowChat2 && i < membersEndRow || + i == addMemberRow || i == channelNameRow || i == leaveChannelRow || i == membersRow || i == managementRow || + i == blockedUsersRow || i == channelInfoRow; } if (enabled) { if (holder.itemView.getBackground() == null) { @@ -2524,7 +2563,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. @Override public int getItemViewType(int i) { - if (i == emptyRow || i == overscrollRow || i == emptyRowChat || i == emptyRowChat2) { + if (i == emptyRow || i == emptyRowChat || i == emptyRowChat2) { return 0; } else if (i == sectionRow || i == userSectionRow) { return 1; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SetAdminsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SetAdminsActivity.java index 614c5bab7..c5cdcaf67 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SetAdminsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SetAdminsActivity.java @@ -379,10 +379,6 @@ public class SetAdminsActivity extends BaseFragment implements NotificationCente return true; } else if (i >= usersStartRow && i < usersEndRow) { TLRPC.ChatParticipant participant = participants.get(i - usersStartRow); - TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id); - if (user != null && user.bot) { - return false; - } if (!(participant instanceof TLRPC.TL_chatParticipantCreator)) { return true; } @@ -451,7 +447,7 @@ public class SetAdminsActivity extends BaseFragment implements NotificationCente userCell.setData(user, null, null, 0); chat = MessagesController.getInstance().getChat(chat_id); userCell.setChecked(!(part instanceof TLRPC.TL_chatParticipant) || chat != null && !chat.admins_enabled, false); - userCell.setCheckDisabled(chat == null || !chat.admins_enabled || part.user_id == UserConfig.getClientUserId() || user != null && user.bot); + userCell.setCheckDisabled(chat == null || !chat.admins_enabled || part.user_id == UserConfig.getClientUserId()); } return view; } @@ -548,7 +544,7 @@ public class SetAdminsActivity extends BaseFragment implements NotificationCente for (int a = 0; a < contactsCopy.size(); a++) { TLRPC.ChatParticipant participant = contactsCopy.get(a); TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id); - if (user.id == UserConfig.getClientUserId() || user.bot) { + if (user.id == UserConfig.getClientUserId()) { continue; } @@ -651,7 +647,7 @@ public class SetAdminsActivity extends BaseFragment implements NotificationCente userCell.setData(user, name, username, 0); chat = MessagesController.getInstance().getChat(chat_id); userCell.setChecked(!(participant instanceof TLRPC.TL_chatParticipant) || chat != null && !chat.admins_enabled, false); - userCell.setCheckDisabled(chat == null || !chat.admins_enabled || participant.user_id == UserConfig.getClientUserId() || user != null && user.bot); + userCell.setCheckDisabled(chat == null || !chat.admins_enabled || participant.user_id == UserConfig.getClientUserId()); return view; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index afdfe696a..308309019 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -61,6 +61,7 @@ import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.BuildVars; import org.telegram.messenger.LocaleController; import org.telegram.messenger.FileLoader; +import org.telegram.messenger.browser.Browser; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.SerializedData; @@ -93,6 +94,7 @@ import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.NumberPicker; +import org.telegram.ui.ActionBar.Theme; import java.io.File; import java.util.ArrayList; @@ -296,7 +298,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter @Override public View createView(Context context) { actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(5)); - actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5)); + actionBar.setItemsBackgroundColor(AvatarDrawable.getButtonColorForId(5)); actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAddToContainer(false); extraHeight = 88; @@ -420,7 +422,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter final TextView message = new TextView(getParentActivity()); message.setText(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo))); message.setTextSize(18); - message.setLinkTextColor(0xff316f9f); + message.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); message.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(5), AndroidUtilities.dp(8), AndroidUtilities.dp(6)); message.setMovementMethod(new LinkMovementMethodMy()); @@ -492,9 +494,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else if (i == telegramFaqRow) { - AndroidUtilities.openUrl(getParentActivity(), LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)); + Browser.openUrl(getParentActivity(), LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)); } else if (i == privacyPolicyRow) { - AndroidUtilities.openUrl(getParentActivity(), LocaleController.getString("PrivacyPolicyUrl", R.string.PrivacyPolicyUrl)); + Browser.openUrl(getParentActivity(), LocaleController.getString("PrivacyPolicyUrl", R.string.PrivacyPolicyUrl)); } else if (i == contactsReimportRow) { //not implemented } else if (i == contactsSortRow) { @@ -537,7 +539,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter mask = MediaController.getInstance().roamingDownloadMask; } - builder.setApplyTopPaddings(false); + builder.setApplyTopPadding(false); + builder.setApplyBottomPadding(false); LinearLayout linearLayout = new LinearLayout(getParentActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < 6; a++) { @@ -583,7 +586,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter BottomSheet.BottomSheetCell cell = new BottomSheet.BottomSheetCell(getParentActivity(), 2); cell.setBackgroundResource(R.drawable.list_selector); cell.setTextAndIcon(LocaleController.getString("Save", R.string.Save).toUpperCase(), 0); - cell.setTextColor(0xff517fad); + cell.setTextColor(Theme.AUTODOWNLOAD_SHEET_SAVE_TEXT_COLOR); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1096,7 +1099,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter photoBig = user.photo.photo_big; } AvatarDrawable avatarDrawable = new AvatarDrawable(user, true); - avatarDrawable.setColor(0xff5c98cd); + + avatarDrawable.setColor(Theme.ACTION_BAR_MAIN_AVATAR_COLOR); if (avatarImage != null) { avatarImage.setImage(photo, "50_50", avatarDrawable); avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); @@ -1255,9 +1259,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } else if (i == raiseToSpeakRow) { textCell.setTextAndCheck(LocaleController.getString("RaiseToSpeak", R.string.RaiseToSpeak), MediaController.getInstance().canRaiseToSpeak(), true); } else if (i == customTabsRow) { - textCell.setTextAndValueAndCheck(LocaleController.getString("ChromeCustomTabs", R.string.ChromeCustomTabs), LocaleController.getString("ChromeCustomTabsInfo", R.string.ChromeCustomTabsInfo), MediaController.getInstance().canCustomTabs(), true); + textCell.setTextAndValueAndCheck(LocaleController.getString("ChromeCustomTabs", R.string.ChromeCustomTabs), LocaleController.getString("ChromeCustomTabsInfo", R.string.ChromeCustomTabsInfo), MediaController.getInstance().canCustomTabs(), false, true); } else if (i == directShareRow) { - textCell.setTextAndValueAndCheck(LocaleController.getString("DirectShare", R.string.DirectShare), LocaleController.getString("DirectShareInfo", R.string.DirectShareInfo), MediaController.getInstance().canDirectShare(), true); + textCell.setTextAndValueAndCheck(LocaleController.getString("DirectShare", R.string.DirectShare), LocaleController.getString("DirectShareInfo", R.string.DirectShareInfo), MediaController.getInstance().canDirectShare(), false, true); } } else if (type == 4) { if (view == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StickerPreviewViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/StickerPreviewViewer.java index 7abf9ddf9..9970ed5e3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StickerPreviewViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StickerPreviewViewer.java @@ -27,6 +27,7 @@ import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.FileLog; import org.telegram.tgnet.TLRPC; +import org.telegram.ui.Cells.ContextLinkCell; import org.telegram.ui.Cells.StickerCell; import org.telegram.ui.Cells.StickerEmojiCell; import org.telegram.ui.Components.LayoutHelper; @@ -88,6 +89,8 @@ public class StickerPreviewViewer { ((StickerEmojiCell) currentStickerPreviewCell).setScaled(false); } else if (currentStickerPreviewCell instanceof StickerCell) { ((StickerCell) currentStickerPreviewCell).setScaled(false); + } else if (currentStickerPreviewCell instanceof ContextLinkCell) { + ((ContextLinkCell) currentStickerPreviewCell).setScaled(false); } currentStickerPreviewCell = null; } @@ -116,6 +119,8 @@ public class StickerPreviewViewer { ((StickerEmojiCell) currentStickerPreviewCell).setScaled(false); } else if (currentStickerPreviewCell instanceof StickerCell) { ((StickerCell) currentStickerPreviewCell).setScaled(false); + } else if (currentStickerPreviewCell instanceof ContextLinkCell) { + ((ContextLinkCell) currentStickerPreviewCell).setScaled(false); } currentStickerPreviewCell = null; } @@ -148,13 +153,23 @@ public class StickerPreviewViewer { if (top > y || bottom < y || left > x || right < x) { continue; } - if (!(view instanceof StickerEmojiCell) && !(view instanceof StickerCell) || view == currentStickerPreviewCell) { + boolean ok = false; + if (view instanceof StickerEmojiCell) { + ok = true; + } else if (view instanceof StickerCell) { + ok = true; + } else if (view instanceof ContextLinkCell) { + ok = ((ContextLinkCell) view).isSticker(); + } + if (!ok || view == currentStickerPreviewCell) { break; } if (currentStickerPreviewCell instanceof StickerEmojiCell) { ((StickerEmojiCell) currentStickerPreviewCell).setScaled(false); } else if (currentStickerPreviewCell instanceof StickerCell) { ((StickerCell) currentStickerPreviewCell).setScaled(false); + } else if (currentStickerPreviewCell instanceof ContextLinkCell) { + ((ContextLinkCell) currentStickerPreviewCell).setScaled(false); } currentStickerPreviewCell = view; setKeyboardHeight(height); @@ -164,6 +179,9 @@ public class StickerPreviewViewer { } else if (currentStickerPreviewCell instanceof StickerCell) { open(((StickerCell) currentStickerPreviewCell).getSticker()); ((StickerCell) currentStickerPreviewCell).setScaled(true); + } else if (currentStickerPreviewCell instanceof ContextLinkCell) { + open(((ContextLinkCell) currentStickerPreviewCell).getDocument()); + ((ContextLinkCell) currentStickerPreviewCell).setScaled(true); } return true; } @@ -212,7 +230,16 @@ public class StickerPreviewViewer { if (top > y || bottom < y || left > x || right < x) { continue; } - if (!(view instanceof StickerEmojiCell) && !(view instanceof StickerCell) || view instanceof StickerEmojiCell && !((StickerEmojiCell) view).showingBitmap() || view instanceof StickerCell && !((StickerCell) view).showingBitmap()) { + boolean ok = false; + if (view instanceof StickerEmojiCell) { + ok = ((StickerEmojiCell) view).showingBitmap(); + } else if (view instanceof StickerCell) { + ok = ((StickerCell) view).showingBitmap(); + } else if (view instanceof ContextLinkCell) { + ContextLinkCell cell = (ContextLinkCell) view; + ok = cell.isSticker() && cell.showingBitmap(); + } + if (!ok) { return false; } startX = x; @@ -240,6 +267,9 @@ public class StickerPreviewViewer { } else if (currentStickerPreviewCell instanceof StickerCell) { open(((StickerCell) currentStickerPreviewCell).getSticker()); ((StickerCell) currentStickerPreviewCell).setScaled(true); + } else if (currentStickerPreviewCell instanceof ContextLinkCell) { + open(((ContextLinkCell) currentStickerPreviewCell).getDocument()); + ((ContextLinkCell) currentStickerPreviewCell).setScaled(true); } } }; @@ -260,7 +290,7 @@ public class StickerPreviewViewer { windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 23) { - windowView.setFitsSystemWindows(true); //TODO ? + windowView.setFitsSystemWindows(true); } containerView = new FrameLayoutDrawer(activity); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java index 1c6b00917..a6644a08a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java @@ -14,7 +14,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.graphics.Canvas; import android.os.Build; -import android.os.Message; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.view.View; @@ -167,18 +166,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter if (stickers == null || stickers.isEmpty()) { return; } - StickersAlert alert = new StickersAlert(getParentActivity(), stickerSet); - alert.setButton(AlertDialog.BUTTON_NEGATIVE, LocaleController.getString("Close", R.string.Close), (Message) null); - if (!stickerSet.set.official) { - alert.setButton(AlertDialog.BUTTON_NEUTRAL, LocaleController.getString("StickersRemove", R.string.StickersRemove), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - StickersQuery.removeStickersSet(getParentActivity(), stickerSet.set, 0); - } - }); - } - setVisibleDialog(alert); - alert.show(); + showDialog(new StickersAlert(getParentActivity(), null, stickerSet, null)); } } }); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java index bc5f0afec..25c793b26 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java @@ -680,8 +680,8 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific if (text == null || text.length() < 3) { return false; } - int dot = text.lastIndexOf("."); - int dog = text.lastIndexOf("@"); + int dot = text.lastIndexOf('.'); + int dog = text.lastIndexOf('@'); return !(dot < 0 || dog < 0 || dot < dog); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java index 64db21a64..111f7be53 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java @@ -49,6 +49,7 @@ import org.telegram.messenger.R; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.VideoSeekBarView; import org.telegram.ui.Components.VideoTimelineView; @@ -225,8 +226,8 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur @Override public View createView(Context context) { - actionBar.setBackgroundColor(0xff333333); - actionBar.setItemsBackground(R.drawable.bar_selector_white); + actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR); + actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR); actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setTitle(LocaleController.getString("EditVideo", R.string.EditVideo)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java index 0e75d8250..e2ee12828 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java @@ -16,6 +16,8 @@ import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.Point; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; @@ -61,7 +63,8 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent private ListAdapter listAdapter; private ImageView backgroundImage; - private ProgressBar progressBar; + private FrameLayout progressView; + private View progressViewBackground; private int selectedBackground; private int selectedColor; private ArrayList wallPapers = new ArrayList<>(); @@ -80,7 +83,6 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); - NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.wallpapersDidLoaded); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); @@ -97,7 +99,6 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent super.onFragmentDestroy(); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidLoaded); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.wallpapersDidLoaded); } @@ -171,9 +172,23 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent } }); - progressBar = new ProgressBar(context); - progressBar.setPadding(AndroidUtilities.dp(6), AndroidUtilities.dp(6), AndroidUtilities.dp(6), AndroidUtilities.dp(6)); - frameLayout.addView(progressBar, LayoutHelper.createFrame(60, 60, Gravity.CENTER, 0, 0, 0, 52)); + progressView = new FrameLayout(context); + progressView.setVisibility(View.INVISIBLE); + frameLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 52)); + + progressViewBackground = new View(context); + progressViewBackground.setBackgroundResource(R.drawable.system_loader); + progressView.addView(progressViewBackground, LayoutHelper.createFrame(36, 36, Gravity.CENTER)); + + ProgressBar progressBar = new ProgressBar(context); + try { + progressBar.setIndeterminateDrawable(context.getResources().getDrawable(R.drawable.loading_animation)); + } catch (Exception e) { + //don't promt + } + progressBar.setIndeterminate(true); + AndroidUtilities.setProgressBarAnimationDuration(progressBar, 1500); + progressView.addView(progressBar, LayoutHelper.createFrame(32, 32, Gravity.CENTER)); RecyclerListView listView = new RecyclerListView(context); listView.setClipToPadding(false); @@ -313,11 +328,12 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg"; File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName); if (!f.exists()) { - progressBar.setProgress(0); + int result[] = AndroidUtilities.calcDrawableColor(backgroundImage.getDrawable()); + progressViewBackground.getBackground().setColorFilter(new PorterDuffColorFilter(result[0], PorterDuff.Mode.MULTIPLY)); loadingFile = fileName; loadingFileObject = f; doneButton.setEnabled(false); - progressBar.setVisibility(View.VISIBLE); + progressView.setVisibility(View.VISIBLE); loadingSize = size; selectedColor = 0; FileLoader.getInstance().loadFile(size, null, true); @@ -337,7 +353,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent backgroundImage.setBackgroundColor(0); selectedColor = 0; doneButton.setEnabled(true); - progressBar.setVisibility(View.GONE); + progressView.setVisibility(View.GONE); } } else { if (loadingFile != null) { @@ -373,7 +389,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent loadingFile = null; loadingSize = null; doneButton.setEnabled(true); - progressBar.setVisibility(View.GONE); + progressView.setVisibility(View.GONE); } } @@ -386,26 +402,20 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent loadingFileObject = null; loadingFile = null; loadingSize = null; - progressBar.setVisibility(View.GONE); + progressView.setVisibility(View.GONE); doneButton.setEnabled(false); } } else if (id == NotificationCenter.FileDidLoaded) { String location = (String) args[0]; if (loadingFile != null && loadingFile.equals(location)) { backgroundImage.setImageURI(Uri.fromFile(loadingFileObject)); - progressBar.setVisibility(View.GONE); + progressView.setVisibility(View.GONE); backgroundImage.setBackgroundColor(0); doneButton.setEnabled(true); loadingFileObject = null; loadingFile = null; loadingSize = null; } - } else if (id == NotificationCenter.FileLoadProgressChanged) { - String location = (String) args[0]; - if (loadingFile != null && loadingFile.equals(location)) { - Float progress = (Float) args[1]; - progressBar.setProgress((int) (progress * 100)); - } } else if (id == NotificationCenter.wallpapersDidLoaded) { wallPapers = (ArrayList) args[0]; wallpappersByIds.clear(); diff --git a/TMessagesProj/src/main/res/drawable-hdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/addcontact_blue.png deleted file mode 100755 index a90b6ce9c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/addcontact_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/admin_star2.png b/TMessagesProj/src/main/res/drawable-hdpi/admin_star2.png new file mode 100755 index 000000000..6d9f3a892 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/admin_star2.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/attach_video.png b/TMessagesProj/src/main/res/drawable-hdpi/attach_video.png index 7bb7aca4f..2b21de5b6 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/attach_video.png and b/TMessagesProj/src/main/res/drawable-hdpi/attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/attach_video_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/attach_video_pressed.png index db40e51ce..3f23133f9 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/attach_video_pressed.png and b/TMessagesProj/src/main/res/drawable-hdpi/attach_video_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bot_file.png b/TMessagesProj/src/main/res/drawable-hdpi/bot_file.png new file mode 100755 index 000000000..81a867e92 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/bot_file.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bot_lines.png b/TMessagesProj/src/main/res/drawable-hdpi/bot_lines.png new file mode 100755 index 000000000..3d80a3e40 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/bot_lines.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bot_link.png b/TMessagesProj/src/main/res/drawable-hdpi/bot_link.png new file mode 100755 index 000000000..9fbea8cf5 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/bot_link.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bot_list.png b/TMessagesProj/src/main/res/drawable-hdpi/bot_list.png index d87b1878f..cbcfa1f25 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/bot_list.png and b/TMessagesProj/src/main/res/drawable-hdpi/bot_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bot_location.png b/TMessagesProj/src/main/res/drawable-hdpi/bot_location.png new file mode 100755 index 000000000..e587748fe Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/bot_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bot_music.png b/TMessagesProj/src/main/res/drawable-hdpi/bot_music.png new file mode 100755 index 000000000..03857ec84 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/bot_music.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/bottom_shadow.png b/TMessagesProj/src/main/res/drawable-hdpi/bottom_shadow.png index 5dc9ed10a..c2d6c3756 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/bottom_shadow.png and b/TMessagesProj/src/main/res/drawable-hdpi/bottom_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/cancel_b.png b/TMessagesProj/src/main/res/drawable-hdpi/cancel_b.png deleted file mode 100755 index c942d603c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/cancel_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/cancel_b_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/cancel_b_pressed.png deleted file mode 100755 index 58add0c14..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/cancel_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/cancel_b_s.png b/TMessagesProj/src/main/res/drawable-hdpi/cancel_b_s.png deleted file mode 100755 index a649b3121..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/cancel_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/cancel_big.png b/TMessagesProj/src/main/res/drawable-hdpi/cancel_big.png index 8a26eefa1..2dadadc3f 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/cancel_big.png and b/TMessagesProj/src/main/res/drawable-hdpi/cancel_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/cancel_g.png b/TMessagesProj/src/main/res/drawable-hdpi/cancel_g.png deleted file mode 100755 index 7c9c3decb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/cancel_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/cancel_g_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/cancel_g_pressed.png deleted file mode 100755 index 2efb6df04..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/cancel_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/cancel_g_s.png b/TMessagesProj/src/main/res/drawable-hdpi/cancel_g_s.png deleted file mode 100755 index a9d24b6fe..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/cancel_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/circle_big.png b/TMessagesProj/src/main/res/drawable-hdpi/circle_big.png index bdad5c802..4a0f8dd5f 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/circle_big.png and b/TMessagesProj/src/main/res/drawable-hdpi/circle_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/contact_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/contact_blue.png new file mode 100755 index 000000000..0f52e8781 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/contact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/contact_green.png b/TMessagesProj/src/main/res/drawable-hdpi/contact_green.png new file mode 100755 index 000000000..1b3c67d76 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/contact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_in_bl.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_bl.png new file mode 100755 index 000000000..de2693153 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_in_br.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_br.png new file mode 100755 index 000000000..4bdd96326 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_in_tl.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_tl.png new file mode 100755 index 000000000..26868c2a3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_in_tr.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_tr.png new file mode 100755 index 000000000..7351bcc97 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_in_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_out_bl.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_bl.png new file mode 100755 index 000000000..6209ba0be Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_out_br.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_br.png new file mode 100755 index 000000000..e4783db81 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_out_tl.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_tl.png new file mode 100755 index 000000000..0c22f84ec Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/corner_out_tr.png b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_tr.png new file mode 100755 index 000000000..64cab85f3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/corner_out_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/delete_reply.png b/TMessagesProj/src/main/res/drawable-hdpi/delete_reply.png index 213ff5b50..d225e7e22 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/delete_reply.png and b/TMessagesProj/src/main/res/drawable-hdpi/delete_reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png old mode 100644 new mode 100755 index dbb256bc3..3d15a62bc Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge2.9.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge2.9.png index 76ff17ccc..3a857ff23 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge2.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/doc_blue.png old mode 100644 new mode 100755 index a6a72c978..2e5b702f5 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/doc_blue.png and b/TMessagesProj/src/main/res/drawable-hdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/doc_blue_s.png b/TMessagesProj/src/main/res/drawable-hdpi/doc_blue_s.png index d5f3d88bf..0484f441a 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/doc_blue_s.png and b/TMessagesProj/src/main/res/drawable-hdpi/doc_blue_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-hdpi/doc_green.png old mode 100644 new mode 100755 index 72180a744..9bc676c99 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/doc_green.png and b/TMessagesProj/src/main/res/drawable-hdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/download_b.png b/TMessagesProj/src/main/res/drawable-hdpi/download_b.png deleted file mode 100755 index a9f428125..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/download_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/download_b_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/download_b_pressed.png deleted file mode 100755 index d3a6eb918..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/download_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/download_b_s.png b/TMessagesProj/src/main/res/drawable-hdpi/download_b_s.png deleted file mode 100755 index ee0cc68fd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/download_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/download_bb.png b/TMessagesProj/src/main/res/drawable-hdpi/download_bb.png deleted file mode 100755 index 20e550799..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/download_bb.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/download_g.png b/TMessagesProj/src/main/res/drawable-hdpi/download_g.png deleted file mode 100755 index 1c5762132..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/download_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/download_g_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/download_g_pressed.png deleted file mode 100755 index c4bba83d5..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/download_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/download_g_s.png b/TMessagesProj/src/main/res/drawable-hdpi/download_g_s.png deleted file mode 100755 index a6fea44b6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/download_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_b.png b/TMessagesProj/src/main/res/drawable-hdpi/file_b.png new file mode 100755 index 000000000..b9b9fdbc1 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_b_cancel.png b/TMessagesProj/src/main/res/drawable-hdpi/file_b_cancel.png new file mode 100755 index 000000000..76fccb3be Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_b_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_b_cancel_s.png b/TMessagesProj/src/main/res/drawable-hdpi/file_b_cancel_s.png new file mode 100755 index 000000000..212a68f29 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_b_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_b_load.png b/TMessagesProj/src/main/res/drawable-hdpi/file_b_load.png new file mode 100755 index 000000000..d704af86e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_b_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_b_load_s.png b/TMessagesProj/src/main/res/drawable-hdpi/file_b_load_s.png new file mode 100755 index 000000000..23a413daa Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_b_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_b_s.png b/TMessagesProj/src/main/res/drawable-hdpi/file_b_s.png new file mode 100755 index 000000000..b682a368c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_g.png b/TMessagesProj/src/main/res/drawable-hdpi/file_g.png new file mode 100755 index 000000000..6b805748c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_g_cancel.png b/TMessagesProj/src/main/res/drawable-hdpi/file_g_cancel.png new file mode 100755 index 000000000..5fbc87d9b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_g_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_g_cancel_s.png b/TMessagesProj/src/main/res/drawable-hdpi/file_g_cancel_s.png new file mode 100755 index 000000000..07b8de153 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_g_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_g_load.png b/TMessagesProj/src/main/res/drawable-hdpi/file_g_load.png new file mode 100755 index 000000000..741b69864 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_g_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_g_load_s.png b/TMessagesProj/src/main/res/drawable-hdpi/file_g_load_s.png new file mode 100755 index 000000000..244900120 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_g_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/file_g_s.png b/TMessagesProj/src/main/res/drawable-hdpi/file_g_s.png new file mode 100755 index 000000000..41228655b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/file_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating.png b/TMessagesProj/src/main/res/drawable-hdpi/floating.png index 99fdffa70..5215c11d3 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/floating.png and b/TMessagesProj/src/main/res/drawable-hdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating_m.png b/TMessagesProj/src/main/res/drawable-hdpi/floating_m.png index 7b5f02ca5..be31f6d4c 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/floating_m.png and b/TMessagesProj/src/main/res/drawable-hdpi/floating_m.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/floating_pressed.png index 1edf010e5..b4579d8bb 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/floating_pressed.png and b/TMessagesProj/src/main/res/drawable-hdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/forward_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/forward_blue.png old mode 100644 new mode 100755 index 36d5c85d6..c39ac4ef7 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/forward_blue.png and b/TMessagesProj/src/main/res/drawable-hdpi/forward_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_new.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_new.png index b604e6257..c06f2c593 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_new.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_new.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_msg_panel_kb.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_msg_panel_kb.png old mode 100644 new mode 100755 index 4a9ed0d81..c6985f357 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_msg_panel_kb.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_msg_panel_kb.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_send.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_send.png index 50e63ae1e..30feca08d 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_send.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_send.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/igvideo.png b/TMessagesProj/src/main/res/drawable-hdpi/igvideo.png deleted file mode 100644 index 92c22481f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/igvideo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/link.png b/TMessagesProj/src/main/res/drawable-hdpi/link.png old mode 100644 new mode 100755 index 5ad1fcb8f..987f4cc52 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/link.png and b/TMessagesProj/src/main/res/drawable-hdpi/link.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/load_big.png b/TMessagesProj/src/main/res/drawable-hdpi/load_big.png index 54ebdc932..6a082f283 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/load_big.png and b/TMessagesProj/src/main/res/drawable-hdpi/load_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/location2.png b/TMessagesProj/src/main/res/drawable-hdpi/location2.png new file mode 100644 index 000000000..84e92b27b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/location2.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/location_b.9.png b/TMessagesProj/src/main/res/drawable-hdpi/location_b.9.png old mode 100644 new mode 100755 index 84e92b27b..28f77558b Binary files a/TMessagesProj/src/main/res/drawable-hdpi/location_b.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/location_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/location_g.9.png b/TMessagesProj/src/main/res/drawable-hdpi/location_g.9.png old mode 100644 new mode 100755 index 2c9c70da2..8f2c9c0c7 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/location_g.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/location_g.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_pause.png b/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_pause.png index 390a69c76..f173ae63a 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_pause.png and b/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_pause.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_play.png b/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_play.png index 7e3d35f71..7dd0d0688 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_play.png and b/TMessagesProj/src/main/res/drawable-hdpi/miniplayer_play.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_in.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_in.9.png index 974d60e2d..984a1871c 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_in.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_in.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo.9.png index e92d7aedb..5bded8c16 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo_selected.9.png index f88932d19..e279dc81e 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_in_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_in_selected.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_in_selected.9.png index a7638c2d6..8ddd4059e 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_in_selected.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_in_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_out.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_out.9.png index 08fd35b4c..5034ea1f0 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_out.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_out.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo.9.png index f8f07f7fb..a6604011a 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo_selected.9.png index 3d5b1f9fa..8a4bd61f3 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_out_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/msg_out_selected.9.png b/TMessagesProj/src/main/res/drawable-hdpi/msg_out_selected.9.png index 5e01d8fe3..82b6bc2db 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/msg_out_selected.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/msg_out_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/newmsg_divider.png b/TMessagesProj/src/main/res/drawable-hdpi/newmsg_divider.png index b6c3c9a33..58321338a 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/newmsg_divider.png and b/TMessagesProj/src/main/res/drawable-hdpi/newmsg_divider.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_b.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_b.png index a9ac7a794..d8547fe06 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_b.png and b/TMessagesProj/src/main/res/drawable-hdpi/pause_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_b_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_b_pressed.png deleted file mode 100755 index 9f4b6e1db..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_b_s.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_b_s.png index 6ae227b1a..fe250126e 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_b_s.png and b/TMessagesProj/src/main/res/drawable-hdpi/pause_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_bb.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_bb.png deleted file mode 100755 index d8d58546b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_bb.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_g.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_g.png index b8bd88ef3..1f1f85d82 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_g.png and b/TMessagesProj/src/main/res/drawable-hdpi/pause_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_g_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_g_pressed.png deleted file mode 100755 index 19c76b441..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_g_s.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_g_s.png index ae16e2fc0..f9b9d4285 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_g_s.png and b/TMessagesProj/src/main/res/drawable-hdpi/pause_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_w.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_w.png deleted file mode 100755 index b3ba2dce6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_w2.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_w2.png deleted file mode 100755 index c673dbc14..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_w2_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_w2_pressed.png deleted file mode 100755 index 7fdae4f8a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/pause_w_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/pause_w_pressed.png deleted file mode 100755 index ca28d541d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/pause_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photocancel.png b/TMessagesProj/src/main/res/drawable-hdpi/photocancel.png old mode 100644 new mode 100755 index fb7572ece..06eae4553 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/photocancel.png and b/TMessagesProj/src/main/res/drawable-hdpi/photocancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photocancel_b.png b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_b.png new file mode 100755 index 000000000..780ecf6ac Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photocancel_b_s.png b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_b_s.png new file mode 100755 index 000000000..6c2bc841f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photocancel_g.png b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_g.png new file mode 100755 index 000000000..23200be5d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photocancel_g_s.png b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_g_s.png new file mode 100755 index 000000000..a8aad3a0e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photocancel_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_pressed.png new file mode 100755 index 000000000..3aa1632d8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photocancel_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photogif.png b/TMessagesProj/src/main/res/drawable-hdpi/photogif.png old mode 100644 new mode 100755 index 0033e3db6..2c71a6420 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/photogif.png and b/TMessagesProj/src/main/res/drawable-hdpi/photogif.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photogif_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/photogif_pressed.png new file mode 100755 index 000000000..ec339890c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photogif_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photoload.png b/TMessagesProj/src/main/res/drawable-hdpi/photoload.png old mode 100644 new mode 100755 index 2dbd58252..57c2e5240 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/photoload.png and b/TMessagesProj/src/main/res/drawable-hdpi/photoload.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photoload_b.png b/TMessagesProj/src/main/res/drawable-hdpi/photoload_b.png new file mode 100755 index 000000000..f78f534d8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photoload_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photoload_b_s.png b/TMessagesProj/src/main/res/drawable-hdpi/photoload_b_s.png new file mode 100755 index 000000000..563dd17c5 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photoload_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photoload_g.png b/TMessagesProj/src/main/res/drawable-hdpi/photoload_g.png new file mode 100755 index 000000000..bb7ba472c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photoload_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photoload_g_s.png b/TMessagesProj/src/main/res/drawable-hdpi/photoload_g_s.png new file mode 100755 index 000000000..027d0da08 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photoload_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photoload_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/photoload_pressed.png new file mode 100755 index 000000000..588a4fa7b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photoload_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photopause.png b/TMessagesProj/src/main/res/drawable-hdpi/photopause.png deleted file mode 100644 index ca0653d40..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/photopause.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/phototime2.9.png b/TMessagesProj/src/main/res/drawable-hdpi/phototime2.9.png new file mode 100755 index 000000000..143a0fbdc Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/phototime2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/phototime2_b.9.png b/TMessagesProj/src/main/res/drawable-hdpi/phototime2_b.9.png new file mode 100755 index 000000000..a0e4a272b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/phototime2_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_b.png b/TMessagesProj/src/main/res/drawable-hdpi/play_b.png new file mode 100755 index 000000000..702c57a9a Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/play_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_b_s.png b/TMessagesProj/src/main/res/drawable-hdpi/play_b_s.png new file mode 100755 index 000000000..fd1dc1228 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/play_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_big.png b/TMessagesProj/src/main/res/drawable-hdpi/play_big.png index a4e74383e..ede6189a8 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play_big.png and b/TMessagesProj/src/main/res/drawable-hdpi/play_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_g.png b/TMessagesProj/src/main/res/drawable-hdpi/play_g.png new file mode 100755 index 000000000..6b61de3ff Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/play_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_g_s.png b/TMessagesProj/src/main/res/drawable-hdpi/play_g_s.png new file mode 100755 index 000000000..0cffb436f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/play_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_w.png b/TMessagesProj/src/main/res/drawable-hdpi/play_w.png deleted file mode 100755 index 3b9bac668..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_w2.png b/TMessagesProj/src/main/res/drawable-hdpi/play_w2.png deleted file mode 100755 index 330da7e1e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_w2_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/play_w2_pressed.png deleted file mode 100755 index 7b7018e2a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/play_w_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/play_w_pressed.png deleted file mode 100755 index 7261585f5..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/play_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/playvideo.png b/TMessagesProj/src/main/res/drawable-hdpi/playvideo.png old mode 100644 new mode 100755 index 1bead9ee9..dc0e8a04d Binary files a/TMessagesProj/src/main/res/drawable-hdpi/playvideo.png and b/TMessagesProj/src/main/res/drawable-hdpi/playvideo.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/playvideo_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/playvideo_pressed.png new file mode 100755 index 000000000..63b03ebb4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/playvideo_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/reply.png b/TMessagesProj/src/main/res/drawable-hdpi/reply.png index 98db79e65..f92853200 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/reply.png and b/TMessagesProj/src/main/res/drawable-hdpi/reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/share_arrow.png b/TMessagesProj/src/main/res/drawable-hdpi/share_arrow.png new file mode 100755 index 000000000..c30cfa144 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/share_arrow.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/share_round.png b/TMessagesProj/src/main/res/drawable-hdpi/share_round.png new file mode 100755 index 000000000..d21a328b5 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/share_round.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/shareblack.png b/TMessagesProj/src/main/res/drawable-hdpi/shareblack.png deleted file mode 100644 index 9a9fd6f15..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/shareblack.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/shareblack_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/shareblack_pressed.png deleted file mode 100644 index be1b13bf8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/shareblack_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/shareblue.png b/TMessagesProj/src/main/res/drawable-hdpi/shareblue.png deleted file mode 100644 index 0171ea6f1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/shareblue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/shareblue_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/shareblue_pressed.png deleted file mode 100644 index 02e40e50f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/shareblue_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/stickercounter.9.png b/TMessagesProj/src/main/res/drawable-hdpi/stickercounter.9.png new file mode 100755 index 000000000..e17364d60 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/stickercounter.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/system.9.png b/TMessagesProj/src/main/res/drawable-hdpi/system.9.png new file mode 100755 index 000000000..de5d484a1 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/system.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/system_black.9.png b/TMessagesProj/src/main/res/drawable-hdpi/system_black.9.png deleted file mode 100644 index 14865b7ab..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/system_black.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/system_blue.9.png b/TMessagesProj/src/main/res/drawable-hdpi/system_blue.9.png deleted file mode 100755 index 65ad2140d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/system_blue.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/system_loader.png b/TMessagesProj/src/main/res/drawable-hdpi/system_loader.png new file mode 100755 index 000000000..f6a19f070 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/system_loader.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/system_loader1.png b/TMessagesProj/src/main/res/drawable-hdpi/system_loader1.png deleted file mode 100755 index c73039957..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/system_loader1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/system_loader2.png b/TMessagesProj/src/main/res/drawable-hdpi/system_loader2.png deleted file mode 100755 index 30432e96d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/system_loader2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/video_actions.png b/TMessagesProj/src/main/res/drawable-hdpi/video_actions.png new file mode 100755 index 000000000..1a80a8cd4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/video_actions.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/admin_star2.png b/TMessagesProj/src/main/res/drawable-mdpi/admin_star2.png new file mode 100755 index 000000000..150fb2159 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/admin_star2.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/attach_video.png b/TMessagesProj/src/main/res/drawable-mdpi/attach_video.png index 67ac2e3c7..4a956ce6a 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/attach_video.png and b/TMessagesProj/src/main/res/drawable-mdpi/attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/attach_video_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/attach_video_pressed.png index b814908bc..aef64ae3c 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/attach_video_pressed.png and b/TMessagesProj/src/main/res/drawable-mdpi/attach_video_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bot_file.png b/TMessagesProj/src/main/res/drawable-mdpi/bot_file.png new file mode 100755 index 000000000..44b53c442 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/bot_file.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bot_lines.png b/TMessagesProj/src/main/res/drawable-mdpi/bot_lines.png new file mode 100755 index 000000000..8f7e13f52 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/bot_lines.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bot_link.png b/TMessagesProj/src/main/res/drawable-mdpi/bot_link.png new file mode 100755 index 000000000..76d34b503 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/bot_link.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bot_list.png b/TMessagesProj/src/main/res/drawable-mdpi/bot_list.png index 0c79af3e2..41a7ae2f0 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/bot_list.png and b/TMessagesProj/src/main/res/drawable-mdpi/bot_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bot_location.png b/TMessagesProj/src/main/res/drawable-mdpi/bot_location.png new file mode 100755 index 000000000..e18474ab1 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/bot_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bot_music.png b/TMessagesProj/src/main/res/drawable-mdpi/bot_music.png new file mode 100755 index 000000000..2a9f2e532 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/bot_music.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/bottom_shadow.png b/TMessagesProj/src/main/res/drawable-mdpi/bottom_shadow.png index 3e170fda5..08ede3f29 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/bottom_shadow.png and b/TMessagesProj/src/main/res/drawable-mdpi/bottom_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/cancel_b.png b/TMessagesProj/src/main/res/drawable-mdpi/cancel_b.png deleted file mode 100755 index b0dd70ea0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/cancel_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/cancel_b_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/cancel_b_pressed.png deleted file mode 100755 index 412153274..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/cancel_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/cancel_b_s.png b/TMessagesProj/src/main/res/drawable-mdpi/cancel_b_s.png deleted file mode 100755 index 7de64f7ac..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/cancel_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/cancel_big.png b/TMessagesProj/src/main/res/drawable-mdpi/cancel_big.png index 8ffce8e40..105022781 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/cancel_big.png and b/TMessagesProj/src/main/res/drawable-mdpi/cancel_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/cancel_g.png b/TMessagesProj/src/main/res/drawable-mdpi/cancel_g.png deleted file mode 100755 index 43b0a71e4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/cancel_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/cancel_g_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/cancel_g_pressed.png deleted file mode 100755 index 4942c02cb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/cancel_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/cancel_g_s.png b/TMessagesProj/src/main/res/drawable-mdpi/cancel_g_s.png deleted file mode 100755 index 074873187..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/cancel_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/circle_big.png b/TMessagesProj/src/main/res/drawable-mdpi/circle_big.png index 46266d416..a42899d88 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/circle_big.png and b/TMessagesProj/src/main/res/drawable-mdpi/circle_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/contact_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/contact_blue.png new file mode 100755 index 000000000..1b2beced2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/contact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/contact_green.png b/TMessagesProj/src/main/res/drawable-mdpi/contact_green.png new file mode 100755 index 000000000..0cb733438 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/contact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_bl.png similarity index 53% rename from TMessagesProj/src/main/res/drawable-hdpi/addcontact_green.png rename to TMessagesProj/src/main/res/drawable-mdpi/corner_in_bl.png index a553f495f..51b1c2810 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/addcontact_green.png and b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/corner_in_br.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_br.png new file mode 100755 index 000000000..ef954307f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_tl.png similarity index 54% rename from TMessagesProj/src/main/res/drawable-mdpi/addcontact_green.png rename to TMessagesProj/src/main/res/drawable-mdpi/corner_in_tl.png index 45d6ac2b4..c9d6a3985 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/addcontact_green.png and b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/corner_in_tr.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_tr.png new file mode 100755 index 000000000..1ca70a22c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/corner_in_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_bl.png similarity index 53% rename from TMessagesProj/src/main/res/drawable-mdpi/addcontact_blue.png rename to TMessagesProj/src/main/res/drawable-mdpi/corner_out_bl.png index ec9b9c028..4d5e2d59f 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/addcontact_blue.png and b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/corner_out_br.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_br.png new file mode 100755 index 000000000..93b55ba67 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/corner_out_tl.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_tl.png new file mode 100755 index 000000000..023cc522d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/corner_out_tr.png b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_tr.png new file mode 100755 index 000000000..c549ad936 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/corner_out_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/delete_reply.png b/TMessagesProj/src/main/res/drawable-mdpi/delete_reply.png index 2fd1c1ac9..8808768e4 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/delete_reply.png and b/TMessagesProj/src/main/res/drawable-mdpi/delete_reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png old mode 100644 new mode 100755 index 2c32c51ef..bf14151a6 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge2.9.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge2.9.png index 45eaa60e0..26856e0f3 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge2.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/doc_blue.png old mode 100644 new mode 100755 index 153d689ba..6412768df Binary files a/TMessagesProj/src/main/res/drawable-mdpi/doc_blue.png and b/TMessagesProj/src/main/res/drawable-mdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/doc_blue_s.png b/TMessagesProj/src/main/res/drawable-mdpi/doc_blue_s.png index 922975c71..361da2e7f 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/doc_blue_s.png and b/TMessagesProj/src/main/res/drawable-mdpi/doc_blue_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-mdpi/doc_green.png old mode 100644 new mode 100755 index 3636a40ca..d9bbb09b2 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/doc_green.png and b/TMessagesProj/src/main/res/drawable-mdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/download_b.png b/TMessagesProj/src/main/res/drawable-mdpi/download_b.png deleted file mode 100755 index 7c3fb80ce..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/download_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/download_b_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/download_b_pressed.png deleted file mode 100755 index 7e5385dd7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/download_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/download_b_s.png b/TMessagesProj/src/main/res/drawable-mdpi/download_b_s.png deleted file mode 100755 index 09ba0e35d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/download_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/download_g.png b/TMessagesProj/src/main/res/drawable-mdpi/download_g.png deleted file mode 100755 index 2b6c9b925..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/download_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/download_g_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/download_g_pressed.png deleted file mode 100755 index a1270b164..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/download_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/download_g_s.png b/TMessagesProj/src/main/res/drawable-mdpi/download_g_s.png deleted file mode 100755 index 7600aa259..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/download_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_b.png b/TMessagesProj/src/main/res/drawable-mdpi/file_b.png new file mode 100755 index 000000000..463d64525 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_b_cancel.png b/TMessagesProj/src/main/res/drawable-mdpi/file_b_cancel.png new file mode 100755 index 000000000..d2e695375 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_b_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_b_cancel_s.png b/TMessagesProj/src/main/res/drawable-mdpi/file_b_cancel_s.png new file mode 100755 index 000000000..0535435fb Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_b_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_b_load.png b/TMessagesProj/src/main/res/drawable-mdpi/file_b_load.png new file mode 100755 index 000000000..4038ef607 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_b_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_b_load_s.png b/TMessagesProj/src/main/res/drawable-mdpi/file_b_load_s.png new file mode 100755 index 000000000..68251f82f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_b_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_b_s.png b/TMessagesProj/src/main/res/drawable-mdpi/file_b_s.png new file mode 100755 index 000000000..970f88a98 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_g.png b/TMessagesProj/src/main/res/drawable-mdpi/file_g.png new file mode 100755 index 000000000..7e3ba2594 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_g_cancel.png b/TMessagesProj/src/main/res/drawable-mdpi/file_g_cancel.png new file mode 100755 index 000000000..8697a7efd Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_g_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_g_cancel_s.png b/TMessagesProj/src/main/res/drawable-mdpi/file_g_cancel_s.png new file mode 100755 index 000000000..16c52423f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_g_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_g_load.png b/TMessagesProj/src/main/res/drawable-mdpi/file_g_load.png new file mode 100755 index 000000000..9a760469d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_g_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_g_load_s.png b/TMessagesProj/src/main/res/drawable-mdpi/file_g_load_s.png new file mode 100755 index 000000000..dd8042267 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_g_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/file_g_s.png b/TMessagesProj/src/main/res/drawable-mdpi/file_g_s.png new file mode 100755 index 000000000..e72c909d9 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/file_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating.png b/TMessagesProj/src/main/res/drawable-mdpi/floating.png index 4f11fc264..465b28eb7 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/floating.png and b/TMessagesProj/src/main/res/drawable-mdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating_m.png b/TMessagesProj/src/main/res/drawable-mdpi/floating_m.png index 6d1b38184..650c4626e 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/floating_m.png and b/TMessagesProj/src/main/res/drawable-mdpi/floating_m.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/floating_pressed.png index 0ff85c17d..d013320f1 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/floating_pressed.png and b/TMessagesProj/src/main/res/drawable-mdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/forward_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/forward_blue.png old mode 100644 new mode 100755 index 7f4ec885e..992a34f5b Binary files a/TMessagesProj/src/main/res/drawable-mdpi/forward_blue.png and b/TMessagesProj/src/main/res/drawable-mdpi/forward_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_new.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_new.png index 1f55ff56f..5d8ee2cc9 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_new.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_new.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_msg_panel_kb.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_msg_panel_kb.png old mode 100644 new mode 100755 index 44b4285c5..57919b9ac Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_msg_panel_kb.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_msg_panel_kb.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_send.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_send.png index 64dd4c8e3..312ce750d 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_send.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_send.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/igvideo.png b/TMessagesProj/src/main/res/drawable-mdpi/igvideo.png deleted file mode 100644 index e7b93b3b7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/igvideo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/link.png b/TMessagesProj/src/main/res/drawable-mdpi/link.png old mode 100644 new mode 100755 index 24125b57e..96b098fff Binary files a/TMessagesProj/src/main/res/drawable-mdpi/link.png and b/TMessagesProj/src/main/res/drawable-mdpi/link.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/load_big.png b/TMessagesProj/src/main/res/drawable-mdpi/load_big.png index ea86a8760..6cc2fabe4 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/load_big.png and b/TMessagesProj/src/main/res/drawable-mdpi/load_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/location2.png b/TMessagesProj/src/main/res/drawable-mdpi/location2.png new file mode 100644 index 000000000..3f0abf8b4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/location2.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/location_b.9.png b/TMessagesProj/src/main/res/drawable-mdpi/location_b.9.png index 3f0abf8b4..c3f9b2417 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/location_b.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/location_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/location_g.9.png b/TMessagesProj/src/main/res/drawable-mdpi/location_g.9.png index d77aa911d..b84039f32 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/location_g.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/location_g.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_pause.png b/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_pause.png index 9f4edcc7d..295f9addc 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_pause.png and b/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_pause.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_play.png b/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_play.png index 088f15e25..10b948e60 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_play.png and b/TMessagesProj/src/main/res/drawable-mdpi/miniplayer_play.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_in.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_in.9.png index f9a0267b6..979a146be 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_in.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_in.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo.9.png index c5c6aa595..5ac724e54 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo_selected.9.png index 0658e94ae..324c65671 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_in_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_in_selected.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_in_selected.9.png index cd1118061..7425774ea 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_in_selected.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_in_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_out.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_out.9.png index f22c541f7..4e1c17bae 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_out.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_out.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo.9.png index ad4ad9ce2..1a759a33e 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo_selected.9.png index 734f94360..030a8a0a1 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_out_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/msg_out_selected.9.png b/TMessagesProj/src/main/res/drawable-mdpi/msg_out_selected.9.png index 7e29c8128..388972c22 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/msg_out_selected.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/msg_out_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/newmsg_divider.png b/TMessagesProj/src/main/res/drawable-mdpi/newmsg_divider.png index 81afcd30e..61510e887 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/newmsg_divider.png and b/TMessagesProj/src/main/res/drawable-mdpi/newmsg_divider.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_b.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_b.png index 4d74e901d..8608ecd68 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_b.png and b/TMessagesProj/src/main/res/drawable-mdpi/pause_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_b_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_b_pressed.png deleted file mode 100755 index e300fbbca..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_b_s.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_b_s.png index e29d3cf41..80fafabb3 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_b_s.png and b/TMessagesProj/src/main/res/drawable-mdpi/pause_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_g.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_g.png index a95855259..081279359 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_g.png and b/TMessagesProj/src/main/res/drawable-mdpi/pause_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_g_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_g_pressed.png deleted file mode 100755 index 82e15e54d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_g_s.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_g_s.png index 020a2499c..b711a3138 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_g_s.png and b/TMessagesProj/src/main/res/drawable-mdpi/pause_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_w.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_w.png deleted file mode 100755 index a6416a69e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_w2.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_w2.png deleted file mode 100755 index a5d419e71..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_w2_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_w2_pressed.png deleted file mode 100755 index 03dad7468..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/pause_w_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/pause_w_pressed.png deleted file mode 100755 index b12e36df9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/pause_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photocancel.png b/TMessagesProj/src/main/res/drawable-mdpi/photocancel.png old mode 100644 new mode 100755 index e3e7a3595..6014372e5 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/photocancel.png and b/TMessagesProj/src/main/res/drawable-mdpi/photocancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photocancel_b.png b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_b.png new file mode 100755 index 000000000..be189093f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photocancel_b_s.png b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_b_s.png new file mode 100755 index 000000000..2d4328698 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photocancel_g.png b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_g.png new file mode 100755 index 000000000..9493aa821 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photocancel_g_s.png b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_g_s.png new file mode 100755 index 000000000..7d4af0439 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photocancel_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_pressed.png new file mode 100755 index 000000000..491b3d434 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photocancel_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photogif.png b/TMessagesProj/src/main/res/drawable-mdpi/photogif.png old mode 100644 new mode 100755 index 1241d8f5a..2ee7a49d2 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/photogif.png and b/TMessagesProj/src/main/res/drawable-mdpi/photogif.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photogif_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/photogif_pressed.png new file mode 100755 index 000000000..64af18ac8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photogif_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photoload.png b/TMessagesProj/src/main/res/drawable-mdpi/photoload.png old mode 100644 new mode 100755 index 18b75497e..1f320b2d8 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/photoload.png and b/TMessagesProj/src/main/res/drawable-mdpi/photoload.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photoload_b.png b/TMessagesProj/src/main/res/drawable-mdpi/photoload_b.png new file mode 100755 index 000000000..fb97fc7c9 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photoload_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photoload_b_s.png b/TMessagesProj/src/main/res/drawable-mdpi/photoload_b_s.png new file mode 100755 index 000000000..be2dfb74f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photoload_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photoload_g.png b/TMessagesProj/src/main/res/drawable-mdpi/photoload_g.png new file mode 100755 index 000000000..7321550e4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photoload_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photoload_g_s.png b/TMessagesProj/src/main/res/drawable-mdpi/photoload_g_s.png new file mode 100755 index 000000000..2411e380e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photoload_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photoload_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/photoload_pressed.png new file mode 100755 index 000000000..87810072f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photoload_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photopause.png b/TMessagesProj/src/main/res/drawable-mdpi/photopause.png deleted file mode 100644 index e3051be70..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/photopause.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/phototime2.9.png b/TMessagesProj/src/main/res/drawable-mdpi/phototime2.9.png new file mode 100755 index 000000000..584a253b0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/phototime2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/phototime2_b.9.png b/TMessagesProj/src/main/res/drawable-mdpi/phototime2_b.9.png new file mode 100755 index 000000000..59f83e02f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/phototime2_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_b.png b/TMessagesProj/src/main/res/drawable-mdpi/play_b.png new file mode 100755 index 000000000..247246ed3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/play_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_b_s.png b/TMessagesProj/src/main/res/drawable-mdpi/play_b_s.png new file mode 100755 index 000000000..c3e88682f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/play_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_big.png b/TMessagesProj/src/main/res/drawable-mdpi/play_big.png index 1424f1301..341bcac7f 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play_big.png and b/TMessagesProj/src/main/res/drawable-mdpi/play_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_g.png b/TMessagesProj/src/main/res/drawable-mdpi/play_g.png new file mode 100755 index 000000000..10f5caf0d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/play_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_g_s.png b/TMessagesProj/src/main/res/drawable-mdpi/play_g_s.png new file mode 100755 index 000000000..761fa5188 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/play_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_w.png b/TMessagesProj/src/main/res/drawable-mdpi/play_w.png deleted file mode 100755 index ca0df62f6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_w2.png b/TMessagesProj/src/main/res/drawable-mdpi/play_w2.png deleted file mode 100755 index 5fba3f1b9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_w2_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/play_w2_pressed.png deleted file mode 100755 index 7b9fc05b3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/play_w_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/play_w_pressed.png deleted file mode 100755 index b8b601b8a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/play_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/playvideo.png b/TMessagesProj/src/main/res/drawable-mdpi/playvideo.png old mode 100644 new mode 100755 index e77608feb..f3a3a6c7e Binary files a/TMessagesProj/src/main/res/drawable-mdpi/playvideo.png and b/TMessagesProj/src/main/res/drawable-mdpi/playvideo.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/playvideo_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/playvideo_pressed.png new file mode 100755 index 000000000..5a361fe42 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/playvideo_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/reply.png b/TMessagesProj/src/main/res/drawable-mdpi/reply.png index 7d71990f7..8e718b4f3 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/reply.png and b/TMessagesProj/src/main/res/drawable-mdpi/reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/share_arrow.png b/TMessagesProj/src/main/res/drawable-mdpi/share_arrow.png new file mode 100755 index 000000000..b42481c86 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/share_arrow.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/share_round.png b/TMessagesProj/src/main/res/drawable-mdpi/share_round.png new file mode 100755 index 000000000..abdb1a8b2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/share_round.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/shareblack.png b/TMessagesProj/src/main/res/drawable-mdpi/shareblack.png deleted file mode 100644 index 815e157dc..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/shareblack.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/shareblack_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/shareblack_pressed.png deleted file mode 100644 index 4bb5e13ed..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/shareblack_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/shareblue.png b/TMessagesProj/src/main/res/drawable-mdpi/shareblue.png deleted file mode 100644 index 12a1c6ca5..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/shareblue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/shareblue_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/shareblue_pressed.png deleted file mode 100644 index 12a52ff43..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/shareblue_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/stickercounter.9.png b/TMessagesProj/src/main/res/drawable-mdpi/stickercounter.9.png new file mode 100755 index 000000000..217e9f16c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/stickercounter.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/system.9.png b/TMessagesProj/src/main/res/drawable-mdpi/system.9.png new file mode 100755 index 000000000..5ffd21af6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/system.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/system_black.9.png b/TMessagesProj/src/main/res/drawable-mdpi/system_black.9.png deleted file mode 100644 index fcb08a14c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/system_black.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/system_blue.9.png b/TMessagesProj/src/main/res/drawable-mdpi/system_blue.9.png deleted file mode 100755 index c1ce3b4f6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/system_blue.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/system_loader.png b/TMessagesProj/src/main/res/drawable-mdpi/system_loader.png new file mode 100755 index 000000000..79c6aab98 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/system_loader.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/system_loader1.png b/TMessagesProj/src/main/res/drawable-mdpi/system_loader1.png deleted file mode 100755 index 357688593..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/system_loader1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/system_loader2.png b/TMessagesProj/src/main/res/drawable-mdpi/system_loader2.png deleted file mode 100755 index 6c319058a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/system_loader2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/video_actions.png b/TMessagesProj/src/main/res/drawable-mdpi/video_actions.png new file mode 100755 index 000000000..84aee2f58 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/video_actions.png differ diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector.xml deleted file mode 100644 index 7c7941ef9..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_audio.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_audio.xml deleted file mode 100644 index fc4dddc7f..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_audio.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_blue.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_blue.xml deleted file mode 100644 index 34512df87..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_blue.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_cyan.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_cyan.xml deleted file mode 100644 index 64d8697d3..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_cyan.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_green.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_green.xml deleted file mode 100644 index 49c5a35ea..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_green.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_grey.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_grey.xml deleted file mode 100644 index fc4dddc7f..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_grey.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_mode.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_mode.xml deleted file mode 100644 index 386d01cee..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_mode.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_orange.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_orange.xml deleted file mode 100644 index 2d5c96c84..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_orange.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_picker.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_picker.xml deleted file mode 100644 index 8c28f1d3f..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_picker.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_pink.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_pink.xml deleted file mode 100644 index 72f764054..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_pink.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_red.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_red.xml deleted file mode 100644 index 4badd6870..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_red.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_violet.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_violet.xml deleted file mode 100644 index ee31ab7fe..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_violet.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector_yellow.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector_yellow.xml deleted file mode 100644 index f0ee5a20f..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector_yellow.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-v21/circle_selector.xml b/TMessagesProj/src/main/res/drawable-v21/circle_selector.xml deleted file mode 100644 index 25423fabb..000000000 --- a/TMessagesProj/src/main/res/drawable-v21/circle_selector.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_blue.png deleted file mode 100755 index 3ba0c9c35..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_green.png deleted file mode 100755 index 5beefa1c3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/addcontact_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/admin_star2.png b/TMessagesProj/src/main/res/drawable-xhdpi/admin_star2.png new file mode 100755 index 000000000..6afc194ec Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/admin_star2.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/attach_video.png b/TMessagesProj/src/main/res/drawable-xhdpi/attach_video.png index 5dfd67b6c..f3182c9da 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/attach_video.png and b/TMessagesProj/src/main/res/drawable-xhdpi/attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/attach_video_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/attach_video_pressed.png index d251fd69c..c932ef092 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/attach_video_pressed.png and b/TMessagesProj/src/main/res/drawable-xhdpi/attach_video_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bot_file.png b/TMessagesProj/src/main/res/drawable-xhdpi/bot_file.png new file mode 100755 index 000000000..2191a418d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/bot_file.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bot_lines.png b/TMessagesProj/src/main/res/drawable-xhdpi/bot_lines.png new file mode 100755 index 000000000..11980a894 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/bot_lines.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bot_link.png b/TMessagesProj/src/main/res/drawable-xhdpi/bot_link.png new file mode 100755 index 000000000..024405b37 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/bot_link.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bot_list.png b/TMessagesProj/src/main/res/drawable-xhdpi/bot_list.png index 286e9644b..f8ed9caa5 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/bot_list.png and b/TMessagesProj/src/main/res/drawable-xhdpi/bot_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bot_location.png b/TMessagesProj/src/main/res/drawable-xhdpi/bot_location.png new file mode 100755 index 000000000..f66cdbd7b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/bot_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bot_music.png b/TMessagesProj/src/main/res/drawable-xhdpi/bot_music.png new file mode 100755 index 000000000..e1aebb69f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/bot_music.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/bottom_shadow.png b/TMessagesProj/src/main/res/drawable-xhdpi/bottom_shadow.png index eeb3c8374..9e1a2a274 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/bottom_shadow.png and b/TMessagesProj/src/main/res/drawable-xhdpi/bottom_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b.png deleted file mode 100755 index 36c6390ed..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b_pressed.png deleted file mode 100755 index 79f951727..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b_s.png deleted file mode 100755 index c8a147d5a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_big.png b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_big.png index 90be05edf..843ef5eb6 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_big.png and b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g.png deleted file mode 100755 index a77e504f2..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g_pressed.png deleted file mode 100755 index dea2364da..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g_s.png deleted file mode 100755 index 8817baf23..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/cancel_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/circle_big.png b/TMessagesProj/src/main/res/drawable-xhdpi/circle_big.png index 7a1e10611..a661d8bae 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/circle_big.png and b/TMessagesProj/src/main/res/drawable-xhdpi/circle_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/contact_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/contact_blue.png new file mode 100755 index 000000000..0691158e3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/contact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/contact_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/contact_green.png new file mode 100755 index 000000000..d50586ac1 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/contact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_bl.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_bl.png new file mode 100755 index 000000000..0620792f8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_br.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_br.png new file mode 100755 index 000000000..40e0bba75 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_tl.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_tl.png new file mode 100755 index 000000000..7c75fa2ce Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_tr.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_tr.png new file mode 100755 index 000000000..919358f8c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_in_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_bl.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_bl.png new file mode 100755 index 000000000..b286218be Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_br.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_br.png new file mode 100755 index 000000000..3e859e80c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_tl.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_tl.png new file mode 100755 index 000000000..84433cf5d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_tr.png b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_tr.png new file mode 100755 index 000000000..ba5b3c2dd Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/corner_out_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/delete_reply.png b/TMessagesProj/src/main/res/drawable-xhdpi/delete_reply.png index ce9fd147b..b1378a6bb 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/delete_reply.png and b/TMessagesProj/src/main/res/drawable-xhdpi/delete_reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png old mode 100644 new mode 100755 index 9632851cc..8dcdfe626 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge2.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge2.9.png index ad1d30b65..6ddebe881 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge2.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue.png old mode 100644 new mode 100755 index 835fec45e..6931af1d4 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue.png and b/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue_s.png index aa12f8834..ae8dcf517 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue_s.png and b/TMessagesProj/src/main/res/drawable-xhdpi/doc_blue_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/doc_green.png old mode 100644 new mode 100755 index 7c4fba30a..05380876a Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/doc_green.png and b/TMessagesProj/src/main/res/drawable-xhdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/download_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/download_b.png deleted file mode 100755 index 5d114b083..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/download_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/download_b_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/download_b_pressed.png deleted file mode 100755 index 671f591b2..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/download_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/download_b_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/download_b_s.png deleted file mode 100755 index 74646e396..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/download_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/download_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/download_g.png deleted file mode 100755 index 1eaf6cfcd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/download_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/download_g_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/download_g_pressed.png deleted file mode 100755 index 4d785fbbe..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/download_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/download_g_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/download_g_s.png deleted file mode 100755 index 6e244b046..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/download_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_b.png new file mode 100755 index 000000000..85c47ecf7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_b_cancel.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_cancel.png new file mode 100755 index 000000000..ed4c2381d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_b_cancel_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_cancel_s.png new file mode 100755 index 000000000..0efa019d1 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_b_load.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_load.png new file mode 100755 index 000000000..f9412a04f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_b_load_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_load_s.png new file mode 100755 index 000000000..50cc62b0b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_b_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_s.png new file mode 100755 index 000000000..da8180c03 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_g.png new file mode 100755 index 000000000..7b1911ab2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_g_cancel.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_cancel.png new file mode 100755 index 000000000..376d89f64 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_g_cancel_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_cancel_s.png new file mode 100755 index 000000000..4a8e785ff Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_g_load.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_load.png new file mode 100755 index 000000000..8ef2faff7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_g_load_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_load_s.png new file mode 100755 index 000000000..6eb2518eb Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/file_g_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_s.png new file mode 100755 index 000000000..aaae696a7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/file_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating.png index 5523f817d..7333b5429 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/floating.png and b/TMessagesProj/src/main/res/drawable-xhdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating_m.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating_m.png index 0e5daf6ac..3e00bc956 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/floating_m.png and b/TMessagesProj/src/main/res/drawable-xhdpi/floating_m.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating_pressed.png index 7a28b2124..98ce443c3 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/floating_pressed.png and b/TMessagesProj/src/main/res/drawable-xhdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/forward_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/forward_blue.png old mode 100644 new mode 100755 index 40af0d3dc..78a131b43 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/forward_blue.png and b/TMessagesProj/src/main/res/drawable-xhdpi/forward_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_new.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_new.png index 700ba4271..71a5fc296 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_new.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_new.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_msg_panel_kb.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_msg_panel_kb.png old mode 100644 new mode 100755 index f811db00e..55722091a Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_msg_panel_kb.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_msg_panel_kb.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_send.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_send.png index 4c42bc008..5413204cf 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_send.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_send.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/igvideo.png b/TMessagesProj/src/main/res/drawable-xhdpi/igvideo.png deleted file mode 100644 index bad393640..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/igvideo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/link.png b/TMessagesProj/src/main/res/drawable-xhdpi/link.png old mode 100644 new mode 100755 index ba82f35b9..d526eee2c Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/link.png and b/TMessagesProj/src/main/res/drawable-xhdpi/link.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/load_big.png b/TMessagesProj/src/main/res/drawable-xhdpi/load_big.png index c405336a0..747d9aff9 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/load_big.png and b/TMessagesProj/src/main/res/drawable-xhdpi/load_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/location2.png b/TMessagesProj/src/main/res/drawable-xhdpi/location2.png new file mode 100644 index 000000000..ade7b9ef9 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/location2.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/location_b.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/location_b.9.png old mode 100644 new mode 100755 index ade7b9ef9..3a59e9579 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/location_b.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/location_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/location_g.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/location_g.9.png old mode 100644 new mode 100755 index bbaeb93c4..893499109 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/location_g.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/location_g.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_pause.png b/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_pause.png index 38746874f..556aec500 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_pause.png and b/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_pause.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_play.png b/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_play.png index e4e14c38a..fd6c00ec9 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_play.png and b/TMessagesProj/src/main/res/drawable-xhdpi/miniplayer_play.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in.9.png index f5db8372d..42b96820b 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo.9.png index 248b9ba2b..2e6c9da23 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo_selected.9.png index 91dabc475..a6a5f615a 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_selected.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_selected.9.png index e61ca03bf..3137acd52 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_selected.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_in_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out.9.png index d7c2816f1..306d56769 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo.9.png index c452372f3..1018fe16a 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo_selected.9.png index faa2daa55..c76a79c92 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_selected.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_selected.9.png index 65e00a868..7f7551686 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_selected.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/msg_out_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/newmsg_divider.png b/TMessagesProj/src/main/res/drawable-xhdpi/newmsg_divider.png index 555f2bf13..935c3fb0f 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/newmsg_divider.png and b/TMessagesProj/src/main/res/drawable-xhdpi/newmsg_divider.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_b.png index 851500ecd..ae9b03813 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_b.png and b/TMessagesProj/src/main/res/drawable-xhdpi/pause_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_b_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_b_pressed.png deleted file mode 100755 index ab048657c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_b_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_b_s.png index 6bbce886f..6c796c011 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_b_s.png and b/TMessagesProj/src/main/res/drawable-xhdpi/pause_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_g.png index 0708a5ede..ec2d1ed05 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_g.png and b/TMessagesProj/src/main/res/drawable-xhdpi/pause_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_g_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_g_pressed.png deleted file mode 100755 index c6d72f73e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_g_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_g_s.png index c2736a5d2..a7bb4434a 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_g_s.png and b/TMessagesProj/src/main/res/drawable-xhdpi/pause_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_w.png deleted file mode 100755 index 9228d6e52..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w2.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_w2.png deleted file mode 100755 index bcb65abfa..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w2_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_w2_pressed.png deleted file mode 100755 index 7b7e39079..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/pause_w_pressed.png deleted file mode 100755 index 214572b3e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/pause_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photocancel.png b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel.png old mode 100644 new mode 100755 index 4dc4b06be..fccbbd7f3 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/photocancel.png and b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_b.png new file mode 100755 index 000000000..7fef9dc1d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_b_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_b_s.png new file mode 100755 index 000000000..81fcc3a97 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_g.png new file mode 100755 index 000000000..e61452ac4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_g_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_g_s.png new file mode 100755 index 000000000..6600032fc Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_pressed.png new file mode 100755 index 000000000..99ff3c7ec Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photocancel_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photogif.png b/TMessagesProj/src/main/res/drawable-xhdpi/photogif.png old mode 100644 new mode 100755 index 067b09c22..cfa6ce735 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/photogif.png and b/TMessagesProj/src/main/res/drawable-xhdpi/photogif.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photogif_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/photogif_pressed.png new file mode 100755 index 000000000..4c9032569 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photogif_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photoload.png b/TMessagesProj/src/main/res/drawable-xhdpi/photoload.png old mode 100644 new mode 100755 index fb4eaec18..e214790e2 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/photoload.png and b/TMessagesProj/src/main/res/drawable-xhdpi/photoload.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photoload_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_b.png new file mode 100755 index 000000000..08d8ba1e1 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photoload_b_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_b_s.png new file mode 100755 index 000000000..9b860d1ee Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photoload_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_g.png new file mode 100755 index 000000000..9ffbdfdd4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photoload_g_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_g_s.png new file mode 100755 index 000000000..c22b11e89 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photoload_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_pressed.png new file mode 100755 index 000000000..3fc49d398 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photoload_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photopause.png b/TMessagesProj/src/main/res/drawable-xhdpi/photopause.png deleted file mode 100644 index 8c6463d64..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/photopause.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/phototime2.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/phototime2.9.png new file mode 100755 index 000000000..8ccee4710 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/phototime2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/phototime2_b.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/phototime2_b.9.png new file mode 100755 index 000000000..504d8397a Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/phototime2_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_b.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_b.png new file mode 100755 index 000000000..c2f1803c7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/play_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_b_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_b_s.png new file mode 100755 index 000000000..9ab9ba848 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/play_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_big.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_big.png index 77bccc78b..37409d865 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play_big.png and b/TMessagesProj/src/main/res/drawable-xhdpi/play_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_g.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_g.png new file mode 100755 index 000000000..6c442666b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/play_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_g_s.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_g_s.png new file mode 100755 index 000000000..95b40bc0e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/play_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_w.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_w.png deleted file mode 100755 index 77d1a292d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_w2.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_w2.png deleted file mode 100755 index 580da8336..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_w2_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_w2_pressed.png deleted file mode 100755 index 9bdc7f202..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/play_w_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/play_w_pressed.png deleted file mode 100755 index 11b12a54c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/play_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png b/TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png old mode 100644 new mode 100755 index d590b0f66..91825e84f Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png and b/TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/playvideo_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/playvideo_pressed.png new file mode 100755 index 000000000..1f3374c2e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/playvideo_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/reply.png b/TMessagesProj/src/main/res/drawable-xhdpi/reply.png index ee23fc6b6..c7226c4f5 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/reply.png and b/TMessagesProj/src/main/res/drawable-xhdpi/reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/share_arrow.png b/TMessagesProj/src/main/res/drawable-xhdpi/share_arrow.png new file mode 100755 index 000000000..f77b129c4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/share_arrow.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/share_round.png b/TMessagesProj/src/main/res/drawable-xhdpi/share_round.png new file mode 100755 index 000000000..78cf5a523 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/share_round.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/shareblack.png b/TMessagesProj/src/main/res/drawable-xhdpi/shareblack.png deleted file mode 100644 index 6f7d9fffb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/shareblack.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/shareblack_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/shareblack_pressed.png deleted file mode 100644 index 2d555afca..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/shareblack_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/shareblue.png b/TMessagesProj/src/main/res/drawable-xhdpi/shareblue.png deleted file mode 100644 index 5d249505c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/shareblue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/shareblue_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/shareblue_pressed.png deleted file mode 100644 index acdc51fbb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/shareblue_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/stickercounter.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/stickercounter.9.png new file mode 100755 index 000000000..7f1f17fbd Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/stickercounter.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/system.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/system.9.png new file mode 100755 index 000000000..2d50ef794 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/system.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/system_black.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/system_black.9.png deleted file mode 100644 index b9df0b89c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/system_black.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/system_blue.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/system_blue.9.png deleted file mode 100755 index 68c398416..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/system_blue.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/system_loader.png b/TMessagesProj/src/main/res/drawable-xhdpi/system_loader.png new file mode 100755 index 000000000..fe0a9e49d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/system_loader.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/system_loader1.png b/TMessagesProj/src/main/res/drawable-xhdpi/system_loader1.png deleted file mode 100755 index 37bef2be0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/system_loader1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/system_loader2.png b/TMessagesProj/src/main/res/drawable-xhdpi/system_loader2.png deleted file mode 100755 index 5bb6c3b1b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/system_loader2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/video_actions.png b/TMessagesProj/src/main/res/drawable-xhdpi/video_actions.png new file mode 100755 index 000000000..f692c3008 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/video_actions.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_blue.png deleted file mode 100755 index a592549b2..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_green.png deleted file mode 100755 index fd4bada3d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/addcontact_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/admin_star2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/admin_star2.png new file mode 100755 index 000000000..6dac9318e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/admin_star2.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video.png b/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video.png index fd4e0ce8e..0572bb47d 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video_pressed.png index 292a0c3d5..edee8cc91 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video_pressed.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/attach_video_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/bot_file.png b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_file.png new file mode 100755 index 000000000..3fdbe9907 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_file.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/bot_lines.png b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_lines.png new file mode 100755 index 000000000..e5d26151c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_lines.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/bot_link.png b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_link.png new file mode 100755 index 000000000..411dc89d8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_link.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/bot_list.png b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_list.png index a42a691ba..3391bb61a 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/bot_list.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_list.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/bot_location.png b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_location.png new file mode 100755 index 000000000..6c75f1deb Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_location.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/bot_music.png b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_music.png new file mode 100755 index 000000000..16bf5bc9e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/bot_music.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/bottom_shadow.png b/TMessagesProj/src/main/res/drawable-xxhdpi/bottom_shadow.png index cf81b6c14..36ba70346 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/bottom_shadow.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/bottom_shadow.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b.png deleted file mode 100755 index 2fa1d0c12..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b_pressed.png deleted file mode 100755 index 8f3b4c08d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b_s.png deleted file mode 100755 index 908de523f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_big.png b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_big.png index 87537b0ba..96a6c3d71 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_big.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g.png deleted file mode 100755 index 34c23a830..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g_pressed.png deleted file mode 100755 index a8585f32d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g_s.png deleted file mode 100755 index 8aefeae63..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/cancel_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/circle_big.png b/TMessagesProj/src/main/res/drawable-xxhdpi/circle_big.png index 40750ead3..8b0cd9fd1 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/circle_big.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/circle_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/contact_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/contact_blue.png new file mode 100755 index 000000000..aa2f30e37 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/contact_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/contact_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/contact_green.png new file mode 100755 index 000000000..1fb42bf40 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/contact_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_bl.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_bl.png new file mode 100755 index 000000000..feb15efe0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_br.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_br.png new file mode 100755 index 000000000..fa742b3b2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_tl.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_tl.png new file mode 100755 index 000000000..5db9f5ce6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_tr.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_tr.png new file mode 100755 index 000000000..a2c058a0b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_in_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_bl.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_bl.png new file mode 100755 index 000000000..64b85cc32 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_bl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_br.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_br.png new file mode 100755 index 000000000..50ae092c0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_br.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_tl.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_tl.png new file mode 100755 index 000000000..1e3f529ed Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_tl.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_tr.png b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_tr.png new file mode 100755 index 000000000..8b7f95fe8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/corner_out_tr.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/delete_reply.png b/TMessagesProj/src/main/res/drawable-xxhdpi/delete_reply.png index 3cfc6883e..f2f98a68e 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/delete_reply.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/delete_reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png old mode 100644 new mode 100755 index 5de08904f..1c07f6c9c Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge2.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge2.9.png index 05816fe12..7facfe30e 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge2.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue.png old mode 100644 new mode 100755 index f8a4f5b75..ac033bc15 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue_s.png index 38910b121..466b3cb3d 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue_s.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_blue_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_green.png old mode 100644 new mode 100755 index e8bb7431b..33f1a5315 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/doc_green.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/doc_green.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/download_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/download_b.png deleted file mode 100755 index 0199ccc17..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/download_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/download_b_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/download_b_pressed.png deleted file mode 100755 index ba3e4dab4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/download_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/download_b_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/download_b_s.png deleted file mode 100755 index 8e8a25943..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/download_b_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/download_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/download_g.png deleted file mode 100755 index edc1b88e9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/download_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/download_g_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/download_g_pressed.png deleted file mode 100755 index 4a258462a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/download_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/download_g_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/download_g_s.png deleted file mode 100755 index 900581fcb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/download_g_s.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b.png new file mode 100755 index 000000000..1c8598cd7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_cancel.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_cancel.png new file mode 100755 index 000000000..9d48270d9 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_cancel_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_cancel_s.png new file mode 100755 index 000000000..5e323f926 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_load.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_load.png new file mode 100755 index 000000000..dc4dae1fb Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_load_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_load_s.png new file mode 100755 index 000000000..044304d96 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_s.png new file mode 100755 index 000000000..925351b02 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g.png new file mode 100755 index 000000000..7dd85a3b5 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_cancel.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_cancel.png new file mode 100755 index 000000000..1ccbe9d93 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_cancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_cancel_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_cancel_s.png new file mode 100755 index 000000000..de91f9158 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_cancel_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_load.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_load.png new file mode 100755 index 000000000..bcddac3bc Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_load.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_load_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_load_s.png new file mode 100755 index 000000000..174947d79 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_load_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_s.png new file mode 100755 index 000000000..8395b5ac8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/file_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating.png index 65abfe39f..76ea18c93 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/floating.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating_m.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating_m.png index 6a353103a..598b8953a 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/floating_m.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating_m.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating_pressed.png index 26d91f198..0904520c9 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/floating_pressed.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/forward_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/forward_blue.png old mode 100644 new mode 100755 index 075a4f7f7..44c2b085a Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/forward_blue.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/forward_blue.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_new.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_new.png index 4a5f91710..57e0563e3 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_new.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_new.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_msg_panel_kb.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_msg_panel_kb.png old mode 100644 new mode 100755 index 98b58eef5..863d5e384 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_msg_panel_kb.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_msg_panel_kb.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_send.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_send.png index eec17c547..c64dbb21d 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_send.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_send.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/igvideo.png b/TMessagesProj/src/main/res/drawable-xxhdpi/igvideo.png deleted file mode 100644 index d13eab929..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/igvideo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/link.png b/TMessagesProj/src/main/res/drawable-xxhdpi/link.png old mode 100644 new mode 100755 index 655dc9e9a..c3edde91b Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/link.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/link.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/load_big.png b/TMessagesProj/src/main/res/drawable-xxhdpi/load_big.png index 3b1f44819..cbf60bc07 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/load_big.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/load_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/location2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/location2.png new file mode 100644 index 000000000..01ea9f4dd Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/location2.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/location_b.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/location_b.9.png old mode 100644 new mode 100755 index 01ea9f4dd..ab744516b Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/location_b.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/location_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/location_g.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/location_g.9.png old mode 100644 new mode 100755 index 7343d9636..09fc04cd9 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/location_g.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/location_g.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_pause.png b/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_pause.png index 1fb43f08b..b3e388b96 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_pause.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_pause.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_play.png b/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_play.png index ee163892d..e8a04810e 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_play.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/miniplayer_play.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in.9.png index 3db9979cf..54475d909 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo.9.png index 7ca493f77..f1d14e0b5 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo_selected.9.png index 350b66faf..2f3076fc2 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_selected.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_selected.9.png index 09abd80eb..0502f0dd7 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_selected.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_in_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out.9.png index b7aa02377..ee6f2df36 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo.9.png index 02e3ad804..6498fa28c 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo_selected.9.png index 67713607b..8c8d11d0d 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo_selected.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_photo_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_selected.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_selected.9.png index 6ce8fda0e..64cf8e69d 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_selected.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/msg_out_selected.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/newmsg_divider.png b/TMessagesProj/src/main/res/drawable-xxhdpi/newmsg_divider.png index 5b8d2eaf7..e9c1a24b7 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/newmsg_divider.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/newmsg_divider.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b.png index fa34156e3..091b06c67 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b_pressed.png deleted file mode 100755 index 14417454f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b_s.png index dadb88073..3b056929b 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b_s.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g.png index 58230127c..d2ed392ad 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g_pressed.png deleted file mode 100755 index 6afeea45e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g_s.png index ae9b96dea..ce7328a18 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g_s.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w.png deleted file mode 100755 index 31bdd7380..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w2.png deleted file mode 100755 index d4be9ec78..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w2_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w2_pressed.png deleted file mode 100755 index 94ce677c2..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w_pressed.png deleted file mode 100755 index 0f81862fe..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/pause_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel.png old mode 100644 new mode 100755 index 774066fe0..2a9105b14 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_b.png new file mode 100755 index 000000000..80d4d9032 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_b_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_b_s.png new file mode 100755 index 000000000..6d29a2681 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_g.png new file mode 100755 index 000000000..d42899e9c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_g_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_g_s.png new file mode 100755 index 000000000..bfa63bb48 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_pressed.png new file mode 100755 index 000000000..1477b2476 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photocancel_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photogif.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photogif.png old mode 100644 new mode 100755 index efc3a64d2..ad4cd9c65 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/photogif.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/photogif.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photogif_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photogif_pressed.png new file mode 100755 index 000000000..365f8f595 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photogif_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photoload.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload.png old mode 100644 new mode 100755 index b720d6d37..efae871de Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/photoload.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_b.png new file mode 100755 index 000000000..314b02410 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_b_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_b_s.png new file mode 100755 index 000000000..8b30d79ef Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_g.png new file mode 100755 index 000000000..5f85ecced Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_g_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_g_s.png new file mode 100755 index 000000000..fdd610942 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_pressed.png new file mode 100755 index 000000000..df021f024 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photoload_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photopause.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photopause.png deleted file mode 100644 index 62f9d3f8b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/photopause.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/phototime2.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/phototime2.9.png new file mode 100755 index 000000000..2f52ccc15 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/phototime2.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/phototime2_b.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/phototime2_b.9.png new file mode 100755 index 000000000..6ce439aa2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/phototime2_b.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_b.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_b.png new file mode 100755 index 000000000..99e2c15c3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/play_b.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_b_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_b_s.png new file mode 100755 index 000000000..c5c551054 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/play_b_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_big.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_big.png index 12ae35019..b04acefb6 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play_big.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/play_big.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_g.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_g.png new file mode 100755 index 000000000..d4461d657 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/play_g.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_g_s.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_g_s.png new file mode 100755 index 000000000..d471364b4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/play_g_s.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_w.png deleted file mode 100755 index be2cb867f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_w2.png deleted file mode 100755 index 263f27db6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w2_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_w2_pressed.png deleted file mode 100755 index 96e0e1276..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/play_w_pressed.png deleted file mode 100755 index 48aa6b658..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/play_w_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png b/TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png old mode 100644 new mode 100755 index c32d8f270..e056d93f8 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/playvideo.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/playvideo_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/playvideo_pressed.png new file mode 100755 index 000000000..6d98bdf7f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/playvideo_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/reply.png b/TMessagesProj/src/main/res/drawable-xxhdpi/reply.png index d08e72b82..d7b1f3354 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/reply.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/reply.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/share_arrow.png b/TMessagesProj/src/main/res/drawable-xxhdpi/share_arrow.png new file mode 100755 index 000000000..4360f9638 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/share_arrow.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/share_round.png b/TMessagesProj/src/main/res/drawable-xxhdpi/share_round.png new file mode 100755 index 000000000..64fe260ba Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/share_round.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblack.png b/TMessagesProj/src/main/res/drawable-xxhdpi/shareblack.png deleted file mode 100644 index 2331b1ff1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblack.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblack_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/shareblack_pressed.png deleted file mode 100644 index 960261dd7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblack_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/shareblue.png deleted file mode 100644 index 217a889ec..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblue_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/shareblue_pressed.png deleted file mode 100644 index 8bba0c980..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/shareblue_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/stickercounter.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/stickercounter.9.png new file mode 100755 index 000000000..a9ff07a7f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/stickercounter.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/system.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/system.9.png new file mode 100755 index 000000000..f4b4f35ec Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/system.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/system_black.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/system_black.9.png deleted file mode 100644 index 0aebf3cee..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/system_black.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/system_blue.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/system_blue.9.png deleted file mode 100755 index 1321d3c15..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/system_blue.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader.png b/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader.png new file mode 100755 index 000000000..d2c6ec3a3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader1.png b/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader1.png deleted file mode 100755 index 26c828f24..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader2.png deleted file mode 100755 index dcf5caf47..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/system_loader2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/video_actions.png b/TMessagesProj/src/main/res/drawable-xxhdpi/video_actions.png new file mode 100755 index 000000000..bfc2dbadd Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/video_actions.png differ diff --git a/TMessagesProj/src/main/res/drawable/bar_selector.xml b/TMessagesProj/src/main/res/drawable/bar_selector.xml deleted file mode 100644 index 961d245f2..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_audio.xml b/TMessagesProj/src/main/res/drawable/bar_selector_audio.xml deleted file mode 100644 index f311824b8..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_audio.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_blue.xml b/TMessagesProj/src/main/res/drawable/bar_selector_blue.xml deleted file mode 100644 index 83e879474..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_blue.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_cyan.xml b/TMessagesProj/src/main/res/drawable/bar_selector_cyan.xml deleted file mode 100644 index e9fb9cc20..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_cyan.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_green.xml b/TMessagesProj/src/main/res/drawable/bar_selector_green.xml deleted file mode 100644 index 2e88b9f42..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_green.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_grey.xml b/TMessagesProj/src/main/res/drawable/bar_selector_grey.xml deleted file mode 100644 index f311824b8..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_grey.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_mode.xml b/TMessagesProj/src/main/res/drawable/bar_selector_mode.xml deleted file mode 100644 index f3319e321..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_mode.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_orange.xml b/TMessagesProj/src/main/res/drawable/bar_selector_orange.xml deleted file mode 100644 index e1880b1e0..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_orange.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_picker.xml b/TMessagesProj/src/main/res/drawable/bar_selector_picker.xml deleted file mode 100644 index 658f21444..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_picker.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_pink.xml b/TMessagesProj/src/main/res/drawable/bar_selector_pink.xml deleted file mode 100644 index 9d81d09dc..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_pink.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_red.xml b/TMessagesProj/src/main/res/drawable/bar_selector_red.xml deleted file mode 100644 index c00e47a4e..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_red.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_violet.xml b/TMessagesProj/src/main/res/drawable/bar_selector_violet.xml deleted file mode 100644 index 405397c10..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_violet.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_yellow.xml b/TMessagesProj/src/main/res/drawable/bar_selector_yellow.xml deleted file mode 100644 index 98da9c127..000000000 --- a/TMessagesProj/src/main/res/drawable/bar_selector_yellow.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/field_carret.xml b/TMessagesProj/src/main/res/drawable/field_carret.xml new file mode 100644 index 000000000..a19003262 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/field_carret.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/TMessagesProj/src/main/res/drawable/search_carret.xml b/TMessagesProj/src/main/res/drawable/search_carret.xml index a07ec56d7..3c44cd870 100644 --- a/TMessagesProj/src/main/res/drawable/search_carret.xml +++ b/TMessagesProj/src/main/res/drawable/search_carret.xml @@ -2,7 +2,5 @@ - + diff --git a/TMessagesProj/src/main/res/values-ar/strings.xml b/TMessagesProj/src/main/res/values-ar/strings.xml index ecb46923a..25365e769 100644 --- a/TMessagesProj/src/main/res/values-ar/strings.xml +++ b/TMessagesProj/src/main/res/values-ar/strings.xml @@ -255,10 +255,12 @@ يكتب… يكتبون… %1$s يقوم بتسجيل رسالة صوتية... + %1$s يقوم بإرسال مقطع صوتي... %1$s يقوم بإرسال صورة... %1$s يقوم بإرسال مقطع مرئي... %1$s يقوم بإرسال ملف... جاري تسجيل الرسالة الصوتية... + جاري إرسال المقطع الصوتي... جاري إرسال الصورة... جاري إرسال المقطع المرئي... جاري إرسال الملف... @@ -504,6 +506,7 @@ نسخ الرابط حذف لا يوجد ملصقات بعد + أرسل ملصق المعذرة، لقد وصلت الحد الأعلى لحزم الملصقات. تم تعيين كافة الإشعارات افتراضيا @@ -539,6 +542,7 @@ سجل الخروج من كافة الأجهزة الأخرى الأحداث اشترك صديق في تيليجرام + رسائل مثبتة اللغة نرجو الأخذ بالعلم أن الدعم الفني في تيليجرام يقوم به مجموعة من المتطوعين. نحن نحاول الرد بسرعة قدر المستطاع، لكن ربما نستغرق القليل من الوقت.
]]> صفحة الأسئلة الأكثر شيوعًا]]>: يوجد بها حلول للمشاكل وإجابات لمعظم الأسئلة.
اسأل أحد المتطوعين @@ -550,8 +554,10 @@ ملف التعريب غير صحيح تمكين تعطيل - خدمة الإشعارات - إذا كانت خدمات Google play كافية بالنسبة لك لتلقي الإشعارات ، يمكنك تعطيل \" خدمة الإشعارات \" . ومع ذلك نحن نوصي بترك هذه الخدمة مفعلة للحفاظ على تشغيل التطبيق في الخلفية ، ولتلقي إشعارات الدردشة . + خدمة التشغيل المستمر + إعادة تشغيل التطبيق في حال تم إقفاله من المستخدم أو النظام. هذا سيساعد في إظهار التطبيق للإشعارات. + الاتصال في الخلفية + استخدام اتصال طفيف في الخلفية للتأكد من وصول إشعارات تيليجرام. قم بالتفعيل لإشعارات أقوى. فرز حسب استيراد جهات الاتصال الاسم الأول @@ -932,7 +938,15 @@ هل أنت متأكد من تسجيل الخروج من جميع الأجهزة الأخرى باستثناء هذا الجهاز؟ هل أنت متأكد من أنك تريد حذف المجموعة والخروج منها؟ هل أنت متأكد من رغبتك في حذف المحادثة؟ - هل أنت متأكد من أنك تريد مشاركة معلومات جهة الاتصال الخاصة بك؟ + هل ترغب في مشاركة موقعك؟ + هذا الخيار سيرسل موقعك الحالي للبوت. + لا يستطيع التطبيق تحديد موقعك الحالي + اختر بشكل يدوي + هذا البوت يرغب في معرفة موقعك في كل مرة ترسل له طلب. هذا يمكن الاستفادة منه لإعطائك نتائج مناسبة لموقعك. + هل ترغب في مشاركة رقم هاتفك؟ + البوت سيعلم رقم هاتفك. سيكون هذا مفيد لتفعيله في خدمات أخرى. + هل أنت متأكد من رغبتك في مشاركة رقم هاتفك %1$s مع ]]>%2$s]]>؟ + هل أنت متأكد من رغبتك في مشاركة رقم هاتفك؟ هل أنت متأكد من رغبتك في حظر جهة الاتصال هذه؟ هل أنت متأكد من رغبتك في إزالة الحظر عن جهة الاتصال هذه؟ هل أنت متأكد من رغبتك في حذف جهة الاتصال هذه؟ @@ -955,11 +969,13 @@ فصلًا قم بالسماح لتيليجرام باستقبال رسائل قصيرة ليتمكن من إدخال الرمز لك تلقائيًا. فصلًا قم بالسماح لتيليجرام باستقبال اتصالات ليتمكن من إدخال الرمز لك تلقائيًا. فصلًا قم بالسماح لتيليجرام باستقبال اتصالات ورسائل قصيرة ليتمكن من إدخال الرمز لك تلقائيًا. + المعذرة، لا يمكنك القيام بذلك. تيليجرام يحتاج للسماح له بالوصول لجهات الاتصال الخاصة بك لتتمكن من محادثة أصدقائك من كافة أجهزتك. تيليجرام يحتاج للسماح له بالوصول للذاكرة الخاصة بك لتتمكن من إرسال وحفظ الصور، المقاطع المرئية، الموسيقى وغيرها من الوسائط. تيليجرام يحتاج للسماح له بالوصول للمايكروفون الخاص بك لتتمكن من إرسال رسائل صوتية. تيليجرام يحتاج للسماح له بالوصول لمكانك لتتمكن من مشاركته مع أصدقائك من خلاله. + تيليجرام يحتاج صلاحية الحصول على موقعك. الإعدادات تيليجرام @@ -1182,4 +1198,4 @@ HH:mm h:mm a %1$s الساعة %2$s - \ No newline at end of file + diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index 080418ecc..453f2a486 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -86,7 +86,7 @@ Möchtest du wirklich diese Gruppe verlassen? Du kannst diesen Nutzer nicht hinzufügen. Leider ist diese Gruppe schon voll. - Dieser Nutzer hat die Gruppe zu verlassen, deshalb kannst du ihn nicht wieder einladen. + Dieser Nutzer hat die Gruppe verlassen, deshalb kannst du ihn nicht wieder einladen. Es gibt bereits zu viele Administratoren. Es gibt bereits zu viele Bots. un1 hat \"%1$s\" angeheftet @@ -184,7 +184,7 @@ Du wurdest gesperrt und kannst öffentliche Gruppen nicht betreten. Dieser Chat ist nicht mehr zugänglich. %1$s zum Kanal hinzufügen? - Dieser Nutzer hat die Gruppe zu verlassen, deshalb kannst du ihn nicht wieder einladen. + Dieser Nutzer hat die Gruppe verlassen, deshalb kannst du ihn nicht wieder einladen. Du kannst diesen Nutzer nicht einladen. Es gibt bereits zu viele Administratoren in diesem Kanal. Es gibt bereits zu viele Bots. @@ -255,10 +255,12 @@ tippt... tippen… %1$s nimmt etwas auf... + %1$s schickt Audio... %1$s schickt Bild... %1$s schickt Video... %1$s schickt Datei... nimmt etwas auf... + schickt Audio... schickt Bild... schickt Video... schickt Datei... @@ -472,7 +474,7 @@ Geheimer Schlüssel Selbstzerstörungs-Timer Aus - Bild und Text zeigen den aktuellen Schlüssen dieses geheimen Chats mit ]]>%1$s]]>.
]]>Sehen sie auf dem Gerät von ]]>%2$s]]> genau so aus, ist eure Sicherheit garantiert.
]]>Erfahre mehr unter telegram.org
+ Bild und Text zeigen den aktuellen Schlüssel dieses geheimen Chats mit ]]>%1$s]]>.
]]>Sehen sie auf dem Gerät von ]]>%2$s]]> genau so aus, ist eure Sicherheit garantiert.
]]>Erfahre mehr unter telegram.org
https://telegram.org/faq/de#geheime-chats Unbekannt Info @@ -504,6 +506,7 @@ Link kopieren Entfernen Noch keine Sticker + STICKER SENDEN Leider hast du die maximale Anzahl an Stickerpaketen erreicht. Alle Einstellungen für Mitteilungen zurücksetzen @@ -539,6 +542,7 @@ Alle anderen Geräte abmelden Ereignisse Kontakt ist Telegram beigetreten + Angeheftete Nachrichten Sprache Bedenke bitte, dass der Telegram Support von ehrenamtlichen Helfern betreut wird. Wir versuchen so schnell wie möglich zu antworten, dies kann jedoch manchmal ein bisschen dauern.
]]>Bitte schau auch in den Fragen und Antworten ]]> nach. Dort findest du Antworten auf die meisten Fragen und wichtige Tipps zur Problembehandlung]]>.
Eine Frage stellen @@ -550,8 +554,10 @@ Falsche Sprachdatei Aktiviert Deaktiviert - Mitteilungsdienst - Sofern Google Play Dienste ausreichend für deine Mitteilungen sind, kannst du unseren Mitteilungsdienst abschalten. Wir empfehlen allerdings, unseren Dienst dauerhaft aktiviert zu lassen, um über neue Nachrichten in Echtzeit informiert zu werden. + Keep-Alive-Dienst + Sofern die App beendet wurde, diese automatisch neu starten, um Benachrichtigungen zu gewährleisten. + Hintergrundverbindung + Nutzt eine batterieschonende Hintergrundverbindung zu Telegram, um Benachrichtigungen zu gewährleisten. sortiert nach Kontakte importieren Vorname @@ -932,7 +938,15 @@ Sicher, dass du alle anderen Geräte abmelden möchtest? Gruppe löschen und verlassen? Möchtest du wirklich diesen Chat löschen? - Wirklich die eigenen Kontaktinformationen teilen? + Deinen Standort teilen? + Teilt deinen aktuellen Standort mit dem Bot. + App kann deinen aktuellen Standort nicht bestimmen + Selbst wählen + Dieser Bot möchte bei jeder Anfrage deinen Standort wissen. Das kann für standortabhängig aufbereitete Informationen benutzt werden. + Deine Telefonnummer teilen? + Der Bot wird deine Nummer sehen. Das kann für verschiedene Dienste nützlich sein. + Möchtest du wirklich deine Nummer %1$s mit ]]>%2$s]]> teilen? + Möchtest du wirklich deine Telefonnummer teilen? Diesen Kontakt wirklich blockieren? Blockierung für diesen Kontakt wirklich aufheben? Diesen Kontakt wirklich löschen? @@ -955,11 +969,13 @@ Bitte erlaube Telegram den Zugriff auf SMS, so dass wir den Code automatisch in der App für dich eingeben können. Bitte erlaube Telegram den Zugriff auf Anrufe, so dass wir den Code automatisch in der App eingeben können. Bitte erlaube Telegram den Zugriff auf SMS und Anrufe, so dass wir den Code automatisch in der App eingeben können. + Du kannst diese Aktion nicht durchführen. Telegram benötigt Zugriff auf deine Kontakte um dich auf all denen Geräten mit deinen Freunden zu verbinden. Telegram benötigt Zugriff auf deinen Speicher, damit du Bilder, Videos und Musik senden und speichern kannst. Telegram benötigt Zugriff auf dein Mikrofon, damit du Sprachnachrichten senden kannst. Telegram benötigt Zugriff auf deinen Standort, damit du ihn mit Freunden teilen kannst. + Telegram benötigt Zugriff auf deinen Standort. EINSTELLUNGEN Telegram @@ -990,12 +1006,12 @@ %1$d Mitglieder %1$d Mitglieder %1$d Mitglieder - und %1$d weitere schreiben + und %1$d weitere tippen und %1$d weitere tippen - und %1$d weitere schreiben - und %1$d weitere schreiben - und %1$d weitere schreiben - und %1$d weitere schreiben + und %1$d weitere tippen + und %1$d weitere tippen + und %1$d weitere tippen + und %1$d weitere tippen keine neuen Nachrichten %1$d neue Nachricht %1$d neue Nachrichten diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index 9e80947ee..fc5140f97 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -255,10 +255,12 @@ está escribiendo... están escribiendo... %1$s está grabando un mensaje de voz... + %1$s está enviando un audio... %1$s está enviando una foto... %1$s está enviando un vídeo... %1$s está enviando un archivo... grabando mensaje de voz... + enviando audio... enviando foto... enviando vídeo... enviando archivo... @@ -504,6 +506,7 @@ Copiar enlace Eliminar Sin stickers aún + ENVIAR STICKER Lo sentimos, alcanzaste el número máximo de packs de stickers. Restablecer las notificaciones @@ -539,6 +542,7 @@ Cerrar todas las otras sesiones Eventos Un contacto se unió a Telegram + Mensajes anclados Idioma Por favor, considera que el soporte de Telegram está hecho por voluntarios. Respondemos lo antes posible, pero puede tomar tiempo.
]]>Por favor, mira las preguntas frecuentes de Telegram]]>: tienen respuestas para la mayoría de las preguntas y soluciones a problemas]]>.
Preguntar @@ -550,8 +554,10 @@ Archivo de traducción incorrecto Activadas Desactivadas - Servicio de notificaciones - Si tus notificaciones funcionan bien con los Servicios de Google Play, puedes desactivar el Servicio de notificaciones. Sin embargo, recomendamos que lo dejes activo para mantener la app en segundo plano y recibir notificaciones al instante. + Servicio keep-alive + Vuelve a abrir la app cuando el usuario o el sistema la cierra. Esto garantiza que la app pueda mostrar notificaciones. + Conexión en segundo plano + Conexión de bajo impacto, en segundo plano, para recibir notificaciones. Úsala para tener notificaciones fiables. Ordenar por Importar contactos Nombre @@ -932,7 +938,15 @@ ¿Quieres terminar todas las otras sesiones? ¿Quieres eliminar y dejar el grupo? ¿Quieres eliminar este chat? - ¿Quieres compartir tu número? + ¿Compartir tu ubicación? + Esto enviará tu ubicación actual al bot. + La aplicación no pudo determinar tu ubicación actual + Elegir manualmente + Este bot podría querer saber tu ubicación cada vez que le envías una solicitud. Esto puede ser usado para entregar resultados específicos para tu ubicación. + ¿Compartir tu número de teléfono? + El bot sabrá tu número de teléfono. Puede ser útil para la integración con otros servicios. + ¿Quieres compartir tu número de teléfono %1$s con ]]>%2$s]]>? + ¿Quieres compartir tu número de teléfono? ¿Quieres bloquear este contacto? ¿Quieres desbloquear este contacto? ¿Quieres eliminar este contacto? @@ -955,11 +969,13 @@ Por favor, permite a Telegram recibir SMS, para ingresar el código automáticamente. Por favor, permite a Telegram recibir llamadas, para ingresar el código automáticamente. Por favor, permite a Telegram recibir llamadas y SMS, para ingresar el código automáticamente. + Lo sentimos, no estás autorizado para hacer esto. Telegram necesita el acceso a tus contactos, para que puedas comunicarte con ellos en todos tus dispositivos. Telegram necesita acceso a tu almacenamiento, para que puedas enviar y guardar fotos, vídeos, música y otros archivos. Telegram necesita acceso a tu micrófono, para que puedas enviar mensajes de voz. Telegram necesita acceso a tu ubicación, para que puedas compartirla con tus amigos. + Telegram necesita acceso a tu ubicación. AJUSTES Telegram diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index 45334c650..3588972a6 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -39,14 +39,14 @@ ieri Nessun risultato Ancora nessuna chat… - Inizia a scrivere premendo il tasto\nnuovo messaggio nell\'angolo in basso a destra\no apri il menu per avere più opzioni. + Inizia a chattare premendo il tasto\nnuovo messaggio nell\'angolo in basso a destra\no apri il menu per avere più opzioni. Attendo la rete... Connetto… Aggiorno… Nuova chat segreta Aspettando che %s si colleghi… Chat segreta annullata - Scambio delle chiavi di cifratura... + Scambio delle chiavi di crittografia... %s si è unito alla tua chat segreta. Sei entrato nella chat segreta. Cancella cronologia @@ -255,15 +255,17 @@ sta scrivendo… stanno scrivendo… %1$s sta registrando un messaggio vocale... + %1$s sta inviando un audio... %1$s sta inviando una foto... %1$s sta inviando un video... %1$s sta inviando un file... registrando un messaggio vocale... + inviando un audio... inviando una foto... inviando un video... inviando un file... Hai una domanda\nsu Telegram? - Scatta una foto + Scatta foto Galleria Posizione Video @@ -469,7 +471,7 @@ Principale Inizia chat segreta Si è verificato un errore. - Chiave di cifratura + Chiave di crittografia Timer di autodistruzione Spento Questa immagine e il testo sono derivati dalla chiave di crittografia per questa chat segreta con ]]>%1$s]]>.
]]>Se sono uguali sul dispositivo di ]]>%2$s]]>, la crittografia end-to-end è garantita.
]]>Ulteriori informazioni su telegram.org
@@ -504,6 +506,7 @@ Copia link Rimuovi Ancora nessuno sticker + INVIA STICKER Spiacenti, hai raggiunto il numero massimo di set di sticker. Ripristina tutte le impostazioni di notifica predefinite @@ -539,8 +542,9 @@ Termina le altre sessioni Eventi Un contatto si è unito a Telegram + Messaggi fissati Lingua - Nota che il supporto di Telegram è fornito da volontari. Proviamo a rispondere quanto prima, ma potrebbe volerci del tempo.
]]>Dai un\'occhiata alle Domande frequenti]]>: troverai risposte alla maggior parte delle domande e suggerimenti importanti per l\'individuazione del problema]]>
+ Nota che il supporto di Telegram è fornito da volontari. Proviamo a rispondere quanto prima, ma potrebbe volerci del tempo.
]]>Dai un\'occhiata alle Domande frequenti]]>di Telegram: contengono risposte a quasi tutte le domande e suggerimenti importanti per risolvere i problemi]]>
Chiedi a un volontario Domande frequenti https://telegram.org/faq/it @@ -550,8 +554,10 @@ File di traduzione non valido Abilitate Disabilitata - Servizio notifiche - Se i Google Play Services ti bastano per ricevere le notifiche, puoi disabilitare il servizio notifiche. Ti consigliamo comunque di lasciarlo abilitato per lasciare l\'app attiva in background e ricevere notifiche istantanee. + Servizio keep-alive + Riavvia l\'app quando terminata dall\'utente o dal sistema. Questo assicura che l\'app possa mostrare le notifiche. + Connessione in background + Mantiene una connessione a basso impatto con Telegram per ricevere le notifiche. Attivala per notifiche affidabili. Ordina per Importa contatti Nome @@ -645,7 +651,7 @@ Ora visualizzerai un\'icona col lucchetto nella pagina delle chat. Premi su di essa per bloccare la tua app Telegram con il codice. PIN Password - Inserisci il tuo codice + Inserisci il tuo codice corrente Inserisci un codice Inserisci il nuovo codice Inserisci il tuo codice @@ -679,7 +685,7 @@ Ibrido m di distanza km di distanza - Invia la tua posizione attuale + Invia la tua posizione corrente Invia la posizione selezionata Posizione Precisione di %1$s @@ -911,7 +917,7 @@ Numero di telefono non valido Codice scaduto, effettua di nuovo l\'accesso Troppi tentativi, riprova più tardi - Troppi tentativi, per favore riprova di nuova tra %1$s + Troppi tentativi, per favore riprova di nuovo tra %1$s Codice non valido Nome non valido Cognome non valido @@ -932,7 +938,15 @@ Terminare tutte le altre sessioni? Sei sicuro di voler uscire ed eliminare il gruppo? Sei sicuro di voler eliminare questa chat? - Vuoi condividere il tuo contatto? + Condividere la tua posizione? + Questo invierà la tua posizione corrente al bot. + L\'app non è riuscita a determinare la tua posizione corrente + Scegli manualmente + Questo bot vorrebbe sapere la tua posizione ogni volta che invii una richiesta. Questo può essere usato per fornire risultati specifici per la posizione. + Condividere il tuo numero di telefono? + Il bot saprà il tuo numero di telefono. Questo può essere utile per l\'integrazione con altri servizi. + Sicuro di voler condividere il tuo numero di telefono %1$s con ]]>%2$s]]>? + Sei sicuro di voler condividere il tuo numero di telefono? Vuoi bloccare questo contatto? Vuoi sbloccare questo contatto? Sei sicuro di voler eliminare questo contatto? @@ -955,11 +969,13 @@ Per favore consenti a Telegram di ricevere SMS così potremo inserire in automatico il codice per te. Per favore consenti a Telegram di ricevere chiamate così potremo inserire in automatico il codice per te. Per favore consenti a Telegram di ricevere chiamate ed SMS così potremo inserire in automatico il codice per te. + Spiacenti, questa azione non ti è permessa. Telegram deve accedere ai tuoi contatti per poterti connettere con i tuoi amici su tutti i tuoi dispositivi. Telegram deve accedere alla tua memoria per poter inviare e salvare foto,video, musica e altri media. Telegram deve accedere al microfono per poter inviare messaggi vocali. Telegram deve accedere alla tua posizione per poterla condividere con i tuoi amici. + Telegram deve accedere alla tua posizione. IMPOSTAZIONI Telegram @@ -976,7 +992,7 @@ Telegram]]> non ha limiti di dimensione]]>per le tue chat e i file multimediali. Telegram]]> ti consente di accedere]]>ai tuoi messaggi da più dispositivi. I messaggi di Telegram]]> sono fortemente]]>criptati e possono autodistruggersi. - Inizia a inviare messaggi + Inizia a chattare %1$d in linea %1$d in linea @@ -990,12 +1006,12 @@ %1$d membri %1$d membri %1$d membri - e %1$d altre persone stanno scrivendo - e %1$d altre persone stanno scrivendo - e %1$d altre persone stanno scrivendo - e %1$d altre persone stanno scrivendo - e %1$d altre persone stanno scrivendo - e %1$d altre persone stanno scrivendo + e altre %1$d persone stanno scrivendo + e %1$d altra persona stanno scrivendo + e altre %1$d persone stanno scrivendo + e altre %1$d persone stanno scrivendo + e altre %1$d persone stanno scrivendo + e altre %1$d persone stanno scrivendo nessun nuovo messaggio %1$d nuovo messaggio %1$d nuovi messaggi diff --git a/TMessagesProj/src/main/res/values-ko/strings.xml b/TMessagesProj/src/main/res/values-ko/strings.xml index 121577771..6ebbc45f8 100644 --- a/TMessagesProj/src/main/res/values-ko/strings.xml +++ b/TMessagesProj/src/main/res/values-ko/strings.xml @@ -255,10 +255,12 @@ 님이 입력 중... 님이 입력 중... %1$s님이 음성메시지를 녹음중입니다... + %1$s님이 음성파일을 전송중입니다... %1$s님이 사진 보내는 중... %1$s님이 동영상 보내는 중... %1$s님이 파일 보내는 중... 음성메시지를 녹음 중입니다.. + 음성파일 전송 중.. 사진 전송 중.. 동영상 전송 중.. 파일 전송 중... @@ -504,6 +506,7 @@ 링크 복사 삭제 스티커가 아직 없음 + 스티커 전송 죄송합니다, 스티커 세트수가 최대치입니다. 모든 알림 설정이 초기화되었습니다 @@ -539,6 +542,7 @@ 다른 모든 세션 종료 이벤트 친구의 텔레그램 가입 알림 + 고정된 메시지 언어 텔레그램에 관한 질문은 자원봉사자들이 답변해 드립니다. 신속한 답변을 위해 노력하지만 답변이 다소 늦을 수 있습니다.
]]>일반적인 문제와 해결방법]]>에 대해서는 \'자주 묻는 질문]]>\'을 확인해 보세요.
질문하기 @@ -550,8 +554,10 @@ 언어 파일이 올바르지 않습니다. 켜기 끄기 - 알림 서비스 - 알림 서비스를 비활성화 하면 새로운 메시지의 알림이 다소 늦을 수 있습니다.텔레그램이 백그라운드에서 작동하며 알림을 바로 알릴 수 있도록 활성화 하는것을 권장합니다. + 항상 활성화 서비스 + 시스템이나 사용자에 의하여 닫힌 앱을 재시작합니다. 해당 작업은 알림을 보여지게 합니다. + 백그라운드 연결 + 알림을 받기 위하여 텔레그램 백그라운드 연결을 최소화로 유지합니다. 안정적인 알림을 유지합니다. 정렬 연락처 가져오기 이름 @@ -932,7 +938,15 @@ 현재 기기를 제외하고 다른 기기에 로그인된 세션을 모두 종료시킬까요? 그룹에서 나갈까요? 채팅방을 삭제할까요? - 연락처를 공유할까요? + 위치를 공유하겠습니까? + 현재 위치를 봇에게 전송합니다. + 앱에서 현재 위치를 확인하지 못하였습니다. + 수동 선택 + 요청시마다 봇이 위치를 확인합니다. 이 요청으로 인하여 특정 위치에 대한 결과 확인이 가능합니다. + 전화번호를 공유하겠습니까? + 봇이 전화번호를 인지를 하며, 다른 서비스와의 통합에 활용이 됩니다. + %1$s 님에게 ]]>%2$s]]> 번호를 공유하겠습니까? + 정말로 전화번호를 공유하겠습니까? 대화상대를 차단할까요? 차단을 해제할까요? 대화상대를 삭제할까요? @@ -955,11 +969,13 @@ 텔레그램이 SMS를 수신 할 수 있도록 설정해주셔야 자동으로 코드 입력이 가능합니다. 텔레그램이 전화를 수신 할 수 있도록 설정해주셔야 자동으로 코드 입력이 가능합니다. 텔레그램이 SMS 및 전화를 수신 할 수 있도록 설정해주셔야 자동으로 코드 입력이 가능합니다. + 죄송합니다, 이 작업이 제한되었습니다. Telegram은 여러 기기에서 친구와 메시지를 주고받을 수 있도록 회원님의 연락처 접근이 필요합니다. Telegram은 사진, 비디오, 음악 및 다양한 미디어를 공유 및 저장하기 위하여 스토리지 접근이 필요합니다. Telegram이 음성 메시지를 보내기 위하여 마이크에 대한 접근이 필요합니다. Telegram이 위치를 친구분들과 공유하기 위해 위치에 대한 접근 권한을 필요로 합니다. + 텔레그램이 위치에 대한 권한이 필요합니다. 설정 텔레그램 diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index 39682c9b0..bc38eea8a 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -255,10 +255,12 @@ is aan het typen zijn aan het typen %1$s neemt een spraakbericht op... + %1$s verstuurt een geluid... %1$s verstuurt een foto %1$s verstuurt een video %1$s verstuurt een bestand neemt een spraakbericht op... + audio versturen... foto versturen video versturen bestand versturen @@ -504,6 +506,7 @@ Link kopiëren Verwijder Nog geen stickers + STICKER STUREN Je hebt het maximale aantal stickerbundels bereikt. Meldingen gereset @@ -539,6 +542,7 @@ Beëindig alle andere sessies Gebeurtenissen Contact lid van Telegram + Vastgezet berichten Taal De ondersteuning van Telegram wordt gedaan door vrijwilligers. We doen ons best om zo snel mogelijk te antwoorden.
]]>Bekijk ook de veelgestelde vragen]]>: Hier staan de antwoorden op de meeste vragen en belangrijke tips voor het oplossen van problemen]]>.
Vraag een vrijwilliger @@ -551,7 +555,9 @@ Inschakelen Uitgeschakeld Meldingenservice - Als Google Play Services genoeg voor je is om meldingen te ontvangen kun je de meldingenservice uitschakelen. We raden echter aan dit ingeschakeld te laten om de app in de achtergrond te laten draaien en directe meldingen te ontvangen. + App automatisch herstarten bij afsluiten om meldingen weer te kunnen blijven geven. + Achtergrondverbinding + Achtergrondverbinding voor meldingen. Inschakelen voor betrouwbare meldingen. Sorteren op Importeer contacten Voornaam @@ -932,7 +938,15 @@ Alle apparaten behalve het huidige apparaat uitloggen? Verwijderen en de groep verlaten? Chat echt verwijderen? - Weet je zeker dat je je contactinformatie wilt delen? + Locatie delen? + Huidige locatie naar deze bot sturen? + Huidige locatie kon niet worden vastgesteld + Handmatig kiezen + Deze bot wil toegang tot je locatie voor ieder verzoek dat je stuurt. Dit kan gebruikt worden voor locatiespecifieke resultaten. + Telefoonnummer delen? + De bot krijgt je telefoonnummer, dit kan handig zijn voor de integratie met andere diensten. + Telefoonnummer %1$s delen met ]]>%2$s]]>? + Telefoonnummer echt delen? Weet je zeker dat je deze persoon wilt blokkeren? Weet je zeker dat je deze persoon wilt deblokkeren? Contact echt verwijderen? @@ -955,11 +969,13 @@ Sta het ontvangen van SMS toe zodat we automatisch je inlogcode kunnen invoeren. Sta het ontvangen van oproepen toe zodat we automatisch je inlogcode kunnen invoeren. Sta het ontvangen van oproepen en SMS toe zodat we automatisch je inlogcode kunnen invoeren. + Je mag deze actie niet uitvoeren. Telegram heeft toegang tot je contacten nodig zodat je kan chatten met je vrienden vanaf al je apparaten. Telegram heeft toegang tot je opslaggeheugen nodig zodat je foto\'s, video\'s, muziek en andere media kunt opslaan en versturen. Telegram heeft toegang tot je microfoon nodig om spraakberichten te kunnen verzenden. Telegram heeft toegang tot je locatie nodig om deze te kunnen delen met je vrienden. + Telegram heeft toegang tot je locatie nodig. INSTELLINGEN Telegram diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 7a98dad6f..a69732ef5 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -90,16 +90,16 @@ Desculpe, há administradores demais neste grupo. Desculpe, há bots demais neste grupo. un1 fixou \"%1$s\" - un1 ficou uma mensagem - un1 ficou uma foto - un1 ficou um vídeo - un1 ficou um arquivo - un1 ficou um sticker + un1 fixou uma mensagem + un1 fixou uma foto + un1 fixou um vídeo + un1 fixou um arquivo + un1 fixou um sticker un1 fixou uma mensagem de voz - un1 ficou um contato - un1 ficou um mapa - un1 ficou um GIF - un1 ficou uma música + un1 fixou um contato + un1 fixou um mapa + un1 fixou um GIF + un1 fixou uma música Este grupo foi atualizado para um supergrupo %1$s foi atualizado para um supergrupo Usuários bloqueados são removidos do grupo e só podem voltar se convidados por um administrador. Convites por link não funcionam para eles. @@ -133,7 +133,7 @@ ENTRAR Info do Canal Transmissão - Transmissão Silenciosa + Mensagem Silenciosa Comentário mostrar comentários O que é um Canal? @@ -255,10 +255,12 @@ está escrevendo... estão escrevendo... %1$s está gravando uma mensagem de voz... + %1$s está enviando um áudio... %1$s está enviando uma foto... %1$s está enviando um vídeo... %1$s está enviando um arquivo... gravando mensagem de voz... + enviando áudio... enviando foto... enviando vídeo... enviando arquivo... @@ -504,6 +506,7 @@ Copiar link Remover Nenhum sticker + ENVIAR STICKER Desculpe, você alcançou o limite máximo de pacotes de sticker. Restaurar todas as configurações de notificação @@ -539,6 +542,7 @@ Terminar todas as outras sessões Eventos Contato entrou para o Telegram + Mensagens Fixadas Idioma Por favor entenda que o suporte do Telegram é feito por voluntários. Tentaremos responder o mais rápido possível, mas poderemos demorar um pouco.
]]>Por favor verifique a página de perguntas frequentes do Telegram]]>: há dicas e respostas para a maioria dos problemas]]>.
Pergunte a um voluntário @@ -550,8 +554,10 @@ Arquivo de localização incorreto Ativado Desativado - Serviço de Notificações - Se o serviço de notificação do Google Play for suficiente para você, você pode desativar o \"Serviço de Notificações\". Porém, recomendamos deixá-lo ativo para manter o aplicativo executando em segundo plano e receber notificações instantaneamente. + Serviço Manter-Ativo + Reiniciar o app quando desligado pelo usuário ou pelo sistema. Isso irá garantir que o app mostre as notificações. + Conexão em Segundo Plano + Manter uma conexão de baixo impacto para o Telegram receber notificações. Habilite para notificações mais confiáveis. Ordenar Por Importar Contatos Primeiro nome @@ -932,7 +938,15 @@ Você tem certeza que deseja terminar todas as outras sessões? Você tem certeza que apagar e sair do grupo? Você tem certeza que deseja apagar esta conversa? - Você tem certeza que deseja compartilhar suas informações de contato? + Compartilhar sua localização? + Isso irá enviar sua localização atual ao bot. + O aplicativo foi impossibilitado de determinar sua localização atual. + Escolher manualmente + Esse bot gostaria de saber sua localização todas as vezes que você enviá-lo uma mensagem. Isso pode ser utilizado para providenciar resultados específicos de localização. + Compartilhar seu número de telefone? + O bot saberá seu número de telefone. Isso pode ser útil para a integração com outros serviços. + Tem certeza que deseja compartilhar seu número de telefone %1$s com ]]>%2$s]]>? + Tem certeza que deseja compartilhar seu número de telefone? Você tem certeza que deseja bloquear este contato? Você tem certeza que deseja desbloquear este contato? Você tem certeza que deseja apagar este contato? @@ -955,11 +969,13 @@ Permita o acesso às SMS ao Telegram, assim podemos automaticamente adicionar o código para você. Permita o acesso às ligações ao Telegram, assim podemos automaticamente adicionar o código para você. Permita o acesso às SMS e ligações ao Telegram, assim podemos automaticamente adicionar o código para você. + Você não tem permissão para isso. Telegram precisa acessar seus contatos para que você possa se conectar aos seus amigos em todos os seus dispositivos. Telegram precisa acessar seu armazenamento para que você possa enviar e salvar fotos, vídeos, músicas e outras mídias. Telegram precisa acessar seu microfone para que você possa enviar mensagens de voz. Telegram precisa acessar sua localização para que você possa compartilhar com seus amigos. + O Telegram precisa acessar sua localização CONFIGURAÇÕES Telegram diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index a0870484a..fa030cb07 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -90,16 +90,16 @@ Desculpe, há administradores demais neste grupo. Desculpe, há bots demais neste grupo. un1 fixou \"%1$s\" - un1 ficou uma mensagem - un1 ficou uma foto - un1 ficou um vídeo - un1 ficou um arquivo - un1 ficou um sticker + un1 fixou uma mensagem + un1 fixou uma foto + un1 fixou um vídeo + un1 fixou um arquivo + un1 fixou um sticker un1 fixou uma mensagem de voz - un1 ficou um contato - un1 ficou um mapa - un1 ficou um GIF - un1 ficou uma música + un1 fixou um contato + un1 fixou um mapa + un1 fixou um GIF + un1 fixou uma música Este grupo foi atualizado para um supergrupo %1$s foi atualizado para um supergrupo Usuários bloqueados são removidos do grupo e só podem voltar se convidados por um administrador. Convites por link não funcionam para eles. @@ -133,7 +133,7 @@ ENTRAR Info do Canal Transmissão - Transmissão Silenciosa + Mensagem Silenciosa Comentário mostrar comentários O que é um Canal? @@ -255,10 +255,12 @@ está escrevendo... estão escrevendo... %1$s está gravando uma mensagem de voz... + %1$s está enviando um áudio... %1$s está enviando uma foto... %1$s está enviando um vídeo... %1$s está enviando um arquivo... gravando mensagem de voz... + enviando áudio... enviando foto... enviando vídeo... enviando arquivo... @@ -504,6 +506,7 @@ Copiar link Remover Nenhum sticker + ENVIAR STICKER Desculpe, você alcançou o limite máximo de pacotes de sticker. Restaurar todas as configurações de notificação @@ -539,6 +542,7 @@ Terminar todas as outras sessões Eventos Contato entrou para o Telegram + Mensagens Fixadas Idioma Por favor entenda que o suporte do Telegram é feito por voluntários. Tentaremos responder o mais rápido possível, mas poderemos demorar um pouco.
]]>Por favor verifique a página de perguntas frequentes do Telegram]]>: há dicas e respostas para a maioria dos problemas]]>.
Pergunte a um voluntário @@ -550,8 +554,10 @@ Arquivo de localização incorreto Ativado Desativado - Serviço de Notificações - Se o serviço de notificação do Google Play for suficiente para você, você pode desativar o \"Serviço de Notificações\". Porém, recomendamos deixá-lo ativo para manter o aplicativo executando em segundo plano e receber notificações instantaneamente. + Serviço Manter-Ativo + Reiniciar o app quando desligado pelo usuário ou pelo sistema. Isso irá garantir que o app mostre as notificações. + Conexão em Segundo Plano + Manter uma conexão de baixo impacto para o Telegram receber notificações. Habilite para notificações mais confiáveis. Ordenar Por Importar Contatos Primeiro nome @@ -932,7 +938,15 @@ Você tem certeza que deseja terminar todas as outras sessões? Você tem certeza que apagar e sair do grupo? Você tem certeza que deseja apagar esta conversa? - Você tem certeza que deseja compartilhar suas informações de contato? + Compartilhar sua localização? + Isso irá enviar sua localização atual ao bot. + O aplicativo foi impossibilitado de determinar sua localização atual. + Escolher manualmente + Esse bot gostaria de saber sua localização todas as vezes que você enviá-lo uma mensagem. Isso pode ser utilizado para providenciar resultados específicos de localização. + Compartilhar seu número de telefone? + O bot saberá seu número de telefone. Isso pode ser útil para a integração com outros serviços. + Tem certeza que deseja compartilhar seu número de telefone %1$s com ]]>%2$s]]>? + Tem certeza que deseja compartilhar seu número de telefone? Você tem certeza que deseja bloquear este contato? Você tem certeza que deseja desbloquear este contato? Você tem certeza que deseja apagar este contato? @@ -955,11 +969,13 @@ Permita o acesso às SMS ao Telegram, assim podemos automaticamente adicionar o código para você. Permita o acesso às ligações ao Telegram, assim podemos automaticamente adicionar o código para você. Permita o acesso às SMS e ligações ao Telegram, assim podemos automaticamente adicionar o código para você. + Você não tem permissão para isso. Telegram precisa acessar seus contatos para que você possa se conectar aos seus amigos em todos os seus dispositivos. Telegram precisa acessar seu armazenamento para que você possa enviar e salvar fotos, vídeos, músicas e outras mídias. Telegram precisa acessar seu microfone para que você possa enviar mensagens de voz. Telegram precisa acessar sua localização para que você possa compartilhar com seus amigos. + O Telegram precisa acessar sua localização CONFIGURAÇÕES Telegram diff --git a/TMessagesProj/src/main/res/values-v21/styles.xml b/TMessagesProj/src/main/res/values-v21/styles.xml index 79d3b0f84..746ee6490 100644 --- a/TMessagesProj/src/main/res/values-v21/styles.xml +++ b/TMessagesProj/src/main/res/values-v21/styles.xml @@ -16,8 +16,8 @@ @android:color/white @android:color/white @null - #435e7e - #54759e + #426482 + #527da3 @@ -69,7 +69,7 @@ @@ -95,4 +95,18 @@ @null + + diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 8046380c1..bce1ee1f0 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -192,7 +192,6 @@ un1 added you to this channel You joined this channel You joined this group - "%@ joined the group" Remove from channel Sorry, you can\'t send messages to this channel. %1$s added you to the channel %2$s @@ -256,10 +255,12 @@ is typing... are typing... %1$s is recording voice message... + %1$s is sending audio... %1$s is sending photo... %1$s is sending video... %1$s is sending file... recording voice message... + sending audio... sending photo... sending video... sending file... @@ -300,7 +301,7 @@ Set self-destruct timer Service notifications Getting Link Info... - Open in Browser + OPEN IN... Copy URL Send %1$s Open url %1$s? @@ -505,6 +506,7 @@ Copy link Remove No stickers yet + SEND STICKER Sorry, you have reached the maximum number of sticker sets. Reset all notification settings to default @@ -540,6 +542,7 @@ Terminate All Other Sessions Events Contact joined Telegram + Pinned Messages Language Please note that Telegram Support is done by volunteers. We try to respond as quickly as possible, but it may take a while.
]]>Please take a look at the Telegram FAQ]]>: it has answers to most questions and important tips for troubleshooting]]>.
Ask a volunteer @@ -551,8 +554,10 @@ Incorrect localization file Enabled Disabled - Notifications Service - If Google Play Services are enough for you to receive notifications, you can disable Notifications Service. However we recommend you to leave it enabled to keep app running in background and receive instant notifications. + Keep-Alive Service + Relaunch app when shut down by user or system. This will ensure app can show notifications. + Background Connection + Keep a low impact background connection to Telegram to receive notifications. Enable for reliable notifications. Sort By Import Contacts First name @@ -933,7 +938,15 @@ Are you sure you want to terminate all other sessions? Are you sure you want to delete and leave the group? Are you sure you want to delete this chat? - Are you sure you want to share your contact info? + Share your location? + This will send your current location to the bot. + App was unable to determine your current location + Choose manually + This bot would like to know your location each time you send it a request. This can be used to provide location-specific results. + Share your phone number? + The bot will know your phone number. This can be useful for integration with other services. + Are you sure you want to share your phone number %1$s with ]]>%2$s]]>? + Are you sure you want to share your phone number? Are you sure you want to block this contact? Are you sure you want to unblock this contact? Are you sure you want to delete this contact? @@ -956,11 +969,13 @@ Please allow Telegram to receive SMS so that we can automatically enter your code for you. Please allow Telegram to receive calls so that we can automatically enter your code for you. Please allow Telegram to receive calls and SMS so that we can automatically enter your code for you. + Sorry, you are not allowed to do this. Telegram needs access to your contacts so that you can connect with your friends across all your devices. Telegram needs access to your storage so that you can send and save photos, videos, music and other media. Telegram needs access to your microphone so that you can send voice messages. Telegram needs access to your location so that you can share it with your friends. + Telegram needs access to your location. SETTINGS Telegram diff --git a/TMessagesProj/src/main/res/values/styles.xml b/TMessagesProj/src/main/res/values/styles.xml index 444570aed..84bd32693 100644 --- a/TMessagesProj/src/main/res/values/styles.xml +++ b/TMessagesProj/src/main/res/values/styles.xml @@ -42,7 +42,7 @@ @@ -77,4 +77,14 @@ @anim/no_animation + + diff --git a/build.gradle b/build.gradle index 2c397bc2a..7f37cedee 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' + classpath 'com.android.tools.build:gradle:2.1.0-beta3' + classpath 'com.google.gms:google-services:2.1.0-alpha3' } } \ No newline at end of file